[FFmpeg-devel] [RFC] Reintroduce sws_getContext() as sws_create_context()

Reimar Döffinger Reimar.Doeffinger
Fri Nov 5 16:52:50 CET 2010


On Thu, Nov 04, 2010 at 08:46:10PM +0100, Stefano Sabatini wrote:
> libavcodec API:
> 
> avcodec_alloc_context() -> creates a non-opaque context, sets the
> fields to the default values.
> 
> the options can be set explicitely setting the fields or using the 
> libavutil/opt.h API.
> 
> avcodec_open() -> opens the context, fails in case of invalid parameters

You are leaving out the helper functions like
avcodec_find_decoder_by_name, avcodec_thread_init and similar.

> libswscale (new) API:
> 
> swsc_alloc_context() -> creates an opaque context, sets the values to
> the default values (check libswscale/options.c).
> 
> The context is opaque, the options can only be set using the
> sws_setColorspaceDetails() or the libavutil/opt.h API.
> 
> swscale_init_context() sets the src and dst filters and intializes the
> context, fails if the options are not valid, at this point (I
> suppose) options should not be changed again when using the context.

The flaw is that sws_setColorspaceDetails requires people to specify
things that are a pain to set up (note e.g. ff_yuv2rgb_coeffs is
not public API) and probably 90% of people don't give a damn about,
while at the same time you have to set width, height, format, ...
in the struct one by one making you feel like eating soup with a fork.
I don't have a constructive suggestion to make right now (for that
it might be good to try to see which (non-user-provided) options
the "average" libswscale user needs to set and provide a function
to set them in one go (or two).
In the mean time, sws_getCachedContext is the dirty secret for
anyone not wanting to bother with the new API...



More information about the ffmpeg-devel mailing list