[FFmpeg-devel] [PATCH] avfilter: propagate colorspace and color_range from buffer filter and between AVFilterLink.

Niklas Haas ffmpeg at haasn.xyz
Sat Mar 23 14:11:58 EET 2024


On Fri, 22 Mar 2024 22:02:39 +0100 Damiano Galassi <damiog at gmail.com> wrote:
> There two new fields were never sent down the filter chain, and no filter after the first had colorspace and color_range set, causing breakage in zscale and possible other filters.
> ---
>  libavfilter/avfilter.c  | 4 ++++
>  libavfilter/buffersrc.c | 2 ++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index 831871de90..153fb700d3 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -391,6 +391,10 @@ int ff_filter_config_links(AVFilterContext *filter)
>                          link->w = inlink->w;
>                      if (!link->h)
>                          link->h = inlink->h;
> +                    if (link->colorspace == AVCOL_SPC_UNSPECIFIED)
> +                        link->colorspace = inlink->color_range;
> +                    if (link->color_range == AVCOL_RANGE_UNSPECIFIED)
> +                        link->color_range = inlink->color_range;
>                  } else if (!link->w || !link->h) {
>                      av_log(link->src, AV_LOG_ERROR,
>                             "Video source filters must set their output link's "
> diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
> index ddcd403785..2760097edf 100644
> --- a/libavfilter/buffersrc.c
> +++ b/libavfilter/buffersrc.c
> @@ -499,6 +499,8 @@ static int config_props(AVFilterLink *link)
>          link->w = c->w;
>          link->h = c->h;
>          link->sample_aspect_ratio = c->pixel_aspect;
> +        link->colorspace = c->color_space;
> +        link->color_range = c->color_range;
>  
>          if (c->hw_frames_ctx) {
>              link->hw_frames_ctx = av_buffer_ref(c->hw_frames_ctx);

LGTM, good catch!


More information about the ffmpeg-devel mailing list