test/acm_random: add Rand16Signed()
and use it in av1_quantize_test.cc and av1_wedge_utils_test.cc
w/clang -fsanitize=integer quiets warnings of the form:
implicit conversion from type 'uint16_t' (aka 'unsigned short') of value
48672 (16-bit, unsigned) to type 'int16_t' (aka 'short') changed the
value to -16864 (16-bit, signed)
Bug: aomedia:3136
Bug: b/229626362
Change-Id: I4b79307e35986e19fe5c17d3fac891082220c605
diff --git a/test/acm_random.h b/test/acm_random.h
index 8b1d51a..742224a 100644
--- a/test/acm_random.h
+++ b/test/acm_random.h
@@ -37,6 +37,8 @@
return (value >> 15) & 0xffff;
}
+ int16_t Rand16Signed(void) { return static_cast<int16_t>(Rand16()); }
+
int16_t Rand15Signed(void) {
const uint32_t value =
random_.Generate(testing::internal::Random::kMaxRange);
diff --git a/test/av1_quantize_test.cc b/test/av1_quantize_test.cc
index 731e99c..5823647 100644
--- a/test/av1_quantize_test.cc
+++ b/test/av1_quantize_test.cc
@@ -79,8 +79,8 @@
}
for (int j = 0; j < 2; j++) {
- zbin_ptr[j] = rnd.Rand16();
- quant_shift_ptr[j] = rnd.Rand16();
+ zbin_ptr[j] = rnd.Rand16Signed();
+ quant_shift_ptr[j] = rnd.Rand16Signed();
// int16_t positive
dequant_ptr[j] = abs(rnd(dequantRange));
quant_ptr[j] = static_cast<int16_t>((1 << 16) / dequant_ptr[j]);
@@ -155,8 +155,8 @@
coeff_ptr[rnd(count)] = rnd(coeffRange);
for (int j = 0; j < 2; j++) {
- zbin_ptr[j] = rnd.Rand16();
- quant_shift_ptr[j] = rnd.Rand16();
+ zbin_ptr[j] = rnd.Rand16Signed();
+ quant_shift_ptr[j] = rnd.Rand16Signed();
// int16_t positive
dequant_ptr[j] = abs(rnd(dequantRange));
quant_ptr[j] = (1 << 16) / dequant_ptr[j];
diff --git a/test/av1_wedge_utils_test.cc b/test/av1_wedge_utils_test.cc
index a51ce12..369479a 100644
--- a/test/av1_wedge_utils_test.cc
+++ b/test/av1_wedge_utils_test.cc
@@ -341,7 +341,7 @@
for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
for (int i = 0; i < MAX_SB_SQUARE; ++i) {
- a[i] = rng_.Rand16();
+ a[i] = rng_.Rand16Signed();
b[i] = rng_(2 * INT16_MAX + 1) - INT16_MAX;
}