Commit 8f75ea6b authored by Timothy B. Terriberry's avatar Timothy B. Terriberry
Browse files

Convert [4][4] matrices to [16] arrays.

Most of the code that actually uses these matrices indexes them as
 if they were a single contiguous array, and coverity produces
 reports about the resulting accesses that overflow the static
 bounds of the first row.
This is perfectly legal in C, but converting them to actual [16]
 arrays should eliminate the report, and removes a good deal of
 extraneous indexing and address operators from the code.

Change-Id: Ibda479e2232b3e51f9edf3b355b8640520fdbf23
parent 45e64941
...@@ -195,7 +195,7 @@ typedef struct ...@@ -195,7 +195,7 @@ typedef struct
short *diff; short *diff;
short *reference; short *reference;
short(*dequant)[4]; short *dequant;
// 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries
unsigned char **base_pre; unsigned char **base_pre;
......
...@@ -83,9 +83,9 @@ typedef struct VP8Common ...@@ -83,9 +83,9 @@ typedef struct VP8Common
{ {
struct vpx_internal_error_info error; struct vpx_internal_error_info error;
DECLARE_ALIGNED(16, short, Y1dequant[QINDEX_RANGE][4][4]); DECLARE_ALIGNED(16, short, Y1dequant[QINDEX_RANGE][16]);
DECLARE_ALIGNED(16, short, Y2dequant[QINDEX_RANGE][4][4]); DECLARE_ALIGNED(16, short, Y2dequant[QINDEX_RANGE][16]);
DECLARE_ALIGNED(16, short, UVdequant[QINDEX_RANGE][4][4]); DECLARE_ALIGNED(16, short, UVdequant[QINDEX_RANGE][16]);
int Width; int Width;
int Height; int Height;
......
...@@ -30,7 +30,7 @@ void vp8_dequantize_b_neon(BLOCKD *d) ...@@ -30,7 +30,7 @@ void vp8_dequantize_b_neon(BLOCKD *d)
int i; int i;
short *DQ = d->dqcoeff; short *DQ = d->dqcoeff;
short *Q = d->qcoeff; short *Q = d->qcoeff;
short *DQC = &d->dequant[0][0]; short *DQC = d->dequant;
vp8_dequantize_b_loop_neon(Q, DQC, DQ); vp8_dequantize_b_loop_neon(Q, DQC, DQ);
} }
...@@ -42,7 +42,7 @@ void vp8_dequantize_b_v6(BLOCKD *d) ...@@ -42,7 +42,7 @@ void vp8_dequantize_b_v6(BLOCKD *d)
int i; int i;
short *DQ = d->dqcoeff; short *DQ = d->dqcoeff;
short *Q = d->qcoeff; short *Q = d->qcoeff;
short *DQC = &d->dequant[0][0]; short *DQC = d->dequant;
vp8_dequantize_b_loop_v6(Q, DQC, DQ); vp8_dequantize_b_loop_v6(Q, DQC, DQ);
} }
......
...@@ -40,27 +40,24 @@ ...@@ -40,27 +40,24 @@
void vp8cx_init_de_quantizer(VP8D_COMP *pbi) void vp8cx_init_de_quantizer(VP8D_COMP *pbi)
{ {
int r, c;
int i; int i;
int Q; int Q;
VP8_COMMON *const pc = & pbi->common; VP8_COMMON *const pc = & pbi->common;
for (Q = 0; Q < QINDEX_RANGE; Q++) for (Q = 0; Q < QINDEX_RANGE; Q++)
{ {
pc->Y1dequant[Q][0][0] = (short)vp8_dc_quant(Q, pc->y1dc_delta_q); pc->Y1dequant[Q][0] = (short)vp8_dc_quant(Q, pc->y1dc_delta_q);
pc->Y2dequant[Q][0][0] = (short)vp8_dc2quant(Q, pc->y2dc_delta_q); pc->Y2dequant[Q][0] = (short)vp8_dc2quant(Q, pc->y2dc_delta_q);
pc->UVdequant[Q][0][0] = (short)vp8_dc_uv_quant(Q, pc->uvdc_delta_q); pc->UVdequant[Q][0] = (short)vp8_dc_uv_quant(Q, pc->uvdc_delta_q);
// all the ac values = ; // all the ac values = ;
for (i = 1; i < 16; i++) for (i = 1; i < 16; i++)
{ {
int rc = vp8_default_zig_zag1d[i]; int rc = vp8_default_zig_zag1d[i];
r = (rc >> 2);
c = (rc & 3);
pc->Y1dequant[Q][r][c] = (short)vp8_ac_yquant(Q); pc->Y1dequant[Q][rc] = (short)vp8_ac_yquant(Q);
pc->Y2dequant[Q][r][c] = (short)vp8_ac2quant(Q, pc->y2ac_delta_q); pc->Y2dequant[Q][rc] = (short)vp8_ac2quant(Q, pc->y2ac_delta_q);
pc->UVdequant[Q][r][c] = (short)vp8_ac_uv_quant(Q, pc->uvac_delta_q); pc->UVdequant[Q][rc] = (short)vp8_ac_uv_quant(Q, pc->uvac_delta_q);
} }
} }
} }
...@@ -253,7 +250,7 @@ void vp8_decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd) ...@@ -253,7 +250,7 @@ void vp8_decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd)
} }
DEQUANT_INVOKE (&pbi->dequant, dc_idct_add_y_block) DEQUANT_INVOKE (&pbi->dequant, dc_idct_add_y_block)
(xd->qcoeff, &xd->block[0].dequant[0][0], (xd->qcoeff, xd->block[0].dequant,
xd->predictor, xd->dst.y_buffer, xd->predictor, xd->dst.y_buffer,
xd->dst.y_stride, xd->eobs, xd->block[24].diff); xd->dst.y_stride, xd->eobs, xd->block[24].diff);
} }
...@@ -268,13 +265,13 @@ void vp8_decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd) ...@@ -268,13 +265,13 @@ void vp8_decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd)
if (xd->eobs[i] > 1) if (xd->eobs[i] > 1)
{ {
DEQUANT_INVOKE(&pbi->dequant, idct_add) DEQUANT_INVOKE(&pbi->dequant, idct_add)
(b->qcoeff, &b->dequant[0][0], b->predictor, (b->qcoeff, b->dequant, b->predictor,
*(b->base_dst) + b->dst, 16, b->dst_stride); *(b->base_dst) + b->dst, 16, b->dst_stride);
} }
else else
{ {
IDCT_INVOKE(RTCD_VTABLE(idct), idct1_scalar_add) IDCT_INVOKE(RTCD_VTABLE(idct), idct1_scalar_add)
(b->qcoeff[0] * b->dequant[0][0], b->predictor, (b->qcoeff[0] * b->dequant[0], b->predictor,
*(b->base_dst) + b->dst, 16, b->dst_stride); *(b->base_dst) + b->dst, 16, b->dst_stride);
((int *)b->qcoeff)[0] = 0; ((int *)b->qcoeff)[0] = 0;
} }
...@@ -284,13 +281,13 @@ void vp8_decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd) ...@@ -284,13 +281,13 @@ void vp8_decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd)
else else
{ {
DEQUANT_INVOKE (&pbi->dequant, idct_add_y_block) DEQUANT_INVOKE (&pbi->dequant, idct_add_y_block)
(xd->qcoeff, &xd->block[0].dequant[0][0], (xd->qcoeff, xd->block[0].dequant,
xd->predictor, xd->dst.y_buffer, xd->predictor, xd->dst.y_buffer,
xd->dst.y_stride, xd->eobs); xd->dst.y_stride, xd->eobs);
} }
DEQUANT_INVOKE (&pbi->dequant, idct_add_uv_block) DEQUANT_INVOKE (&pbi->dequant, idct_add_uv_block)
(xd->qcoeff+16*16, &xd->block[16].dequant[0][0], (xd->qcoeff+16*16, xd->block[16].dequant,
xd->predictor+16*16, xd->dst.u_buffer, xd->dst.v_buffer, xd->predictor+16*16, xd->dst.u_buffer, xd->dst.v_buffer,
xd->dst.uv_stride, xd->eobs+16); xd->dst.uv_stride, xd->eobs+16);
} }
......
...@@ -24,7 +24,7 @@ void vp8_dequantize_b_c(BLOCKD *d) ...@@ -24,7 +24,7 @@ void vp8_dequantize_b_c(BLOCKD *d)
int i; int i;
short *DQ = d->dqcoeff; short *DQ = d->dqcoeff;
short *Q = d->qcoeff; short *Q = d->qcoeff;
short *DQC = &d->dequant[0][0]; short *DQC = d->dequant;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
......
...@@ -184,7 +184,7 @@ void vp8mt_decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int mb ...@@ -184,7 +184,7 @@ void vp8mt_decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int mb
} }
DEQUANT_INVOKE (&pbi->dequant, dc_idct_add_y_block) DEQUANT_INVOKE (&pbi->dequant, dc_idct_add_y_block)
(xd->qcoeff, &xd->block[0].dequant[0][0], (xd->qcoeff, xd->block[0].dequant,
xd->predictor, xd->dst.y_buffer, xd->predictor, xd->dst.y_buffer,
xd->dst.y_stride, xd->eobs, xd->block[24].diff); xd->dst.y_stride, xd->eobs, xd->block[24].diff);
} }
...@@ -198,13 +198,13 @@ void vp8mt_decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int mb ...@@ -198,13 +198,13 @@ void vp8mt_decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int mb
if (xd->eobs[i] > 1) if (xd->eobs[i] > 1)
{ {
DEQUANT_INVOKE(&pbi->dequant, idct_add) DEQUANT_INVOKE(&pbi->dequant, idct_add)
(b->qcoeff, &b->dequant[0][0], b->predictor, (b->qcoeff, b->dequant, b->predictor,
*(b->base_dst) + b->dst, 16, b->dst_stride); *(b->base_dst) + b->dst, 16, b->dst_stride);
} }
else else
{ {
IDCT_INVOKE(RTCD_VTABLE(idct), idct1_scalar_add) IDCT_INVOKE(RTCD_VTABLE(idct), idct1_scalar_add)
(b->qcoeff[0] * b->dequant[0][0], b->predictor, (b->qcoeff[0] * b->dequant[0], b->predictor,
*(b->base_dst) + b->dst, 16, b->dst_stride); *(b->base_dst) + b->dst, 16, b->dst_stride);
((int *)b->qcoeff)[0] = 0; ((int *)b->qcoeff)[0] = 0;
} }
...@@ -213,13 +213,13 @@ void vp8mt_decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int mb ...@@ -213,13 +213,13 @@ void vp8mt_decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int mb
else else
{ {
DEQUANT_INVOKE (&pbi->dequant, idct_add_y_block) DEQUANT_INVOKE (&pbi->dequant, idct_add_y_block)
(xd->qcoeff, &xd->block[0].dequant[0][0], (xd->qcoeff, xd->block[0].dequant,
xd->predictor, xd->dst.y_buffer, xd->predictor, xd->dst.y_buffer,
xd->dst.y_stride, xd->eobs); xd->dst.y_stride, xd->eobs);
} }
DEQUANT_INVOKE (&pbi->dequant, idct_add_uv_block) DEQUANT_INVOKE (&pbi->dequant, idct_add_uv_block)
(xd->qcoeff+16*16, &xd->block[16].dequant[0][0], (xd->qcoeff+16*16, xd->block[16].dequant,
xd->predictor+16*16, xd->dst.u_buffer, xd->dst.v_buffer, xd->predictor+16*16, xd->dst.u_buffer, xd->dst.v_buffer,
xd->dst.uv_stride, xd->eobs+16); xd->dst.uv_stride, xd->eobs+16);
#else #else
......
...@@ -29,7 +29,7 @@ extern int vp8_fast_quantize_b_neon_func(short *coeff_ptr, short *zbin_ptr, shor ...@@ -29,7 +29,7 @@ extern int vp8_fast_quantize_b_neon_func(short *coeff_ptr, short *zbin_ptr, shor
void vp8_fast_quantize_b_neon(BLOCK *b, BLOCKD *d) void vp8_fast_quantize_b_neon(BLOCK *b, BLOCKD *d)
{ {
d->eob = vp8_fast_quantize_b_neon_func(b->coeff, &b->zbin[0][0], d->qcoeff, d->dqcoeff, d->dequant[0], vp8_rvsplus1_default_zig_zag1d, &b->round[0][0], &b->quant[0][0]); d->eob = vp8_fast_quantize_b_neon_func(b->coeff, b->zbin, d->qcoeff, d->dqcoeff, d->dequant, vp8_rvsplus1_default_zig_zag1d, b->round, b->quant);
} }
/* /*
......
...@@ -32,11 +32,11 @@ typedef struct ...@@ -32,11 +32,11 @@ typedef struct
short *coeff; short *coeff;
// 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries
short(*quant)[4]; short *quant;
short(*quant_shift)[4]; short *quant_shift;
short(*zbin)[4]; short *zbin;
short(*zrun_zbin_boost); short *zrun_zbin_boost;
short(*round)[4]; short *round;
// Zbin Over Quant value // Zbin Over Quant value
short zbin_extra; short zbin_extra;
......
...@@ -160,7 +160,6 @@ static void vp8cx_invert_quant(short *quant, short *shift, short d) ...@@ -160,7 +160,6 @@ static void vp8cx_invert_quant(short *quant, short *shift, short d)
void vp8cx_init_quantizer(VP8_COMP *cpi) void vp8cx_init_quantizer(VP8_COMP *cpi)
{ {
int r, c;
int i; int i;
int quant_val; int quant_val;
int Q; int Q;
...@@ -171,58 +170,56 @@ void vp8cx_init_quantizer(VP8_COMP *cpi) ...@@ -171,58 +170,56 @@ 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] + 0, vp8cx_invert_quant(cpi->Y1quant[Q] + 0,
cpi->Y1quant_shift[Q][0] + 0, quant_val); cpi->Y1quant_shift[Q] + 0, quant_val);
cpi->Y1zbin[Q][0][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; cpi->Y1zbin[Q][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;
cpi->Y1round[Q][0][0] = (qrounding_factors[Q] * quant_val) >> 7; cpi->Y1round[Q][0] = (qrounding_factors[Q] * quant_val) >> 7;
cpi->common.Y1dequant[Q][0][0] = quant_val; cpi->common.Y1dequant[Q][0] = quant_val;
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] + 0, vp8cx_invert_quant(cpi->Y2quant[Q] + 0,
cpi->Y2quant_shift[Q][0] + 0, quant_val); cpi->Y2quant_shift[Q] + 0, quant_val);
cpi->Y2zbin[Q][0][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][0] = (qrounding_factors_y2[Q] * quant_val) >> 7; cpi->Y2round[Q][0] = (qrounding_factors_y2[Q] * quant_val) >> 7;
cpi->common.Y2dequant[Q][0][0] = quant_val; cpi->common.Y2dequant[Q][0] = quant_val;
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] + 0, vp8cx_invert_quant(cpi->UVquant[Q] + 0,
cpi->UVquant_shift[Q][0] + 0, quant_val); cpi->UVquant_shift[Q] + 0, quant_val);
cpi->UVzbin[Q][0][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;; cpi->UVzbin[Q][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;;
cpi->UVround[Q][0][0] = (qrounding_factors[Q] * quant_val) >> 7; cpi->UVround[Q][0] = (qrounding_factors[Q] * quant_val) >> 7;
cpi->common.UVdequant[Q][0][0] = quant_val; cpi->common.UVdequant[Q][0] = quant_val;
cpi->zrun_zbin_boost_uv[Q][0] = (quant_val * zbin_boost[0]) >> 7; cpi->zrun_zbin_boost_uv[Q][0] = (quant_val * zbin_boost[0]) >> 7;
// all the ac values = ; // all the ac values = ;
for (i = 1; i < 16; i++) for (i = 1; i < 16; i++)
{ {
int rc = vp8_default_zig_zag1d[i]; int rc = vp8_default_zig_zag1d[i];
r = (rc >> 2);
c = (rc & 3);
quant_val = vp8_ac_yquant(Q); quant_val = vp8_ac_yquant(Q);
vp8cx_invert_quant(cpi->Y1quant[Q][r] + c, vp8cx_invert_quant(cpi->Y1quant[Q] + rc,
cpi->Y1quant_shift[Q][r] + c, quant_val); cpi->Y1quant_shift[Q] + rc, quant_val);
cpi->Y1zbin[Q][r][c] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; cpi->Y1zbin[Q][rc] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;
cpi->Y1round[Q][r][c] = (qrounding_factors[Q] * quant_val) >> 7; cpi->Y1round[Q][rc] = (qrounding_factors[Q] * quant_val) >> 7;
cpi->common.Y1dequant[Q][r][c] = quant_val; cpi->common.Y1dequant[Q][rc] = quant_val;
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][r] + c, vp8cx_invert_quant(cpi->Y2quant[Q] + rc,
cpi->Y2quant_shift[Q][r] + c, quant_val); cpi->Y2quant_shift[Q] + rc, quant_val);
cpi->Y2zbin[Q][r][c] = ((qzbin_factors_y2[Q] * quant_val) + 64) >> 7; cpi->Y2zbin[Q][rc] = ((qzbin_factors_y2[Q] * quant_val) + 64) >> 7;
cpi->Y2round[Q][r][c] = (qrounding_factors_y2[Q] * quant_val) >> 7; cpi->Y2round[Q][rc] = (qrounding_factors_y2[Q] * quant_val) >> 7;
cpi->common.Y2dequant[Q][r][c] = quant_val; cpi->common.Y2dequant[Q][rc] = quant_val;
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][r] + c, vp8cx_invert_quant(cpi->UVquant[Q] + rc,
cpi->UVquant_shift[Q][r] + c, quant_val); cpi->UVquant_shift[Q] + rc, quant_val);
cpi->UVzbin[Q][r][c] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; cpi->UVzbin[Q][rc] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;
cpi->UVround[Q][r][c] = (qrounding_factors[Q] * quant_val) >> 7; cpi->UVround[Q][rc] = (qrounding_factors[Q] * quant_val) >> 7;
cpi->common.UVdequant[Q][r][c] = quant_val; cpi->common.UVdequant[Q][rc] = quant_val;
cpi->zrun_zbin_boost_uv[Q][i] = (quant_val * zbin_boost[i]) >> 7; cpi->zrun_zbin_boost_uv[Q][i] = (quant_val * zbin_boost[i]) >> 7;
} }
} }
...@@ -230,7 +227,6 @@ void vp8cx_init_quantizer(VP8_COMP *cpi) ...@@ -230,7 +227,6 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
#else #else
void vp8cx_init_quantizer(VP8_COMP *cpi) void vp8cx_init_quantizer(VP8_COMP *cpi)
{ {
int r, c;
int i; int i;
int quant_val; int quant_val;
int Q; int Q;
...@@ -241,52 +237,50 @@ void vp8cx_init_quantizer(VP8_COMP *cpi) ...@@ -241,52 +237,50 @@ 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);
cpi->Y1quant[Q][0][0] = (1 << 16) / quant_val; cpi->Y1quant[Q][0] = (1 << 16) / quant_val;
cpi->Y1zbin[Q][0][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; cpi->Y1zbin[Q][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;
cpi->Y1round[Q][0][0] = (qrounding_factors[Q] * quant_val) >> 7; cpi->Y1round[Q][0] = (qrounding_factors[Q] * quant_val) >> 7;
cpi->common.Y1dequant[Q][0][0] = quant_val; cpi->common.Y1dequant[Q][0] = quant_val;
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);
cpi->Y2quant[Q][0][0] = (1 << 16) / quant_val; cpi->Y2quant[Q][0] = (1 << 16) / quant_val;
cpi->Y2zbin[Q][0][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][0] = (qrounding_factors_y2[Q] * quant_val) >> 7; cpi->Y2round[Q][0] = (qrounding_factors_y2[Q] * quant_val) >> 7;
cpi->common.Y2dequant[Q][0][0] = quant_val; cpi->common.Y2dequant[Q][0] = quant_val;
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);
cpi->UVquant[Q][0][0] = (1 << 16) / quant_val; cpi->UVquant[Q][0] = (1 << 16) / quant_val;
cpi->UVzbin[Q][0][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;; cpi->UVzbin[Q][0] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;;
cpi->UVround[Q][0][0] = (qrounding_factors[Q] * quant_val) >> 7; cpi->UVround[Q][0] = (qrounding_factors[Q] * quant_val) >> 7;
cpi->common.UVdequant[Q][0][0] = quant_val; cpi->common.UVdequant[Q][0] = quant_val;
cpi->zrun_zbin_boost_uv[Q][0] = (quant_val * zbin_boost[0]) >> 7; cpi->zrun_zbin_boost_uv[Q][0] = (quant_val * zbin_boost[0]) >> 7;
// all the ac values = ; // all the ac values = ;
for (i = 1; i < 16; i++) for (i = 1; i < 16; i++)
{ {
int rc = vp8_default_zig_zag1d[i]; int rc = vp8_default_zig_zag1d[i];
r = (rc >> 2);
c = (rc & 3);
quant_val = vp8_ac_yquant(Q); quant_val = vp8_ac_yquant(Q);
cpi->Y1quant[Q][r][c] = (1 << 16) / quant_val; cpi->Y1quant[Q][rc] = (1 << 16) / quant_val;
cpi->Y1zbin[Q][r][c] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; cpi->Y1zbin[Q][rc] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;
cpi->Y1round[Q][r][c] = (qrounding_factors[Q] * quant_val) >> 7; cpi->Y1round[Q][rc] = (qrounding_factors[Q] * quant_val) >> 7;
cpi->common.Y1dequant[Q][r][c] = quant_val; cpi->common.Y1dequant[Q][rc] = quant_val;
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);
cpi->Y2quant[Q][r][c] = (1 << 16) / quant_val; cpi->Y2quant[Q][rc] = (1 << 16) / quant_val;
cpi->Y2zbin[Q][r][c] = ((qzbin_factors_y2[Q] * quant_val) + 64) >> 7; cpi->Y2zbin[Q][rc] = ((qzbin_factors_y2[Q] * quant_val) + 64) >> 7;
cpi->Y2round[Q][r][c] = (qrounding_factors_y2[Q] * quant_val) >> 7; cpi->Y2round[Q][rc] = (qrounding_factors_y2[Q] * quant_val) >> 7;
cpi->common.Y2dequant[Q][r][c] = quant_val; cpi->common.Y2dequant[Q][rc] = quant_val;
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);
cpi->UVquant[Q][r][c] = (1 << 16) / quant_val; cpi->UVquant[Q][rc] = (1 << 16) / quant_val;
cpi->UVzbin[Q][r][c] = ((qzbin_factors[Q] * quant_val) + 64) >> 7; cpi->UVzbin[Q][rc] = ((qzbin_factors[Q] * quant_val) + 64) >> 7;
cpi->UVround[Q][r][c] = (qrounding_factors[Q] * quant_val) >> 7; cpi->UVround[Q][rc] = (qrounding_factors[Q] * quant_val) >> 7;
cpi->common.UVdequant[Q][r][c] = quant_val; cpi->common.UVdequant[Q][rc] = quant_val;
cpi->zrun_zbin_boost_uv[Q][i] = (quant_val * zbin_boost[i]) >> 7; cpi->zrun_zbin_boost_uv[Q][i] = (quant_val * zbin_boost[i]) >> 7;
} }
} }
...@@ -317,7 +311,7 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x) ...@@ -317,7 +311,7 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
QIndex = cpi->common.base_qindex; QIndex = cpi->common.base_qindex;
// Y // Y
zbin_extra = (cpi->common.Y1dequant[QIndex][0][1] * (cpi->zbin_over_quant + cpi->zbin_mode_boost)) >> 7; zbin_extra = (cpi->common.Y1dequant[QIndex][1] * (cpi->zbin_over_quant + cpi->zbin_mode_boost)) >> 7;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
...@@ -331,7 +325,7 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x) ...@@ -331,7 +325,7 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
} }
// UV // UV
zbin_extra = (cpi->common.UVdequant[QIndex][0][1] * (cpi->zbin_over_quant + cpi->zbin_mode_boost)) >> 7; zbin_extra = (cpi->common.UVdequant[QIndex][1] * (cpi->zbin_over_quant + cpi->zbin_mode_boost)) >> 7;
for (i = 16; i < 24; i++) for (i = 16; i < 24; i++)
{ {
...@@ -345,7 +339,7 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x) ...@@ -345,7 +339,7 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
} }
// Y2 // Y2
zbin_extra = (cpi->common.Y2dequant[QIndex][0][1] * ((cpi->zbin_over_quant / 2) + cpi->zbin_mode_boost)) >> 7; zbin_extra = (cpi->common.Y2dequant[QIndex][1] * ((cpi->zbin_over_quant / 2) + cpi->zbin_mode_boost)) >> 7;
x->block[24].quant = cpi->Y2quant[QIndex]; x->block[24].quant = cpi->Y2quant[QIndex];
x->block[24].quant_shift = cpi->Y2quant_shift[QIndex]; x->block[24].quant_shift = cpi->Y2quant_shift[QIndex];
x->block[24].zbin = cpi->Y2zbin[QIndex]; x->block[24].zbin = cpi->Y2zbin[QIndex];
......
...@@ -301,8 +301,8 @@ void vp8_optimize_b(MACROBLOCK *mb, int ib, int type, ...@@ -301,8 +301,8 @@ void vp8_optimize_b(MACROBLOCK *mb, int ib, int type,
vp8_strict_quantize_b(b, d); vp8_strict_quantize_b(b, d);
#endif #endif
dequant_ptr = &d->dequant[0][0]; dequant_ptr = d->dequant;
coeff_ptr = &b->coeff[0]; coeff_ptr = b->coeff;
qcoeff_ptr = d->qcoeff; qcoeff_ptr = d->qcoeff;
dqcoeff_ptr = d->dqcoeff; dqcoeff_ptr = d->dqcoeff;
i0 = !type; i0 = !type;
......