Enable rectangular support for comp inter-intra
authorJingning Han <jingning@google.com>
Tue, 23 Apr 2013 22:07:35 +0000 (15:07 -0700)
committerJingning Han <jingning@google.com>
Tue, 23 Apr 2013 22:39:19 +0000 (15:39 -0700)
This commit enables rectangular block prediction of compound
inter-intra mode. It combines the mb/sb32/sb64 prediction functions
into a unified version with configurable block width and height.
This fixes the enc/dec mismatch of the codebase when
comp-interintra-pred is enabled.

Change-Id: I1d0db2f1f184007802df04fcd12b9dadb3189ff0

vp9/common/vp9_reconinter.c
vp9/common/vp9_reconintra.c
vp9/common/vp9_reconintra.h
vp9/encoder/vp9_encodeframe.c

index 80eb2c6..c2e0f2f 100644 (file)
@@ -447,14 +447,10 @@ void vp9_build_inter_predictors_sb(MACROBLOCKD *xd,
   vp9_build_inter_predictors_sbuv(xd, mb_row, mb_col, bsize);
 
 #if CONFIG_COMP_INTERINTRA_PRED
-  if (xd->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME) {
-    if (bsize == BLOCK_SIZE_SB32X32)
-      vp9_build_interintra_32x32_predictors_sb(xd, y, u, v,
-                                               y_stride, uv_stride);
-    else
-      vp9_build_interintra_64x64_predictors_sb(xd, y, u, v,
-                                               y_stride, uv_stride);
-  }
+  if (xd->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME)
+    vp9_build_interintra_predictors(xd, y, u, v,
+                                    y_stride, uv_stride,
+                                    bsize);
 #endif
 }
 
index 6caebd7..0e3c68d 100644 (file)
@@ -465,7 +465,7 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
                                int interstride,
                                uint8_t *intrapred,
                                int intrastride,
-                               int size) {
+                               int bw, int bh) {
   // TODO(debargha): Explore different ways of combining predictors
   //                 or designing the tables below
   static const int scale_bits = 8;
@@ -483,6 +483,7 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
      68,  68,  68,  67,  67,  67,  67,  67,
   };
 
