summaryrefslogtreecommitdiff
path: root/vp9/encoder
diff options
context:
space:
mode:
Diffstat (limited to 'vp9/encoder')
-rw-r--r--vp9/encoder/vp9_firstpass.c8
-rw-r--r--vp9/encoder/vp9_onyx_if.c22
-rw-r--r--vp9/encoder/vp9_onyx_int.h12
-rw-r--r--vp9/encoder/vp9_ratectrl.c50
4 files changed, 46 insertions, 46 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 1dacfaaae..c6dc03be8 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -930,7 +930,7 @@ static int get_twopass_worst_quality(const VP9_COMP *cpi,
}
// Restriction on active max q for constrained quality mode.
- if (oxcf->end_usage == USAGE_CONSTRAINED_QUALITY)
+ if (cpi->oxcf.rc_mode == RC_MODE_CONSTRAINED_QUALITY)
q = MAX(q, oxcf->cq_level);
return q;
}
@@ -2244,7 +2244,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
cm->frame_type = INTER_FRAME;
#ifdef LONG_TERM_VBR_CORRECTION
// Correction to rate target based on prior over or under shoot.
- if (cpi->oxcf.end_usage == USAGE_LOCAL_FILE_PLAYBACK)
+ if (cpi->oxcf.rc_mode == RC_MODE_VBR)
vbr_rate_correction(&modified_target, rc->vbr_bits_off_target);
#endif
vp9_rc_set_frame_target(cpi, modified_target);
@@ -2258,7 +2258,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.end_usage == USAGE_CONSTANT_QUALITY) {
+ if (cpi->oxcf.rc_mode == RC_MODE_CONSTANT_QUALITY) {
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)) {
@@ -2346,7 +2346,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
rc->base_frame_target = target;
#ifdef LONG_TERM_VBR_CORRECTION
// Correction to rate target based on prior over or under shoot.
- if (cpi->oxcf.end_usage == USAGE_LOCAL_FILE_PLAYBACK)
+ if (cpi->oxcf.rc_mode == RC_MODE_VBR)
vbr_rate_correction(&target, rc->vbr_bits_off_target);
#endif
vp9_rc_set_frame_target(cpi, target);
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index f8dd5c5b7..2430bd9e1 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -537,7 +537,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.end_usage == USAGE_STREAM_FROM_SERVER) ||
+ cpi->oxcf.rc_mode == RC_MODE_CBR) ||
(cpi->svc.number_spatial_layers > 1 &&
cpi->oxcf.mode == TWO_PASS_SECOND_BEST)) {
vp9_init_layer_context(cpi);
@@ -624,7 +624,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.end_usage == USAGE_LOCAL_FILE_PLAYBACK) {
+ if (cpi->oxcf.rc_mode == RC_MODE_VBR) {
cpi->oxcf.starting_buffer_level = 60000;
cpi->oxcf.optimal_buffer_level = 60000;
cpi->oxcf.maximum_buffer_size = 240000;
@@ -680,7 +680,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.end_usage == USAGE_STREAM_FROM_SERVER) ||
+ cpi->oxcf.rc_mode == RC_MODE_CBR) ||
(cpi->svc.number_spatial_layers > 1 && cpi->pass == 2)) {
vp9_update_layer_context_change_config(cpi,
(int)cpi->oxcf.target_bandwidth);
@@ -1584,7 +1584,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 (oxcf->end_usage == USAGE_CONSTRAINED_QUALITY) {
+ } else if (cpi->oxcf.rc_mode == RC_MODE_CONSTRAINED_QUALITY) {
// Deal with frame undershoot and whether or not we are
// below the automatically set cq level.
if (q > oxcf->cq_level &&
@@ -1907,7 +1907,7 @@ static void encode_with_recode_loop(VP9_COMP *cpi,
frame_over_shoot_limit = 1;
}
- if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) {
+ if (cpi->oxcf.rc_mode == RC_MODE_CONSTANT_QUALITY) {
loop = 0;
} else {
if ((cm->frame_type == KEY_FRAME) &&
@@ -2005,7 +2005,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.end_usage == USAGE_CONSTRAINED_QUALITY &&
+ if (cpi->oxcf.rc_mode == RC_MODE_CONSTRAINED_QUALITY &&
q < q_low) {
q_low = q;
}
@@ -2203,7 +2203,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.end_usage == USAGE_STREAM_FROM_SERVER &&
+ cpi->oxcf.rc_mode == RC_MODE_CBR &&
cm->frame_type != KEY_FRAME) {
if (vp9_rc_drop_frame(cpi)) {
vp9_rc_postencode_update_drop_frame(cpi);
@@ -2400,7 +2400,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.end_usage == USAGE_STREAM_FROM_SERVER) {
+ if (cpi->oxcf.rc_mode == RC_MODE_CBR) {
vp9_rc_get_one_pass_cbr_params(cpi);
} else {
vp9_rc_get_one_pass_vbr_params(cpi);
@@ -2691,7 +2691,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
}
if (cpi->svc.number_temporal_layers > 1 &&
- cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) {
+ cpi->oxcf.rc_mode == RC_MODE_CBR) {
vp9_update_temporal_layer_framerate(cpi);
vp9_restore_layer_context(cpi);
}
@@ -2724,7 +2724,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.end_usage == USAGE_LOCAL_FILE_PLAYBACK) {
+ cpi->oxcf.rc_mode == RC_MODE_VBR) {
// Internal scaling is triggered on the first frame.
vp9_set_size_literal(cpi, cpi->oxcf.scaled_frame_width,
cpi->oxcf.scaled_frame_height);
@@ -2783,7 +2783,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.end_usage == USAGE_STREAM_FROM_SERVER) ||
+ cpi->oxcf.rc_mode == RC_MODE_CBR) ||
(cpi->svc.number_spatial_layers > 1 && cpi->pass == 2)) {
vp9_save_layer_context(cpi);
}
diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h
index 5f4112369..d1a812389 100644
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -132,11 +132,11 @@ typedef enum {
} VPX_SCALING;
typedef enum {
- USAGE_LOCAL_FILE_PLAYBACK = 0,
- USAGE_STREAM_FROM_SERVER = 1,
- USAGE_CONSTRAINED_QUALITY = 2,
- USAGE_CONSTANT_QUALITY = 3,
-} END_USAGE;
+ 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
@@ -210,7 +210,7 @@ typedef struct VP9EncoderConfig {
// ----------------------------------------------------------------
// DATARATE CONTROL OPTIONS
- END_USAGE end_usage; // vbr or cbr
+ RC_MODE rc_mode; // vbr, cbr, constrained quality or constant quality
// buffer targeting aggressiveness
int under_shoot_pct;
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index b8d0ec40d..2e35e5fbc 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -181,13 +181,13 @@ static void update_buffer_level(VP9_COMP *cpi, int encoded_frame_size) {
rc->bits_off_target = MIN(rc->bits_off_target, oxcf->maximum_buffer_size);
rc->buffer_level = rc->bits_off_target;
- if (cpi->use_svc && cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) {
+ if (cpi->use_svc && cpi->oxcf.rc_mode == RC_MODE_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->end_usage == USAGE_STREAM_FROM_SERVER) {
+ 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;
@@ -280,7 +280,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.end_usage == USAGE_STREAM_FROM_SERVER))
+ !(cpi->use_svc && cpi->oxcf.rc_mode == RC_MODE_CBR))
return cpi->rc.gf_rate_correction_factor;
else
return cpi->rc.rate_correction_factor;
@@ -293,7 +293,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.end_usage == USAGE_STREAM_FROM_SERVER))
+ !(cpi->use_svc && cpi->oxcf.rc_mode == RC_MODE_CBR))
cpi->rc.gf_rate_correction_factor = factor;
else
cpi->rc.rate_correction_factor = factor;
@@ -671,7 +671,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->end_usage == USAGE_CONSTRAINED_QUALITY) {
+ if (oxcf->rc_mode == RC_MODE_CONSTRAINED_QUALITY) {
if (q < cq_level)
q = cq_level;
if (rc->frames_since_key > 1) {
@@ -688,7 +688,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->end_usage == USAGE_CONSTANT_QUALITY) {
+ } else if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) {
if (!cpi->refresh_alt_ref_frame) {
active_best_quality = cq_level;
} else {
@@ -708,7 +708,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
gf_low_motion_minq, gf_high_motion_minq);
}
} else {
- if (oxcf->end_usage == USAGE_CONSTANT_QUALITY) {
+ if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) {
active_best_quality = cq_level;
} else {
// Use the lower of active_worst_quality and recent/average Q.
@@ -718,7 +718,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->end_usage == USAGE_CONSTRAINED_QUALITY) &&
+ if ((oxcf->rc_mode == RC_MODE_CONSTRAINED_QUALITY) &&
(active_best_quality < cq_level)) {
active_best_quality = cq_level;
}
@@ -755,7 +755,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
}
#endif
- if (oxcf->end_usage == USAGE_CONSTANT_QUALITY) {
+ if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) {
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) {
@@ -774,7 +774,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.end_usage != USAGE_CONSTANT_QUALITY) {
+ cpi->oxcf.rc_mode != RC_MODE_CONSTANT_QUALITY) {
double new_q;
double current_q = vp9_convert_qindex_to_q(active_worst_quality);
int level = cpi->this_frame_weight;
@@ -862,7 +862,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->end_usage == USAGE_CONSTRAINED_QUALITY) {
+ if (oxcf->rc_mode == RC_MODE_CONSTRAINED_QUALITY) {
if (q < cq_level)
q = cq_level;
if (rc->frames_since_key > 1) {
@@ -879,7 +879,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->end_usage == USAGE_CONSTANT_QUALITY) {
+ } else if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) {
if (!cpi->refresh_alt_ref_frame) {
active_best_quality = cq_level;
} else {
@@ -899,14 +899,14 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
gf_low_motion_minq, gf_high_motion_minq);
}
} else {
- if (oxcf->end_usage == USAGE_CONSTANT_QUALITY) {
+ if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) {
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->end_usage == USAGE_CONSTRAINED_QUALITY) &&
+ if ((oxcf->rc_mode == RC_MODE_CONSTRAINED_QUALITY) &&
(active_best_quality < cq_level)) {
active_best_quality = cq_level;
}
@@ -932,7 +932,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->end_usage != USAGE_STREAM_FROM_SERVER) &&
+ (oxcf->rc_mode != RC_MODE_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);
@@ -942,7 +942,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
}
#endif
- if (oxcf->end_usage == USAGE_CONSTANT_QUALITY) {
+ if (oxcf->rc_mode == RC_MODE_CONSTANT_QUALITY) {
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) {
@@ -961,7 +961,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.end_usage != USAGE_CONSTANT_QUALITY) {
+ cpi->oxcf.rc_mode != RC_MODE_CONSTANT_QUALITY) {
double new_q;
double current_q = vp9_convert_qindex_to_q(active_worst_quality);
int level = cpi->this_frame_weight;
@@ -987,7 +987,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.end_usage == USAGE_STREAM_FROM_SERVER)
+ if (cpi->oxcf.rc_mode == RC_MODE_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);
@@ -1015,7 +1015,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.end_usage == USAGE_CONSTANT_QUALITY) {
+ if (cpi->oxcf.rc_mode == RC_MODE_CONSTANT_QUALITY) {
*frame_under_shoot_limit = 0;
*frame_over_shoot_limit = INT_MAX;
} else {
@@ -1090,7 +1090,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->end_usage == USAGE_STREAM_FROM_SERVER) ? 2 : 0);
+ oxcf->rc_mode == RC_MODE_CBR) ? 2 : 0);
// Keep a record of last Q and ambient average Q.
if (cm->frame_type == KEY_FRAME) {
@@ -1099,7 +1099,7 @@ void vp9_rc_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) {
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->end_usage == USAGE_STREAM_FROM_SERVER)) {
+ !(cpi->use_svc && oxcf->rc_mode == RC_MODE_CBR)) {
rc->last_q[2] = qindex;
rc->avg_frame_qindex[2] =
ROUND_POWER_OF_TWO(3 * rc->avg_frame_qindex[2] + qindex, 2);
@@ -1247,7 +1247,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->end_usage == USAGE_STREAM_FROM_SERVER) {
+ oxcf->rc_mode == RC_MODE_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).
@@ -1280,7 +1280,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->end_usage == USAGE_STREAM_FROM_SERVER) {
+ oxcf->rc_mode == RC_MODE_CBR) {
// Use the layer framerate for temporal layers CBR mode.
const LAYER_CONTEXT *lc = &svc->layer_context[svc->temporal_layer_id];
framerate = lc->framerate;
@@ -1305,12 +1305,12 @@ void vp9_rc_get_svc_params(VP9_COMP *cpi) {
cpi->key_frame_frequency == 0))) {
cm->frame_type = KEY_FRAME;
rc->source_alt_ref_active = 0;
- if (cpi->pass == 0 && cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) {
+ if (cpi->pass == 0 && cpi->oxcf.rc_mode == RC_MODE_CBR) {
target = calc_iframe_target_size_one_pass_cbr(cpi);
}
} else {
cm->frame_type = INTER_FRAME;
- if (cpi->pass == 0 && cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) {
+ if (cpi->pass == 0 && cpi->oxcf.rc_mode == RC_MODE_CBR) {
target = calc_pframe_target_size_one_pass_cbr(cpi);
}
}