[FFmpeg-devel] [PATCH v2 10/16] avfilter/vf_scale: strip metadata when changing colorspace

Niklas Haas ffmpeg at haasn.xyz
Sat Dec 7 23:47:57 EET 2024


On Fri, 06 Dec 2024 10:17:48 -0500 Leo Izen <leo.izen at gmail.com> wrote:
>
>
> On 12/6/24 9:32 AM, Niklas Haas wrote:
> > From: Niklas Haas <git at haasn.dev>
> >
> > This is no longer relevant after a change in color space.
> > ---
> >   libavfilter/vf_scale.c | 12 ++++++++++++
> >   1 file changed, 12 insertions(+)
> >
> > diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
> > index e33617468a..a56d452c6c 100644
> > --- a/libavfilter/vf_scale.c
> > +++ b/libavfilter/vf_scale.c
> > @@ -868,6 +868,18 @@ scale:
> >       if (scale->out_transfer != AVCOL_TRC_UNSPECIFIED)
> >           out->color_trc = scale->out_transfer;
> >
> > +    if (in->color_primaries != out->color_primaries ||
> > +        in->color_trc != out->color_trc)
> > +    {
> > +        av_frame_remove_side_data(out, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
> > +        av_frame_remove_side_data(out, AV_FRAME_DATA_DYNAMIC_HDR_PLUS);
> > +        av_frame_remove_side_data(out, AV_FRAME_DATA_DYNAMIC_HDR_VIVID);
> > +        av_frame_remove_side_data(out, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
> > +        av_frame_remove_side_data(out, AV_FRAME_DATA_ICC_PROFILE);
> > +        av_frame_remove_side_data(out, AV_FRAME_DATA_DOVI_METADATA);
> > +        av_frame_remove_side_data(out, AV_FRAME_DATA_DOVI_RPU_BUFFER);
> > +    }
> > +
> >       av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
> >                 (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
> >                 (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
>
> I think Mastering Display Metadata may still be relevant after a change
> in TRC but not primaries (e.g. after linearization), since it only
> references the gamut of the mastering display.

That is true; but I think I'd rather handle this as a separate patch
that re-attaches a modified / inferred set of MDM reflecting the new state
after tone/gamut mapping.

We need to strip the original and attach a modified copy in either case, and
the status quo after this patch seems no less wrong than not stripping this
metadata. (Otherwise, the behavior you get is something very strange like
HDR-in-SDR curves and other things that one should not get by default)

>
> - Leo Izen (Traneptora)
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list