From 999bd6ea84ca0249190dea97d5290fea5ed5c520 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 28 Jul 2017 19:11:53 -0700 Subject: [PATCH] vp9: Fix denoising condition when pickmode partition is used. When the superblock partition is based on the nonrd-pickmode, we need to avoid the denoising. Current condition was based on the speed level. This change is to make the condition at the superblock level, as the switch in partitioning may be done at sb level based on source_sad (e.g., in speed 6). Change-Id: I12ece4f60b93ed34ee65ff2d6cdce1213c36de04 --- vp9/encoder/vp9_block.h | 2 ++ vp9/encoder/vp9_context_tree.h | 1 + vp9/encoder/vp9_denoiser.c | 5 +---- vp9/encoder/vp9_encodeframe.c | 2 ++ vp9/encoder/vp9_pickmode.c | 5 +++++ 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/vp9/encoder/vp9_block.h b/vp9/encoder/vp9_block.h index e64cb1b..9fb275e 100644 --- a/vp9/encoder/vp9_block.h +++ b/vp9/encoder/vp9_block.h @@ -178,6 +178,8 @@ struct macroblock { int sb_mvrow_part; + int sb_pickmode_part; + // For each superblock: saves the content value (e.g., low/high sad/sumdiff) // based on source sad, prior to encoding the frame. uint8_t content_state_sb; diff --git a/vp9/encoder/vp9_context_tree.h b/vp9/encoder/vp9_context_tree.h index 9e4cbb3..73423c0 100644 --- a/vp9/encoder/vp9_context_tree.h +++ b/vp9/encoder/vp9_context_tree.h @@ -65,6 +65,7 @@ typedef struct { int_mv best_sse_mv; MV_REFERENCE_FRAME best_reference_frame; MV_REFERENCE_FRAME best_zeromv_reference_frame; + int sb_skip_denoising; #endif // motion vector cache for adaptive motion search control in partition diff --git a/vp9/encoder/vp9_denoiser.c b/vp9/encoder/vp9_denoiser.c index bed6439..50b495e 100644 --- a/vp9/encoder/vp9_denoiser.c +++ b/vp9/encoder/vp9_denoiser.c @@ -366,10 +366,7 @@ void vp9_denoiser_denoise(VP9_COMP *cpi, MACROBLOCK *mb, int mi_row, int mi_col, } if (!is_skin && denoiser->denoising_level == kDenHigh) increase_denoising = 1; - // TODO(marpan): There is an issue with denoising for speed 5, - // due to the partitioning scheme based on pickmode. - // Remove this speed constraint when issue is resolved. - if (denoiser->denoising_level >= kDenLow && cpi->oxcf.speed > 5) + if (denoiser->denoising_level >= kDenLow && !ctx->sb_skip_denoising) decision = perform_motion_compensation( &cpi->common, denoiser, mb, bs, increase_denoising, mi_row, mi_col, ctx, motion_magnitude, is_skin, &zeromv_filter, consec_zeromv, diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index b927bac..278f83f 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -4154,6 +4154,7 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, ThreadData *td, x->sb_use_mv_part = 0; x->sb_mvcol_part = 0; x->sb_mvrow_part = 0; + x->sb_pickmode_part = 0; if (seg->enabled) { const uint8_t *const map = @@ -4194,6 +4195,7 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, ThreadData *td, BLOCK_64X64, 1, &dummy_rdc, td->pc_root); break; case REFERENCE_PARTITION: + x->sb_pickmode_part = 1; set_offsets(cpi, tile_info, x, mi_row, mi_col, BLOCK_64X64); // Use nonrd_pick_partition on scene-cut for VBR mode. // nonrd_pick_partition does not support 4x4 partition, so avoid it diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c index a8d0648..fdd31c7 100644 --- a/vp9/encoder/vp9_pickmode.c +++ b/vp9/encoder/vp9_pickmode.c @@ -2250,6 +2250,11 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, TileDataEnc *tile_data, denoise_svc_pickmode && cpi->denoiser.denoising_level > kDenLowLow && cpi->denoiser.reset == 0) { VP9_DENOISER_DECISION decision = COPY_BLOCK; + ctx->sb_skip_denoising = 0; + // TODO(marpan): There is an issue with denoising when the + // superblock partitioning scheme is based on the pickmode. + // Remove this condition when the issue is resolved. + if (x->sb_pickmode_part) ctx->sb_skip_denoising = 1; vp9_pickmode_ctx_den_update(&ctx_den, zero_last_cost_orig, ref_frame_cost, frame_mv, reuse_inter_pred, best_tx_size, best_mode, best_ref_frame, best_pred_filter, -- 2.7.4