Merge "Adding get_switchable_rate function." into experimental
diff --git a/configure b/configure
index 945a681..5cbf070 100755
--- a/configure
+++ b/configure
@@ -240,13 +240,11 @@
 EXPERIMENT_LIST="
     csm
     implicit_segmentation
-    comp_interintra_pred
     modelcoefprob
     loop_dering
     scatterscan
     oneshotq
     multiple_arf
-    code_zerogroup
     non420
     ab4x4
 "
diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h
index a219935..af8e662 100644
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -234,9 +234,6 @@
 
 typedef struct {
   MB_PREDICTION_MODE mode, uv_mode;
-#if CONFIG_COMP_INTERINTRA_PRED
-  MB_PREDICTION_MODE interintra_mode, interintra_uv_mode;
-#endif
   MV_REFERENCE_FRAME ref_frame, second_ref_frame;
   TX_SIZE txfm_size;
   int_mv mv[2]; // for each reference frame used
@@ -961,9 +958,4 @@
   }
 }
 
-#if CONFIG_CODE_ZEROGROUP
-static int get_zpc_used(TX_SIZE tx_size) {
-  return (tx_size >= TX_16X16);
-}
-#endif
 #endif  // VP9_COMMON_VP9_BLOCKD_H_
diff --git a/vp9/common/vp9_coefupdateprobs.h b/vp9/common/vp9_coefupdateprobs.h
index e49935c..231def1 100644
--- a/vp9/common/vp9_coefupdateprobs.h
+++ b/vp9/common/vp9_coefupdateprobs.h
@@ -18,10 +18,6 @@
   252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252
 };
 
-#if CONFIG_CODE_ZEROGROUP
-#define ZPC_UPDATE_PROB         248
-#endif
-
 #if CONFIG_MODELCOEFPROB
 #define COEF_MODEL_UPDATE_PROB   16
 #endif
diff --git a/vp9/common/vp9_default_coef_probs.h b/vp9/common/vp9_default_coef_probs.h
index 453b4a2..9e37333 100644
--- a/vp9/common/vp9_default_coef_probs.h
+++ b/vp9/common/vp9_default_coef_probs.h
@@ -699,86 +699,3 @@
     }
   }
 };
-
-#if CONFIG_CODE_ZEROGROUP
-
-// There are two probs: the first is the prob(0) of the isolated zero bit,
-// the second is the prob(0) of the end of orientation symbol [if 0 that
-// indicates a zerotree root].
-static const vp9_zpc_probs default_zpc_probs_4x4 = {
-  { /* Intra */
-    { /* Coeff Band 0 */
-      { 1, }, { 1, }, { 1, },
-    }, { /* Coeff Band 1 */
-      { 1, }, { 1, }, { 1, },
-    }, { /* Coeff Band 2 */
-      { 1, }, { 1, }, { 1, },
-    }
-  }, { /* Inter */
-    { /* Coeff Band 0 */
-      { 1, }, { 1, }, { 1, },
-    }, { /* Coeff Band 1 */
-      { 1, }, { 1, }, { 1, },
-    }, { /* Coeff Band 2 */
-      { 1, }, { 1, }, { 1, },
-    }
-  }
-};
-static const vp9_zpc_probs default_zpc_probs_8x8 = {
-  { /* Intra */
-    { /* ZPC Band 0 */
-      { 4, }, { 2, }, { 1, },
-    }, { /* ZPC Band 1 */
-      { 4, }, { 2, }, { 1, },
-    }, { /* ZPC Band 2 */
-      { 4, }, { 2, }, { 1, },
-    }
-  }, { /* Inter */
-    { /* ZPC Band 0 */
-      { 4, }, { 2, }, { 1, },
-    }, { /* ZPC Band 1 */
-      { 4, }, { 2, }, { 1, },
-    }, { /* ZPC Band 2 */
-      { 4, }, { 2, }, { 1, },
-    }
-  }
-};
-static const vp9_zpc_probs default_zpc_probs_16x16 = {
-  { /* Intra */
-    { /* ZPC Band 0 */
-      {  57,  }, {  30,  }, {   13,  },
-    }, { /* ZPC Band 1 */
-      {  46,  }, {  23,  }, {   4,  },
-    }, { /* ZPC Band 1 */
-      {  36,  }, {  11,  }, {   2,  },
-    },
-  }, { /* Inter */
-    { /* ZPC Band 0 */
-      {  45,  }, {  21  }, {  10,  },
-    }, { /* ZPC Band 1 */
-      {  24,  }, {  14,  }, {   3,  },
-    }, { /* ZPC Band 2 */
-      {  16,  }, {  6,  }, {   1,  },
-    },
-  },
-};
-static const vp9_zpc_probs default_zpc_probs_32x32 = {
-  { /* Intra */
-    { /* ZPC Band 0 */
-      {  132,  }, {  60,  }, {  19,  },
-    }, { /* ZPC Band 1 */
-      {  64,  }, {  32,  }, {   8,  },
-    }, { /* ZPC Band 2 */
-      {  25,  }, {  11,  }, {   1,  },
-    },
-  }, { /* Inter */
-    { /* ZPC Band 0 */
-      {  134,  }, {  39,  }, {  25,  },
-    }, { /* ZPC Band 1 */
-      {  64,  }, {  24,  }, {  12,  },
-    }, { /* ZPC Band 2 */
-      {  21,  }, {  10,  }, {   1,  },
-    },
-  },
-};
-#endif  // CONFIG_CODE_ZEROGROUP
diff --git a/vp9/common/vp9_entropy.c b/vp9/common/vp9_entropy.c
index faa45bd..4dfe9c4 100644
--- a/vp9/common/vp9_entropy.c
+++ b/vp9/common/vp9_entropy.c
@@ -1338,16 +1338,6 @@
   vpx_memcpy(pc->fc.coef_probs_32x32, default_coef_probs_32x32,
              sizeof(pc->fc.coef_probs_32x32));
 #endif
-#if CONFIG_CODE_ZEROGROUP
-  vpx_memcpy(pc->fc.zpc_probs_4x4, default_zpc_probs_4x4,
-             sizeof(pc->fc.zpc_probs_4x4));
-  vpx_memcpy(pc->fc.zpc_probs_8x8, default_zpc_probs_8x8,
-             sizeof(pc->fc.zpc_probs_8x8));
-  vpx_memcpy(pc->fc.zpc_probs_16x16, default_zpc_probs_16x16,
-             sizeof(pc->fc.zpc_probs_16x16));
-  vpx_memcpy(pc->fc.zpc_probs_32x32, default_zpc_probs_32x32,
-             sizeof(pc->fc.zpc_probs_32x32));
-#endif
 }
 
 // Neighborhood 5-tuples for various scans and blocksizes,
@@ -1588,121 +1578,3 @@
                    count_sat, update_factor);
 #endif
 }
-
-#if CONFIG_CODE_ZEROGROUP
-OrientationType vp9_get_orientation(int rc, TX_SIZE tx_size) {
-  int i = rc >> (tx_size + 2);
-  int j = rc & ((4 << tx_size) - 1);
-  if (i > 2 * j)
-    return VERTICAL;
-  else if (j > 2 * i)
-    return HORIZONTAL;
-  else
-    return DIAGONAL;
-  /*
-  if (i == 0 && j == 0) return DIAGONAL;
-  while (i > 1 || j > 1) {
-    i >>= 1;
-    j >>= 1;
-  }
-  if (i == 0 && j == 1)
-    return HORIZONTAL;  // horizontal
-  else if (i == 1 && j == 1)
-    return DIAGONAL;    // diagonal
-  else if (i == 1 && j == 0)
-    return VERTICAL;    // vertical
-  assert(0);
-  */
-}
-
-int vp9_use_eoo(int c, int seg_eob, const int *scan,
-                TX_SIZE tx_size, int *is_last_zero, int *is_eoo) {
-  // NOTE: returning 0 from this function will turn off eoo symbols
-  // For instance we can experiment with turning eoo off for smaller blocks
-  // and/or lower bands
-  int o = vp9_get_orientation(scan[c], tx_size);
-  int band = get_coef_band(scan, tx_size, c);
-  int use_eoo = (!is_last_zero[o] &&
-                 !is_eoo[o] &&
-                 band <= ZPC_EOO_BAND_UPPER &&
-                 band >= ZPC_EOO_BAND_LOWER &&
-                 get_zpc_used(tx_size) &&
-                 seg_eob - c > (ZPC_USEEOO_THRESH << tx_size) &&
-                 is_eoo[0] + is_eoo[1] + is_eoo[2] < 2);
-  return use_eoo;
-}
-
-int vp9_is_eoo(int c, int eob, const int *scan, TX_SIZE tx_size,
-               const int16_t *qcoeff_ptr, int *last_nz_pos) {
-  int rc = scan[c];
-  int o = vp9_get_orientation(rc, tx_size);
-  int eoo = c > last_nz_pos[o];
-  return eoo;
-}
-
-static void adapt_zpc_probs_common(VP9_COMMON *cm,
-                                   TX_SIZE tx_size,
-                                   int count_sat,
-                                   int update_factor) {
-  int r, b, p, n;
-  int count, factor;
-  vp9_zpc_probs *zpc_probs;
-  vp9_zpc_probs *pre_zpc_probs;
-  vp9_zpc_count *zpc_counts;
-  if (!get_zpc_used(tx_size)) return;
-  if (tx_size == TX_32X32) {
-    zpc_probs = &cm->fc.zpc_probs_32x32;
-    pre_zpc_probs = &cm->fc.pre_zpc_probs_32x32;
-    zpc_counts = &cm->fc.zpc_counts_32x32;
-  } else if (tx_size == TX_16X16) {
-    zpc_probs = &cm->fc.zpc_probs_16x16;
-    pre_zpc_probs = &cm->fc.pre_zpc_probs_16x16;
-    zpc_counts = &cm->fc.zpc_counts_16x16;
-  } else if (tx_size == TX_8X8) {
-    zpc_probs = &cm->fc.zpc_probs_8x8;
-    pre_zpc_probs = &cm->fc.pre_zpc_probs_8x8;
-    zpc_counts = &cm->fc.zpc_counts_8x8;
-  } else {
-    zpc_probs = &cm->fc.zpc_probs_4x4;
-    pre_zpc_probs = &cm->fc.pre_zpc_probs_4x4;
-    zpc_counts = &cm->fc.zpc_counts_4x4;
-  }
-  for (r = 0; r < REF_TYPES; ++r) {
-    for (b = 0; b < ZPC_BANDS; ++b) {
-      for (p = 0; p < ZPC_PTOKS; ++p) {
-        for (n = 0; n < ZPC_NODES; ++n) {
-          vp9_prob prob = get_binary_prob((*zpc_counts)[r][b][p][n][0],
-                                          (*zpc_counts)[r][b][p][n][1]);
-          count = (*zpc_counts)[r][b][p][n][0] + (*zpc_counts)[r][b][p][n][1];
-          count = count > count_sat ? count_sat : count;
-          factor = (update_factor * count / count_sat);
-          (*zpc_probs)[r][b][p][n] = weighted_prob(
-              (*pre_zpc_probs)[r][b][p][n], prob, factor);
-        }
-      }
-    }
-  }
-}
-
-// #define ZPC_COUNT_TESTING
-void vp9_adapt_zpc_probs(VP9_COMMON *cm) {
-  int count_sat;
-  int update_factor; /* denominator 256 */
-
-  if (cm->frame_type == KEY_FRAME) {
-    update_factor = COEF_MAX_UPDATE_FACTOR_KEY;
-    count_sat = COEF_COUNT_SAT_KEY;
-  } else if (cm->last_frame_type == KEY_FRAME) {
-    update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY;  /* adapt quickly */
-    count_sat = COEF_COUNT_SAT_AFTER_KEY;
-  } else {
-    update_factor = COEF_MAX_UPDATE_FACTOR;
-    count_sat = COEF_COUNT_SAT;
-  }
-
-  adapt_zpc_probs_common(cm, TX_4X4, count_sat, update_factor);
-  adapt_zpc_probs_common(cm, TX_8X8, count_sat, update_factor);
-  adapt_zpc_probs_common(cm, TX_16X16, count_sat, update_factor);
-  adapt_zpc_probs_common(cm, TX_32X32, count_sat, update_factor);
-}
-#endif  // CONFIG_CODE_ZEROGROUP
diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h
index f12ee95..fe3d5c6 100644
--- a/vp9/common/vp9_entropy.h
+++ b/vp9/common/vp9_entropy.h
@@ -176,62 +176,6 @@
                                 int b, int r);
 #endif  // CONFIG_MODELCOEFPROB
 
