Commit 4a26b240 authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Using 2 instead of 3 elements for avg_frame_qindex array.

The third array element was unused. 2 elements now: key- and interframe.

Change-Id: I5b8b9f5d889cc96a204cedfc432059293256298e
parent 74d47a81
......@@ -187,15 +187,12 @@ static void update_buffer_level(VP9_COMP *cpi, int encoded_frame_size) {
void vp9_rc_init(const VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) {
if (pass == 0 && oxcf->rc_mode == RC_MODE_CBR) {
rc->avg_frame_qindex[0] = oxcf->worst_allowed_q;
rc->avg_frame_qindex[1] = oxcf->worst_allowed_q;
rc->avg_frame_qindex[2] = oxcf->worst_allowed_q;
rc->avg_frame_qindex[KEY_FRAME] = oxcf->worst_allowed_q;
rc->avg_frame_qindex[INTER_FRAME] = oxcf->worst_allowed_q;
} else {
rc->avg_frame_qindex[0] = (oxcf->worst_allowed_q +
rc->avg_frame_qindex[KEY_FRAME] = (oxcf->worst_allowed_q +
oxcf->best_allowed_q) / 2;
rc->avg_frame_qindex[1] = (oxcf->worst_allowed_q +
oxcf->best_allowed_q) / 2;
rc->avg_frame_qindex[2] = (oxcf->worst_allowed_q +
rc->avg_frame_qindex[INTER_FRAME] = (oxcf->worst_allowed_q +
oxcf->best_allowed_q) / 2;
}
......@@ -1084,22 +1081,22 @@ void vp9_rc_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) {
rc->last_q[KEY_FRAME] = qindex;
rc->avg_frame_qindex[KEY_FRAME] =
ROUND_POWER_OF_TWO(3 * rc->avg_frame_qindex[KEY_FRAME] + qindex, 2);
} else if (!rc->is_src_frame_alt_ref &&
(cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame) &&
!(cpi->use_svc && oxcf->rc_mode == RC_MODE_CBR)) {
rc->avg_frame_qindex[2] =
ROUND_POWER_OF_TWO(3 * rc->avg_frame_qindex[2] + qindex, 2);
} else {
if (rc->is_src_frame_alt_ref ||
!(cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame) ||
(cpi->use_svc && oxcf->rc_mode == RC_MODE_CBR)) {
rc->last_q[INTER_FRAME] = qindex;
rc->avg_frame_qindex[INTER_FRAME] =
ROUND_POWER_OF_TWO(3 * rc->avg_frame_qindex[INTER_FRAME] + qindex, 2);
rc->ni_frames++;
rc->tot_q += vp9_convert_qindex_to_q(qindex);
rc->avg_q = rc->tot_q / rc->ni_frames;
// Calculate the average Q for normal inter frames (not key or GFU frames).
// Calculate the average Q for normal inter frames (not key or GFU
// frames).
rc->ni_tot_qi += qindex;
rc->ni_av_qi = rc->ni_tot_qi / rc->ni_frames;
}
}
// Keep record of last boosted (KF/KF/ARF) Q value.
// If the current frame is coded at a lower Q then we also update it.
......
......@@ -61,7 +61,7 @@ typedef struct {
int ni_av_qi;
int ni_tot_qi;
int ni_frames;
int avg_frame_qindex[3]; // 0 - KEY, 1 - INTER, 2 - ARF/GF
int avg_frame_qindex[FRAME_TYPES];
double tot_q;
double avg_q;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment