[FFmpeg-devel] [PATCH 1/2] doc/examples/demuxing: show how to use the reference counting system.

wm4 nfxjfg at googlemail.com
Thu Oct 31 12:18:11 CET 2013


On Thu, 31 Oct 2013 11:57:24 +0100
Clément Bœsch <u at pkh.me> wrote:

> On Thu, Oct 31, 2013 at 11:50:14AM +0100, wm4 wrote:
> > On Thu, 31 Oct 2013 11:13:30 +0100
> > Clément Bœsch <u at pkh.me> wrote:
> > 
> > > On Thu, Oct 31, 2013 at 10:53:00AM +0100, wm4 wrote:
> > > > On Wed, 30 Oct 2013 16:28:51 +0100
> > > > Clément Bœsch <u at pkh.me> wrote:
> > > > 
> > > > > From: Clément Bœsch <clement at stupeflix.com>
> > > > > 
> > > > > ---
> > > > >  doc/examples/demuxing.c | 44 ++++++++++++++++++++++++++++++++++++++------
> > > > >  1 file changed, 38 insertions(+), 6 deletions(-)
> > > > > 
> > > > > diff --git a/doc/examples/demuxing.c b/doc/examples/demuxing.c
> > > > > index 7ae3654..379b1ea 100644
> > > > > --- a/doc/examples/demuxing.c
> > > > > +++ b/doc/examples/demuxing.c
> > > > > @@ -53,6 +53,11 @@ static AVPacket pkt;
> > > > >  static int video_frame_count = 0;
> > > > >  static int audio_frame_count = 0;
> > > > >  
> > > > > +/* This flag is used to make decoding using ref counting or not. In practice,
> > > > > + * you choose one way or another; ref counting notably allowing you to keep the
> > > > > + * data as long as you wish. */
> > > > > +static int use_ref_counting = 0;
> > > > 
> > > > Why confuse people with providing both? That's just confusing. In fact
> > > > I'd expect that the API without reference counting would be removed
> > > > sooner or later.
> > > > 
> > > 
> > > I'm assuming it could be helpful when moving code from the old to the new
> > > API. Also, the new one requires more non-intuitive code (setting an
> > > obscure option).
> > > 
> > > Are you sure the API without ref counting is supposed to be dropped? Where
> > > is that mentioned?
> > 
> > Libav basically said "eventually, probably", so at least there are no
> > definitive plans to this, but it might happen.
> > 
> > In general, whether the API does refcounting or not doesn't matter
> > for an API user who is not interested in refcounting. The user can
> > just use av_frame_alloc and av_frame_free at start and end of decoding,
> > and ignore the fact that they're really reference counted.
> > 
> 
> And unref the frame manually after each decode (so you actually need to
> understand the ref counting system when using it). This is another
> addition from the old method.

You're right, unexpectedly this is required.

> Or maybe what you mean is that you can also use the new API without
> setting the refcount option, in which case you must not unref the frame
> after each decode?

I was assuming it does unref on its own. Although that should be
trivial to add (two lines in libavcodec/utils.c). Anyway, nobody seems
to understand why a simple API that has a single way to accomplish
something is a good idea, so I give up.


More information about the ffmpeg-devel mailing list