From c073e5ca96bc5cf2e20c1c6cbc000be025b2e008 Mon Sep 17 00:00:00 2001
From: John Koleszar <jkoleszar@google.com>
Date: Tue, 16 Oct 2012 14:08:40 -0700
Subject: [PATCH] Force interleaved decoding

Rather than decoding all modes/mvs separately, decode them per MB. This
forces the mode which was already used form the CONFIG_NEWBESTREFMV and
CONFIG_SUPERBLOCKS experiments, and is a precursor to changing to
interleaved encoding.

Change-Id: If19ee74ac8a987846d1cd0cf2b2e02a82f1a43ad
---
 vp8/decoder/decodemv.c   | 85 ----------------------------------------
 vp8/decoder/decodemv.h   |  1 -
 vp8/decoder/decodframe.c | 11 ++----
 vp8/decoder/onyxd_if.c   |  2 -
 vp8/decoder/onyxd_int.h  |  2 -
 5 files changed, 3 insertions(+), 98 deletions(-)

diff --git a/vp8/decoder/decodemv.c b/vp8/decoder/decodemv.c
index fa15af9e9a..4408ae7f91 100644
--- a/vp8/decoder/decodemv.c
+++ b/vp8/decoder/decodemv.c
@@ -1302,91 +1302,6 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
   }
 }
 
