shithub: libvpx

Download patch

ref: 68033ca47253f446f4040bb0c75ca88710bb4e08
parent: 157f15e1d3f5343607e683844cfa57bee0dd8cce
author: Paul Wilkins <paulwilkins@google.com>
date: Tue Mar 6 06:23:50 EST 2012

Snapshot candidate

Pulled out super block code for the snapshot as this
is not quite ready and will need an extensive re-merge.

Change-Id: I436369b511257447a7b0ea064016cb63f5011849

--- a/configure
+++ b/configure
@@ -219,7 +219,6 @@
     uvintra
     compred
     enhanced_interp
-    superblocks
     featureupdates
     high_precision_mv
     sixteenth_subpel_uv
--- a/vp8/decoder/decodemv.c
+++ b/vp8/decoder/decodemv.c
@@ -988,83 +988,8 @@
 
 }
 
-#if CONFIG_SUPERBLOCKS
 void vp8_decode_mode_mvs(VP8D_COMP *pbi)
 {
-    int i;
-    VP8_COMMON *cm = &pbi->common;
-    int sb_row, sb_col;
-    int sb_rows = (cm->mb_rows + 1)>>1;
-    int sb_cols = (cm->mb_cols + 1)>>1;
-    MODE_INFO *mi = cm->mi;
-    int row_delta[4] = {-1,  0, +1,  0};
-    int col_delta[4] = {+1, +1, -1, +1};
-
-    MODE_INFO *prev_mi = cm->prev_mi;
-
-    mb_mode_mv_init(pbi);
-
-#if CONFIG_QIMODE
-    if(cm->frame_type==KEY_FRAME && !cm->kf_ymode_probs_update)
-    {
-        cm->kf_ymode_probs_index = vp8_read_literal(&pbi->bc, 3);
-    }
-#endif
-
-    for (sb_row=0; sb_row<sb_rows; sb_row++)
-    {
-        int mb_col = -col_delta[0];
-        int mb_row = (sb_row <<1)-row_delta[0];
-
-        for (sb_col=0; sb_col<sb_cols; sb_col++)
-        {
-            for ( i=0; i<4; i++ )
-            {
-                int mb_to_top_edge;
-                int mb_to_bottom_edge;
-
-                int offset_extended = row_delta[(i+1) & 0x3]
-                                    * cm->mode_info_stride + col_delta[(i+1) & 0x3];
-                int dy = row_delta[i];
-                int dx = col_delta[i];
-
-                mb_row += dy;
-                mb_col += dx;
-
-                if ((mb_row >= cm->mb_rows) || (mb_col >= cm->mb_cols))
-                {
-                    prev_mi += offset_extended;
-                    mi += offset_extended;       /* next macroblock */
-                    continue;
-                }
-
-                pbi->mb.mb_to_top_edge =
-                mb_to_top_edge = -((mb_row * 16)) << 3;
-                mb_to_top_edge -= LEFT_TOP_MARGIN;
-
-                pbi->mb.mb_to_bottom_edge =
-                mb_to_bottom_edge = ((pbi->common.mb_rows - 1 - mb_row) * 16) << 3;
-                mb_to_bottom_edge += RIGHT_BOTTOM_MARGIN;
-
-                /*read_mb_modes_mv(pbi, cm->mode_info_context, &cm->mode_info_context->mbmi, mb_row, mb_col);*/
-                if(pbi->common.frame_type == KEY_FRAME)
-                    vp8_kfread_modes(pbi, mi, mb_row, mb_col);
-                else
-                    read_mb_modes_mv(pbi, mi, &mi->mbmi,
-                    prev_mi,
-                    mb_row, mb_col);
-
-                prev_mi += offset_extended;
-                mi += offset_extended;       /* next macroblock */
-            }
-        }
-
-        mi += cm->mode_info_stride + (1 - (cm->mb_cols & 0x1));
-    }
-}
-#else
-void vp8_decode_mode_mvs(VP8D_COMP *pbi)
-{
     MODE_INFO *mi = pbi->common.mi;
 
     MODE_INFO *prev_mi = pbi->common.prev_mi;
@@ -1148,4 +1073,3 @@
 
 
 }
-#endif /* CONFIG_SUPERBLOCKS */
--- a/vp8/decoder/decodframe.c
+++ b/vp8/decoder/decodframe.c
@@ -244,10 +244,10 @@
             {
                 RECON_INVOKE(&pbi->common.rtcd.recon,
                     build_intra_predictors_mby)(xd);
-            } else {
-#if !CONFIG_SUPERBLOCKS
+            }
+            else
+            {
                 vp8_intra_prediction_down_copy(xd);
-#endif
             }
         }
     }
@@ -448,136 +448,7 @@
 FILE *vpxlog = 0;
 #endif
 
-#if CONFIG_SUPERBLOCKS
 static void
