diff options
Diffstat (limited to 'vp9/encoder/vp9_rd.c')
-rw-r--r-- | vp9/encoder/vp9_rd.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/vp9/encoder/vp9_rd.c b/vp9/encoder/vp9_rd.c index 3407e74c6..dcdd00d92 100644 --- a/vp9/encoder/vp9_rd.c +++ b/vp9/encoder/vp9_rd.c @@ -200,6 +200,38 @@ int vp9_compute_rd_mult(const VP9_COMP *cpi, int qindex) { return (int)rdmult; } +int vp9_get_adaptive_rdmult(const VP9_COMP *cpi, double beta) { + const VP9_COMMON *cm = &cpi->common; + int64_t q = vp9_dc_quant(cm->base_qindex, 0, cpi->common.bit_depth); + +#if CONFIG_VP9_HIGHBITDEPTH + int64_t rdmult = 0; + switch (cpi->common.bit_depth) { + case VPX_BITS_8: rdmult = (int)((88 * q * q / beta) / 24); break; + case VPX_BITS_10: + rdmult = ROUND_POWER_OF_TWO((int)((88 * q * q / beta) / 24), 4); + break; + default: + assert(cpi->common.bit_depth == VPX_BITS_12); + rdmult = ROUND_POWER_OF_TWO((int)((88 * q * q / beta) / 24), 8); + break; + } +#else + int64_t rdmult = (int)((88 * q * q / beta) / 24); +#endif // CONFIG_VP9_HIGHBITDEPTH + + if (cpi->oxcf.pass == 2 && (cpi->common.frame_type != KEY_FRAME)) { + const GF_GROUP *const gf_group = &cpi->twopass.gf_group; + const FRAME_UPDATE_TYPE frame_type = gf_group->update_type[gf_group->index]; + const int boost_index = VPXMIN(15, (cpi->rc.gfu_boost / 100)); + + rdmult = (rdmult * rd_frame_type_factor[frame_type]) >> 7; + rdmult += ((rdmult * rd_boost_factor[boost_index]) >> 7); + } + if (rdmult < 1) rdmult = 1; + return (int)rdmult; +} + static int compute_rd_thresh_factor(int qindex, vpx_bit_depth_t bit_depth) { double q; #if CONFIG_VP9_HIGHBITDEPTH |