const int *const rfct = cpi->count_mb_ref_frame_usage;
const int rf_intra = rfct[INTRA_FRAME];
const int rf_inter = rfct[LAST_FRAME] + rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME];
- int new_intra, new_last, gf_last, oldtotal, newtotal;
+ int new_intra, new_last, new_gf_alt, oldtotal, newtotal;
int ref_frame_cost[MAX_REF_FRAMES];
vp8_clear_system_state(); //__asm emms;
+ // Estimate reference frame cost savings.
+ // For now this is just based on projected overall frequency of
+ // each reference frame coded using an unpredicted coding tree.
if (cpi->common.frame_type != KEY_FRAME)
{
-//#if CONFIG_SEGFEATURES
new_intra = (rf_intra + rf_inter)
? rf_intra * 255 / (rf_intra + rf_inter) : 1;
-
- if (!new_intra)
- new_intra = 1;
+ new_intra += !new_intra;
new_last = rf_inter ? (rfct[LAST_FRAME] * 255) / rf_inter : 128;
+ new_last += !new_last;
- gf_last = (rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME])
- ? (rfct[GOLDEN_FRAME] * 255) / (rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME]) : 128;
+ new_gf_alt = (rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME])
+ ? (rfct[GOLDEN_FRAME] * 255) /
+ (rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME]) : 128;
+ new_gf_alt += !new_gf_alt;
// new costs
ref_frame_cost[INTRA_FRAME] = vp8_cost_zero(new_intra);
+ vp8_cost_zero(new_last);
ref_frame_cost[GOLDEN_FRAME] = vp8_cost_one(new_intra)
+ vp8_cost_one(new_last)
- + vp8_cost_zero(gf_last);
+ + vp8_cost_zero(new_gf_alt);
ref_frame_cost[ALTREF_FRAME] = vp8_cost_one(new_intra)
+ vp8_cost_one(new_last)
- + vp8_cost_one(gf_last);
+ + vp8_cost_one(new_gf_alt);
newtotal =
rfct[INTRA_FRAME] * ref_frame_cost[INTRA_FRAME] +
rfct[GOLDEN_FRAME] * ref_frame_cost[GOLDEN_FRAME] +
rfct[ALTREF_FRAME] * ref_frame_cost[ALTREF_FRAME];
-
// old costs
ref_frame_cost[INTRA_FRAME] = vp8_cost_zero(cm->prob_intra_coded);
ref_frame_cost[LAST_FRAME] = vp8_cost_one(cm->prob_intra_coded)
rfct[ALTREF_FRAME] * ref_frame_cost[ALTREF_FRAME];
savings += (oldtotal - newtotal) / 256;
- }
+ // Update the reference frame probability numbers to reflect
+ // the observed counts in this frame. Doing this here insures
+ // that if there are multiple recode iterations the baseline
+ // probabilities used are updated in each iteration.
+ cm->prob_intra_coded = new_intra;
+ cm->prob_last_coded = new_last;
+ cm->prob_gf_coded = new_gf_alt;
+ }
if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS)
savings += independent_coef_context_savings(cpi);
}
#endif
- // Adjust the projected reference frame usage probability numbers to reflect
- // what we have just seen. This may be usefull when we make multiple itterations
- // of the recode loop rather than continuing to use values from the previous frame.
- if ((cm->frame_type != KEY_FRAME) && !cm->refresh_alt_ref_frame && !cm->refresh_golden_frame)
- {
- const int *const rfct = cpi->count_mb_ref_frame_usage;
- const int rf_intra = rfct[INTRA_FRAME];
- const int rf_inter = rfct[LAST_FRAME] + rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME];
-
- if ((rf_intra + rf_inter) > 0)
- {
- cm->prob_intra_coded = (rf_intra * 255) / (rf_intra + rf_inter);
-
- if (cm->prob_intra_coded < 1)
- cm->prob_intra_coded = 1;
-
- if ((cm->frames_since_golden > 0) || cpi->source_alt_ref_active)
- {
- cm->prob_last_coded =
- rf_inter ? (rfct[LAST_FRAME] * 255) / rf_inter : 128;
-
- if (cm->prob_last_coded < 1)
- cm->prob_last_coded = 1;
-
- cm->prob_gf_coded =
- (rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME])
- ? (rfct[GOLDEN_FRAME] * 255) /
- (rfct[GOLDEN_FRAME] + rfct[ALTREF_FRAME]) : 128;
-
- if (cm->prob_gf_coded < 1)
- cm->prob_gf_coded = 1;
- }
- }
-//#if CONFIG_SEGFEATURES
- else
- {
- // Trap case where cpi->count_mb_ref_frame_usage[] blank.
- cm->prob_intra_coded = 63;
- cm->prob_last_coded = 128;
- cm->prob_gf_coded = 128;
- }
- }
#if 0
// Keep record of the total distortion this time around for future use
cpi->last_frame_distortion = cpi->frame_distortion;