[FFmpeg-devel] [RFC] Global or local variables in ffmpeg.c

Stefano Sabatini stefano.sabatini-lala
Sat Sep 15 22:20:14 CEST 2007

On date Saturday 2007-09-15 16:14:52 -0300, Ramiro Polla encoded:
> Hello,
> In [1], it was discussed whether variables passed to av_encode would be 
> passed as arguments or used as globals.
> Since the beginning of ffmpeg, they have been defined globals, are 
> passed as arguments to av_encode, and av_encode uses the same local name 
> as the global variables for them.
> The arguments to av_encode are useless. Regression tests still pass for 
> av_encode(void).
> I'm trying to finish Limin Wang's work to split av_encode, but don't 
> know which way to go.
> Which way is preferable: making everything global variables and have 
> parameter-less functions in ffmpeg.c, or passing something like 
> AVTranscodeContext to av_encode and other functions?

With global variables the code should be slightly simpler and faster,
since there is no need to access the context struct. 

On the other hand with a context struct then it would be simpler to
isolate the transcoding functionality from the options acquisition
mechanism. In this way it would be also straightforward to implement
different interfaces (api, command line parsing, gui?) to the same
transcoding functionality and export it to external applications,
which would be definitively a *nice* thing.

But I know that to achieve this isn't trivial, and maybe it also
requires a major rework of the FFmpeg options system.

My two cents.

Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)

More information about the ffmpeg-devel mailing list