From 8980362eedbe3b23d47be55f70afcf5579094fa8 Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 4 Aug 2022 11:24:41 -0700 Subject: [PATCH] dsp,x86: normalize types w/_mm_set* calls (2) missed in: 83539239 (origin/main, main) dsp,x86: normalize types w/_mm_set* calls fixes integer sanitizer warnings of the form: implicit conversion from type 'uint32_t' (aka 'unsigned int') of value 4292337446 (32-bit, unsigned) to type 'int' changed the value to -2629850 (32-bit, signed) runtime error: implicit conversion from type 'uint8_t' (aka 'unsigned char') of value 128 (8-bit, unsigned) to type 'char' changed the value to -128 (8-bit, signed) Bug: b/229626362 Change-Id: Ie904da8ded26725b4e0a9b82cc0679234f0a5388 --- src/dsp/dec_sse2.c | 2 +- src/dsp/lossless_sse2.c | 8 ++++---- src/dsp/lossless_sse41.c | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/dsp/dec_sse2.c b/src/dsp/dec_sse2.c index cc640ea5..77c08c33 100644 --- a/src/dsp/dec_sse2.c +++ b/src/dsp/dec_sse2.c @@ -1062,7 +1062,7 @@ static void VE16_SSE2(uint8_t* dst) { static void HE16_SSE2(uint8_t* dst) { // horizontal int j; for (j = 16; j > 0; --j) { - const __m128i values = _mm_set1_epi8(dst[-1]); + const __m128i values = _mm_set1_epi8((char)dst[-1]); _mm_storeu_si128((__m128i*)dst, values); dst += BPS; } diff --git a/src/dsp/lossless_sse2.c b/src/dsp/lossless_sse2.c index 4dd896ec..8c6a94f7 100644 --- a/src/dsp/lossless_sse2.c +++ b/src/dsp/lossless_sse2.c @@ -208,7 +208,7 @@ static void PredictorAdd0_SSE2(const uint32_t* in, const uint32_t* upper, static void PredictorAdd1_SSE2(const uint32_t* in, const uint32_t* upper, int num_pixels, uint32_t* out) { int i; - __m128i prev = _mm_set1_epi32(out[-1]); + __m128i prev = _mm_set1_epi32((int)out[-1]); for (i = 0; i + 4 <= num_pixels; i += 4) { // a | b | c | d const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]); @@ -561,7 +561,7 @@ static void ConvertBGRAToRGBA_SSE2(const uint32_t* src, static void ConvertBGRAToRGBA4444_SSE2(const uint32_t* src, int num_pixels, uint8_t* dst) { const __m128i mask_0x0f = _mm_set1_epi8(0x0f); - const __m128i mask_0xf0 = _mm_set1_epi8(0xf0); + const __m128i mask_0xf0 = _mm_set1_epi8((char)0xf0); const __m128i* in = (const __m128i*)src; __m128i* out = (__m128i*)dst; while (num_pixels >= 8) { @@ -596,8 +596,8 @@ static void ConvertBGRAToRGBA4444_SSE2(const uint32_t* src, static void ConvertBGRAToRGB565_SSE2(const uint32_t* src, int num_pixels, uint8_t* dst) { - const __m128i mask_0xe0 = _mm_set1_epi8(0xe0); - const __m128i mask_0xf8 = _mm_set1_epi8(0xf8); + const __m128i mask_0xe0 = _mm_set1_epi8((char)0xe0); + const __m128i mask_0xf8 = _mm_set1_epi8((char)0xf8); const __m128i mask_0x07 = _mm_set1_epi8(0x07); const __m128i* in = (const __m128i*)src; __m128i* out = (__m128i*)dst; diff --git a/src/dsp/lossless_sse41.c b/src/dsp/lossless_sse41.c index ed41a4b0..bb7ce761 100644 --- a/src/dsp/lossless_sse41.c +++ b/src/dsp/lossless_sse41.c @@ -25,8 +25,9 @@ static void TransformColorInverse_SSE41(const VP8LMultipliers* const m, int num_pixels, uint32_t* dst) { // sign-extended multiplying constants, pre-shifted by 5. #define CST(X) (((int16_t)(m->X << 8)) >> 5) // sign-extend - const __m128i mults_rb = _mm_set1_epi32((uint32_t)CST(green_to_red_) << 16 | - (CST(green_to_blue_) & 0xffff)); + const __m128i mults_rb = + _mm_set1_epi32((int)((uint32_t)CST(green_to_red_) << 16 | + (CST(green_to_blue_) & 0xffff))); const __m128i mults_b2 = _mm_set1_epi32(CST(red_to_blue_)); #undef CST const __m128i mask_ag = _mm_set1_epi32((int)0xff00ff00);