[FFmpeg-devel] [PATCH v2] avutil/frame: add av_frame_replace

Anton Khirnov anton at khirnov.net
Tue Jun 7 14:47:32 EEST 2022


Quoting James Almer (2022-06-07 13:39:55)
> >> diff --git a/libavutil/frame.h b/libavutil/frame.h
> >> index 33fac2054c..e5c10e2b66 100644
> >> --- a/libavutil/frame.h
> >> +++ b/libavutil/frame.h
> >> @@ -752,6 +752,19 @@ void av_frame_free(AVFrame **frame);
> >>    */
> >>   int av_frame_ref(AVFrame *dst, const AVFrame *src);
> >>   
> >> +/**
> >> + * Ensure the destination frame refers to the same data described by the source
> >> + * frame by creating a new reference for each AVBufferRef from src if they
> >> + * differ from those in dst, or if src is not reference counted, by allocating
> >> + * new buffers and copying data.
> >> + *
> >> + * Frame properties on dst will be replaced by those from src.
> >> + *
> >> + * @return 0 on success, a negative AVERROR on error. On error, dst is
> >> + *         unreferenced.
> >> + */
> >> +int av_frame_replace(AVFrame *dst, const AVFrame *src);
> > 
> > An important property of av_buffer_replace() is that it's equivalent to
> > av_buffer_unref(dst) when src is NULL. It would probably be desirable
> > for av_frame_replace() to work the same way - currently it will try to
> > call av_frame_get_buffer() with invalid parameters and fail.
> 
> Should it really accept NULL as src, or you meant a recently 
> allocated/unreff'd frame as src (So src->data[0] == NULL)?

I mean an equivalent of NULL buffer, so an empty (but non-NULL) frame.
So all of src->data[] == NULL (some hwaccel pixfmts store things only in
data[3] for hysterical raisins).

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list