From 64baa8df2e3f5cd8036fac9715d3f7d348620fa6 Mon Sep 17 00:00:00 2001 From: Scott LaVarnway Date: Thu, 16 Dec 2010 17:01:27 -0500 Subject: [PATCH] Changed segmentation check order In SPLITMV, the 8x8 segment will be checked first. If the 8x8 rd is better than the best, we check the other segments. Otherwise bail. Adjustments to the thresh_mult were necessary to make up for the initial quality loss. The performance improved by 20% (average) for good quality, speed 0 and speed 1, while the overall quality remained the same. Change-Id: I717aef401323c8a254fba3e9777d2a316c774cc3 --- vp8/encoder/onyx_if.c | 30 ++++++++++++++++++++++++++++-- vp8/encoder/rdopt.c | 31 ++++++++++++++++++++++--------- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 3ccffb7..279d50d 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -683,6 +683,32 @@ void vp8_set_speed_features(VP8_COMP *cpi) sf->thresh_mult[THR_NEARG ] = 1000; sf->thresh_mult[THR_NEARA ] = 1000; +#if 1 + sf->thresh_mult[THR_ZEROMV ] = 0; + sf->thresh_mult[THR_ZEROG ] = 0; + sf->thresh_mult[THR_ZEROA ] = 0; + sf->thresh_mult[THR_NEARESTMV] = 0; + sf->thresh_mult[THR_NEARESTG ] = 0; + sf->thresh_mult[THR_NEARESTA ] = 0; + sf->thresh_mult[THR_NEARMV ] = 0; + sf->thresh_mult[THR_NEARG ] = 0; + sf->thresh_mult[THR_NEARA ] = 0; + +// sf->thresh_mult[THR_DC ] = 0; + +// sf->thresh_mult[THR_V_PRED ] = 1000; +// sf->thresh_mult[THR_H_PRED ] = 1000; +// sf->thresh_mult[THR_B_PRED ] = 2000; +// sf->thresh_mult[THR_TM ] = 1000; + + sf->thresh_mult[THR_NEWMV ] = 1000; + sf->thresh_mult[THR_NEWG ] = 1000; + sf->thresh_mult[THR_NEWA ] = 1000; + + sf->thresh_mult[THR_SPLITMV ] = 1700; + sf->thresh_mult[THR_SPLITG ] = 4500; + sf->thresh_mult[THR_SPLITA ] = 4500; +#else sf->thresh_mult[THR_NEWMV ] = 1500; sf->thresh_mult[THR_NEWG ] = 1500; sf->thresh_mult[THR_NEWA ] = 1500; @@ -690,7 +716,7 @@ void vp8_set_speed_features(VP8_COMP *cpi) sf->thresh_mult[THR_SPLITMV ] = 5000; sf->thresh_mult[THR_SPLITG ] = 10000; sf->thresh_mult[THR_SPLITA ] = 10000; - +#endif sf->full_freq[0] = 15; sf->full_freq[1] = 31; @@ -731,7 +757,7 @@ void vp8_set_speed_features(VP8_COMP *cpi) cpi->mode_check_freq[THR_SPLITG] = 4; cpi->mode_check_freq[THR_SPLITA] = 4; - cpi->mode_check_freq[THR_SPLITMV] = 2; + cpi->mode_check_freq[THR_SPLITMV] = 0; sf->thresh_mult[THR_TM ] = 1500; sf->thresh_mult[THR_V_PRED ] = 1500; diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index b541da7..f1e0579 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -1038,7 +1038,7 @@ typedef struct int d; int segment_yrate; B_PREDICTION_MODE modes[16]; - MV mvs[16]; + int_mv mvs[16]; unsigned char eobs[16]; int mvthresh; @@ -1276,7 +1276,7 @@ void vp8_rd_check_segment(VP8_COMP *cpi, MACROBLOCK *x, BEST_SEG_INFO *bsi, { BLOCKD *bd = &x->e_mbd.block[i]; - bsi->mvs[i] = bd->bmi.mv.as_mv; + bsi->mvs[i].as_mv = bd->bmi.mv.as_mv; bsi->modes[i] = bd->bmi.mode; bsi->eobs[i] = bd->eob; } @@ -1305,19 +1305,32 @@ static int vp8_rd_pick_best_mbsegmentation(VP8_COMP *cpi, MACROBLOCK *x, { bsi.modes[i] = ZERO4X4; } - - /* original */ - vp8_rd_check_segment(cpi, x, &bsi, 0); - vp8_rd_check_segment(cpi, x, &bsi, 1); - vp8_rd_check_segment(cpi, x, &bsi, 2); - vp8_rd_check_segment(cpi, x, &bsi, 3); + if(cpi->compressor_speed == 0) + { + /* for now, we will keep the original segmentation order + when in best quality mode */ + vp8_rd_check_segment(cpi, x, &bsi, BLOCK_16X8); + vp8_rd_check_segment(cpi, x, &bsi, BLOCK_8X16); + vp8_rd_check_segment(cpi, x, &bsi, BLOCK_8X8); + vp8_rd_check_segment(cpi, x, &bsi, BLOCK_4X4); + } + else + { + vp8_rd_check_segment(cpi, x, &bsi, BLOCK_8X8); + if (bsi.segment_rd < best_rd) + { + vp8_rd_check_segment(cpi, x, &bsi, BLOCK_8X16); + vp8_rd_check_segment(cpi, x, &bsi, BLOCK_16X8); + vp8_rd_check_segment(cpi, x, &bsi, BLOCK_4X4); + } + } /* set it to the best */ for (i = 0; i < 16; i++) { BLOCKD *bd = &x->e_mbd.block[i]; - bd->bmi.mv.as_mv = bsi.mvs[i]; + bd->bmi.mv.as_mv = bsi.mvs[i].as_mv; bd->bmi.mode = bsi.modes[i]; bd->eob = bsi.eobs[i]; } -- 2.7.4