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

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Aug 13 18:27:06 EEST 2021


James Almer:
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
> Not going to bother with implementing replace for side data, since it's IMO not
> worth it, but patches are welcome of course.
> 
> Missing version bump and APIchanges entry.
> 
>  libavutil/frame.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++
>  libavutil/frame.h | 18 +++++++++
>  2 files changed, 116 insertions(+)
> 
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index ff2540a20f..36ed128886 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -695,6 +695,24 @@ 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.
> + *
> + * Copy frame properties from src to dst and create a new reference for each
> + * AVBufferRef from src if they differ from those in dst.
> + *
> + * src must be reference counted.
> + *
> + * @param src The source frame. If there's data described in it, it must be
> + *            reference counted.
> + * @param dst The destination frame.
> + *
> + * @return 0 on success, a negative AVERROR on error. On error, dst is
> + *         unreferenced.
> + */
> +int av_frame_replace(AVFrame *dst, const AVFrame *src);
> +
>  /**
>   * Create a new frame that references the same data as src.
>   *
> 
av_buffer_replace() is a no-op if src == dst (and documented to be so);
this is not true for this function where you instantly wipe side data.

- Andreas


More information about the ffmpeg-devel mailing list