diff mbox series

[FFmpeg-devel,2/6] avfilter/vf_scale*: strip metadata on size change

Message ID 20240426122803.19967-2-ffmpeg@haasn.xyz
State New
Headers show
Series [FFmpeg-devel,1/6] avutil/frame: add av_frame_remove_side_data_changed | expand

Checks

Context Check Description
yinshiyou/configure_loongarch64 warning Failed to apply patch

Commit Message

Niklas Haas April 26, 2024, 12:27 p.m. UTC
From: Niklas Haas <git@haasn.dev>

---
 libavfilter/vf_scale.c        | 2 ++
 libavfilter/vf_scale_cuda.c   | 3 +++
 libavfilter/vf_scale_npp.c    | 3 +++
 libavfilter/vf_scale_vaapi.c  | 3 +++
 libavfilter/vf_scale_vt.c     | 3 +++
 libavfilter/vf_scale_vulkan.c | 3 +++
 6 files changed, 17 insertions(+)
diff mbox series

Patch

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 1c07daeddf..7b9be039ad 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -870,6 +870,8 @@  scale:
     out->height = outlink->h;
     out->color_range = outlink->color_range;
     out->colorspace = outlink->colorspace;
+    if (out->width != in->width || out->height != in->height)
+        av_frame_remove_side_data_changed(out, AV_FRAME_CHANGED_SIZE);
 
     if (scale->output_is_pal)
         avpriv_set_systematic_pal2((uint32_t*)out->data[1], outlink->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : outlink->format);
diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c
index 5571a52b1e..1e381d6e52 100644
--- a/libavfilter/vf_scale_cuda.c
+++ b/libavfilter/vf_scale_cuda.c
@@ -525,6 +525,9 @@  static int cudascale_scale(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
     if (ret < 0)
         return ret;
 
+    if (out->width != in->width || out->height != in->height)
+        av_frame_remove_side_data_changed(out, AV_FRAME_CHANGED_SIZE);
+
     return 0;
 }
 
diff --git a/libavfilter/vf_scale_npp.c b/libavfilter/vf_scale_npp.c
index 27e5e584ae..ed09f4f301 100644
--- a/libavfilter/vf_scale_npp.c
+++ b/libavfilter/vf_scale_npp.c
@@ -892,6 +892,9 @@  scale:
     if (ret < 0)
         return ret;
 
+    if (out->width != in->width || out->height != in->height)
+        av_frame_remove_side_data_changed(out, AV_FRAME_CHANGED_SIZE);
+
     return 0;
 }
 
diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
index 5f20b8a43c..cf7af5c68e 100644
--- a/libavfilter/vf_scale_vaapi.c
+++ b/libavfilter/vf_scale_vaapi.c
@@ -137,6 +137,9 @@  static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
     if (err < 0)
         goto fail;
 
+    if (output_frame->width != input_frame->width || output_frame->height != input_frame->height)
+        av_frame_remove_side_data_changed(output_frame, AV_FRAME_CHANGED_SIZE);
+
     if (ctx->colour_primaries != AVCOL_PRI_UNSPECIFIED)
         output_frame->color_primaries = ctx->colour_primaries;
     if (ctx->colour_transfer != AVCOL_TRC_UNSPECIFIED)
diff --git a/libavfilter/vf_scale_vt.c b/libavfilter/vf_scale_vt.c
index af4a8b32c6..085f14d5fe 100644
--- a/libavfilter/vf_scale_vt.c
+++ b/libavfilter/vf_scale_vt.c
@@ -141,6 +141,9 @@  static int scale_vt_filter_frame(AVFilterLink *link, AVFrame *in)
     if (ret < 0)
         goto fail;
 
+    if (out->width != in->width || out->height != in->height)
+        av_frame_remove_side_data_changed(out, AV_FRAME_CHANGED_SIZE);
+
     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,
diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c
index 7210509de3..957f99a4d5 100644
--- a/libavfilter/vf_scale_vulkan.c
+++ b/libavfilter/vf_scale_vulkan.c
@@ -288,6 +288,9 @@  static int scale_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
     if (err < 0)
         goto fail;
 
+    if (out->width != in->width || out->height != in->height)
+        av_frame_remove_side_data_changed(out, AV_FRAME_CHANGED_SIZE);
+
     if (s->out_range != AVCOL_RANGE_UNSPECIFIED)
         out->color_range = s->out_range;
     if (s->vkctx.output_format != s->vkctx.input_format)