-#if CONFIG_CODE_ZEROGROUP
-
-#define ZPC_STATS
-
-typedef enum {
-  HORIZONTAL = 0,
-  DIAGONAL,
-  VERTICAL,
-} OrientationType;
-
-/* Note EOB should become part of this symbol eventually,
- * but holding off on this for now because that is a major
- * change in the rest of the codebase */
-
-#define ZPC_ISOLATED     (MAX_ENTROPY_TOKENS + 0)    /* Isolated zero */
-
-/* ZPC_EOORIENT: All remaining coefficients in the same orientation are 0.
- * In other words all remaining coeffs in the current subband, and all
- * children of the current subband are zero. Subbands are defined by
- * dyadic partitioning in the coeff domain */
-#define ZPC_EOORIENT     (MAX_ENTROPY_TOKENS + 1)    /* End of Orientation */
-
-/* Band limits over which the eoo bit is sent */
-#define ZPC_EOO_BAND_LOWER       0
-#define ZPC_EOO_BAND_UPPER       5
-
-#define USE_ZPC_EOORIENT         1       /* 0: not used */
-                                         /* 1: used */
-#define ZPC_NODES                1
-
-#define UNKNOWN_TOKEN          255       /* Not signalled, encoder only */
-
-#define ZPC_BANDS                3       /* context bands for izr */
-#define ZPC_PTOKS                3       /* context pt for zpcs */
-
-#define coef_to_zpc_band(b)      ((b) >> 1)
-#define coef_to_zpc_ptok(p)      ((p) > 2 ? 2 : (p))
-
-typedef vp9_prob vp9_zpc_probs[REF_TYPES][ZPC_BANDS]
-                              [ZPC_PTOKS][ZPC_NODES];
-typedef unsigned int vp9_zpc_count[REF_TYPES][ZPC_BANDS]
-                                  [ZPC_PTOKS][ZPC_NODES][2];
-
-OrientationType vp9_get_orientation(int rc, TX_SIZE tx_size);
-int vp9_use_eoo(int c, int eob, const int *scan, TX_SIZE tx_size,
-                int *is_last_zero, int *is_eoo);
-int vp9_is_eoo(int c, int eob, const int *scan, TX_SIZE tx_size,
-               const int16_t *qcoeff_ptr, int *last_nz_pos);
-
-#define ZPC_USEEOO_THRESH        4
-#define ZPC_ZEROSSAVED_EOO       7   /* encoder only */
-
-void vp9_adapt_zpc_probs(struct VP9Common *cm);
-
-#endif  // CONFIG_CODE_ZEROGROUP
-
 static INLINE const int* get_scan_4x4(TX_TYPE tx_type) {
   switch (tx_type) {
     case ADST_DCT:
diff --git a/vp9/common/vp9_entropymode.c b/vp9/common/vp9_entropymode.c
index 503ad95..dcee62f 100644
--- a/vp9/common/vp9_entropymode.c
+++ b/vp9/common/vp9_entropymode.c
@@ -256,9 +256,6 @@
   vpx_memcpy(x->fc.partition_prob, vp9_partition_probs,
              sizeof(vp9_partition_probs));
 
-#if CONFIG_COMP_INTERINTRA_PRED
-  x->fc.interintra_prob = VP9_DEF_INTERINTRA_PROB;
-#endif
   x->ref_pred_probs[0] = DEFAULT_PRED_PROB_0;
   x->ref_pred_probs[1] = DEFAULT_PRED_PROB_1;
   x->ref_pred_probs[2] = DEFAULT_PRED_PROB_2;
@@ -493,13 +490,6 @@
   for (t = 0; t < VP9_NUMMBSPLITS; ++t)
     printf("%d, ", fc->mbsplit_counts[t]);
   printf("};\n");
-#if CONFIG_COMP_INTERINTRA_PRED
-  printf("static const unsigned int\ninterintra_counts"
-         "[2] = {\n");
-  for (t = 0; t < 2; ++t)
-    printf("%d, ", fc->interintra_counts[t]);
-  printf("};\n");
-#endif
 #endif
 
   update_mode_probs(VP9_YMODES, vp9_ymode_tree,
@@ -523,20 +513,6 @@
                       vp9_sub_mv_ref_tree, fc->sub_mv_ref_counts[i],
                       fc->pre_sub_mv_ref_prob[i], fc->sub_mv_ref_prob[i],
                       LEFT4X4);
-
-#if CONFIG_COMP_INTERINTRA_PRED
-  if (cm->use_interintra) {
-    int factor, interintra_prob, count;
-
-    interintra_prob = get_binary_prob(fc->interintra_counts[0],
-                                      fc->interintra_counts[1]);
-    count = fc->interintra_counts[0] + fc->interintra_counts[1];
-    count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
-    factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
-    fc->interintra_prob = weighted_prob(fc->pre_interintra_prob,
-                                        interintra_prob, factor);
-  }
-#endif
   for (i = 0; i < NUM_PARTITION_CONTEXTS; i++)
     update_mode_probs(PARTITION_TYPES, vp9_partition_tree,
                       fc->partition_counts[i], fc->pre_partition_prob[i],
diff --git a/vp9/common/vp9_entropymode.h b/vp9/common/vp9_entropymode.h
index f49bb3b..4c3fc06 100644
--- a/vp9/common/vp9_entropymode.h
+++ b/vp9/common/vp9_entropymode.h
@@ -16,13 +16,6 @@
 
 #define SUBMVREF_COUNT 5
 
-#if CONFIG_COMP_INTERINTRA_PRED
-#define VP9_DEF_INTERINTRA_PROB 248
-#define VP9_UPD_INTERINTRA_PROB 192
-// whether to use a separate uv mode (1) or use the same as the y mode (0)
-#define SEPARATE_INTERINTRA_UV  0
-#endif
-
 extern int vp9_mv_cont(const int_mv *l, const int_mv *a);
 
 extern const vp9_prob vp9_sub_mv_ref_prob2[SUBMVREF_COUNT][VP9_SUBMVREFS - 1];
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index fe6e14a..d9d2989 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -62,12 +62,6 @@
   vp9_coeff_probs coef_probs_8x8[BLOCK_TYPES];
   vp9_coeff_probs coef_probs_16x16[BLOCK_TYPES];
   vp9_coeff_probs coef_probs_32x32[BLOCK_TYPES];
-#if CONFIG_CODE_ZEROGROUP
-  vp9_zpc_probs zpc_probs_4x4;
-  vp9_zpc_probs zpc_probs_8x8;
-  vp9_zpc_probs zpc_probs_16x16;
-  vp9_zpc_probs zpc_probs_32x32;
-#endif
 
   nmv_context nmvc;
   nmv_context pre_nmvc;
@@ -88,12 +82,6 @@
   vp9_coeff_probs pre_coef_probs_8x8[BLOCK_TYPES];
   vp9_coeff_probs pre_coef_probs_16x16[BLOCK_TYPES];
   vp9_coeff_probs pre_coef_probs_32x32[BLOCK_TYPES];
-#if CONFIG_CODE_ZEROGROUP
-  vp9_zpc_probs pre_zpc_probs_4x4;
-  vp9_zpc_probs pre_zpc_probs_8x8;
-  vp9_zpc_probs pre_zpc_probs_16x16;
-  vp9_zpc_probs pre_zpc_probs_32x32;
-#endif
 
   vp9_coeff_count coef_counts_4x4[BLOCK_TYPES];
   vp9_coeff_count coef_counts_8x8[BLOCK_TYPES];
@@ -102,21 +90,9 @@
   unsigned int eob_branch_counts[TX_SIZE_MAX_SB][BLOCK_TYPES][REF_TYPES]
                                 [COEF_BANDS][PREV_COEF_CONTEXTS];
 
-#if CONFIG_CODE_ZEROGROUP
-  vp9_zpc_count zpc_counts_4x4;
-  vp9_zpc_count zpc_counts_8x8;
-  vp9_zpc_count zpc_counts_16x16;
-  vp9_zpc_count zpc_counts_32x32;
-#endif
-
   nmv_context_counts NMVcount;
   vp9_prob switchable_interp_prob[VP9_SWITCHABLE_FILTERS + 1]
                                  [VP9_SWITCHABLE_FILTERS - 1];
-#if CONFIG_COMP_INTERINTRA_PRED
-  unsigned int interintra_counts[2];
-  vp9_prob interintra_prob;
-  vp9_prob pre_interintra_prob;
-#endif
 
   int vp9_mode_contexts[INTER_MODE_CONTEXTS][4];
   unsigned int mv_ref_ct[INTER_MODE_CONTEXTS][4][2];
@@ -292,10 +268,6 @@
   struct postproc_state  postproc_state;
 #endif
 
-#if CONFIG_COMP_INTERINTRA_PRED
-  int use_interintra;
-#endif
-
   int error_resilient_mode;
   int frame_parallel_decoding_mode;
 
@@ -352,10 +324,6 @@
 }
 
 static int get_token_alloc(int mb_rows, int mb_cols) {
-#if CONFIG_CODE_ZEROGROUP
-  return mb_rows * mb_cols * (24 * 16 * 2);
-#else
   return mb_rows * mb_cols * (24 * 16 + 4);
-#endif
 }
 #endif  // VP9_COMMON_VP9_ONYXC_INT_H_
diff --git a/vp9/common/vp9_reconinter.c b/vp9/common/vp9_reconinter.c
index 14642f2..65a9093 100644
--- a/vp9/common/vp9_reconinter.c
+++ b/vp9/common/vp9_reconinter.c
@@ -416,23 +416,9 @@
 void vp9_build_inter_predictors_sb(MACROBLOCKD *xd,
                                    int mi_row, int mi_col,
                                    BLOCK_SIZE_TYPE bsize) {
-#if CONFIG_COMP_INTERINTRA_PRED
-  uint8_t *const y = xd->plane[0].dst.buf;
-  uint8_t *const u = xd->plane[1].dst.buf;
-  uint8_t *const v = xd->plane[2].dst.buf;
-  const int y_stride = xd->plane[0].dst.stride;
-  const int uv_stride = xd->plane[1].dst.stride;
-#endif
 
   vp9_build_inter_predictors_sby(xd, mi_row, mi_col, bsize);
   vp9_build_inter_predictors_sbuv(xd, mi_row, mi_col, bsize);
-
-#if CONFIG_COMP_INTERINTRA_PRED
-  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
 }
 
 /*encoder only*/
diff --git a/vp9/common/vp9_reconintra.c b/vp9/common/vp9_reconintra.c
index dad5be76..9e580c7 100644
--- a/vp9/common/vp9_reconintra.c
+++ b/vp9/common/vp9_reconintra.c
@@ -363,186 +363,6 @@
   }
 }
 
