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

Michael Niedermayer michaelni
Thu Nov 4 22:15:59 CET 2010

On Thu, Nov 04, 2010 at 08:46:10PM +0100, Stefano Sabatini wrote:
> On date Thursday 2010-11-04 17:07:16 +0100, Cyril Russo encoded:
> > Hi,
> > 
> >   I'm a FFmpeg library user. Recently, you've deprecated
> > sws_getContext telling to use sws_alloc_context & sws_init_context
> > instead.
> > This looks like a bad choice to me, as they are not equivalent.

I think the current situation can be described as the old API being deprecated
and the new not being fully documented yet and possibly also not 100% guranteed
to not change.
as stefano said, adding of the deprecated attribute was maybe slightly

> >
> > First, sws_getContext had these avantages:
> > 1) Library's user didn't need to know what the SwsContext content was.

SwsContext is still a private struct

> > 2) All in one function, with no possible error in handling the return code.
> > 
> > And these cons: (so far as I can understand)
> > 1) not the same naming convention as the other libraries in FFmpeg project
> > 2) API is fixed.
> > 
> > In my opinion, new code have these defects:
> > 1) sws_init_context meaning isn't clear. What is it used for ? Why
> > is there no equivalent to this init function in other libraries ?

> > 2) SwsContext isn't described in swscale.h file, but it's required
> > to set its member if you want to actually use the context.

It is a private struct as said.

> > 3) Since SwsContext structure can change, the user code (mine) could
> > break if you rename/remove a member of the struct.

It is a private struct as said so this problem does not exist
The correct way is to access is via av_set_int() and its friends
The old api still exists and other ways may be provided to access it if the
need arrises

> > 4) sws_getCachedContext is still here but not deprecated, and the
> > documentation refer to sws_getContext.
> > 5) I finally have to duplicate the getContext code in my code, and
> > handle all the possible errors myself.
> > 
> > For me, I would prefer the "blackbox" idea, and having a function
> > that does the dirty work of filling the opaque structure member
> > correctly, and not having to deal with it.

we have that, its av_set_int/av_set_string ...


Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA
-------------- 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/20101104/9ce8e957/attachment.pgp>

More information about the ffmpeg-devel mailing list