Refactor of build_compound_diffwtd_mask(_highbd)

1. Add "av1_" prefix for public functions
av1_build_compound_diffwtd_mask_c and
av1_build_compound_diffwtd_mask_highbd_c

2. Move them to rtcd, SIMD version will be added in
following up CL.

3. Remove sb_type from argument list, given that
block_size_wide[sb_type] is always equal to the width.

Change-Id: I6a7be770b8acd040c2f167d7aca08cb9e7b3a78e
diff --git a/av1/common/av1_rtcd_defs.pl b/av1/common/av1_rtcd_defs.pl
index 9ea7c61..7ad01f3 100755
--- a/av1/common/av1_rtcd_defs.pl
+++ b/av1/common/av1_rtcd_defs.pl
@@ -144,6 +144,10 @@
 add_proto qw/void av1_highbd_dr_prediction_z2/, "uint16_t *dst, ptrdiff_t stride, int bw, int bh, const uint16_t *above, const uint16_t *left, int upsample_above, int upsample_left, int dx, int dy, int bd";
 add_proto qw/void av1_highbd_dr_prediction_z3/, "uint16_t *dst, ptrdiff_t stride, int bw, int bh, const uint16_t *above, const uint16_t *left, int upsample_left, int dx, int dy, int bd";
 
+# build compound seg mask functions
+add_proto qw/void av1_build_compound_diffwtd_mask/, "uint8_t *mask, DIFFWTD_MASK_TYPE mask_type, const uint8_t *src0, int src0_stride, const uint8_t *src1, int src1_stride, int h, int w";
+add_proto qw/void av1_build_compound_diffwtd_mask_highbd/, "uint8_t *mask, DIFFWTD_MASK_TYPE mask_type, const uint8_t *src0, int src0_stride, const uint8_t *src1, int src1_stride, int h, int w, int bd";
+
 #
 # Encoder functions below this point.
 #
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c
index 52df7b7..5b78bf5 100644
--- a/av1/common/reconinter.c
+++ b/av1/common/reconinter.c
@@ -305,36 +305,33 @@
 
 static void diffwtd_mask_d32(uint8_t *mask, int which_inverse, int mask_base,
                              const CONV_BUF_TYPE *src0, int src0_stride,
-                             const CONV_BUF_TYPE *src1, int src1_stride,
-                             BLOCK_SIZE sb_type, int h, int w,
-                             ConvolveParams *conv_params, int bd) {
+                             const CONV_BUF_TYPE *src1, int src1_stride, int h,
+                             int w, ConvolveParams *conv_params, int bd) {
   int round =
       2 * FILTER_BITS - conv_params->round_0 - conv_params->round_1 + (bd - 8);
   int i, j, m, diff;
-  int block_stride = block_size_wide[sb_type];
   for (i = 0; i < h; ++i) {
     for (j = 0; j < w; ++j) {
       diff = abs(src0[i * src0_stride + j] - src1[i * src1_stride + j]);
       diff = ROUND_POWER_OF_TWO(diff, round);
       m = clamp(mask_base + (diff / DIFF_FACTOR), 0, AOM_BLEND_A64_MAX_ALPHA);
-      mask[i * block_stride + j] =
-          which_inverse ? AOM_BLEND_A64_MAX_ALPHA - m : m;
+      mask[i * w + j] = which_inverse ? AOM_BLEND_A64_MAX_ALPHA - m : m;
     }
   }
 }
 
 static void build_compound_diffwtd_mask_d16(
     uint8_t *mask, DIFFWTD_MASK_TYPE mask_type, const CONV_BUF_TYPE *src0,
-    int src0_stride, const CONV_BUF_TYPE *src1, int src1_stride,
-    BLOCK_SIZE sb_type, int h, int w, ConvolveParams *conv_params, int bd) {
+    int src0_stride, const CONV_BUF_TYPE *src1, int src1_stride, int h, int w,
+    ConvolveParams *conv_params, int bd) {
   switch (mask_type) {
     case DIFFWTD_38:
-      diffwtd_mask_d32(mask, 0, 38, src0, src0_stride, src1, src1_stride,
-                       sb_type, h, w, conv_params, bd);
+      diffwtd_mask_d32(mask, 0, 38, src0, src0_stride, src1, src1_stride, h, w,
+                       conv_params, bd);
       break;
     case DIFFWTD_38_INV:
-      diffwtd_mask_d32(mask, 1, 38, src0, src0_stride, src1, src1_stride,
-                       sb_type, h, w, conv_params, bd);
+      diffwtd_mask_d32(mask, 1, 38, src0, src0_stride, src1, src1_stride, h, w,
+                       conv_params, bd);
       break;
     default: assert(0);
   }
@@ -342,33 +339,29 @@
 
 static void diffwtd_mask(uint8_t *mask, int which_inverse, int mask_base,
                          const uint8_t *src0, int src0_stride,
-                         const uint8_t *src1, int src1_stride,
-                         BLOCK_SIZE sb_type, int h, int w) {
+                         const uint8_t *src1, int src1_stride, int h, int w) {
   int i, j, m, diff;
-  int block_stride = block_size_wide[sb_type];
   for (i = 0; i < h; ++i) {
     for (j = 0; j < w; ++j) {
       diff =
           abs((int)src0[i * src0_stride + j] - (int)src1[i * src1_stride + j]);
       m = clamp(mask_base + (diff / DIFF_FACTOR), 0, AOM_BLEND_A64_MAX_ALPHA);
-      mask[i * block_stride + j] =
-          which_inverse ? AOM_BLEND_A64_MAX_ALPHA - m : m;
+      mask[i * w + j] = which_inverse ? AOM_BLEND_A64_MAX_ALPHA - m : m;
     }
   }
 }
 
-void build_compound_diffwtd_mask(uint8_t *mask, DIFFWTD_MASK_TYPE mask_type,
-                                 const uint8_t *src0, int src0_stride,
-                                 const uint8_t *src1, int src1_stride,
-                                 BLOCK_SIZE sb_type, int h, int w) {
+void av1_build_compound_diffwtd_mask_c(uint8_t *mask,
+                                       DIFFWTD_MASK_TYPE mask_type,
+                                       const uint8_t *src0, int src0_stride,
+                                       const uint8_t *src1, int src1_stride,
+                                       int h, int w) {
   switch (mask_type) {
     case DIFFWTD_38:
-      diffwtd_mask(mask, 0, 38, src0, src0_stride, src1, src1_stride, sb_type,
-                   h, w);
+      diffwtd_mask(mask, 0, 38, src0, src0_stride, src1, src1_stride, h, w);
       break;
     case DIFFWTD_38_INV:
-      diffwtd_mask(mask, 1, 38, src0, src0_stride, src1, src1_stride, sb_type,
-                   h, w);
+      diffwtd_mask(mask, 1, 38, src0, src0_stride, src1, src1_stride, h, w);
       break;
     default: assert(0);
   }
@@ -376,38 +369,32 @@
 
 static void diffwtd_mask_highbd(uint8_t *mask, int which_inverse, int mask_base,
                                 const uint16_t *src0, int src0_stride,
-                                const uint16_t *src1, int src1_stride,
-                                BLOCK_SIZE sb_type, int h, int w, int bd) {
+                                const uint16_t *src1, int src1_stride, int h,
+                                int w, int bd) {
   int i, j, m, diff;
-  int block_stride = block_size_wide[sb_type];
   for (i = 0; i < h; ++i) {
     for (j = 0; j < w; ++j) {
       diff = abs((int)src0[i * src0_stride + j] -
                  (int)src1[i * src1_stride + j]) >>
              (bd - 8);
       m = clamp(mask_base + (diff / DIFF_FACTOR), 0, AOM_BLEND_A64_MAX_ALPHA);
-      mask[i * block_stride + j] =
-          which_inverse ? AOM_BLEND_A64_MAX_ALPHA - m : m;
+      mask[i * w + j] = which_inverse ? AOM_BLEND_A64_MAX_ALPHA - m : m;
     }
   }
 }
 
-void build_compound_diffwtd_mask_highbd(uint8_t *mask,
-                                        DIFFWTD_MASK_TYPE mask_type,
-                                        const uint8_t *src0, int src0_stride,
-                                        const uint8_t *src1, int src1_stride,
-                                        BLOCK_SIZE sb_type, int h, int w,
-                                        int bd) {
+void av1_build_compound_diffwtd_mask_highbd_c(
+    uint8_t *mask, DIFFWTD_MASK_TYPE mask_type, const uint8_t *src0,
+    int src0_stride, const uint8_t *src1, int src1_stride, int h, int w,
+    int bd) {
   switch (mask_type) {
     case DIFFWTD_38:
       diffwtd_mask_highbd(mask, 0, 38, CONVERT_TO_SHORTPTR(src0), src0_stride,
-                          CONVERT_TO_SHORTPTR(src1), src1_stride, sb_type, h, w,
-                          bd);
+                          CONVERT_TO_SHORTPTR(src1), src1_stride, h, w, bd);
       break;
     case DIFFWTD_38_INV:
       diffwtd_mask_highbd(mask, 1, 38, CONVERT_TO_SHORTPTR(src0), src0_stride,
-                          CONVERT_TO_SHORTPTR(src1), src1_stride, sb_type, h, w,
-                          bd);
+                          CONVERT_TO_SHORTPTR(src1), src1_stride, h, w, bd);
       break;
     default: assert(0);
   }
@@ -645,9 +632,9 @@
                            xd, can_use_previous);
 
   if (!plane && comp_data.interinter_compound_type == COMPOUND_DIFFWTD) {
-    build_compound_diffwtd_mask_d16(
-        comp_data.seg_mask, comp_data.mask_type, org_dst, org_dst_stride,
-        tmp_buf16, tmp_buf_stride, mi->sb_type, h, w, conv_params, xd->bd);
+    build_compound_diffwtd_mask_d16(comp_data.seg_mask, comp_data.mask_type,
+                                    org_dst, org_dst_stride, tmp_buf16,
+                                    tmp_buf_stride, h, w, conv_params, xd->bd);
   }
   build_masked_compound_no_round(dst, dst_stride, org_dst, org_dst_stride,
                                  tmp_buf16, tmp_buf_stride, &comp_data,
@@ -1861,15 +1848,14 @@
   if (is_compound && is_masked_compound_type(mbmi->interinter_compound_type)) {
     if (!plane && comp_data.interinter_compound_type == COMPOUND_DIFFWTD) {
       if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
-        build_compound_diffwtd_mask_highbd(
+        av1_build_compound_diffwtd_mask_highbd(
             comp_data.seg_mask, comp_data.mask_type,
             CONVERT_TO_BYTEPTR(ext_dst0), ext_dst_stride0,
-            CONVERT_TO_BYTEPTR(ext_dst1), ext_dst_stride1, mbmi->sb_type, h, w,
-            xd->bd);
+            CONVERT_TO_BYTEPTR(ext_dst1), ext_dst_stride1, h, w, xd->bd);
       else
-        build_compound_diffwtd_mask(comp_data.seg_mask, comp_data.mask_type,
-                                    ext_dst0, ext_dst_stride0, ext_dst1,
-                                    ext_dst_stride1, mbmi->sb_type, h, w);
+        av1_build_compound_diffwtd_mask(comp_data.seg_mask, comp_data.mask_type,
+                                        ext_dst0, ext_dst_stride0, ext_dst1,
+                                        ext_dst_stride1, h, w);
     }
 
     if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
diff --git a/av1/common/reconinter.h b/av1/common/reconinter.h
index dc882e0..ceea638 100644
--- a/av1/common/reconinter.h
+++ b/av1/common/reconinter.h
@@ -176,17 +176,6 @@
   return wedge_params_lookup[sb_type].bits;
 }
 
-void build_compound_diffwtd_mask(uint8_t *mask, DIFFWTD_MASK_TYPE mask_type,
-                                 const uint8_t *src0, int src0_stride,
-                                 const uint8_t *src1, int src1_stride,
-                                 BLOCK_SIZE sb_type, int h, int w);
-void build_compound_diffwtd_mask_highbd(uint8_t *mask,
-                                        DIFFWTD_MASK_TYPE mask_type,
-                                        const uint8_t *src0, int src0_stride,
-                                        const uint8_t *src1, int src1_stride,
-                                        BLOCK_SIZE sb_type, int h, int w,
-                                        int bd);
-
 void av1_make_masked_inter_predictor(
     const uint8_t *pre, int pre_stride, uint8_t *dst, int dst_stride,
     const int subpel_x, const int subpel_y, const struct scale_factors *sf,
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 01a202e..f257161 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -6349,12 +6349,12 @@
   for (cur_mask_type = 0; cur_mask_type < DIFFWTD_MASK_TYPES; cur_mask_type++) {
     // build mask and inverse
     if (hbd)
-      build_compound_diffwtd_mask_highbd(
+      av1_build_compound_diffwtd_mask_highbd(
           xd->seg_mask, cur_mask_type, CONVERT_TO_BYTEPTR(p0), bw,
-          CONVERT_TO_BYTEPTR(p1), bw, bsize, bh, bw, xd->bd);
+          CONVERT_TO_BYTEPTR(p1), bw, bh, bw, xd->bd);
     else
-      build_compound_diffwtd_mask(xd->seg_mask, cur_mask_type, p0, bw, p1, bw,
-                                  bsize, bh, bw);
+      av1_build_compound_diffwtd_mask(xd->seg_mask, cur_mask_type, p0, bw, p1,
+                                      bw, bh, bw);
 
     // compute rd for mask
     sse = av1_wedge_sse_from_residuals(r1, d10, xd->seg_mask, N);
@@ -6372,12 +6372,12 @@
   // make final mask
   mbmi->mask_type = best_mask_type;
   if (hbd)
-    build_compound_diffwtd_mask_highbd(
+    av1_build_compound_diffwtd_mask_highbd(
         xd->seg_mask, mbmi->mask_type, CONVERT_TO_BYTEPTR(p0), bw,
-        CONVERT_TO_BYTEPTR(p1), bw, bsize, bh, bw, xd->bd);
+        CONVERT_TO_BYTEPTR(p1), bw, bh, bw, xd->bd);
   else
-    build_compound_diffwtd_mask(xd->seg_mask, mbmi->mask_type, p0, bw, p1, bw,
-                                bsize, bh, bw);
+    av1_build_compound_diffwtd_mask(xd->seg_mask, mbmi->mask_type, p0, bw, p1,
+                                    bw, bh, bw);
 
   return best_rd;
 }