Merge "Adds masked variance and sad functions for wedge" into nextgenv2
diff --git a/vp10/common/reconintra.c b/vp10/common/reconintra.c
index b16fc4e..76d50c6 100644
--- a/vp10/common/reconintra.c
+++ b/vp10/common/reconintra.c
@@ -107,6 +107,10 @@
   const int w = VPXMAX(num_4x4_blocks_wide_lookup[bsize] >> ss_x, 1);
   const int step = 1 << txsz;
 
+  // Handle block size 4x8 and 4x4
+  if (ss_x == 0 && num_4x4_blocks_wide_lookup[bsize] < 2 && x == 0)
+    return 1;
+
   if (y == 0) {
     const int hl = mi_height_log2_lookup[bsize];
     const uint8_t *order = orders[bsize];
@@ -144,6 +148,13 @@
     const uint8_t *order = orders[bsize];
     int my_order, bl_order;
 
+    // Handle block size 8x4 and 4x4
+    if (ss_y == 0 && num_4x4_blocks_high_lookup[bsize] < 2 && y == 0)
+      return 1;
+
+    if (y + step < h)
+      return 1;
+
     mi_row = (mi_row & 7) >> hl;
     mi_col = (mi_col & 7) >> wl;
 
@@ -154,9 +165,6 @@
     if (((mi_row + 1) << hl) >= 8)
       return 0;
 
-    if (y + step < h)
-      return 1;
-
     my_order = order[((mi_row + 0) << (3 - wl)) + mi_col + 0];
     bl_order = order[((mi_row + 1) << (3 - wl)) + mi_col - 1];
 
diff --git a/vp10/common/thread_common.c b/vp10/common/thread_common.c
index 679adc6..ecc971a 100644
--- a/vp10/common/thread_common.c
+++ b/vp10/common/thread_common.c
@@ -365,6 +365,11 @@
   for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++)
     for (j = 0; j < SWITCHABLE_FILTERS; j++)
       cm->counts.switchable_interp[i][j] += counts->switchable_interp[i][j];
+#if CONFIG_OBMC
+  for (i = 0; i < BLOCK_SIZES; i++)
+    for (j = 0; j < 2; j++)
+      cm->counts.obmc[i][j] += counts->obmc[i][j];
+#endif  // CONFIG_OBMC
 
 #if CONFIG_REF_MV
   for (i = 0; i < NEWMV_MODE_CONTEXTS; ++i)
diff --git a/vp10/decoder/decodeframe.c b/vp10/decoder/decodeframe.c
index 4136f14..2c2dc48 100644
--- a/vp10/decoder/decodeframe.c
+++ b/vp10/decoder/decodeframe.c
@@ -466,6 +466,7 @@
 }
 #endif  // CONFIG_VAR_TX
 
+#if !CONFIG_VAR_TX || CONFIG_SUPERTX
 static int reconstruct_inter_block(MACROBLOCKD *const xd,
 #if CONFIG_ANS
                                    const rans_dec_lut *const token_tab,
@@ -492,6 +493,7 @@
                             pd->dst.stride, eob, block_idx);
   return eob;
 }
+#endif  // !CONFIG_VAR_TX || CONFIG_SUPER_TX
 
 #if (CONFIG_SUPERTX || CONFIG_OBMC)
 static void build_mc_border(const uint8_t *src, int src_stride,
diff --git a/vp10/encoder/encoder.h b/vp10/encoder/encoder.h
index 2c158a4..efde0fc 100644
--- a/vp10/encoder/encoder.h
+++ b/vp10/encoder/encoder.h
@@ -701,10 +701,6 @@
 
 #define LAYER_IDS_TO_IDX(sl, tl, num_tl) ((sl) * (num_tl) + (tl))
 
-#ifdef __cplusplus
-}  // extern "C"
-#endif
-
 #if CONFIG_AFFINE_MOTION
 // Update up-sampled reference frame index.
 static INLINE void uref_cnt_fb(EncRefCntBuffer *ubufs, int *uidx,
@@ -719,4 +715,8 @@
 }
 #endif
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP10_ENCODER_ENCODER_H_
diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c
index 5c74d32..96edc0f 100644
--- a/vp10/encoder/rdopt.c
+++ b/vp10/encoder/rdopt.c
@@ -2404,7 +2404,7 @@
   MACROBLOCKD *xd = &x->e_mbd;
   const struct macroblock_plane *const p = &x->plane[plane];
   struct macroblockd_plane *const pd = &xd->plane[plane];
-  unsigned int tmp;
+  int64_t tmp;
   tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
   PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
   TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
@@ -2472,7 +2472,7 @@
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
     tmp = ROUNDZ_POWER_OF_TWO(tmp, (xd->bd - 8) * 2);
 #endif  // CONFIG_VP9_HIGHBITDEPTH
-  *bsse += (int64_t)tmp * 16;
+  *bsse += tmp * 16;
 
   if (p->eobs[block] > 0) {
     const int lossless = xd->lossless[xd->mi[0]->mbmi.segment_id];
@@ -2544,12 +2544,12 @@
         }
       }
     } else {
-      cpi->fn_ptr[txm_bsize].vf(src, src_stride,
-                                rec_buffer, 32, &tmp);
+      uint32_t this_dist;
+      cpi->fn_ptr[txm_bsize].vf(src, src_stride, rec_buffer, 32, &this_dist);
+      tmp = this_dist;
     }
   }
-  *dist += (int64_t)tmp * 16;
-
+  *dist += tmp * 16;
   *rate += cost_coeffs(x, plane, block, coeff_ctx, tx_size,
                        scan_order->scan, scan_order->neighbors, 0);
   *skip &= (p->eobs[block] == 0);
diff --git a/vp10/encoder/rdopt.h b/vp10/encoder/rdopt.h
index 74702a9..f4d9b95 100644
--- a/vp10/encoder/rdopt.h
+++ b/vp10/encoder/rdopt.h
@@ -102,9 +102,6 @@
                                          uint8_t *tmp_buf[MAX_MB_PLANE],
                                          int tmp_stride[MAX_MB_PLANE]);
 #endif  // CONFIG_OBMC
-#ifdef __cplusplus
-}  // extern "C"
-#endif
 
 #if CONFIG_AFFINE_MOTION
 static INLINE const YV12_BUFFER_CONFIG *get_upsampled_ref(VP10_COMP *cpi,
@@ -122,4 +119,8 @@
 }
 #endif
 
+#ifdef __cplusplus
+}  // extern "C"
+#endif
+
 #endif  // VP10_ENCODER_RDOPT_H_