-#if CONFIG_COMP_INTERINTRA_PRED
-static void combine_interintra(MB_PREDICTION_MODE mode,
-                               uint8_t *interpred,
-                               int interstride,
-                               uint8_t *intrapred,
-                               int intrastride,
-                               int bw, int bh) {
-  // TODO(debargha): Explore different ways of combining predictors
-  //                 or designing the tables below
-  static const int scale_bits = 8;
-  static const int scale_max = 256;     // 1 << scale_bits;
-  static const int scale_round = 127;   // (1 << (scale_bits - 1));
-  // This table is a function A + B*exp(-kx), where x is hor. index
-  static const int weights1d[64] = {
-    128, 125, 122, 119, 116, 114, 111, 109,
-    107, 105, 103, 101,  99,  97,  96,  94,
-     93,  91,  90,  89,  88,  86,  85,  84,
-     83,  82,  81,  81,  80,  79,  78,  78,
-     77,  76,  76,  75,  75,  74,  74,  73,
-     73,  72,  72,  71,  71,  71,  70,  70,
-     70,  70,  69,  69,  69,  69,  68,  68,
-     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 :
-                    size == 8  ? 8 : 16);
-  int i, j;
-  switch (mode) {
-    case V_PRED:
-      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] =
-              ((scale_max - scale) * interpred[k] +
-               scale * intrapred[i * intrastride + j] + scale_round)
-              >> scale_bits;
-        }
-      }
-      break;
-
-    case H_PRED:
-      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] =
-              ((scale_max - scale) * interpred[k] +
-               scale * intrapred[i * intrastride + j] + scale_round)
-              >> scale_bits;
-        }
-      }
-      break;
-
-    case D63_PRED:
-    case D117_PRED:
-      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;
-          interpred[k] =
-              ((scale_max - scale) * interpred[k] +
-               scale * intrapred[i * intrastride + j] + scale_round)
-              >> scale_bits;
-        }
-      }
-      break;
-
-    case D27_PRED:
-    case D153_PRED:
-      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;
-          interpred[k] =
-              ((scale_max - scale) * interpred[k] +
-               scale * intrapred[i * intrastride + j] + scale_round)
-              >> scale_bits;
-        }
-      }
-      break;
-
-    case D135_PRED:
-      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] =
-              ((scale_max - scale) * interpred[k] +
-               scale * intrapred[i * intrastride + j] + scale_round)
-              >> scale_bits;
-        }
-      }
-      break;
-
-    case D45_PRED:
-      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;
-          interpred[k] =
-              ((scale_max - scale) * interpred[k] +
-               scale * intrapred[i * intrastride + j] + scale_round)
-              >> scale_bits;
-        }
-      }
-      break;
-
-    case TM_PRED:
-    case DC_PRED:
-    default:
-      // simple average
-      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;
-        }
-      }
-      break;
-  }
-}
-
-void vp9_build_interintra_predictors(MACROBLOCKD *xd,
-                                              uint8_t *ypred,
-                                              uint8_t *upred,
-                                              uint8_t *vpred,
-                                              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_predictors_sby(MACROBLOCKD *xd,
-                                               uint8_t *ypred,
-                                               int ystride,
-                                               BLOCK_SIZE_TYPE bsize) {
-  int bwl = mi_width_log2(bsize),  bw = MI_SIZE << bwl;
-  int bhl = mi_height_log2(bsize), bh = MI_SIZE << bhl;
-  uint8_t intrapredictor[4096];
-  vp9_build_intra_predictors(
-      xd->plane[0].dst.buf, xd->plane[0].dst.stride,
-      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, bw, bw, bh);
-}
-
-void vp9_build_interintra_predictors_sbuv(MACROBLOCKD *xd,
-                                                uint8_t *upred,
-                                                uint8_t *vpred,
-                                                int uvstride,
-                                                BLOCK_SIZE_TYPE bsize) {
-  int bwl = mi_width_log2(bsize),  bw = MI_UV_SIZE << bwl;
-  int bhl = mi_height_log2(bsize), bh = MI_UV_SIZE << bhl;
-  uint8_t uintrapredictor[1024];
-  uint8_t vintrapredictor[1024];
-  vp9_build_intra_predictors(
-      xd->plane[1].dst.buf, xd->plane[1].dst.stride,
-      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, 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, bw, bw, bh);
-  combine_interintra(xd->mode_info_context->mbmi.interintra_uv_mode,
-                     vpred, uvstride, vintrapredictor, bw, bw, bh);
-}
-#endif  // CONFIG_COMP_INTERINTRA_PRED
-
 void vp9_build_intra_predictors_sby_s(MACROBLOCKD *xd,
                                       BLOCK_SIZE_TYPE bsize) {
   const int bwl = b_width_log2(bsize),  bw = 4 << bwl;
diff --git a/vp9/common/vp9_reconintra.h b/vp9/common/vp9_reconintra.h
index 21cd7ab..1a715c3 100644
--- a/vp9/common/vp9_reconintra.h
+++ b/vp9/common/vp9_reconintra.h
@@ -21,25 +21,4 @@
 B_PREDICTION_MODE vp9_find_bpred_context(MACROBLOCKD *xd, int block,
                                          uint8_t *ptr, int stride);
 
-#if CONFIG_COMP_INTERINTRA_PRED
-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
-
 #endif  // VP9_COMMON_VP9_RECONINTRA_H_
diff --git a/vp9/common/vp9_swapyv12buffer.c b/vp9/common/vp9_swapyv12buffer.c
deleted file mode 100644
index 10c6b41..0000000
--- a/vp9/common/vp9_swapyv12buffer.c
+++ /dev/null
@@ -1,32 +0,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 "vp9/common/vp9_swapyv12buffer.h"
-
-void vp9_swap_yv12_buffer(YV12_BUFFER_CONFIG *new_frame,
-                          YV12_BUFFER_CONFIG *last_frame) {
-  uint8_t *temp;
-
-  temp = last_frame->buffer_alloc;
-  last_frame->buffer_alloc = new_frame->buffer_alloc;
-  new_frame->buffer_alloc = temp;
-
-  temp = last_frame->y_buffer;
-  last_frame->y_buffer = new_frame->y_buffer;
-  new_frame->y_buffer = temp;
-
-  temp = last_frame->u_buffer;
-  last_frame->u_buffer = new_frame->u_buffer;
-  new_frame->u_buffer = temp;
-
-  temp = last_frame->v_buffer;
-  last_frame->v_buffer = new_frame->v_buffer;
-  new_frame->v_buffer = temp;
-}
diff --git a/vp9/common/vp9_swapyv12buffer.h b/vp9/common/vp9_swapyv12buffer.h
deleted file mode 100644
index 2e11206..0000000
--- a/vp9/common/vp9_swapyv12buffer.h
+++ /dev/null
@@ -1,19 +0,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 VP9_COMMON_VP9_SWAPYV12BUFFER_H_
-#define VP9_COMMON_VP9_SWAPYV12BUFFER_H_
-
-#include "vpx_scale/yv12config.h"
-
-void vp9_swap_yv12_buffer(YV12_BUFFER_CONFIG *new_frame,
-                          YV12_BUFFER_CONFIG *last_frame);
-
-#endif  // VP9_COMMON_VP9_SWAPYV12BUFFER_H_
diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c
index 2c7483d..0f0dee0 100644
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -439,12 +439,7 @@
 
     if (cm->mcomp_filter_type == SWITCHABLE)
       read_switchable_interp_probs(pbi, r);
-#if CONFIG_COMP_INTERINTRA_PRED
-    if (cm->use_interintra) {
-      if (vp9_read(r, VP9_UPD_INTERINTRA_PROB))
-        cm->fc.interintra_prob = vp9_read_prob(r);
-    }
-#endif
+
     // Baseline probabilities for decoding reference frame
     cm->prob_intra_coded = vp9_read_prob(r);
     cm->prob_last_coded  = vp9_read_prob(r);
@@ -693,33 +688,6 @@
         }
       }
 
-    } else {
-#if CONFIG_COMP_INTERINTRA_PRED
-      if (pbi->common.use_interintra &&
-          mbmi->mode >= NEARESTMV && mbmi->mode < SPLITMV &&
-          mbmi->second_ref_frame == NONE) {
-        mbmi->second_ref_frame = (vp9_read(r, pbi->common.fc.interintra_prob) ?
-                                  INTRA_FRAME : NONE);
-        // printf("-- %d (%d)\n", mbmi->second_ref_frame == INTRA_FRAME,
-        //        pbi->common.fc.interintra_prob);
-        pbi->common.fc.interintra_counts[
-            mbmi->second_ref_frame == INTRA_FRAME]++;
-        if (mbmi->second_ref_frame == INTRA_FRAME) {
-          mbmi->interintra_mode = read_ymode(r, pbi->common.fc.ymode_prob);
-          pbi->common.fc.ymode_counts[mbmi->interintra_mode]++;
-#if SEPARATE_INTERINTRA_UV
-          mbmi->interintra_uv_mode = read_uv_mode(r,
-              pbi->common.fc.uv_mode_prob[mbmi->interintra_mode]);
-          pbi->common.fc.uv_mode_counts[mbmi->interintra_mode]
-                                       [mbmi->interintra_uv_mode]++;
-#else
-          mbmi->interintra_uv_mode = mbmi->interintra_mode;
-#endif
-          // printf("** %d %d\n",
-          //        mbmi->interintra_mode, mbmi->interintra_uv_mode);
-        }
-      }
-#endif
     }
 
     mbmi->uv_mode = DC_PRED;
diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c
index dc1db51..3007863 100644
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -530,54 +530,6 @@
   xd->mode_info_stride = pc->mode_info_stride;
 }
 
-#if CONFIG_CODE_ZEROGROUP
-static void read_zpc_probs_common(VP9_COMMON *cm,
-                                  vp9_reader* bc,
-                                  TX_SIZE tx_size) {
-  int r, b, p, n;
-  vp9_zpc_probs *zpc_probs;
-  vp9_prob upd = ZPC_UPDATE_PROB;
-  if (!get_zpc_used(tx_size)) return;
-  if (!vp9_read_bit(bc)) return;
-
-  if (tx_size == TX_32X32) {
-    zpc_probs = &cm->fc.zpc_probs_32x32;
-  } else if (tx_size == TX_16X16) {
-    zpc_probs = &cm->fc.zpc_probs_16x16;
-  } else if (tx_size == TX_8X8) {
-    zpc_probs = &cm->fc.zpc_probs_8x8;
-  } else {
-    zpc_probs = &cm->fc.zpc_probs_4x4;
-  }
-  for (r = 0; r < REF_TYPES; ++r) {
-    for (b = 0; b < ZPC_BANDS; ++b) {
-      for (p = 0; p < ZPC_PTOKS; ++p) {
-        for (n = 0; n < ZPC_NODES; ++n) {
-          vp9_prob *q = &(*zpc_probs)[r][b][p][n];
-#if USE_ZPC_EXTRA == 0
-          if (n == 1) continue;
-#endif
-          if (vp9_read(bc, upd)) {
-            *q = read_prob_diff_update(bc, *q);
-          }
-        }
-      }
-    }
-  }
-}
-
-static void read_zpc_probs(VP9_COMMON *cm,
-                           vp9_reader* bc) {
-  read_zpc_probs_common(cm, bc, TX_4X4);
-  if (cm->txfm_mode > ONLY_4X4)
-    read_zpc_probs_common(cm, bc, TX_8X8);
-  if (cm->txfm_mode > ALLOW_8X8)
-    read_zpc_probs_common(cm, bc, TX_16X16);
-  if (cm->txfm_mode > ALLOW_16X16)
-    read_zpc_probs_common(cm, bc, TX_32X32);
-}
-#endif  // CONFIG_CODE_ZEROGROUP
-
 static void read_coef_probs_common(vp9_coeff_probs *coef_probs,
                                    TX_SIZE tx_size,
                                    vp9_reader *r) {
@@ -855,23 +807,6 @@
   vp9_zero(fc->NMVcount);
   vp9_zero(fc->mv_ref_ct);
   vp9_zero(fc->partition_counts);
-
-#if CONFIG_COMP_INTERINTRA_PRED
-  fc->pre_interintra_prob = fc->interintra_prob;
-  vp9_zero(fc->interintra_counts);
-#endif
-
-#if CONFIG_CODE_ZEROGROUP
-  vp9_copy(fc->pre_zpc_probs_4x4, fc->zpc_probs_4x4);
-  vp9_copy(fc->pre_zpc_probs_8x8, fc->zpc_probs_8x8);
-  vp9_copy(fc->pre_zpc_probs_16x16, fc->zpc_probs_16x16);
-  vp9_copy(fc->pre_zpc_probs_32x32, fc->zpc_probs_32x32);
-
-  vp9_zero(fc->zpc_counts_4x4);
-  vp9_zero(fc->zpc_counts_8x8);
-  vp9_zero(fc->zpc_counts_16x16);
-  vp9_zero(fc->zpc_counts_32x32);
-#endif
 }
 
 static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) {
@@ -1092,10 +1027,6 @@
     xd->allow_high_precision_mv = vp9_read_bit(&header_bc);
     pc->mcomp_filter_type = read_mcomp_filter_type(&header_bc);
 
-#if CONFIG_COMP_INTERINTRA_PRED
-    pc->use_interintra = vp9_read_bit(&header_bc);
-#endif
-
     // To enable choice of different interpolation filters
     vp9_setup_interp_filters(xd, pc->mcomp_filter_type, pc);
   }
@@ -1133,9 +1064,6 @@
   update_frame_context(&pc->fc);
 
   read_coef_probs(pbi, &header_bc);
