[FFmpeg-devel] [PATCH] RPL demuxer

Rich Felker dalias
Sat Nov 3 02:16:14 CET 2007


On Sat, Nov 03, 2007 at 12:56:42AM +0100, Michael Niedermayer wrote:
> On Sat, Nov 03, 2007 at 12:04:01AM +0100, Aurelien Jacobs wrote:
> [...]
> > > +	rpl->author = b;
> > > +
> > > +	i++;
> > > +
> > > +	sscanf(buffer + so[i], "%i", &rpl->video_format);
> > > +
> > > +	i++;
> > > +
> > > +	sscanf(buffer + so[i], "%i", &rpl->video_width);
> > 
> > All those i++ lines and empty lines make the code much longer than needed.
> > I would prefer seeing something like:
> > 
> > +	sscanf(buffer + so[i++], "%i", &rpl->video_format);
> > +	sscanf(buffer + so[i++], "%i", &rpl->video_width);
> 
> even better would be IMHO:
> rpl->video_format= atoi(buffer + so[i++]);
> rpl->video_width = atoi(buffer + so[i++]);

Functionality is not the same. sscanf with %i will read 010 as 8 while
atoi will read 010 as 10. Also %i will interpret 0x1 as 1 while atoi
will interpret it as a 0 followed by junk. Behavior matching %i can be
obtained by using strtol with 0 for the base argument, but I wonder
which is actually the correct behavior here and if anyone's even
thought about it...

Rich




More information about the ffmpeg-devel mailing list