# HG changeset patch # User michael # Date 1153123748 0 # Node ID a647bf3a7fa8fb8145b445db9de566022dc2d58d # Parent 26d3704e12c04b015a1a29e7dcd7041666cd58d1 replace *_dequant (2 intra, 1 inter) by qmat (3 intra, 3 inter) (needed for theora according to spec) diff -r 26d3704e12c0 -r a647bf3a7fa8 vp3.c --- a/vp3.c Sun Jul 16 21:09:32 2006 +0000 +++ b/vp3.c Mon Jul 17 08:09:08 2006 +0000 @@ -285,9 +285,7 @@ /* these arrays need to be on 16-byte boundaries since SSE2 operations * index into them */ - DECLARE_ALIGNED_16(int16_t, intra_y_dequant[64]); - DECLARE_ALIGNED_16(int16_t, intra_c_dequant[64]); - DECLARE_ALIGNED_16(int16_t, inter_dequant[64]); + DECLARE_ALIGNED_16(int16_t, qmat[2][4][64]); //intra_y_dequant[0] = s->coded_intra_y_dequant[0] * dc_scale_factor / 100; - if (s->intra_y_dequant[0] < MIN_DEQUANT_VAL * 2) - s->intra_y_dequant[0] = MIN_DEQUANT_VAL * 2; - s->intra_y_dequant[0] *= SCALER; - - s->intra_c_dequant[0] = s->coded_intra_c_dequant[0] * dc_scale_factor / 100; - if (s->intra_c_dequant[0] < MIN_DEQUANT_VAL * 2) - s->intra_c_dequant[0] = MIN_DEQUANT_VAL * 2; - s->intra_c_dequant[0] *= SCALER; - - s->inter_dequant[0] = s->coded_inter_dequant[0] * dc_scale_factor / 100; - if (s->inter_dequant[0] < MIN_DEQUANT_VAL * 4) - s->inter_dequant[0] = MIN_DEQUANT_VAL * 4; - s->inter_dequant[0] *= SCALER; + s->qmat[0][0][0] = s->coded_intra_y_dequant[0] * dc_scale_factor / 100; + if (s->qmat[0][0][0] < MIN_DEQUANT_VAL * 2) + s->qmat[0][0][0] = MIN_DEQUANT_VAL * 2; + s->qmat[0][0][0] *= SCALER; + + s->qmat[0][1][0] = s->coded_intra_c_dequant[0] * dc_scale_factor / 100; + if (s->qmat[0][1][0] < MIN_DEQUANT_VAL * 2) + s->qmat[0][1][0] = MIN_DEQUANT_VAL * 2; + s->qmat[0][1][0] *= SCALER; + + s->qmat[1][0][0] = s->coded_inter_dequant[0] * dc_scale_factor / 100; + if (s->qmat[1][0][0] < MIN_DEQUANT_VAL * 4) + s->qmat[1][0][0] = MIN_DEQUANT_VAL * 4; + s->qmat[1][0][0] *= SCALER; /* scale AC quantizers, zigzag at the same time in preparation for * the dequantization phase */ @@ -688,29 +686,33 @@ int k= s->scantable.scantable[i]; j = s->scantable.permutated[i]; - s->intra_y_dequant[j] = s->coded_intra_y_dequant[k] * ac_scale_factor / 100; - if (s->intra_y_dequant[j] < MIN_DEQUANT_VAL) - s->intra_y_dequant[j] = MIN_DEQUANT_VAL; - s->intra_y_dequant[j] *= SCALER; - - s->intra_c_dequant[j] = s->coded_intra_c_dequant[k] * ac_scale_factor / 100; - if (s->intra_c_dequant[j] < MIN_DEQUANT_VAL) - s->intra_c_dequant[j] = MIN_DEQUANT_VAL; - s->intra_c_dequant[j] *= SCALER; - - s->inter_dequant[j] = s->coded_inter_dequant[k] * ac_scale_factor / 100; - if (s->inter_dequant[j] < MIN_DEQUANT_VAL * 2) - s->inter_dequant[j] = MIN_DEQUANT_VAL * 2; - s->inter_dequant[j] *= SCALER; + s->qmat[0][0][j] = s->coded_intra_y_dequant[k] * ac_scale_factor / 100; + if (s->qmat[0][0][j] < MIN_DEQUANT_VAL) + s->qmat[0][0][j] = MIN_DEQUANT_VAL; + s->qmat[0][0][j] *= SCALER; + + s->qmat[0][1][j] = s->coded_intra_c_dequant[k] * ac_scale_factor / 100; + if (s->qmat[0][1][j] < MIN_DEQUANT_VAL) + s->qmat[0][1][j] = MIN_DEQUANT_VAL; + s->qmat[0][1][j] *= SCALER; + + s->qmat[1][0][j] = s->coded_inter_dequant[k] * ac_scale_factor / 100; + if (s->qmat[1][0][j] < MIN_DEQUANT_VAL * 2) + s->qmat[1][0][j] = MIN_DEQUANT_VAL * 2; + s->qmat[1][0][j] *= SCALER; } - memset(s->qscale_table, (FFMAX(s->intra_y_dequant[1], s->intra_c_dequant[1])+8)/16, 512); //FIXME finetune + memcpy(s->qmat[0][2], s->qmat[0][1], sizeof(s->qmat[0][0])); + memcpy(s->qmat[1][1], s->qmat[1][0], sizeof(s->qmat[0][0])); + memcpy(s->qmat[1][2], s->qmat[1][0], sizeof(s->qmat[0][0])); + + memset(s->qscale_table, (FFMAX(s->qmat[0][0][1], s->qmat[0][1][1])+8)/16, 512); //FIXME finetune /* print debug information as requested */ debug_dequantizers("intra Y dequantizers:\n"); for (i = 0; i < 8; i++) { for (j = i * 8; j < i * 8 + 8; j++) { - debug_dequantizers(" %4d,", s->intra_y_dequant[j]); + debug_dequantizers(" %4d,", s->qmat[0][0][j]); } debug_dequantizers("\n"); } @@ -719,7 +721,7 @@ debug_dequantizers("intra C dequantizers:\n"); for (i = 0; i < 8; i++) { for (j = i * 8; j < i * 8 + 8; j++) { - debug_dequantizers(" %4d,", s->intra_c_dequant[j]); + debug_dequantizers(" %4d,", s->qmat[0][1][j]); } debug_dequantizers("\n"); } @@ -728,7 +730,7 @@ debug_dequantizers("interframe dequantizers:\n"); for (i = 0; i < 8; i++) { for (j = i * 8; j < i * 8 + 8; j++) { - debug_dequantizers(" %4d,", s->inter_dequant[j]); + debug_dequantizers(" %4d,", s->qmat[1][0][j]); } debug_dequantizers("\n"); } @@ -1847,12 +1849,9 @@ motion_source + stride + 1 + d, stride, 8); } - dequantizer = s->inter_dequant; + dequantizer = s->qmat[1][plane]; }else{ - if (plane == 0) - dequantizer = s->intra_y_dequant; - else - dequantizer = s->intra_c_dequant; + dequantizer = s->qmat[0][plane]; } /* dequantize the DCT coefficients */