From 4f792921e74cff85fd130cf482669846fcd809e5 Mon Sep 17 00:00:00 2001
From: Paul Wilkins <paulwilkins@google.com>
Date: Fri, 18 Nov 2011 19:44:57 +0000
Subject: [PATCH] CONFIG_T8X8 experiment.:

Block the selection of 4x4 modes in key frames if 8x8 is selected.

Change-Id: Ie5729ec22a999d9a1996f020bd4b941e29514992
---
 vp8/encoder/encodeframe.c |  3 ++-
 vp8/encoder/pickinter.c   | 17 +++++++++++++++++
 vp8/encoder/rdopt.c       | 19 +++++++++++++++++++
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c
index 7a8683a9dd..da6d7a4510 100644
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -1355,7 +1355,8 @@ int vp8cx_encode_intra_macro_block(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t)
     vp8_tokenize_mb(cpi, &x->e_mbd, t);
 #if CONFIG_T8X8
         if ( get_seg_tx_type(&x->e_mbd,
-                             x->e_mbd.mode_info_context->mbmi.segment_id) )
+                             x->e_mbd.mode_info_context->mbmi.segment_id)
+             == TX_8X8 )
         {
             cpi->t8x8_count++;
         }
diff --git a/vp8/encoder/pickinter.c b/vp8/encoder/pickinter.c
index 4d8c0b97be..73595738bf 100644
--- a/vp8/encoder/pickinter.c
+++ b/vp8/encoder/pickinter.c
@@ -539,12 +539,14 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
         {
             continue;
         }
+#if CONFIG_T8X8
         // No 4x4 modes if segment flagged as 8x8
         else if ( ( get_seg_tx_type( xd, segment_id ) == TX_8X8 ) &&
                   ( (this_mode == B_PRED) || (this_mode == SPLITMV) ) )
         {
             continue;
         }
+#endif
 //#if !CONFIG_SEGFEATURES
         // Disable this drop out case if either the mode or ref frame
         // segment level feature is enabled for this segment. This is to
@@ -920,6 +922,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
 
 void vp8_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate_)
 {
+    MACROBLOCKD *xd = &x->e_mbd;
     int error4x4, error16x16 = INT_MAX;
     int rate, best_rate = 0, distortion, best_sse;
     MB_PREDICTION_MODE mode, best_mode = DC_PRED;
@@ -951,8 +954,22 @@ void vp8_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate_)
     }
     x->e_mbd.mode_info_context->mbmi.mode = best_mode;
 
+#if CONFIG_T8X8
+    if ( get_seg_tx_type( xd,
+                          xd->mode_info_context->mbmi.segment_id ) == TX_4X4 )
+    {
+        error4x4 = pick_intra4x4mby_modes(IF_RTCD(&cpi->rtcd), x, &rate,
+                                          &best_sse);
+    }
+    else
+    {
+        error4x4 = INT_MAX;
+    }
+#else
     error4x4 = pick_intra4x4mby_modes(IF_RTCD(&cpi->rtcd), x, &rate,
                                       &best_sse);
+#endif
+
     if (error4x4 < error16x16)
     {
         x->e_mbd.mode_info_context->mbmi.mode = B_PRED;
diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c
index 688451f050..ab801f30f7 100644
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -2146,12 +2146,15 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
         {
             continue;
         }
+#if CONFIG_T8X8
         // No 4x4 modes if segment flagged as 8x8
         else if ( ( get_seg_tx_type( xd, segment_id ) == TX_8X8 ) &&
                   ( (this_mode == B_PRED) || (this_mode == SPLITMV) ) )
         {
             continue;
         }
+#endif
+
 //#if !CONFIG_SEGFEATURES
         // Disable this drop out case if either the mode or ref frame
         // segment level feature is enabled for this segment. This is to
@@ -2729,6 +2732,7 @@ static void set_i8x8_block_modes(MACROBLOCK *x, int *modes)
 
 void vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate_)
 {
+    MACROBLOCKD *xd = &x->e_mbd;
     int error4x4, error16x16;
     int rate4x4, rate16x16 = 0, rateuv;
     int dist4x4, dist16x16, distuv;
@@ -2761,9 +2765,24 @@ void vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate_)
     mode8x8[2]= x->e_mbd.mode_info_context->bmi[8].as_mode;
     mode8x8[3]= x->e_mbd.mode_info_context->bmi[10].as_mode;
 #endif
+
+#if CONFIG_T8X8
+    if ( get_seg_tx_type( xd,
+                          xd->mode_info_context->mbmi.segment_id ) == TX_4X4 )
+    {
+        error4x4 = rd_pick_intra4x4mby_modes(cpi, x,
+                                             &rate4x4, &rate4x4_tokenonly,
+                                             &dist4x4, error16x16);
+    }
+    else
+    {
+        error4x4 = INT_MAX;
+    }
+#else
     error4x4 = rd_pick_intra4x4mby_modes(cpi, x,
                                          &rate4x4, &rate4x4_tokenonly,
                                          &dist4x4, error16x16);
+#endif
 
 #if CONFIG_I8X8
     if(error8x8> error16x16)
-- 
GitLab