summaryrefslogtreecommitdiff
path: root/vp8/encoder/encodeframe.c
diff options
context:
space:
mode:
authorScott LaVarnway <slavarnway@google.com>2010-12-29 14:30:57 -0500
committerScott LaVarnway <slavarnway@google.com>2011-01-24 11:00:56 -0500
commit0ee525d6deff6f047bc152119dd74a0149b815f3 (patch)
treecbd6e7ffbe898d506140b65db4bdb2dedcc31b86 /vp8/encoder/encodeframe.c
parentd3e9409bb07e6411ff867935883bd5d56d2f9041 (diff)
downloadlibvpx-0ee525d6deff6f047bc152119dd74a0149b815f3.tar
libvpx-0ee525d6deff6f047bc152119dd74a0149b815f3.tar.gz
libvpx-0ee525d6deff6f047bc152119dd74a0149b815f3.tar.bz2
libvpx-0ee525d6deff6f047bc152119dd74a0149b815f3.zip
Added vp8_update_zbin_extra
vp8cx_mb_init_quantizer was being called for every mode checked in vp8_rd_pick_inter_mode. zbin_extra is the only value that really needs to be recalculated. This calculation is disabled when using the fast quantizer for mode selection. This gave a small performance boost (~.5% to 1%). Note: This needs to be verified with segmentation_enabled. Change-Id: I62716a870b3c82b4a998bdf95130ff0b02106f1e
Diffstat (limited to 'vp8/encoder/encodeframe.c')
-rw-r--r--vp8/encoder/encodeframe.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c
index 4c95f28d6..1689b43d1 100644
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -365,6 +365,33 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
x->e_mbd.block[24].dequant = cpi->common.Y2dequant[QIndex];
x->block[24].zrun_zbin_boost = cpi->zrun_zbin_boost_y2[QIndex];
x->block[24].zbin_extra = (short)zbin_extra;
+
+ /* save this macroblock QIndex for vp8_update_zbin_extra() */
+ x->q_index = QIndex;
+}
+void vp8_update_zbin_extra(VP8_COMP *cpi, MACROBLOCK *x)
+{
+ int i;
+ int QIndex = x->q_index;
+ int zbin_extra;
+
+ // Y
+ zbin_extra = (cpi->common.Y1dequant[QIndex][1] * (cpi->zbin_over_quant + cpi->zbin_mode_boost)) >> 7;
+ for (i = 0; i < 16; i++)
+ {
+ x->block[i].zbin_extra = (short)zbin_extra;
+ }
+
+ // UV
+ zbin_extra = (cpi->common.UVdequant[QIndex][1] * (cpi->zbin_over_quant + cpi->zbin_mode_boost)) >> 7;
+ for (i = 16; i < 24; i++)
+ {
+ x->block[i].zbin_extra = (short)zbin_extra;
+ }
+
+ // Y2
+ zbin_extra = (cpi->common.Y2dequant[QIndex][1] * ((cpi->zbin_over_quant / 2) + cpi->zbin_mode_boost)) >> 7;
+ x->block[24].zbin_extra = (short)zbin_extra;
}
void vp8cx_frame_init_quantizer(VP8_COMP *cpi)
@@ -1261,10 +1288,17 @@ int vp8cx_encode_inter_macroblock
if (cpi->sf.RD)
{
+ int zbin_mode_boost_enabled = cpi->zbin_mode_boost_enabled;
+
/* Are we using the fast quantizer for the mode selection? */
if(cpi->sf.use_fastquant_for_pick)
+ {
cpi->mb.quantize_b = QUANTIZE_INVOKE(&cpi->rtcd.quantize, fastquantb);
+ /* the fast quantizer does not use zbin_extra, so
+ * do not recalculate */
+ cpi->zbin_mode_boost_enabled = 0;
+ }
inter_error = vp8_rd_pick_inter_mode(cpi, x, recon_yoffset, recon_uvoffset, &rate, &distortion, &intra_error);
/* switch back to the regular quantizer for the encode */
@@ -1273,6 +1307,9 @@ int vp8cx_encode_inter_macroblock
cpi->mb.quantize_b = QUANTIZE_INVOKE(&cpi->rtcd.quantize, quantb);
}
+ /* restore cpi->zbin_mode_boost_enabled */
+ cpi->zbin_mode_boost_enabled = zbin_mode_boost_enabled;
+
}
else
#endif
@@ -1289,7 +1326,7 @@ int vp8cx_encode_inter_macroblock
#endif
// MB level adjutment to quantizer setup
- if (xd->segmentation_enabled || cpi->zbin_mode_boost_enabled)
+ if (xd->segmentation_enabled)
{
// If cyclic update enabled
if (cpi->cyclic_refresh_mode_enabled)
@@ -1299,9 +1336,14 @@ int vp8cx_encode_inter_macroblock
((xd->mode_info_context->mbmi.ref_frame != LAST_FRAME) || (xd->mode_info_context->mbmi.mode != ZEROMV)))
{
xd->mode_info_context->mbmi.segment_id = 0;
+
+ /* segment_id changed, so update */
+ vp8cx_mb_init_quantizer(cpi, x);
}
}
+ }
+ {
// Experimental code. Special case for gf and arf zeromv modes. Increase zbin size to supress noise
if (cpi->zbin_mode_boost_enabled)
{
@@ -1325,7 +1367,7 @@ int vp8cx_encode_inter_macroblock
else
cpi->zbin_mode_boost = 0;
- vp8cx_mb_init_quantizer(cpi, x);
+ vp8_update_zbin_extra(cpi, x);
}
cpi->count_mb_ref_frame_usage[xd->mode_info_context->mbmi.ref_frame] ++;