diff options
Diffstat (limited to 'chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.h')
-rw-r--r-- | chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.h | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.h b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.h index bc74129e591..869f6e59e97 100644 --- a/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.h +++ b/chromium/third_party/libvpx/source/libvpx/vp9/encoder/vp9_ratectrl.h @@ -33,6 +33,27 @@ typedef enum { RATE_FACTOR_LEVELS = 5 } RATE_FACTOR_LEVEL; +// Internal frame scaling level. +typedef enum { + UNSCALED = 0, // Frame is unscaled. + SCALE_STEP1 = 1, // First-level down-scaling. + FRAME_SCALE_STEPS +} FRAME_SCALE_LEVEL; + +// Frame dimensions multiplier wrt the native frame size, in 1/16ths, +// specified for the scale-up case. +// e.g. 24 => 16/24 = 2/3 of native size. The restriction to 1/16th is +// intended to match the capabilities of the normative scaling filters, +// giving precedence to the up-scaling accuracy. +static const int frame_scale_factor[FRAME_SCALE_STEPS] = {16, 24}; + +// Multiplier of the target rate to be used as threshold for triggering scaling. +static const double rate_thresh_mult[FRAME_SCALE_STEPS] = {1.0, 2.0}; + +// Scale dependent Rate Correction Factor multipliers. Compensates for the +// greater number of bits per pixel generated in down-scaled frames. +static const double rcf_mult[FRAME_SCALE_STEPS] = {1.0, 2.0}; + typedef struct { // Rate targetting variables int base_frame_target; // A baseline frame target before adjustment @@ -52,9 +73,11 @@ typedef struct { int frames_since_golden; int frames_till_gf_update_due; + int min_gf_interval; int max_gf_interval; int static_scene_max_gf_interval; int baseline_gf_interval; + int constrained_gf_group; int frames_to_key; int frames_since_key; int this_key_frame_forced; @@ -99,7 +122,22 @@ typedef struct { int64_t starting_buffer_level; int64_t optimal_buffer_level; int64_t maximum_buffer_size; - // int active_best_quality; + + // rate control history for last frame(1) and the frame before(2). + // -1: undershot + // 1: overshoot + // 0: not initialized. + int rc_1_frame; + int rc_2_frame; + int q_1_frame; + int q_2_frame; + + // Auto frame-scaling variables. + FRAME_SCALE_LEVEL frame_size_selector; + FRAME_SCALE_LEVEL next_frame_size_selector; + int frame_width[FRAME_SCALE_STEPS]; + int frame_height[FRAME_SCALE_STEPS]; + int rf_level_maxq[RATE_FACTOR_LEVELS]; } RATE_CONTROL; struct VP9_COMP; @@ -108,6 +146,10 @@ struct VP9EncoderConfig; void vp9_rc_init(const struct VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc); +int vp9_estimate_bits_at_q(FRAME_TYPE frame_kind, int q, int mbs, + double correction_factor, + vpx_bit_depth_t bit_depth); + double vp9_convert_qindex_to_q(int qindex, vpx_bit_depth_t bit_depth); void vp9_rc_init_minq_luts(); @@ -148,7 +190,7 @@ void vp9_rc_postencode_update_drop_frame(struct VP9_COMP *cpi); // Updates rate correction factors // Changes only the rate correction factors in the rate control structure. -void vp9_rc_update_rate_correction_factors(struct VP9_COMP *cpi, int damp_var); +void vp9_rc_update_rate_correction_factors(struct VP9_COMP *cpi); // Decide if we should drop this frame: For 1-pass CBR. // Changes only the decimation count in the rate control structure @@ -193,10 +235,14 @@ int vp9_compute_qdelta_by_rate(const RATE_CONTROL *rc, FRAME_TYPE frame_type, int qindex, double rate_target_ratio, vpx_bit_depth_t bit_depth); +int vp9_frame_type_qdelta(const struct VP9_COMP *cpi, int rf_level, int q); + void vp9_rc_update_framerate(struct VP9_COMP *cpi); -void vp9_rc_set_gf_max_interval(const struct VP9_COMP *const cpi, - RATE_CONTROL *const rc); +void vp9_rc_set_gf_interval_range(const struct VP9_COMP *const cpi, + RATE_CONTROL *const rc); + +void vp9_set_target_rate(struct VP9_COMP *cpi); #ifdef __cplusplus } // extern "C" |