From 067457339bc6dce72cc07cb0ebf9f549f452250a Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 24 Jan 2018 17:12:43 -0800 Subject: [PATCH] vp9-svc: Add QP dependency to thresh_svc_skip_golden. In nonrd-pickmode: the golden/spatial reference for inter-layer prediction may be skipped in the mode testing. Add QP dependency to reduce the threshold for skipping (i.e., check it more often) at high QP, if the lower layer was encoded at lower QP relative to the current layer. At high QP, a better quality lower resolution is more likely to provide good spatial (inter-layer) prediction. avgPSNR/SSIM metrics up by ~1% (all clips positive gain or neutral). Some decrease in encode time (~1-2%) expected at lower bitrates, for 3 layer SVC. Change-Id: I9ee0f62d4b10d4ebd30165d378ecfa4399ae5ef1 --- vp9/encoder/vp9_pickmode.c | 12 +++++++++++- vp9/encoder/vp9_ratectrl.c | 3 +++ vp9/encoder/vp9_svc_layercontext.h | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c index ef03384e4..185653d80 100644 --- a/vp9/encoder/vp9_pickmode.c +++ b/vp9/encoder/vp9_pickmode.c @@ -1488,7 +1488,6 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, TileDataEnc *tile_data, int skip_ref_find_pred[4] = { 0 }; unsigned int sse_zeromv_normalized = UINT_MAX; unsigned int best_sse_sofar = UINT_MAX; - unsigned int thresh_svc_skip_golden = 500; #if CONFIG_VP9_TEMPORAL_DENOISING VP9_PICKMODE_CTX_DEN ctx_den; int64_t zero_last_cost_orig = INT64_MAX; @@ -1501,6 +1500,17 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, TileDataEnc *tile_data, int flag_svc_subpel = 0; int svc_mv_col = 0; int svc_mv_row = 0; + unsigned int thresh_svc_skip_golden = 500; + // Lower the skip threshold if lower spatial layer is better quality relative + // to current layer. + if (cpi->svc.spatial_layer_id > 0 && cm->base_qindex > 150 && + cm->base_qindex > cpi->svc.lower_layer_qindex + 15) + thresh_svc_skip_golden = 100; + // Increase skip threshold if lower spatial layer is lower quality relative + // to current layer. + else if (cpi->svc.spatial_layer_id > 0 && cm->base_qindex < 140 && + cm->base_qindex < cpi->svc.lower_layer_qindex - 20) + thresh_svc_skip_golden = 1000; init_ref_frame_cost(cm, xd, ref_frame_cost); diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 3e40cce8e..72647bf8e 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -1490,6 +1490,9 @@ void vp9_rc_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) { if (cm->frame_type != KEY_FRAME) rc->reset_high_source_sad = 0; rc->last_avg_frame_bandwidth = rc->avg_frame_bandwidth; + if (cpi->use_svc && + cpi->svc.spatial_layer_id < cpi->svc.number_spatial_layers - 1) + cpi->svc.lower_layer_qindex = cm->base_qindex; } void vp9_rc_postencode_update_drop_frame(VP9_COMP *cpi) { diff --git a/vp9/encoder/vp9_svc_layercontext.h b/vp9/encoder/vp9_svc_layercontext.h index 8b708e271..87686fe59 100644 --- a/vp9/encoder/vp9_svc_layercontext.h +++ b/vp9/encoder/vp9_svc_layercontext.h @@ -103,6 +103,8 @@ typedef struct SVC { int first_layer_denoise; int skip_enhancement_layer; + + int lower_layer_qindex; } SVC; struct VP9_COMP; -- 2.40.0