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

Nicolas George george at nsup.org
Wed Jul 1 19:47:15 EEST 2020


Anton Khirnov (12020-07-01):
> instead of
> #define AVRC_TYPE AVBuffer
> #define AVRC_PREFIX prefix
> #define AVRC_FIELD refcount
> you'd have
> av_refcount_init(&buf->refcount, buf, buffer_free);
> Does not look more annoying to me, to the contrary macro templates
> require more effort to understand or debug.

The annoying part is to have to dereference buf->opaque each time we
need to use it. It clutters all the code that use a structure. It is
completely unacceptable to me.

> Why? I do not see how an extra pointer dereference could possibly matter here.

It does not matter much, but in tights loops it can.

> In my experience, providing the wrong opaque pointer has never been a
> common source of bugs (and is typically easily noticeable if it does
> happen), so I see that as an acceptable tradeoff.

Acceptable, certainly. But I prefer static type safety whenever
possible, especially when it comes with the other benefits.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200701/fdd9e1bf/attachment.sig>


More information about the ffmpeg-devel mailing list