[FFmpeg-devel] [PATCH 2/3] lavf: replace all uses of url_fskip with avio_seek

Michael Niedermayer michaelni
Wed Mar 2 16:31:51 CET 2011


On Wed, Mar 02, 2011 at 10:17:14AM -0500, Ronald S. Bultje wrote:
> Hi,
> 
> On Wed, Mar 2, 2011 at 8:29 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Wed, Mar 02, 2011 at 08:11:48AM -0500, Ronald S. Bultje wrote:
> >> On Wed, Mar 2, 2011 at 8:01 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> >> > On Mon, Feb 28, 2011 at 02:57:55PM +0100, Anton Khirnov wrote:
> >> > [...]
> >> >> diff --git a/libavformat/aea.c b/libavformat/aea.c
> >> >> index 8316a7e..60b2d38 100644
> >> >> --- a/libavformat/aea.c
> >> >> +++ b/libavformat/aea.c
> >> >> @@ -62,9 +62,9 @@ static int aea_read_header(AVFormatContext *s,
> >> >> ? ? ? ? ?return AVERROR(ENOMEM);
> >> >>
> >> >> ? ? ?/* Parse the amount of channels and skip to pos 2048(0x800) */
> >> >> - ? ?url_fskip(s->pb, 264);
> >> >> + ? ?avio_seek(s->pb, 264, SEEK_CUR);
> >> >> ? ? ?st->codec->channels = avio_r8(s->pb);
> >> >> - ? ?url_fskip(s->pb, 1783);
> >> >> + ? ?avio_seek(s->pb, 1783, SEEK_CUR);
> >> >
> >> > another worsening of the API
> >>
> >> How?
> >
> > 1 argument more that is always the same
> >
> >
> >>
> >> We have two functions (seek(SEEK_CUR) and skip) that do the same
> >> thing. Why not merge them together, optimize that correctly for the
> >> corner cases where possible (data is in buffer, etc.), and otherwise
> >> drop the other?
> >
> > same reason as printf() vs. fprintf(stdout)
> > and ?a+= b vs. a= a+b
> >
> > the shorter form exists because it is very common and more readable.
> 
> I'm fine with a macro that defines avio_skip or ffio_skip to
> avio_seek(SEEK_CUR).

a function is better than a macro for this. Because it avoids passing the 3rd
argument in >300 calls.
With a function the code is smaller in terms of bytes in the object files

for a human the API complexity is also slightly lower with a function than a
macro that looks like a function. The reason is that macros dont behave the
same as functions, for example if someone tried to use it with a
function pointer.

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

Incandescent light bulbs waste a lot of energy as heat so the EU forbids them.
Their replacement, compact fluorescent lamps, much more expensive, dont fit in
many old lamps, flicker, contain toxic mercury, produce a fraction of the light
that is claimed and in a unnatural spectrum rendering colors different than
in natural light. Ah and we now need to turn the heaters up more in winter to
compensate the lower wasted heat. Who wins? Not the environment, thats for sure
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110302/10a4a8bc/attachment.pgp>



More information about the ffmpeg-devel mailing list