[arm]: Fix bug in highbd_quantize_b_neon().
Fix bug in highbd_quantize_b_neon() which was exposed when randomizing
the first nonzero coeff position.
Bug: b/217282899
Change-Id: Id91fb753d9008df816340a4298e48dd603e39e9e
diff --git a/aom_dsp/arm/highbd_quantize_neon.c b/aom_dsp/arm/highbd_quantize_neon.c
index 3deb80d..7ab5663 100644
--- a/aom_dsp/arm/highbd_quantize_neon.c
+++ b/aom_dsp/arm/highbd_quantize_neon.c
@@ -135,8 +135,8 @@
const int32x4_t v_zbin_s32x = vdupq_lane_s32(vget_low_s32(v_zbin_s32), 1);
int i = n_coeffs;
do {
- const int32x4_t v_coeff_a = vld1q_s32(coeff_ptr + i - 4 - 1);
- const int32x4_t v_coeff_b = vld1q_s32(coeff_ptr + i - 8 - 1);
+ const int32x4_t v_coeff_a = vld1q_s32(coeff_ptr + i - 4);
+ const int32x4_t v_coeff_b = vld1q_s32(coeff_ptr + i - 8);
const int32x4_t v_abs_coeff_a = vabsq_s32(v_coeff_a);
const int32x4_t v_abs_coeff_b = vabsq_s32(v_coeff_b);
const uint32x4_t v_mask_a = vcgeq_s32(v_abs_coeff_a, v_zbin_s32x);
diff --git a/test/quantize_func_test.cc b/test/quantize_func_test.cc
index 90957d8..d9876a7 100644
--- a/test/quantize_func_test.cc
+++ b/test/quantize_func_test.cc
@@ -9,6 +9,7 @@
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
+#include <algorithm>
#include <tuple>
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
@@ -208,8 +209,11 @@
void FillCoeffRandom() {
const int n_coeffs = coeff_num();
FillCoeffZero();
- int num = rnd_.Rand16() % n_coeffs;
- for (int i = 0; i < num; ++i) {
+ const int num = rnd_.Rand16() % n_coeffs;
+ // Randomize the first non zero coeff position.
+ const int start = rnd_.Rand16() % n_coeffs;
+ const int end = std::min(start + num, n_coeffs);
+ for (int i = start; i < end; ++i) {
coeff_[i] = GetRandomCoeff();
}
}