Commit fc47c5d6 authored by Paul Wilkins's avatar Paul Wilkins
Browse files

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
parent d0312379
......@@ -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);
}
......@@ -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);
}
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment