From 0c4cb3d1539fefa66c05d131385e35fb2a205fa3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 4 Dec 2023 20:01:15 -0800 Subject: [PATCH] Fixed warning C26451: Arithmetic overflow: Using operator '<<' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '<<' to avoid overflow (io.2). --- src/video/yuv2rgb/yuv_rgb.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/video/yuv2rgb/yuv_rgb.c b/src/video/yuv2rgb/yuv_rgb.c index bf4002014a..f24b27b4f6 100644 --- a/src/video/yuv2rgb/yuv_rgb.c +++ b/src/video/yuv2rgb/yuv_rgb.c @@ -31,6 +31,11 @@ typedef struct // |G| = 1/PRECISION_FACTOR * |y_factor u_g_factor v_g_factor| * | U-128 | // |B| |y_factor u_b_factor 0 | | V-128 | +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 26451) +#endif + #define V(value) (int16_t)((value*PRECISION_FACTOR)+0.5) // for ITU-T T.871, values can be found in section 7 @@ -56,6 +61,10 @@ static const RGB2YUVParam RGB2YUV[3] = { {/*.y_shift=*/ 16, /*.matrix=*/ {{V(0.1826), V(0.6142), V(0.062)}, {-V(0.1006), -V(0.3386), V(0.4392)}, {V(0.4392), -V(0.3989), -V(0.0403)}}} }; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + /* The various layouts of YUV data we support */ #define YUV_FORMAT_420 1 #define YUV_FORMAT_422 2