-#if CONFIG_CODE_ZEROGROUP
-  read_zpc_probs(pc, &header_bc);
-#endif
 
   // Initialize xd pointers. Any reference should do for xd->pre, so use 0.
   setup_pre_planes(xd, &pc->yv12_fb[pc->active_ref_idx[0]], NULL,
@@ -1173,9 +1101,7 @@
   // Adaptation
   if (!pc->error_resilient_mode && !pc->frame_parallel_decoding_mode) {
     vp9_adapt_coef_probs(pc);
-#if CONFIG_CODE_ZEROGROUP
-    vp9_adapt_zpc_probs(pc);
-#endif
+
     if (pc->frame_type != KEY_FRAME) {
       vp9_adapt_mode_probs(pc);
       vp9_adapt_nmv_probs(pc, xd->allow_high_precision_mv);
diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c
index e698441..ce2a86b 100644
--- a/vp9/decoder/vp9_detokenize.c
+++ b/vp9/decoder/vp9_detokenize.c
@@ -60,28 +60,12 @@
 
 DECLARE_ALIGNED(16, extern const uint8_t, vp9_norm[256]);
 
-#if CONFIG_CODE_ZEROGROUP
-#define ZEROGROUP_ADVANCE()                \
-  do {                                     \
-    token_cache[scan[c]] = ZERO_TOKEN;     \
-    is_last_zero[o] = 1;                   \
-    c++;                                   \
-  } while (0)
-#define INCREMENT_COUNT(token)             \
-  do {                                     \
-    coef_counts[type][ref][get_coef_band(scan, txfm_size, c)] \
-               [pt][token]++;     \
-    token_cache[scan[c]] = token; \
-    is_last_zero[o] = (token == ZERO_TOKEN);    \
-  } while (0)
-#else
 #define INCREMENT_COUNT(token)               \
   do {                                       \
     coef_counts[type][ref][get_coef_band(scan, txfm_size, c)] \
                [pt][token]++;     \
     token_cache[scan[c]] = token; \
   } while (0)
-#endif
 
 #define WRITE_COEF_CONTINUE(val, token)                  \
   {                                                      \
@@ -117,20 +101,8 @@
   vp9_coeff_count *coef_counts;
   const int ref = xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME;
   TX_TYPE tx_type = DCT_DCT;
-#if CONFIG_CODE_ZEROGROUP
-  int is_eoo[3] = {0, 0, 0};
-  int is_last_zero[3] = {0, 0, 0};
-  int o, rc;
-  vp9_zpc_probs *zpc_probs;
-  vp9_zpc_count *zpc_count;
-  vp9_prob *zprobs;
-  int eoo = 0, use_eoo;
-#endif
   const int *scan, *nb;
   uint8_t token_cache[1024];
-#if CONFIG_CODE_ZEROGROUP
-  vpx_memset(token_cache, UNKNOWN_TOKEN, sizeof(token_cache));
-#endif
 
   switch (txfm_size) {
     default:
@@ -143,10 +115,6 @@
       coef_probs  = fc->coef_probs_4x4;
       coef_counts = fc->coef_counts_4x4;
       default_eob = 16;
-#if CONFIG_CODE_ZEROGROUP
-      zpc_probs = &(fc->zpc_probs_4x4);
-      zpc_count = &(fc->zpc_counts_4x4);
-#endif
       break;
     }
     case TX_8X8: {
@@ -162,10 +130,6 @@
       above_ec = (A[0] + A[1]) != 0;
       left_ec = (L[0] + L[1]) != 0;
       default_eob = 64;
-#if CONFIG_CODE_ZEROGROUP
-      zpc_probs = &(fc->zpc_probs_8x8);
-      zpc_count = &(fc->zpc_counts_8x8);
-#endif
       break;
     }
     case TX_16X16: {
@@ -181,10 +145,6 @@
       above_ec = (A[0] + A[1] + A[2] + A[3]) != 0;
       left_ec = (L[0] + L[1] + L[2] + L[3]) != 0;
       default_eob = 256;
-#if CONFIG_CODE_ZEROGROUP
-      zpc_probs = &(fc->zpc_probs_16x16);
-      zpc_count = &(fc->zpc_counts_16x16);
-#endif
       break;
     }
     case TX_32X32:
@@ -194,10 +154,6 @@
       above_ec = (A[0] + A[1] + A[2] + A[3] + A[4] + A[5] + A[6] + A[7]) != 0;
       left_ec = (L[0] + L[1] + L[2] + L[3] + L[4] + L[5] + L[6] + L[7]) != 0;
       default_eob = 1024;
-#if CONFIG_CODE_ZEROGROUP
-      zpc_probs = &fc->zpc_probs_32x32;
-      zpc_count = &fc->zpc_counts_32x32;
-#endif
       break;
   }
 
@@ -218,15 +174,6 @@
     fc->eob_branch_counts[txfm_size][type][ref][band][pt]++;
     if (!vp9_read(r, prob[EOB_CONTEXT_NODE]))
       break;
-#if CONFIG_CODE_ZEROGROUP
-    rc = scan[c];
-    o = vp9_get_orientation(rc, txfm_size);
-    if (token_cache[rc] == ZERO_TOKEN || is_eoo[o]) {
-      coef_counts[type][ref][band][pt][ZERO_TOKEN]++;
-      ZEROGROUP_ADVANCE();
-      goto SKIP_START;
-    }
-#endif
 
 SKIP_START:
     if (c >= seg_eob)
@@ -236,35 +183,7 @@
                                 c, default_eob);
     band = get_coef_band(scan, txfm_size, c);
     prob = coef_probs[type][ref][band][pt];
-#if CONFIG_CODE_ZEROGROUP
-    rc = scan[c];
-    o = vp9_get_orientation(rc, txfm_size);
-    if (token_cache[rc] == ZERO_TOKEN || is_eoo[o]) {
-      ZEROGROUP_ADVANCE();
-      goto SKIP_START;
-    }
-    zprobs = (*zpc_probs)[ref]
-             [coef_to_zpc_band(band)]
-             [coef_to_zpc_ptok(pt)];
-#endif
     if (!vp9_read(r, prob[ZERO_CONTEXT_NODE])) {
-#if CONFIG_CODE_ZEROGROUP
-      eoo = 0;
-#if USE_ZPC_EOORIENT == 1
-      use_eoo = vp9_use_eoo(c, seg_eob, scan, txfm_size, is_last_zero, is_eoo);
-#else
-      use_eoo = 0;
-#endif
-      if (use_eoo) {
-        eoo = !vp9_read(r, zprobs[0]);
-        ++(*zpc_count)[ref]
-                      [coef_to_zpc_band(band)]
-                      [coef_to_zpc_ptok(pt)][0][!eoo];
-        if (eoo) {
-          is_eoo[o] = 1;
-        }
-      }
-#endif
       INCREMENT_COUNT(ZERO_TOKEN);
       ++c;
       goto SKIP_START;
diff --git a/vp9/decoder/vp9_onyxd_if.c b/vp9/decoder/vp9_onyxd_if.c
index 9582e8f..c0ce311 100644
--- a/vp9/decoder/vp9_onyxd_if.c
+++ b/vp9/decoder/vp9_onyxd_if.c
@@ -21,8 +21,6 @@
 #include "vpx_mem/vpx_mem.h"
 #include "vp9/common/vp9_alloccommon.h"
 #include "vp9/common/vp9_loopfilter.h"
-#include "vp9/common/vp9_swapyv12buffer.h"
-
 #include "vp9/common/vp9_quant_common.h"
 #include "vpx_scale/vpx_scale.h"
 #include "vp9/common/vp9_systemdependent.h"
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c
index 4967ccf..a7c26a4 100644
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -50,18 +50,6 @@
 extern unsigned int active_section;
 #endif
 
-#if CONFIG_CODE_ZEROGROUP
-#ifdef ZPC_STATS
-vp9_zpc_count zpc_stats_4x4;
-vp9_zpc_count zpc_stats_8x8;
-vp9_zpc_count zpc_stats_16x16;
-vp9_zpc_count zpc_stats_32x32;
-void init_zpcstats();
-void update_zpcstats(VP9_COMMON *const cm);
-void print_zpcstats();
-#endif
-#endif
-
 #ifdef MODE_STATS
 int count_mb_seg[4] = { 0, 0, 0, 0 };
 #endif
@@ -400,20 +388,6 @@
       break;
     }
     assert(pp != 0);
-#if CONFIG_CODE_ZEROGROUP
-    if (t == ZPC_ISOLATED || t == ZPC_EOORIENT) {
-      assert((p - 1)->token == ZERO_TOKEN);
-      encode_bool(bc, t == ZPC_ISOLATED, *pp);
-      ++p;
-      continue;
-    } else if (p->skip_coef_val) {
-      assert(p->skip_eob_node == 0);
-      assert(t == DCT_EOB_TOKEN || t == ZERO_TOKEN);
-      encode_bool(bc, t == ZERO_TOKEN, *pp);
-      ++p;
-      continue;
-    }
-#endif
 
     /* skip one or two nodes */
     if (p->skip_eob_node) {
@@ -706,27 +680,6 @@
       vp9_write(bc, mi->second_ref_frame > INTRA_FRAME,
                 vp9_get_pred_prob(pc, xd, PRED_COMP));
     }
-#if CONFIG_COMP_INTERINTRA_PRED
-    if (cpi->common.use_interintra &&
-        mode >= NEARESTMV && mode < SPLITMV &&
-        mi->second_ref_frame <= INTRA_FRAME) {
-      vp9_write(bc, mi->second_ref_frame == INTRA_FRAME,
-                pc->fc.interintra_prob);
-      // if (!cpi->dummy_packing)
-      //   printf("-- %d (%d)\n", mi->second_ref_frame == INTRA_FRAME,
-      //          pc->fc.interintra_prob);
-      if (mi->second_ref_frame == INTRA_FRAME) {
-        // if (!cpi->dummy_packing)
-        //   printf("** %d %d\n", mi->interintra_mode,
-        // mi->interintra_uv_mode);
-        write_ymode(bc, mi->interintra_mode, pc->fc.ymode_prob);
-#if SEPARATE_INTERINTRA_UV
-        write_uv_mode(bc, mi->interintra_uv_mode,
-                      pc->fc.uv_mode_prob[mi->interintra_mode]);
-#endif
-      }
-    }
-#endif
 
     switch (mode) { /* new, split require MVs */
       case NEWMV:
@@ -863,151 +816,6 @@
   }
 }
 
-
-#if CONFIG_CODE_ZEROGROUP
-#ifdef ZPC_STATS
-void init_zpcstats() {
-  vp9_zero(zpc_stats_4x4);
-  vp9_zero(zpc_stats_8x8);
-  vp9_zero(zpc_stats_16x16);
-  vp9_zero(zpc_stats_32x32);
-}
-
-void update_zpcstats(VP9_COMMON *const cm) {
-  int r, b, p, n;
-  for (r = 0; r < REF_TYPES; ++r) {
-    for (b = 0; b < ZPC_BANDS; ++b) {
-      for (p = 0; p < ZPC_PTOKS; ++p) {
-        for (n = 0; n < ZPC_NODES; ++n) {
-          zpc_stats_4x4[r][b][p][n][0] += cm->fc.zpc_counts_4x4[r][b][p][n][0];
-          zpc_stats_4x4[r][b][p][n][1] += cm->fc.zpc_counts_4x4[r][b][p][n][1];
-          zpc_stats_8x8[r][b][p][n][0] += cm->fc.zpc_counts_8x8[r][b][p][n][0];
-          zpc_stats_8x8[r][b][p][n][1] += cm->fc.zpc_counts_8x8[r][b][p][n][1];
-          zpc_stats_16x16[r][b][p][n][0] +=
-              cm->fc.zpc_counts_16x16[r][b][p][n][0];
-          zpc_stats_16x16[r][b][p][n][1] +=
-              cm->fc.zpc_counts_16x16[r][b][p][n][1];
-          zpc_stats_32x32[r][b][p][n][0] +=
-              cm->fc.zpc_counts_32x32[r][b][p][n][0];
-          zpc_stats_32x32[r][b][p][n][1] +=
-              cm->fc.zpc_counts_32x32[r][b][p][n][1];
-        }
-      }
-    }
-  }
-}
-
-void print_zpcstats() {
-  int r, b, p, n;
-  FILE *f;
-
-  printf(
-      "static const unsigned int default_zpc_probs_4x4[REF_TYPES]\n"
-      "                                               [ZPC_BANDS]\n"
-      "                                               [ZPC_PTOKS]\n"
-      "                                               [ZPC_NODES] = {\n");
-  for (r = 0; r < REF_TYPES; ++r) {
-    printf("  {\n");
-    for (b = 0; b < ZPC_BANDS; ++b) {
-      printf("    {\n");
-      for (p = 0; p < ZPC_PTOKS; ++p) {
-        printf("      {");
-        for (n = 0; n < ZPC_NODES; ++n) {
-          vp9_prob prob = get_binary_prob(zpc_stats_4x4[r][b][p][n][0],
-                                          zpc_stats_4x4[r][b][p][n][1]);
-          printf(" %-3d [%d/%d],", prob, zpc_stats_4x4[r][b][p][n][0],
-                                         zpc_stats_4x4[r][b][p][n][1]);
-        }
-        printf(" },\n");
-      }
-      printf("    },\n");
-    }
-    printf("  },\n");
-  }
-  printf("};\n");
-  printf(
-    "static const unsigned int default_zpc_probs_8x8[REF_TYPES]\n"
-    "                                               [ZPC_BANDS]\n"
-    "                                               [ZPC_PTOKS]\n"
-    "                                               [ZPC_NODES] = {\n");
-  for (r = 0; r < REF_TYPES; ++r) {
-    printf("  {\n");
-    for (b = 0; b < ZPC_BANDS; ++b) {
-      printf("    {\n");
-      for (p = 0; p < ZPC_PTOKS; ++p) {
-        printf("      {");
-        for (n = 0; n < ZPC_NODES; ++n) {
-          vp9_prob prob = get_binary_prob(zpc_stats_8x8[r][b][p][n][0],
-                                          zpc_stats_8x8[r][b][p][n][1]);
-          printf(" %-3d [%d/%d],", prob, zpc_stats_8x8[r][b][p][n][0],
-                                         zpc_stats_8x8[r][b][p][n][1]);
-        }
-        printf(" },\n");
-      }
-      printf("    },\n");
-    }
-    printf("  },\n");
-  }
-  printf("};\n");
-  printf(
-    "static const unsigned int default_zpc_probs_16x16[REF_TYPES]\n"
-    "                                                 [ZPC_BANDS]\n"
-    "                                                 [ZPC_PTOKS]\n"
-    "                                                 [ZPC_NODES] = {\n");
-  for (r = 0; r < REF_TYPES; ++r) {
-    printf("  {\n");
-    for (b = 0; b < ZPC_BANDS; ++b) {
-      printf("    {\n");
-      for (p = 0; p < ZPC_PTOKS; ++p) {
-        printf("      {");
-        for (n = 0; n < ZPC_NODES; ++n) {
-          vp9_prob prob = get_binary_prob(zpc_stats_16x16[r][b][p][n][0],
-                                          zpc_stats_16x16[r][b][p][n][1]);
-          printf(" %-3d [%d/%d],", prob, zpc_stats_16x16[r][b][p][n][0],
-                                         zpc_stats_16x16[r][b][p][n][1]);
-        }
-        printf(" },\n");
-      }
-      printf("    },\n");
-    }
-    printf("  },\n");
-  }
-  printf("};\n");
-  printf(
-    "static const unsigned int default_zpc_probs_32x32[REF_TYPES]\n"
-    "                                                 [ZPC_BANDS]\n"
-    "                                                 [ZPC_PTOKS]\n"
-    "                                                 [ZPC_NODES] = {\n");
-  for (r = 0; r < REF_TYPES; ++r) {
-    printf("  {\n");
-    for (b = 0; b < ZPC_BANDS; ++b) {
-      printf("    {\n");
-      for (p = 0; p < ZPC_PTOKS; ++p) {
-        printf("      {");
-        for (n = 0; n < ZPC_NODES; ++n) {
-          vp9_prob prob = get_binary_prob(zpc_stats_32x32[r][b][p][n][0],
-                                          zpc_stats_32x32[r][b][p][n][1]);
-          printf(" %-3d [%d/%d],", prob, zpc_stats_32x32[r][b][p][n][0],
-                                         zpc_stats_32x32[r][b][p][n][1]);
-        }
-        printf(" },\n");
-      }
-      printf("    },\n");
-    }
-    printf("  },\n");
-  }
-  printf("};\n");
-
-  f = fopen("zpcstats.bin", "wb");
-  fwrite(zpc_stats_4x4, sizeof(zpc_stats_4x4), 1, f);
-  fwrite(zpc_stats_8x8, sizeof(zpc_stats_8x8), 1, f);
-  fwrite(zpc_stats_16x16, sizeof(zpc_stats_16x16), 1, f);
-  fwrite(zpc_stats_32x32, sizeof(zpc_stats_32x32), 1, f);
-  fclose(f);
-}
-#endif
-#endif  // CONFIG_CODE_ZEROGROUP
-
 static void write_modes_b(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
                           TOKENEXTRA **tok, TOKENEXTRA *tok_end,
                           int mi_row, int mi_col) {
@@ -1244,129 +1052,6 @@
                           cpi->frame_branch_ct_32x32, BLOCK_TYPES);
 }
 
