From 159cc3b33c718d90a1a3bae87682d1d21d4af480 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 13 Jan 2017 11:21:33 -0800 Subject: [PATCH] vp9: Add speed feature flag for computing average source sad. If enabled will compute source_sad for every superblock on every frame, prior to encoding. Off by default, only on for speed=8 when copy_partition is set. Change-Id: Iab7903180a23dad369135e8234b7f896f20e1231 --- vp9/encoder/vp9_encoder.c | 2 +- vp9/encoder/vp9_ratectrl.c | 4 ++-- vp9/encoder/vp9_speed_features.c | 2 ++ vp9/encoder/vp9_speed_features.h | 4 ++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 3fa7dbbf6..7b85e4a52 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -3165,7 +3165,7 @@ static void encode_without_recode_loop(VP9_COMP *cpi, size_t *size, if (cpi->oxcf.pass == 0 && cpi->oxcf.mode == REALTIME && cpi->oxcf.speed >= 5 && cpi->resize_state == 0 && (cpi->oxcf.content == VP9E_CONTENT_SCREEN || - cpi->oxcf.rc_mode == VPX_VBR || cpi->sf.copy_partition_flag) && + cpi->oxcf.rc_mode == VPX_VBR || cpi->sf.use_source_sad) && cm->show_frame) vp9_avg_source_sad(cpi); diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 3a5abfa20..7834393f0 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -2254,8 +2254,8 @@ void vp9_avg_source_sad(VP9_COMP *cpi) { for (sbi_row = 0; sbi_row < sb_rows; ++sbi_row) { for (sbi_col = 0; sbi_col < sb_cols; ++sbi_col) { // Checker-board pattern, ignore boundary. - // If the partition copy is on, compute for every superblock. - if (cpi->sf.copy_partition_flag || + // If the use_source_sad is on, compute for every superblock. + if (cpi->sf.use_source_sad || ((sbi_row > 0 && sbi_col > 0) && (sbi_row < sb_rows - 1 && sbi_col < sb_cols - 1) && ((sbi_row % 2 == 0 && sbi_col % 2 == 0) || diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c index 088c4d0a9..4207a88d2 100644 --- a/vp9/encoder/vp9_speed_features.c +++ b/vp9/encoder/vp9_speed_features.c @@ -312,6 +312,7 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf, int speed, sf->exhaustive_searches_thresh = INT_MAX; sf->allow_acl = 0; sf->copy_partition_flag = 0; + sf->use_source_sad = 0; if (speed >= 1) { sf->allow_txfm_domain_distortion = 1; @@ -502,6 +503,7 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf, int speed, !cpi->external_resize) sf->copy_partition_flag = 1; if (sf->copy_partition_flag) { + sf->use_source_sad = 1; if (cpi->prev_partition == NULL) { cpi->prev_partition = (BLOCK_SIZE *)vpx_calloc( cm->mi_stride * cm->mi_rows, sizeof(BLOCK_SIZE)); diff --git a/vp9/encoder/vp9_speed_features.h b/vp9/encoder/vp9_speed_features.h index 944fe6322..df93b14c8 100644 --- a/vp9/encoder/vp9_speed_features.h +++ b/vp9/encoder/vp9_speed_features.h @@ -478,6 +478,10 @@ typedef struct SPEED_FEATURES { // Global flag to enable partition copy from the previous frame. int copy_partition_flag; + + // Compute the source sad for every superblock of the frame, + // prior to encoding the frame, to be used to bypass some encoder decisions. + int use_source_sad; } SPEED_FEATURES; struct VP9_COMP;