diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c index 85e121be35b37a3556d29bde3a019f124effbbbe..b67edd39f9e060aa0c2bfc64c8c49c6d8feb4f63 100644 --- a/vp8/encoder/encodeframe.c +++ b/vp8/encoder/encodeframe.c @@ -62,7 +62,6 @@ unsigned int b_modes[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; static const int qrounding_factors[129] = { - 56, 56, 56, 56, 48, 48, 56, 56, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, @@ -78,16 +77,18 @@ 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 }; static const int qzbin_factors[129] = { - 72, 72, 72, 72, 80, 80, 72, 72, - 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, + 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, @@ -98,13 +99,11 @@ static const int qzbin_factors[129] = 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] = { - 56, 56, 56, 56, 48, 48, 56, 56, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, @@ -120,15 +119,18 @@ 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 }; static const int qzbin_factors_y2[129] = { - 72, 72, 72, 72, 80, 80, 72, 72, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, + 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, @@ -139,12 +141,10 @@ static const int qzbin_factors_y2[129] = 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 +#define EXACT_QUANT #ifdef EXACT_QUANT static void vp8cx_invert_quant(short *quant, short *shift, short d) { @@ -351,6 +351,9 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x) void vp8cx_frame_init_quantizer(VP8_COMP *cpi) { + // Clear Zbin mode boost for default case + cpi->zbin_mode_boost = 0; + // vp8cx_init_quantizer() is first called in vp8_create_compressor(). A check is added here so that vp8cx_init_quantizer() is only called // when these values are not all zero. if (cpi->common.y1dc_delta_q | cpi->common.y2dc_delta_q | cpi->common.uvdc_delta_q | cpi->common.y2ac_delta_q | cpi->common.uvac_delta_q) @@ -1214,11 +1217,25 @@ int vp8cx_encode_inter_macroblock // Experimental code. Special case for gf and arf zeromv modes. Increase zbin size to supress noise if (cpi->zbin_mode_boost_enabled) { - if ((xd->mode_info_context->mbmi.mode == ZEROMV) && (xd->mode_info_context->mbmi.ref_frame != LAST_FRAME)) - cpi->zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST; + if ( xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME ) + cpi->zbin_mode_boost = 0; else - cpi->zbin_mode_boost = 0; + { + if (xd->mode_info_context->mbmi.mode == ZEROMV) + { + if (xd->mode_info_context->mbmi.ref_frame != LAST_FRAME) + cpi->zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST; + else + cpi->zbin_mode_boost = LF_ZEROMV_ZBIN_BOOST; + } + else if (xd->mode_info_context->mbmi.mode == SPLITMV) + cpi->zbin_mode_boost = 0; + else + cpi->zbin_mode_boost = MV_ZBIN_BOOST; + } } + else + cpi->zbin_mode_boost = 0; vp8cx_mb_init_quantizer(cpi, x); } diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index bceb58602248062c6fc24e02d1a902807777cef4..93e13d139efddb4809ce6864ae21a8b4313a88e3 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -3494,8 +3494,18 @@ static void encode_frame_to_data_rate cpi->zbin_over_quant = 0; cpi->zbin_mode_boost = 0; - // Enable mode based tweaking of the zbin + // Enable or disable mode based tweaking of the zbin + // For 2 Pass Only used where GF/ARF prediction quality + // is above a threshold + cpi->zbin_mode_boost = 0; cpi->zbin_mode_boost_enabled = TRUE; + if (cpi->pass == 2) + { + if ( cpi->gfu_boost <= 400 ) + { + cpi->zbin_mode_boost_enabled = FALSE; + } + } // Current default encoder behaviour for the altref sign bias if (cpi->source_alt_ref_active) diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h index 134e03075b67db79d0a8d3deff684ef71c9c81ff..be5b00de8c71f4dc6b2fe48ff881f90ed3e0a4cf 100644 --- a/vp8/encoder/onyx_int.h +++ b/vp8/encoder/onyx_int.h @@ -46,6 +46,8 @@ #define MAX_THRESHMULT 512 #define GF_ZEROMV_ZBIN_BOOST 24 +#define LF_ZEROMV_ZBIN_BOOST 12 +#define MV_ZBIN_BOOST 4 #define ZBIN_OQ_MAX 192 #define VP8_TEMPORAL_ALT_REF 1 diff --git a/vp8/encoder/quantize.c b/vp8/encoder/quantize.c index 5e65fadb3fef292553f2eed54ab5fa0753b6b302..c2c0351c05a4fa5d6d44d125d27b8a9d9fc9de57 100644 --- a/vp8/encoder/quantize.c +++ b/vp8/encoder/quantize.c @@ -16,7 +16,7 @@ #include "entropy.h" #include "predictdc.h" -//#define EXACT_QUANT +#define EXACT_QUANT #ifdef EXACT_QUANT void vp8_fast_quantize_b_c(BLOCK *b, BLOCKD *d) { diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index 8a753fd4403f8ac2f1289f13dc1365aa64e80672..d291b9e6f29360032228047275437d17faf41b86 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -1626,10 +1626,22 @@ int vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int // Experimental code. Special case for gf and arf zeromv modes. Increase zbin size to supress noise if (cpi->zbin_mode_boost_enabled) { - if ((vp8_mode_order[mode_index] == ZEROMV) && (vp8_ref_frame_order[mode_index] != LAST_FRAME)) - cpi->zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST; - else + if ( vp8_ref_frame_order[mode_index] == INTRA_FRAME ) cpi->zbin_mode_boost = 0; + else + { + if (vp8_mode_order[mode_index] == ZEROMV) + { + if (vp8_ref_frame_order[mode_index] != LAST_FRAME) + cpi->zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST; + else + cpi->zbin_mode_boost = LF_ZEROMV_ZBIN_BOOST; + } + else if (vp8_ref_frame_order[mode_index] == SPLITMV) + cpi->zbin_mode_boost = 0; + else + cpi->zbin_mode_boost = MV_ZBIN_BOOST; + } vp8cx_mb_init_quantizer(cpi, x); }