-void vp8_decode_mode_mvs(VP8D_COMP *pbi) {
-  int i;
-  VP8_COMMON *cm = &pbi->common;
-  MODE_INFO *mi = cm->mi;
-  MACROBLOCKD *const xd  = &pbi->mb;
-  int sb_row, sb_col;
-  int sb_rows = (cm->mb_rows + 1) >> 1;
-  int sb_cols = (cm->mb_cols + 1) >> 1;
-  int row_delta[4] = { 0, +1,  0, -1};
-  int col_delta[4] = { +1, -1, +1, +1};
-
-  MODE_INFO *prev_mi = cm->prev_mi;
-
-  mb_mode_mv_init(pbi);
-
-  if (cm->frame_type == KEY_FRAME && !cm->kf_ymode_probs_update) {
-    cm->kf_ymode_probs_index = vp8_read_literal(&pbi->bc, 3);
-  }
-
-  for (sb_row = 0; sb_row < sb_rows; sb_row++) {
-    int mb_col = 0;
-    int mb_row = (sb_row << 1);
-
-    for (sb_col = 0; sb_col < sb_cols; sb_col++) {
-#if CONFIG_SUPERBLOCKS
-      mi->mbmi.encoded_as_sb = vp8_read(&pbi->bc, cm->sb_coded);
-#endif
-      for (i = 0; i < 4; i++) {
-
-        int dy = row_delta[i];
-        int dx = col_delta[i];
-        int offset_extended = dy * cm->mode_info_stride + dx;
-
-        if ((mb_row >= cm->mb_rows) || (mb_col >= cm->mb_cols)) {
-          /* next macroblock */
-          mb_row += dy;
-          mb_col += dx;
-          mi += offset_extended;
-          prev_mi += offset_extended;
-          continue;
-        }
-#if CONFIG_SUPERBLOCKS
-        if (i)
-          mi->mbmi.encoded_as_sb = 0;
-#endif
-
-        // Make sure the MacroBlockD mode info pointer is set correctly
-        xd->mode_info_context = mi;
-        xd->prev_mode_info_context = prev_mi;
-
-        pbi->mb.mb_to_top_edge = -((mb_row * 16)) << 3;
-        pbi->mb.mb_to_bottom_edge =
-            ((pbi->common.mb_rows - 1 - mb_row) * 16) << 3;
-
-        if (cm->frame_type == KEY_FRAME)
-          vp8_kfread_modes(pbi, mi, mb_row, mb_col);
-        else
-          read_mb_modes_mv(pbi, mi, &mi->mbmi, prev_mi, mb_row,
-                           mb_col);
-
-#if CONFIG_SUPERBLOCKS
-        if (mi->mbmi.encoded_as_sb) {
-          assert(!i);
-          mb_col += 2;
-          mi[1] = mi[cm->mode_info_stride] =
-            mi[cm->mode_info_stride + 1] = mi[0];
-          mi += 2;
-          prev_mi += 2;
-          break;
-        }
-#endif
-
-        /* next macroblock */
-        mb_row += dy;
-        mb_col += dx;
-        mi += offset_extended;
-        prev_mi += offset_extended;
-      }
-    }
-
-    mi += cm->mode_info_stride + (1 - (cm->mb_cols & 0x1));
-    prev_mi += cm->mode_info_stride + (1 - (cm->mb_cols & 0x1));
-  }
-}
-
 void vpx_decode_mode_mvs_init(VP8D_COMP *pbi){
   VP8_COMMON *cm = &pbi->common;
   mb_mode_mv_init(pbi);
diff --git a/vp8/decoder/decodemv.h b/vp8/decoder/decodemv.h
index 17bbb5b674..9629f952be 100644
--- a/vp8/decoder/decodemv.h
+++ b/vp8/decoder/decodemv.h
@@ -11,7 +11,6 @@
 
 #include "onyxd_int.h"
 
-void vp8_decode_mode_mvs(VP8D_COMP *);
 void vpx_decode_mb_mode_mv(VP8D_COMP *pbi,
                            MACROBLOCKD *xd,
                            int mb_row,
diff --git a/vp8/decoder/decodframe.c b/vp8/decoder/decodframe.c
index c46957202a..bcf6ea3d4f 100644
--- a/vp8/decoder/decodframe.c
+++ b/vp8/decoder/decodframe.c
@@ -635,8 +635,7 @@ decode_sb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mbrow, MACROBLOCKD *xd) {
     MODE_INFO *mi = xd->mode_info_context;
 
 #if CONFIG_SUPERBLOCKS
-    if (pbi->interleaved_decoding)
-      mi->mbmi.encoded_as_sb = vp8_read(&pbi->bc, pc->sb_coded);
+    mi->mbmi.encoded_as_sb = vp8_read(&pbi->bc, pc->sb_coded);
 #endif
 
     // Process the 4 MBs within the SB in the order:
@@ -685,8 +684,7 @@ decode_sb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mbrow, MACROBLOCKD *xd) {
       if (i)
         mi->mbmi.encoded_as_sb = 0;
 #endif
-      if(pbi->interleaved_decoding)
-        vpx_decode_mb_mode_mv(pbi, xd, mb_row, mb_col);
+      vpx_decode_mb_mode_mv(pbi, xd, mb_row, mb_col);
 
       update_blockd_bmi(xd);
 
@@ -1510,10 +1508,7 @@ int vp8_decode_frame(VP8D_COMP *pbi) {
   /* Read the mb_no_coeff_skip flag */
   pc->mb_no_coeff_skip = (int)vp8_read_bit(bc);
 
-  if(pbi->interleaved_decoding)
-    vpx_decode_mode_mvs_init(pbi);
-  else
-    vp8_decode_mode_mvs(pbi);
+  vpx_decode_mode_mvs_init(pbi);
 
   vpx_memset(pc->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) * pc->mb_cols);
 
diff --git a/vp8/decoder/onyxd_if.c b/vp8/decoder/onyxd_if.c
index aa3ef81b38..2e7751325d 100644
--- a/vp8/decoder/onyxd_if.c
+++ b/vp8/decoder/onyxd_if.c
@@ -149,8 +149,6 @@ VP8D_PTR vp8dx_create_decompressor(VP8D_CONFIG *oxcf) {
 
   pbi->decoded_key_frame = 0;
 
-  pbi->interleaved_decoding = CONFIG_NEWBESTREFMV || CONFIG_SUPERBLOCKS;
-
   return (VP8D_PTR) pbi;
 }
 
diff --git a/vp8/decoder/onyxd_int.h b/vp8/decoder/onyxd_int.h
index 53350b8193..b757f77645 100644
--- a/vp8/decoder/onyxd_int.h
+++ b/vp8/decoder/onyxd_int.h
@@ -82,8 +82,6 @@ typedef struct VP8Decompressor {
 
   int decoded_key_frame;
 
-  int interleaved_decoding;
-
 } VP8D_COMP;
 
 int vp8_decode_frame(VP8D_COMP *cpi);
-- 
GitLab