]> granicus.if.org Git - libvpx/commitdiff
vp8 quantize: silence conversion warning
authorJohann <johannkoenig@google.com>
Mon, 29 Apr 2019 21:38:27 +0000 (14:38 -0700)
committerJohann <johannkoenig@google.com>
Mon, 29 Apr 2019 21:38:58 +0000 (14:38 -0700)
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

index 6f2c1634926ece5abb7b186ec84397b619300b6b..5b7eec02e8866ee47426f841fe9f4ce91a678f3c 100644 (file)
 #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) {