diff options
author | Paul Wilkins <paulwilkins@google.com> | 2011-12-02 14:57:21 +0000 |
---|---|---|
committer | Paul Wilkins <paulwilkins@google.com> | 2011-12-02 15:30:01 +0000 |
commit | 8487a68baf32fc86af55c39cc7fd06c3444523d5 (patch) | |
tree | 8558833c85bda0c92d7dfcae56106f2d4d5cf012 /vp8/encoder/quantize.c | |
parent | 2b307b38e3d77555c6da3a65573d781c0a991a5b (diff) | |
download | libvpx-8487a68baf32fc86af55c39cc7fd06c3444523d5.tar libvpx-8487a68baf32fc86af55c39cc7fd06c3444523d5.tar.gz libvpx-8487a68baf32fc86af55c39cc7fd06c3444523d5.tar.bz2 libvpx-8487a68baf32fc86af55c39cc7fd06c3444523d5.zip |
Further work on extended Q range.
Fixed some further QIndex related issues and replaced some tables
(eg zbin and rounding)
Also Added function (currently disabled by default) to populate the
main AC and DC quantizer tables. Using the original AC range the
resulting computed DC values give behavior broadly comparable
on the DERF set. That is not to say that the equations will hold good
over a more extended range. The purpose of this code is to make it
easier to experiment with further alterations to the Q range and distribution
of Q values plus the relative weights given to AC and DC.
The function find_fp_qindex() ensures that changes to the Q tables
are reflected in the value passed in to the first pass code.
Slight experimental adjustment to static segment Q offset.
Change-Id: I36186267d55dfc2a3d565d0cff7218ef300d1cd5
Diffstat (limited to 'vp8/encoder/quantize.c')
-rw-r--r-- | vp8/encoder/quantize.c | 150 |
1 files changed, 37 insertions, 113 deletions
diff --git a/vp8/encoder/quantize.c b/vp8/encoder/quantize.c index 8bbc0d0a5..2e2a8dcbf 100644 --- a/vp8/encoder/quantize.c +++ b/vp8/encoder/quantize.c @@ -934,94 +934,6 @@ void vp8_fast_quantize_b_pair_c(BLOCK *b1, BLOCK *b2, BLOCKD *d1, BLOCKD *d2) } -static const int qrounding_factors[129] = -{ - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48 -}; - - -static const int qzbin_factors[129] = -{ - 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80 -}; - - -static const int qrounding_factors_y2[129] = -{ - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, - 48 -}; - - -static const int qzbin_factors_y2[129] = -{ - 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, - 84, 84, 84, 84, 84, 84, 84, 84, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80 -}; - - #define EXACT_QUANT #ifdef EXACT_QUANT static void invert_quant(int improved_quant, short *quant, @@ -1054,6 +966,13 @@ void vp8cx_init_quantizer(VP8_COMP *cpi) int zbin_boost[16] = {0, 0, 8, 10, 12, 14, 16, 20, 24, 28, 32, 36, 40, 44, 44, 44}; + int qrounding_factor = 48; +#if CONFIG_EXTEND_QRANGE + int qzbin_factor = (vp8_dc_quant(Q,0) < 148) ? 84 : 80; +#else + int qzbin_factor = (vp8_dc_quant(Q,0) < 37) ? 84: 80; +#endif + for (Q = 0; Q < QINDEX_RANGE; Q++) { // dc values @@ -1061,8 +980,8 @@ void vp8cx_init_quantizer(VP8_COMP *cpi) cpi->Y1quant_fast[Q][0] = (1 << 16) / quant_val; invert_quant(cpi->sf.improved_quant, cpi->Y1quant[Q] + 0, cpi->Y1quant_shift[Q] + 0, quant_val); - cpi->Y1zbin[Q][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; - cpi->Y1round[Q][0] = (qrounding_factors[Q] * quant_val) >> 7; + cpi->Y1zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7; + cpi->Y1round[Q][0] = (qrounding_factor * quant_val) >> 7; cpi->common.Y1dequant[Q][0] = quant_val; cpi->zrun_zbin_boost_y1[Q][0] = (quant_val * zbin_boost[0]) >> 7; @@ -1070,8 +989,8 @@ void vp8cx_init_quantizer(VP8_COMP *cpi) cpi->Y2quant_fast[Q][0] = (1 << 16) / quant_val; invert_quant(cpi->sf.improved_quant, cpi->Y2quant[Q] + 0, cpi->Y2quant_shift[Q] + 0, quant_val); - cpi->Y2zbin[Q][0] = ((qzbin_factors_y2[Q] * quant_val) + 64) >> 7; - cpi->Y2round[Q][0] = (qrounding_factors_y2[Q] * quant_val) >> 7; + cpi->Y2zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7; + cpi->Y2round[Q][0] = (qrounding_factor * quant_val) >> 7; cpi->common.Y2dequant[Q][0] = quant_val; cpi->zrun_zbin_boost_y2[Q][0] = (quant_val * zbin_boost[0]) >> 7; @@ -1079,8 +998,8 @@ void vp8cx_init_quantizer(VP8_COMP *cpi) cpi->UVquant_fast[Q][0] = (1 << 16) / quant_val; invert_quant(cpi->sf.improved_quant, cpi->UVquant[Q] + 0, cpi->UVquant_shift[Q] + 0, quant_val); - cpi->UVzbin[Q][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;; - cpi->UVround[Q][0] = (qrounding_factors[Q] * quant_val) >> 7; + cpi->UVzbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;; + cpi->UVround[Q][0] = (qrounding_factor * quant_val) >> 7; cpi->common.UVdequant[Q][0] = quant_val; cpi->zrun_zbin_boost_uv[Q][0] = (quant_val * zbin_boost[0]) >> 7; @@ -1093,8 +1012,8 @@ void vp8cx_init_quantizer(VP8_COMP *cpi) cpi->Y1quant_fast[Q][rc] = (1 << 16) / quant_val; invert_quant(cpi->sf.improved_quant, cpi->Y1quant[Q] + rc, cpi->Y1quant_shift[Q] + rc, quant_val); - cpi->Y1zbin[Q][rc] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; - cpi->Y1round[Q][rc] = (qrounding_factors[Q] * quant_val) >> 7; + cpi->Y1zbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7; + cpi->Y1round[Q][rc] = (qrounding_factor * quant_val) >> 7; cpi->common.Y1dequant[Q][rc] = quant_val; cpi->zrun_zbin_boost_y1[Q][i] = (quant_val * zbin_boost[i]) >> 7; @@ -1102,8 +1021,8 @@ void vp8cx_init_quantizer(VP8_COMP *cpi) cpi->Y2quant_fast[Q][rc] = (1 << 16) / quant_val; invert_quant(cpi->sf.improved_quant, cpi->Y2quant[Q] + rc, cpi->Y2quant_shift[Q] + rc, quant_val); - cpi->Y2zbin[Q][rc] = ((qzbin_factors_y2[Q] * quant_val) + 64) >> 7; - cpi->Y2round[Q][rc] = (qrounding_factors_y2[Q] * quant_val) >> 7; + cpi->Y2zbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7; + cpi->Y2round[Q][rc] = (qrounding_factor * quant_val) >> 7; cpi->common.Y2dequant[Q][rc] = quant_val; cpi->zrun_zbin_boost_y2[Q][i] = (quant_val * zbin_boost[i]) >> 7; @@ -1111,8 +1030,8 @@ void vp8cx_init_quantizer(VP8_COMP *cpi) cpi->UVquant_fast[Q][rc] = (1 << 16) / quant_val; invert_quant(cpi->sf.improved_quant, cpi->UVquant[Q] + rc, cpi->UVquant_shift[Q] + rc, quant_val); - cpi->UVzbin[Q][rc] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; - cpi->UVround[Q][rc] = (qrounding_factors[Q] * quant_val) >> 7; + cpi->UVzbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7; + cpi->UVround[Q][rc] = (qrounding_factor * quant_val) >> 7; cpi->common.UVdequant[Q][rc] = quant_val; cpi->zrun_zbin_boost_uv[Q][i] = (quant_val * zbin_boost[i]) >> 7; } @@ -1124,30 +1043,35 @@ void vp8cx_init_quantizer(VP8_COMP *cpi) int i; int quant_val; int Q; - int zbin_boost[16] = {0, 0, 8, 10, 12, 14, 16, 20, 24, 28, 32, 36, 40, 44, 44, 44}; + int qrounding_factor = 48; +#if CONFIG_EXTEND_QRANGE + int qzbin_factor = vp8_dc_quant(Q,0) < 148 ) ? 84: 80; +#else + int qzbin_factor = vp8_dc_quant(Q,0) < 37 ) ? 84: 80; +#endif for (Q = 0; Q < QINDEX_RANGE; Q++) { // dc values quant_val = vp8_dc_quant(Q, cpi->common.y1dc_delta_q); cpi->Y1quant[Q][0] = (1 << 16) / quant_val; - cpi->Y1zbin[Q][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; - cpi->Y1round[Q][0] = (qrounding_factors[Q] * quant_val) >> 7; + cpi->Y1zbin[Q][0] = ((qzbin_factors * quant_val) + 64) >> 7; + cpi->Y1round[Q][0] = (qrounding_factor * quant_val) >> 7; cpi->common.Y1dequant[Q][0] = quant_val; cpi->zrun_zbin_boost_y1[Q][0] = (quant_val * zbin_boost[0]) >> 7; quant_val = vp8_dc2quant(Q, cpi->common.y2dc_delta_q); cpi->Y2quant[Q][0] = (1 << 16) / quant_val; - cpi->Y2zbin[Q][0] = ((qzbin_factors_y2[Q] * quant_val) + 64) >> 7; - cpi->Y2round[Q][0] = (qrounding_factors_y2[Q] * quant_val) >> 7; + cpi->Y2zbin[Q][0] = ((qzbin_factors * quant_val) + 64) >> 7; + cpi->Y2round[Q][0] = (qrounding_factor * quant_val) >> 7; cpi->common.Y2dequant[Q][0] = quant_val; cpi->zrun_zbin_boost_y2[Q][0] = (quant_val * zbin_boost[0]) >> 7; quant_val = vp8_dc_uv_quant(Q, cpi->common.uvdc_delta_q); cpi->UVquant[Q][0] = (1 << 16) / quant_val; - cpi->UVzbin[Q][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;; - cpi->UVround[Q][0] = (qrounding_factors[Q] * quant_val) >> 7; + cpi->UVzbin[Q][0] = ((qzbin_factors * quant_val) + 64) >> 7;; + cpi->UVround[Q][0] = (qrounding_factor * quant_val) >> 7; cpi->common.UVdequant[Q][0] = quant_val; cpi->zrun_zbin_boost_uv[Q][0] = (quant_val * zbin_boost[0]) >> 7; @@ -1158,22 +1082,22 @@ void vp8cx_init_quantizer(VP8_COMP *cpi) quant_val = vp8_ac_yquant(Q); cpi->Y1quant[Q][rc] = (1 << 16) / quant_val; - cpi->Y1zbin[Q][rc] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; - cpi->Y1round[Q][rc] = (qrounding_factors[Q] * quant_val) >> 7; + cpi->Y1zbin[Q][rc] = ((qzbin_factors * quant_val) + 64) >> 7; + cpi->Y1round[Q][rc] = (qrounding_factor * quant_val) >> 7; cpi->common.Y1dequant[Q][rc] = quant_val; cpi->zrun_zbin_boost_y1[Q][i] = (quant_val * zbin_boost[i]) >> 7; quant_val = vp8_ac2quant(Q, cpi->common.y2ac_delta_q); cpi->Y2quant[Q][rc] = (1 << 16) / quant_val; - cpi->Y2zbin[Q][rc] = ((qzbin_factors_y2[Q] * quant_val) + 64) >> 7; - cpi->Y2round[Q][rc] = (qrounding_factors_y2[Q] * quant_val) >> 7; + cpi->Y2zbin[Q][rc] = ((qzbin_factors * quant_val) + 64) >> 7; + cpi->Y2round[Q][rc] = (qrounding_factors * quant_val) >> 7; cpi->common.Y2dequant[Q][rc] = quant_val; cpi->zrun_zbin_boost_y2[Q][i] = (quant_val * zbin_boost[i]) >> 7; quant_val = vp8_ac_uv_quant(Q, cpi->common.uvac_delta_q); cpi->UVquant[Q][rc] = (1 << 16) / quant_val; - cpi->UVzbin[Q][rc] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; - cpi->UVround[Q][rc] = (qrounding_factors[Q] * quant_val) >> 7; + cpi->UVzbin[Q][rc] = ((qzbin_factors * quant_val) + 64) >> 7; + cpi->UVround[Q][rc] = (qrounding_factors * quant_val) >> 7; cpi->common.UVdequant[Q][rc] = quant_val; cpi->zrun_zbin_boost_uv[Q][i] = (quant_val * zbin_boost[i]) >> 7; } |