[FFmpeg-cvslog] r9808 - trunk/libavformat/utils.c

Alex Beregszaszi alex
Fri Jul 27 14:02:50 CEST 2007


Hi,
     1. 
> >>  enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag)
> >>  {
> >> -    while (tags->id != CODEC_ID_NONE) {
> >> -        if(   toupper((tag >> 0)&0xFF) == toupper((tags->tag >> 0)&0xFF)
> >> -           && toupper((tag >> 8)&0xFF) == toupper((tags->tag >> 8)&0xFF)
> >> -           && toupper((tag >>16)&0xFF) == toupper((tags->tag >>16)&0xFF)
> >> -           && toupper((tag >>24)&0xFF) == toupper((tags->tag >>24)&0xFF))
> >> -            return tags->id;
> >> -        tags++;
> >> +    int i;
> >> +    for(i=0; tags[i].id != CODEC_ID_NONE;i++) {
> >> +        if(tag == tags[i].tag)
> >> +            return tags[i].id;
> >> +    }
> >> +    for(i=0; tags[i].id != CODEC_ID_NONE; i++) {
> >> +        if(   toupper((tag >> 0)&0xFF) == toupper((tags[i].tag >> 0)&0xFF)
> >> +           && toupper((tag >> 8)&0xFF) == toupper((tags[i].tag >> 8)&0xFF)
> >> +           && toupper((tag >>16)&0xFF) == toupper((tags[i].tag >>16)&0xFF)
> >> +           && toupper((tag >>24)&0xFF) == toupper((tags[i].tag >>24)&0xFF))
> >> +            return tags[i].id;
> >
> > Why did you cosmetic while -> for change? You go from i=0 thus the while
> > and for cycles are the same.
> 
> The while loop destroys the original value of tags, which is needed
> again at the start of the second loop.  The alternative would be to
> use a temporary tags pointer, resetting it to the original value
> between the two loops.  Only Michael can tell why he prefers the for
> loop.  I don't personally care one way or the other.

No, I meant just moving down the original while loop would do the same.
I can read code too, I know it changes the pointer.

--
Alex






More information about the ffmpeg-cvslog mailing list