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

Only support improved quant

Deprecate fast quant and strict_quant code.
Small effect on quality as fast was used in first pass but the
effect is basically neutral across the derf set.

The rationale here is to reduce the number of code paths for
now to make experimentation easier. Optimized and fast code
options can be re-introduced later along with other  encode
speed options.

Change-Id: Ia30c5daf3dbc52e72c83b277a1d281e3c934cdad
parent 36af2035
......@@ -1168,18 +1168,6 @@ int vp8cx_encode_inter_macroblock
int zbin_mode_boost_enabled = cpi->zbin_mode_boost_enabled;
int single, compound, hybrid;
/* Are we using the fast quantizer for the mode selection? */
if(cpi->sf.use_fastquant_for_pick)
{
cpi->mb.quantize_b = QUANTIZE_INVOKE(&cpi->rtcd.quantize,
fastquantb);
cpi->mb.quantize_b_pair = QUANTIZE_INVOKE(&cpi->rtcd.quantize,
fastquantb_pair);
/* the fast quantizer does not use zbin_extra, so
* do not recalculate */
cpi->zbin_mode_boost_enabled = 0;
}
vp8_rd_pick_inter_mode(cpi, x, recon_yoffset, recon_uvoffset, &rate,
&distortion, &intra_error, &single, &compound, &hybrid);
......@@ -1215,14 +1203,6 @@ int vp8cx_encode_inter_macroblock
cpi->t4x4_count++;
}
/* switch back to the regular quantizer for the encode */
if (cpi->sf.improved_quant)
{
cpi->mb.quantize_b = QUANTIZE_INVOKE(&cpi->rtcd.quantize,
quantb);
cpi->mb.quantize_b_pair = QUANTIZE_INVOKE(&cpi->rtcd.quantize,
quantb_pair);
}
/* restore cpi->zbin_mode_boost_enabled */
cpi->zbin_mode_boost_enabled = zbin_mode_boost_enabled;
......@@ -1263,10 +1243,7 @@ int vp8cx_encode_inter_macroblock
}
}
/* The fast quantizer doesn't use zbin_extra, only do so with
* the regular quantizer. */
if (cpi->sf.improved_quant)
vp8_update_zbin_extra(cpi, x);
vp8_update_zbin_extra(cpi, x);
}
seg_ref_active = segfeature_active( xd, *segment_id, SEG_LVL_REF_FRAME );
......
......@@ -399,13 +399,6 @@ static void optimize_b(MACROBLOCK *mb, int ib, int type,
b = &mb->block[ib];
d = &mb->e_mbd.block[ib];
/* Enable this to test the effect of RDO as a replacement for the dynamic
* zero bin instead of an augmentation of it.
*/
#if 0
vp8_strict_quantize_b(b, d);
#endif
dequant_ptr = d->dequant;
coeff_ptr = b->coeff;
qcoeff_ptr = d->qcoeff;
......@@ -831,13 +824,6 @@ void optimize_b_8x8(MACROBLOCK *mb, int i, int type,
b = &mb->block[i];
d = &mb->e_mbd.block[i];
/* Enable this to test the effect of RDO as a replacement for the dynamic
* zero bin instead of an augmentation of it.
*/
#if 0
vp8_strict_quantize_b(b, d);
#endif
dequant_ptr = d->dequant;
coeff_ptr = b->coeff;
qcoeff_ptr = d->qcoeff;
......
......@@ -84,14 +84,6 @@ void vp8_cmachine_specific_config(VP8_COMP *cpi)
cpi->rtcd.encodemb.submby = vp8_subtract_mby_c;
cpi->rtcd.encodemb.submbuv = vp8_subtract_mbuv_c;
cpi->rtcd.quantize.quantb = vp8_regular_quantize_b;
cpi->rtcd.quantize.quantb_pair = vp8_regular_quantize_b_pair;
cpi->rtcd.quantize.fastquantb = vp8_fast_quantize_b_c;
cpi->rtcd.quantize.fastquantb_pair = vp8_fast_quantize_b_pair_c;
cpi->rtcd.quantize.quantb_8x8 = vp8_regular_quantize_b_8x8;
cpi->rtcd.quantize.fastquantb_8x8 = vp8_fast_quantize_b_8x8_c;
cpi->rtcd.quantize.quantb_2x2 = vp8_regular_quantize_b_2x2;
cpi->rtcd.quantize.fastquantb_2x2 = vp8_fast_quantize_b_2x2_c;
cpi->rtcd.search.full_search = vp8_full_search_sad;
cpi->rtcd.search.refining_search = vp8_refining_search_sad;
cpi->rtcd.search.diamond_search = vp8_diamond_search_sad;
......
......@@ -652,7 +652,6 @@ void vp8_set_speed_features(VP8_COMP *cpi)
int Speed = cpi->Speed;
int i;
VP8_COMMON *cm = &cpi->common;
int last_improved_quant = sf->improved_quant;
// Only modes 0 and 1 supported for now in experimental code basae
if ( Mode > 1 )
......@@ -671,7 +670,6 @@ void vp8_set_speed_features(VP8_COMP *cpi)
// best quality defaults
sf->RD = 1;
sf->search_method = NSTEP;
sf->improved_quant = 1;
sf->improved_dct = 1;
sf->auto_filter = 1;
sf->recode_loop = 1;
......@@ -679,7 +677,6 @@ void vp8_set_speed_features(VP8_COMP *cpi)
sf->half_pixel_search = 1;
sf->iterative_sub_pixel = 1;
sf->optimize_coefficients = 1;
sf->use_fastquant_for_pick = 0;
sf->no_skip_block4x4_search = 1;
sf->first_step = 0;
......@@ -791,7 +788,6 @@ void vp8_set_speed_features(VP8_COMP *cpi)
{
/* Disable coefficient optimization above speed 0 */
sf->optimize_coefficients = 0;
sf->use_fastquant_for_pick = 1;
sf->no_skip_block4x4_search = 0;
sf->first_step = 1;
......@@ -902,7 +898,6 @@ void vp8_set_speed_features(VP8_COMP *cpi)
sf->thresh_mult[THR_COMP_NEWLA ] = 2500;
sf->thresh_mult[THR_COMP_NEWGA ] = 2500;
sf->improved_quant = 0;
sf->improved_dct = 0;
// Only do recode loop on key frames, golden frames and
......@@ -971,7 +966,6 @@ void vp8_set_speed_features(VP8_COMP *cpi)
// so make sure they are always turned off.
if ( cpi->pass == 1 )
{
sf->improved_quant = 0;
sf->optimize_coefficients = 0;
sf->improved_dct = 0;
}
......@@ -1001,26 +995,13 @@ void vp8_set_speed_features(VP8_COMP *cpi)
cpi->mb.short_walsh4x4 = FDCT_INVOKE(&cpi->rtcd.fdct, walsh_short4x4);
cpi->mb.short_fhaar2x2 = FDCT_INVOKE(&cpi->rtcd.fdct, haar_short2x2);
if (cpi->sf.improved_quant)
{
cpi->mb.quantize_b = QUANTIZE_INVOKE(&cpi->rtcd.quantize,
quantb);
cpi->mb.quantize_b_pair = QUANTIZE_INVOKE(&cpi->rtcd.quantize,
quantb_pair);
cpi->mb.quantize_b_8x8 = QUANTIZE_INVOKE(&cpi->rtcd.quantize, quantb_8x8);
cpi->mb.quantize_b_2x2 = QUANTIZE_INVOKE(&cpi->rtcd.quantize, quantb_2x2);
}
else
{
cpi->mb.quantize_b = QUANTIZE_INVOKE(&cpi->rtcd.quantize,
fastquantb);
cpi->mb.quantize_b_pair = QUANTIZE_INVOKE(&cpi->rtcd.quantize,
fastquantb_pair);
cpi->mb.quantize_b_8x8 = QUANTIZE_INVOKE(&cpi->rtcd.quantize, fastquantb_8x8);
cpi->mb.quantize_b_2x2 = QUANTIZE_INVOKE(&cpi->rtcd.quantize, fastquantb_2x2);
}
if (cpi->sf.improved_quant != last_improved_quant)
vp8cx_init_quantizer(cpi);
cpi->mb.quantize_b = vp8_regular_quantize_b;
cpi->mb.quantize_b_pair = vp8_regular_quantize_b_pair;
cpi->mb.quantize_b_8x8 = vp8_regular_quantize_b_8x8;
cpi->mb.quantize_b_2x2 = vp8_regular_quantize_b_2x2;
vp8cx_init_quantizer(cpi);
#if CONFIG_RUNTIME_CPU_DETECT
cpi->mb.e_mbd.rtcd = &cpi->common.rtcd;
......
......@@ -220,7 +220,6 @@ typedef struct
{
int RD;
SEARCH_METHODS search_method;
int improved_quant;
int improved_dct;
int auto_filter;
int recode_loop;
......@@ -231,8 +230,6 @@ typedef struct
int max_step_search_steps;
int first_step;
int optimize_coefficients;
int use_fastquant_for_pick;
int no_skip_block4x4_search;
int improved_mv_pred;
......@@ -269,7 +266,6 @@ typedef struct VP8_ENCODER_RTCD
vp8_variance_rtcd_vtable_t variance;
vp8_fdct_rtcd_vtable_t fdct;
vp8_encodemb_rtcd_vtable_t encodemb;
vp8_quantize_rtcd_vtable_t quantize;
vp8_search_rtcd_vtable_t search;
vp8_temporal_rtcd_vtable_t temporal;
} VP8_ENCODER_RTCD;
......
......@@ -22,41 +22,6 @@
extern int enc_debug;
#endif
void vp8_fast_quantize_b_c(BLOCK *b, BLOCKD *d)
{
int i, rc, eob;
int x, y, z, sz;
short *coeff_ptr = b->coeff;
short *round_ptr = b->round;
short *quant_ptr = b->quant_fast;
short *qcoeff_ptr = d->qcoeff;
short *dqcoeff_ptr = d->dqcoeff;
short *dequant_ptr = d->dequant;
vpx_memset(qcoeff_ptr, 0, 32);
vpx_memset(dqcoeff_ptr, 0, 32);
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)
{
int i, rc, eob;
......@@ -109,66 +74,6 @@ void vp8_regular_quantize_b(BLOCK *b, BLOCKD *d)
d->eob = eob + 1;
}
/* Perform regular quantization, with unbiased rounding and no zero bin. */
void vp8_strict_quantize_b(BLOCK *b, BLOCKD *d)
{
int i;
int rc;
int eob;
int x;
int y;
int z;
int sz;
short *coeff_ptr;
short *quant_ptr;
unsigned char *quant_shift_ptr;
short *qcoeff_ptr;
short *dqcoeff_ptr;
short *dequant_ptr;
coeff_ptr = b->coeff;
quant_ptr = b->quant;
quant_shift_ptr = b->quant_shift;
qcoeff_ptr = d->qcoeff;
dqcoeff_ptr = d->dqcoeff;
dequant_ptr = d->dequant;
eob = - 1;
vpx_memset(qcoeff_ptr, 0, 32);
vpx_memset(dqcoeff_ptr, 0, 32);
for (i = 0; i < 16; i++)
{
int dq;
int round;
/*TODO: These arrays should be stored in zig-zag order.*/
rc = vp8_default_zig_zag1d[i];
z = coeff_ptr[rc];
dq = dequant_ptr[rc];
round = dq >> 1;
/* Sign of z. */
sz = -(z < 0);
x = (z + sz) ^ sz;
x += round;
if (x >= dq)
{
/* Quantize x. */
y = (((x * quant_ptr[rc]) >> 16) + x) >> quant_shift_ptr[rc];
/* Put the sign back. */
x = (y + sz) ^ sz;
/* Save the coefficient and its dequantized value. */
qcoeff_ptr[rc] = x;
dqcoeff_ptr[rc] = x * dq;
/* Remember the last non-zero coefficient. */
if (y)
{
eob = i;
}
}
}
d->eob = eob + 1;
}
void vp8_quantize_mby_c(MACROBLOCK *x)
{
int i;
......@@ -203,103 +108,6 @@ void vp8_quantize_mbuv_c(MACROBLOCK *x)
x->quantize_b(&x->block[i], &x->e_mbd.block[i]);
}
void vp8_fast_quantize_b_2x2_c(BLOCK *b, BLOCKD *d)
{
int i, rc, eob;
int zbin;
int x, y, z, sz;
short *coeff_ptr = b->coeff;
short *zbin_ptr = b->zbin;
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;
//double q2nd = 4;
vpx_memset(qcoeff_ptr, 0, 32);
vpx_memset(dqcoeff_ptr, 0, 32);
eob = -1;
for (i = 0; i < 4; i++)
{
rc = vp8_default_zig_zag1d[i];
z = coeff_ptr[rc];
//zbin = zbin_ptr[rc]/q2nd;
zbin = zbin_ptr[rc];
sz = (z >> 31); // sign of z
x = (z ^ sz) - sz; // x = abs(z)
if (x >= zbin)
{
//y = ((int)((x + round_ptr[rc]/q2nd) * quant_ptr[rc] * q2nd)) >> 16; // quantize (x)
y = ((int)((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] / q2nd; // dequantized value
dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
dqcoeff_ptr[rc] = (dqcoeff_ptr[rc]+2)>>2;
if (y)
{
eob = i; // last nonzero coeffs
}
}
}
d->eob = eob + 1;
}
void vp8_fast_quantize_b_8x8_c(BLOCK *b, BLOCKD *d)
{
int i, rc, eob;
int zbin;
int x, y, z, sz;
short *coeff_ptr = b->coeff;
short *zbin_ptr = b->zbin;
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;
//double q1st = 2;
vpx_memset(qcoeff_ptr, 0, 64*sizeof(short));
vpx_memset(dqcoeff_ptr, 0, 64*sizeof(short));
eob = -1;
for (i = 0; i < 64; i++)
{
rc = vp8_default_zig_zag1d_8x8[i];
z = coeff_ptr[rc];
//zbin = zbin_ptr[rc!=0]/q1st ;
zbin = zbin_ptr[rc!=0] ;
sz = (z >> 31); // sign of z
x = (z ^ sz) - sz; // x = abs(z)
if (x >= zbin)
{
//y = ((int)((x + round_ptr[rc!=0] / q1st) * quant_ptr[rc!=0] * q1st)) >> 16;
y = ((int)((x + round_ptr[rc!=0]) * quant_ptr[rc!=0])) >> 16;
x = (y ^ sz) - sz; // get the sign back
qcoeff_ptr[rc] = x; // write to destination
//dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0] / q1st; // dequantized value
dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0]; // dequantized value
dqcoeff_ptr[rc] = (dqcoeff_ptr[rc]+2)>>2;
if (y)
{
eob = i; // last nonzero coeffs
}
}
}
d->eob = eob + 1;
}
......@@ -420,127 +228,6 @@ void vp8_regular_quantize_b_8x8(BLOCK *b, BLOCKD *d)
d->eob = eob + 1;
}
void vp8_strict_quantize_b_2x2(BLOCK *b, BLOCKD *d)
{
int i;
int rc;
int eob;
int x;
int y;
int z;
int sz;
short *coeff_ptr;
short *quant_ptr;
unsigned char *quant_shift_ptr;
short *qcoeff_ptr;
short *dqcoeff_ptr;
short *dequant_ptr;
//double q2nd = 4;
coeff_ptr = b->coeff;
quant_ptr = b->quant;
quant_shift_ptr = b->quant_shift;
qcoeff_ptr = d->qcoeff;
dqcoeff_ptr = d->dqcoeff;
dequant_ptr = d->dequant;
eob = - 1;
vpx_memset(qcoeff_ptr, 0, 32);
vpx_memset(dqcoeff_ptr, 0, 32);
for (i = 0; i < 4; i++)
{
int dq;
int round;
/*TODO: These arrays should be stored in zig-zag order.*/
rc = vp8_default_zig_zag1d[i];
z = coeff_ptr[rc];
//z = z * q2nd;
//dq = dequant_ptr[rc]/q2nd;
dq = dequant_ptr[rc];
round = dq >> 1;
/* Sign of z. */
sz = -(z < 0);
x = (z + sz) ^ sz;
x += round;
if (x >= dq)
{
/* Quantize x */
y = (((x * quant_ptr[rc]) >> 16) + x) >> quant_shift_ptr[rc];
/* Put the sign back. */
x = (y + sz) ^ sz;
/* Save * the * coefficient and its dequantized value. */
qcoeff_ptr[rc] = x;
dqcoeff_ptr[rc] = x * dq;
/* Remember the last non-zero coefficient. */
if (y)
{
eob = i;
}
}
}
d->eob = eob + 1;
}
void vp8_strict_quantize_b_8x8(BLOCK *b, BLOCKD *d)
{
int i;
int rc;
int eob;
int x;
int y;
int z;
int sz;
short *coeff_ptr;
short *quant_ptr;
unsigned char *quant_shift_ptr;
short *qcoeff_ptr;
short *dqcoeff_ptr;
short *dequant_ptr;
//double q1st = 2;
printf("call strict quantizer\n");
coeff_ptr = b->coeff;
quant_ptr = b->quant;
quant_shift_ptr = b->quant_shift;
qcoeff_ptr = d->qcoeff;
dqcoeff_ptr = d->dqcoeff;
dequant_ptr = d->dequant;
eob = - 1;
vpx_memset(qcoeff_ptr, 0, 64*sizeof(short));
vpx_memset(dqcoeff_ptr, 0, 64*sizeof(short));
for (i = 0; i < 64; i++)
{
int dq;
int round;
/*TODO: These arrays should be stored in zig-zag order.*/
rc = vp8_default_zig_zag1d_8x8[i];
z = coeff_ptr[rc];
//z = z * q1st;
//dq = dequant_ptr[rc!=0]/q1st;
dq = dequant_ptr[rc!=0];
round = dq >> 1;
/* Sign of z. */
sz = -(z < 0);
x = (z + sz) ^ sz;
x += round;
if (x >= dq)
{
/* Quantize x. */
y = ((int)(((int)((x * quant_ptr[rc!=0])) >> 16) + x)) >> quant_shift_ptr[rc!=0];
/* Put the sign back. */
x = (y + sz) ^ sz;
/* Save the coefficient and its dequantized value. * */
qcoeff_ptr[rc] = x;
dqcoeff_ptr[rc] = x * dq;
/* Remember the last non-zero coefficient. */
if (y)
{
eob = i;
}
}
}
d->eob = eob + 1;
}
void vp8_quantize_mby_8x8(MACROBLOCK *x)
{
int i;
......@@ -599,32 +286,17 @@ void vp8_regular_quantize_b_pair(BLOCK *b1, BLOCK *b2, BLOCKD *d1, BLOCKD *d2)
vp8_regular_quantize_b(b2, d2);
}
void vp8_fast_quantize_b_pair_c(BLOCK *b1, BLOCK *b2, BLOCKD *d1, BLOCKD *d2)
static void invert_quant(short *quant,
unsigned char *shift, short d)
{
vp8_fast_quantize_b_c(b1, d1);
vp8_fast_quantize_b_c(b2, d2);
}
static void invert_quant(int improved_quant, short *quant,
unsigned char *shift, short d)
{
if(improved_quant)
{
unsigned t;
int l;
t = d;
for(l = 0; t > 1; l++)
t>>=1;
t = 1 + (1<<(16+l))/d;
*quant = (short)(t - (1<<16));
*shift = l;
}
else
{
*quant = (1 << 16) / d;
*shift = 0;
}
unsigned t;
int l;
t = d;
for(l = 0; t > 1; l++)
t>>=1;
t = 1 + (1<<(16+l))/d;
*quant = (short)(t - (1<<16));
*shift = l;
}
......@@ -644,7 +316,7 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
// dc values
quant_val = vp8_dc_quant(Q, cpi->common.y1dc_delta_q);
cpi->Y1quant_fast[Q][0] = (1 << 16) / quant_val;
invert_quant(cpi->sf.improved_quant, cpi->Y1quant[Q] + 0,
invert_quant(cpi->Y1quant[Q] + 0,
cpi->Y1quant_shift[Q] + 0, quant_val);
cpi->Y1zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
cpi->Y1round[Q][0] = (qrounding_factor * quant_val) >> 7;
......@@ -653,7 +325,7 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
quant_val = vp8_dc2quant(Q, cpi->common.y2dc_delta_q);
cpi->Y2quant_fast[Q][0] = (1 << 16) / quant_val;
invert_quant(cpi->sf.improved_quant, cpi->Y2quant[Q] + 0,
invert_quant(cpi->Y2quant[Q] + 0,
cpi->Y2quant_shift[Q] + 0, quant_val);
cpi->Y2zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
cpi->Y2round[Q][0] = (qrounding_factor * quant_val) >> 7;
......@@ -662,7 +334,7 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
quant_val = vp8_dc_uv_quant(Q, cpi->common.uvdc_delta_q);
cpi->UVquant_fast[Q][0] = (1 << 16) / quant_val;
invert_quant(cpi->sf.improved_quant, cpi->UVquant[Q] + 0,
invert_quant(cpi->UVquant[Q] + 0,
cpi->UVquant_shift[Q] + 0, quant_val);
cpi->UVzbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;;
cpi->UVround[Q][0] = (qrounding_factor * quant_val) >> 7;
......@@ -676,7 +348,7 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
quant_val = vp8_ac_yquant(Q);
cpi->Y1quant_fast[Q][rc] = (1 << 16) / quant_val;
invert_quant(cpi->sf.improved_quant, cpi->Y1quant[Q] + rc,
invert_quant(cpi->Y1quant[Q] + rc,
cpi->Y1quant_shift[Q] + rc, quant_val);
cpi->Y1zbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
cpi->Y1round[Q][rc] = (qrounding_factor * quant_val) >> 7;
......@@ -685,7 +357,7 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)