diff options
Diffstat (limited to 'vp8/encoder/encodeframe.c')
-rw-r--r-- | vp8/encoder/encodeframe.c | 104 |
1 files changed, 34 insertions, 70 deletions
diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c index f784cf434..0910cfd35 100644 --- a/vp8/encoder/encodeframe.c +++ b/vp8/encoder/encodeframe.c @@ -120,8 +120,8 @@ static unsigned int tt_activity_measure(VP8_COMP *cpi, MACROBLOCK *x) { * lambda using a non-linear combination (e.g., the smallest, or second * smallest, etc.). */ - act = VARIANCE_INVOKE(&cpi->rtcd.variance, var16x16)(x->src.y_buffer, - x->src.y_stride, VP8_VAR_OFFS, 0, &sse); + act = vp8_variance16x16(x->src.y_buffer, x->src.y_stride, VP8_VAR_OFFS, 0, + &sse); act = act << 4; /* If the region is flat, lower the activity some more. */ @@ -222,7 +222,7 @@ static void calc_av_activity(VP8_COMP *cpi, int64_t activity_sum) { #if USE_ACT_INDEX // Calculate and activity index for each mb static void calc_activity_index(VP8_COMP *cpi, MACROBLOCK *x) { - VP8_COMMON *const cm = & cpi->common; + VP8_COMMON *const cm = &cpi->common; int mb_row, mb_col; int64_t act; @@ -276,9 +276,9 @@ static void calc_activity_index(VP8_COMP *cpi, MACROBLOCK *x) { // Loop through all MBs. Note activity of each, average activity and // calculate a normalized activity for each static void build_activity_map(VP8_COMP *cpi) { - MACROBLOCK *const x = & cpi->mb; + MACROBLOCK *const x = &cpi->mb; MACROBLOCKD *xd = &x->e_mbd; - VP8_COMMON *const cm = & cpi->common; + VP8_COMMON *const cm = &cpi->common; #if ALT_ACT_MEASURE YV12_BUFFER_CONFIG *new_yv12 = &cm->yv12_fb[cm->new_fb_idx]; @@ -411,7 +411,6 @@ static void update_state(VP8_COMP *cpi, MACROBLOCK *x, PICK_MODE_CONTEXT *ctx) { mbmi->mv[1].as_int = x->partition_info->bmi[15].second_mv.as_int; } -#if CONFIG_TX_SELECT { int segment_id = mbmi->segment_id; if (!segfeature_active(xd, segment_id, SEG_LVL_EOB) || @@ -421,7 +420,6 @@ static void update_state(VP8_COMP *cpi, MACROBLOCK *x, PICK_MODE_CONTEXT *ctx) { } } } -#endif if (cpi->common.frame_type == KEY_FRAME) { // Restore the coding modes to that held in the coding context @@ -1051,9 +1049,6 @@ static void encode_sb(VP8_COMP *cpi, cpi->inter_zz_count++; } - // TODO Partitioning is broken! - cpi->tplist[mb_row].stop = *tp; - #if CONFIG_SUPERBLOCKS if (xd->mode_info_context->mbmi.encoded_as_sb) { x->src.y_buffer += 32; @@ -1064,7 +1059,10 @@ static void encode_sb(VP8_COMP *cpi, x->partition_info += 2; xd->mode_info_context += 2; xd->prev_mode_info_context += 2; - + + (*tp)->Token = EOSB_TOKEN; + (*tp)++; + if (mb_row < cm->mb_rows) cpi->tplist[mb_row].stop = *tp; break; } #endif @@ -1086,6 +1084,9 @@ static void encode_sb(VP8_COMP *cpi, assert((xd->prev_mode_info_context - cpi->common.prev_mip) == (xd->mode_info_context - cpi->common.mip)); #endif + (*tp)->Token = EOSB_TOKEN; + (*tp)++; + if (mb_row < cm->mb_rows) cpi->tplist[mb_row].stop = *tp; } // debug output @@ -1216,9 +1217,9 @@ void encode_sb_row(VP8_COMP *cpi, } void init_encode_frame_mb_context(VP8_COMP *cpi) { - MACROBLOCK *const x = & cpi->mb; - VP8_COMMON *const cm = & cpi->common; - MACROBLOCKD *const xd = & x->e_mbd; + MACROBLOCK *const x = &cpi->mb; + VP8_COMMON *const cm = &cpi->common; + MACROBLOCKD *const xd = &x->e_mbd; // GF active flags data structure x->gf_active_ptr = (signed char *)cpi->gf_active_flags; @@ -1287,9 +1288,9 @@ void init_encode_frame_mb_context(VP8_COMP *cpi) { static void encode_frame_internal(VP8_COMP *cpi) { int mb_row; - MACROBLOCK *const x = & cpi->mb; - VP8_COMMON *const cm = & cpi->common; - MACROBLOCKD *const xd = & x->e_mbd; + MACROBLOCK *const x = &cpi->mb; + VP8_COMMON *const cm = &cpi->common; + MACROBLOCKD *const xd = &x->e_mbd; TOKENEXTRA *tp = cpi->tok; int totalrate; @@ -1339,37 +1340,18 @@ static void encode_frame_internal(VP8_COMP *cpi) { cpi->pred_filter_on_count = 0; cpi->pred_filter_off_count = 0; #endif -#if CONFIG_SWITCHABLE_INTERP vp8_zero(cpi->switchable_interp_count); -#endif - -#if 0 - // Experimental code - cpi->frame_distortion = 0; - cpi->last_mb_distortion = 0; -#endif xd->mode_info_context = cm->mi; xd->prev_mode_info_context = cm->prev_mi; -#if CONFIG_NEWMVENTROPY vp8_zero(cpi->NMVcount); -#else - vp8_zero(cpi->MVcount); - vp8_zero(cpi->MVcount_hp); -#endif vp8_zero(cpi->coef_counts); -#if CONFIG_HYBRIDTRANSFORM vp8_zero(cpi->hybrid_coef_counts); -#endif vp8_zero(cpi->coef_counts_8x8); -#if CONFIG_HYBRIDTRANSFORM8X8 vp8_zero(cpi->hybrid_coef_counts_8x8); -#endif vp8_zero(cpi->coef_counts_16x16); -#if CONFIG_HYBRIDTRANSFORM16X16 vp8_zero(cpi->hybrid_coef_counts_16x16); -#endif vp8cx_frame_init_quantizer(cpi); @@ -1390,11 +1372,9 @@ static void encode_frame_internal(VP8_COMP *cpi) { vpx_memset(cpi->rd_comp_pred_diff, 0, sizeof(cpi->rd_comp_pred_diff)); vpx_memset(cpi->single_pred_count, 0, sizeof(cpi->single_pred_count)); vpx_memset(cpi->comp_pred_count, 0, sizeof(cpi->comp_pred_count)); -#if CONFIG_TX_SELECT vpx_memset(cpi->txfm_count, 0, sizeof(cpi->txfm_count)); vpx_memset(cpi->txfm_count_8x8p, 0, sizeof(cpi->txfm_count_8x8p)); vpx_memset(cpi->rd_tx_select_diff, 0, sizeof(cpi->rd_tx_select_diff)); -#endif { struct vpx_usec_timer emr_timer; vpx_usec_timer_start(&emr_timer); @@ -1454,7 +1434,6 @@ static int check_dual_ref_flags(VP8_COMP *cpi) { } } -#if CONFIG_TX_SELECT static void reset_skip_txfm_size(VP8_COMP *cpi, TX_SIZE txfm_max) { VP8_COMMON *cm = &cpi->common; int mb_row, mb_col, mis = cm->mode_info_stride; @@ -1478,7 +1457,6 @@ static void reset_skip_txfm_size(VP8_COMP *cpi, TX_SIZE txfm_max) { } } } -#endif void vp8_encode_frame(VP8_COMP *cpi) { if (cpi->sf.RD) { @@ -1524,7 +1502,6 @@ void vp8_encode_frame(VP8_COMP *cpi) { txfm_type = ONLY_4X4; } else #endif -#if CONFIG_TX_SELECT /* FIXME (rbultje) * this is a hack (no really), basically to work around the complete * nonsense coefficient cost prediction for keyframes. The probabilities @@ -1572,16 +1549,11 @@ void vp8_encode_frame(VP8_COMP *cpi) { cpi->rd_tx_select_threshes[frame_type][TX_MODE_SELECT] ? ALLOW_16X16 : TX_MODE_SELECT; #endif -#else - txfm_type = ALLOW_16X16; -#endif // CONFIG_TX_SELECT cpi->common.txfm_mode = txfm_type; -#if CONFIG_TX_SELECT if (txfm_type != TX_MODE_SELECT) { cpi->common.prob_tx[0] = 128; cpi->common.prob_tx[1] = 128; } -#endif cpi->common.comp_pred_mode = pred_type; encode_frame_internal(cpi); @@ -1591,7 +1563,6 @@ void vp8_encode_frame(VP8_COMP *cpi) { cpi->rd_prediction_type_threshes[frame_type][i] >>= 1; } -#if CONFIG_TX_SELECT for (i = 0; i < NB_TXFM_MODES; ++i) { int64_t pd = cpi->rd_tx_select_diff[i]; int diff; @@ -1601,7 +1572,6 @@ void vp8_encode_frame(VP8_COMP *cpi) { cpi->rd_tx_select_threshes[frame_type][i] += diff; cpi->rd_tx_select_threshes[frame_type][i] /= 2; } -#endif if (cpi->common.comp_pred_mode == HYBRID_PREDICTION) { int single_count_zero = 0; @@ -1619,7 +1589,6 @@ void vp8_encode_frame(VP8_COMP *cpi) { } } -#if CONFIG_TX_SELECT if (cpi->common.txfm_mode == TX_MODE_SELECT) { const int count4x4 = cpi->txfm_count[TX_4X4] + cpi->txfm_count_8x8p[TX_4X4]; const int count8x8 = cpi->txfm_count[TX_8X8]; @@ -1636,7 +1605,6 @@ void vp8_encode_frame(VP8_COMP *cpi) { cpi->common.txfm_mode = ALLOW_16X16; } } -#endif } else { encode_frame_internal(cpi); } @@ -1719,7 +1687,7 @@ void vp8_build_block_offsets(MACROBLOCK *x) { } static void sum_intra_stats(VP8_COMP *cpi, MACROBLOCK *x) { - const MACROBLOCKD *xd = & x->e_mbd; + const MACROBLOCKD *xd = &x->e_mbd; const MB_PREDICTION_MODE m = xd->mode_info_context->mbmi.mode; const MB_PREDICTION_MODE uvm = xd->mode_info_context->mbmi.uv_mode; @@ -1928,7 +1896,7 @@ void vp8cx_encode_intra_super_block(VP8_COMP *cpi, update_sb_skip_coeff_state(cpi, x, ta, tl, tp, t, skip); } } -#endif +#endif /* CONFIG_SUPERBLOCKS */ void vp8cx_encode_intra_macro_block(VP8_COMP *cpi, MACROBLOCK *x, @@ -1939,29 +1907,27 @@ void vp8cx_encode_intra_macro_block(VP8_COMP *cpi, adjust_act_zbin(cpi, x); vp8_update_zbin_extra(cpi, x); } - if (mbmi->mode == I8X8_PRED) { vp8_encode_intra8x8mby(IF_RTCD(&cpi->rtcd), x); vp8_encode_intra8x8mbuv(IF_RTCD(&cpi->rtcd), x); - } else if (mbmi->mode == B_PRED) + } else if (mbmi->mode == B_PRED) { + vp8_intra_prediction_down_copy(&x->e_mbd); vp8_encode_intra4x4mby(IF_RTCD(&cpi->rtcd), x); - else + } else { vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x); + } if (mbmi->mode != I8X8_PRED) { vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x); } if (output_enabled) { -#if CONFIG_TX_SELECT int segment_id = mbmi->segment_id; -#endif // Tokenize sum_intra_stats(cpi, x); vp8_tokenize_mb(cpi, &x->e_mbd, t, 0); -#if CONFIG_TX_SELECT if (cpi->common.txfm_mode == TX_MODE_SELECT && !((cpi->common.mb_no_coeff_skip && mbmi->mb_skip_coeff) || (segfeature_active(&x->e_mbd, segment_id, SEG_LVL_EOB) && @@ -1971,9 +1937,7 @@ void vp8cx_encode_intra_macro_block(VP8_COMP *cpi, } else if (mbmi->mode == I8X8_PRED) { cpi->txfm_count_8x8p[mbmi->txfm_size]++; } - } else -#endif - if (cpi->common.txfm_mode >= ALLOW_16X16 && mbmi->mode <= TM_PRED) { + } else if (cpi->common.txfm_mode >= ALLOW_16X16 && mbmi->mode <= TM_PRED) { mbmi->txfm_size = TX_16X16; } else if (cpi->common.txfm_mode >= ALLOW_8X8 && mbmi->mode != B_PRED) { @@ -2008,9 +1972,7 @@ void vp8cx_encode_inter_macroblock (VP8_COMP *cpi, MACROBLOCK *x, assert(!xd->mode_info_context->mbmi.encoded_as_sb); #endif -#if CONFIG_SWITCHABLE_INTERP vp8_setup_interp_filters(xd, mbmi->interp_filter, cm); -#endif if (cpi->oxcf.tuning == VP8_TUNE_SSIM) { // Adjust the zbin based on this MB rate. adjust_act_zbin(cpi, x); @@ -2047,6 +2009,7 @@ void vp8cx_encode_inter_macroblock (VP8_COMP *cpi, MACROBLOCK *x, if (mbmi->ref_frame == INTRA_FRAME) { if (mbmi->mode == B_PRED) { + vp8_intra_prediction_down_copy(xd); vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x); vp8_encode_intra4x4mby(IF_RTCD(&cpi->rtcd), x); } else if (mbmi->mode == I8X8_PRED) { @@ -2153,7 +2116,6 @@ void vp8cx_encode_inter_macroblock (VP8_COMP *cpi, MACROBLOCK *x, } if (output_enabled) { -#if CONFIG_TX_SELECT int segment_id = mbmi->segment_id; if (cpi->common.txfm_mode == TX_MODE_SELECT && !((cpi->common.mb_no_coeff_skip && mbmi->mb_skip_coeff) || @@ -2162,16 +2124,18 @@ void vp8cx_encode_inter_macroblock (VP8_COMP *cpi, MACROBLOCK *x, if (mbmi->mode != B_PRED && mbmi->mode != I8X8_PRED && mbmi->mode != SPLITMV) { cpi->txfm_count[mbmi->txfm_size]++; - } else if (mbmi->mode == I8X8_PRED) { + } else if (mbmi->mode == I8X8_PRED || + (mbmi->mode == SPLITMV && + mbmi->partitioning != PARTITIONING_4X4)) { cpi->txfm_count_8x8p[mbmi->txfm_size]++; } - } else -#endif - if (mbmi->mode != B_PRED && mbmi->mode != I8X8_PRED && + } else if (mbmi->mode != B_PRED && mbmi->mode != I8X8_PRED && mbmi->mode != SPLITMV && cpi->common.txfm_mode >= ALLOW_16X16) { mbmi->txfm_size = TX_16X16; - } else if (mbmi->mode != B_PRED && mbmi->mode != SPLITMV && - cpi->common.txfm_mode >= ALLOW_8X8) { + } else if (mbmi->mode != B_PRED && + !(mbmi->mode == SPLITMV && + mbmi->partitioning == PARTITIONING_4X4) && + cpi->common.txfm_mode >= ALLOW_8X8) { mbmi->txfm_size = TX_8X8; } else { mbmi->txfm_size = TX_4X4; |