Replace stride by bwl in get_level_count()

Change-Id: Id191159a851513b6eb3f2ddd104a1299eed59292
diff --git a/av1/common/txb_common.h b/av1/common/txb_common.h
index 8cec13d..198665f 100644
--- a/av1/common/txb_common.h
+++ b/av1/common/txb_common.h
@@ -36,16 +36,17 @@
   /* clang-format on*/
 };
 
-static INLINE int get_level_count(const tran_low_t *tcoeffs, int stride,
+static INLINE int get_level_count(const tran_low_t *tcoeffs, int bwl,
                                   int height, int row, int col, int level,
                                   int (*nb_offset)[2], int nb_num) {
   int count = 0;
   for (int idx = 0; idx < nb_num; ++idx) {
     const int ref_row = row + nb_offset[idx][0];
     const int ref_col = col + nb_offset[idx][1];
-    const int pos = ref_row * stride + ref_col;
-    if (ref_row < 0 || ref_col < 0 || ref_row >= height || ref_col >= stride)
+    if (ref_row < 0 || ref_col < 0 || ref_row >= height ||
+        ref_col >= (1 << bwl))
       continue;
+    const int pos = (ref_row << bwl) + ref_col;
     tran_low_t abs_coeff = abs(tcoeffs[pos]);
     count += abs_coeff > level;
   }
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c
index c09d1f7..37c5265 100644
--- a/av1/encoder/encodetxb.c
+++ b/av1/encoder/encodetxb.c
@@ -412,19 +412,18 @@
                                    int (*base_mag_arr)[2],
                                    const tran_low_t *qcoeff, int bwl,
                                    int height, int eob, const int16_t *scan) {
-  const int stride = 1 << bwl;
   for (int c = 0; c < eob; ++c) {
     const int coeff_idx = scan[c];  // raster order
     if (!has_base(qcoeff[coeff_idx], 0)) continue;
-    const int row = coeff_idx / stride;
-    const int col = coeff_idx % stride;
+    const int row = coeff_idx >> bwl;
+    const int col = coeff_idx - (row << bwl);
     int *mag = base_mag_arr[coeff_idx];
     get_mag(mag, qcoeff, bwl, height, row, col, base_ref_offset,
             BASE_CONTEXT_POSITION_NUM);
     for (int i = 0; i < NUM_BASE_LEVELS; ++i) {
       if (!has_base(qcoeff[coeff_idx], i)) continue;
       int *count = base_count_arr[i] + coeff_idx;
-      *count = get_level_count(qcoeff, stride, height, row, col, i,
+      *count = get_level_count(qcoeff, bwl, height, row, col, i,
                                base_ref_offset, BASE_CONTEXT_POSITION_NUM);
     }
   }
@@ -484,15 +483,14 @@
 static void gen_br_count_mag_arr(int *br_count_arr, int (*br_mag_arr)[2],
                                  const tran_low_t *qcoeff, int bwl, int height,
                                  int eob, const int16_t *scan) {
-  const int stride = 1 << bwl;
   for (int c = 0; c < eob; ++c) {
     const int coeff_idx = scan[c];  // raster order
     if (!has_br(qcoeff[coeff_idx])) continue;
-    const int row = coeff_idx / stride;
-    const int col = coeff_idx % stride;
+    const int row = coeff_idx >> bwl;
+    const int col = coeff_idx - (row << bwl);
     int *count = br_count_arr + coeff_idx;
     int *mag = br_mag_arr[coeff_idx];
-    *count = get_level_count(qcoeff, stride, height, row, col, NUM_BASE_LEVELS,
+    *count = get_level_count(qcoeff, bwl, height, row, col, NUM_BASE_LEVELS,
                              br_ref_offset, BR_CONTEXT_POSITION_NUM);
     get_mag(mag, qcoeff, bwl, height, row, col, br_ref_offset,
             BR_CONTEXT_POSITION_NUM);