-#if CONFIG_CODE_ZEROGROUP
-static void update_zpc_probs_common(VP9_COMP* cpi,
-                                    vp9_writer* const bc,
-                                    TX_SIZE tx_size) {
-  int r, b, p, n;
-  VP9_COMMON *const cm = &cpi->common;
-  int update[2] = {0, 0};
-  int savings = 0;
-  vp9_zpc_probs newprobs;
-  vp9_zpc_probs *zpc_probs;
-  vp9_zpc_count *zpc_counts;
-  vp9_prob upd = ZPC_UPDATE_PROB;
-
-  if (!get_zpc_used(tx_size)) return;
-  if (tx_size == TX_32X32) {
-    zpc_probs = &cm->fc.zpc_probs_32x32;
-    zpc_counts = &cm->fc.zpc_counts_32x32;
-  } else if (tx_size == TX_16X16) {
-    zpc_probs = &cm->fc.zpc_probs_16x16;
-    zpc_counts = &cm->fc.zpc_counts_16x16;
-  } else if (tx_size == TX_8X8) {
-    zpc_probs = &cm->fc.zpc_probs_8x8;
-    zpc_counts = &cm->fc.zpc_counts_8x8;
-  } else {
-    zpc_probs = &cm->fc.zpc_probs_4x4;
-    zpc_counts = &cm->fc.zpc_counts_4x4;
-  }
-  for (r = 0; r < REF_TYPES; ++r) {
-    for (b = 0; b < ZPC_BANDS; ++b) {
-      for (p = 0; p < ZPC_PTOKS; ++p) {
-        for (n = 0; n < ZPC_NODES; ++n) {
-          newprobs[r][b][p][n] = get_binary_prob((*zpc_counts)[r][b][p][n][0],
-                                                 (*zpc_counts)[r][b][p][n][1]);
-        }
-      }
-    }
-  }
-  for (r = 0; r < REF_TYPES; ++r) {
-    for (b = 0; b < ZPC_BANDS; ++b) {
-      for (p = 0; p < ZPC_PTOKS; ++p) {
-        for (n = 0; n < ZPC_NODES; ++n) {
-          vp9_prob newp = newprobs[r][b][p][n];
-          vp9_prob oldp = (*zpc_probs)[r][b][p][n];
-          int s, u = 0;
-#if USE_ZPC_EXTRA == 0
-          if (n == 1) continue;
-#endif
-#if defined(SEARCH_NEWP)
-          s = prob_diff_update_savings_search((*zpc_counts)[r][b][p][n],
-                                              oldp, &newp, upd);
-          if (s > 0 && newp != oldp)
-            u = 1;
-          if (u)
-            savings += s - (int)(vp9_cost_zero(upd));
-          else
-            savings -= (int)(vp9_cost_zero(upd));
-#else
-          s = prob_update_savings((*zpc_counts)[r][b][p][n],
-                                  oldp, newp, upd);
-          if (s > 0)
-            u = 1;
-          if (u)
-            savings += s;
-#endif
-          update[u]++;
-        }
-      }
-    }
-  }
-  if (update[1] == 0 || savings < 0) {
-    vp9_write_bit(bc, 0);
-    return;
-  }
-  vp9_write_bit(bc, 1);
-  for (r = 0; r < REF_TYPES; ++r) {
-    for (b = 0; b < ZPC_BANDS; ++b) {
-      for (p = 0; p < ZPC_PTOKS; ++p) {
-        for (n = 0; n < ZPC_NODES; ++n) {
-          vp9_prob newp = newprobs[r][b][p][n];
-          vp9_prob *oldp = &(*zpc_probs)[r][b][p][n];
-          int s, u = 0;
-#if USE_ZPC_EXTRA == 0
-          if (n == 1) continue;
-#endif
-#if defined(SEARCH_NEWP)
-          s = prob_diff_update_savings_search((*zpc_counts)[r][b][p][n],
-                                              *oldp, &newp, upd);
-          if (s > 0 && newp != *oldp)
-            u = 1;
-#else
-          s = prob_update_savings((*zpc_counts)[r][b][p][n],
-                                  *oldp, newp, upd);
-          if (s > 0)
-            u = 1;
-#endif
-          vp9_write(bc, u, upd);
-          if (u) {
-            /* send/use new probability */
-            write_prob_diff_update(bc, newp, *oldp);
-            *oldp = newp;
-          }
-        }
-      }
-    }
-  }
-}
-
-static void update_zpc_probs(VP9_COMP* cpi,
-                             vp9_writer* const bc) {
-  update_zpc_probs_common(cpi, bc, TX_4X4);
-  if (cpi->common.txfm_mode != ONLY_4X4)
-    update_zpc_probs_common(cpi, bc, TX_8X8);
-  if (cpi->common.txfm_mode > ALLOW_8X8)
-    update_zpc_probs_common(cpi, bc, TX_16X16);
-  if (cpi->common.txfm_mode > ALLOW_16X16)
-    update_zpc_probs_common(cpi, bc, TX_32X32);
-#ifdef ZPC_STATS
-  if (!cpi->dummy_packing)
-    update_zpcstats(&cpi->common);
-#endif
-}
-#endif  // CONFIG_CODE_ZEROGROUP
-
 static void update_coef_probs_common(vp9_writer* const bc,
                                      VP9_COMP *cpi,
 #ifdef ENTROPY_STATS
@@ -1908,15 +1593,6 @@
     vp9_write_bit(&header_bc, (pc->mcomp_filter_type == SWITCHABLE));
     if (pc->mcomp_filter_type != SWITCHABLE)
       vp9_write_literal(&header_bc, (pc->mcomp_filter_type), 2);
-#if CONFIG_COMP_INTERINTRA_PRED
-    //  printf("Counts: %d %d\n", cpi->interintra_count[0],
-    //         cpi->interintra_count[1]);
-    if (!cpi->dummy_packing && pc->use_interintra)
-      pc->use_interintra = (cpi->interintra_count[1] > 0);
-    vp9_write_bit(&header_bc, pc->use_interintra);
-    if (!pc->use_interintra)
-      vp9_zero(cpi->interintra_count);
-#endif
   }
 
   if (!pc->error_resilient_mode) {
@@ -2032,16 +1708,7 @@
            cpi->common.fc.coef_probs_16x16);
   vp9_copy(cpi->common.fc.pre_coef_probs_32x32,
            cpi->common.fc.coef_probs_32x32);
-#if CONFIG_CODE_ZEROGROUP
-  vp9_copy(cpi->common.fc.pre_zpc_probs_4x4,
-           cpi->common.fc.zpc_probs_4x4);
-  vp9_copy(cpi->common.fc.pre_zpc_probs_8x8,
-           cpi->common.fc.zpc_probs_8x8);
-  vp9_copy(cpi->common.fc.pre_zpc_probs_16x16,
-           cpi->common.fc.zpc_probs_16x16);
-  vp9_copy(cpi->common.fc.pre_zpc_probs_32x32,
-           cpi->common.fc.zpc_probs_32x32);
-#endif
+
   vp9_copy(cpi->common.fc.pre_sb_ymode_prob, cpi->common.fc.sb_ymode_prob);
   vp9_copy(cpi->common.fc.pre_ymode_prob, cpi->common.fc.ymode_prob);
   vp9_copy(cpi->common.fc.pre_uv_mode_prob, cpi->common.fc.uv_mode_prob);
@@ -2049,16 +1716,10 @@
   vp9_copy(cpi->common.fc.pre_sub_mv_ref_prob, cpi->common.fc.sub_mv_ref_prob);
   vp9_copy(cpi->common.fc.pre_partition_prob, cpi->common.fc.partition_prob);
   cpi->common.fc.pre_nmvc = cpi->common.fc.nmvc;
-#if CONFIG_COMP_INTERINTRA_PRED
-  cpi->common.fc.pre_interintra_prob = cpi->common.fc.interintra_prob;
-#endif
   vp9_zero(cpi->sub_mv_ref_count);
   vp9_zero(cpi->common.fc.mv_ref_ct);
 
   update_coef_probs(cpi, &header_bc);
-#if CONFIG_CODE_ZEROGROUP
-  update_zpc_probs(cpi, &header_bc);
-#endif
 
 #ifdef ENTROPY_STATS
   active_section = 2;
@@ -2084,15 +1745,6 @@
     if (pc->mcomp_filter_type == SWITCHABLE)
       update_switchable_interp_probs(cpi, &header_bc);
 
-#if CONFIG_COMP_INTERINTRA_PRED
-    if (pc->use_interintra) {
-      vp9_cond_prob_update(&header_bc,
-                           &pc->fc.interintra_prob,
-                           VP9_UPD_INTERINTRA_PROB,
-                           cpi->interintra_count);
-    }
-#endif
-
     vp9_write_prob(&header_bc, pc->prob_intra_coded);
     vp9_write_prob(&header_bc, pc->prob_last_coded);
     vp9_write_prob(&header_bc, pc->prob_gf_coded);
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index aa9f33a..8ddad26 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -487,20 +487,7 @@
         for (i = 0; i < bw; ++i)
           xd->mode_info_context[mis * j + i].mbmi = *mbmi;
     }
