From 1e01d13fb8e7fb904bdbc9fe461a7c86d2b57427 Mon Sep 17 00:00:00 2001 From: Johann Date: Mon, 29 Apr 2019 14:38:27 -0700 Subject: [PATCH] vp8 quantize: silence conversion warning clang 7 integer sanitizer warns about storing any int16_t value where the high bit is 1. Treated as an int, such number would be positive. Treated as an int16_t, it is negative. BUG=webm:1615 Change-Id: Idf655cd92d26b7c1180910159be3f64164577eca --- vp8/encoder/x86/quantize_sse4.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/vp8/encoder/x86/quantize_sse4.c b/vp8/encoder/x86/quantize_sse4.c index 6f2c16349..5b7eec02e 100644 --- a/vp8/encoder/x86/quantize_sse4.c +++ b/vp8/encoder/x86/quantize_sse4.c @@ -14,17 +14,19 @@ #include "vp8/encoder/block.h" #include "vp8/common/entropy.h" /* vp8_default_inv_zig_zag */ -#define SELECT_EOB(i, z, x, y, q) \ - do { \ - short boost = *zbin_boost_ptr; \ - short x_z = _mm_extract_epi16(x, z); \ - short y_z = _mm_extract_epi16(y, z); \ - int cmp = (x_z < boost) | (y_z == 0); \ - zbin_boost_ptr++; \ - if (cmp) break; \ - q = _mm_insert_epi16(q, y_z, z); \ - eob = i; \ - zbin_boost_ptr = b->zrun_zbin_boost; \ +#define SELECT_EOB(i, z, x, y, q) \ + do { \ + short boost = *zbin_boost_ptr; \ + /* Technically _mm_extract_epi16() returns an int: */ \ + /* https://bugs.llvm.org/show_bug.cgi?id=41657 */ \ + short x_z = (short)_mm_extract_epi16(x, z); \ + short y_z = (short)_mm_extract_epi16(y, z); \ + int cmp = (x_z < boost) | (y_z == 0); \ + zbin_boost_ptr++; \ + if (cmp) break; \ + q = _mm_insert_epi16(q, y_z, z); \ + eob = i; \ + zbin_boost_ptr = b->zrun_zbin_boost; \ } while (0) void vp8_regular_quantize_b_sse4_1(BLOCK *b, BLOCKD *d) { -- 2.40.0