-decode_sb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mbrow, MACROBLOCKD *xd)
-{
-    int i;
-    int recon_yoffset, recon_uvoffset;
-    int mb_row, mb_col;
-    int ref_fb_idx = pc->lst_fb_idx;
-    int dst_fb_idx = pc->new_fb_idx;
-    int recon_y_stride = pc->yv12_fb[ref_fb_idx].y_stride;
-    int recon_uv_stride = pc->yv12_fb[ref_fb_idx].uv_stride;
-    int sb_col;
-    int row_delta[4] = { 0, +1,  0, -1};
-    int col_delta[4] = {+1, -1, +1, +1};
-    int sb_cols = (pc->mb_cols + 1)>>1;
-    ENTROPY_CONTEXT_PLANES left_context[2];
-
-    vpx_memset(left_context, 0, sizeof(left_context));
-
-    mb_row = mbrow;
-    mb_col = 0;
-
-    for (sb_col=0; sb_col<sb_cols; sb_col++)
-    {
-        for ( i=0; i<4; i++ )
-        {
-            int dy = row_delta[i];
-            int dx = col_delta[i];
-            int offset_extended = dy * xd->mode_info_stride + dx;
-
-            if ((mb_row >= pc->mb_rows) || (mb_col >= pc->mb_cols))
-            {
-                // Skip on to the next MB
-                mb_row += dy;
-                mb_col += dx;
-                xd->mode_info_context += offset_extended;
-                continue;
-            }
-
-            // Copy in the appropriate left context
-            vpx_memcpy (&pc->left_context,
-                        &left_context[(i>>1) & 0x1],
-                        sizeof(ENTROPY_CONTEXT_PLANES));
-
-            // reset above block coeffs
-            xd->above_context = pc->above_context + mb_col;
-
-            /* Distance of Mb to the various image edges.
-             * These are specified to 8th pel as they are always compared to
-             * values that are in 1/8th pel units
-             */
-            xd->mb_to_top_edge = -((mb_row * 16)) << 3;
-            xd->mb_to_bottom_edge = ((pc->mb_rows - 1 - mb_row) * 16) << 3;
-
-            xd->mb_to_left_edge = -((mb_col * 16) << 3);
-            xd->mb_to_right_edge = ((pc->mb_cols - 1 - mb_col) * 16) << 3;
-
-            xd->up_available = (mb_row != 0);
-            xd->left_available = (mb_col != 0);
-
-            update_blockd_bmi(xd);
-
-            recon_yoffset = (mb_row * recon_y_stride * 16) + (mb_col * 16);
-            recon_uvoffset = (mb_row * recon_uv_stride * 8) + (mb_col * 8);
-
-            xd->dst.y_buffer = pc->yv12_fb[dst_fb_idx].y_buffer + recon_yoffset;
-            xd->dst.u_buffer = pc->yv12_fb[dst_fb_idx].u_buffer + recon_uvoffset;
-            xd->dst.v_buffer = pc->yv12_fb[dst_fb_idx].v_buffer + recon_uvoffset;
-
-            /* Select the appropriate reference frame for this MB */
-            if (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME)
-                ref_fb_idx = pc->lst_fb_idx;
-            else if (xd->mode_info_context->mbmi.ref_frame == GOLDEN_FRAME)
-                ref_fb_idx = pc->gld_fb_idx;
-            else
-                ref_fb_idx = pc->alt_fb_idx;
-
-            xd->pre.y_buffer = pc->yv12_fb[ref_fb_idx].y_buffer +recon_yoffset;
-            xd->pre.u_buffer = pc->yv12_fb[ref_fb_idx].u_buffer +recon_uvoffset;
-            xd->pre.v_buffer = pc->yv12_fb[ref_fb_idx].v_buffer +recon_uvoffset;
-
-            if (xd->mode_info_context->mbmi.second_ref_frame)
-            {
-                int second_ref_fb_idx;
-
-                /* Select the appropriate reference frame for this MB */
-                if (xd->mode_info_context->mbmi.second_ref_frame == LAST_FRAME)
-                    second_ref_fb_idx = pc->lst_fb_idx;
-                else if (xd->mode_info_context->mbmi.second_ref_frame ==
-                                                                   GOLDEN_FRAME)
-                    second_ref_fb_idx = pc->gld_fb_idx;
-                else
-                    second_ref_fb_idx = pc->alt_fb_idx;
-
-                xd->second_pre.y_buffer =
-                       pc->yv12_fb[second_ref_fb_idx].y_buffer + recon_yoffset;
-                xd->second_pre.u_buffer =
-                       pc->yv12_fb[second_ref_fb_idx].u_buffer + recon_uvoffset;
-                xd->second_pre.v_buffer =
-                       pc->yv12_fb[second_ref_fb_idx].v_buffer + recon_uvoffset;
-            }
-
-            if (xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME)
-            {
-                /* propagate errors from reference frames */
-                xd->corrupted |= pc->yv12_fb[ref_fb_idx].corrupted;
-            }
-
-            decode_macroblock(pbi, xd, mb_row * pc->mb_cols + mb_col);
-
-            /* check if the boolean decoder has suffered an error */
-            xd->corrupted |= vp8dx_bool_error(xd->current_bc);
-
-            // Copy in the appropriate left context
-            vpx_memcpy (&left_context[(i>>1) & 0x1],
-                        &pc->left_context,
-                        sizeof(ENTROPY_CONTEXT_PLANES));
-
-            // skip to next MB
-            xd->mode_info_context += offset_extended;
-            mb_row += dy;
-            mb_col += dx;
-        }
-    }
-
-    /* skip prediction column */
-    xd->mode_info_context += 1 - (pc->mb_cols & 0x1) + xd->mode_info_stride;
-}
-#else
-static void
 decode_mb_row(VP8D_COMP *pbi, VP8_COMMON *pc, int mb_row, MACROBLOCKD *xd)
 {
     int recon_yoffset, recon_uvoffset;
@@ -674,7 +545,6 @@
 
     ++xd->mode_info_context;      /* skip prediction column */
 }
