[FFmpeg-devel] [PATCH 3/6] avfilter/vf_zscale: strip metadata on change

Niklas Haas ffmpeg at haasn.xyz
Fri Apr 26 15:28:00 EEST 2024


From: Niklas Haas <git at haasn.dev>

Required for both size chnages 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 45f1bd25ce..c012464615 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -783,7 +783,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;
 
@@ -880,6 +880,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_FRAME_CHANGED_SIZE;
+        if (out->color_trc != in->color_trc || out->color_primaries != in->color_primaries)
+            changed |= AV_FRAME_CHANGED_COLOR_VOLUME;
+        av_frame_remove_side_data_changed(out, changed);
+
         td.in = in;
         td.out = out;
         td.desc = desc;
-- 
2.44.0



More information about the ffmpeg-devel mailing list