On 11/5/2017 9:34 AM, Michael Niedermayer wrote: > This gives libavcodec a field that it can freely and safely use. > Avoiding the need of wraping of a users opaque_ref field and its issues.
Could this perhaps be in an opaque internal struct instead, much like AVCodecInternal and whatnot? As wm4 said in the relevant discussion, this approach is nonoptimal and *will* snowball into a mess of fields if other libav* libraries start requiring their own buffers in a frame. An internal field of an opaque struct being in a public header is much cleaner and easier to maintain than adding such specific fields that may at some point in the future need to be removed. No actual comments about the approach in question to solve the issue. Will leave that to someone more knowledgeable. But at least I'm glad something is being done about it. > > Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > --- > libavutil/frame.c | 8 +++++++- > libavutil/frame.h | 10 ++++++++++ > 2 files changed, 17 insertions(+), 1 deletion(-) > > diff --git a/libavutil/frame.c b/libavutil/frame.c > index 982fbb5c81..6ddaef1e74 100644 > --- a/libavutil/frame.c > +++ b/libavutil/frame.c > @@ -383,12 +383,17 @@ FF_ENABLE_DEPRECATION_WARNINGS > #endif > > av_buffer_unref(&dst->opaque_ref); > + av_buffer_unref(&dst->avcodec_private_ref); > if (src->opaque_ref) { > dst->opaque_ref = av_buffer_ref(src->opaque_ref); > if (!dst->opaque_ref) > return AVERROR(ENOMEM); > } > - > + if (src->avcodec_private_ref) { > + dst->avcodec_private_ref = av_buffer_ref(src->avcodec_private_ref); > + if (!dst->avcodec_private_ref) > + return AVERROR(ENOMEM); > + } > return 0; > } > > @@ -524,6 +529,7 @@ void av_frame_unref(AVFrame *frame) > av_buffer_unref(&frame->hw_frames_ctx); > > av_buffer_unref(&frame->opaque_ref); > + av_buffer_unref(&frame->avcodec_private_ref); > > get_frame_defaults(frame); > } > diff --git a/libavutil/frame.h b/libavutil/frame.h > index 0c6aab1c02..73b7d949a9 100644 > --- a/libavutil/frame.h > +++ b/libavutil/frame.h > @@ -563,6 +563,16 @@ typedef struct AVFrame { > /** > * @} > */ > + /** > + * AVBufferRef for free use by libavcodec. Code outside avcodec will > never > + * check or change the contents of the buffer ref. FFmpeg calls > + * av_buffer_unref() on it when the frame is unreferenced. > + * av_frame_copy_props() calls create a new reference with > av_buffer_ref() > + * for the target frame's avcodec_private_ref field. > + * > + * avcodec should never assign mutually incompatible types to this field. > + */ > + AVBufferRef *avcodec_private_ref; > } AVFrame; > > #if FF_API_FRAME_GET_SET > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel