This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit d7b8f4a9ba0401ed6bf867d2f03bd7cdb08eba25 Author: Kacper Michajłow <[email protected]> AuthorDate: Sat Oct 24 21:02:20 2026 +0200 Commit: Kacper Michajłow <[email protected]> CommitDate: Wed Oct 28 19:22:28 2026 +0000 avfilter/vf_colorspace: refuse a primaries conversion that does not fit the fixed point The linear RGB to RGB matrix is stored as int16 with 14 fractional bits, so a coefficient of 2 or more wraps around. The conversion from the XYZ basis of SMPTE ST 428-1 to BT.709 has one of 3.15, and a neutral (126, 128, 128) came out as (99, 143, 64). Check the coefficients before narrowing them and refuse the conversion. Fast mode does not use the matrix and is not checked, and a refused conversion forgets the primaries, so that the next frame is refused too instead of using the matrix left behind. Signed-off-by: Kacper Michajłow <[email protected]> --- libavfilter/vf_colorspace.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c index 5e78868064..5f0523cae2 100644 --- a/libavfilter/vf_colorspace.c +++ b/libavfilter/vf_colorspace.c @@ -484,7 +484,7 @@ static int create_filtergraph(AVFilterContext *ctx, } s->lrgb2lrgb_passthrough = !memcmp(s->in_primaries, s->out_primaries, sizeof(*s->in_primaries)); - if (!s->lrgb2lrgb_passthrough) { + if (!s->lrgb2lrgb_passthrough && !s->fast_mode) { double rgb2xyz[3][3], xyz2rgb[3][3], rgb2rgb[3][3]; const AVWhitepointCoefficients *wp_out, *wp_in; @@ -506,7 +506,18 @@ static int create_filtergraph(AVFilterContext *ctx, } for (m = 0; m < 3; m++) for (n = 0; n < 3; n++) { - s->lrgb2lrgb_coeffs[m][n][0] = lrint(16384.0 * rgb2rgb[m][n]); + long coeff = lrint(16384.0 * rgb2rgb[m][n]); + if (coeff < INT16_MIN || coeff > INT16_MAX) { + av_log(ctx, AV_LOG_ERROR, + "Conversion from %s to %s primaries does not fit " + "the fixed point range of the filter\n", + av_color_primaries_name(s->in_prm), + av_color_primaries_name(s->out_prm)); + s->in_primaries = NULL; + s->out_primaries = NULL; + return AVERROR(EINVAL); + } + s->lrgb2lrgb_coeffs[m][n][0] = coeff; for (o = 1; o < 8; o++) s->lrgb2lrgb_coeffs[m][n][o] = s->lrgb2lrgb_coeffs[m][n][0]; } -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
