diff options
author | Jan Ekström <[email protected]> | 2021-08-29 00:38:29 +0300 |
---|---|---|
committer | Jan Ekström <[email protected]> | 2021-09-06 09:11:25 +0300 |
commit | b1f2d203c0232dcb861f795e8958ed43b4da21da (patch) | |
tree | 4b6eb557897e84ab04131617cc5cecba8fd60898 | |
parent | ae057cec10b454da6ad5e2891d6898c8f0f787ca (diff) |
avfilter/vf_scale: set the RGB matrix coefficients in case of RGB
This fixes the passing through of non-RGB matrix from input to
output when conversion from YCbCr to RGB happens.
(cherry picked from commit 2818b143929d86f6b67695b09bc7483da5cef434)
-rw-r--r-- | libavfilter/vf_scale.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 6e2294a4d2..3ca6ba2368 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -739,13 +739,16 @@ scale: out->width = outlink->w; out->height = outlink->h; - // Sanity check: If we've got the RGB/XYZ (identity) matrix configured, and - // the output is no longer RGB, unset the matrix. - // In theory this should be in swscale itself as the AVFrame - // based API gets in, so that not every swscale API user has - // to go through duplicating such sanity checks. - if (out->colorspace == AVCOL_SPC_RGB && - !(av_pix_fmt_desc_get(out->format)->flags & AV_PIX_FMT_FLAG_RGB)) + // Sanity checks: + // 1. If the output is RGB, set the matrix coefficients to RGB. + // 2. If the output is not RGB and we've got the RGB/XYZ (identity) + // matrix configured, unset the matrix. + // In theory these should be in swscale itself as the AVFrame + // based API gets in, so that not every swscale API user has + // to go through duplicating such sanity checks. + if (av_pix_fmt_desc_get(out->format)->flags & AV_PIX_FMT_FLAG_RGB) + out->colorspace = AVCOL_SPC_RGB; + else if (out->colorspace == AVCOL_SPC_RGB) out->colorspace = AVCOL_SPC_UNSPECIFIED; if (scale->output_is_pal) |