shithub: libvpx

Download patch

ref: 79d330d7d5f948f66c38fc7a7bddb24134189ba8
parent: 8b71f3e0593a5163368412c4976238c6b174a344
author: Paul Wilkins <paulwilkins@google.com>
date: Thu Feb 16 12:02:17 EST 2012

Code simplification

Removal of the pickinter.c and .h files and calls to this
code.

Removal of some code relating to real time and one pass
settings  though there is more to be done in this regard.

However,  vp8_set_speed_features() now
only supports modes 0 and 1 and speeds up to 3
so rd should always be set.

Change-Id: I62c0c1b6154ab499785baef310536080e87bc4d8

--- a/vp8/common/alloccommon.c
+++ b/vp8/common/alloccommon.c
@@ -186,17 +186,19 @@
         cm->full_pixel = 0;
         break;
     case 2:
+    case 3:
         cm->no_lpf = 1;
         cm->filter_type = NORMAL_LOOPFILTER;
         cm->use_bilinear_mc_filter = 1;
         cm->full_pixel = 0;
         break;
-    case 3:
-        cm->no_lpf = 1;
-        cm->filter_type = SIMPLE_LOOPFILTER;
-        cm->use_bilinear_mc_filter = 1;
-        cm->full_pixel = 1;
-        break;
+    // Full pel only code deprecated in experimental code base
+    //case 3:
+    //    cm->no_lpf = 1;
+    //    cm->filter_type = SIMPLE_LOOPFILTER;
+    //    cm->use_bilinear_mc_filter = 1;
+    //    cm->full_pixel = 1;
+    //    break;
     }
 }
 void vp8_create_common(VP8_COMMON *oci)
--- a/vp8/encoder/arm/arm_csystemdependent.c
+++ b/vp8/encoder/arm/arm_csystemdependent.c
@@ -56,8 +56,6 @@
         cpi->rtcd.variance.mse16x16              = vp8_mse16x16_armv6;
         /*cpi->rtcd.variance.getmbss               = vp8_get_mb_ss_c;*/
 
-        /*cpi->rtcd.variance.get4x4sse_cs          = vp8_get4x4sse_cs_c;*/
-
         cpi->rtcd.fdct.short4x4                  = vp8_short_fdct4x4_armv6;
         cpi->rtcd.fdct.short8x4                  = vp8_short_fdct8x4_armv6;
         cpi->rtcd.fdct.fast4x4                   = vp8_short_fdct4x4_armv6;
@@ -102,8 +100,6 @@
 
         cpi->rtcd.variance.mse16x16              = vp8_mse16x16_neon;
         /*cpi->rtcd.variance.getmbss               = vp8_get_mb_ss_c;*/
-
-        cpi->rtcd.variance.get4x4sse_cs          = vp8_get4x4sse_cs_neon;
 
         cpi->rtcd.fdct.short4x4                  = vp8_short_fdct4x4_neon;
         cpi->rtcd.fdct.short8x4                  = vp8_short_fdct8x4_neon;
--- a/vp8/encoder/arm/variance_arm.h
+++ b/vp8/encoder/arm/variance_arm.h
@@ -83,7 +83,6 @@
 
 //extern prototype_getmbss(vp8_get_mb_ss_c);
 extern prototype_variance(vp8_mse16x16_neon);
-extern prototype_get16x16prederror(vp8_get4x4sse_cs_neon);
 
 #if !CONFIG_RUNTIME_CPU_DETECT
 #undef  vp8_variance_sad4x4
@@ -146,8 +145,6 @@
 #undef  vp8_variance_mse16x16
 #define vp8_variance_mse16x16 vp8_mse16x16_neon
 
-#undef  vp8_variance_get4x4sse_cs
-#define vp8_variance_get4x4sse_cs vp8_get4x4sse_cs_neon
 #endif
 
 #endif
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -22,7 +22,6 @@
 #include "encodeintra.h"
 #include "vp8/common/reconinter.h"
 #include "rdopt.h"
-#include "pickinter.h"
 #include "vp8/common/findnearmv.h"
 #include "vp8/common/reconintra.h"
 #include "vp8/common/seg_common.h"
@@ -1161,14 +1160,6 @@
 
     totalrate = 0;
 
