From: Paul Wilkins Date: Thu, 20 Nov 2014 23:03:01 +0000 (-0800) Subject: Add adaptive midpoint for AQ1. X-Git-Tag: v1.4.0~473^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fc47c5d653342084718a70f9e7fdd5e5e267507e;p=libvpx Add adaptive midpoint for AQ1. Make the midpoint variance used in AQ mode 1 segmentation depend on the overall complexity of the frame in two pass. Change-Id: I452814ec57f7a32352e41bb250e78066abe952dd --- diff --git a/vp9/encoder/vp9_aq_variance.c b/vp9/encoder/vp9_aq_variance.c index df65696b1..5a9f8a661 100644 --- a/vp9/encoder/vp9_aq_variance.c +++ b/vp9/encoder/vp9_aq_variance.c @@ -132,8 +132,13 @@ double vp9_log_block_var(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) { return log(var + 1.0); } +#define DEFAULT_E_MIDPOINT 10.0; int vp9_block_energy(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) { double energy; - energy = 0.9 * (vp9_log_block_var(cpi, x, bs) - 10.0); + double energy_midpoint; + vp9_clear_system_state(); + energy_midpoint = + (cpi->oxcf.pass == 2) ? cpi->twopass.mb_av_energy : DEFAULT_E_MIDPOINT; + energy = vp9_log_block_var(cpi, x, bs) - energy_midpoint; return clamp((int)round(energy), ENERGY_MIN, ENERGY_MAX); } diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 2e33776fa..8f14d4c8e 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -2457,6 +2457,15 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { rc->base_frame_target = target_rate; + { + const int num_mbs = (cpi->oxcf.resize_mode != RESIZE_NONE) + ? cpi->initial_mbs : cpi->common.MBs; + // The multiplication by 256 reverses a scaling factor of (>> 8) + // applied when combining MB error values for the frame. + twopass->mb_av_energy = + log(((this_frame.intra_error * 256.0) / num_mbs) + 1.0); + } + // Update the total stats remaining structure. subtract_stats(&twopass->total_left_stats, &this_frame); } diff --git a/vp9/encoder/vp9_firstpass.h b/vp9/encoder/vp9_firstpass.h index 0a8f756bf..a8e4987cc 100644 --- a/vp9/encoder/vp9_firstpass.h +++ b/vp9/encoder/vp9_firstpass.h @@ -96,6 +96,7 @@ typedef struct { double modified_error_min; double modified_error_max; double modified_error_left; + double mb_av_energy; #if CONFIG_FP_MB_STATS uint8_t *frame_mb_stats_buf;