Commit 1ee49167 authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Cleaning up vp9_get_second_pass_params() function.

Change-Id: Ie7b295190d8def447408e575ea0f3fa3c7eb7dd2
parent 5ccd1932
...@@ -2385,22 +2385,23 @@ void vp9_get_first_pass_params(VP9_COMP *cpi) { ...@@ -2385,22 +2385,23 @@ void vp9_get_first_pass_params(VP9_COMP *cpi) {
} }
void vp9_get_second_pass_params(VP9_COMP *cpi) { void vp9_get_second_pass_params(VP9_COMP *cpi) {
int tmp_q; VP9_COMMON *const cm = &cpi->common;
int frames_left = (int)(cpi->twopass.total_stats.count - RATE_CONTROL *const rc = &cpi->rc;
cpi->common.current_video_frame); struct twopass_rc *const twopass = &cpi->twopass;
const int frames_left = (int)(twopass->total_stats.count -
cm->current_video_frame);
FIRSTPASS_STATS this_frame; FIRSTPASS_STATS this_frame;
FIRSTPASS_STATS this_frame_copy; FIRSTPASS_STATS this_frame_copy;
RATE_CONTROL *rc = &cpi->rc;
double this_frame_intra_error; double this_frame_intra_error;
double this_frame_coded_error; double this_frame_coded_error;
if (!cpi->twopass.stats_in) if (!twopass->stats_in)
return; return;
if (cpi->refresh_alt_ref_frame) { if (cpi->refresh_alt_ref_frame) {
cpi->common.frame_type = INTER_FRAME; cm->frame_type = INTER_FRAME;
rc->per_frame_bandwidth = cpi->twopass.gf_bits; rc->per_frame_bandwidth = twopass->gf_bits;
return; return;
} }
...@@ -2408,13 +2409,12 @@ void vp9_get_second_pass_params(VP9_COMP *cpi) { ...@@ -2408,13 +2409,12 @@ void vp9_get_second_pass_params(VP9_COMP *cpi) {
if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) { if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) {
rc->active_worst_quality = cpi->oxcf.cq_level; rc->active_worst_quality = cpi->oxcf.cq_level;
} else if (cpi->common.current_video_frame == 0) { } else if (cm->current_video_frame == 0) {
// Special case code for first frame. // Special case code for first frame.
int section_target_bandwidth = const int section_target_bandwidth = (int)(twopass->bits_left /
(int)(cpi->twopass.bits_left / frames_left); frames_left);
const int tmp_q = estimate_max_q(cpi, &twopass->total_left_stats,
tmp_q = estimate_max_q(cpi, &cpi->twopass.total_left_stats, section_target_bandwidth);
section_target_bandwidth);
rc->active_worst_quality = tmp_q; rc->active_worst_quality = tmp_q;
rc->ni_av_qi = tmp_q; rc->ni_av_qi = tmp_q;
...@@ -2428,7 +2428,7 @@ void vp9_get_second_pass_params(VP9_COMP *cpi) { ...@@ -2428,7 +2428,7 @@ void vp9_get_second_pass_params(VP9_COMP *cpi) {
// adjust_maxq_qrange(cpi); // adjust_maxq_qrange(cpi);
} }
vp9_zero(this_frame); vp9_zero(this_frame);
if (EOF == input_stats(&cpi->twopass, &this_frame)) if (EOF == input_stats(twopass, &this_frame))
return; return;
this_frame_intra_error = this_frame.intra_error; this_frame_intra_error = this_frame.intra_error;
...@@ -2436,12 +2436,12 @@ void vp9_get_second_pass_params(VP9_COMP *cpi) { ...@@ -2436,12 +2436,12 @@ void vp9_get_second_pass_params(VP9_COMP *cpi) {
// keyframe and section processing ! // keyframe and section processing !
if (rc->frames_to_key == 0 || if (rc->frames_to_key == 0 ||
(cpi->common.frame_flags & FRAMEFLAGS_KEY)) { (cm->frame_flags & FRAMEFLAGS_KEY)) {
// Define next KF group and assign bits to it // Define next KF group and assign bits to it
this_frame_copy = this_frame; this_frame_copy = this_frame;
find_next_key_frame(cpi, &this_frame_copy); find_next_key_frame(cpi, &this_frame_copy);
} else { } else {
cpi->common.frame_type = INTER_FRAME; cm->frame_type = INTER_FRAME;
} }
// Is this a GF / ARF (Note that a KF is always also a GF) // Is this a GF / ARF (Note that a KF is always also a GF)
...@@ -2459,10 +2459,10 @@ void vp9_get_second_pass_params(VP9_COMP *cpi) { ...@@ -2459,10 +2459,10 @@ void vp9_get_second_pass_params(VP9_COMP *cpi) {
} }
#endif #endif
if (cpi->twopass.gf_zeromotion_pct > 995) { if (twopass->gf_zeromotion_pct > 995) {
// As long as max_thresh for encode breakout is small enough, it is ok // As long as max_thresh for encode breakout is small enough, it is ok
// to enable it for no-show frame, i.e. set enable_encode_breakout to 2. // to enable it for no-show frame, i.e. set enable_encode_breakout to 2.
if (!cpi->common.show_frame) if (!cm->show_frame)
cpi->enable_encode_breakout = 0; cpi->enable_encode_breakout = 0;
else else
cpi->enable_encode_breakout = 2; cpi->enable_encode_breakout = 2;
...@@ -2478,13 +2478,13 @@ void vp9_get_second_pass_params(VP9_COMP *cpi) { ...@@ -2478,13 +2478,13 @@ void vp9_get_second_pass_params(VP9_COMP *cpi) {
} }
// Keep a globally available copy of this and the next frame's iiratio. // Keep a globally available copy of this and the next frame's iiratio.
cpi->twopass.this_iiratio = (int)(this_frame_intra_error / twopass->this_iiratio = (int)(this_frame_intra_error /
DOUBLE_DIVIDE_CHECK(this_frame_coded_error)); DOUBLE_DIVIDE_CHECK(this_frame_coded_error));
{ {
FIRSTPASS_STATS next_frame; FIRSTPASS_STATS next_frame;
if (lookup_next_frame_stats(&cpi->twopass, &next_frame) != EOF) { if (lookup_next_frame_stats(twopass, &next_frame) != EOF) {
cpi->twopass.next_iiratio = (int)(next_frame.intra_error / twopass->next_iiratio = (int)(next_frame.intra_error /
DOUBLE_DIVIDE_CHECK(next_frame.coded_error)); DOUBLE_DIVIDE_CHECK(next_frame.coded_error));
} }
} }
...@@ -2495,7 +2495,7 @@ void vp9_get_second_pass_params(VP9_COMP *cpi) { ...@@ -2495,7 +2495,7 @@ void vp9_get_second_pass_params(VP9_COMP *cpi) {
cpi->target_bandwidth = 0; cpi->target_bandwidth = 0;
// Update the total stats remaining structure // Update the total stats remaining structure
subtract_stats(&cpi->twopass.total_left_stats, &this_frame); subtract_stats(&twopass->total_left_stats, &this_frame);
} }
void vp9_twopass_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) { void vp9_twopass_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) {
......
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