fix implicit conversion warnings w/bitops
w/clang -fsanitize=integer quiets warnings of the form:
implicit conversion from type 'int' of value -3 (32-bit, signed) to type
'unsigned int' changed the value to 4294967293 (32-bit, unsigned)
Bug: aomedia:3136
Bug: b/229626362
Change-Id: Ib7e946be5e997d0790f498e1ec365e46439d2893
diff --git a/aom_dsp/x86/highbd_quantize_intrin_sse2.c b/aom_dsp/x86/highbd_quantize_intrin_sse2.c
index 1764a49..a5c450a 100644
--- a/aom_dsp/x86/highbd_quantize_intrin_sse2.c
+++ b/aom_dsp/x86/highbd_quantize_intrin_sse2.c
@@ -80,7 +80,8 @@
const int64_t tmp4 = ((tmp3 * quant_ptr[k != 0]) >> 16) + tmp3;
const uint32_t abs_qcoeff =
(uint32_t)((tmp4 * quant_shift_ptr[k != 0]) >> 16);
- qcoeff_ptr[k] = (int)(abs_qcoeff ^ coeff_sign[j]) - coeff_sign[j];
+ qcoeff_ptr[k] =
+ (int)(abs_qcoeff ^ (uint32_t)coeff_sign[j]) - coeff_sign[j];
dqcoeff_ptr[k] = qcoeff_ptr[k] * dequant_ptr[k != 0];
if (abs_qcoeff) eob_i = iscan[k] > eob_i ? iscan[k] : eob_i;
}
@@ -140,7 +141,7 @@
const int64_t tmp2 = ((tmp1 * quant_ptr[rc != 0]) >> 16) + tmp1;
const uint32_t abs_qcoeff =
(uint32_t)((tmp2 * quant_shift_ptr[rc != 0]) >> 15);
- qcoeff_ptr[rc] = (int)(abs_qcoeff ^ coeff_sign) - coeff_sign;
+ qcoeff_ptr[rc] = (int)(abs_qcoeff ^ (uint32_t)coeff_sign) - coeff_sign;
dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / 2;
if (abs_qcoeff) eob = iscan[idx_arr[i]] > eob ? iscan[idx_arr[i]] : eob;
}
@@ -198,7 +199,7 @@
const int64_t tmp2 = ((tmp1 * quant_ptr[rc != 0]) >> 16) + tmp1;
const uint32_t abs_qcoeff =
(uint32_t)((tmp2 * quant_shift_ptr[rc != 0]) >> 14);
- qcoeff_ptr[rc] = (int)(abs_qcoeff ^ coeff_sign) - coeff_sign;
+ qcoeff_ptr[rc] = (int)(abs_qcoeff ^ (uint32_t)coeff_sign) - coeff_sign;
dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / 4;
if (abs_qcoeff) eob = iscan[idx_arr[i]] > eob ? iscan[idx_arr[i]] : eob;
}
diff --git a/aom_dsp/x86/sum_squares_sse2.c b/aom_dsp/x86/sum_squares_sse2.c
index 053d595..25be856 100644
--- a/aom_dsp/x86/sum_squares_sse2.c
+++ b/aom_dsp/x86/sum_squares_sse2.c
@@ -306,7 +306,7 @@
if (n % 64 == 0) {
return aom_sum_squares_i16_64n_sse2(src, n);
} else if (n > 64) {
- int k = n & ~(64 - 1);
+ const uint32_t k = n & ~63u;
return aom_sum_squares_i16_64n_sse2(src, k) +
aom_sum_squares_i16_c(src + k, n - k);
} else {
diff --git a/av1/av1_iface_common.h b/av1/av1_iface_common.h
index 57dd1b8..b923c3d 100644
--- a/av1/av1_iface_common.h
+++ b/av1/av1_iface_common.h
@@ -137,7 +137,7 @@
// Note(yunqing): if img is allocated the same as the frame buffer, y_stride
// is 32-byte aligned. Also, handle the cases while allocating img without a
// border or stride_align is less than 32.
- int border = (yv12->y_stride - (int)((img->w + 31) & ~31)) / 2;
+ int border = (yv12->y_stride - (int)((img->w + 31) & ~31u)) / 2;
yv12->border = (border < 0) ? 0 : border;
yv12->subsampling_x = img->x_chroma_shift;
yv12->subsampling_y = img->y_chroma_shift;
diff --git a/av1/encoder/encode_strategy.c b/av1/encoder/encode_strategy.c
index a90661a..0c71036 100644
--- a/av1/encoder/encode_strategy.c
+++ b/av1/encoder/encode_strategy.c
@@ -413,35 +413,35 @@
const RefreshFrameInfo *const refresh_frame,
unsigned int *frame_flags) {
if (encode_show_existing_frame(cm)) {
- *frame_flags &= ~FRAMEFLAGS_GOLDEN;
- *frame_flags &= ~FRAMEFLAGS_BWDREF;
- *frame_flags &= ~FRAMEFLAGS_ALTREF;
- *frame_flags &= ~FRAMEFLAGS_KEY;
+ *frame_flags &= ~(uint32_t)FRAMEFLAGS_GOLDEN;
+ *frame_flags &= ~(uint32_t)FRAMEFLAGS_BWDREF;
+ *frame_flags &= ~(uint32_t)FRAMEFLAGS_ALTREF;
+ *frame_flags &= ~(uint32_t)FRAMEFLAGS_KEY;
return;
}
if (refresh_frame->golden_frame) {
*frame_flags |= FRAMEFLAGS_GOLDEN;
} else {
- *frame_flags &= ~FRAMEFLAGS_GOLDEN;
+ *frame_flags &= ~(uint32_t)FRAMEFLAGS_GOLDEN;
}
if (refresh_frame->alt_ref_frame) {
*frame_flags |= FRAMEFLAGS_ALTREF;
} else {
- *frame_flags &= ~FRAMEFLAGS_ALTREF;
+ *frame_flags &= ~(uint32_t)FRAMEFLAGS_ALTREF;
}
if (refresh_frame->bwd_ref_frame) {
*frame_flags |= FRAMEFLAGS_BWDREF;
} else {
- *frame_flags &= ~FRAMEFLAGS_BWDREF;
+ *frame_flags &= ~(uint32_t)FRAMEFLAGS_BWDREF;
}
if (cm->current_frame.frame_type == KEY_FRAME) {
*frame_flags |= FRAMEFLAGS_KEY;
} else {
- *frame_flags &= ~FRAMEFLAGS_KEY;
+ *frame_flags &= ~(uint32_t)FRAMEFLAGS_KEY;
}
}
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index bb61ef0..3085e2d 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -3885,7 +3885,7 @@
}
mask->pred_modes[INTRA_FRAME] |=
- ~(sf->intra_sf.intra_y_mode_mask[max_txsize_lookup[bsize]]);
+ ~(uint32_t)sf->intra_sf.intra_y_mode_mask[max_txsize_lookup[bsize]];
}
static AOM_INLINE void init_neighbor_pred_buf(
diff --git a/av1/encoder/segmentation.c b/av1/encoder/segmentation.c
index d315838..4b4e787 100644
--- a/av1/encoder/segmentation.c
+++ b/av1/encoder/segmentation.c
@@ -35,7 +35,7 @@
void av1_disable_segfeature(struct segmentation *seg, int segment_id,
SEG_LVL_FEATURES feature_id) {
- seg->feature_mask[segment_id] &= ~(1 << feature_id);
+ seg->feature_mask[segment_id] &= ~(1u << feature_id);
}
void av1_clear_segdata(struct segmentation *seg, int segment_id,
diff --git a/test/video_source.h b/test/video_source.h
index 742178e..b51cbf4 100644
--- a/test/video_source.h
+++ b/test/video_source.h
@@ -215,7 +215,7 @@
aom_img_free(img_);
img_ = aom_img_alloc(nullptr, format_, width_, height_, 32);
ASSERT_NE(img_, nullptr);
- raw_sz_ = ((img_->w + 31) & ~31) * img_->h * img_->bps / 8;
+ raw_sz_ = ((img_->w + 31) & ~31u) * img_->h * img_->bps / 8;
}
aom_image_t *img_;