[FFmpeg-devel] [PATCH v3 5/8] avfilter/vf_zscale: strip metadata on change

Niklas Haas ffmpeg at haasn.xyz
Mon Dec 23 14:48:46 EET 2024


From: Niklas Haas <git at haasn.dev>

Required for both size changes and color volume changes (as a result of
changing primaries/transfer).
---
 libavfilter/vf_zscale.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index e456053b4e..569d0382ca 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -781,7 +781,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
     const AVPixFmtDescriptor *odesc = av_pix_fmt_desc_get(outlink->format);
     char buf[32];
-    int ret = 0;
+    int ret = 0, changed = 0;
     AVFrame *out = NULL;
     ThreadData td;
 
@@ -875,6 +875,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
                   (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
                   INT_MAX);
 
+        if (out->width != in->width || out->height != in->height)
+            changed |= AV_SIDE_DATA_PROP_SIZE_DEPENDENT;
+        if (out->color_trc != in->color_trc || out->color_primaries != in->color_primaries)
+            changed |= AV_SIDE_DATA_PROP_COLOR_DEPENDENT;
+        av_frame_side_data_remove_by_props(&out->side_data, &out->nb_side_data, changed);
+
         td.in = in;
         td.out = out;
         td.desc = desc;
-- 
2.47.0



More information about the ffmpeg-devel mailing list