[FFmpeg-devel] [PATCH 1/3] lavu: add a template for refcounted objects.

Alexander Strasser eclipse7 at gmx.net
Mon Jul 6 20:53:09 EEST 2020


Hi all!

On 2020-07-01 17:05 +0200, Anton Khirnov wrote:
> Quoting Nicolas George (2020-06-27 17:16:44)
> > Signed-off-by: Nicolas George <george at nsup.org>
> > ---
> >  libavutil/avrefcount_template.h | 140 ++++++++++++++++++++++++++++++++
> >  tests/ref/fate/source           |   1 +
> >  2 files changed, 141 insertions(+)
> >  create mode 100644 libavutil/avrefcount_template.h
> >
> >
> > I will need to refcount something soon. Recently, the need to stop
> > abusing AVBuffer for all refcounting was mentioned on the list. So here
> > is an attempt at isolating the refcounting itself.
> >
> > This is not the final verion, I will first work on the "something" to
> > make sure it suits the needs. But it is a first version.
> >
> > Anton, I would appreciate if you had a look at this and told me if there
> > is something you strongly dislike about before I have piled too much
> > efforts over it.
>
> Why a template? It seems simpler to add a struct like
> typedef struct AVRefcount {
>     atomic_uint refcount;
>     void       *opaque;
>     void      (*free)(void *opaque);
> } AVRefcount;
> and then embed it in everything that wants to be refcounted. All just
> normal structs and functions, no layers of macros.

Maybe we need to be more precise about the goal. Or maybe we need
to find a common goal.

So my first question in this direction is:
What do we want? Do we want to make reference counting available
for internal and FFmpeg-external use?

If we want to generalize for internal use I think Nicolas' proposal
has advantages. Not because of performance, but because it makes
the definition of ref-counted types easier and more uniformly
manageable.

If we want to export ref counting, so lavu users can use it for
their own types too, I would tend to what Anton proposed.

I can go more into detail about the why, but I think we need
to find the wanted direction first.


Best regards,
  Alexander


More information about the ffmpeg-devel mailing list