Skip to content

Commit

Permalink
avfilter/vf_scale: reset color properties if a conversion was done
Browse files Browse the repository at this point in the history
Utilizes newly added swscale API to check if the underlying color
space was changed.

Fixes #9132
  • Loading branch information
jeeb committed Apr 18, 2021
1 parent 4565e0e commit 09abc1e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libavfilter/vf_scale.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,15 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out)
av_frame_copy_props(out, in);
out->width = outlink->w;
out->height = outlink->h;
if (sws_has_colorspace_changed(scale->sws)) {
// av_frame_copy_props unconditionally copies everything,
// so until we get more complex logic on board, if we have
// changed the color space, reset all main values.
out->color_primaries = AVCOL_PRI_UNSPECIFIED;
out->color_trc = AVCOL_TRC_UNSPECIFIED;
out->colorspace = AVCOL_SPC_UNSPECIFIED;
out->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
}

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);
Expand Down

0 comments on commit 09abc1e

Please sign in to comment.