From 4d34154b66c697c477111a608a77d5f3a002ff2c Mon Sep 17 00:00:00 2001 From: Yaowu Xu Date: Tue, 15 Nov 2016 20:47:52 -0800 Subject: [PATCH] Fix IOC warnings av1_txfm.h: left shift of a negative number av1/encoder/quantize.c: unsigned int overflow aom_dsp/entenc.c: unsigned int overflow Change-Id: I6143e68f7d6e2621f97900808c8ef7ee0ad0c814 --- aom_dsp/entenc.c | 6 +++--- av1/common/av1_txfm.h | 2 +- av1/encoder/quantize.c | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/aom_dsp/entenc.c b/aom_dsp/entenc.c index 390f61b9b..214f183a3 100644 --- a/aom_dsp/entenc.c +++ b/aom_dsp/entenc.c @@ -514,7 +514,7 @@ unsigned char *od_ec_enc_done(od_ec_enc *enc, uint32_t *nbytes) { unsigned char *out; uint32_t storage; uint16_t *buf; - uint32_t offs; + int offs; uint32_t end_offs; int nend_bits; od_ec_window m; @@ -554,7 +554,7 @@ unsigned char *od_ec_enc_done(od_ec_enc *enc, uint32_t *nbytes) { if (s > 0) { unsigned n; storage = enc->precarry_storage; - if (offs + ((s + 7) >> 3) > storage) { + if (offs + ((s + 7) >> 3) > (int)storage) { storage = storage * 2 + ((s + 7) >> 3); buf = (uint16_t *)realloc(buf, sizeof(*buf) * storage); if (buf == NULL) { @@ -566,7 +566,7 @@ unsigned char *od_ec_enc_done(od_ec_enc *enc, uint32_t *nbytes) { } n = (1 << (c + 16)) - 1; do { - OD_ASSERT(offs < storage); + OD_ASSERT(offs < (int)storage); buf[offs++] = (uint16_t)(e >> (c + 16)); e &= n; s -= 8; diff --git a/av1/common/av1_txfm.h b/av1/common/av1_txfm.h index 3b7898181..c2f1b1a52 100644 --- a/av1/common/av1_txfm.h +++ b/av1/common/av1_txfm.h @@ -81,7 +81,7 @@ static INLINE void round_shift_array(int32_t *arr, int size, int bit) { } } else { for (i = 0; i < size; i++) { - arr[i] = arr[i] << (-bit); + arr[i] = arr[i] * (1 << (-bit)); } } } diff --git a/av1/encoder/quantize.c b/av1/encoder/quantize.c index 644a4c383..da0164267 100644 --- a/av1/encoder/quantize.c +++ b/av1/encoder/quantize.c @@ -1464,7 +1464,8 @@ void av1_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, #else const uint32_t abs_qcoeff = (uint32_t)((tmp2 * quant_shift_ptr[rc != 0]) >> shift); - qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign); + qcoeff_ptr[rc] = + (tran_low_t)((int)(abs_qcoeff ^ coeff_sign) - coeff_sign); dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / scale; #endif // CONFIG_AOM_QM if (abs_qcoeff) eob = i;