+  int size = MAX(bw, bh);
   int size_scale = (size >= 64 ? 1:
                     size == 32 ? 2 :
                     size == 16 ? 4 :
@@ -490,8 +491,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
   int i, j;
   switch (mode) {
     case V_PRED:
-      for (i = 0; i < size; ++i) {
-        for (j = 0; j < size; ++j) {
+      for (i = 0; i < bh; ++i) {
+        for (j = 0; j < bw; ++j) {
           int k = i * interstride + j;
           int scale = weights1d[i * size_scale];
           interpred[k] =
@@ -503,8 +504,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
       break;
 
     case H_PRED:
-      for (i = 0; i < size; ++i) {
-        for (j = 0; j < size; ++j) {
+      for (i = 0; i < bh; ++i) {
+        for (j = 0; j < bw; ++j) {
           int k = i * interstride + j;
           int scale = weights1d[j * size_scale];
           interpred[k] =
@@ -517,8 +518,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
 
     case D63_PRED:
     case D117_PRED:
-      for (i = 0; i < size; ++i) {
-        for (j = 0; j < size; ++j) {
+      for (i = 0; i < bh; ++i) {
+        for (j = 0; j < bw; ++j) {
           int k = i * interstride + j;
           int scale = (weights1d[i * size_scale] * 3 +
                        weights1d[j * size_scale]) >> 2;
@@ -532,8 +533,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
 
     case D27_PRED:
     case D153_PRED:
-      for (i = 0; i < size; ++i) {
-        for (j = 0; j < size; ++j) {
+      for (i = 0; i < bh; ++i) {
+        for (j = 0; j < bw; ++j) {
           int k = i * interstride + j;
           int scale = (weights1d[j * size_scale] * 3 +
                        weights1d[i * size_scale]) >> 2;
@@ -546,8 +547,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
       break;
 
     case D135_PRED:
-      for (i = 0; i < size; ++i) {
-        for (j = 0; j < size; ++j) {
+      for (i = 0; i < bh; ++i) {
+        for (j = 0; j < bw; ++j) {
           int k = i * interstride + j;
           int scale = weights1d[(i < j ? i : j) * size_scale];
           interpred[k] =
@@ -559,8 +560,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
       break;
 
     case D45_PRED:
-      for (i = 0; i < size; ++i) {
-        for (j = 0; j < size; ++j) {
+      for (i = 0; i < bh; ++i) {
+        for (j = 0; j < bw; ++j) {
           int k = i * interstride + j;
           int scale = (weights1d[i * size_scale] +
                        weights1d[j * size_scale]) >> 1;
@@ -576,8 +577,8 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
     case DC_PRED:
     default:
       // simple average
-      for (i = 0; i < size; ++i) {
-        for (j = 0; j < size; ++j) {
+      for (i = 0; i < bh; ++i) {
+        for (j = 0; j < bw; ++j) {
           int k = i * interstride + j;
           interpred[k] = (interpred[k] + intrapred[i * intrastride + j]) >> 1;
         }
@@ -586,137 +587,55 @@ static void combine_interintra(MB_PREDICTION_MODE mode,
   }
 }
 
-void vp9_build_interintra_16x16_predictors_mb(MACROBLOCKD *xd,
+void vp9_build_interintra_predictors(MACROBLOCKD *xd,
                                               uint8_t *ypred,
                                               uint8_t *upred,
                                               uint8_t *vpred,
-                                              int ystride, int uvstride) {
-  vp9_build_interintra_16x16_predictors_mby(xd, ypred, ystride);
-  vp9_build_interintra_16x16_predictors_mbuv(xd, upred, vpred, uvstride);
+                                              int ystride, int uvstride,
+                                              BLOCK_SIZE_TYPE bsize) {
+  vp9_build_interintra_predictors_sby(xd, ypred, ystride, bsize);
+  vp9_build_interintra_predictors_sbuv(xd, upred, vpred, uvstride, bsize);
 }
 
-void vp9_build_interintra_16x16_predictors_mby(MACROBLOCKD *xd,
+void vp9_build_interintra_predictors_sby(MACROBLOCKD *xd,
                                                uint8_t *ypred,
-                                               int ystride) {
-  uint8_t intrapredictor[256];
-  vp9_build_intra_predictors(
-      xd->plane[0].dst.buf, xd->plane[0].dst.stride,
-      intrapredictor, 16,
-      xd->mode_info_context->mbmi.interintra_mode, 16, 16,
-      xd->up_available, xd->left_available, xd->right_available);
-  combine_interintra(xd->mode_info_context->mbmi.interintra_mode,
-                     ypred, ystride, intrapredictor, 16, 16);
-}
-
-void vp9_build_interintra_16x16_predictors_mbuv(MACROBLOCKD *xd,
-                                                uint8_t *upred,
-                                                uint8_t *vpred,
-                                                int uvstride) {
-  uint8_t uintrapredictor[64];
-  uint8_t vintrapredictor[64];
-  vp9_build_intra_predictors(
-      xd->plane[1].dst.buf, xd->plane[1].dst.stride,
-      uintrapredictor, 8,
-      xd->mode_info_context->mbmi.interintra_uv_mode, 8, 8,
-      xd->up_available, xd->left_available, xd->right_available);
-  vp9_build_intra_predictors(
-      xd->plane[2].dst.buf, xd->plane[1].dst.stride,
-      vintrapredictor, 8,
-      xd->mode_info_context->mbmi.interintra_uv_mode, 8, 8,
-      xd->up_available, xd->left_available, xd->right_available);
-  combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
-                     upred, uvstride, uintrapredictor, 8, 8);
-  combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
-                     vpred, uvstride, vintrapredictor, 8, 8);
-}
-
-void vp9_build_interintra_32x32_predictors_sby(MACROBLOCKD *xd,
-                                               uint8_t *ypred,
-                                               int ystride) {
-  uint8_t intrapredictor[1024];
+                                               int ystride,
+                                               BLOCK_SIZE_TYPE bsize) {
+  int bwl = mb_width_log2(bsize),  bw = 16 << bwl;
+  int bhl = mb_height_log2(bsize), bh = 16 << bhl;
+  uint8_t intrapredictor[4096];
   vp9_build_intra_predictors(
       xd->plane[0].dst.buf, xd->plane[0].dst.stride,
-      intrapredictor, 32,
-      xd->mode_info_context->mbmi.interintra_mode, 32, 32,
+      intrapredictor, bw,
+      xd->mode_info_context->mbmi.interintra_mode, bw, bh,
       xd->up_available, xd->left_available, xd->right_available);
   combine_interintra(xd->mode_info_context->mbmi.interintra_mode,
-                     ypred, ystride, intrapredictor, 32, 32);
+                     ypred, ystride, intrapredictor, bw, bw, bh);
 }
 
-void vp9_build_interintra_32x32_predictors_sbuv(MACROBLOCKD *xd,
+void vp9_build_interintra_predictors_sbuv(MACROBLOCKD *xd,
                                                 uint8_t *upred,
                                                 uint8_t *vpred,
-                                                int uvstride) {
-  uint8_t uintrapredictor[256];
-  uint8_t vintrapredictor[256];
+                                                int uvstride,
+                                                BLOCK_SIZE_TYPE bsize) {
+  int bwl = mb_width_log2(bsize),  bw = 8 << bwl;
+  int bhl = mb_height_log2(bsize), bh = 8 << bhl;
+  uint8_t uintrapredictor[1024];
+  uint8_t vintrapredictor[1024];
   vp9_build_intra_predictors(
       xd->plane[1].dst.buf, xd->plane[1].dst.stride,
-      uintrapredictor, 16,
-      xd->mode_info_context->mbmi.interintra_uv_mode, 16, 16,
+      uintrapredictor, bw,
+      xd->mode_info_context->mbmi.interintra_uv_mode, bw, bh,
       xd->up_available, xd->left_available, xd->right_available);
   vp9_build_intra_predictors(
       xd->plane[2].dst.buf, xd->plane[1].dst.stride,
-      vintrapredictor, 16,
-      xd->mode_info_context->mbmi.interintra_uv_mode, 16, 16,
+      vintrapredictor, bw,
+      xd->mode_info_context->mbmi.interintra_uv_mode, bw, bh,
       xd->up_available, xd->left_available, xd->right_available);
   combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
-                     upred, uvstride, uintrapredictor, 16, 16);
-  combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
-                     vpred, uvstride, vintrapredictor, 16, 16);
-}
-
-void vp9_build_interintra_32x32_predictors_sb(MACROBLOCKD *xd,
-                                              uint8_t *ypred,
-                                              uint8_t *upred,
-                                              uint8_t *vpred,
-                                              int ystride,
-                                              int uvstride) {
-  vp9_build_interintra_32x32_predictors_sby(xd, ypred, ystride);
-  vp9_build_interintra_32x32_predictors_sbuv(xd, upred, vpred, uvstride);
-}
-
-void vp9_build_interintra_64x64_predictors_sby(MACROBLOCKD *xd,
-                                               uint8_t *ypred,
-                                               int ystride) {
-  uint8_t intrapredictor[4096];
-  const int mode = xd->mode_info_context->mbmi.interintra_mode;
-  vp9_build_intra_predictors(xd->plane[0].dst.buf, xd->plane[0].dst.stride,
-                             intrapredictor, 64, mode, 64, 64,
-                             xd->up_available, xd->left_available,
-                             xd->right_available);
-  combine_interintra(xd->mode_info_context->mbmi.interintra_mode,
-                     ypred, ystride, intrapredictor, 64, 64);
-}
-
-void vp9_build_interintra_64x64_predictors_sbuv(MACROBLOCKD *xd,
-                                                uint8_t *upred,
-                                                uint8_t *vpred,
-                                                int uvstride) {
-  uint8_t uintrapredictor[1024];
-  uint8_t vintrapredictor[1024];
-  const int mode = xd->mode_info_context->mbmi.interintra_uv_mode;
-  vp9_build_intra_predictors(xd->plane[1].dst.buf, xd->plane[1].dst.stride,
-                             uintrapredictor, 32, mode, 32, 32,
-                             xd->up_available, xd->left_available,
-                             xd->right_available);
-  vp9_build_intra_predictors(xd->plane[2].dst.buf, xd->plane[1].dst.stride,
-                             vintrapredictor, 32, mode, 32, 32,
-                             xd->up_available, xd->left_available,
-                             xd->right_available);
-  combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
-                     upred, uvstride, uintrapredictor, 32, 32);
+                     upred, uvstride, uintrapredictor, bw, bw, bh);
   combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
-                     vpred, uvstride, vintrapredictor, 32, 32);
-}
-
-void vp9_build_interintra_64x64_predictors_sb(MACROBLOCKD *xd,
-                                              uint8_t *ypred,
-                                              uint8_t *upred,
-                                              uint8_t *vpred,
-                                              int ystride,
-                                              int uvstride) {
-  vp9_build_interintra_64x64_predictors_sby(xd, ypred, ystride);
-  vp9_build_interintra_64x64_predictors_sbuv(xd, upred, vpred, uvstride);
+                     vpred, uvstride, vintrapredictor, bw, bw, bh);
 }
 #endif  // CONFIG_COMP_INTERINTRA_PRED
 
index 1e0cfa4..e943596 100644 (file)
@@ -21,35 +21,24 @@ B_PREDICTION_MODE vp9_find_dominant_direction(uint8_t *ptr,
 B_PREDICTION_MODE vp9_find_bpred_context(MACROBLOCKD *xd, BLOCKD *x);
 
 #if CONFIG_COMP_INTERINTRA_PRED
-void vp9_build_interintra_16x16_predictors_mb(MACROBLOCKD *xd,
-                                              uint8_t *ypred,
-                                              uint8_t *upred,
-                                              uint8_t *vpred,
-                                              int ystride,
-                                              int uvstride);
-
-void vp9_build_interintra_16x16_predictors_mby(MACROBLOCKD *xd,
-                                               uint8_t *ypred,
-                                               int ystride);
-
-void vp9_build_interintra_16x16_predictors_mbuv(MACROBLOCKD *xd,
-                                                uint8_t *upred,
-                                                uint8_t *vpred,
-                                                int uvstride);
+void vp9_build_interintra_predictors(MACROBLOCKD *xd,
+                                     uint8_t *ypred,
+                                     uint8_t *upred,
+                                     uint8_t *vpred,
+                                     int ystride,
+                                     int uvstride,
+                                     BLOCK_SIZE_TYPE bsize);
+
+void vp9_build_interintra_predictors_sby(MACROBLOCKD *xd,
+                                         uint8_t *ypred,
+                                         int ystride,
+                                         BLOCK_SIZE_TYPE bsize);
+
+void vp9_build_interintra_predictors_sbuv(MACROBLOCKD *xd,
+                                          uint8_t *upred,
+                                          uint8_t *vpred,
+                                          int uvstride,
+                                          BLOCK_SIZE_TYPE bsize);
 #endif  // CONFIG_COMP_INTERINTRA_PRED
 
-void vp9_build_interintra_32x32_predictors_sb(MACROBLOCKD *xd,
-                                              uint8_t *ypred,
-                                              uint8_t *upred,
-                                              uint8_t *vpred,
-                                              int ystride,
-                                              int uvstride);
-
-void vp9_build_interintra_64x64_predictors_sb(MACROBLOCKD *xd,
-                                              uint8_t *ypred,
-                                              uint8_t *upred,
-                                              uint8_t *vpred,
-                                              int ystride,
-                                              int uvstride);
-
 #endif  // VP9_COMMON_VP9_RECONINTRA_H_
index 1f20d5e..407da9e 100644 (file)
@@ -1989,12 +1989,13 @@ static void encode_macroblock(VP9_COMP *cpi, TOKENEXTRA **t,
       vp9_build_inter_predictors_sb(xd, mb_row, mb_col, BLOCK_SIZE_MB16X16);
 #if CONFIG_COMP_INTERINTRA_PRED
       if (xd->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME) {
-        vp9_build_interintra_16x16_predictors_mb(xd,
-                                                 xd->plane[0].dst.buf,
-                                                 xd->plane[1].dst.buf,
-                                                 xd->plane[2].dst.buf,
-                                                 xd->plane[0].dst.stride,
-                                                 xd->plane[1].dst.stride);
+        vp9_build_interintra_predictors(xd,
+                                        xd->plane[0].dst.buf,
+                                        xd->plane[1].dst.buf,
+                                        xd->plane[2].dst.buf,
+                                        xd->plane[0].dst.stride,
+                                        xd->plane[1].dst.stride,
+                                        BLOCK_SIZE_MB16X16);
       }
 #endif
     }