-#if CONFIG_COMP_INTERINTRA_PRED
-    if (mbmi->mode >= NEARESTMV && mbmi->mode < SPLITMV &&
-        mbmi->second_ref_frame <= INTRA_FRAME) {
-      if (mbmi->second_ref_frame == INTRA_FRAME) {
-        ++cpi->interintra_count[1];
-        ++cpi->ymode_count[mbmi->interintra_mode];
-#if SEPARATE_INTERINTRA_UV
-        ++cpi->y_uv_mode_count[mbmi->interintra_mode][mbmi->interintra_uv_mode];
-#endif
-      } else {
-        ++cpi->interintra_count[0];
-      }
-    }
-#endif
+
     if (cpi->common.mcomp_filter_type == SWITCHABLE &&
         is_inter_mode(mbmi->mode)) {
       ++cpi->switchable_interp_count
@@ -1439,11 +1426,6 @@
   vp9_zero(cpi->sb_ymode_count)
   vp9_zero(cpi->partition_count);
 
-#if CONFIG_COMP_INTERINTRA_PRED
-  vp9_zero(cpi->interintra_count);
-  vp9_zero(cpi->interintra_select_count);
-#endif
-
   // Note: this memset assumes above_context[0], [1] and [2]
   // are allocated as part of the same buffer.
   vpx_memset(cm->above_context[0], 0, sizeof(ENTROPY_CONTEXT) * 4 *
@@ -1517,12 +1499,6 @@
   vp9_zero(cpi->coef_counts_16x16);
   vp9_zero(cpi->coef_counts_32x32);
   vp9_zero(cm->fc.eob_branch_counts);
-#if CONFIG_CODE_ZEROGROUP
-  vp9_zero(cm->fc.zpc_counts_4x4);
-  vp9_zero(cm->fc.zpc_counts_8x8);
-  vp9_zero(cm->fc.zpc_counts_16x16);
-  vp9_zero(cm->fc.zpc_counts_32x32);
-#endif
 
   cpi->mb.e_mbd.lossless = (cm->base_qindex == 0 &&
                             cm->y_dc_delta_q == 0 &&
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index a1898af..1e25a00 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -22,7 +22,7 @@
 #include "vp9/common/vp9_extend.h"
 #include "vp9/common/vp9_systemdependent.h"
 #include "vpx_mem/vpx_mem.h"
-#include "vp9/common/vp9_swapyv12buffer.h"
+#include "vpx_scale/yv12config.h"
 #include <stdio.h>
 #include "vp9/encoder/vp9_quantize.h"
 #include "vp9/encoder/vp9_rdopt.h"
@@ -52,6 +52,12 @@
 #define POW1 (double)cpi->oxcf.two_pass_vbrbias/100.0
 #define POW2 (double)cpi->oxcf.two_pass_vbrbias/100.0
 
+static void swap_yv12(YV12_BUFFER_CONFIG *a, YV12_BUFFER_CONFIG *b) {
+  YV12_BUFFER_CONFIG temp = *a;
+  *a = *b;
+  *b = temp;
+}
+
 static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame);
 
 static int select_cq_level(int qindex) {
@@ -444,13 +450,13 @@
   MACROBLOCKD *const xd = &x->e_mbd;
 
   int recon_yoffset, recon_uvoffset;
-  YV12_BUFFER_CONFIG *lst_yv12 =
-      &cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]];
-  YV12_BUFFER_CONFIG *new_yv12 = &cm->yv12_fb[cm->new_fb_idx];
-  YV12_BUFFER_CONFIG *gld_yv12 =
-      &cm->yv12_fb[cm->ref_frame_map[cpi->gld_fb_idx]];
-  int recon_y_stride = lst_yv12->y_stride;
-  int recon_uv_stride = lst_yv12->uv_stride;
+  const int lst_yv12_idx = cm->ref_frame_map[cpi->lst_fb_idx];
+  const int gld_yv12_idx = cm->ref_frame_map[cpi->gld_fb_idx];
+  YV12_BUFFER_CONFIG *const lst_yv12 = &cm->yv12_fb[lst_yv12_idx];
+  YV12_BUFFER_CONFIG *const new_yv12 = &cm->yv12_fb[cm->new_fb_idx];
+  YV12_BUFFER_CONFIG *const gld_yv12 = &cm->yv12_fb[gld_yv12_idx];
+  const int recon_y_stride = lst_yv12->y_stride;
+  const int recon_uv_stride = lst_yv12->uv_stride;
   int64_t intra_error = 0;
   int64_t coded_error = 0;
   int64_t sr_coded_error = 0;
@@ -772,14 +778,13 @@
     cpi->twopass.sr_update_lag++;
 
   // swap frame pointers so last frame refers to the frame we just compressed
-  vp9_swap_yv12_buffer(lst_yv12, new_yv12);
+  swap_yv12(lst_yv12, new_yv12);
+
   vp8_yv12_extend_frame_borders(lst_yv12);
 
   // Special case for the first frame. Copy into the GF buffer as a second reference.
-  if (cm->current_video_frame == 0) {
+  if (cm->current_video_frame == 0)
     vp8_yv12_copy_frame(lst_yv12, gld_yv12);
-  }
-
 
   // use this to see what the first pass reconstruction looks like
   if (0) {
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index 09a0fab..5fdbbef 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -32,7 +32,6 @@
 #include "vp9/common/vp9_postproc.h"
 #endif
 #include "vpx_mem/vpx_mem.h"
-#include "vp9/common/vp9_swapyv12buffer.h"
 #include "vpx_ports/vpx_timer.h"
 
 #include "vp9/common/vp9_seg_common.h"
@@ -114,13 +113,6 @@
 extern void print_nmvstats();
 #endif
 
-#if CONFIG_CODE_ZEROGROUP
-#ifdef ZPC_STATS
-extern void init_zpcstats();
-extern void print_zpcstats();
-#endif
-#endif
-
 #ifdef SPEEDSTATS
 unsigned int frames_at_speed[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 #endif
@@ -651,24 +643,6 @@
   sf->thresh_mult[THR_COMP_SPLITGA  ] += speed_multiplier * 4500;
   sf->thresh_mult[THR_COMP_SPLITLG  ] += speed_multiplier * 4500;
 
-#if CONFIG_COMP_INTERINTRA_PRED
-  sf->thresh_mult[THR_COMP_INTERINTRA_ZEROL   ] += speed_multiplier * 1500;
-  sf->thresh_mult[THR_COMP_INTERINTRA_ZEROG   ] += speed_multiplier * 1500;
-  sf->thresh_mult[THR_COMP_INTERINTRA_ZEROA   ] += speed_multiplier * 1500;
-
-  sf->thresh_mult[THR_COMP_INTERINTRA_NEARESTL] += speed_multiplier * 1500;
-  sf->thresh_mult[THR_COMP_INTERINTRA_NEARESTG] += speed_multiplier * 1500;
-  sf->thresh_mult[THR_COMP_INTERINTRA_NEARESTA] += speed_multiplier * 1500;
-
-  sf->thresh_mult[THR_COMP_INTERINTRA_NEARL   ] += speed_multiplier * 1500;
-  sf->thresh_mult[THR_COMP_INTERINTRA_NEARG   ] += speed_multiplier * 1500;
-  sf->thresh_mult[THR_COMP_INTERINTRA_NEARA   ] += speed_multiplier * 1500;
-
-  sf->thresh_mult[THR_COMP_INTERINTRA_NEWL    ] += speed_multiplier * 2000;
-  sf->thresh_mult[THR_COMP_INTERINTRA_NEWG    ] += speed_multiplier * 2000;
-  sf->thresh_mult[THR_COMP_INTERINTRA_NEWA    ] += speed_multiplier * 2000;
-#endif
-
   /* disable frame modes if flags not set */
   if (!(cpi->ref_frame_flags & VP9_LAST_FLAG)) {
     sf->thresh_mult[THR_NEWMV    ] = INT_MAX;
@@ -676,12 +650,6 @@
     sf->thresh_mult[THR_ZEROMV   ] = INT_MAX;
     sf->thresh_mult[THR_NEARMV   ] = INT_MAX;
     sf->thresh_mult[THR_SPLITMV  ] = INT_MAX;
-#if CONFIG_COMP_INTERINTRA_PRED
-    sf->thresh_mult[THR_COMP_INTERINTRA_ZEROL   ] = INT_MAX;
-    sf->thresh_mult[THR_COMP_INTERINTRA_NEARESTL] = INT_MAX;
-    sf->thresh_mult[THR_COMP_INTERINTRA_NEARL   ] = INT_MAX;
-    sf->thresh_mult[THR_COMP_INTERINTRA_NEWL    ] = INT_MAX;
-#endif
   }
   if (!(cpi->ref_frame_flags & VP9_GOLD_FLAG)) {
     sf->thresh_mult[THR_NEARESTG ] = INT_MAX;
@@ -689,12 +657,6 @@
     sf->thresh_mult[THR_NEARG    ] = INT_MAX;
     sf->thresh_mult[THR_NEWG     ] = INT_MAX;
     sf->thresh_mult[THR_SPLITG   ] = INT_MAX;
-#if CONFIG_COMP_INTERINTRA_PRED
-    sf->thresh_mult[THR_COMP_INTERINTRA_ZEROG   ] = INT_MAX;
-    sf->thresh_mult[THR_COMP_INTERINTRA_NEARESTG] = INT_MAX;
-    sf->thresh_mult[THR_COMP_INTERINTRA_NEARG   ] = INT_MAX;
-    sf->thresh_mult[THR_COMP_INTERINTRA_NEWG    ] = INT_MAX;
-#endif
   }
   if (!(cpi->ref_frame_flags & VP9_ALT_FLAG)) {
     sf->thresh_mult[THR_NEARESTA ] = INT_MAX;
@@ -702,12 +664,6 @@
     sf->thresh_mult[THR_NEARA    ] = INT_MAX;
     sf->thresh_mult[THR_NEWA     ] = INT_MAX;
     sf->thresh_mult[THR_SPLITA   ] = INT_MAX;
-#if CONFIG_COMP_INTERINTRA_PRED
-    sf->thresh_mult[THR_COMP_INTERINTRA_ZEROA   ] = INT_MAX;
-    sf->thresh_mult[THR_COMP_INTERINTRA_NEARESTA] = INT_MAX;
-    sf->thresh_mult[THR_COMP_INTERINTRA_NEARA   ] = INT_MAX;
-    sf->thresh_mult[THR_COMP_INTERINTRA_NEWA    ] = INT_MAX;
-#endif
   }
 
   if ((cpi->ref_frame_flags & (VP9_LAST_FLAG | VP9_GOLD_FLAG)) !=
@@ -1434,11 +1390,6 @@
 #ifdef NMV_STATS
   init_nmvstats();
 #endif
-#if CONFIG_CODE_ZEROGROUP
-#ifdef ZPC_STATS
-  init_zpcstats();
-#endif
-#endif
 
   /*Initialize the feed-forward activity masking.*/
   cpi->activity_avg = 90 << 12;
@@ -1648,12 +1599,6 @@
   cpi->common.error.setjmp = 0;
 
   vp9_zero(cpi->y_uv_mode_count)
-#if CONFIG_CODE_ZEROGROUP
-  vp9_zero(cm->fc.zpc_counts_4x4);
-  vp9_zero(cm->fc.zpc_counts_8x8);
-  vp9_zero(cm->fc.zpc_counts_16x16);
-  vp9_zero(cm->fc.zpc_counts_32x32);
-#endif
 
   return (VP9_PTR) cpi;
 }
@@ -1681,12 +1626,6 @@
     if (cpi->pass != 1)
       print_nmvstats();
 #endif
-#if CONFIG_CODE_ZEROGROUP
-#ifdef ZPC_STATS
-    if (cpi->pass != 1)
-      print_zpcstats();
-#endif
-#endif
 
 #if CONFIG_INTERNAL_STATS
 
@@ -2542,20 +2481,6 @@
   }
 }
 
-#if CONFIG_COMP_INTERINTRA_PRED
-static void select_interintra_mode(VP9_COMP *cpi) {
-  static const double threshold = 0.01;
-  VP9_COMMON *cm = &cpi->common;
-  // FIXME(debargha): Make this RD based
-  int sum = cpi->interintra_select_count[1] + cpi->interintra_select_count[0];
-  if (sum) {
-    double fraction = (double) cpi->interintra_select_count[1] / sum;
-    // printf("fraction: %f\n", fraction);
-    cm->use_interintra = (fraction > threshold);
-  }
-}
-#endif
-
 static void scale_references(VP9_COMP *cpi) {
   VP9_COMMON *cm = &cpi->common;
   int i;
@@ -2912,12 +2837,6 @@
     set_mvcost(&cpi->mb);
   }
 
-#if CONFIG_COMP_INTERINTRA_PRED
-  if (cm->current_video_frame == 0) {
-    cm->use_interintra = 1;
-  }
-#endif
-
 #if CONFIG_POSTPROC
 
   if (cpi->oxcf.noise_sensitivity > 0) {
@@ -3291,9 +3210,6 @@
   if (!cpi->common.error_resilient_mode &&
       !cpi->common.frame_parallel_decoding_mode) {
     vp9_adapt_coef_probs(&cpi->common);
-#if CONFIG_CODE_ZEROGROUP
-    vp9_adapt_zpc_probs(&cpi->common);
-#endif
   }
 
   if (cpi->common.frame_type != KEY_FRAME) {
@@ -3303,9 +3219,6 @@
     vp9_copy(cpi->common.fc.bmode_counts, cpi->bmode_count);
     vp9_copy(cpi->common.fc.sub_mv_ref_counts, cpi->sub_mv_ref_count);
     vp9_copy(cpi->common.fc.partition_counts, cpi->partition_count);
-#if CONFIG_COMP_INTERINTRA_PRED
-    vp9_copy(cpi->common.fc.interintra_counts, cpi->interintra_count);
-#endif
     cpi->common.fc.NMVcount = cpi->NMVcount;
     if (!cpi->common.error_resilient_mode &&
         !cpi->common.frame_parallel_decoding_mode) {
@@ -3314,10 +3227,6 @@
       vp9_adapt_nmv_probs(&cpi->common, cpi->mb.e_mbd.allow_high_precision_mv);
     }
   }
-#if CONFIG_COMP_INTERINTRA_PRED
-  if (cm->frame_type != KEY_FRAME)
-    select_interintra_mode(cpi);
-#endif
 
   /* Move storing frame_type out of the above loop since it is also
    * needed in motion search besides loopfilter */
diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h
index cc91ba5..7b56f9c 100644
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -47,11 +47,7 @@
 
 #define KEY_FRAME_CONTEXT 5
 
-#if CONFIG_COMP_INTERINTRA_PRED
-#define MAX_MODES 53
-#else
 #define MAX_MODES 41
-#endif
 
 #define MIN_THRESHMULT  32
 #define MAX_THRESHMULT  512
@@ -104,19 +100,10 @@
 
   vp9_prob switchable_interp_prob[VP9_SWITCHABLE_FILTERS + 1]
                                  [VP9_SWITCHABLE_FILTERS - 1];
-#if CONFIG_COMP_INTERINTRA_PRED
-  vp9_prob interintra_prob;
-#endif
 
   int mv_ref_ct[INTER_MODE_CONTEXTS][4][2];
   int vp9_mode_contexts[INTER_MODE_CONTEXTS][4];
 
-#if CONFIG_CODE_ZEROGROUP
-  vp9_zpc_probs zpc_probs_4x4;
-  vp9_zpc_probs zpc_probs_8x8;
-  vp9_zpc_probs zpc_probs_16x16;
-  vp9_zpc_probs zpc_probs_32x32;
-#endif
 } CODING_CONTEXT;
 
 typedef struct {
@@ -224,22 +211,6 @@
   THR_COMP_SPLITLG,
   THR_COMP_SPLITLA,
   THR_COMP_SPLITGA,
-#if CONFIG_COMP_INTERINTRA_PRED
-  THR_COMP_INTERINTRA_ZEROL,
-  THR_COMP_INTERINTRA_NEARESTL,
-  THR_COMP_INTERINTRA_NEARL,
-  THR_COMP_INTERINTRA_NEWL,
-
-  THR_COMP_INTERINTRA_ZEROG,
-  THR_COMP_INTERINTRA_NEARESTG,
-  THR_COMP_INTERINTRA_NEARG,
-  THR_COMP_INTERINTRA_NEWG,
-
-  THR_COMP_INTERINTRA_ZEROA,
-  THR_COMP_INTERINTRA_NEARESTA,
-  THR_COMP_INTERINTRA_NEARA,
-  THR_COMP_INTERINTRA_NEWA,
-#endif
 }
 THR_MODES;
 
@@ -452,10 +423,6 @@
   int sub_mv_ref_count[SUBMVREF_COUNT][VP9_SUBMVREFS];
   int y_uv_mode_count[VP9_YMODES][VP9_UV_MODES];
   unsigned int partition_count[NUM_PARTITION_CONTEXTS][PARTITION_TYPES];
-#if CONFIG_COMP_INTERINTRA_PRED
-  unsigned int interintra_count[2];
-  unsigned int interintra_select_count[2];
-#endif
 
   nmv_context_counts NMVcount;
 
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index 0f84b1a..10a3b2e 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -167,15 +167,6 @@
   vp9_copy(cc->coef_probs_16x16, cm->fc.coef_probs_16x16);
   vp9_copy(cc->coef_probs_32x32, cm->fc.coef_probs_32x32);
   vp9_copy(cc->switchable_interp_prob, cm->fc.switchable_interp_prob);
-#if CONFIG_COMP_INTERINTRA_PRED
-  cc->interintra_prob = cm->fc.interintra_prob;
-#endif
-#if CONFIG_CODE_ZEROGROUP
-  vp9_copy(cc->zpc_probs_4x4, cm->fc.zpc_probs_4x4);
-  vp9_copy(cc->zpc_probs_8x8, cm->fc.zpc_probs_8x8);
-  vp9_copy(cc->zpc_probs_16x16, cm->fc.zpc_probs_16x16);
-  vp9_copy(cc->zpc_probs_32x32, cm->fc.zpc_probs_32x32);
-#endif
 }
 
 void vp9_restore_coding_context(VP9_COMP *cpi) {
@@ -227,15 +218,6 @@
   vp9_copy(cm->fc.coef_probs_16x16, cc->coef_probs_16x16);
   vp9_copy(cm->fc.coef_probs_32x32, cc->coef_probs_32x32);
   vp9_copy(cm->fc.switchable_interp_prob, cc->switchable_interp_prob);
-#if CONFIG_COMP_INTERINTRA_PRED
-  cm->fc.interintra_prob = cc->interintra_prob;
-#endif
-#if CONFIG_CODE_ZEROGROUP
-  vp9_copy(cm->fc.zpc_probs_4x4, cc->zpc_probs_4x4);
-  vp9_copy(cm->fc.zpc_probs_8x8, cc->zpc_probs_8x8);
-  vp9_copy(cm->fc.zpc_probs_16x16, cc->zpc_probs_16x16);
-  vp9_copy(cm->fc.zpc_probs_32x32, cc->zpc_probs_32x32);
-#endif
 }
 
 void vp9_setup_key_frame(VP9_COMP *cpi) {
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 4e51f54..cccd488 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -103,24 +103,6 @@
   {SPLITMV,   LAST_FRAME,   GOLDEN_FRAME},
   {SPLITMV,   ALTREF_FRAME, LAST_FRAME  },
   {SPLITMV,   GOLDEN_FRAME, ALTREF_FRAME},
-
-#if CONFIG_COMP_INTERINTRA_PRED
-  /* compound inter-intra prediction */
-  {ZEROMV,    LAST_FRAME,   INTRA_FRAME},
-  {NEARESTMV, LAST_FRAME,   INTRA_FRAME},
-  {NEARMV,    LAST_FRAME,   INTRA_FRAME},
-  {NEWMV,     LAST_FRAME,   INTRA_FRAME},
-
-  {ZEROMV,    GOLDEN_FRAME,   INTRA_FRAME},
-  {NEARESTMV, GOLDEN_FRAME,   INTRA_FRAME},
-  {NEARMV,    GOLDEN_FRAME,   INTRA_FRAME},
-  {NEWMV,     GOLDEN_FRAME,   INTRA_FRAME},
-
-  {ZEROMV,    ALTREF_FRAME,   INTRA_FRAME},
-  {NEARESTMV, ALTREF_FRAME,   INTRA_FRAME},
-  {NEARMV,    ALTREF_FRAME,   INTRA_FRAME},
-  {NEWMV,     ALTREF_FRAME,   INTRA_FRAME},
-#endif
 };
 
 static void fill_token_costs(vp9_coeff_count *c,
@@ -285,25 +267,12 @@
   ENTROPY_CONTEXT above_ec, left_ec;
   TX_TYPE tx_type = DCT_DCT;
 
-#if CONFIG_CODE_ZEROGROUP
-  int last_nz_pos[3] = {-1, -1, -1};  // Encoder only
-  int is_eoo_list[3] = {0, 0, 0};
-  int is_eoo_negative[3] = {0, 0, 0};
-  int is_last_zero[3] = {0, 0, 0};
-  int o, rc, skip_coef_val;
-  vp9_zpc_probs *zpc_probs;
-  uint8_t token_cache_full[1024];
-#endif
   const int segment_id = xd->mode_info_context->mbmi.segment_id;
   vp9_prob (*coef_probs)[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS]
                         [ENTROPY_NODES];
   int seg_eob, default_eob;
   uint8_t token_cache[1024];
 
-#if CONFIG_CODE_ZEROGROUP
-  vpx_memset(token_cache, UNKNOWN_TOKEN, sizeof(token_cache));
-#endif
-
   // Check for consistency of tx_size with mode info
   assert((!type && !plane) || (type && plane));
   if (type == PLANE_TYPE_Y_WITH_DC) {
@@ -322,9 +291,6 @@
       coef_probs = cm->fc.coef_probs_4x4;
       seg_eob = 16;
       scan = get_scan_4x4(tx_type);
-#if CONFIG_CODE_ZEROGROUP
-      zpc_probs = &cm->fc.zpc_probs_4x4;
-#endif
       break;
     }
     case TX_8X8: {
@@ -338,9 +304,6 @@
       scan = get_scan_8x8(tx_type);
       coef_probs = cm->fc.coef_probs_8x8;
       seg_eob = 64;
-#if CONFIG_CODE_ZEROGROUP
-      zpc_probs = &cm->fc.zpc_probs_8x8;
-#endif
       break;
     }
     case TX_16X16: {
@@ -354,9 +317,6 @@
       seg_eob = 256;
       above_ec = (A[0] + A[1] + A[2] + A[3]) != 0;
       left_ec = (L[0] + L[1] + L[2] + L[3]) != 0;
-#if CONFIG_CODE_ZEROGROUP
-      zpc_probs = &cm->fc.zpc_probs_16x16;
-#endif
       break;
     }
     case TX_32X32:
@@ -365,10 +325,6 @@
       seg_eob = 1024;
       above_ec = (A[0] + A[1] + A[2] + A[3] + A[4] + A[5] + A[6] + A[7]) != 0;
       left_ec = (L[0] + L[1] + L[2] + L[3] + L[4] + L[5] + L[6] + L[7]) != 0;
-
-#if CONFIG_CODE_ZEROGROUP
-      zpc_probs = &cm->fc.zpc_probs_32x32;
-#endif
       break;
     default:
       abort();
@@ -387,16 +343,6 @@
   if (eob < seg_eob)
     assert(qcoeff_ptr[scan[eob]] == 0);
 
-#if CONFIG_CODE_ZEROGROUP
-  vpx_memset(token_cache_full, ZERO_TOKEN, sizeof(token_cache_full));
-  for (c = 0; c < eob; ++c) {
-    rc = scan[c];
-    token_cache_full[rc] = vp9_dct_value_tokens_ptr[qcoeff_ptr[rc]].token;
-    o = vp9_get_orientation(rc, tx_size);
-    if (qcoeff_ptr[rc] != 0)
-      last_nz_pos[o] = c;
-  }
-#endif
   {
     for (c = 0; c < eob; c++) {
       int v = qcoeff_ptr[scan[c]];
@@ -404,77 +350,12 @@
       int band = get_coef_band(scan, tx_size, c);
       if (c)
         pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
-#if CONFIG_CODE_ZEROGROUP
-      rc = scan[c];
-      o = vp9_get_orientation(rc, tx_size);
-      skip_coef_val = (token_cache[rc] == ZERO_TOKEN || is_eoo_list[o]);
-      if (!skip_coef_val) {
-        cost += token_costs[band][pt][t] + vp9_dct_value_cost_ptr[v];
-      } else {
-        assert(v == 0);
-      }
-#else
+
       cost += token_costs[band][pt][t] + vp9_dct_value_cost_ptr[v];
-#endif
+
       if (!c || token_cache[scan[c - 1]])
         cost += vp9_cost_bit(coef_probs[type][ref][band][pt][0], 1);
       token_cache[scan[c]] = t;
-#if CONFIG_CODE_ZEROGROUP
-      if (t == ZERO_TOKEN && !skip_coef_val) {
-        int eoo = 0, use_eoo;
-#if USE_ZPC_EOORIENT == 1
-        use_eoo = vp9_use_eoo(c, seg_eob, scan, tx_size,
-                              is_last_zero, is_eoo_list);
-#else
-        use_eoo = 0;
-#endif
-        if (use_eoo) {
-          eoo = vp9_is_eoo(c, eob, scan, tx_size, qcoeff_ptr, last_nz_pos);
-          if (eoo && is_eoo_negative[o]) eoo = 0;
-          if (eoo) {
-            int c_;
-            int savings = 0;
-            int zsaved = 0;
-            savings = vp9_cost_bit((*zpc_probs)[ref]
-                                   [coef_to_zpc_band(band)]
-                                   [coef_to_zpc_ptok(pt)][0], 1) -
-                      vp9_cost_bit((*zpc_probs)[ref]
-                                   [coef_to_zpc_band(band)]
-                                   [coef_to_zpc_ptok(pt)][0], 0);
-            for (c_ = c + 1; c_ < eob; ++c_) {
-              if (o == vp9_get_orientation(scan[c_], tx_size)) {
-                int pt_ = vp9_get_coef_context(scan, nb, pad,
-                                               token_cache_full, c_,
-                                               default_eob);
-                int band_ = get_coef_band(scan, tx_size, c_);
-                assert(token_cache_full[scan[c_]] == ZERO_TOKEN);
-                if (!c_ || token_cache_full[scan[c_ - 1]])
-                  savings += vp9_cost_bit(
-                      coef_probs[type][ref][band_][pt_][0], 1);
-                savings += vp9_cost_bit(
-                    coef_probs[type][ref][band_][pt_][1], 0);
-                zsaved++;
-              }
-            }
-            if (savings < 0) {
-            // if (zsaved < ZPC_ZEROSSAVED_EOO) {
-              eoo = 0;
-              is_eoo_negative[o] = 1;
-            }
-          }
-        }
-        if (use_eoo) {
-          cost += vp9_cost_bit((*zpc_probs)[ref]
-                                           [coef_to_zpc_band(band)]
-                                           [coef_to_zpc_ptok(pt)][0], !eoo);
-          if (eoo) {
-            assert(is_eoo_list[o] == 0);
-            is_eoo_list[o] = 1;
-          }
-        }
-      }
-      is_last_zero[o] = (t == ZERO_TOKEN);
-#endif
     }
     if (c < seg_eob) {
       if (c)
@@ -1925,9 +1806,6 @@
                                  int mdcounts[4], int64_t txfm_cache[],
                                  int *rate2, int *distortion, int *skippable,
                                  int *compmode_cost,
-#if CONFIG_COMP_INTERINTRA_PRED
-                                 int *compmode_interintra_cost,
-#endif
                                  int *rate_y, int *distortion_y,
                                  int *rate_uv, int *distortion_uv,
                                  int *mode_excluded, int *disable_skip,
@@ -1944,9 +1822,6 @@
   MACROBLOCKD *xd = &x->e_mbd;
   MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
   const int is_comp_pred = (mbmi->second_ref_frame > 0);
-#if CONFIG_COMP_INTERINTRA_PRED
-  const int is_comp_interintra_pred = (mbmi->second_ref_frame == INTRA_FRAME);
-#endif
   const int num_refs = is_comp_pred ? 2 : 1;
   const int this_mode = mbmi->mode;
   int i;
@@ -2088,20 +1963,6 @@
                                 is_comp_pred);
   *rate2 += vp9_cost_mv_ref(cpi, this_mode,
                             mbmi->mb_mode_context[mbmi->ref_frame]);
-#if CONFIG_COMP_INTERINTRA_PRED
-  if (!is_comp_pred) {
-    *compmode_interintra_cost = vp9_cost_bit(cm->fc.interintra_prob,
-                                             is_comp_interintra_pred);
-    if (is_comp_interintra_pred) {
-      *compmode_interintra_cost +=
-          x->mbmode_cost[xd->frame_type][mbmi->interintra_mode];
-#if SEPARATE_INTERINTRA_UV
-      *compmode_interintra_cost +=
-          x->intra_uv_mode_cost[xd->frame_type][mbmi->interintra_uv_mode];
-#endif
-    }
-  }
-#endif
 
   pred_exists = 0;
   interpolating_intpel_seen = 0;
@@ -2270,9 +2131,6 @@
     } else {
       *mode_excluded = (cpi->common.comp_pred_mode == COMP_PREDICTION_ONLY);
     }
-#if CONFIG_COMP_INTERINTRA_PRED
-    if (is_comp_interintra_pred && !cm->use_interintra) *mode_excluded = 1;
-#endif
   }
 
   return this_rd;  // if 0, this will be re-calculated by caller
