From 646e62211ead802e9898b2fdaa50c5a08769c8a7 Mon Sep 17 00:00:00 2001 From: Paul Wilkins Date: Sun, 26 Feb 2012 01:15:47 +0000 Subject: [PATCH] Code Cleanup. Removal of error_resilient_mode features. The interface has been left in place but does nothing. Change-Id: I2407863bd0d3c98407354507423ca48d29f63b17 --- vp8/common/onyx.h | 6 -- vp8/encoder/bitstream.c | 182 ++++------------------------------------ vp8/encoder/firstpass.c | 36 +------- vp8/encoder/onyx_if.c | 28 ++----- vp8/encoder/ratectrl.c | 3 +- vp8/vp8_cx_iface.c | 2 - 6 files changed, 29 insertions(+), 228 deletions(-) diff --git a/vp8/common/onyx.h b/vp8/common/onyx.h index 97f71080f..53a3d23cc 100644 --- a/vp8/common/onyx.h +++ b/vp8/common/onyx.h @@ -170,12 +170,6 @@ extern "C" int token_partitions; // how many token partitions to create for multi core decoding int encode_breakout; // early breakout encode threshold : for video conf recommend 800 - unsigned int error_resilient_mode; // Bitfield defining the error - // resiliency features to enable. Can provide - // decodable frames after losses in previous - // frames and decodable partitions after - // losses in the same frame. - int arnr_max_frames; int arnr_strength ; int arnr_type ; diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c index 72bc3d41d..ff83794c1 100644 --- a/vp8/encoder/bitstream.c +++ b/vp8/encoder/bitstream.c @@ -1931,84 +1931,6 @@ static int prob_update_savings(const unsigned int *ct, return old_b - new_b - update_b; } -static int independent_coef_context_savings(VP8_COMP *cpi) -{ - int savings = 0; - int i = 0; - do - { - int j = 0; - do - { - int k = 0; - unsigned int prev_coef_count_sum[MAX_ENTROPY_TOKENS] = {0}; - int prev_coef_savings[MAX_ENTROPY_TOKENS] = {0}; - /* Calculate new probabilities given the constraint that - * they must be equal over the prev coef contexts - */ - if (cpi->common.frame_type == KEY_FRAME) - { - /* Reset to default probabilities at key frames */ - sum_probs_over_prev_coef_context(default_coef_counts[i][j], - prev_coef_count_sum); - } - else - { - sum_probs_over_prev_coef_context(cpi->coef_counts[i][j], - prev_coef_count_sum); - } - do - { - /* at every context */ - - /* calc probs and branch cts for this frame only */ - //vp8_prob new_p [ENTROPY_NODES]; - //unsigned int branch_ct [ENTROPY_NODES] [2]; - - int t = 0; /* token/prob index */ - - vp8_tree_probs_from_distribution( - MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree, - cpi->frame_coef_probs[i][j][k], - cpi->frame_branch_ct [i][j][k], - prev_coef_count_sum, - 256, 1); - - do - { - const unsigned int *ct = cpi->frame_branch_ct [i][j][k][t]; - const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t]; - const vp8_prob oldp = cpi->common.fc.coef_probs [i][j][k][t]; - const vp8_prob upd = vp8_coef_update_probs [i][j][k][t]; - const int s = prob_update_savings(ct, oldp, newp, upd); - - if (cpi->common.frame_type != KEY_FRAME || - (cpi->common.frame_type == KEY_FRAME && newp != oldp)) - prev_coef_savings[t] += s; - } - while (++t < ENTROPY_NODES); - } - while (++k < PREV_COEF_CONTEXTS); - k = 0; - do - { - /* We only update probabilities if we can save bits, except - * for key frames where we have to update all probabilities - * to get the equal probabilities across the prev coef - * contexts. - */ - if (prev_coef_savings[k] > 0 || - cpi->common.frame_type == KEY_FRAME) - savings += prev_coef_savings[k]; - } - while (++k < ENTROPY_NODES); - } - while (++j < COEF_BANDS); - } - while (++i < BLOCK_TYPES); - return savings; -} - static int default_coef_context_savings(VP8_COMP *cpi) { int savings = 0; @@ -2138,11 +2060,7 @@ int vp8_estimate_entropy_savings(VP8_COMP *cpi) cm->prob_gf_coded = new_gf_alt; } - if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS) - savings += independent_coef_context_savings(cpi); - else - savings += default_coef_context_savings(cpi); - + savings += default_coef_context_savings(cpi); #if CONFIG_T8X8 /* do not do this if not evena allowed */ @@ -2221,25 +2139,6 @@ static void update_coef_probs(VP8_COMP *cpi) { int k = 0; int prev_coef_savings[ENTROPY_NODES] = {0}; - if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS) - { - for (k = 0; k < PREV_COEF_CONTEXTS; ++k) - { - int t; /* token/prob index */ - for (t = 0; t < ENTROPY_NODES; ++t) - { - const unsigned int *ct = cpi->frame_branch_ct [i][j] - [k][t]; - const vp8_prob newp = cpi->frame_coef_probs[i][j][k][t]; - const vp8_prob oldp = cpi->common.fc.coef_probs[i][j] - [k][t]; - const vp8_prob upd = vp8_coef_update_probs[i][j][k][t]; - prev_coef_savings[t] += - prob_update_savings(ct, oldp, newp, upd); - } - } - k = 0; - } do { //note: use result from vp8_estimate_entropy_savings, so no need to call vp8_tree_probs_from_distribution here. @@ -2260,23 +2159,14 @@ static void update_coef_probs(VP8_COMP *cpi) const vp8_prob upd = vp8_coef_update_probs [i][j][k][t]; int s = prev_coef_savings[t]; int u = 0; - if (!(cpi->oxcf.error_resilient_mode & - VPX_ERROR_RESILIENT_PARTITIONS)) - { - s = prob_update_savings( - cpi->frame_branch_ct [i][j][k][t], - *Pold, newp, upd); - } + + s = prob_update_savings( + cpi->frame_branch_ct [i][j][k][t], + *Pold, newp, upd); + if (s > 0) u = 1; - /* Force updates on key frames if the new is different, - * so that we can be sure we end up with equal probabilities - * over the prev coef contexts. - */ - if ((cpi->oxcf.error_resilient_mode & - VPX_ERROR_RESILIENT_PARTITIONS) && - cpi->common.frame_type == KEY_FRAME && newp != *Pold) - u = 1; + update += u; } while (++t < ENTROPY_NODES); @@ -2303,25 +2193,7 @@ static void update_coef_probs(VP8_COMP *cpi) { int k = 0; int prev_coef_savings[ENTROPY_NODES] = {0}; - if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS) - { - for (k = 0; k < PREV_COEF_CONTEXTS; ++k) - { - int t; /* token/prob index */ - for (t = 0; t < ENTROPY_NODES; ++t) - { - const unsigned int *ct = cpi->frame_branch_ct [i][j] - [k][t]; - const vp8_prob newp = cpi->frame_coef_probs[i][j][k][t]; - const vp8_prob oldp = cpi->common.fc.coef_probs[i][j] - [k][t]; - const vp8_prob upd = vp8_coef_update_probs[i][j][k][t]; - prev_coef_savings[t] += - prob_update_savings(ct, oldp, newp, upd); - } - } - k = 0; - } + do { //note: use result from vp8_estimate_entropy_savings, so no need to call vp8_tree_probs_from_distribution here. @@ -2343,23 +2215,14 @@ static void update_coef_probs(VP8_COMP *cpi) const vp8_prob upd = vp8_coef_update_probs [i][j][k][t]; int s = prev_coef_savings[t]; int u = 0; - if (!(cpi->oxcf.error_resilient_mode & - VPX_ERROR_RESILIENT_PARTITIONS)) - { - s = prob_update_savings( - cpi->frame_branch_ct [i][j][k][t], - *Pold, newp, upd); - } + + s = prob_update_savings( + cpi->frame_branch_ct [i][j][k][t], + *Pold, newp, upd); + if (s > 0) u = 1; - /* Force updates on key frames if the new is different, - * so that we can be sure we end up with equal probabilities - * over the prev coef contexts. - */ - if ((cpi->oxcf.error_resilient_mode & - VPX_ERROR_RESILIENT_PARTITIONS) && - cpi->common.frame_type == KEY_FRAME && newp != *Pold) - u = 1; + vp8_write(w, u, upd); #ifdef ENTROPY_STATS ++ tree_update_hist [i][j][k][t] [u]; @@ -2850,8 +2713,7 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size) if (xd->mode_ref_lf_delta_enabled) { // Do the deltas need to be updated - int send_update = xd->mode_ref_lf_delta_update - || cpi->oxcf.error_resilient_mode; + int send_update = xd->mode_ref_lf_delta_update; vp8_write_bit(bc, send_update); if (send_update) @@ -2864,8 +2726,7 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size) Data = xd->ref_lf_deltas[i]; // Frame level data - if (xd->ref_lf_deltas[i] != xd->last_ref_lf_deltas[i] - || cpi->oxcf.error_resilient_mode) + if (xd->ref_lf_deltas[i] != xd->last_ref_lf_deltas[i]) { xd->last_ref_lf_deltas[i] = xd->ref_lf_deltas[i]; vp8_write_bit(bc, 1); @@ -2891,8 +2752,7 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size) { Data = xd->mode_lf_deltas[i]; - if (xd->mode_lf_deltas[i] != xd->last_mode_lf_deltas[i] - || cpi->oxcf.error_resilient_mode) + if (xd->mode_lf_deltas[i] != xd->last_mode_lf_deltas[i]) { xd->last_mode_lf_deltas[i] = xd->mode_lf_deltas[i]; vp8_write_bit(bc, 1); @@ -2952,14 +2812,6 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size) #endif } - if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS) - { - if (pc->frame_type == KEY_FRAME) - pc->refresh_entropy_probs = 1; - else - pc->refresh_entropy_probs = 0; - } - vp8_write_bit(bc, pc->refresh_entropy_probs); if (pc->frame_type != KEY_FRAME) diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c index ef0d3d745..b5e81cd6e 100644 --- a/vp8/encoder/firstpass.c +++ b/vp8/encoder/firstpass.c @@ -2353,19 +2353,6 @@ void vp8_second_pass(VP8_COMP *cpi) // Define next KF group and assign bits to it vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame)); find_next_key_frame(cpi, &this_frame_copy); - - // Special case: Error error_resilient_mode mode does not make much sense for two pass but with its current meaning but this code is designed to stop - // outlandish behaviour if someone does set it when using two pass. It effectively disables GF groups. - // This is temporary code till we decide what should really happen in this case. - if (cpi->oxcf.error_resilient_mode) - { - cpi->twopass.gf_group_bits = cpi->twopass.kf_group_bits; - cpi->twopass.gf_group_error_left = cpi->twopass.kf_group_error_left; - cpi->baseline_gf_interval = cpi->twopass.frames_to_key; - cpi->frames_till_gf_update_due = cpi->baseline_gf_interval; - cpi->source_alt_ref_pending = FALSE; - } - } // Is this a GF / ARF (Note that a KF is always also a GF) @@ -2391,26 +2378,9 @@ void vp8_second_pass(VP8_COMP *cpi) // Otherwise this is an ordinary frame else { - // Special case: Error error_resilient_mode mode does not make much sense for two pass but with its current meaning but this code is designed to stop - // outlandish behaviour if someone does set it when using two pass. It effectively disables GF groups. - // This is temporary code till we decide what should really happen in this case. - if (cpi->oxcf.error_resilient_mode) - { - cpi->frames_till_gf_update_due = cpi->twopass.frames_to_key; - - if (cpi->common.frame_type != KEY_FRAME) - { - // Assign bits from those allocated to the GF group - vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame)); - assign_std_frame_bits(cpi, &this_frame_copy); - } - } - else - { - // Assign bits from those allocated to the GF group - vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame)); - assign_std_frame_bits(cpi, &this_frame_copy); - } + // Assign bits from those allocated to the GF group + vpx_memcpy(&this_frame_copy, &this_frame, sizeof(this_frame)); + assign_std_frame_bits(cpi, &this_frame_copy); } // Keep a globally available copy of this and the next frame's iiratio. diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 837a39515..834819125 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -3425,10 +3425,8 @@ static void encode_frame_to_data_rate // For inter frames the current default behavior is that when // cm->refresh_golden_frame is set we copy the old GF over to the ARF buffer // This is purely an encoder decision at present. - if (!cpi->oxcf.error_resilient_mode && cm->refresh_golden_frame) + if (cm->refresh_golden_frame) cm->copy_buffer_to_arf = 2; - else - cm->copy_buffer_to_arf = 0; cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx]; @@ -3447,11 +3445,6 @@ static void encode_frame_to_data_rate update_reference_frames(cm); - if (cpi->oxcf.error_resilient_mode) - { - cm->refresh_entropy_probs = 0; - } - // Work out the segment probabilites if segmentation is enabled and // the map is due to be updated if (xd->segmentation_enabled && xd->update_mb_segmentation_map) @@ -3714,16 +3707,12 @@ static void encode_frame_to_data_rate if (cpi->gold_is_alt) cpi->ref_frame_flags &= ~VP8_ALT_FLAG; - - if (!cpi->oxcf.error_resilient_mode) - { - if (cpi->oxcf.play_alternate && cm->refresh_alt_ref_frame && (cm->frame_type != KEY_FRAME)) - // Update the alternate reference frame stats as appropriate. - update_alt_ref_frame_stats(cpi); - else - // Update the Golden frame stats as appropriate. - update_golden_frame_stats(cpi); - } + if (cpi->oxcf.play_alternate && cm->refresh_alt_ref_frame && (cm->frame_type != KEY_FRAME)) + // Update the alternate reference frame stats as appropriate. + update_alt_ref_frame_stats(cpi); + else + // Update the Golden frame stats as appropriate. + update_golden_frame_stats(cpi); if (cm->frame_type == KEY_FRAME) { @@ -3948,8 +3937,7 @@ int vp8_get_compressed_data(VP8_PTR ptr, unsigned int *frame_flags, unsigned lon cpi->source = NULL; // Should we code an alternate reference frame - if (cpi->oxcf.error_resilient_mode == 0 && - cpi->oxcf.play_alternate && + if (cpi->oxcf.play_alternate && cpi->source_alt_ref_pending) { if ((cpi->source = vp8_lookahead_peek(cpi->lookahead, diff --git a/vp8/encoder/ratectrl.c b/vp8/encoder/ratectrl.c index 2a86fc014..05dc09e9b 100644 --- a/vp8/encoder/ratectrl.c +++ b/vp8/encoder/ratectrl.c @@ -373,8 +373,7 @@ static void calc_pframe_target_size(VP8_COMP *cpi) cpi->inter_frame_target = cpi->this_frame_target; // Adjust target frame size for Golden Frames: - if ( cpi->oxcf.error_resilient_mode == 0 && - (cpi->frames_till_gf_update_due == 0) ) + if ( cpi->frames_till_gf_update_due == 0 ) { //int Boost = 0; int Q = (cpi->oxcf.fixed_q < 0) ? cpi->last_q[INTER_FRAME] : cpi->oxcf.fixed_q; diff --git a/vp8/vp8_cx_iface.c b/vp8/vp8_cx_iface.c index 47d3f25f7..ba736485f 100644 --- a/vp8/vp8_cx_iface.c +++ b/vp8/vp8_cx_iface.c @@ -243,8 +243,6 @@ static vpx_codec_err_t set_vp8e_config(VP8_CONFIG *oxcf, oxcf->frame_rate = 30; } - oxcf->error_resilient_mode = cfg.g_error_resilient; - switch (cfg.g_pass) { case VPX_RC_ONE_PASS: