From 019384f2d365e4265b554e235c7d669b69ef35c0 Mon Sep 17 00:00:00 2001 From: Yunqing Wang <yunqingwang@google.com> Date: Mon, 27 Feb 2012 17:38:53 -0500 Subject: [PATCH] Only do uv intra-mode evaluation when intra mode is checked When we encode slide-show clips, for the majority of the time, only ZEROMV mode is checked, and all other modes are skipped. This change delayed uv intra-mode evaluation until intra mode is actually checked. This gave big performance gain for slide-show video encoding (2nd pass gain: 18% to 28%). But, this change doesn't help other types of videos. Also, zbin_mode_boost is adjusted in mode-checking loop, which causes bitstream mismatch before/after this change when --best or --good with --cpu-used=0 are used. Change-Id: I582b3e69fd384039994360e870e6e059c36a64cc --- vp8/encoder/rdopt.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index 528e6bedf4..0019cb0708 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -1738,11 +1738,12 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int rate2, distortion2; int uv_intra_rate, uv_intra_distortion, uv_intra_rate_tokenonly; int uv_intra_tteob = 0; + int uv_intra_done = 0; int rate_y, UNINITIALIZED_IS_SAFE(rate_uv); int distortion_uv; int best_yrd = INT_MAX; - MB_PREDICTION_MODE uv_intra_mode; + MB_PREDICTION_MODE uv_intra_mode = 0; int_mv mvp; int near_sadidx[8] = {0, 1, 2, 3, 4, 5, 6, 7}; int saddone=0; @@ -1785,17 +1786,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, x->skip = 0; - x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME; - rd_pick_intra_mbuv_mode(cpi, x, &uv_intra_rate, &uv_intra_rate_tokenonly, &uv_intra_distortion); - uv_intra_mode = x->e_mbd.mode_info_context->mbmi.uv_mode; - /* - * Total of the eobs is used later to further adjust rate2. Since uv block's - * intra eobs will be overwritten when we check inter modes in following - * for-loop, we need to save uv_intra_tteob here. - */ - for (i = 16; i < 24; i++) - uv_intra_tteob += x->e_mbd.eobs[i]; - for (mode_index = 0; mode_index < MAX_MODES; mode_index++) { int this_rd = INT_MAX; @@ -1817,7 +1807,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, this_mode = vp8_mode_order[mode_index]; x->e_mbd.mode_info_context->mbmi.mode = this_mode; - x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED; x->e_mbd.mode_info_context->mbmi.ref_frame = this_ref_frame; // Only consider ZEROMV/ALTREF_FRAME for alt ref frame, @@ -1888,6 +1877,24 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, vp8_update_zbin_extra(cpi, x); } + if(!uv_intra_done && this_ref_frame == INTRA_FRAME) + { + rd_pick_intra_mbuv_mode(cpi, x, &uv_intra_rate, + &uv_intra_rate_tokenonly, + &uv_intra_distortion); + uv_intra_mode = x->e_mbd.mode_info_context->mbmi.uv_mode; + + /* + * Total of the eobs is used later to further adjust rate2. Since uv + * block's intra eobs will be overwritten when we check inter modes, + * we need to save uv_intra_tteob here. + */ + for (i = 16; i < 24; i++) + uv_intra_tteob += x->e_mbd.eobs[i]; + + uv_intra_done = 1; + } + switch (this_mode) { case B_PRED: -- GitLab