-#endif // CONFIG_SUPERBLOCKS
 
 static unsigned int read_partition_size(const unsigned char *cx_size)
 {
@@ -1278,19 +1148,11 @@
     // Resset the macroblock mode info context to the start of the list
     xd->mode_info_context = pc->mi;
 
-#if CONFIG_SUPERBLOCKS
-    /* Decode a row of super-blocks */
-    for (mb_row = 0; mb_row < pc->mb_rows; mb_row+=2)
-    {
-        decode_sb_row(pbi, pc, mb_row, xd);
-    }
-#else
     /* Decode a row of macro blocks */
     for (mb_row = 0; mb_row < pc->mb_rows; mb_row++)
     {
         decode_mb_row(pbi, pc, mb_row, xd);
     }
-#endif /* CONFIG_SUPERBLOCKS */
     corrupt_tokens |= xd->corrupted;
 
     /* Collect information about decoder corruption. */
--- a/vp8/encoder/bitstream.c
+++ b/vp8/encoder/bitstream.c
@@ -561,7 +561,6 @@
     compute_mod_refprobs( cm );
 }
 
-#if CONFIG_SUPERBLOCKS
 static void pack_inter_mode_mvs(VP8_COMP *const cpi)
 {
     VP8_COMMON *const pc = & cpi->common;
@@ -575,397 +574,7 @@
     int i;
     int pred_context;
 
-    MODE_INFO *m = pc->mi;
-    MODE_INFO *prev_m = pc->prev_mi;
 
-    const int mis = pc->mode_info_stride;
-    int mb_row, mb_col;
-    int row, col;
-
-    int prob_skip_false = 0;
-
-    // Values used in prediction model coding
-    vp8_prob pred_prob;
-    unsigned char prediction_flag;
-
-    int row_delta[4] = { 0, +1,  0, -1};
-    int col_delta[4] = {+1, -1, +1, +1};
-
-    cpi->mb.partition_info = cpi->mb.pi;
-
-    // Update the probabilities used to encode reference frame data
-    update_ref_probs( cpi );
-
-#ifdef ENTROPY_STATS
-    active_section = 1;
-#endif
-
-    if (pc->mb_no_coeff_skip)
-    {
-        // Divide by 0 check. 0 case possible with segment features
-        if ( (cpi->skip_false_count + cpi->skip_true_count) )
-        {
-            prob_skip_false = cpi->skip_false_count * 256 /
-                              (cpi->skip_false_count + cpi->skip_true_count);
-
-            if (prob_skip_false <= 1)
-                prob_skip_false = 1;
-
-            if (prob_skip_false > 255)
-                prob_skip_false = 255;
-        }
-        else
-            prob_skip_false = 255;
-
-        cpi->prob_skip_false = prob_skip_false;
-        vp8_write_literal(w, prob_skip_false, 8);
-    }
-
-    vp8_write_literal(w, pc->prob_intra_coded, 8);
-    vp8_write_literal(w, pc->prob_last_coded, 8);
-    vp8_write_literal(w, pc->prob_gf_coded, 8);
-
-    if (cpi->common.comp_pred_mode == HYBRID_PREDICTION)
-    {
-        vp8_write(w, 1, 128);
-        vp8_write(w, 1, 128);
-        for (i = 0; i < COMP_PRED_CONTEXTS; i++)
-        {
-            if (cpi->single_pred_count[i] + cpi->comp_pred_count[i])
-            {
-                pc->prob_comppred[i] = cpi->single_pred_count[i] * 255 /
-                    (cpi->single_pred_count[i] + cpi->comp_pred_count[i]);
-                if (pc->prob_comppred[i] < 1)
-                    pc->prob_comppred[i] = 1;
-            }
-            else
-            {
-                pc->prob_comppred[i] = 128;
-            }
-            vp8_write_literal(w, pc->prob_comppred[i], 8);
-        }
-    }
-    else if (cpi->common.comp_pred_mode == SINGLE_PREDICTION_ONLY)
-    {
-        vp8_write(w, 0, 128);
-    }
-    else /* compound prediction only */
-    {
-        vp8_write(w, 1, 128);
-        vp8_write(w, 0, 128);
-    }
-
-    update_mbintra_mode_probs(cpi);
-
-#if CONFIG_HIGH_PRECISION_MV
-    if (xd->allow_high_precision_mv)
-        vp8_write_mvprobs_hp(cpi);
-    else
-#endif
-    vp8_write_mvprobs(cpi);
-
-    mb_row = 0;
-    for (row=0; row < pc->mb_rows; row += 2)
-    {
-        m = pc->mi + row * mis;
-
-        mb_col = 0;
-        for (col=0; col < pc->mb_cols; col += 2)
-        {
-            int i;
-
-            for (i=0; i<4; i++)
-            {
-                const MB_MODE_INFO *const mi = & m->mbmi;
-                const MV_REFERENCE_FRAME rf = mi->ref_frame;
-                const MB_PREDICTION_MODE mode = mi->mode;
-                const int segment_id = mi->segment_id;
-
-                int dy = row_delta[i];
-                int dx = col_delta[i];
-                int offset_extended = dy * mis + dx;
-
-                if ((mb_row >= pc->mb_rows) || (mb_col >= pc->mb_cols))
-                {
-                    mb_row += dy;
-                    mb_col += dx;
-                    m += offset_extended;
-                    cpi->mb.partition_info += offset_extended;
-                    continue;
-                }
-
-                // Distance of Mb to the various image edges.
-                // These specified to 8th pel as they are always compared to MV
-                // values that are in 1/8th pel units
-                xd->mb_to_left_edge = -((mb_col * 16) << 3);
-                xd->mb_to_right_edge = ((pc->mb_cols - 1 - mb_col) * 16) << 3;
-                xd->mb_to_top_edge = -((mb_row * 16)) << 3;
-                xd->mb_to_bottom_edge = ((pc->mb_rows - 1 - mb_row) * 16) << 3;
-
-                // Make sure the MacroBlockD mode info pointer is set correctly
-                xd->mode_info_context = m;
-                xd->prev_mode_info_context = prev_m;
-
-#ifdef ENTROPY_STATS
-                active_section = 9;
-#endif
-                if (cpi->mb.e_mbd.update_mb_segmentation_map)
-                {
-                    // Is temporal coding of the segment map enabled
-                    if (pc->temporal_update)
-                    {
-                        prediction_flag =
-                            get_pred_flag( xd, PRED_SEG_ID );
-                        pred_prob =
-                            get_pred_prob( pc, xd, PRED_SEG_ID);
-
-                        // Code the segment id prediction flag for this mb
-                        vp8_write( w, prediction_flag, pred_prob );
-
-                        // If the mbs segment id was not predicted code explicitly
-                        if (!prediction_flag)
-                            write_mb_segid(w, mi, &cpi->mb.e_mbd);
-                    }
-                    else
-                    {
-                        // Normal undpredicted coding
-                        write_mb_segid(w, mi, &cpi->mb.e_mbd);
-                    }
-                }
-
-                if ( pc->mb_no_coeff_skip &&
-                     ( !segfeature_active( xd, segment_id, SEG_LVL_EOB ) ||
-                       ( get_segdata( xd, segment_id, SEG_LVL_EOB ) != 0 ) ) )
-                {
-                    vp8_encode_bool(w, mi->mb_skip_coeff, prob_skip_false);
-                }
-
-                // Encode the reference frame.
-                encode_ref_frame( w, pc, xd,
-                              segment_id, rf );
-
-                if (rf == INTRA_FRAME)
-                {
-#ifdef ENTROPY_STATS
-                    active_section = 6;
-#endif
-
-                    if ( !segfeature_active( xd, segment_id, SEG_LVL_MODE ) )
-                        write_ymode(w, mode, pc->fc.ymode_prob);
-
-                    if (mode == B_PRED)
-                    {
-                        int j = 0, uses_second = m->bmi[0].as_mode.second != (B_PREDICTION_MODE);
-
-                        vp8_write(w, uses_second, 128);
-                        do {
-#if CONFIG_COMP_INTRA_PRED
-                            int mode2 = m->bmi[j].as_mode.second;
-#endif
-                            write_bmode(w, m->bmi[j].as_mode.first, pc->fc.bmode_prob);
-#if CONFIG_COMP_INTRA_PRED
-                            if (uses_second)
-                            {
-                                write_bmode(w, mode2, pc->fc.bmode_prob);
-                            }
-#endif
-                        } while (++j < 16);
-                    }
-
-                    if(mode == I8X8_PRED)
-                    {
-                        write_i8x8_mode(w, m->bmi[0].as_mode.first, pc->i8x8_mode_prob);
-                        write_i8x8_mode(w, m->bmi[2].as_mode.first, pc->i8x8_mode_prob);
-                        write_i8x8_mode(w, m->bmi[8].as_mode.first, pc->i8x8_mode_prob);
-                        write_i8x8_mode(w, m->bmi[10].as_mode.first, pc->i8x8_mode_prob);
-                    }
-                    else
-                    {
-#if CONFIG_UVINTRA
-                        write_uv_mode(w, mi->uv_mode, pc->fc.uv_mode_prob[mode]);
-#ifdef MODE_STATS
-                        if(mode!=B_PRED)
-                            ++cpi->y_uv_mode_count[mode][mi->uv_mode];
-#endif
-
-#else
-                        write_uv_mode(w, mi->uv_mode, pc->fc.uv_mode_prob);
-#endif /*CONFIG_UVINTRA*/
-                    }
-
-                }
-                else
-                {
-                    int_mv best_mv;
-                    vp8_prob mv_ref_p [VP8_MVREFS-1];
-
-                    {
-                        int_mv n1, n2;
-                        int ct[4];
-
-                        vp8_find_near_mvs(xd, m,
-                                          prev_m,
-                                          &n1, &n2, &best_mv, ct, rf,
-                                          cpi->common.ref_frame_sign_bias);
-                        vp8_mv_ref_probs(&cpi->common, mv_ref_p, ct);
-
-#ifdef ENTROPY_STATS
-                        accum_mv_refs(mode, ct);
-#endif
-                    }
-
-#ifdef ENTROPY_STATS
-                    active_section = 3;
-#endif
-
-                    // Is the segment coding of mode enabled
-                    if ( !segfeature_active( xd, segment_id, SEG_LVL_MODE ) )
-                    {
-                        write_mv_ref(w, mode, mv_ref_p);
-                        vp8_accum_mv_refs(&cpi->common, mode, ct);
-                    }
-
-
-                    {
-                        switch (mode)   /* new, split require MVs */
-                        {
-                        case NEWMV:
-
-#ifdef ENTROPY_STATS
-                            active_section = 5;
-#endif
-
-#if CONFIG_HIGH_PRECISION_MV
-                            if (xd->allow_high_precision_mv)
-                                write_mv_hp(w, &mi->mv.as_mv, &best_mv, mvc_hp);
-                            else
-#endif
-                            write_mv(w, &mi->mv.as_mv, &best_mv, mvc);
-
-                            if (cpi->common.comp_pred_mode == HYBRID_PREDICTION)
-                            {
-                                vp8_write(w,
-                                          mi->second_ref_frame != INTRA_FRAME,
-                                          get_pred_prob( pc, xd, PRED_COMP ) );
-                            }
-                            if (mi->second_ref_frame)
-                            {
-                                const int second_rf = mi->second_ref_frame;
-                                int_mv n1, n2;
-                                int ct[4];
-                                vp8_find_near_mvs(xd, m,
-                                                  prev_m,
-                                                  &n1, &n2, &best_mv,
-                                                  ct, second_rf,
-                                                  cpi->common.ref_frame_sign_bias);
-#if CONFIG_HIGH_PRECISION_MV
-                                if (xd->allow_high_precision_mv)
-                                    write_mv_hp(w, &mi->second_mv.as_mv,
-                                                &best_mv, mvc_hp);
-                                else
-#endif
-                                write_mv(w, &mi->second_mv.as_mv, &best_mv,
-                                         mvc);
-                            }
-                            break;
-
-                        case SPLITMV:
-                        {
-                            int j = 0;
-
-#ifdef MODE_STATS
-                            ++count_mb_seg [mi->partitioning];
-#endif
-
-                            write_split(w, mi->partitioning);
-
-                            do
-                            {
-                                B_PREDICTION_MODE blockmode;
-                                int_mv blockmv;
-                                const int *const  L = vp8_mbsplits [mi->partitioning];
-                                int k = -1;  /* first block in subset j */
-                                int mv_contz;
-                                int_mv leftmv, abovemv;
-
-                                blockmode =  cpi->mb.partition_info->bmi[j].mode;
-                                blockmv =  cpi->mb.partition_info->bmi[j].mv;
-#if CONFIG_DEBUG
-                                while (j != L[++k])
-                                    if (k >= 16)
-                                        assert(0);
-#else
-                                while (j != L[++k]);
-#endif
-                                leftmv.as_int = left_block_mv(m, k);
-                                abovemv.as_int = above_block_mv(m, k, mis);
-                                mv_contz = vp8_mv_cont(&leftmv, &abovemv);
-
-                                write_sub_mv_ref(w, blockmode, vp8_sub_mv_ref_prob2 [mv_contz]);
-
-                                if (blockmode == NEW4X4)
-                                {
-#ifdef ENTROPY_STATS
-                                    active_section = 11;
-#endif
-#if CONFIG_HIGH_PRECISION_MV
-                                    if (xd->allow_high_precision_mv)
-                                        write_mv_hp(w, &blockmv.as_mv, &best_mv,
-                                                    (const MV_CONTEXT_HP *)
-                                                    mvc_hp);
-                                    else
-#endif
-                                    write_mv(w, &blockmv.as_mv, &best_mv,
-                                             (const MV_CONTEXT *) mvc);
-                                }
-                            }
-                            while (++j < cpi->mb.partition_info->count);
-                        }
-                        break;
-                        default:
-                            if (cpi->common.comp_pred_mode == HYBRID_PREDICTION)
-                            {
-                                vp8_write(w,
-                                          mi->second_ref_frame != INTRA_FRAME,
-                                          get_pred_prob( pc, xd, PRED_COMP ) );
-                            }
-                            break;
-                        }
-                    }
-                }
-
-                prev_m += offset_extended;
-                assert((prev_m-cpi->common.prev_mip)==(m-cpi->common.mip));
-                assert((prev_m-cpi->common.prev_mi)==(m-cpi->common.mi));
-
-                // skip to next MB
-                mb_row += dy;
-                mb_col += dx;
-                m += offset_extended;
-                cpi->mb.partition_info += offset_extended;
-            }
-        }
-
-        mb_row += 2;
-        m += mis + (1- (pc->mb_cols & 0x1));
-        cpi->mb.partition_info += mis + (1- (pc->mb_cols & 0x1));
-    }
-}
-#else
-static void pack_inter_mode_mvs(VP8_COMP *const cpi)
-{
-    VP8_COMMON *const pc = & cpi->common;
-    vp8_writer *const w = & cpi->bc;
-    const MV_CONTEXT *mvc = pc->fc.mvc;
-#if CONFIG_HIGH_PRECISION_MV
-    const MV_CONTEXT_HP *mvc_hp = pc->fc.mvc_hp;
-#endif
-    MACROBLOCKD *xd = &cpi->mb.e_mbd;
-
-    int i;
-    int pred_context;
-
-
     MODE_INFO *m = pc->mi;
     MODE_INFO *prev_m = pc->prev_mi;
 
@@ -1307,152 +916,11 @@
         cpi->mb.partition_info++;
     }
 }
