[FFmpeg-cvslog] avfilter/vf_scale*: strip metadata on size change
Niklas Haas
git at videolan.org
Mon Dec 23 15:23:28 EET 2024
ffmpeg | branch: master | Niklas Haas <git at haasn.dev> | Fri Apr 26 12:56:35 2024 +0200| [f22965b8823c92b16c645e7ef5a0ef95b81c7821] | committer: Niklas Haas
avfilter/vf_scale*: strip metadata on size change
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f22965b8823c92b16c645e7ef5a0ef95b81c7821
---
libavfilter/vf_scale.c | 18 ++++++++----------
libavfilter/vf_scale_cuda.c | 5 +++++
libavfilter/vf_scale_npp.c | 5 +++++
libavfilter/vf_scale_vaapi.c | 6 ++++++
libavfilter/vf_scale_vt.c | 4 ++++
libavfilter/vf_scale_vulkan.c | 5 +++++
6 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 566bf11cda..af55c3b7ef 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -868,16 +868,14 @@ scale:
if (scale->out_transfer != -1)
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);
+ if (out->width != in->width || out->height != in->height) {
+ av_frame_side_data_remove_by_props(&out->side_data, &out->nb_side_data,
+ AV_SIDE_DATA_PROP_SIZE_DEPENDENT);
+ }
+
+ if (in->color_primaries != out->color_primaries || in->color_trc != out->color_trc) {
+ av_frame_side_data_remove_by_props(&out->side_data, &out->nb_side_data,
+ AV_SIDE_DATA_PROP_COLOR_DEPENDENT);
}
av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c
index eb8beee771..b9a30e6de9 100644
--- a/libavfilter/vf_scale_cuda.c
+++ b/libavfilter/vf_scale_cuda.c
@@ -536,6 +536,11 @@ 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_side_data_remove_by_props(&out->side_data, &out->nb_side_data,
+ AV_SIDE_DATA_PROP_SIZE_DEPENDENT);
+ }
+
return 0;
}
diff --git a/libavfilter/vf_scale_npp.c b/libavfilter/vf_scale_npp.c
index 0c38987687..89ed709903 100644
--- a/libavfilter/vf_scale_npp.c
+++ b/libavfilter/vf_scale_npp.c
@@ -897,6 +897,11 @@ scale:
if (ret < 0)
return ret;
+ if (out->width != in->width || out->height != in->height) {
+ av_frame_side_data_remove_by_props(&out->side_data, &out->nb_side_data,
+ AV_SIDE_DATA_PROP_SIZE_DEPENDENT);
+ }
+
return 0;
}
diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
index 65db05c23d..78406bbcf3 100644
--- a/libavfilter/vf_scale_vaapi.c
+++ b/libavfilter/vf_scale_vaapi.c
@@ -137,6 +137,12 @@ 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_side_data_remove_by_props(&output_frame->side_data,
+ &output_frame->nb_side_data,
+ AV_SIDE_DATA_PROP_SIZE_DEPENDENT);
+ }
+
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 eff23a6f39..0d612d5338 100644
--- a/libavfilter/vf_scale_vt.c
+++ b/libavfilter/vf_scale_vt.c
@@ -160,6 +160,10 @@ static int scale_vt_filter_frame(AVFilterLink *link, AVFrame *in)
out->crop_top = 0;
out->crop_right = 0;
out->crop_bottom = 0;
+ if (out->width != in->width || out->height != in->height) {
+ av_frame_side_data_remove_by_props(&out->side_data, &out->nb_side_data,
+ AV_SIDE_DATA_PROP_SIZE_DEPENDENT);
+ }
av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
(int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c
index 82641a3bff..c23f7a245d 100644
--- a/libavfilter/vf_scale_vulkan.c
+++ b/libavfilter/vf_scale_vulkan.c
@@ -293,6 +293,11 @@ 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_side_data_remove_by_props(&out->side_data, &out->nb_side_data,
+ AV_SIDE_DATA_PROP_SIZE_DEPENDENT);
+ }
+
if (s->out_range != AVCOL_RANGE_UNSPECIFIED)
out->color_range = s->out_range;
if (s->vkctx.output_format != s->vkctx.input_format)
More information about the ffmpeg-cvslog
mailing list