avfilter/vf_scale*: strip metadata on size change

This commit is contained in:
Niklas Haas 2024-04-26 12:56:35 +02:00
parent b88944a8aa
commit f22965b882
6 changed files with 33 additions and 10 deletions

View file

@ -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,

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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)

View file

@ -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,

View file

@ -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)