diff options
author | Adrian Grange <agrange@google.com> | 2014-11-14 15:29:18 -0800 |
---|---|---|
committer | Adrian Grange <agrange@google.com> | 2015-02-10 09:59:32 -0800 |
commit | 23ebacdb81adeee7a082a573068d84921898f39d (patch) | |
tree | 2a82a9bf1826dcd9e80abae4a0e64791c881c9f4 /vp9/encoder/vp9_ratectrl.h | |
parent | 84b813aa42c99bce15cec774153bdb1cd09e9578 (diff) | |
download | libvpx-23ebacdb81adeee7a082a573068d84921898f39d.tar libvpx-23ebacdb81adeee7a082a573068d84921898f39d.tar.gz libvpx-23ebacdb81adeee7a082a573068d84921898f39d.tar.bz2 libvpx-23ebacdb81adeee7a082a573068d84921898f39d.zip |
Auto-adaptive encoder frame resizing logic
Note: This feature is still in development.
Add an option for the encoder to decide the resolution
at which to encode each frame.
Each KF/GF/ARF goup is tested to see if it would be
better encoded at a lower resolution. At present, each
KF/GF/ARF is coded first at full-size and if the coded
size exceeds a threshold (twice target data rate) at
the maximum active Q then the entire group is encoded
at lower resolution.
This feature is enabled in vpxenc by setting:
--resize-allowed=1
In addition, if the vpxenc command line also specifies
valid frame dimensions using:
--resize-width=XXXX & --resize_height=YYYY
then *all* frames will be encoded at this resolution.
Change-Id: I13f341e0a82512f9e84e144e0f3b5aed8a65402b
Diffstat (limited to 'vp9/encoder/vp9_ratectrl.h')
-rw-r--r-- | vp9/encoder/vp9_ratectrl.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/vp9/encoder/vp9_ratectrl.h b/vp9/encoder/vp9_ratectrl.h index 9774127a9..705796a8d 100644 --- a/vp9/encoder/vp9_ratectrl.h +++ b/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 @@ -100,6 +121,7 @@ typedef struct { int64_t starting_buffer_level; int64_t optimal_buffer_level; int64_t maximum_buffer_size; + // rate control history for last frame(1) and the frame before(2). // -1: undershot // 1: overshoot @@ -108,6 +130,13 @@ typedef struct { 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; @@ -205,6 +234,8 @@ 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, |