-#endif // CONFIG_SUPERBLOCKS
 
-#if CONFIG_SUPERBLOCKS
 static void write_kfmodes(VP8_COMP *cpi)
 {
     vp8_writer *const bc = & cpi->bc;
     const VP8_COMMON *const c = & cpi->common;
-    MODE_INFO *m;
-    int i;
-    int row, col;
-    int mb_row, mb_col;
-    int prob_skip_false = 0;
-    int row_delta[4] = { 0, +1,  0, -1};
-    int col_delta[4] = {+1, -1, +1, +1};
-    const int mis = c->mode_info_stride;
-
-    MACROBLOCKD *xd = &cpi->mb.e_mbd;
-
-    if (c->mb_no_coeff_skip)
-    {
-        // Divide by 0 check. 0 case possible with segment features
-        if ( (cpi->skip_false_count + cpi->skip_true_count) )
-        {
-            prob_skip_false = cpi->skip_false_count * 256 /
-                              (cpi->skip_false_count + cpi->skip_true_count);
-
-            if (prob_skip_false <= 1)
-                prob_skip_false = 1;
-
-            if (prob_skip_false > 255)
-                prob_skip_false = 255;
-        }
-        else
-            prob_skip_false = 255;
-
-        cpi->prob_skip_false = prob_skip_false;
-        vp8_write_literal(bc, prob_skip_false, 8);
-    }
-
-#if CONFIG_QIMODE
-    if(!c->kf_ymode_probs_update)
-    {
-        vp8_write_literal(bc, c->kf_ymode_probs_index, 3);
-    }
-#endif
-
-    mb_row = 0;
-    for (row=0; row < c->mb_rows; row += 2)
-    {
-        m = c->mi + row * mis;
-
-        mb_col = 0;
-        for (col=0; col < c->mb_cols; col += 2)
-        {
-            for (i=0; i<4; i++)
-            {
-                int ym;
-                int segment_id;
-                int dy = row_delta[i];
-                int dx = col_delta[i];
-                int offset_extended = dy * mis + dx;
-
-                if ((mb_row >= c->mb_rows) || (mb_col >= c->mb_cols))
-                {
-                    mb_row += dy;
-                    mb_col += dx;
-                    m += offset_extended;
-                    continue;
-                }
-
-                ym = m->mbmi.mode;
-                segment_id = m->mbmi.segment_id;
-
-                if (cpi->mb.e_mbd.update_mb_segmentation_map)
-                {
-                    write_mb_segid(bc, &m->mbmi, &cpi->mb.e_mbd);
-                }
-
-                if ( c->mb_no_coeff_skip &&
-                     ( !segfeature_active( xd, segment_id, SEG_LVL_EOB ) ||
-                       (get_segdata( xd, segment_id, SEG_LVL_EOB ) != 0) ) )
-                {
-                    vp8_encode_bool(bc, m->mbmi.mb_skip_coeff, prob_skip_false);
-                }
-#if CONFIG_QIMODE
-                kfwrite_ymode(bc, ym, c->kf_ymode_prob[c->kf_ymode_probs_index]);
-#else
-                kfwrite_ymode(bc, ym, c->kf_ymode_prob);
-#endif
-                if (ym == B_PRED)
-                {
-                    int i = 0, uses_second = m->bmi[0].as_mode.second != (B_PREDICTION_MODE);
-
-                    vp8_write(bc, uses_second, 128);
-                    do
-                    {
-                        const B_PREDICTION_MODE A = above_block_mode(m, i, mis);
-                        const B_PREDICTION_MODE L = left_block_mode(m, i);
-                        const int bm = m->bmi[i].as_mode.first;
-#if CONFIG_COMP_INTRA_PRED
-                        const int bm2 = m->bmi[i].as_mode.second;
-#endif
-
-#ifdef ENTROPY_STATS
-                        ++intra_mode_stats [A] [L] [bm];
-#endif
-
-                        write_bmode(bc, bm, c->kf_bmode_prob [A] [L]);
-#if CONFIG_COMP_INTRA_PRED
-                        if (uses_second)
-                        {
-                            write_bmode(bc, bm2, c->kf_bmode_prob [A] [L]);
-                        }
-#endif
-                    }
-                    while (++i < 16);
-                }
-
-                if(ym == I8X8_PRED)
-                {
-                    write_i8x8_mode(bc, m->bmi[0].as_mode.first, c->i8x8_mode_prob);
-                    write_i8x8_mode(bc, m->bmi[2].as_mode.first, c->i8x8_mode_prob);
-                    write_i8x8_mode(bc, m->bmi[8].as_mode.first, c->i8x8_mode_prob);
-                    write_i8x8_mode(bc, m->bmi[10].as_mode.first, c->i8x8_mode_prob);
-                }
-                else
-#if CONFIG_UVINTRA
-                write_uv_mode(bc, m->mbmi.uv_mode, c->kf_uv_mode_prob[ym]);
-#else
-                write_uv_mode(bc, m->mbmi.uv_mode, c->kf_uv_mode_prob);
-#endif
-                // skip to next MB
-                mb_row += dy;
-                mb_col += dx;
-                m += offset_extended;
-            }
-        }
-
-        mb_row += 2;
-    }
-}
-#else
-static void write_kfmodes(VP8_COMP *cpi)
-{
-    vp8_writer *const bc = & cpi->bc;
-    const VP8_COMMON *const c = & cpi->common;
     /* const */
     MODE_INFO *m = c->mi;
     int mb_row = -1;
@@ -1563,7 +1031,6 @@
         m++;    // skip L prediction border
     }
 }
