Commit 1e59cbf2 authored by Deb Mukherjee's avatar Deb Mukherjee

Rate control changes on active_worst_quality

Various cleanups and refactoring.
Removes feedback of active worst qaulity and uses last_q
instead to make the interface cleaner. Active worst quality
is now decided only once for a frame being coded in the
beginning based on last_q and other stats. Also, adds other
cleaups on last_q to store also the last_q for altref frames,
and reduces the altref interval a little.

The output does change a little.
derfraw300: +0.224% (global psnr)
stdhdraw250: +0.442% (global psnr)

Change-Id: Ie634cdc032697044c472dd0fe79c109b3e7f9767
parent 3755be94
......@@ -1460,7 +1460,7 @@ static void compute_fast_motion_search_level(VP9_COMP *cpi, BLOCK_SIZE bsize) {
// int use_8x8 = (MIN(cpi->common.width, cpi->common.height) < 720) ? 1 : 0;
int use_8x8 = 1;
if (cm->frame_type && !cpi->is_src_frame_alt_ref &&
if (cm->frame_type && !cpi->rc.is_src_frame_alt_ref &&
((use_8x8 && bsize == BLOCK_16X16) ||
bsize == BLOCK_32X32 || bsize == BLOCK_64X64)) {
int ref0 = 0, ref1 = 0, ref2 = 0, ref3 = 0;
......@@ -1949,7 +1949,7 @@ static void encode_sb_row(VP9_COMP *cpi, const TileInfo *const tile,
|| cm->prev_mi == 0
|| cpi->common.show_frame == 0
|| cpi->common.frame_type == KEY_FRAME
|| cpi->is_src_frame_alt_ref
|| cpi->rc.is_src_frame_alt_ref
|| ((cpi->sf.use_lastframe_partitioning ==
LAST_FRAME_PARTITION_LOW_MOTION) &&
sb_has_motion(cpi, prev_mi_8x8))) {
......@@ -2279,7 +2279,7 @@ static int get_frame_type(VP9_COMP *cpi) {
int frame_type;
if (frame_is_intra_only(&cpi->common))
frame_type = 0;
else if (cpi->is_src_frame_alt_ref && cpi->refresh_golden_frame)
else if (cpi->rc.is_src_frame_alt_ref && cpi->refresh_golden_frame)
frame_type = 3;
else if (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)
frame_type = 1;
......
This diff is collapsed.
......@@ -399,8 +399,7 @@ void vp9_update_mbgraph_stats(VP9_COMP *cpi) {
// being a GF - so exit if we don't look ahead beyond that
if (n_frames <= cpi->rc.frames_till_gf_update_due)
return;
if (n_frames > (int)cpi->frames_till_alt_ref_frame)
n_frames = cpi->frames_till_alt_ref_frame;
if (n_frames > MAX_LAG_BUFFERS)
n_frames = MAX_LAG_BUFFERS;
......
This diff is collapsed.
......@@ -294,7 +294,7 @@ typedef struct {
int this_frame_target;
int projected_frame_size;
int sb64_target_rate;
int last_q[2]; // Separate values for Intra/Inter
int last_q[3]; // Separate values for Intra/Inter/ARF-GF
int last_boosted_qindex; // Last boosted GF/KF/ARF q
int gfu_boost;
......@@ -306,13 +306,17 @@ typedef struct {
double gf_rate_correction_factor;
unsigned int frames_since_golden;
int frames_till_gf_update_due; // Count down till next GF
int max_gf_interval;
int baseline_gf_interval;
unsigned int frames_till_gf_update_due; // Count down till next GF
unsigned int max_gf_interval;
unsigned int baseline_gf_interval;
unsigned int frames_to_key;
unsigned int frames_since_key;
unsigned int this_key_frame_forced;
unsigned int next_key_frame_forced;
unsigned int source_alt_ref_pending;
unsigned int source_alt_ref_active;
unsigned int is_src_frame_alt_ref;
int64_t key_frame_count;
int prior_key_frame_distance[KEY_FRAME_CONTEXT];
int per_frame_bandwidth; // Current section per frame bandwidth target
int av_per_frame_bandwidth; // Average frame size target for clip
int min_frame_bandwidth; // Minimum allocation used for any frame
......@@ -320,7 +324,7 @@ typedef struct {
int ni_av_qi;
int ni_tot_qi;
int ni_frames;
int avg_frame_qindex;
int avg_frame_qindex[3]; // 0 - KEY, 1 - INTER, 2 - ARF/GF
double tot_q;
double avg_q;
......@@ -376,11 +380,7 @@ typedef struct VP9_COMP {
YV12_BUFFER_CONFIG *un_scaled_source;
YV12_BUFFER_CONFIG scaled_source;
unsigned int frames_till_alt_ref_frame;
int source_alt_ref_pending;
int source_alt_ref_active;
int is_src_frame_alt_ref;
unsigned int key_frame_frequency;
int gold_is_last; // gold same as last frame ( short circuit gold searches)
int alt_is_last; // Alt same as last ( short circuit altref search)
......@@ -405,11 +405,6 @@ typedef struct VP9_COMP {
TOKENEXTRA *tok;
unsigned int tok_count[4][1 << 6];
unsigned int frames_since_key;
unsigned int key_frame_frequency;
unsigned int this_key_frame_forced;
unsigned int next_key_frame_forced;
#if CONFIG_MULTIPLE_ARF
// Position within a frame coding order (including any additional ARF frames).
unsigned int sequence_number;
......@@ -472,9 +467,6 @@ typedef struct VP9_COMP {
vp9_coeff_probs_model frame_coef_probs[TX_SIZES][PLANE_TYPES];
vp9_coeff_stats frame_branch_ct[TX_SIZES][PLANE_TYPES];
int kf_zeromotion_pct;
int gf_zeromotion_pct;
int64_t target_bandwidth;
struct vpx_codec_pkt_list *output_pkt_list;
......@@ -547,7 +539,6 @@ typedef struct VP9_COMP {
double modified_error_left;
double kf_intra_err_min;
double gf_intra_err_min;
int frames_to_key;
int maxq_max_limit;
int maxq_min_limit;
int static_scene_max_gf_interval;
......@@ -568,6 +559,9 @@ typedef struct VP9_COMP {
int alt_extra_bits;
int sr_update_lag;
int kf_zeromotion_pct;
int gf_zeromotion_pct;
} twopass;
YV12_BUFFER_CONFIG alt_ref_buffer;
......
This diff is collapsed.
......@@ -42,18 +42,16 @@ void vp9_rc_compute_frame_size_bounds(const VP9_COMP *cpi,
// Picks q and q bounds given the target for bits
int vp9_rc_pick_q_and_adjust_q_bounds(const VP9_COMP *cpi,
int *bottom_index,
int *top_index,
int *top_index_prop);
int *top_index);
// Estimates q to achieve a target bits per frame
int vp9_rc_regulate_q(const VP9_COMP *cpi, int target_bits_per_frame,
int active_best_quality, int active_worst_quality);
// Post encode update of the rate control parameters based
// on bytes used and q used for the frame
// on bytes used
void vp9_rc_postencode_update(VP9_COMP *cpi,
uint64_t bytes_used,
int worst_q);
uint64_t bytes_used);
// estimates bits per mb for a given qindex and correction factor
int vp9_rc_bits_per_mb(FRAME_TYPE frame_type, int qindex,
......
......@@ -3351,7 +3351,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
// unless ARNR filtering is enabled in which case we want
// an unfiltered alternative. We allow near/nearest as well
// because they may result in zero-zero MVs but be cheaper.
if (cpi->is_src_frame_alt_ref && (cpi->oxcf.arnr_max_frames == 0)) {
if (cpi->rc.is_src_frame_alt_ref && (cpi->oxcf.arnr_max_frames == 0)) {
if ((this_mode != ZEROMV &&
!(this_mode == NEARMV &&
frame_mv[NEARMV][ALTREF_FRAME].as_int == 0) &&
......@@ -3998,7 +3998,7 @@ int64_t vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
// unless ARNR filtering is enabled in which case we want
// an unfiltered alternative. We allow near/nearest as well
// because they may result in zero-zero MVs but be cheaper.
if (cpi->is_src_frame_alt_ref && (cpi->oxcf.arnr_max_frames == 0))
if (cpi->rc.is_src_frame_alt_ref && (cpi->oxcf.arnr_max_frames == 0))
continue;
}
......
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