-    if (cpi->compressor_speed == 2)
-    {
-        if (cpi->oxcf.cpu_used < 0)
-            cpi->Speed = -(cpi->oxcf.cpu_used);
-        else
-            vp8_auto_select_speed(cpi);
-    }
-
     // Functions setup for all frame types so we can use MC in AltRef
     if (cm->mcomp_filter_type == SIXTAP)
     {
@@ -1579,10 +1570,11 @@
 {
     int rate;
 
-    if (cpi->sf.RD && cpi->compressor_speed != 2)
-        vp8_rd_pick_intra_mode(cpi, x, &rate);
-    else
-        vp8_pick_intra_mode(cpi, x, &rate);
+    // Non rd path deprecated in test code base
+    //if (cpi->sf.RD && cpi->compressor_speed != 2)
+    vp8_rd_pick_intra_mode(cpi, x, &rate);
+    //else
+    //   vp8_pick_intra_mode(cpi, x, &rate);
 
     if(cpi->oxcf.tuning == VP8_TUNE_SSIM)
     {
@@ -1651,7 +1643,8 @@
     else
         x->encode_breakout = cpi->oxcf.encode_breakout;
 
-    if (cpi->sf.RD)
+    //if (cpi->sf.RD)
+    // For now this codebase is limited to a single rd encode path
     {
         int zbin_mode_boost_enabled = cpi->zbin_mode_boost_enabled;
         int single, dual, hybrid;
@@ -1715,9 +1708,10 @@
         cpi->zbin_mode_boost_enabled = zbin_mode_boost_enabled;
 
     }
-    else
-        vp8_pick_inter_mode(cpi, x, recon_yoffset, recon_uvoffset, &rate,
-                            &distortion, &intra_error);
+    //else
+    // The non rd encode path has been deleted from this code base
+    // to simplify development
+    //    vp8_pick_inter_mode
 
     cpi->prediction_error += distortion;
     cpi->intra_error += intra_error;
--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -1002,7 +1002,7 @@
 
     // Corrections for higher compression speed settings
     // (reduced compression expected)
-    if ((cpi->compressor_speed == 3) || (cpi->compressor_speed == 1))
+    if (cpi->compressor_speed == 1)
     {
         if (cpi->oxcf.cpu_used <= 5)
             speed_correction = 1.04 + (cpi->oxcf.cpu_used * 0.04);
@@ -1105,7 +1105,7 @@
 
     // Corrections for higher compression speed settings
     // (reduced compression expected)
-    if ((cpi->compressor_speed == 3) || (cpi->compressor_speed == 1))
+    if (cpi->compressor_speed == 1)
     {
         if (cpi->oxcf.cpu_used <= 5)
             speed_correction = 1.04 + (cpi->oxcf.cpu_used * 0.04);
@@ -1173,7 +1173,7 @@
     target_norm_bits_per_mb = (section_target_bandwitdh < (1 << 20)) ? (512 * section_target_bandwitdh) / num_mbs : 512 * (section_target_bandwitdh / num_mbs);
 
     // Corrections for higher compression speed settings (reduced compression expected)
-    if ((cpi->compressor_speed == 3) || (cpi->compressor_speed == 1))
+    if (cpi->compressor_speed == 1)
     {
         if (cpi->oxcf.cpu_used <= 5)
             speed_correction = 1.04 + (cpi->oxcf.cpu_used * 0.04);
@@ -1246,7 +1246,7 @@
         iiratio_correction_factor = 0.5;
 
     // Corrections for higher compression speed settings (reduced compression expected)
-    if ((cpi->compressor_speed == 3) || (cpi->compressor_speed == 1))
+    if (cpi->compressor_speed == 1)
     {
         if (cpi->oxcf.cpu_used <= 5)
             speed_correction = 1.04 + (cpi->oxcf.cpu_used * 0.04);
--- a/vp8/encoder/generic/csystemdependent.c
+++ b/vp8/encoder/generic/csystemdependent.c
@@ -69,8 +69,6 @@
     cpi->rtcd.variance.mse16x16              = vp8_mse16x16_c;
     cpi->rtcd.variance.getmbss               = vp8_get_mb_ss_c;
 
-    cpi->rtcd.variance.get4x4sse_cs          = vp8_get4x4sse_cs_c;
-
 #if CONFIG_T8X8
     cpi->rtcd.fdct.short8x8                  = vp8_short_fdct8x8_c;
     cpi->rtcd.fdct.haar_short2x2             = vp8_short_fhaar2x2_c;
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -792,6 +792,10 @@
     VP8_COMMON *cm = &cpi->common;
     int last_improved_quant = sf->improved_quant;
 
+    // Only modes 0 and 1 supported for now in experimental code basae
+    if ( Mode > 1 )
+        Mode = 1;
+
     // Initialise default mode frequency sampling variables
     for (i = 0; i < MAX_MODES; i ++)
     {
@@ -871,7 +875,6 @@
         sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
         break;
     case 1:
-    case 3:
         sf->thresh_mult[THR_NEARESTMV] = 0;
         sf->thresh_mult[THR_ZEROMV   ] = 0;
         sf->thresh_mult[THR_DC       ] = 0;
@@ -890,7 +893,6 @@
         sf->thresh_mult[THR_NEARG    ] = 1000;
         sf->thresh_mult[THR_NEARA    ] = 1000;
 
-#if 1
         sf->thresh_mult[THR_ZEROMV   ] = 0;
         sf->thresh_mult[THR_ZEROG    ] = 0;
         sf->thresh_mult[THR_ZEROA    ] = 0;
@@ -901,13 +903,6 @@
         sf->thresh_mult[THR_NEARG    ] = 0;
         sf->thresh_mult[THR_NEARA    ] = 0;
 
-//        sf->thresh_mult[THR_DC       ] = 0;
-
-//        sf->thresh_mult[THR_V_PRED   ] = 1000;
-//        sf->thresh_mult[THR_H_PRED   ] = 1000;
-//        sf->thresh_mult[THR_B_PRED   ] = 2000;
-//        sf->thresh_mult[THR_TM       ] = 1000;
-
         sf->thresh_mult[THR_NEWMV    ] = 1000;
         sf->thresh_mult[THR_NEWG     ] = 1000;
         sf->thresh_mult[THR_NEWA     ] = 1000;
@@ -929,16 +924,7 @@
         sf->thresh_mult[THR_DUAL_NEWLG    ] = 1000;
         sf->thresh_mult[THR_DUAL_NEWLA    ] = 1000;
         sf->thresh_mult[THR_DUAL_NEWGA    ] = 1000;
-#else
-        sf->thresh_mult[THR_NEWMV    ] = 1500;
-        sf->thresh_mult[THR_NEWG     ] = 1500;
-        sf->thresh_mult[THR_NEWA     ] = 1500;
 
-        sf->thresh_mult[THR_SPLITMV  ] = 5000;
-        sf->thresh_mult[THR_SPLITG   ] = 10000;
-        sf->thresh_mult[THR_SPLITA   ] = 10000;
-#endif
-
         if (Speed > 0)
         {
             /* Disable coefficient optimization above speed 0 */
@@ -1063,454 +1049,8 @@
 
         }
 
-        if (Speed > 3)
-        {
-            sf->thresh_mult[THR_SPLITA  ] = INT_MAX;
-            sf->thresh_mult[THR_SPLITG  ] = INT_MAX;
-            sf->thresh_mult[THR_SPLITMV  ] = INT_MAX;
-
-            cpi->mode_check_freq[THR_V_PRED] = 0;
-            cpi->mode_check_freq[THR_H_PRED] = 0;
-            cpi->mode_check_freq[THR_B_PRED] = 0;
-            cpi->mode_check_freq[THR_I8X8_PRED]   = 0;
-            cpi->mode_check_freq[THR_NEARG] = 0;
-            cpi->mode_check_freq[THR_NEWG] = 0;
-            cpi->mode_check_freq[THR_NEARA] = 0;
-            cpi->mode_check_freq[THR_NEWA] = 0;
-
-            sf->auto_filter = 1;
-            sf->recode_loop = 0; // recode loop off
-            sf->RD = 0;         // Turn rd off
-
-        }
-
-        if (Speed > 4)
-        {
-            sf->auto_filter = 0;                     // Faster selection of loop filter
-
-            cpi->mode_check_freq[THR_V_PRED] = 2;
-            cpi->mode_check_freq[THR_H_PRED] = 2;
-            cpi->mode_check_freq[THR_B_PRED] = 2;
-            cpi->mode_check_freq[THR_I8X8_PRED]=2;
-
-            if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
-            {
-                cpi->mode_check_freq[THR_NEARG] = 2;
-                cpi->mode_check_freq[THR_NEWG] = 4;
-            }
-
-            if (cpi->ref_frame_flags & VP8_ALT_FLAG)
-            {
-                cpi->mode_check_freq[THR_NEARA] = 2;
-                cpi->mode_check_freq[THR_NEWA] = 4;
-            }
-
-            cpi->mode_check_freq[THR_DUAL_NEARLG   ] = 2;
-            cpi->mode_check_freq[THR_DUAL_NEARLA   ] = 2;
-            cpi->mode_check_freq[THR_DUAL_NEARGA   ] = 2;
-            cpi->mode_check_freq[THR_DUAL_NEWLG    ] = 4;
-            cpi->mode_check_freq[THR_DUAL_NEWLA    ] = 4;
-            cpi->mode_check_freq[THR_DUAL_NEWGA    ] = 4;
-
-            if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
-            {
-                sf->thresh_mult[THR_NEARESTG ] = 2000;
-                sf->thresh_mult[THR_ZEROG    ] = 2000;
-                sf->thresh_mult[THR_NEARG    ] = 2000;
-                sf->thresh_mult[THR_NEWG     ] = 4000;
-            }
-
-            if (cpi->ref_frame_flags & VP8_ALT_FLAG)
-            {
-                sf->thresh_mult[THR_NEARESTA ] = 2000;
-                sf->thresh_mult[THR_ZEROA    ] = 2000;
-                sf->thresh_mult[THR_NEARA    ] = 2000;
-                sf->thresh_mult[THR_NEWA     ] = 4000;
-            }
-
-            sf->thresh_mult[THR_DUAL_NEWLG    ] = 4000;
-            sf->thresh_mult[THR_DUAL_NEWLA    ] = 4000;
-            sf->thresh_mult[THR_DUAL_NEWGA    ] = 4000;
-        }
-
         break;
-    case 2:
-        sf->optimize_coefficients = 0;
-        sf->recode_loop = 0;
-        sf->auto_filter = 1;
-        sf->iterative_sub_pixel = 1;
-        sf->thresh_mult[THR_NEARESTMV] = 0;
-        sf->thresh_mult[THR_ZEROMV   ] = 0;
-        sf->thresh_mult[THR_DC       ] = 0;
-        sf->thresh_mult[THR_TM       ] = 0;
-        sf->thresh_mult[THR_NEARMV   ] = 0;
-        sf->thresh_mult[THR_V_PRED   ] = 1000;
-        sf->thresh_mult[THR_H_PRED   ] = 1000;
-        sf->thresh_mult[THR_B_PRED   ] = 2500;
-        sf->thresh_mult[THR_I8X8_PRED] = 2500;
-        sf->thresh_mult[THR_NEARESTG ] = 1000;
-        sf->thresh_mult[THR_ZEROG    ] = 1000;
-        sf->thresh_mult[THR_NEARG    ] = 1000;
-        sf->thresh_mult[THR_NEARESTA ] = 1000;
-        sf->thresh_mult[THR_ZEROA    ] = 1000;
-        sf->thresh_mult[THR_NEARA    ] = 1000;
-        sf->thresh_mult[THR_NEWMV    ] = 2000;
-        sf->thresh_mult[THR_NEWG     ] = 2000;
-        sf->thresh_mult[THR_NEWA     ] = 2000;
-        sf->thresh_mult[THR_SPLITMV  ] = 5000;
-        sf->thresh_mult[THR_SPLITG   ] = 10000;
-        sf->thresh_mult[THR_SPLITA   ] = 10000;
-        sf->search_method = NSTEP;
 
-        sf->thresh_mult[THR_DUAL_ZEROLG   ] = 1000;
-        sf->thresh_mult[THR_DUAL_NEARESTLG] = 1000;
-        sf->thresh_mult[THR_DUAL_NEARLG   ] = 1000;
-        sf->thresh_mult[THR_DUAL_ZEROLA   ] = 1000;
-        sf->thresh_mult[THR_DUAL_NEARESTLA] = 1000;
-        sf->thresh_mult[THR_DUAL_NEARLA   ] = 1000;
-        sf->thresh_mult[THR_DUAL_ZEROGA   ] = 1000;
-        sf->thresh_mult[THR_DUAL_NEARESTGA] = 1000;
-        sf->thresh_mult[THR_DUAL_NEARGA   ] = 1000;
-
-        sf->thresh_mult[THR_DUAL_NEWLG    ] = 2000;
-        sf->thresh_mult[THR_DUAL_NEWLA    ] = 2000;
-        sf->thresh_mult[THR_DUAL_NEWGA    ] = 2000;
-
-        if (Speed > 0)
-        {
-            cpi->mode_check_freq[THR_SPLITG] = 4;
-            cpi->mode_check_freq[THR_SPLITA] = 4;
-            cpi->mode_check_freq[THR_SPLITMV] = 2;
-
-            sf->thresh_mult[THR_DC       ] = 0;
-            sf->thresh_mult[THR_TM       ] = 1000;
-            sf->thresh_mult[THR_V_PRED   ] = 2000;
-            sf->thresh_mult[THR_H_PRED   ] = 2000;
-            sf->thresh_mult[THR_B_PRED   ] = 5000;
-            sf->thresh_mult[THR_I8X8_PRED] = 5000;
-
-            if (cpi->ref_frame_flags & VP8_LAST_FLAG)
-            {
-                sf->thresh_mult[THR_NEARESTMV] = 0;
-                sf->thresh_mult[THR_ZEROMV   ] = 0;
-                sf->thresh_mult[THR_NEARMV   ] = 0;
-                sf->thresh_mult[THR_NEWMV    ] = 2000;
-                sf->thresh_mult[THR_SPLITMV  ] = 10000;
-            }
-
-            if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
-            {
-                sf->thresh_mult[THR_NEARESTG ] = 1000;
-                sf->thresh_mult[THR_ZEROG    ] = 1000;
-                sf->thresh_mult[THR_NEARG    ] = 1000;
-                sf->thresh_mult[THR_NEWG     ] = 2000;
-                sf->thresh_mult[THR_SPLITG   ] = 20000;
-            }
-
-            if (cpi->ref_frame_flags & VP8_ALT_FLAG)
-            {
-                sf->thresh_mult[THR_NEARESTA ] = 1000;
-                sf->thresh_mult[THR_ZEROA    ] = 1000;
-                sf->thresh_mult[THR_NEARA    ] = 1000;
-                sf->thresh_mult[THR_NEWA     ] = 2000;
-                sf->thresh_mult[THR_SPLITA   ] = 20000;
-            }
-
-            sf->improved_quant = 0;
-            sf->improved_dct = 0;
-
-            sf->use_fastquant_for_pick = 1;
-            sf->no_skip_block4x4_search = 0;
-            sf->first_step = 1;
-        }
-
-        if (Speed > 1)
-        {
-            cpi->mode_check_freq[THR_SPLITMV] = 7;
-            cpi->mode_check_freq[THR_SPLITG] = 15;
-            cpi->mode_check_freq[THR_SPLITA] = 15;
-
-            sf->thresh_mult[THR_TM       ] = 2000;
-            sf->thresh_mult[THR_V_PRED   ] = 2000;
-            sf->thresh_mult[THR_H_PRED   ] = 2000;
-            sf->thresh_mult[THR_B_PRED   ] = 5000;
-            sf->thresh_mult[THR_I8X8_PRED] = 5000;
-
-            if (cpi->ref_frame_flags & VP8_LAST_FLAG)
-            {
-                sf->thresh_mult[THR_NEWMV    ] = 2000;
-                sf->thresh_mult[THR_SPLITMV  ] = 25000;
-            }
-
-            if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
-            {
-                sf->thresh_mult[THR_NEARESTG ] = 2000;
-                sf->thresh_mult[THR_ZEROG    ] = 2000;
-                sf->thresh_mult[THR_NEARG    ] = 2000;
-                sf->thresh_mult[THR_NEWG     ] = 2500;
-                sf->thresh_mult[THR_SPLITG   ] = 50000;
-            }
-
-            if (cpi->ref_frame_flags & VP8_ALT_FLAG)
-            {
-                sf->thresh_mult[THR_NEARESTA ] = 2000;
-                sf->thresh_mult[THR_ZEROA    ] = 2000;
-                sf->thresh_mult[THR_NEARA    ] = 2000;
-                sf->thresh_mult[THR_NEWA     ] = 2500;
-                sf->thresh_mult[THR_SPLITA   ] = 50000;
-            }
-
-            sf->thresh_mult[THR_DUAL_ZEROLG   ] = 2000;
-            sf->thresh_mult[THR_DUAL_NEARESTLG] = 2000;
-            sf->thresh_mult[THR_DUAL_NEARLG   ] = 2000;
-            sf->thresh_mult[THR_DUAL_ZEROLA   ] = 2000;
-            sf->thresh_mult[THR_DUAL_NEARESTLA] = 2000;
-            sf->thresh_mult[THR_DUAL_NEARLA   ] = 2000;
-            sf->thresh_mult[THR_DUAL_ZEROGA   ] = 2000;
-            sf->thresh_mult[THR_DUAL_NEARESTGA] = 2000;
-            sf->thresh_mult[THR_DUAL_NEARGA   ] = 2000;
-
-            sf->thresh_mult[THR_DUAL_NEWLG    ] = 2500;
-            sf->thresh_mult[THR_DUAL_NEWLA    ] = 2500;
-            sf->thresh_mult[THR_DUAL_NEWGA    ] = 2500;
-        }
-
-        if (Speed > 2)
-        {
-            sf->auto_filter = 0;                     // Faster selection of loop filter
-
-            cpi->mode_check_freq[THR_V_PRED] = 2;
-            cpi->mode_check_freq[THR_H_PRED] = 2;
-            cpi->mode_check_freq[THR_B_PRED] = 2;
-            cpi->mode_check_freq[THR_I8X8_PRED]=2;
-
-            if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
-            {
-                cpi->mode_check_freq[THR_NEARG] = 2;
-                cpi->mode_check_freq[THR_NEWG] = 4;
-            }
-
-            if (cpi->ref_frame_flags & VP8_ALT_FLAG)
-            {
-                cpi->mode_check_freq[THR_NEARA] = 2;
-                cpi->mode_check_freq[THR_NEWA] = 4;
-            }
-
-            cpi->mode_check_freq[THR_DUAL_NEARLG   ] = 2;
-            cpi->mode_check_freq[THR_DUAL_NEARLA   ] = 2;
-            cpi->mode_check_freq[THR_DUAL_NEARGA   ] = 2;
-            cpi->mode_check_freq[THR_DUAL_NEWLG    ] = 4;
-            cpi->mode_check_freq[THR_DUAL_NEWLA    ] = 4;
-            cpi->mode_check_freq[THR_DUAL_NEWGA    ] = 4;
-
-            sf->thresh_mult[THR_SPLITMV  ] = INT_MAX;
-            sf->thresh_mult[THR_SPLITG  ] = INT_MAX;
-            sf->thresh_mult[THR_SPLITA  ] = INT_MAX;
-
-        }
-
-        if (Speed > 3)
-        {
-            sf->RD = 0;
-
-            sf->auto_filter = 1;
-        }
-
-        if (Speed > 4)
-        {
-            sf->auto_filter = 0;                     // Faster selection of loop filter
-
-            sf->search_method = HEX;
-            //sf->search_method = DIAMOND;
-
-            sf->iterative_sub_pixel = 0;
-
-            cpi->mode_check_freq[THR_V_PRED] = 4;
-            cpi->mode_check_freq[THR_H_PRED] = 4;
-            cpi->mode_check_freq[THR_B_PRED] = 4;
-            cpi->mode_check_freq[THR_I8X8_PRED]=4;
-
-            if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
-            {
-                cpi->mode_check_freq[THR_NEARG] = 2;
-                cpi->mode_check_freq[THR_NEWG] = 4;
-            }
-
-            if (cpi->ref_frame_flags & VP8_ALT_FLAG)
-            {
-                cpi->mode_check_freq[THR_NEARA] = 2;
-                cpi->mode_check_freq[THR_NEWA] = 4;
-            }
-
-            sf->thresh_mult[THR_TM       ] = 2000;
-            sf->thresh_mult[THR_B_PRED   ] = 5000;
-            sf->thresh_mult[THR_I8X8_PRED] = 5000;
-
-            if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
-            {
-                sf->thresh_mult[THR_NEARESTG ] = 2000;
-                sf->thresh_mult[THR_ZEROG    ] = 2000;
-                sf->thresh_mult[THR_NEARG    ] = 2000;
-                sf->thresh_mult[THR_NEWG     ] = 4000;
-            }
-
-            if (cpi->ref_frame_flags & VP8_ALT_FLAG)
-            {
-                sf->thresh_mult[THR_NEARESTA ] = 2000;
-                sf->thresh_mult[THR_ZEROA    ] = 2000;
-                sf->thresh_mult[THR_NEARA    ] = 2000;
-                sf->thresh_mult[THR_NEWA     ] = 4000;
-            }
-
-            sf->thresh_mult[THR_DUAL_NEWLG    ] = 4000;
-            sf->thresh_mult[THR_DUAL_NEWLA    ] = 4000;
-            sf->thresh_mult[THR_DUAL_NEWGA    ] = 4000;
-        }
-
-        if (Speed > 5)
-        {
-            // Disable split MB intra prediction mode
-            sf->thresh_mult[THR_B_PRED] = INT_MAX;
-            sf->thresh_mult[THR_I8X8_PRED] = INT_MAX;
-        }
-
-        if (Speed > 6)
-        {
-            unsigned int i, sum = 0;
-            unsigned int total_mbs = cm->MBs;
-            int thresh;
-            int total_skip;
-
-            int min = 2000;
-
-            if (cpi->oxcf.encode_breakout > 2000)
-                min = cpi->oxcf.encode_breakout;
-
-            min >>= 7;
-
-            for (i = 0; i < min; i++)
-            {
-                sum += cpi->error_bins[i];
-            }
-
-            total_skip = sum;
-            sum = 0;
-
-            // i starts from 2 to make sure thresh started from 2048
-            for (; i < 1024; i++)
-            {
-                sum += cpi->error_bins[i];
-
-                if (10 * sum >= (unsigned int)(cpi->Speed - 6)*(total_mbs - total_skip))
-                    break;
-            }
-
-            i--;
-            thresh = (i << 7);
-
-            if (thresh < 2000)
-                thresh = 2000;
-
-            if (cpi->ref_frame_flags & VP8_LAST_FLAG)
-            {
-                sf->thresh_mult[THR_NEWMV] = thresh;
-                sf->thresh_mult[THR_NEARESTMV ] = thresh >> 1;
-                sf->thresh_mult[THR_NEARMV    ] = thresh >> 1;
-            }
-
-            if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
-            {
-                sf->thresh_mult[THR_NEWG] = thresh << 1;
-                sf->thresh_mult[THR_NEARESTG ] = thresh;
-                sf->thresh_mult[THR_NEARG    ] = thresh;
-            }
-
-            if (cpi->ref_frame_flags & VP8_ALT_FLAG)
-            {
-                sf->thresh_mult[THR_NEWA] = thresh << 1;
-                sf->thresh_mult[THR_NEARESTA ] = thresh;
-                sf->thresh_mult[THR_NEARA    ] = thresh;
-            }
-
-            sf->thresh_mult[THR_DUAL_ZEROLG   ] = thresh;
-            sf->thresh_mult[THR_DUAL_NEARESTLG] = thresh;
-            sf->thresh_mult[THR_DUAL_NEARLG   ] = thresh;
-            sf->thresh_mult[THR_DUAL_ZEROLA   ] = thresh;
-            sf->thresh_mult[THR_DUAL_NEARESTLA] = thresh;
-            sf->thresh_mult[THR_DUAL_NEARLA   ] = thresh;
-            sf->thresh_mult[THR_DUAL_ZEROGA   ] = thresh;
-            sf->thresh_mult[THR_DUAL_NEARESTGA] = thresh;
-            sf->thresh_mult[THR_DUAL_NEARGA   ] = thresh;
-
-            sf->thresh_mult[THR_DUAL_NEWLG    ] = thresh << 1;
-            sf->thresh_mult[THR_DUAL_NEWLA    ] = thresh << 1;
-            sf->thresh_mult[THR_DUAL_NEWGA    ] = thresh << 1;
-
-            // Disable other intra prediction modes
-            sf->thresh_mult[THR_TM] = INT_MAX;
-            sf->thresh_mult[THR_V_PRED] = INT_MAX;
-            sf->thresh_mult[THR_H_PRED] = INT_MAX;
-
-            sf->improved_mv_pred = 0;
-        }
-
-        if (Speed > 8)
-        {
-            sf->quarter_pixel_search = 0;
-        }
-
-        if (Speed > 9)
-        {
-            int Tmp = cpi->Speed - 8;
-
-            if (Tmp > 4)
-                Tmp = 4;
-
-            if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
-            {
-                cpi->mode_check_freq[THR_ZEROG] = 1 << (Tmp - 1);
-                cpi->mode_check_freq[THR_NEARESTG] = 1 << (Tmp - 1);
-                cpi->mode_check_freq[THR_NEARG] = 1 << Tmp;
-                cpi->mode_check_freq[THR_NEWG] = 1 << (Tmp + 1);
-            }
-
-            if (cpi->ref_frame_flags & VP8_ALT_FLAG)
-            {
-                cpi->mode_check_freq[THR_ZEROA] = 1 << (Tmp - 1);
-                cpi->mode_check_freq[THR_NEARESTA] = 1 << (Tmp - 1);
-                cpi->mode_check_freq[THR_NEARA] = 1 << Tmp;
-                cpi->mode_check_freq[THR_NEWA] = 1 << (Tmp + 1);
-            }
-
-            cpi->mode_check_freq[THR_DUAL_ZEROLG   ] = 1 << (Tmp - 1);
-            cpi->mode_check_freq[THR_DUAL_NEARESTLG] = 1 << (Tmp - 1);
-            cpi->mode_check_freq[THR_DUAL_NEARLG   ] = 1 << Tmp;
-            cpi->mode_check_freq[THR_DUAL_ZEROLA   ] = 1 << (Tmp - 1);
-            cpi->mode_check_freq[THR_DUAL_NEARESTLA] = 1 << (Tmp - 1);
-            cpi->mode_check_freq[THR_DUAL_NEARLA   ] = 1 << Tmp;
-            cpi->mode_check_freq[THR_DUAL_ZEROGA   ] = 1 << (Tmp - 1);
-            cpi->mode_check_freq[THR_DUAL_NEARESTGA] = 1 << (Tmp - 1);
-            cpi->mode_check_freq[THR_DUAL_NEARGA   ] = 1 << Tmp;
-
-            cpi->mode_check_freq[THR_DUAL_NEWLG    ] = 1 << (Tmp + 1);
-            cpi->mode_check_freq[THR_DUAL_NEWLA    ] = 1 << (Tmp + 1);
-            cpi->mode_check_freq[THR_DUAL_NEWGA    ] = 1 << (Tmp + 1);
-
-            cpi->mode_check_freq[THR_NEWMV] = 1 << (Tmp - 1);
-        }
-
-        cm->filter_type = NORMAL_LOOPFILTER;
-
-        if (Speed >= 14)
-            cm->filter_type = SIMPLE_LOOPFILTER;
-
-        if (Speed >= 15)
-        {
-            sf->half_pixel_search = 0;        // This has a big hit on quality. Last resort
-        }
-
-        vpx_memset(cpi->error_bins, 0, sizeof(cpi->error_bins));
-
     }; /* switch */
 
     /* disable frame modes if flags not set */
@@ -1646,10 +1186,6 @@
     {
         cpi->find_fractional_mv_step = vp8_find_best_half_pixel_step;
     }
-    else
-    {
-        cpi->find_fractional_mv_step = vp8_skip_fractional_mv_step;
-    }
 
     if (cpi->sf.optimize_coefficients == 1 && cpi->pass!=1)
         cpi->mb.optimize = 1;
@@ -1656,9 +1192,6 @@
     else
         cpi->mb.optimize = 0;
 
-    if (cpi->common.full_pixel)
-        cpi->find_fractional_mv_step = vp8_skip_fractional_mv_step;
-
 #ifdef SPEEDSTATS
     frames_at_speed[cpi->Speed]++;
 #endif
@@ -1930,44 +1463,12 @@
 
     switch (cpi->oxcf.Mode)
     {
-
-    case MODE_REALTIME:
-        cpi->pass = 0;
-        cpi->compressor_speed = 2;
-
-        if (cpi->oxcf.cpu_used < -16)
-        {
-            cpi->oxcf.cpu_used = -16;
-        }
-
-        if (cpi->oxcf.cpu_used > 16)
-            cpi->oxcf.cpu_used = 16;
-
-        break;
-
-    case MODE_GOODQUALITY:
-        cpi->pass = 0;
-        cpi->compressor_speed = 1;
-
-        if (cpi->oxcf.cpu_used < -5)
-        {
-            cpi->oxcf.cpu_used = -5;
-        }
-
-        if (cpi->oxcf.cpu_used > 5)
-            cpi->oxcf.cpu_used = 5;
-
-        break;
-
-    case MODE_BESTQUALITY:
-        cpi->pass = 0;
-        cpi->compressor_speed = 0;
-        break;
-
+    // Real time and one pass deprecated in test code base
     case MODE_FIRSTPASS:
         cpi->pass = 1;
         cpi->compressor_speed = 1;
         break;
+
     case MODE_SECONDPASS:
         cpi->pass = 2;
         cpi->compressor_speed = 1;
@@ -1981,6 +1482,7 @@
             cpi->oxcf.cpu_used = 5;
 
         break;
+
     case MODE_SECONDPASS_BEST:
         cpi->pass = 2;
         cpi->compressor_speed = 0;
@@ -2453,13 +1955,6 @@
         vp8_init_second_pass(cpi);
     }
 
-    if (cpi->compressor_speed == 2)
-    {
-        cpi->cpu_freq            = 0; //vp8_get_processor_freq();
-        cpi->avg_encode_time      = 0;
-        cpi->avg_pick_mode_time    = 0;
-    }
-
     vp8_set_speed_features(cpi);
 
     // Set starting values of RD threshold multipliers (128 = *1)
@@ -2632,25 +2127,6 @@
 #endif
 
 
-#ifdef SPEEDSTATS
-
-        if (cpi->compressor_speed == 2)
-        {
-            int i;
-            FILE *f = fopen("cxspeed.stt", "a");
-            cnt_pm /= cpi->common.MBs;
-
-            for (i = 0; i < 16; i++)
-                fprintf(f, "%5d", frames_at_speed[i]);
-
-            fprintf(f, "\n");
-            //fprintf(f, "%10d PM %10d %10d %10d EF %10d %10d %10d\n", cpi->Speed, cpi->avg_pick_mode_time, (tot_pm/cnt_pm), cnt_pm,  cpi->avg_encode_time, 0, 0);
-            fclose(f);
-        }
-
-#endif
-
-
 #ifdef MODE_STATS
         {
             extern int count_mb_seg[4];
@@ -3311,50 +2787,6 @@
     // Clear down mmx registers
     vp8_clear_system_state();  //__asm emms;
 
-    if ((cpi->compressor_speed == 2) && (cpi->Speed >= 5) && (cpi->sf.RD == 0))
-    {
-        double change = 1.0 * abs((int)(cpi->intra_error - cpi->last_intra_error)) / (1 + cpi->last_intra_error);
-        double change2 = 1.0 * abs((int)(cpi->prediction_error - cpi->last_prediction_error)) / (1 + cpi->last_prediction_error);
-        double minerror = cm->MBs * 256;
-
-#if 0
-
-        if (10 * cpi->intra_error / (1 + cpi->prediction_error) < 15
-            && cpi->prediction_error > minerror
-            && (change > .25 || change2 > .25))
-        {
-            FILE *f = fopen("intra_inter.stt", "a");
-
-            if (cpi->prediction_error <= 0)
-                cpi->prediction_error = 1;
-
-            fprintf(f, "%d %d %d %d %14.4f\n",
-                    cm->current_video_frame,
-                    (int) cpi->prediction_error,
-                    (int) cpi->intra_error,
-                    (int)((10 * cpi->intra_error) / cpi->prediction_error),
-                    change);
-
-            fclose(f);
-        }
-
-#endif
-
-        cpi->last_intra_error = cpi->intra_error;
-        cpi->last_prediction_error = cpi->prediction_error;
-
-        if (10 * cpi->intra_error / (1 + cpi->prediction_error) < 15
-            && cpi->prediction_error > minerror
-            && (change > .25 || change2 > .25))
-        {
-            /*(change > 1.4 || change < .75)&& cpi->this_frame_percent_intra > cpi->last_frame_percent_intra + 3*/
-            return TRUE;
-        }
-
-        return FALSE;
-
-    }
-
     // If the following are true we might as well code a key frame
     if (((cpi->this_frame_percent_intra == 100) &&
          (cpi->this_frame_percent_intra > (cpi->last_frame_percent_intra + 2))) ||
@@ -3759,18 +3191,6 @@
     // Clear down mmx registers to allow floating point in what follows
     vp8_clear_system_state();
 
-    if (cpi->compressor_speed == 2)
-    {
-        if(cpi->oxcf.auto_key && cm->frame_type != KEY_FRAME)
-        {
-            if(cpi->force_next_frame_intra)
-            {
-                cm->frame_type = KEY_FRAME;  /* delayed intra frame */
-            }
-        }
-        cpi->force_next_frame_intra = 0;
-    }
-
     // For an alt ref frame in 2 pass we skip the call to the second pass function that sets the target bandwidth
     if (cpi->pass == 2)
     {
@@ -4345,14 +3765,8 @@
         {
             int key_frame_decision = decide_key_frame(cpi);
 
-            if (cpi->compressor_speed == 2)
+            if (key_frame_decision)
             {
-                /* we don't do re-encoding in realtime mode
-                 * if key frame is decided than we force it on next frame */
-                cpi->force_next_frame_intra = key_frame_decision;
-            }
-            else if (key_frame_decision)
-            {
                 // Reset all our sizing numbers and recode
                 cm->frame_type = KEY_FRAME;
 
@@ -5374,13 +4788,6 @@
         cpi->last_end_time_stamp_seen = cpi->source->ts_end;
     }
 
-    if (cpi->compressor_speed == 2)
-    {
-        check_gf_quality(cpi);
-        vpx_usec_timer_start(&tsctimer);
-        vpx_usec_timer_start(&ticktimer);
-    }
-
     // start with a 0 size frame
     *size = 0;
 
@@ -5429,39 +4836,6 @@
     }
     else
         encode_frame_to_data_rate(cpi, size, dest, frame_flags);
-
-    if (cpi->compressor_speed == 2)
-    {
-        unsigned int duration, duration2;
-        vpx_usec_timer_mark(&tsctimer);
-        vpx_usec_timer_mark(&ticktimer);
-
-        duration = vpx_usec_timer_elapsed(&ticktimer);
-        duration2 = (unsigned int)((double)duration / 2);
-
-        if (cm->frame_type != KEY_FRAME)
-        {
-            if (cpi->avg_encode_time == 0)
-                cpi->avg_encode_time = duration;
-            else
-                cpi->avg_encode_time = (7 * cpi->avg_encode_time + duration) >> 3;
-        }
-
-        if (duration2)
-        {
-            //if(*frame_flags!=1)
-            {
-
-                if (cpi->avg_pick_mode_time == 0)
-                    cpi->avg_pick_mode_time = duration2;
-                else
-                    cpi->avg_pick_mode_time = (7 * cpi->avg_pick_mode_time + duration2) >> 3;
-            }
-        }
-
-    }
-
-
 
     if(cm->refresh_entropy_probs)
     {
--- a/vp8/encoder/pickinter.c
+++ /dev/null
@@ -1,1001 +1,0 @@
-/*
- *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-
-#include <limits.h>
-#include "vpx_ports/config.h"
-#include "onyx_int.h"
-#include "modecosts.h"
-#include "encodeintra.h"
-#include "vp8/common/entropymode.h"
-#include "pickinter.h"
-#include "vp8/common/findnearmv.h"
-#include "encodemb.h"
-#include "vp8/common/reconinter.h"
-#include "vp8/common/reconintra.h"
-#include "vp8/common/reconintra4x4.h"
-#include "vp8/common/g_common.h"
-#include "variance.h"
-#include "mcomp.h"
-#include "rdopt.h"
-#include "vpx_mem/vpx_mem.h"
-
-#include "vp8/common/seg_common.h"
-
-#if CONFIG_RUNTIME_CPU_DETECT
-#define IF_RTCD(x) (x)
-#else
-#define IF_RTCD(x)  NULL
-#endif
-
-extern int VP8_UVSSE(MACROBLOCK *x, const vp8_variance_rtcd_vtable_t *rtcd);
-
-#ifdef SPEEDSTATS
-extern unsigned int cnt_pm;
-#endif
-
-extern const MV_REFERENCE_FRAME vp8_ref_frame_order[MAX_MODES];
-extern const MB_PREDICTION_MODE vp8_mode_order[MAX_MODES];
-extern const MV_REFERENCE_FRAME vp8_second_ref_frame_order[MAX_MODES];
-
-extern unsigned int (*vp8_get4x4sse_cs)(unsigned char *src_ptr, int  source_stride, unsigned char *ref_ptr, int  recon_stride);
-extern int vp8_cost_mv_ref(VP8_COMMON *pc,
-                           MB_PREDICTION_MODE m, const int near_mv_ref_ct[4]);
-
-
-int vp8_skip_fractional_mv_step(MACROBLOCK *mb, BLOCK *b, BLOCKD *d,
-                                int_mv *bestmv, int_mv *ref_mv,
-                                int error_per_bit,
-                                const vp8_variance_fn_ptr_t *vfp,
-                                int *mvcost[2], int *distortion,
-                                unsigned int *sse)
-{
-    (void) b;
-    (void) d;
-    (void) ref_mv;
-    (void) error_per_bit;
-    (void) vfp;
-    (void) mvcost;
-    (void) distortion;
-    (void) sse;
-    bestmv->as_mv.row <<= 3;
-    bestmv->as_mv.col <<= 3;
-    return 0;
-}
-
-
-static int get_inter_mbpred_error(MACROBLOCK *mb,
-                                  const vp8_variance_fn_ptr_t *vfp,
-                                  unsigned int *sse,
-                                  int_mv this_mv)
-{
-
-    BLOCK *b = &mb->block[0];
-    BLOCKD *d = &mb->e_mbd.block[0];
-    unsigned char *what = (*(b->base_src) + b->src);
-    int what_stride = b->src_stride;
-    unsigned char *in_what = *(d->base_pre) + d->pre ;
-    int in_what_stride = d->pre_stride;
-    int xoffset = this_mv.as_mv.col & 7;
-    int yoffset = this_mv.as_mv.row & 7;
-
-    in_what += (this_mv.as_mv.row >> 3) * d->pre_stride + (this_mv.as_mv.col >> 3);
-
-    if (xoffset | yoffset)
-    {
-        return vfp->svf(in_what, in_what_stride, xoffset, yoffset, what, what_stride, sse);
-    }
-    else
-    {
-        return vfp->vf(what, what_stride, in_what, in_what_stride, sse);
-    }
-
-}
-
-
-unsigned int vp8_get4x4sse_cs_c
-(
-    const unsigned char *src_ptr,
-    int  source_stride,
-    const unsigned char *ref_ptr,
-    int  recon_stride
-)
-{
-    int distortion = 0;
-    int r, c;
-
-    for (r = 0; r < 4; r++)
-    {
-        for (c = 0; c < 4; c++)
-        {
-            int diff = src_ptr[c] - ref_ptr[c];
-            distortion += diff * diff;
-        }
-
-        src_ptr += source_stride;
-        ref_ptr += recon_stride;
-    }
-
-    return distortion;
-}
-
-static int get_prediction_error(BLOCK *be, BLOCKD *b, const vp8_variance_rtcd_vtable_t *rtcd)
-{
-    unsigned char *sptr;
-    unsigned char *dptr;
-    sptr = (*(be->base_src) + be->src);
-    dptr = b->predictor;
-
-    return VARIANCE_INVOKE(rtcd, get4x4sse_cs)(sptr, be->src_stride, dptr, 16);
-
-}
-
-static int pick_intra4x4block(
-    const VP8_ENCODER_RTCD *rtcd,
-    MACROBLOCK *x,
-    int ib,
-    B_PREDICTION_MODE *best_mode,
-    unsigned int *mode_costs,
-
-    int *bestrate,
-    int *bestdistortion)
-{
-
-    BLOCKD *b = &x->e_mbd.block[ib];
-    BLOCK *be = &x->block[ib];
-    B_PREDICTION_MODE mode;
-    int best_rd = INT_MAX;       // 1<<30
-    int rate;
-    int distortion;
-
-    for (mode = B_DC_PRED; mode <= B_HE_PRED /*B_HU_PRED*/; mode++)
-    {
-        int this_rd;
-
-#if CONFIG_SUPERBLOCKS
-        // Pre-empt mode range being restored to B_HU_PRED in the loop above:
-        // Ignore modes that need the above-right data
-        if (mode==B_LD_PRED || mode==B_VL_PRED)
-            continue;
-#endif
-
-        rate = mode_costs[mode];
-        RECON_INVOKE(&rtcd->common->recon, intra4x4_predict)
-                     (b, mode, b->predictor);
-        distortion = get_prediction_error(be, b, &rtcd->variance);
-        this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
-
-        if (this_rd < best_rd)
-        {
-            *bestrate = rate;
-            *bestdistortion = distortion;
-            best_rd = this_rd;
-            *best_mode = mode;
-        }
-    }
-
-    b->bmi.as_mode = (B_PREDICTION_MODE)(*best_mode);
-    vp8_encode_intra4x4block(rtcd, x, ib);
-    return best_rd;
-}
-
-
-static int pick_intra4x4mby_modes
-(
-    const VP8_ENCODER_RTCD *rtcd,
-    MACROBLOCK *mb,
-    int *Rate,
-    int *best_dist
-)
-{
-    MACROBLOCKD *const xd = &mb->e_mbd;
-    int i;
-    int cost = mb->mbmode_cost [xd->frame_type] [B_PRED];
-    int error;
-    int distortion = 0;
-    unsigned int *bmode_costs;
-
-#if !CONFIG_SUPERBLOCKS
-    vp8_intra_prediction_down_copy(xd);
-#endif
-
-    bmode_costs = mb->inter_bmode_costs;
-
-    for (i = 0; i < 16; i++)
-    {
-        MODE_INFO *const mic = xd->mode_info_context;
-        const int mis = xd->mode_info_stride;
-
-        B_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_mode);
-        int UNINITIALIZED_IS_SAFE(r), UNINITIALIZED_IS_SAFE(d);
-
-        if (mb->e_mbd.frame_type == KEY_FRAME)
-        {
-            const B_PREDICTION_MODE A = above_block_mode(mic, i, mis);
-            const B_PREDICTION_MODE L = left_block_mode(mic, i);
-
-            bmode_costs  = mb->bmode_costs[A][L];
-        }
-
-
-        pick_intra4x4block(rtcd, mb, i, &best_mode, bmode_costs, &r, &d);
-
-        cost += r;
-        distortion += d;
-        mic->bmi[i].as_mode = best_mode;
-
-        // Break out case where we have already exceeded best so far value
-        // that was passed in
-        if (distortion > *best_dist)
-            break;
-    }
-
-    *Rate = cost;
-
-    if (i == 16)
-    {
-        *best_dist = distortion;
-        error = RDCOST(mb->rdmult, mb->rddiv, cost, distortion);
-    }
-    else
-    {
-        *best_dist = INT_MAX;
-        error = INT_MAX;
-    }
-
-    return error;
-}
-
-static void pick_intra_mbuv_mode(MACROBLOCK *mb)
-{
-
-    MACROBLOCKD *x = &mb->e_mbd;
-    unsigned char *uabove_row = x->dst.u_buffer - x->dst.uv_stride;
-    unsigned char *vabove_row = x->dst.v_buffer - x->dst.uv_stride;
-    unsigned char *usrc_ptr = (mb->block[16].src + *mb->block[16].base_src);
-    unsigned char *vsrc_ptr = (mb->block[20].src + *mb->block[20].base_src);
-    int uvsrc_stride = mb->block[16].src_stride;
-    unsigned char uleft_col[8];
-    unsigned char vleft_col[8];
-    unsigned char utop_left = uabove_row[-1];
-    unsigned char vtop_left = vabove_row[-1];
-    int i, j;
-    int expected_udc;
-    int expected_vdc;
-    int shift;
-    int Uaverage = 0;
-    int Vaverage = 0;
-    int diff;
-    int pred_error[4] = {0, 0, 0, 0}, best_error = INT_MAX;
-    MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_mode);
-
-
-    for (i = 0; i < 8; i++)
-    {
-        uleft_col[i] = x->dst.u_buffer [i* x->dst.uv_stride -1];
-        vleft_col[i] = x->dst.v_buffer [i* x->dst.uv_stride -1];
-    }
-
-    if (!x->up_available && !x->left_available)
-    {
-        expected_udc = 128;
-        expected_vdc = 128;
-    }
-    else
-    {
-        shift = 2;
-
-        if (x->up_available)
-        {
-
-            for (i = 0; i < 8; i++)
-            {
-                Uaverage += uabove_row[i];
-                Vaverage += vabove_row[i];
-            }
-
-            shift ++;
-
-        }
-
-        if (x->left_available)
-        {
-            for (i = 0; i < 8; i++)
-            {
-                Uaverage += uleft_col[i];
-                Vaverage += vleft_col[i];
-            }
-
-            shift ++;
-
-        }
-
-        expected_udc = (Uaverage + (1 << (shift - 1))) >> shift;
-        expected_vdc = (Vaverage + (1 << (shift - 1))) >> shift;
-    }
-
-
-    for (i = 0; i < 8; i++)
-    {
-        for (j = 0; j < 8; j++)
-        {
-
-            int predu = uleft_col[i] + uabove_row[j] - utop_left;
-            int predv = vleft_col[i] + vabove_row[j] - vtop_left;
-            int u_p, v_p;
-
-            u_p = usrc_ptr[j];
-            v_p = vsrc_ptr[j];
-
-            if (predu < 0)
-                predu = 0;
-
-            if (predu > 255)
-                predu = 255;
-
-            if (predv < 0)
-                predv = 0;
-
-            if (predv > 255)
-                predv = 255;
-
-
-            diff = u_p - expected_udc;
-            pred_error[DC_PRED] += diff * diff;
-            diff = v_p - expected_vdc;
-            pred_error[DC_PRED] += diff * diff;
-
-
-            diff = u_p - uabove_row[j];
-            pred_error[V_PRED] += diff * diff;
-            diff = v_p - vabove_row[j];
-            pred_error[V_PRED] += diff * diff;
-
-
-            diff = u_p - uleft_col[i];
-            pred_error[H_PRED] += diff * diff;
-            diff = v_p - vleft_col[i];
-            pred_error[H_PRED] += diff * diff;
-
-
-            diff = u_p - predu;
-            pred_error[TM_PRED] += diff * diff;
-            diff = v_p - predv;
-            pred_error[TM_PRED] += diff * diff;
-
-
-        }
-
-        usrc_ptr += uvsrc_stride;
-        vsrc_ptr += uvsrc_stride;
-
-        if (i == 3)
-        {
-            usrc_ptr = (mb->block[18].src + *mb->block[18].base_src);
-            vsrc_ptr = (mb->block[22].src + *mb->block[22].base_src);
-        }
-
-
-
-    }
-
-
-    for (i = DC_PRED; i <= TM_PRED; i++)
-    {
-        if (best_error > pred_error[i])
-        {
-            best_error = pred_error[i];
-            best_mode = (MB_PREDICTION_MODE)i;
-        }
-    }
-
-
-    mb->e_mbd.mode_info_context->mbmi.uv_mode = best_mode;
-
-}
-
-static void update_mvcount(VP8_COMP *cpi, MACROBLOCKD *xd, int_mv *best_ref_mv)
-{
-    /* Split MV modes currently not supported when RD is nopt enabled,
-     * therefore, only need to modify MVcount in NEWMV mode. */
-    if (xd->mode_info_context->mbmi.mode == NEWMV)
-    {
-        cpi->MVcount[0][mv_max+((xd->mode_info_context->mbmi.mv.as_mv.row -
-                                      best_ref_mv->as_mv.row) >> 1)]++;
-        cpi->MVcount[1][mv_max+((xd->mode_info_context->mbmi.mv.as_mv.col -
-                                      best_ref_mv->as_mv.col) >> 1)]++;
-    }
-}
-
-void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
-                         int recon_uvoffset, int *returnrate,
-                         int *returndistortion, int *returnintra)
-{
-    BLOCK *b = &x->block[0];
-    BLOCKD *d = &x->e_mbd.block[0];
-    MACROBLOCKD *xd = &x->e_mbd;
-    MB_MODE_INFO best_mbmode;
-    VP8_COMMON *cm = & cpi->common;
-
-    int_mv best_ref_mv;
-    int_mv mode_mv[MB_MODE_COUNT];
-    MB_PREDICTION_MODE this_mode;
-    int num00;
-    int mdcounts[4];
-    int best_rd = INT_MAX; // 1 << 30;
-    int best_intra_rd = INT_MAX;
-    int mode_index;
-    int rate;
-    int rate2;
-    int distortion2;
-    int bestsme;
-    //int all_rds[MAX_MODES];         // Experimental debug code.
-    int best_mode_index = 0;
-    unsigned char segment_id = xd->mode_info_context->mbmi.segment_id;
-
-    unsigned int sse = INT_MAX, best_sse = INT_MAX;
-
-    int_mv mvp;
-    int near_sadidx[8] = {0, 1, 2, 3, 4, 5, 6, 7};
-    int saddone=0;
-    int sr=0;    //search range got from mv_pred(). It uses step_param levels. (0-7)
-
-    int_mv nearest_mv[4];
-    int_mv near_mv[4];
-    int_mv frame_best_ref_mv[4];
-    int MDCounts[4][4];
-    unsigned char *y_buffer[4];
-    unsigned char *u_buffer[4];
-    unsigned char *v_buffer[4];
-
-    int skip_mode[4] = {0, 0, 0, 0};
-
-    int have_subp_search = cpi->sf.half_pixel_search;  /* In real-time mode, when Speed >= 15, no sub-pixel search. */
-
-    vpx_memset(mode_mv, 0, sizeof(mode_mv));
-    vpx_memset(nearest_mv, 0, sizeof(nearest_mv));
-    vpx_memset(near_mv, 0, sizeof(near_mv));
-    vpx_memset(&best_mbmode, 0, sizeof(best_mbmode));
-
-
-    // set up all the refframe dependent pointers.
-    if (cpi->ref_frame_flags & VP8_LAST_FLAG)
-    {
-        YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.lst_fb_idx];
-
-        vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
-                        x->e_mbd.prev_mode_info_context,
-            &nearest_mv[LAST_FRAME], &near_mv[LAST_FRAME],
-                          &frame_best_ref_mv[LAST_FRAME], MDCounts[LAST_FRAME], LAST_FRAME, cpi->common.ref_frame_sign_bias);
-
-        y_buffer[LAST_FRAME] = lst_yv12->y_buffer + recon_yoffset;
-        u_buffer[LAST_FRAME] = lst_yv12->u_buffer + recon_uvoffset;
-        v_buffer[LAST_FRAME] = lst_yv12->v_buffer + recon_uvoffset;
-    }
-    else
-        skip_mode[LAST_FRAME] = 1;
-
-    if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
-    {
-        YV12_BUFFER_CONFIG *gld_yv12 = &cpi->common.yv12_fb[cpi->common.gld_fb_idx];
-
-        vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
-            x->e_mbd.prev_mode_info_context,
-            &nearest_mv[GOLDEN_FRAME], &near_mv[GOLDEN_FRAME],
-            &frame_best_ref_mv[GOLDEN_FRAME], MDCounts[GOLDEN_FRAME], GOLDEN_FRAME, cpi->common.ref_frame_sign_bias);
-
-        y_buffer[GOLDEN_FRAME] = gld_yv12->y_buffer + recon_yoffset;
-        u_buffer[GOLDEN_FRAME] = gld_yv12->u_buffer + recon_uvoffset;
-        v_buffer[GOLDEN_FRAME] = gld_yv12->v_buffer + recon_uvoffset;
-    }
-    else
-        skip_mode[GOLDEN_FRAME] = 1;
-
-    if (cpi->ref_frame_flags & VP8_ALT_FLAG && cpi->source_alt_ref_active)
-    {
-        YV12_BUFFER_CONFIG *alt_yv12 = &cpi->common.yv12_fb[cpi->common.alt_fb_idx];
-
-        vp8_find_near_mvs(&x->e_mbd, x->e_mbd.mode_info_context,
-                        x->e_mbd.prev_mode_info_context,
-                        &nearest_mv[ALTREF_FRAME], &near_mv[ALTREF_FRAME],
-                        &frame_best_ref_mv[ALTREF_FRAME], MDCounts[ALTREF_FRAME], ALTREF_FRAME, cpi->common.ref_frame_sign_bias);
-
-        y_buffer[ALTREF_FRAME] = alt_yv12->y_buffer + recon_yoffset;
-        u_buffer[ALTREF_FRAME] = alt_yv12->u_buffer + recon_uvoffset;
-        v_buffer[ALTREF_FRAME] = alt_yv12->v_buffer + recon_uvoffset;
-    }
-    else
-        skip_mode[ALTREF_FRAME] = 1;
-
-    cpi->mbs_tested_so_far++;          // Count of the number of MBs tested so far this frame
-
-    *returnintra = INT_MAX;
-    x->skip = 0;
-
-    x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
-
-    // if we encode a new mv this is important
-    // find the best new motion vector
-    for (mode_index = 0; mode_index < MAX_MODES; mode_index++)
-    {
-        int frame_cost;
-        int this_rd = INT_MAX;
-
-        if (best_rd <= cpi->rd_threshes[mode_index])
-            continue;
-
-        if (vp8_second_ref_frame_order[mode_index])
-            continue;
-
-        x->e_mbd.mode_info_context->mbmi.ref_frame = vp8_ref_frame_order[mode_index];
-
-        if (skip_mode[x->e_mbd.mode_info_context->mbmi.ref_frame])
-            continue;
-
-        this_mode = vp8_mode_order[mode_index];
-
-        // If the segment reference frame feature is enabled....
-        // then do nothing if the current ref frame is not allowed..
-        if ( segfeature_active( xd, segment_id, SEG_LVL_REF_FRAME ) &&
-             !check_segref( xd, segment_id,
-                            xd->mode_info_context->mbmi.ref_frame ) )
-        {
-            continue;
-        }
-        // If the segment mode feature is enabled....
-        // then do nothing if the current mode is not allowed..
-        else if ( segfeature_active( xd, segment_id, SEG_LVL_MODE )  &&
-                  ( this_mode !=
-                    get_segdata( xd, segment_id, SEG_LVL_MODE ) ) )
-        {
-            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
-        // Disable this drop out case if either the mode or ref frame
-        // segment level feature is enabled for this segment. This is to
-        // prevent the possibility that the we end up unable to pick any mode.
-        else if ( !segfeature_active( xd, segment_id, SEG_LVL_REF_FRAME ) &&
-                  !segfeature_active( xd, segment_id, SEG_LVL_MODE ) )
-        {
-            // Only consider ZEROMV/ALTREF_FRAME for alt ref frame,
-            // unless ARNR filtering is enabled in which case we want
-            // an unfiltered alternative
-            if (cpi->is_src_frame_alt_ref && (cpi->oxcf.arnr_max_frames == 0))
-            {
-                if (this_mode != ZEROMV ||
-                    x->e_mbd.mode_info_context->mbmi.ref_frame != ALTREF_FRAME)
-                    continue;
-            }
-        }
-
-        // We have now reached the point where we are going to test the current mode so increment the counter for the number of times it has been tested
-        cpi->mode_test_hit_counts[mode_index] ++;
-
-        rate2 = 0;
-        distortion2 = 0;
-
-        // Experimental debug code.
-        //all_rds[mode_index] = -1;
-
-        x->e_mbd.mode_info_context->mbmi.mode = this_mode;
-        x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED;
-
-
-// #if CONFIG_COMPRED
-// TODO... this will need changing for new reference frame coding model
-// #endif
-        // Work out the cost assosciated with selecting the reference frame
-        frame_cost =
-            x->e_mbd.ref_frame_cost[x->e_mbd.mode_info_context->mbmi.ref_frame];
-        rate2 += frame_cost;
-
-        // everything but intra
-        if (x->e_mbd.mode_info_context->mbmi.ref_frame)
-        {
-            x->e_mbd.pre.y_buffer = y_buffer[x->e_mbd.mode_info_context->mbmi.ref_frame];
-            x->e_mbd.pre.u_buffer = u_buffer[x->e_mbd.mode_info_context->mbmi.ref_frame];
-            x->e_mbd.pre.v_buffer = v_buffer[x->e_mbd.mode_info_context->mbmi.ref_frame];
-            mode_mv[NEARESTMV] = nearest_mv[x->e_mbd.mode_info_context->mbmi.ref_frame];
-            mode_mv[NEARMV] = near_mv[x->e_mbd.mode_info_context->mbmi.ref_frame];
-            best_ref_mv = frame_best_ref_mv[x->e_mbd.mode_info_context->mbmi.ref_frame];
-            memcpy(mdcounts, MDCounts[x->e_mbd.mode_info_context->mbmi.ref_frame], sizeof(mdcounts));
-        }
-
-        switch (this_mode)
-        {
-        case B_PRED:
-            // Pass best so far to pick_intra4x4mby_modes to use as breakout
-            distortion2 = best_sse;
-            pick_intra4x4mby_modes(IF_RTCD(&cpi->rtcd), x, &rate, &distortion2);
-
-            if (distortion2 == INT_MAX)
-            {
-                this_rd = INT_MAX;
-            }
-            else
-            {
-                rate2 += rate;
-                distortion2 = VARIANCE_INVOKE
-                                (&cpi->rtcd.variance, var16x16)(
-                                    *(b->base_src), b->src_stride,
-                                    x->e_mbd.predictor, 16, &sse);
-                this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
-
-                if (this_rd < best_intra_rd)
-                {
-                    best_intra_rd = this_rd;
-                    *returnintra = distortion2;
-                }
-            }
-
-            break;
-
-        case SPLITMV:
-
-            // Split MV modes currently not supported when RD is nopt enabled.
-            break;
-
-        case DC_PRED:
-        case V_PRED:
-        case H_PRED:
-        case TM_PRED:
-            RECON_INVOKE(&cpi->common.rtcd.recon, build_intra_predictors_mby)
-                (&x->e_mbd);
-            distortion2 = VARIANCE_INVOKE(&cpi->rtcd.variance, var16x16)
-                                          (*(b->base_src), b->src_stride,
-                                          x->e_mbd.predictor, 16, &sse);
-            rate2 += x->mbmode_cost[x->e_mbd.frame_type][x->e_mbd.mode_info_context->mbmi.mode];
-            this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
-
-            if (this_rd < best_intra_rd)
-            {
-                best_intra_rd = this_rd;
-                *returnintra = distortion2;
-            }
-            break;
-
-        case NEWMV:
-        {
-            int thissme;
-            int step_param;
-            int further_steps;
-            int n = 0;
-            int sadpb = x->sadperbit16;
-            int_mv mvp_full;
-
-            int col_min = (best_ref_mv.as_mv.col>>3) - MAX_FULL_PEL_VAL + ((best_ref_mv.as_mv.col & 7)?1:0);
-            int row_min = (best_ref_mv.as_mv.row>>3) - MAX_FULL_PEL_VAL + ((best_ref_mv.as_mv.row & 7)?1:0);
-            int col_max = (best_ref_mv.as_mv.col>>3) + MAX_FULL_PEL_VAL;
-            int row_max = (best_ref_mv.as_mv.row>>3) + MAX_FULL_PEL_VAL;
-
-            int tmp_col_min = x->mv_col_min;
-            int tmp_col_max = x->mv_col_max;
-            int tmp_row_min = x->mv_row_min;
-            int tmp_row_max = x->mv_row_max;
-
-            int speed_adjust = (cpi->Speed > 5) ? ((cpi->Speed >= 8)? 3 : 2) : 1;
-
-            // Further step/diamond searches as necessary
-            step_param = cpi->sf.first_step + speed_adjust;
-
-            if(cpi->sf.improved_mv_pred)
-            {
-                if(!saddone)
-                {
-                    vp8_cal_sad(cpi,xd,x, recon_yoffset ,&near_sadidx[0] );
-                    saddone = 1;
-                }
-
-                vp8_mv_pred(cpi, &x->e_mbd, x->e_mbd.mode_info_context, &mvp,
-                            x->e_mbd.mode_info_context->mbmi.ref_frame, cpi->common.ref_frame_sign_bias, &sr, &near_sadidx[0]);
-
-                sr += speed_adjust;
-                //adjust search range according to sr from mv prediction
-                if(sr > step_param)
-                    step_param = sr;
-
-                mvp_full.as_mv.col = mvp.as_mv.col>>3;
-                mvp_full.as_mv.row = mvp.as_mv.row>>3;
-
-            }else
-            {
-                mvp.as_int = best_ref_mv.as_int;
-                mvp_full.as_mv.col = best_ref_mv.as_mv.col>>3;
-                mvp_full.as_mv.row = best_ref_mv.as_mv.row>>3;
-            }
-
-            // Get intersection of UMV window and valid MV window to reduce # of checks in diamond search.
-            if (x->mv_col_min < col_min )
-                x->mv_col_min = col_min;
-            if (x->mv_col_max > col_max )
-                x->mv_col_max = col_max;
-            if (x->mv_row_min < row_min )
-                x->mv_row_min = row_min;
-            if (x->mv_row_max > row_max )
-                x->mv_row_max = row_max;
-
-            further_steps = (cpi->Speed >= 8)? 0: (cpi->sf.max_step_search_steps - 1 - step_param);
-
-            if (cpi->sf.search_method == HEX)
-            {
-                bestsme = vp8_hex_search(x, b, d, &mvp_full, &d->bmi.mv, step_param,
-                                      sadpb, &cpi->fn_ptr[BLOCK_16X16],
-                                      x->mvsadcost, x->mvcost, &best_ref_mv);
-                mode_mv[NEWMV].as_int = d->bmi.mv.as_int;
-            }
-            else
-            {
-                bestsme = cpi->diamond_search_sad(x, b, d, &mvp_full, &d->bmi.mv,
-                                      step_param, sadpb, &num00,
-                                      &cpi->fn_ptr[BLOCK_16X16],
-                                      x->mvcost, &best_ref_mv);
-                mode_mv[NEWMV].as_int = d->bmi.mv.as_int;
-
-                // Further step/diamond searches as necessary
-                n = 0;
-                //further_steps = (cpi->sf.max_step_search_steps - 1) - step_param;
-
-                n = num00;
-                num00 = 0;
-
-                while (n < further_steps)
-                {
-                    n++;
-
-                    if (num00)
-                        num00--;
-                    else
-                    {
-                        thissme =
-                        cpi->diamond_search_sad(x, b, d, &mvp_full,
-                                                &d->bmi.mv,
-                                                step_param + n,
-                                                sadpb, &num00,
-                                                &cpi->fn_ptr[BLOCK_16X16],
-                                                x->mvcost, &best_ref_mv);
-                        if (thissme < bestsme)
-                        {
-                            bestsme = thissme;
-                            mode_mv[NEWMV].as_int = d->bmi.mv.as_int;
-                        }
-                        else
-                        {
-                            d->bmi.mv.as_int = mode_mv[NEWMV].as_int;
-                        }
-                    }
-                }
-            }
-
-            x->mv_col_min = tmp_col_min;
-            x->mv_col_max = tmp_col_max;
-            x->mv_row_min = tmp_row_min;
-            x->mv_row_max = tmp_row_max;
-
-            if (bestsme < INT_MAX)
-                cpi->find_fractional_mv_step(x, b, d, &d->bmi.mv, &best_ref_mv,
-                                             x->errorperbit,
-                                             &cpi->fn_ptr[BLOCK_16X16],
-                                             cpi->mb.mvcost,
-                                             &distortion2,&sse);
-
-            mode_mv[NEWMV].as_int = d->bmi.mv.as_int;
-
-            // mv cost;
-            rate2 += vp8_mv_bit_cost(&mode_mv[NEWMV], &best_ref_mv, cpi->mb.mvcost, 128);
-        }
-
-        case NEARESTMV:
-        case NEARMV:
-
-            if (mode_mv[this_mode].as_int == 0)
-                continue;
-
-        case ZEROMV:
-
-            // Trap vectors that reach beyond the UMV borders
-            // Note that ALL New MV, Nearest MV Near MV and Zero MV code drops through to this point
-            // because of the lack of break statements in the previous two cases.
-            if (((mode_mv[this_mode].as_mv.row >> 3) < x->mv_row_min) || ((mode_mv[this_mode].as_mv.row >> 3) > x->mv_row_max) ||
-                ((mode_mv[this_mode].as_mv.col >> 3) < x->mv_col_min) || ((mode_mv[this_mode].as_mv.col >> 3) > x->mv_col_max))
-                continue;
-
-            rate2 += vp8_cost_mv_ref(&cpi->common, this_mode, mdcounts);
-            x->e_mbd.mode_info_context->mbmi.mv.as_int =
-                                                    mode_mv[this_mode].as_int;
-
-            /* Exit early and don't compute the distortion if this macroblock is marked inactive. */
-            if (cpi->active_map_enabled && x->active_ptr[0] == 0)
-            {
-                sse = 0;
-                distortion2 = 0;
-                x->skip = 1;
-                break;
-            }
-
-            if((this_mode != NEWMV) ||
-                !(have_subp_search) || cpi->common.full_pixel==1)
-                distortion2 = get_inter_mbpred_error(x,
-                                                     &cpi->fn_ptr[BLOCK_16X16],
-                                                     &sse, mode_mv[this_mode]);
-
-            this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
-
-            if (sse < x->encode_breakout)
-            {
-                // Check u and v to make sure skip is ok
-                int sse2 = 0;
-
-                sse2 = VP8_UVSSE(x, IF_RTCD(&cpi->rtcd.variance));
-
-                if (sse2 * 2 < x->encode_breakout)
-                    x->skip = 1;
-                else
-                    x->skip = 0;
-            }
-
-            break;
-        default:
-            break;
-        }
-
-        // Experimental debug code.
-        //all_rds[mode_index] = this_rd;
-
-        if (this_rd < best_rd || x->skip)
-        {
-            // Note index of best mode
-            best_mode_index = mode_index;
-
-            *returnrate = rate2;
-            *returndistortion = distortion2;
-            best_sse = sse;
-            best_rd = this_rd;
-            vpx_memcpy(&best_mbmode, &x->e_mbd.mode_info_context->mbmi, sizeof(MB_MODE_INFO));
-
-            // Testing this mode gave rise to an improvement in best error score. Lower threshold a bit for next time
-            cpi->rd_thresh_mult[mode_index] = (cpi->rd_thresh_mult[mode_index] >= (MIN_THRESHMULT + 2)) ? cpi->rd_thresh_mult[mode_index] - 2 : MIN_THRESHMULT;
-            cpi->rd_threshes[mode_index] = (cpi->rd_baseline_thresh[mode_index] >> 7) * cpi->rd_thresh_mult[mode_index];
-        }
-
-        // If the mode did not help improve the best error case then raise the threshold for testing that mode next time around.
-        else
-        {
-            cpi->rd_thresh_mult[mode_index] += 4;
-
-            if (cpi->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
-                cpi->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
-
-            cpi->rd_threshes[mode_index] = (cpi->rd_baseline_thresh[mode_index] >> 7) * cpi->rd_thresh_mult[mode_index];
-        }
-
-        if (x->skip)
-            break;
-    }
-
-    // Reduce the activation RD thresholds for the best choice mode
-    if ((cpi->rd_baseline_thresh[best_mode_index] > 0) && (cpi->rd_baseline_thresh[best_mode_index] < (INT_MAX >> 2)))
-    {
-        int best_adjustment = (cpi->rd_thresh_mult[best_mode_index] >> 3);
-
-        cpi->rd_thresh_mult[best_mode_index] = (cpi->rd_thresh_mult[best_mode_index] >= (MIN_THRESHMULT + best_adjustment)) ? cpi->rd_thresh_mult[best_mode_index] - best_adjustment : MIN_THRESHMULT;
-        cpi->rd_threshes[best_mode_index] = (cpi->rd_baseline_thresh[best_mode_index] >> 7) * cpi->rd_thresh_mult[best_mode_index];
-    }
-
-
-    {
-        int this_rdbin = (*returndistortion >> 7);
-
-        if (this_rdbin >= 1024)
-        {
-            this_rdbin = 1023;
-        }
-
-        cpi->error_bins[this_rdbin] ++;
-    }
-
-    // This code force Altref,0,0 and skip for the frame that overlays a
-    // an alrtef unless Altref is filtered. However, this is unsafe if
-    // segment level coding of ref frame or mode is enabled for this
-    // segment.
-    if (!segfeature_active( xd, segment_id, SEG_LVL_REF_FRAME ) &&
-        !segfeature_active( xd, segment_id, SEG_LVL_MODE ) &&
-        cpi->is_src_frame_alt_ref &&
-        (cpi->oxcf.arnr_max_frames == 0) &&
-        (best_mbmode.mode != ZEROMV || best_mbmode.ref_frame != ALTREF_FRAME))
-    {
-        x->e_mbd.mode_info_context->mbmi.mode = ZEROMV;
-        x->e_mbd.mode_info_context->mbmi.ref_frame = ALTREF_FRAME;
-        x->e_mbd.mode_info_context->mbmi.mv.as_int = 0;
-        x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED;
-        x->e_mbd.mode_info_context->mbmi.mb_skip_coeff =
-                                        (cpi->common.mb_no_coeff_skip) ? 1 : 0;
-        x->e_mbd.mode_info_context->mbmi.partitioning = 0;
-
-        return;
-    }
-
-    /* set to the best mb mode */
-    vpx_memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mbmode, sizeof(MB_MODE_INFO));
-
-    if (best_mbmode.mode <= B_PRED)
-    {
-        /* set mode_info_context->mbmi.uv_mode */
-        pick_intra_mbuv_mode(x);
-    }
-
-    update_mvcount(cpi, &x->e_mbd, &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame]);
-}
-
-
-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;
-    int this_rd;
-    unsigned int sse;
-    BLOCK *b = &x->block[0];
-
-    x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
-
-    pick_intra_mbuv_mode(x);
-
-    for (mode = DC_PRED; mode <= TM_PRED; mode ++)
-    {
-        x->e_mbd.mode_info_context->mbmi.mode = mode;
-        RECON_INVOKE(&cpi->common.rtcd.recon, build_intra_predictors_mby)
-            (&x->e_mbd);
-        distortion = VARIANCE_INVOKE(&cpi->rtcd.variance, var16x16)
-            (*(b->base_src), b->src_stride, x->e_mbd.predictor, 16, &sse);
-        rate = x->mbmode_cost[x->e_mbd.frame_type][mode];
-        this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
-
-        if (error16x16 > this_rd)
-        {
-            error16x16 = this_rd;
-            best_mode = mode;
-            best_sse = sse;
-            best_rate = 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;
-        best_rate = rate;
-    }
-
-    *rate_ = best_rate;
-}
--- a/vp8/encoder/pickinter.h
+++ /dev/null
@@ -1,19 +1,0 @@
-/*
- *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-
-#ifndef __INC_PICKINTER_H
-#define __INC_PICKINTER_H
-#include "vpx_ports/config.h"
-#include "vp8/common/onyxc_int.h"
-
-extern void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int recon_uvoffset, int *returnrate, int *returndistortion, int *returnintra);
-extern void vp8_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate);
-#endif
--- a/vp8/encoder/ppc/csystemdependent.c
+++ b/vp8/encoder/ppc/csystemdependent.c
@@ -48,8 +48,6 @@
 void (*vp8_subtract_mbuv)(short *diff, unsigned char *usrc, unsigned char *vsrc, unsigned char *pred, int stride);
 void (*vp8_fast_quantize_b)(BLOCK *b, BLOCKD *d);
 
-unsigned int (*vp8_get4x4sse_cs)(unsigned char *src_ptr, int  source_stride, unsigned char *ref_ptr, int  recon_stride);
-
 // c imports
 extern int block_error_c(short *coeff, short *dqcoeff);
 extern int vp8_mbblock_error_c(MACROBLOCK *mb, int dc);
@@ -85,7 +83,6 @@
 extern sub_pixel_variance_function sub_pixel_variance16x16_c;
 
 extern unsigned int vp8_get_mb_ss_c(short *);
-extern unsigned int vp8_get4x4sse_cs_c(unsigned char *src_ptr, int  source_stride, unsigned char *ref_ptr, int  recon_stride);
 
 // ppc
 extern int vp8_block_error_ppc(short *coeff, short *dqcoeff);
@@ -143,7 +140,6 @@
     vp8_sub_pixel_variance16x16   = vp8_sub_pixel_variance16x16_ppc;
 
     vp8_get_mb_ss                 = vp8_get_mb_ss_c;
-    vp8_get4x4sse_cs            = vp8_get4x4sse_cs_c;
 
     vp8_sad16x16                = vp8_sad16x16_ppc;
     vp8_sad16x8                 = vp8_sad16x8_ppc;
--- a/vp8/encoder/ratectrl.c
+++ b/vp8/encoder/ratectrl.c
@@ -471,13 +471,6 @@
 #endif
         }
 
-        // golden frame boost without recode loop often goes awry.  be safe by keeping numbers down.
-        if (!cpi->sf.recode_loop)
-        {
-            if (cpi->compressor_speed == 2)
-                Boost = Boost / 2;
-        }
-
         // Apply an upper limit based on Q for 1 pass encodes
         // TODO.
         // This is a temporay measure oas one pass not really supported yet in
--- a/vp8/encoder/variance.h
+++ b/vp8/encoder/variance.h
@@ -315,11 +315,6 @@
 #endif
 extern prototype_variance(vp8_variance_mse16x16);
 
-#ifndef vp8_variance_get4x4sse_cs
-#define vp8_variance_get4x4sse_cs vp8_get4x4sse_cs_c
-#endif
-extern prototype_get16x16prederror(vp8_variance_get4x4sse_cs);
-
 #ifndef vp8_ssimpf_8x8
 #define vp8_ssimpf_8x8 vp8_ssim_parms_8x8_c
 #endif
@@ -372,8 +367,6 @@
 
     vp8_getmbss_fn_t         getmbss;
     vp8_variance_fn_t        mse16x16;
-
-    vp8_get16x16prederror_fn_t get4x4sse_cs;
 
     vp8_sad_multi_fn_t       sad16x16x3;
     vp8_sad_multi_fn_t       sad16x8x3;
--- a/vp8/encoder/x86/variance_x86.h
+++ b/vp8/encoder/x86/variance_x86.h
@@ -42,7 +42,6 @@
 extern prototype_getmbss(vp8_get_mb_ss_mmx);
 extern prototype_variance(vp8_mse16x16_mmx);
 extern prototype_variance2(vp8_get8x8var_mmx);
-extern prototype_get16x16prederror(vp8_get4x4sse_cs_mmx);
 
 #if !CONFIG_RUNTIME_CPU_DETECT
 #undef  vp8_variance_sad4x4
@@ -107,9 +106,6 @@
 
 #undef  vp8_variance_mse16x16
 #define vp8_variance_mse16x16 vp8_mse16x16_mmx
-
-#undef  vp8_variance_get4x4sse_cs
-#define vp8_variance_get4x4sse_cs vp8_get4x4sse_cs_mmx
 
 #endif
 #endif
--- a/vp8/encoder/x86/x86_csystemdependent.c
+++ b/vp8/encoder/x86/x86_csystemdependent.c
@@ -152,8 +152,6 @@
         cpi->rtcd.variance.mse16x16              = vp8_mse16x16_mmx;
         cpi->rtcd.variance.getmbss               = vp8_get_mb_ss_mmx;
 
-        cpi->rtcd.variance.get4x4sse_cs          = vp8_get4x4sse_cs_mmx;
-
         cpi->rtcd.fdct.short4x4                  = vp8_short_fdct4x4_mmx;
         cpi->rtcd.fdct.short8x4                  = vp8_short_fdct8x4_mmx;
         cpi->rtcd.fdct.fast4x4                   = vp8_short_fdct4x4_mmx;
@@ -200,8 +198,6 @@
 
         cpi->rtcd.variance.mse16x16              = vp8_mse16x16_wmt;
         cpi->rtcd.variance.getmbss               = vp8_get_mb_ss_sse2;
-
-        /* cpi->rtcd.variance.get4x4sse_cs  not implemented for wmt */;
 
         cpi->rtcd.fdct.short4x4                  = vp8_short_fdct4x4_sse2;
         cpi->rtcd.fdct.short8x4                  = vp8_short_fdct8x4_sse2;
--- a/vp8/vp8cx.mk
+++ b/vp8/vp8cx.mk
@@ -57,7 +57,6 @@
 VP8_CX_SRCS-yes += encoder/mcomp.h
 VP8_CX_SRCS-yes += encoder/modecosts.h
 VP8_CX_SRCS-yes += encoder/onyx_int.h
-VP8_CX_SRCS-yes += encoder/pickinter.h
 VP8_CX_SRCS-yes += encoder/psnr.h
 VP8_CX_SRCS-yes += encoder/quantize.h
 VP8_CX_SRCS-yes += encoder/ratectrl.h
@@ -68,7 +67,6 @@
 VP8_CX_SRCS-yes += encoder/mcomp.c
 VP8_CX_SRCS-yes += encoder/modecosts.c
 VP8_CX_SRCS-yes += encoder/onyx_if.c
-VP8_CX_SRCS-yes += encoder/pickinter.c
 VP8_CX_SRCS-yes += encoder/picklpf.c
 VP8_CX_SRCS-yes += encoder/psnr.c
 VP8_CX_SRCS-yes += encoder/quantize.c