-#endif /* CONFIG_SUPERBLOCKS */
 
 
 /* This function is used for debugging probability trees. */
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -380,227 +380,7 @@
     adjust_act_zbin(cpi, x);
 }
 
-#if CONFIG_SUPERBLOCKS
 static
-void encode_sb_row (VP8_COMP *cpi,
-                   VP8_COMMON *cm,
-                   int mbrow,
-                   MACROBLOCK  *x,
-                   MACROBLOCKD *xd,
-                   TOKENEXTRA **tp,
-                   int *totalrate)
-{
-    int i;
-    int map_index;
-    int mb_row, mb_col;
-    int recon_yoffset, recon_uvoffset;
-    int ref_fb_idx = cm->lst_fb_idx;
-    int dst_fb_idx = cm->new_fb_idx;
-    int recon_y_stride = cm->yv12_fb[ref_fb_idx].y_stride;
-    int recon_uv_stride = cm->yv12_fb[ref_fb_idx].uv_stride;
-    int row_delta[4] = {-1,  0, +1,  0};
-    int col_delta[4] = {+1, +1, -1, +1};
-    int sb_cols = (cm->mb_cols + 1)>>1;
-    int sb_col;
-    ENTROPY_CONTEXT_PLANES left_context[2];
-
-    vpx_memset (left_context, 0, sizeof(left_context));
-
-    // TODO put NULL into MB rows that have no tokens?
-    cpi->tplist[mbrow].start = *tp;
-
-    x->src.y_buffer -= 16 * (col_delta[0] + row_delta[0]*x->src.y_stride);
-    x->src.u_buffer -= 8  * (col_delta[0] + row_delta[0]*x->src.uv_stride);
-    x->src.v_buffer -= 8  * (col_delta[0] + row_delta[0]*x->src.uv_stride);
-    mb_row = mbrow - row_delta[0];
-    mb_col = 0     - col_delta[0];
-
-    for (sb_col=0; sb_col<sb_cols; sb_col++)
-   {
-        /* Encode MBs within the SB in raster order */
-        for ( i=0; i<4; i++ )
-        {
-            int offset_extended = row_delta[(i+1) & 0x3] *
-                                  xd->mode_info_stride + col_delta[(i+1) & 0x3];
-            int offset_unextended = row_delta[(i+1) & 0x3] *
-                                    cm->mb_cols + col_delta[(i+1) & 0x3];
-            int dy = row_delta[i];
-            int dx = col_delta[i];
-
-            mb_row += dy;
-            mb_col += dx;
-
-            x->src.y_buffer += 16 * (dx + dy*x->src.y_stride);
-            x->src.u_buffer += 8  * (dx + dy*x->src.uv_stride);
-            x->src.v_buffer += 8  * (dx + dy*x->src.uv_stride);
-
-            if ((mb_row >= cm->mb_rows) || (mb_col >= cm->mb_cols))
-            {
-                // Skip on to the next MB
-                x->gf_active_ptr      += offset_unextended;
-                x->partition_info     += offset_extended;
-                xd->mode_info_context += offset_extended;
-
-                xd->prev_mode_info_context += offset_extended;
-
-                assert((xd->prev_mode_info_context - cpi->common.prev_mip)
-                    ==(xd->mode_info_context - cpi->common.mip));
-                continue;
-            }
-
-            // Copy in the appropriate left context
-            vpx_memcpy (&cm->left_context,
-                        &left_context[(i>>1) & 0x1],
-                        sizeof(ENTROPY_CONTEXT_PLANES));
-
-            map_index = (mb_row * cpi->common.mb_cols) + mb_col;
-            x->mb_activity_ptr = &cpi->mb_activity_map[map_index];
-
-            // reset above block coeffs
-            xd->above_context = cm->above_context + mb_col;
-
-            // Distance of Mb to the top & bottom edges, specified in 1/8th pel
-            // units as they are always compared to values in 1/8th pel units
-            xd->mb_to_top_edge = -((mb_row * 16) << 3);
-            xd->mb_to_bottom_edge = ((cm->mb_rows - 1 - mb_row) * 16) << 3;
-
-            // Set up limit values for motion vector components
-            // to prevent them extending beyond the UMV borders
-            x->mv_row_min = -((mb_row * 16) + (VP8BORDERINPIXELS - 16));
-            x->mv_row_max = ((cm->mb_rows - 1 - mb_row) * 16)
-                                + (VP8BORDERINPIXELS - 16);
-            x->mv_col_min = -((mb_col * 16) + (VP8BORDERINPIXELS - 16));
-            x->mv_col_max = ((cm->mb_cols - 1 - mb_col) * 16)
-                                + (VP8BORDERINPIXELS - 16);
-
-            // Distance of Mb to the left & right edges, specified in
-            // 1/8th pel units as they are always compared to values
-            // that are in 1/8th pel units
-            xd->mb_to_left_edge = -((mb_col * 16) << 3);
-            xd->mb_to_right_edge = ((cm->mb_cols - 1 - mb_col) * 16) << 3;
-
-            xd->up_available = (mb_row != 0);
-            xd->left_available = (mb_col != 0);
-
-            recon_yoffset = (mb_row * recon_y_stride * 16) + (mb_col * 16);
-            recon_uvoffset = (mb_row * recon_uv_stride * 8) + (mb_col * 8);
-
-            xd->dst.y_buffer = cm->yv12_fb[dst_fb_idx].y_buffer + recon_yoffset;
-            xd->dst.u_buffer = cm->yv12_fb[dst_fb_idx].u_buffer + recon_uvoffset;
-            xd->dst.v_buffer = cm->yv12_fb[dst_fb_idx].v_buffer + recon_uvoffset;
-
-            x->rddiv = cpi->RDDIV;
-            x->rdmult = cpi->RDMULT;
-
-            // Copy current mb to a buffer
-            RECON_INVOKE(&xd->rtcd->recon, copy16x16)(x->src.y_buffer,
-                                                      x->src.y_stride,
-                                                      x->thismb, 16);
-
-            if(cpi->oxcf.tuning == VP8_TUNE_SSIM)
-                vp8_activity_masking(cpi, x);
-
-            // Is segmentation enabled
-            if (xd->segmentation_enabled)
-            {
-                // Code to set segment id in xd->mbmi.segment_id
-                if (cpi->segmentation_map[map_index] <= 3)
-                    xd->mode_info_context->mbmi.segment_id =
-                                  cpi->segmentation_map[map_index];
-                else
-                    xd->mode_info_context->mbmi.segment_id = 0;
-
-                vp8cx_mb_init_quantizer(cpi, x);
-            }
-            else
-                // Set to Segment 0 by default
-                xd->mode_info_context->mbmi.segment_id = 0;
-
-            x->active_ptr = cpi->active_map + map_index;
-
-            if (cm->frame_type == KEY_FRAME)
-            {
-                *totalrate += vp8cx_encode_intra_macro_block(cpi, x, tp);
-                //Note the encoder may have changed the segment_id
-
-#ifdef MODE_STATS
-                y_modes[xd->mode_info_context->mbmi.mode] ++;
-#endif
-            }
-            else
-            {
-                *totalrate += vp8cx_encode_inter_macroblock(cpi, x, tp,
-                                             recon_yoffset, recon_uvoffset);
-                //Note the encoder may have changed the segment_id
-
-#ifdef MODE_STATS
-                inter_y_modes[xd->mode_info_context->mbmi.mode] ++;
-
-                if (xd->mode_info_context->mbmi.mode == SPLITMV)
-                {
-                    int b;
-
-                    for (b = 0; b < x->partition_info->count; b++)
-                    {
-                        inter_b_modes[x->partition_info->bmi[b].mode] ++;
-                   }
-                }
-
-#endif
-
-                // Count of last ref frame 0,0 usage
-                if ((xd->mode_info_context->mbmi.mode == ZEROMV) &&
-                    (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME))
-                    cpi->inter_zz_count ++;
-            }
-
-            // TODO Make sure partitioning works with this new scheme
-            cpi->tplist[mbrow].stop = *tp;
-
-            // Copy back updated left context
-            vpx_memcpy (&left_context[(i>>1) & 0x1],
-                        &cm->left_context,
-                        sizeof(ENTROPY_CONTEXT_PLANES));
-
-            // skip to next mb
-            x->gf_active_ptr      += offset_unextended;
-            x->partition_info     += offset_extended;
-            xd->mode_info_context += offset_extended;
-
-            xd->prev_mode_info_context += offset_extended;
-
-            assert((xd->prev_mode_info_context - cpi->common.prev_mip)
-                ==(xd->mode_info_context - cpi->common.mip));
-        }
-    }
-
-    // Intra-pred modes requiring top-right data have been disabled,
-    // so we don't need this:
-    // extend the recon for intra prediction
-    /*vp8_extend_mb_row(
-        &cm->yv12_fb[dst_fb_idx],
-        xd->dst.y_buffer + 16,
-        xd->dst.u_buffer + 8,
-        xd->dst.v_buffer + 8);*/
-
-    // this is to account for the border
-    xd->prev_mode_info_context += 1 - (cm->mb_cols & 0x1) + xd->mode_info_stride;
-    xd->mode_info_context += 1 - (cm->mb_cols & 0x1) + xd->mode_info_stride;
-    x->partition_info     += 1 - (cm->mb_cols & 0x1) + xd->mode_info_stride;
-    x->gf_active_ptr      += cm->mb_cols - (cm->mb_cols & 0x1);
-
-// debug output
-#if DBG_PRNT_SEGMAP
-    {
-        FILE *statsfile;
-        statsfile = fopen("segmap2.stt", "a");
-        fprintf(statsfile, "\n" );
-        fclose(statsfile);
-    }
-#endif
-}
-#else
-static
 void encode_mb_row(VP8_COMP *cpi,
                    VP8_COMMON *cm,
                    int mb_row,
@@ -781,7 +561,6 @@
     }
 #endif
 }
