diff options
author | Marco <marpan@google.com> | 2015-12-01 09:30:35 -0800 |
---|---|---|
committer | Marco <marpan@google.com> | 2015-12-01 09:39:01 -0800 |
commit | 1abf575f326c8e7163ffc0122595d2537e207f96 (patch) | |
tree | 58bc3ce07e6d7043de6c8ac7abcaed42272a9235 | |
parent | f78b7daec44643b87861e48ea8b0f9a981b7a735 (diff) | |
download | libvpx-1abf575f326c8e7163ffc0122595d2537e207f96.tar libvpx-1abf575f326c8e7163ffc0122595d2537e207f96.tar.gz libvpx-1abf575f326c8e7163ffc0122595d2537e207f96.tar.bz2 libvpx-1abf575f326c8e7163ffc0122595d2537e207f96.zip |
vp9 denoiser: Re-evaluate mode selection for golden reference.
Under certain denoising conditons, check for re-evaluation of
zero_last mode if best mode was golden reference.
Change-Id: Ic6cdfd175eef2f7d68606300c7173ab6654b3f6e
-rw-r--r-- | vp9/encoder/vp9_denoiser.c | 10 | ||||
-rw-r--r-- | vp9/encoder/vp9_denoiser.h | 3 | ||||
-rw-r--r-- | vp9/encoder/vp9_pickmode.c | 22 |
3 files changed, 25 insertions, 10 deletions
diff --git a/vp9/encoder/vp9_denoiser.c b/vp9/encoder/vp9_denoiser.c index fc76c11c4..93aa40ae9 100644 --- a/vp9/encoder/vp9_denoiser.c +++ b/vp9/encoder/vp9_denoiser.c @@ -194,7 +194,8 @@ static VP9_DENOISER_DECISION perform_motion_compensation(VP9_DENOISER *denoiser, int mi_col, PICK_MODE_CONTEXT *ctx, int motion_magnitude, - int is_skin) { + int is_skin, + int *zeromv_filter) { int mv_col, mv_row; int sse_diff = ctx->zeromv_sse - ctx->newmv_sse; MV_REFERENCE_FRAME frame; @@ -237,6 +238,7 @@ static VP9_DENOISER_DECISION perform_motion_compensation(VP9_DENOISER *denoiser, mbmi->mv[0].as_int = 0; ctx->best_sse_inter_mode = ZEROMV; ctx->best_sse_mv.as_int = 0; + *zeromv_filter = 1; } if (ctx->newmv_sse > sse_thresh(bs, increase_denoising)) { @@ -320,6 +322,7 @@ void vp9_denoiser_denoise(VP9_DENOISER *denoiser, MACROBLOCK *mb, VP9_DENOISER_DECISION *denoiser_decision) { int mv_col, mv_row; int motion_magnitude = 0; + int zeromv_filter = 0; VP9_DENOISER_DECISION decision = COPY_BLOCK; YV12_BUFFER_CONFIG avg = denoiser->running_avg_y[INTRA_FRAME]; YV12_BUFFER_CONFIG mc_avg = denoiser->mc_running_avg_y; @@ -360,7 +363,8 @@ void vp9_denoiser_denoise(VP9_DENOISER *denoiser, MACROBLOCK *mb, denoiser->increase_denoising, mi_row, mi_col, ctx, motion_magnitude, - is_skin); + is_skin, + &zeromv_filter); if (decision == FILTER_BLOCK) { decision = vp9_denoiser_filter(src.buf, src.stride, @@ -382,6 +386,8 @@ void vp9_denoiser_denoise(VP9_DENOISER *denoiser, MACROBLOCK *mb, num_4x4_blocks_high_lookup[bs] << 2); } *denoiser_decision = decision; + if (decision == FILTER_BLOCK && zeromv_filter == 1) + *denoiser_decision = FILTER_ZEROMV_BLOCK; } static void copy_frame(YV12_BUFFER_CONFIG * const dest, diff --git a/vp9/encoder/vp9_denoiser.h b/vp9/encoder/vp9_denoiser.h index c8c93528b..d07056b45 100644 --- a/vp9/encoder/vp9_denoiser.h +++ b/vp9/encoder/vp9_denoiser.h @@ -23,7 +23,8 @@ extern "C" { typedef enum vp9_denoiser_decision { COPY_BLOCK, - FILTER_BLOCK + FILTER_BLOCK, + FILTER_ZEROMV_BLOCK } VP9_DENOISER_DECISION; typedef enum vp9_denoiser_level { diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c index 095847a23..412cf1b6e 100644 --- a/vp9/encoder/vp9_pickmode.c +++ b/vp9/encoder/vp9_pickmode.c @@ -1696,11 +1696,11 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, VP9_DENOISER_DECISION decision = COPY_BLOCK; vp9_denoiser_denoise(&cpi->denoiser, x, mi_row, mi_col, VPXMAX(BLOCK_8X8, bsize), ctx, &decision); - // If INTRA mode was selected, re-evaluate ZEROMV on denoised result. - // Only do this under noise conditions, and if rdcost of ZEROMV on - // original source is not significantly higher than rdcost of INTRA MODE. - if (best_ref_frame == INTRA_FRAME && - decision == FILTER_BLOCK && + // If INTRA or GOLDEN reference was selected, re-evaluate ZEROMV on denoised + // result. Only do this under noise conditions, and if rdcost of ZEROMV on + // original source is not significantly higher than rdcost of best mode. + if (((best_ref_frame == INTRA_FRAME && decision >= FILTER_BLOCK) || + (best_ref_frame == GOLDEN_FRAME && decision == FILTER_ZEROMV_BLOCK)) && cpi->noise_estimate.enabled && cpi->noise_estimate.level > kLow && zero_last_cost_orig < (best_rdc.rdcost << 2)) { @@ -1721,13 +1721,21 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, this_rdc.dist = dist; this_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, rate, dist); // Switch to ZEROMV if the rdcost for ZEROMV on denoised source - // is lower than INTRA (on original source). + // is lower than best_ref mode (on original source). if (this_rdc.rdcost > best_rdc.rdcost) { this_rdc = best_rdc; mbmi->mode = best_mode; mbmi->ref_frame[0] = best_ref_frame; - mbmi->mv[0].as_int = INVALID_MV; mbmi->interp_filter = best_pred_filter; + if (best_ref_frame == INTRA_FRAME) + mbmi->mv[0].as_int = INVALID_MV; + else if (best_ref_frame == GOLDEN_FRAME) { + mbmi->mv[0].as_int = frame_mv[best_mode][best_ref_frame].as_int; + if (reuse_inter_pred) { + xd->plane[0].pre[0] = yv12_mb[GOLDEN_FRAME][0]; + vp9_build_inter_predictors_sby(xd, mi_row, mi_col, bsize); + } + } mbmi->tx_size = best_tx_size; x->skip_txfm[0] = best_mode_skip_txfm; } else { |