Merge remote branch 'internal/upstream' into HEAD

This commit is contained in:
John Koleszar 2010-11-13 00:05:05 -05:00
Родитель adbb1de01c 8c2dfde3ed
Коммит 9b5cd1c3ff
4 изменённых файлов: 75 добавлений и 55 удалений

Просмотреть файл

@ -146,8 +146,11 @@ static const int qzbin_factors_y2[129] =
#define EXACT_QUANT #define EXACT_QUANT
#ifdef EXACT_QUANT #ifdef EXACT_QUANT
static void vp8cx_invert_quant(short *quant, short *shift, short d) static void vp8cx_invert_quant(int improved_quant, short *quant,
short *shift, short d)
{ {
if(improved_quant)
{
unsigned t; unsigned t;
int l; int l;
t = d; t = d;
@ -156,6 +159,12 @@ static void vp8cx_invert_quant(short *quant, short *shift, short d)
t = 1 + (1<<(16+l))/d; t = 1 + (1<<(16+l))/d;
*quant = (short)(t - (1<<16)); *quant = (short)(t - (1<<16));
*shift = l; *shift = l;
}
else
{
*quant = (1 << 16) / d;
*shift = 0;
}
} }
void vp8cx_init_quantizer(VP8_COMP *cpi) void vp8cx_init_quantizer(VP8_COMP *cpi)
@ -170,7 +179,7 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
{ {
// dc values // dc values
quant_val = vp8_dc_quant(Q, cpi->common.y1dc_delta_q); quant_val = vp8_dc_quant(Q, cpi->common.y1dc_delta_q);
vp8cx_invert_quant(cpi->Y1quant[Q] + 0, vp8cx_invert_quant(cpi->sf.improved_quant, cpi->Y1quant[Q] + 0,
cpi->Y1quant_shift[Q] + 0, quant_val); cpi->Y1quant_shift[Q] + 0, quant_val);
cpi->Y1zbin[Q][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; cpi->Y1zbin[Q][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;
cpi->Y1round[Q][0] = (qrounding_factors[Q] * quant_val) >> 7; cpi->Y1round[Q][0] = (qrounding_factors[Q] * quant_val) >> 7;
@ -178,7 +187,7 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
cpi->zrun_zbin_boost_y1[Q][0] = (quant_val * zbin_boost[0]) >> 7; cpi->zrun_zbin_boost_y1[Q][0] = (quant_val * zbin_boost[0]) >> 7;
quant_val = vp8_dc2quant(Q, cpi->common.y2dc_delta_q); quant_val = vp8_dc2quant(Q, cpi->common.y2dc_delta_q);
vp8cx_invert_quant(cpi->Y2quant[Q] + 0, vp8cx_invert_quant(cpi->sf.improved_quant, cpi->Y2quant[Q] + 0,
cpi->Y2quant_shift[Q] + 0, quant_val); cpi->Y2quant_shift[Q] + 0, quant_val);
cpi->Y2zbin[Q][0] = ((qzbin_factors_y2[Q] * quant_val) + 64) >> 7; cpi->Y2zbin[Q][0] = ((qzbin_factors_y2[Q] * quant_val) + 64) >> 7;
cpi->Y2round[Q][0] = (qrounding_factors_y2[Q] * quant_val) >> 7; cpi->Y2round[Q][0] = (qrounding_factors_y2[Q] * quant_val) >> 7;
@ -186,7 +195,7 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
cpi->zrun_zbin_boost_y2[Q][0] = (quant_val * zbin_boost[0]) >> 7; cpi->zrun_zbin_boost_y2[Q][0] = (quant_val * zbin_boost[0]) >> 7;
quant_val = vp8_dc_uv_quant(Q, cpi->common.uvdc_delta_q); quant_val = vp8_dc_uv_quant(Q, cpi->common.uvdc_delta_q);
vp8cx_invert_quant(cpi->UVquant[Q] + 0, vp8cx_invert_quant(cpi->sf.improved_quant, cpi->UVquant[Q] + 0,
cpi->UVquant_shift[Q] + 0, quant_val); cpi->UVquant_shift[Q] + 0, quant_val);
cpi->UVzbin[Q][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;; cpi->UVzbin[Q][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;;
cpi->UVround[Q][0] = (qrounding_factors[Q] * quant_val) >> 7; cpi->UVround[Q][0] = (qrounding_factors[Q] * quant_val) >> 7;
@ -199,7 +208,7 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
int rc = vp8_default_zig_zag1d[i]; int rc = vp8_default_zig_zag1d[i];
quant_val = vp8_ac_yquant(Q); quant_val = vp8_ac_yquant(Q);
vp8cx_invert_quant(cpi->Y1quant[Q] + rc, vp8cx_invert_quant(cpi->sf.improved_quant, cpi->Y1quant[Q] + rc,
cpi->Y1quant_shift[Q] + rc, quant_val); cpi->Y1quant_shift[Q] + rc, quant_val);
cpi->Y1zbin[Q][rc] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; cpi->Y1zbin[Q][rc] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;
cpi->Y1round[Q][rc] = (qrounding_factors[Q] * quant_val) >> 7; cpi->Y1round[Q][rc] = (qrounding_factors[Q] * quant_val) >> 7;
@ -207,7 +216,7 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
cpi->zrun_zbin_boost_y1[Q][i] = (quant_val * zbin_boost[i]) >> 7; cpi->zrun_zbin_boost_y1[Q][i] = (quant_val * zbin_boost[i]) >> 7;
quant_val = vp8_ac2quant(Q, cpi->common.y2ac_delta_q); quant_val = vp8_ac2quant(Q, cpi->common.y2ac_delta_q);
vp8cx_invert_quant(cpi->Y2quant[Q] + rc, vp8cx_invert_quant(cpi->sf.improved_quant, cpi->Y2quant[Q] + rc,
cpi->Y2quant_shift[Q] + rc, quant_val); cpi->Y2quant_shift[Q] + rc, quant_val);
cpi->Y2zbin[Q][rc] = ((qzbin_factors_y2[Q] * quant_val) + 64) >> 7; cpi->Y2zbin[Q][rc] = ((qzbin_factors_y2[Q] * quant_val) + 64) >> 7;
cpi->Y2round[Q][rc] = (qrounding_factors_y2[Q] * quant_val) >> 7; cpi->Y2round[Q][rc] = (qrounding_factors_y2[Q] * quant_val) >> 7;
@ -215,7 +224,7 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
cpi->zrun_zbin_boost_y2[Q][i] = (quant_val * zbin_boost[i]) >> 7; cpi->zrun_zbin_boost_y2[Q][i] = (quant_val * zbin_boost[i]) >> 7;
quant_val = vp8_ac_uv_quant(Q, cpi->common.uvac_delta_q); quant_val = vp8_ac_uv_quant(Q, cpi->common.uvac_delta_q);
vp8cx_invert_quant(cpi->UVquant[Q] + rc, vp8cx_invert_quant(cpi->sf.improved_quant, cpi->UVquant[Q] + rc,
cpi->UVquant_shift[Q] + rc, quant_val); cpi->UVquant_shift[Q] + rc, quant_val);
cpi->UVzbin[Q][rc] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; cpi->UVzbin[Q][rc] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;
cpi->UVround[Q][rc] = (qrounding_factors[Q] * quant_val) >> 7; cpi->UVround[Q][rc] = (qrounding_factors[Q] * quant_val) >> 7;

Просмотреть файл

@ -563,6 +563,7 @@ void vp8_set_speed_features(VP8_COMP *cpi)
int Speed = cpi->Speed; int Speed = cpi->Speed;
int i; int i;
VP8_COMMON *cm = &cpi->common; VP8_COMMON *cm = &cpi->common;
int last_improved_quant = sf->improved_quant;
// Initialise default mode frequency sampling variables // Initialise default mode frequency sampling variables
for (i = 0; i < MAX_MODES; i ++) for (i = 0; i < MAX_MODES; i ++)
@ -1262,6 +1263,8 @@ void vp8_set_speed_features(VP8_COMP *cpi)
{ {
cpi->mb.quantize_b = QUANTIZE_INVOKE(&cpi->rtcd.quantize, fastquantb); cpi->mb.quantize_b = QUANTIZE_INVOKE(&cpi->rtcd.quantize, fastquantb);
} }
if (cpi->sf.improved_quant != last_improved_quant)
vp8cx_init_quantizer(cpi);
#if CONFIG_RUNTIME_CPU_DETECT #if CONFIG_RUNTIME_CPU_DETECT
cpi->mb.e_mbd.rtcd = &cpi->common.rtcd; cpi->mb.e_mbd.rtcd = &cpi->common.rtcd;

Просмотреть файл

@ -17,7 +17,8 @@
#include "predictdc.h" #include "predictdc.h"
#define EXACT_QUANT #define EXACT_QUANT
#ifdef EXACT_QUANT
#ifdef EXACT_FASTQUANT
void vp8_fast_quantize_b_c(BLOCK *b, BLOCKD *d) void vp8_fast_quantize_b_c(BLOCK *b, BLOCKD *d)
{ {
int i, rc, eob; int i, rc, eob;
@ -64,6 +65,45 @@ void vp8_fast_quantize_b_c(BLOCK *b, BLOCKD *d)
d->eob = eob + 1; d->eob = eob + 1;
} }
#else
void vp8_fast_quantize_b_c(BLOCK *b, BLOCKD *d)
{
int i, rc, eob;
int zbin;
int x, y, z, sz;
short *coeff_ptr = b->coeff;
short *round_ptr = b->round;
short *quant_ptr = b->quant;
short *qcoeff_ptr = d->qcoeff;
short *dqcoeff_ptr = d->dqcoeff;
short *dequant_ptr = d->dequant;
eob = -1;
for (i = 0; i < 16; i++)
{
rc = vp8_default_zig_zag1d[i];
z = coeff_ptr[rc];
sz = (z >> 31); // sign of z
x = (z ^ sz) - sz; // x = abs(z)
y = ((x + round_ptr[rc]) * quant_ptr[rc]) >> 16; // quantize (x)
x = (y ^ sz) - sz; // get the sign back
qcoeff_ptr[rc] = x; // write to destination
dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
if (y)
{
eob = i; // last nonzero coeffs
}
}
d->eob = eob + 1;
}
#endif
#ifdef EXACT_QUANT
void vp8_regular_quantize_b(BLOCK *b, BLOCKD *d) void vp8_regular_quantize_b(BLOCK *b, BLOCKD *d)
{ {
int i, rc, eob; int i, rc, eob;
@ -178,39 +218,6 @@ void vp8_strict_quantize_b(BLOCK *b, BLOCKD *d)
} }
#else #else
void vp8_fast_quantize_b_c(BLOCK *b, BLOCKD *d)
{
int i, rc, eob;
int zbin;
int x, y, z, sz;
short *coeff_ptr = b->coeff;
short *round_ptr = b->round;
short *quant_ptr = b->quant;
short *qcoeff_ptr = d->qcoeff;
short *dqcoeff_ptr = d->dqcoeff;
short *dequant_ptr = d->dequant;
eob = -1;
for (i = 0; i < 16; i++)
{
rc = vp8_default_zig_zag1d[i];
z = coeff_ptr[rc];
sz = (z >> 31); // sign of z
x = (z ^ sz) - sz; // x = abs(z)
y = ((x + round_ptr[rc]) * quant_ptr[rc]) >> 16; // quantize (x)
x = (y ^ sz) - sz; // get the sign back
qcoeff_ptr[rc] = x; // write to destination
dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
if (y)
{
eob = i; // last nonzero coeffs
}
}
d->eob = eob + 1;
}
void vp8_regular_quantize_b(BLOCK *b, BLOCKD *d) void vp8_regular_quantize_b(BLOCK *b, BLOCKD *d)
{ {

Просмотреть файл

@ -438,7 +438,7 @@ struct EbmlGlobal
int debug; int debug;
FILE *stream; FILE *stream;
uint64_t last_pts_ms; int64_t last_pts_ms;
vpx_rational_t framerate; vpx_rational_t framerate;
/* These pointers are to the start of an element */ /* These pointers are to the start of an element */
@ -651,7 +651,7 @@ write_webm_block(EbmlGlobal *glob,
unsigned char track_number; unsigned char track_number;
unsigned short block_timecode = 0; unsigned short block_timecode = 0;
unsigned char flags; unsigned char flags;
uint64_t pts_ms; int64_t pts_ms;
int start_cluster = 0, is_keyframe; int start_cluster = 0, is_keyframe;
/* Calculate the PTS of this frame in milliseconds */ /* Calculate the PTS of this frame in milliseconds */
@ -1077,6 +1077,7 @@ int main(int argc, const char **argv_)
int psnr_count = 0; int psnr_count = 0;
exec_name = argv_[0]; exec_name = argv_[0];
ebml.last_pts_ms = -1;
if (argc < 3) if (argc < 3)
usage_exit(); usage_exit();