-#endif /* CONFIG_SUPERBLOCKS */
 
 void init_encode_frame_mb_context(VP8_COMP *cpi)
 {
@@ -959,20 +738,6 @@
         vpx_usec_timer_start(&emr_timer);
 
         {
-#if CONFIG_SUPERBLOCKS
-            // for each superblock row in the image
-            for (mb_row = 0; mb_row < cm->mb_rows; mb_row+=2)
-             {
-                int offset = cm->mb_cols - 1 + (cm->mb_cols & 0x1);
-
-                encode_sb_row(cpi, cm, mb_row, x, xd, &tp, &totalrate);
-
-                // adjust to the next row of SBs
-                x->src.y_buffer += 16 * x->src.y_stride - 16 * offset;
-                x->src.u_buffer += 8 * x->src.uv_stride - 8 * offset;
-                x->src.v_buffer += 8 * x->src.uv_stride - 8 * offset;
-            }
-#else
             // for each macroblock row in the image
             for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
             {
@@ -983,7 +748,6 @@
                 x->src.u_buffer += 8 * x->src.uv_stride - 8 * cm->mb_cols;
                 x->src.v_buffer += 8 * x->src.uv_stride - 8 * cm->mb_cols;
             }
-#endif  // CONFIG_SUPERBLOCKS
 
             cpi->tok_count = tp - cpi->tok;
 
--- a/vp8/encoder/encodeintra.c
+++ b/vp8/encoder/encodeintra.c
@@ -101,9 +101,7 @@
     int i;
 
     MACROBLOCKD *x = &mb->e_mbd;
-#if !CONFIG_SUPERBLOCKS
     vp8_intra_prediction_down_copy(x);
-#endif
 
     for (i = 0; i < 16; i++)
         vp8_encode_intra4x4block(rtcd, mb, i);
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -874,11 +874,6 @@
         int this_rd;
         int ratey;
 
-#if CONFIG_SUPERBLOCKS
-        // Ignore modes thact need the above-right data
-        if (mode==B_LD_PRED || mode==B_VL_PRED)
-            continue;
-#endif
         rate = bmode_costs[mode];
 
 #if CONFIG_COMP_INTRA_PRED
@@ -960,9 +955,7 @@
     ta = (ENTROPY_CONTEXT *)&t_above;
     tl = (ENTROPY_CONTEXT *)&t_left;
 
-#if !CONFIG_SUPERBLOCKS
     vp8_intra_prediction_down_copy(xd);
-#endif
 
     bmode_costs = mb->inter_bmode_costs;