ref: ae244efb85a9735c4b0f58fae40c97b053b82985
parent: f6f0ffe96a69d7de718b9528dcc3f6f66b9cb92d
parent: 28de670cd990e8d1da8ffafb34d1bc24c9c2299a
author: Paul Wilkins <paulwilkins@google.com>
date: Wed Jun 9 23:04:45 EDT 2010
Merge "Fix RD bug."
--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -1869,6 +1869,14 @@
}
}
+ // Keep a globally available copy of this frames iiratio and the next.
+ cpi->this_iiratio = this_frame_intra_error / DOUBLE_DIVIDE_CHECK(this_frame_coded_error);
+ {
+ FIRSTPASS_STATS next_frame;
+ if ( lookup_next_frame_stats(cpi, &next_frame) != EOF )
+ cpi->next_iiratio = next_frame.intra_error / DOUBLE_DIVIDE_CHECK(next_frame.coded_error);
+ }
+
// Set nominal per second bandwidth for this frame
cpi->target_bandwidth = cpi->per_frame_bandwidth * cpi->output_frame_rate;
if (cpi->target_bandwidth < 0)
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -171,7 +171,7 @@
}
-static int rd_iifactor [ 32 ] = { 16, 16, 16, 12, 8, 4, 2, 0,
+static int rd_iifactor [ 32 ] = { 4, 4, 3, 2, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -178,8 +178,6 @@
};
-
-
// The values in this table should be reviewed
static int sad_per_bit16lut[128] =
{
@@ -238,20 +236,20 @@
vp8_clear_system_state(); //__asm emms;
- cpi->RDMULT = (int)((0.00007 * (capped_q * capped_q * capped_q * capped_q)) - (0.0125 * (capped_q * capped_q * capped_q)) +
- (2.25 * (capped_q * capped_q)) - (12.5 * capped_q) + 25.0);
+ cpi->RDMULT = (int)( (0.0001 * (capped_q * capped_q * capped_q * capped_q))
+ -(0.0125 * (capped_q * capped_q * capped_q))
+ +(3.25 * (capped_q * capped_q))
+ -(12.5 * capped_q) + 50.0);
- if (cpi->RDMULT < 25)
- cpi->RDMULT = 25;
+ if (cpi->RDMULT < 50)
+ cpi->RDMULT = 50;
- if (cpi->pass == 2)
+ if (cpi->pass == 2 && (cpi->common.frame_type != KEY_FRAME))
{
- if (cpi->common.frame_type == KEY_FRAME)
- cpi->RDMULT += (cpi->RDMULT * rd_iifactor[0]) / 16;
- else if (cpi->next_iiratio > 31)
- cpi->RDMULT += (cpi->RDMULT * rd_iifactor[31]) / 16;
+ if (cpi->next_iiratio > 31)
+ cpi->RDMULT += (cpi->RDMULT * rd_iifactor[31]) >> 4;
else
- cpi->RDMULT += (cpi->RDMULT * rd_iifactor[cpi->next_iiratio]) / 16;
+ cpi->RDMULT += (cpi->RDMULT * rd_iifactor[cpi->next_iiratio]) >> 4;
}
@@ -258,16 +256,12 @@
// Extend rate multiplier along side quantizer zbin increases
if (cpi->zbin_over_quant > 0)
{
- // Extend rate multiplier along side quantizer zbin increases
- if (cpi->zbin_over_quant > 0)
- {
- double oq_factor = pow(1.006, cpi->zbin_over_quant);
+ double oq_factor = pow(1.006, cpi->zbin_over_quant);
- if (oq_factor > (1.0 + ((double)cpi->zbin_over_quant / 64.0)))
- oq_factor = (1.0 + (double)cpi->zbin_over_quant / 64.0);
+ if (oq_factor > (1.0 + ((double)cpi->zbin_over_quant / 64.0)))
+ oq_factor = (1.0 + (double)cpi->zbin_over_quant / 64.0);
- cpi->RDMULT = (int)(oq_factor * cpi->RDMULT);
- }
+ cpi->RDMULT = (int)(oq_factor * cpi->RDMULT);
}
cpi->mb.errorperbit = (cpi->RDMULT / 100);