diff options
author | Yaowu Xu <yaowu@xuyaowu.com> | 2018-11-11 14:17:35 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-11-11 14:17:35 +0000 |
commit | 4a8c248744500f9caf00588ca312efce5659e45e (patch) | |
tree | 70f674ab2d0545d4f0bcfe5dd76c44345035d9af /vp9/encoder | |
parent | 2ac954dfd2e47afd0df2a6dece14d1689644e30c (diff) | |
parent | 42c81fcafc0d682b58b4858ca0ffe68813120f59 (diff) | |
download | libvpx-4a8c248744500f9caf00588ca312efce5659e45e.tar libvpx-4a8c248744500f9caf00588ca312efce5659e45e.tar.gz libvpx-4a8c248744500f9caf00588ca312efce5659e45e.tar.bz2 libvpx-4a8c248744500f9caf00588ca312efce5659e45e.zip |
Merge "Refactor common code in RDMULT computation"
Diffstat (limited to 'vp9/encoder')
-rw-r--r-- | vp9/encoder/vp9_rd.c | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/vp9/encoder/vp9_rd.c b/vp9/encoder/vp9_rd.c index e65cf42d8..dca12feba 100644 --- a/vp9/encoder/vp9_rd.c +++ b/vp9/encoder/vp9_rd.c @@ -188,8 +188,7 @@ int vp9_compute_rd_mult_based_on_qindex(const VP9_COMP *cpi, int qindex) { return rdmult > 0 ? rdmult : 1; } -int vp9_compute_rd_mult(const VP9_COMP *cpi, int qindex) { - int64_t rdmult = vp9_compute_rd_mult_based_on_qindex(cpi, qindex); +static int modulate_rdmult(const VP9_COMP *cpi, int64_t rdmult) { 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]; @@ -204,39 +203,17 @@ 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 gfu_boost = cpi->multi_layer_arf - ? gf_group->gfu_boost[gf_group->index] - : cpi->rc.gfu_boost; - const int boost_index = VPXMIN(15, (gfu_boost / 100)); +int vp9_compute_rd_mult(const VP9_COMP *cpi, int qindex) { + int64_t rdmult = vp9_compute_rd_mult_based_on_qindex(cpi, qindex); + return modulate_rdmult(cpi, rdmult); +} - 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; +int vp9_get_adaptive_rdmult(const VP9_COMP *cpi, double beta) { + int64_t rdmult = + vp9_compute_rd_mult_based_on_qindex(cpi, cpi->common.base_qindex); + rdmult = (int64_t)((double)rdmult / beta); + rdmult = rdmult > 0 ? rdmult : 1; + return modulate_rdmult(cpi, rdmult); } static int compute_rd_thresh_factor(int qindex, vpx_bit_depth_t bit_depth) { |