From c8678fb7f38024345462cfab3b34d649548ff445 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 3 Oct 2017 10:55:55 -0700 Subject: [PATCH] Use adapt_partition for ARF in 1 pass. For speed 6 real-time mode: use adapt_partition on ARF frame instead of REFERENCE_PARTITION (which is slower). This requires enabling compute_source_sad_onepass for no-show_frames. Speedup of ~3-5% on some clips that heavily use ARF, small loss (~0.2%) in quality on ytlive set. Change-Id: Ib50acc97df06458244a6ac55d2bd882c30012536 --- vp9/encoder/vp9_encodeframe.c | 2 +- vp9/encoder/vp9_encoder.c | 5 ++--- vp9/encoder/vp9_speed_features.c | 8 ++------ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index a401176d4..4d7d28500 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -4183,7 +4183,7 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, ThreadData *td, if (sf->adapt_partition_source_sad && (cpi->oxcf.rc_mode == VPX_VBR && !cpi->rc.is_src_frame_alt_ref && source_sad > sf->adapt_partition_thresh && - cpi->refresh_golden_frame)) + (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame))) partition_search_type = REFERENCE_PARTITION; } diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 37ecca711..765c0578b 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -3438,8 +3438,7 @@ static void encode_without_recode_loop(VP9_COMP *cpi, size_t *size, // Flag to check if its valid to compute the source sad (used for // scene detection and for superblock content state in CBR mode). // The flag may get reset below based on SVC or resizing state. - cpi->compute_source_sad_onepass = - cpi->oxcf.mode == REALTIME && cm->show_frame; + cpi->compute_source_sad_onepass = cpi->oxcf.mode == REALTIME; vpx_clear_system_state(); @@ -3532,7 +3531,7 @@ static void encode_without_recode_loop(VP9_COMP *cpi, size_t *size, // For other cases (e.g., CBR mode) use it for 5 <= speed < 8 for now // (need to check encoding time cost for doing this for speed 8). cpi->rc.high_source_sad = 0; - if (cpi->compute_source_sad_onepass && + if (cpi->compute_source_sad_onepass && cm->show_frame && (cpi->oxcf.rc_mode == VPX_VBR || cpi->oxcf.content == VP9E_CONTENT_SCREEN || (cpi->oxcf.speed >= 5 && cpi->oxcf.speed < 8 && !cpi->use_svc))) diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c index c9821dec3..4dcecd563 100644 --- a/vp9/encoder/vp9_speed_features.c +++ b/vp9/encoder/vp9_speed_features.c @@ -527,12 +527,6 @@ static void set_rt_speed_feature_framesize_independent( if (speed >= 6) { sf->partition_search_type = VAR_BASED_PARTITION; - if (cpi->oxcf.rc_mode == VPX_VBR && cpi->oxcf.lag_in_frames > 0 && - !is_keyframe) { - if (sf->use_altref_onepass && cpi->refresh_alt_ref_frame) { - sf->partition_search_type = REFERENCE_PARTITION; - } - } // Turn on this to use non-RD key frame coding mode. sf->use_nonrd_pick_mode = 1; sf->mv.search_method = NSTEP; @@ -545,6 +539,8 @@ static void set_rt_speed_feature_framesize_independent( sf->adapt_partition_source_sad = 1; sf->adapt_partition_thresh = (cm->width * cm->height <= 640 * 360) ? 40000 : 80000; + if (sf->use_altref_onepass && cpi->refresh_alt_ref_frame && !is_keyframe) + sf->adapt_partition_thresh = (3 * sf->adapt_partition_thresh) >> 2; if (cpi->content_state_sb_fd == NULL && (!cpi->use_svc || cpi->svc.spatial_layer_id == cpi->svc.number_spatial_layers - 1)) { -- 2.40.0