[FFmpeg-devel] [PATCH v6 5/8] avfilter/avfilter: Add avfilter_link_get_hw_frames_ctx()

Stefano Sabatini stefasab at gmail.com
Tue Mar 11 00:11:10 EET 2025


On date Saturday 2025-03-08 20:16:31 +0000, softworkz wrote:
> From: softworkz <softworkz at hotmail.com>
> 
> ---
>  doc/APIchanges         |  3 +++
>  libavfilter/avfilter.c |  9 +++++++++
>  libavfilter/avfilter.h | 12 ++++++++++++
>  libavfilter/version.h  |  2 +-
>  4 files changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 5a64836e25..354716399d 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
>  
>  API changes, most recent first:
>  

> +2025-02-xx - xxxxxxxxxx - lavfi 10.10.100 - avfilter.h
> +  Add avfilter_link_get_hw_frames_ctx().
> +
>  2025-03-01 - xxxxxxxxxx - lavu 59.58.100 - pixfmt.h
>    Add AV_PIX_FMT_GRAY32BE and AV_PIX_FMT_GRAY32LE.

Unrelated but we should automate this xxx filling.

> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index e732556ffa..13abd7e8ad 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -1006,6 +1006,15 @@ enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
>      return pads[pad_idx].type;
>  }
>  
> +AVBufferRef *avfilter_link_get_hw_frames_ctx(AVFilterLink *link)
> +{

> +    FilterLink* plink = ff_filter_link(link);

nit: FilterLink *plink style is more kosher

> +    if (plink->hw_frames_ctx)
> +        return av_buffer_ref(plink->hw_frames_ctx);
> +
> +    return NULL;
> +}
> +
>  static int default_filter_frame(AVFilterLink *link, AVFrame *frame)
>  {
>      return ff_filter_frame(link->dst->outputs[0], frame);
> diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
> index 4520d5f978..27c50520b3 100644
> --- a/libavfilter/avfilter.h
> +++ b/libavfilter/avfilter.h
> @@ -96,6 +96,18 @@ const char *avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx);
>   */
>  enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx);
>  
> +/**
> + * Get the hardware frames context of a filter link.
> + *
> + * @param link an AVFilterLink
> + *

> + * @return a ref-counted copy of the link's hw_frames_ctx if there's a hardware

of the link's hw_frames_ctx *field* ...

> + *         frames context associated with the link or NULL otherwise.
> + *         The returned AVBufferRef needs to be released with av_buffer_unref()
> + *         when it's no longer used.

nit++: "there is... it is..." to aid non-native readers

[...]

Looks good to me otherwise.


More information about the ffmpeg-devel mailing list