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

Michael Niedermayer michaelni
Fri Jul 27 14:17:25 CEST 2007


Hi

On Fri, Jul 27, 2007 at 02:02:50PM +0200, Alex Beregszaszi wrote:
> 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.

true, sorry ive missed that possibility when i changed it ...

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I count him braver who overcomes his desires than him who conquers his
enemies for the hardest victory is over self. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/attachments/20070727/5d44aa02/attachment.pgp>



More information about the ffmpeg-cvslog mailing list