Commit bcfbd2f9 authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Replacing RC_MODE with vpx_rc_mode.

Both enums are identical.
Change-Id: I06653f9c90a2d3a2dd5c741e75b17ee7d066a56f
parent 39e28f9f
......@@ -538,7 +538,7 @@ static void init_config(struct VP9_COMP *cpi, VP9EncoderConfig *oxcf) {
cpi->svc.number_temporal_layers = oxcf->ts_number_layers;
if ((cpi->svc.number_temporal_layers > 1 &&
cpi->oxcf.rc_mode == RC_MODE_CBR) ||
cpi->oxcf.rc_mode == VPX_CBR) ||
(cpi->svc.number_spatial_layers > 1 &&
cpi->oxcf.mode == TWO_PASS_SECOND_BEST)) {
vp9_init_layer_context(cpi);
......@@ -609,7 +609,7 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) {
cpi->encode_breakout = cpi->oxcf.encode_breakout;
// local file playback mode == really big buffer
if (cpi->oxcf.rc_mode == RC_MODE_VBR) {
if (cpi->oxcf.rc_mode == VPX_VBR) {
cpi->oxcf.starting_buffer_level_ms = 60000;
cpi->oxcf.optimal_buffer_level_ms = 60000;
cpi->oxcf.maximum_buffer_size_ms = 240000;
......@@ -657,7 +657,7 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) {
update_frame_size(cpi);
if ((cpi->svc.number_temporal_layers > 1 &&
cpi->oxcf.rc_mode == RC_MODE_CBR) ||
cpi->oxcf.rc_mode == VPX_CBR) ||
(cpi->svc.number_spatial_layers > 1 && cpi->pass == 2)) {
vp9_update_layer_context_change_config(cpi,
(int)cpi->oxcf.target_bandwidth);
......@@ -1487,7 +1487,7 @@ static int recode_loop_test(const VP9_COMP *cpi,
if ((rc->projected_frame_size > high_limit && q < maxq) ||
(rc->projected_frame_size < low_limit && q > minq)) {
force_recode = 1;
} else if (cpi->oxcf.rc_mode == RC_MODE_CONSTRAINED_QUALITY) {
} else if (cpi->oxcf.rc_mode == VPX_CQ) {
// Deal with frame undershoot and whether or not we are
// below the automatically set cq level.
if (q > oxcf->cq_level &&
......@@ -1789,7 +1789,7 @@ static void encode_with_recode_loop(VP9_COMP *cpi,
frame_over_shoot_limit = 1;
}
if (cpi->oxcf.rc_mode == RC_MODE_CONSTANT_QUALITY) {
if (cpi->oxcf.rc_mode == VPX_Q) {
loop = 0;
} else {
if ((cm->frame_type == KEY_FRAME) &&
......@@ -1887,7 +1887,7 @@ static void encode_with_recode_loop(VP9_COMP *cpi,
// This should only trigger where there is very substantial
// undershoot on a frame and the auto cq level is above
// the user passsed in value.
if (cpi->oxcf.rc_mode == RC_MODE_CONSTRAINED_QUALITY &&
if (cpi->oxcf.rc_mode == VPX_CQ &&
q < q_low) {
q_low = q;
}
......@@ -2085,7 +2085,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
// For 1 pass CBR, check if we are dropping this frame.
// Never drop on key frame.
if (cpi->pass == 0 &&
cpi->oxcf.rc_mode == RC_MODE_CBR &&
cpi->oxcf.rc_mode == VPX_CBR &&
cm->frame_type != KEY_FRAME) {
if (vp9_rc_drop_frame(cpi)) {
vp9_rc_postencode_update_drop_frame(cpi);
......@@ -2281,7 +2281,7 @@ static void SvcEncode(VP9_COMP *cpi, size_t *size, uint8_t *dest,
static void Pass0Encode(VP9_COMP *cpi, size_t *size, uint8_t *dest,
unsigned int *frame_flags) {
if (cpi->oxcf.rc_mode == RC_MODE_CBR) {
if (cpi->oxcf.rc_mode == VPX_CBR) {
vp9_rc_get_one_pass_cbr_params(cpi);
} else {
vp9_rc_get_one_pass_vbr_params(cpi);
......@@ -2561,7 +2561,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
}
if (cpi->svc.number_temporal_layers > 1 &&
cpi->oxcf.rc_mode == RC_MODE_CBR) {
cpi->oxcf.rc_mode == VPX_CBR) {
vp9_update_temporal_layer_framerate(cpi);
vp9_restore_layer_context(cpi);
}
......@@ -2594,7 +2594,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
if (cpi->pass == 2 &&
cm->current_video_frame == 0 &&
cpi->oxcf.allow_spatial_resampling &&
cpi->oxcf.rc_mode == RC_MODE_VBR) {
cpi->oxcf.rc_mode == VPX_VBR) {
// Internal scaling is triggered on the first frame.
vp9_set_size_literal(cpi, cpi->oxcf.scaled_frame_width,
cpi->oxcf.scaled_frame_height);
......@@ -2656,7 +2656,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
// Save layer specific state.
if ((cpi->svc.number_temporal_layers > 1 &&
cpi->oxcf.rc_mode == RC_MODE_CBR) ||
cpi->oxcf.rc_mode == VPX_CBR) ||
(cpi->svc.number_spatial_layers > 1 && cpi->pass == 2)) {
vp9_save_layer_context(cpi);
}
......
......@@ -133,13 +133,6 @@ typedef enum {
ONETWO = 3
} VPX_SCALING;
typedef enum {
RC_MODE_VBR = 0,
RC_MODE_CBR = 1,
RC_MODE_CONSTRAINED_QUALITY = 2,
RC_MODE_CONSTANT_QUALITY = 3,
} RC_MODE;
typedef enum {
// Good Quality Fast Encoding. The encoder balances quality with the
// amount of time it takes to encode the output. (speed setting
......@@ -212,7 +205,8 @@ typedef struct VP9EncoderConfig {
// ----------------------------------------------------------------
// DATARATE CONTROL OPTIONS
RC_MODE rc_mode; // vbr, cbr, constrained quality or constant quality
// vbr, cbr, constrained quality or constant quality
enum vpx_rc_mode rc_mode;
// buffer targeting aggressiveness
int under_shoot_pct;
......
......@@ -922,7 +922,7 @@ static int get_twopass_worst_quality(const VP9_COMP *cpi,
}
// Restriction on active max q for constrained quality mode.
if (cpi->oxcf.rc_mode == RC_MODE_CONSTRAINED_QUALITY)
if (cpi->oxcf.rc_mode == VPX_CQ)
q = MAX(q, oxcf->cq_level);
return q;
}
......@@ -2144,7 +2144,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
rc->base_frame_target = target_rate;
#ifdef LONG_TERM_VBR_CORRECTION
// Correction to rate target based on prior over or under shoot.
if (cpi->oxcf.rc_mode == RC_MODE_VBR)
if (cpi->oxcf.rc_mode == VPX_VBR)
vbr_rate_correction(&target_rate, rc->vbr_bits_off_target);
#endif
vp9_rc_set_frame_target(cpi, target_rate);
......@@ -2159,7 +2159,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
twopass->gf_intra_err_min = GF_MB_INTRA_MIN * cpi->common.MBs;
}
if (cpi->oxcf.rc_mode == RC_MODE_CONSTANT_QUALITY) {
if (cpi->oxcf.rc_mode == VPX_Q) {
twopass->active_worst_quality = cpi->oxcf.cq_level;
} else if (cm->current_video_frame == 0 ||
(is_spatial_svc && lc->current_video_frame_in_layer == 0)) {
......@@ -2244,7 +2244,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
rc->base_frame_target = target_rate;
#ifdef LONG_TERM_VBR_CORRECTION
// Correction to rate target based on prior over or under shoot.
if (cpi->oxcf.rc_mode == RC_MODE_VBR)
if (cpi->oxcf.rc_mode == VPX_VBR)
vbr_rate_correction(&target_rate, rc->vbr_bits_off_target);
#endif
vp9_rc_set_frame_target(cpi, target_rate);
......
......@@ -180,13 +180,13 @@ static void update_buffer_level(VP9_COMP *cpi, int encoded_frame_size) {
rc->bits_off_target = MIN(rc->bits_off_target, rc->maximum_buffer_size);
rc->buffer_level = rc->bits_off_target;
if (cpi->use_svc && cpi->oxcf.rc_mode == RC_MODE_CBR) {
if (cpi->use_svc && cpi->oxcf.rc_mode == VPX_CBR) {
update_layer_buffer_level(&cpi->svc, encoded_frame_size);
}
}
void vp9_rc_init(const VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) {
if (pass == 0 && oxcf->rc_mode == RC_MODE_CBR) {
if (pass == 0 && oxcf->rc_mode == VPX_CBR) {
rc->avg_frame_qindex[KEY_FRAME] = oxcf->worst_allowed_q;
rc->avg_frame_qindex[INTER_FRAME] = oxcf->worst_allowed_q;
} else {
......@@ -276,7 +276,7 @@ static double get_rate_correction_factor(const VP9_COMP *cpi) {
} else {
if ((cpi->refresh_alt_ref_frame || cpi->refresh_golden_frame) &&
!cpi->rc.is_src_frame_alt_ref &&
!(cpi->use_svc && cpi->oxcf.rc_mode == RC_MODE_CBR))
!(cpi->use_svc && cpi->oxcf.rc_mode == VPX_CBR))
return cpi->rc.gf_rate_correction_factor;
else
return cpi->rc.rate_correction_factor;
......@@ -289,7 +289,7 @@ static void set_rate_correction_factor(VP9_COMP *cpi, double factor) {
} else {
if ((cpi->refresh_alt_ref_frame || cpi->refresh_golden_frame) &&
!cpi->rc.is_src_frame_alt_ref &&
!(cpi->use_svc && cpi->oxcf.rc_mode == RC_MODE_CBR))
!(cpi->use_svc && cpi->oxcf.rc_mode == VPX_CBR))
cpi->rc.gf_rate_correction_factor = factor;
else
cpi->rc.rate_correction_factor = factor;
......@@ -605,7 +605,7 @@ static int get_active_cq_level(const RATE_CONTROL *rc,
const VP9EncoderConfig *const oxcf) {
static const double cq_adjust_threshold = 0.5;
int active_cq_level = oxcf->cq_level;
if (oxcf->rc_mode == RC_MODE_CONSTRAINED_QUALITY &&
if (oxcf->rc_mode == VPX_CQ &&
rc->total_target_bits > 0) {
const double x = (double)rc->total_actual_bits / rc->total_target_bits;
if (x < cq_adjust_threshold) {
......@@ -679,7 +679,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
q = rc->avg_frame_qindex[KEY_FRAME];
}
// For constrained quality dont allow Q less than the cq level
if (oxcf->rc_mode == RC_MODE_CONSTRAINED_QUALITY) {
if (oxcf->rc_mode == VPX_CQ) {
if (q < cq_level)
q = cq_level;
......@@ -691,7 +691,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
// Constrained quality use slightly lower active best.
active_best_quality = active_best_quality * 15 / 16;
} else if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) {
} else if (oxcf->rc_mode == VPX_Q) {
if (!cpi->refresh_alt_ref_frame) {
active_best_quality = cq_level;
} else {
......@@ -705,7 +705,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
arfgf_low_motion_minq, arfgf_high_motion_minq);
}
} else {
if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) {
if (oxcf->rc_mode == VPX_Q) {
active_best_quality = cq_level;
} else {
// Use the lower of active_worst_quality and recent/average Q.
......@@ -715,7 +715,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
active_best_quality = inter_minq[rc->avg_frame_qindex[KEY_FRAME]];
// For the constrained quality mode we don't want
// q to fall below the cq level.
if ((oxcf->rc_mode == RC_MODE_CONSTRAINED_QUALITY) &&
if ((oxcf->rc_mode == VPX_CQ) &&
(active_best_quality < cq_level)) {
active_best_quality = cq_level;
}
......@@ -752,7 +752,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
}
#endif
if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) {
if (oxcf->rc_mode == VPX_Q) {
q = active_best_quality;
// Special case code to try and match quality with forced key frames
} else if ((cm->frame_type == KEY_FRAME) && rc->this_key_frame_forced) {
......@@ -771,7 +771,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
#if CONFIG_MULTIPLE_ARF
// Force the quantizer determined by the coding order pattern.
if (cpi->multi_arf_enabled && (cm->frame_type != KEY_FRAME) &&
cpi->oxcf.rc_mode != RC_MODE_CONSTANT_QUALITY) {
cpi->oxcf.rc_mode != VPX_Q) {
double new_q;
double current_q = vp9_convert_qindex_to_q(active_worst_quality);
int level = cpi->this_frame_weight;
......@@ -859,7 +859,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
q = active_worst_quality;
}
// For constrained quality dont allow Q less than the cq level
if (oxcf->rc_mode == RC_MODE_CONSTRAINED_QUALITY) {
if (oxcf->rc_mode == VPX_CQ) {
if (q < cq_level)
q = cq_level;
......@@ -871,7 +871,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
// Constrained quality use slightly lower active best.
active_best_quality = active_best_quality * 15 / 16;
} else if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) {
} else if (oxcf->rc_mode == VPX_Q) {
if (!cpi->refresh_alt_ref_frame) {
active_best_quality = cq_level;
} else {
......@@ -885,14 +885,14 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
arfgf_low_motion_minq, arfgf_high_motion_minq);
}
} else {
if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) {
if (oxcf->rc_mode == VPX_Q) {
active_best_quality = cq_level;
} else {
active_best_quality = inter_minq[active_worst_quality];
// For the constrained quality mode we don't want
// q to fall below the cq level.
if ((oxcf->rc_mode == RC_MODE_CONSTRAINED_QUALITY) &&
if ((oxcf->rc_mode == VPX_CQ) &&
(active_best_quality < cq_level)) {
active_best_quality = cq_level;
}
......@@ -919,7 +919,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
qdelta = vp9_compute_qdelta_by_rate(&cpi->rc, cm->frame_type,
active_worst_quality, 2.0);
} else if (!rc->is_src_frame_alt_ref &&
(oxcf->rc_mode != RC_MODE_CBR) &&
(oxcf->rc_mode != VPX_CBR) &&
(cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) {
qdelta = vp9_compute_qdelta_by_rate(&cpi->rc, cm->frame_type,
active_worst_quality, 1.75);
......@@ -929,7 +929,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
}
#endif
if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) {
if (oxcf->rc_mode == VPX_Q) {
q = active_best_quality;
// Special case code to try and match quality with forced key frames.
} else if ((cm->frame_type == KEY_FRAME) && rc->this_key_frame_forced) {
......@@ -948,7 +948,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
#if CONFIG_MULTIPLE_ARF
// Force the quantizer determined by the coding order pattern.
if (cpi->multi_arf_enabled && (cm->frame_type != KEY_FRAME) &&
cpi->oxcf.rc_mode != RC_MODE_CONSTANT_QUALITY) {
cpi->oxcf.rc_mode != VPX_Q) {
double new_q;
double current_q = vp9_convert_qindex_to_q(active_worst_quality);
int level = cpi->this_frame_weight;
......@@ -974,7 +974,7 @@ int vp9_rc_pick_q_and_bounds(const VP9_COMP *cpi,
int *bottom_index, int *top_index) {
int q;
if (cpi->pass == 0) {
if (cpi->oxcf.rc_mode == RC_MODE_CBR)
if (cpi->oxcf.rc_mode == VPX_CBR)
q = rc_pick_q_and_bounds_one_pass_cbr(cpi, bottom_index, top_index);
else
q = rc_pick_q_and_bounds_one_pass_vbr(cpi, bottom_index, top_index);
......@@ -997,7 +997,7 @@ void vp9_rc_compute_frame_size_bounds(const VP9_COMP *cpi,
int frame_target,
int *frame_under_shoot_limit,
int *frame_over_shoot_limit) {
if (cpi->oxcf.rc_mode == RC_MODE_CONSTANT_QUALITY) {
if (cpi->oxcf.rc_mode == VPX_Q) {
*frame_under_shoot_limit = 0;
*frame_over_shoot_limit = INT_MAX;
} else {
......@@ -1072,7 +1072,7 @@ void vp9_rc_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) {
// Post encode loop adjustment of Q prediction.
vp9_rc_update_rate_correction_factors(
cpi, (cpi->sf.recode_loop >= ALLOW_RECODE_KFARFGF ||
oxcf->rc_mode == RC_MODE_CBR) ? 2 : 0);
oxcf->rc_mode == VPX_CBR) ? 2 : 0);
// Keep a record of last Q and ambient average Q.
if (cm->frame_type == KEY_FRAME) {
......@@ -1082,7 +1082,7 @@ void vp9_rc_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) {
} 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)) {
(cpi->use_svc && oxcf->rc_mode == VPX_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);
......@@ -1225,7 +1225,7 @@ static int calc_pframe_target_size_one_pass_cbr(const VP9_COMP *cpi) {
int min_frame_target = MAX(rc->avg_frame_bandwidth >> 4, FRAME_OVERHEAD_BITS);
int target = rc->avg_frame_bandwidth;
if (svc->number_temporal_layers > 1 &&
oxcf->rc_mode == RC_MODE_CBR) {
oxcf->rc_mode == VPX_CBR) {
// Note that for layers, avg_frame_bandwidth is the cumulative
// per-frame-bandwidth. For the target size of this frame, use the
// layer average frame size (i.e., non-cumulative per-frame-bw).
......@@ -1258,7 +1258,7 @@ static int calc_iframe_target_size_one_pass_cbr(const VP9_COMP *cpi) {
int kf_boost = 32;
double framerate = oxcf->framerate;
if (svc->number_temporal_layers > 1 &&
oxcf->rc_mode == RC_MODE_CBR) {
oxcf->rc_mode == VPX_CBR) {
// Use the layer framerate for temporal layers CBR mode.
const LAYER_CONTEXT *lc = &svc->layer_context[svc->temporal_layer_id];
framerate = lc->framerate;
......@@ -1288,7 +1288,7 @@ void vp9_rc_get_svc_params(VP9_COMP *cpi) {
cpi->svc.layer_context[cpi->svc.spatial_layer_id].is_key_frame = 1;
}
if (cpi->pass == 0 && cpi->oxcf.rc_mode == RC_MODE_CBR) {
if (cpi->pass == 0 && cpi->oxcf.rc_mode == VPX_CBR) {
target = calc_iframe_target_size_one_pass_cbr(cpi);
}
} else {
......@@ -1303,7 +1303,7 @@ void vp9_rc_get_svc_params(VP9_COMP *cpi) {
}
}
if (cpi->pass == 0 && cpi->oxcf.rc_mode == RC_MODE_CBR) {
if (cpi->pass == 0 && cpi->oxcf.rc_mode == VPX_CBR) {
target = calc_pframe_target_size_one_pass_cbr(cpi);
}
}
......
......@@ -318,14 +318,7 @@ static vpx_codec_err_t set_encoder_config(
oxcf->lag_in_frames = cfg->g_pass == VPX_RC_FIRST_PASS ? 0
: cfg->g_lag_in_frames;
oxcf->rc_mode = RC_MODE_VBR;
if (cfg->rc_end_usage == VPX_CQ)
oxcf->rc_mode = RC_MODE_CONSTRAINED_QUALITY;
else if (cfg->rc_end_usage == VPX_Q)
oxcf->rc_mode = RC_MODE_CONSTANT_QUALITY;
else if (cfg->rc_end_usage == VPX_CBR)
oxcf->rc_mode = RC_MODE_CBR;
oxcf->rc_mode = cfg->rc_end_usage;
// Convert target bandwidth from Kbit/s to Bit/s
oxcf->target_bandwidth = 1000 * cfg->rc_target_bitrate;
......
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