@@ -2372,14 +2230,6 @@
   int j;
   int mode_index, best_mode_index = 0;
   unsigned int ref_costs[MAX_REF_FRAMES];
-#if CONFIG_COMP_INTERINTRA_PRED
-  int is_best_interintra = 0;
-  int64_t best_intra16_rd = INT64_MAX;
-  int best_intra16_mode = DC_PRED;
-#if SEPARATE_INTERINTRA_UV
-  int best_intra16_uv_mode = DC_PRED;
-#endif
-#endif
   int64_t best_overall_rd = INT64_MAX;
   INTERPOLATIONFILTERTYPE best_filter = SWITCHABLE;
   INTERPOLATIONFILTERTYPE tmp_best_filter = SWITCHABLE;
@@ -2481,9 +2331,6 @@
     int distortion2 = 0, distortion_y = 0, distortion_uv = 0;
     int skippable;
     int64_t txfm_cache[NB_TXFM_MODES];
-#if CONFIG_COMP_INTERINTRA_PRED
-    int compmode_interintra_cost = 0;
-#endif
 
     // Test best rd so far against threshold for trying this mode.
     if (best_rd <= cpi->rd_threshes[mode_index] ||
@@ -2535,10 +2382,6 @@
     comp_pred = mbmi->second_ref_frame > INTRA_FRAME;
     mbmi->mode = this_mode;
     mbmi->uv_mode = DC_PRED;
-#if CONFIG_COMP_INTERINTRA_PRED
-    mbmi->interintra_mode = (MB_PREDICTION_MODE)(DC_PRED - 1);
-    mbmi->interintra_uv_mode = (MB_PREDICTION_MODE)(DC_PRED - 1);
-#endif
 
     // Evaluate all sub-pel filters irrespective of whether we can use
     // them for this frame.
@@ -2572,10 +2415,6 @@
           mode_excluded =
               mode_excluded ?
                   mode_excluded : cm->comp_pred_mode == COMP_PREDICTION_ONLY;
-#if CONFIG_COMP_INTERINTRA_PRED
-        else
-          mode_excluded = mode_excluded ? mode_excluded : !cm->use_interintra;
-#endif
       }
     }
 
