summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vp9/encoder/vp9_encodeframe.c22
-rw-r--r--vp9/encoder/vp9_encoder.c41
-rw-r--r--vp9/encoder/vp9_encoder.h3
-rw-r--r--vp9/encoder/vp9_firstpass.c3
-rw-r--r--vp9/encoder/vp9_speed_features.c4
-rw-r--r--vp9/encoder/vp9_speed_features.h3
-rw-r--r--vpx_util/vpx_util.mk4
7 files changed, 40 insertions, 40 deletions
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index 9f9abd20f..28a900514 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -231,6 +231,7 @@ static void set_segment_index(VP9_COMP *cpi, MACROBLOCK *const x, int mi_row,
mi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
break;
case PSNR_AQ: mi->segment_id = segment_index; break;
+ case PERCEPTUAL_AQ: mi->segment_id = x->segment_id; break;
default:
// NO_AQ or PSNR_AQ
break;
@@ -240,8 +241,6 @@ static void set_segment_index(VP9_COMP *cpi, MACROBLOCK *const x, int mi_row,
if (cpi->roi.enabled)
mi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
- if (cpi->sf.enable_wiener_variance) mi->segment_id = x->segment_id;
-
vp9_init_plane_quantizers(cpi, x);
}
@@ -1944,8 +1943,9 @@ static void set_segment_rdmult(VP9_COMP *const cpi, MACROBLOCK *const x,
vpx_clear_system_state();
if (aq_mode == NO_AQ || aq_mode == PSNR_AQ) {
- if (cpi->sf.enable_tpl_model || cpi->sf.enable_wiener_variance)
- x->rdmult = x->cb_rdmult;
+ if (cpi->sf.enable_tpl_model) x->rdmult = x->cb_rdmult;
+ } else if (aq_mode == PERCEPTUAL_AQ) {
+ x->rdmult = x->cb_rdmult;
} else if (aq_mode == CYCLIC_REFRESH_AQ) {
// If segment is boosted, use rdmult for that segment.
if (cyclic_refresh_segment_id_boosted(
@@ -1953,12 +1953,6 @@ static void set_segment_rdmult(VP9_COMP *const cpi, MACROBLOCK *const x,
x->rdmult = vp9_cyclic_refresh_get_rdmult(cpi->cyclic_refresh);
} else {
x->rdmult = vp9_compute_rd_mult(cpi, cm->base_qindex + cm->y_dc_delta_q);
- if (cpi->sf.enable_wiener_variance && cm->show_frame) {
- if (cm->seg.enabled)
- x->rdmult = vp9_compute_rd_mult(
- cpi, vp9_get_qindex(&cm->seg, x->e_mbd.mi[0]->segment_id,
- cm->base_qindex));
- }
}
if (oxcf->tuning == VP8_TUNE_SSIM) {
@@ -2200,8 +2194,8 @@ static void encode_b(VP9_COMP *cpi, const TileInfo *const tile, ThreadData *td,
MACROBLOCK *const x = &td->mb;
set_offsets(cpi, tile, x, mi_row, mi_col, bsize);
- if ((cpi->sf.enable_tpl_model || cpi->sf.enable_wiener_variance) &&
- cpi->oxcf.aq_mode == NO_AQ) {
+ if (cpi->sf.enable_tpl_model &&
+ (cpi->oxcf.aq_mode == NO_AQ || cpi->oxcf.aq_mode == PERCEPTUAL_AQ)) {
const VP9EncoderConfig *const oxcf = &cpi->oxcf;
x->rdmult = x->cb_rdmult;
if (oxcf->tuning == VP8_TUNE_SSIM) {
@@ -4423,7 +4417,7 @@ static void encode_rd_sb_row(VP9_COMP *cpi, ThreadData *td,
x->cb_rdmult = dr;
}
- if (cpi->sf.enable_wiener_variance && cm->show_frame) {
+ if (cpi->oxcf.aq_mode == PERCEPTUAL_AQ && cm->show_frame) {
x->segment_id = wiener_var_segment(cpi, BLOCK_64X64, mi_row, mi_col);
x->cb_rdmult = vp9_compute_rd_mult(
cpi, vp9_get_qindex(&cm->seg, x->segment_id, cm->base_qindex));
@@ -5987,7 +5981,7 @@ static void encode_frame_internal(VP9_COMP *cpi) {
}
// Frame segmentation
- if (cpi->sf.enable_wiener_variance) build_kmeans_segmentation(cpi);
+ if (cpi->oxcf.aq_mode == PERCEPTUAL_AQ) build_kmeans_segmentation(cpi);
{
struct vpx_usec_timer emr_timer;
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 55cfd13c6..a5b89ee96 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -988,9 +988,6 @@ static void dealloc_compressor_data(VP9_COMP *cpi) {
vpx_free(cpi->consec_zero_mv);
cpi->consec_zero_mv = NULL;
- vpx_free(cpi->stack_rank_buffer);
- cpi->stack_rank_buffer = NULL;
-
vpx_free(cpi->mb_wiener_variance);
cpi->mb_wiener_variance = NULL;
@@ -2384,17 +2381,13 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf,
}
#endif // !CONFIG_REALTIME_ONLY
+ cpi->mb_wiener_var_cols = 0;
+ cpi->mb_wiener_var_rows = 0;
+ cpi->mb_wiener_variance = NULL;
+
vp9_set_speed_features_framesize_independent(cpi, oxcf->speed);
vp9_set_speed_features_framesize_dependent(cpi, oxcf->speed);
- if (cpi->sf.enable_wiener_variance) {
- CHECK_MEM_ERROR(cm, cpi->stack_rank_buffer,
- vpx_calloc(UINT16_MAX, sizeof(*cpi->stack_rank_buffer)));
- CHECK_MEM_ERROR(cm, cpi->mb_wiener_variance,
- vpx_calloc(cm->mb_rows * cm->mb_cols,
- sizeof(*cpi->mb_wiener_variance)));
- }
-
{
const int bsize = BLOCK_64X64;
const int w = num_8x8_blocks_wide_lookup[bsize];
@@ -4842,6 +4835,23 @@ static int qsort_comp(const void *elem1, const void *elem2) {
return 0;
}
+static void init_mb_wiener_var_buffer(VP9_COMP *cpi) {
+ VP9_COMMON *cm = &cpi->common;
+
+ if (cpi->mb_wiener_variance && cpi->mb_wiener_var_rows >= cm->mb_rows &&
+ cpi->mb_wiener_var_cols >= cm->mb_cols)
+ return;
+
+ vpx_free(cpi->mb_wiener_variance);
+ cpi->mb_wiener_variance = NULL;
+
+ CHECK_MEM_ERROR(
+ cm, cpi->mb_wiener_variance,
+ vpx_calloc(cm->mb_rows * cm->mb_cols, sizeof(*cpi->mb_wiener_variance)));
+ cpi->mb_wiener_var_rows = cm->mb_rows;
+ cpi->mb_wiener_var_cols = cm->mb_cols;
+}
+
static void set_mb_wiener_variance(VP9_COMP *cpi) {
VP9_COMMON *cm = &cpi->common;
uint8_t *buffer = cpi->Source->y_buffer;
@@ -4867,8 +4877,6 @@ static void set_mb_wiener_variance(VP9_COMP *cpi) {
const int coeff_count = block_size * block_size;
const TX_SIZE tx_size = TX_16X16;
- if (cpi->sf.enable_wiener_variance == 0) return;
-
#if CONFIG_VP9_HIGHBITDEPTH
xd->cur_buf = cpi->Source;
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
@@ -4912,7 +4920,7 @@ static void set_mb_wiener_variance(VP9_COMP *cpi) {
coeff[0] = 0;
for (idx = 1; idx < coeff_count; ++idx) coeff[idx] = abs(coeff[idx]);
- qsort(coeff, coeff_count, sizeof(*coeff), qsort_comp);
+ qsort(coeff, coeff_count - 1, sizeof(*coeff), qsort_comp);
// Noise level estimation
median_val = coeff[coeff_count / 2];
@@ -5027,7 +5035,10 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, size_t *size,
if (oxcf->tuning == VP8_TUNE_SSIM) set_mb_ssim_rdmult_scaling(cpi);
- set_mb_wiener_variance(cpi);
+ if (oxcf->aq_mode == PERCEPTUAL_AQ) {
+ init_mb_wiener_var_buffer(cpi);
+ set_mb_wiener_variance(cpi);
+ }
vpx_clear_system_state();
diff --git a/vp9/encoder/vp9_encoder.h b/vp9/encoder/vp9_encoder.h
index dcf318e29..f448f961c 100644
--- a/vp9/encoder/vp9_encoder.h
+++ b/vp9/encoder/vp9_encoder.h
@@ -644,8 +644,9 @@ typedef struct VP9_COMP {
int64_t norm_wiener_variance;
int64_t *mb_wiener_variance;
+ int mb_wiener_var_rows;
+ int mb_wiener_var_cols;
double *mi_ssim_rdmult_scaling_factors;
- int *stack_rank_buffer;
YV12_BUFFER_CONFIG last_frame_uf;
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 97c6e8cd7..726724ec5 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -3379,7 +3379,8 @@ void vp9_twopass_postencode_update(VP9_COMP *cpi) {
// Extend min or Max Q range to account for imbalance from the base
// value when using AQ.
- if (cpi->oxcf.aq_mode != NO_AQ) {
+ if (cpi->oxcf.aq_mode != NO_AQ && cpi->oxcf.aq_mode != PSNR_AQ &&
+ cpi->oxcf.aq_mode != PERCEPTUAL_AQ) {
if (cm->seg.aq_av_offset < 0) {
// The balance of the AQ map tends towarda lowering the average Q.
aq_extend_min = 0;
diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c
index b12364f6d..18130dded 100644
--- a/vp9/encoder/vp9_speed_features.c
+++ b/vp9/encoder/vp9_speed_features.c
@@ -955,10 +955,6 @@ void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi, int speed) {
sf->tx_size_search_breakout = 1;
sf->tx_size_search_depth = 2;
- // Manually turn this on during experimentation. Off by default to disable its
- // effect on the baseline encoder.
- sf->enable_wiener_variance = 0;
-
sf->exhaustive_searches_thresh =
(cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) ? (1 << 20)
: INT_MAX;
diff --git a/vp9/encoder/vp9_speed_features.h b/vp9/encoder/vp9_speed_features.h
index 6b04a3ad4..eb0628199 100644
--- a/vp9/encoder/vp9_speed_features.h
+++ b/vp9/encoder/vp9_speed_features.h
@@ -288,9 +288,6 @@ typedef struct SPEED_FEATURES {
// level within a frame.
int allow_skip_recode;
- // Enable Wiener filter based block complexity analysis.
- int enable_wiener_variance;
-
// Coefficient probability model approximation step size
int coeff_prob_appx_step;
diff --git a/vpx_util/vpx_util.mk b/vpx_util/vpx_util.mk
index 03da63b5a..e83a4c4ec 100644
--- a/vpx_util/vpx_util.mk
+++ b/vpx_util/vpx_util.mk
@@ -15,5 +15,5 @@ UTIL_SRCS-yes += vpx_thread.h
UTIL_SRCS-yes += endian_inl.h
UTIL_SRCS-yes += vpx_write_yuv_frame.h
UTIL_SRCS-yes += vpx_write_yuv_frame.c
-UTIL_SRCS-yes += vpx_debug_util.h
-UTIL_SRCS-yes += vpx_debug_util.c
+UTIL_SRCS-$(CONFIG_BITSTREAM_DEBUG) += vpx_debug_util.h
+UTIL_SRCS-$(CONFIG_BITSTREAM_DEBUG) += vpx_debug_util.c