@@ -2784,24 +2623,10 @@
       if (cpi->scaled_ref_idx[fb] != cm->ref_frame_map[fb])
         scaled_ref_frame = &cm->yv12_fb[cpi->scaled_ref_idx[fb]];
 
-#if CONFIG_COMP_INTERINTRA_PRED
-      if (mbmi->second_ref_frame == INTRA_FRAME) {
-        if (best_intra16_mode == DC_PRED - 1) continue;
-        mbmi->interintra_mode = best_intra16_mode;
-#if SEPARATE_INTERINTRA_UV
-        mbmi->interintra_uv_mode = best_intra16_uv_mode;
-#else
-        mbmi->interintra_uv_mode = best_intra16_mode;
-#endif
-      }
-#endif
       this_rd = handle_inter_mode(cpi, x, bsize,
                                   mdcounts, txfm_cache,
                                   &rate2, &distortion2, &skippable,
                                   &compmode_cost,
-#if CONFIG_COMP_INTERINTRA_PRED
-                                  &compmode_interintra_cost,
-#endif
                                   &rate_y, &distortion_y,
                                   &rate_uv, &distortion_uv,
                                   &mode_excluded, &disable_skip,
@@ -2811,11 +2636,6 @@
         continue;
     }
 
-#if CONFIG_COMP_INTERINTRA_PRED
-    if (cpi->common.use_interintra) {
-      rate2 += compmode_interintra_cost;
-    }
-#endif
     if (cpi->common.comp_pred_mode == HYBRID_PREDICTION) {
       rate2 += compmode_cost;
     }
@@ -2873,18 +2693,6 @@
       *returnintra = distortion2;
     }
 #endif
-#if CONFIG_COMP_INTERINTRA_PRED
-    if ((mbmi->ref_frame == INTRA_FRAME) &&
-        (this_mode <= TM_PRED) &&
-        (this_rd < best_intra16_rd)) {
-      best_intra16_rd = this_rd;
-      best_intra16_mode = this_mode;
-#if SEPARATE_INTERINTRA_UV
-      best_intra16_uv_mode = (mbmi->txfm_size != TX_4X4 ?
-                              mode_uv_8x8 : mode_uv_4x4);
-#endif
-    }
-#endif
 
     if (!disable_skip && mbmi->ref_frame == INTRA_FRAME)
       for (i = 0; i < NB_PREDICTION_TYPES; ++i)
@@ -2894,9 +2702,6 @@
       best_overall_rd = this_rd;
       best_filter = tmp_best_filter;
       best_mode = this_mode;
-#if CONFIG_COMP_INTERINTRA_PRED
-      is_best_interintra = (mbmi->second_ref_frame == INTRA_FRAME);
-#endif
     }
 
     // Store the respective mode distortions for later use.
@@ -3035,11 +2840,6 @@
          (cm->mcomp_filter_type == best_mbmode.interp_filter) ||
          (best_mbmode.mode <= I4X4_PRED));
 
-#if CONFIG_COMP_INTERINTRA_PRED
-  ++cpi->interintra_select_count[is_best_interintra];
-  // if (is_best_interintra)  printf("best_interintra\n");
-#endif
-
   // Accumulate filter usage stats
   // TODO(agrange): Use RD criteria to select interpolation filter mode.
   if (is_inter_mode(best_mode))
diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c
index 6bd8b50..d272cbb 100644
--- a/vp9/encoder/vp9_temporal_filter.c
+++ b/vp9/encoder/vp9_temporal_filter.c
@@ -26,7 +26,6 @@
 #include "vp9/common/vp9_quant_common.h"
 #include "vp9/encoder/vp9_segmentation.h"
 #include "vpx_mem/vpx_mem.h"
-#include "vp9/common/vp9_swapyv12buffer.h"
 #include "vpx_ports/vpx_timer.h"
 
 #define ALT_REF_MC_ENABLED 1    // dis/enable MC in AltRef filtering
diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c
index 9a65985..cb670da 100644
--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -136,20 +136,6 @@
   ENTROPY_CONTEXT above_ec, left_ec;
   uint8_t token_cache[1024];
   TX_TYPE tx_type = DCT_DCT;
-#if CONFIG_CODE_ZEROGROUP
-  int last_nz_pos[3] = {-1, -1, -1};  // Encoder only
-  int is_eoo_list[3] = {0, 0, 0};
-  int is_last_zero[3] = {0, 0, 0};
-  int is_eoo_negative[3] = {0, 0, 0};
-  int o;
-  vp9_zpc_probs *zpc_probs;
-  vp9_zpc_count *zpc_count;
-  uint8_t token_cache_full[1024];
-#endif
-#if CONFIG_CODE_ZEROGROUP
-  vpx_memset(token_cache, UNKNOWN_TOKEN, sizeof(token_cache));
-#endif
-
   assert((!type && !plane) || (type && plane));
 
   switch (tx_size) {
@@ -163,10 +149,6 @@
       scan = get_scan_4x4(tx_type);
       counts = cpi->coef_counts_4x4;
       coef_probs = cpi->common.fc.coef_probs_4x4;
-#if CONFIG_CODE_ZEROGROUP
-      zpc_count = &cpi->common.fc.zpc_counts_4x4;
-      zpc_probs = &cpi->common.fc.zpc_probs_4x4;
-#endif
       break;
     }
     case TX_8X8: {
@@ -180,10 +162,6 @@
       scan = get_scan_8x8(tx_type);
       counts = cpi->coef_counts_8x8;
       coef_probs = cpi->common.fc.coef_probs_8x8;
-#if CONFIG_CODE_ZEROGROUP
-      zpc_count = &cpi->common.fc.zpc_counts_8x8;
-      zpc_probs = &cpi->common.fc.zpc_probs_8x8;
-#endif
       break;
     }
     case TX_16X16: {
@@ -197,10 +175,6 @@
       scan = get_scan_16x16(tx_type);
       counts = cpi->coef_counts_16x16;
       coef_probs = cpi->common.fc.coef_probs_16x16;
-#if CONFIG_CODE_ZEROGROUP
-      zpc_count = &cpi->common.fc.zpc_counts_16x16;
-      zpc_probs = &cpi->common.fc.zpc_probs_16x16;
-#endif
       break;
     }
     case TX_32X32:
@@ -210,10 +184,6 @@
       scan = vp9_default_zig_zag1d_32x32;
       counts = cpi->coef_counts_32x32;
       coef_probs = cpi->common.fc.coef_probs_32x32;
-#if CONFIG_CODE_ZEROGROUP
-      zpc_count = &cpi->common.fc.zpc_counts_32x32;
-      zpc_probs = &cpi->common.fc.zpc_probs_32x32;
-#endif
       break;
   }
 
@@ -224,17 +194,6 @@
   if (vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP))
     seg_eob = 0;
 
-#if CONFIG_CODE_ZEROGROUP
-  vpx_memset(token_cache_full, ZERO_TOKEN, sizeof(token_cache_full));
-  for (c = 0; c < eob; ++c) {
-    rc = scan[c];
-    token_cache_full[rc] = vp9_dct_value_tokens_ptr[qcoeff_ptr[rc]].token;
-    o = vp9_get_orientation(rc, tx_size);
-    if (qcoeff_ptr[rc] != 0) {
-      last_nz_pos[o] = c;
-    }
-  }
-#endif
   c = 0;
   do {
     const int band = get_coef_band(scan, tx_size, c);
@@ -257,94 +216,13 @@
     t->context_tree = coef_probs[type][ref][band][pt];
       t->skip_eob_node = (c > 0) && (token_cache[scan[c - 1]] == 0);
     assert(vp9_coef_encodings[t->token].len - t->skip_eob_node > 0);
-#if CONFIG_CODE_ZEROGROUP
-    o = vp9_get_orientation(rc, tx_size);
-    t->skip_coef_val = (token_cache[rc] == ZERO_TOKEN || is_eoo_list[o]);
-    if (t->skip_coef_val) {
-      assert(v == 0);
-    }
-    // No need to transmit any token
-    if (t->skip_eob_node && t->skip_coef_val) {
-      assert(token == ZERO_TOKEN);
-      is_last_zero[o] = 1;
-      token_cache[scan[c]] = ZERO_TOKEN;
-      continue;
-    }
-#endif
+
     if (!dry_run) {
       ++counts[type][ref][band][pt][token];
       if (!t->skip_eob_node)
         ++cpi->common.fc.eob_branch_counts[tx_size][type][ref][band][pt];
     }
     token_cache[scan[c]] = token;
-#if CONFIG_CODE_ZEROGROUP
-    if (token == ZERO_TOKEN && !t->skip_coef_val) {
-      int eoo = 0, use_eoo;
-#if USE_ZPC_EOORIENT == 1
-      use_eoo = vp9_use_eoo(c, seg_eob, scan, tx_size,
-                            is_last_zero, is_eoo_list);
-#else
-      use_eoo = 0;
-#endif
-      if (use_eoo) {
-        eoo = vp9_is_eoo(c, eob, scan, tx_size, qcoeff_ptr, last_nz_pos);
-        if (eoo && is_eoo_negative[o]) eoo = 0;
-        if (eoo) {
-          int c_;
-          int savings = 0;
-          int zsaved = 0;
-          savings =
-              vp9_cost_bit((*zpc_probs)[ref]
-                           [coef_to_zpc_band(band)]
-                           [coef_to_zpc_ptok(pt)][0], 1) -
-              vp9_cost_bit((*zpc_probs)[ref]
-                           [coef_to_zpc_band(band)]
-                           [coef_to_zpc_ptok(pt)][0], 0);
-          for (c_ = c + 1; c_ < eob; ++c_) {
-            if (o == vp9_get_orientation(scan[c_], tx_size)) {
-              int pt_ = vp9_get_coef_context(scan, nb, pad, token_cache_full,
-                                             c_, default_eob);
-              int band_ = get_coef_band(scan, tx_size, c_);
-              assert(token_cache_full[scan[c_]] == ZERO_TOKEN);
-              if (!c_ || token_cache_full[scan[c_ - 1]])
-                savings +=
-                    vp9_cost_bit(coef_probs[type][ref][band_][pt_][0], 1);
-              savings += vp9_cost_bit(coef_probs[type][ref][band_][pt_][1], 0);
-              zsaved++;
-            }
-          }
-          /*
-          if (!dry_run)
-            if (savings > 0)
-              printf("savings %d zsaved %d (%d, %d)\n",
-                     savings, zsaved, tx_size, band);
-                     */
-          if (savings < 0) {
-            eoo = 0;
-            is_eoo_negative[o] = 1;
-          }
-        }
-      }
-      if (use_eoo) {
-        t++;
-        t->skip_eob_node = t->skip_coef_val = 0;
-        // transmit the eoo symbol
-        t->token = !eoo ? ZPC_ISOLATED : ZPC_EOORIENT;
-        t->context_tree = &((*zpc_probs)[ref]
-                            [coef_to_zpc_band(band)]
-                            [coef_to_zpc_ptok(pt)][0]);
-        if (!dry_run)
-          (*zpc_count)[ref]
-              [coef_to_zpc_band(band)]
-              [coef_to_zpc_ptok(pt)][0][!eoo]++;
-        if (eoo) {
-          assert(is_eoo_list[o] == 0);
-          is_eoo_list[o] = 1;
-        }
-      }
-    }
-    is_last_zero[o] = (token == ZERO_TOKEN);
-#endif
     ++t;
   } while (c < eob && ++c < seg_eob);
 
diff --git a/vp9/vp9_common.mk b/vp9/vp9_common.mk
index a5b33ba..ace7e6f 100644
--- a/vp9/vp9_common.mk
+++ b/vp9/vp9_common.mk
@@ -56,7 +56,6 @@
 VP9_COMMON_SRCS-yes += common/vp9_subpelvar.h
 VP9_COMMON_SRCS-yes += common/vp9_seg_common.h
 VP9_COMMON_SRCS-yes += common/vp9_seg_common.c
-VP9_COMMON_SRCS-yes += common/vp9_swapyv12buffer.h
 VP9_COMMON_SRCS-yes += common/vp9_systemdependent.h
 VP9_COMMON_SRCS-yes += common/vp9_textblit.h
 VP9_COMMON_SRCS-yes += common/vp9_tile_common.h
@@ -74,7 +73,6 @@
 VP9_COMMON_SRCS-yes += common/vp9_recon.c
 VP9_COMMON_SRCS-yes += common/vp9_reconinter.c
 VP9_COMMON_SRCS-yes += common/vp9_reconintra.c
-VP9_COMMON_SRCS-yes += common/vp9_swapyv12buffer.c
 VP9_COMMON_SRCS-$(CONFIG_POSTPROC_VISUALIZER) += common/vp9_textblit.c
 VP9_COMMON_SRCS-yes += common/vp9_treecoder.c
 VP9_COMMON_SRCS-$(CONFIG_IMPLICIT_SEGMENTATION) += common/vp9_implicit_segmentation.c