diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2011-02-16 14:18:21 -0500 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-02-17 17:35:35 -0500 |
commit | 1da6ea39542424ddb691dc6cf08d611a4c6db247 (patch) | |
tree | 36b2273877ee0a91d23a73b3eab1cad15acff600 /libavcodec/vc1dec.c | |
parent | c2ca851b234e169b50730ef357aeade8047491eb (diff) | |
download | ffmpeg-1da6ea39542424ddb691dc6cf08d611a4c6db247.tar.gz |
VC1: transpose IDCT 8x8 coeffs while reading.
Diffstat (limited to 'libavcodec/vc1dec.c')
-rw-r--r-- | libavcodec/vc1dec.c | 95 |
1 files changed, 50 insertions, 45 deletions
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 3bd2cce297..169797ca75 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -1499,11 +1499,11 @@ static int vc1_decode_i_block(VC1Context *v, DCTELEM block[64], int n, int coded if(v->s.ac_pred) { if(!dc_pred_dir) - zz_table = wmv1_scantable[2]; + zz_table = v->zz_8x8[2]; else - zz_table = wmv1_scantable[3]; + zz_table = v->zz_8x8[3]; } else - zz_table = wmv1_scantable[1]; + zz_table = v->zz_8x8[1]; ac_val = s->ac_val[0][0] + s->block_index[n] * 16; ac_val2 = ac_val; @@ -1524,16 +1524,16 @@ static int vc1_decode_i_block(VC1Context *v, DCTELEM block[64], int n, int coded if(s->ac_pred) { if(dc_pred_dir) { //left for(k = 1; k < 8; k++) - block[k << 3] += ac_val[k]; + block[k] += ac_val[k]; } else { //top for(k = 1; k < 8; k++) - block[k] += ac_val[k + 8]; + block[k << 3] += ac_val[k + 8]; } } /* save AC coeffs for further prediction */ for(k = 1; k < 8; k++) { - ac_val2[k] = block[k << 3]; - ac_val2[k + 8] = block[k]; + ac_val2[k] = block[k]; + ac_val2[k + 8] = block[k << 3]; } /* scale AC coeffs */ @@ -1570,15 +1570,15 @@ not_coded: if(s->ac_pred) { if(dc_pred_dir) { //left for(k = 1; k < 8; k++) { - block[k << 3] = ac_val[k] * scale; - if(!v->pquantizer && block[k << 3]) - block[k << 3] += (block[k << 3] < 0) ? -v->pq : v->pq; + block[k] = ac_val[k] * scale; + if(!v->pquantizer && block[k]) + block[k] += (block[k] < 0) ? -v->pq : v->pq; } } else { //top for(k = 1; k < 8; k++) { - block[k] = ac_val[k + 8] * scale; - if(!v->pquantizer && block[k]) - block[k] += (block[k] < 0) ? -v->pq : v->pq; + block[k << 3] = ac_val[k + 8] * scale; + if(!v->pquantizer && block[k << 3]) + block[k << 3] += (block[k << 3] < 0) ? -v->pq : v->pq; } } i = 63; @@ -1682,11 +1682,11 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int c if(v->s.ac_pred) { if(!dc_pred_dir) - zz_table = wmv1_scantable[2]; + zz_table = v->zz_8x8[2]; else - zz_table = wmv1_scantable[3]; + zz_table = v->zz_8x8[3]; } else - zz_table = wmv1_scantable[1]; + zz_table = v->zz_8x8[1]; while (!last) { vc1_decode_ac_coeff(v, &last, &skip, &value, codingset); @@ -1705,25 +1705,25 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int c if(dc_pred_dir) { //left for(k = 1; k < 8; k++) - block[k << 3] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; + block[k] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; } else { //top for(k = 1; k < 8; k++) - block[k] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; + block[k << 3] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; } } else { if(dc_pred_dir) { //left for(k = 1; k < 8; k++) - block[k << 3] += ac_val[k]; + block[k] += ac_val[k]; } else { //top for(k = 1; k < 8; k++) - block[k] += ac_val[k + 8]; + block[k << 3] += ac_val[k + 8]; } } } /* save AC coeffs for further prediction */ for(k = 1; k < 8; k++) { - ac_val2[k] = block[k << 3]; - ac_val2[k + 8] = block[k]; + ac_val2[k] = block[k]; + ac_val2[k + 8] = block[k << 3]; } /* scale AC coeffs */ @@ -1765,15 +1765,15 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int c if(use_pred) { if(dc_pred_dir) { //left for(k = 1; k < 8; k++) { - block[k << 3] = ac_val2[k] * scale; - if(!v->pquantizer && block[k << 3]) - block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant; + block[k] = ac_val2[k] * scale; + if(!v->pquantizer && block[k]) + block[k] += (block[k] < 0) ? -mquant : mquant; } } else { //top for(k = 1; k < 8; k++) { - block[k] = ac_val2[k + 8] * scale; - if(!v->pquantizer && block[k]) - block[k] += (block[k] < 0) ? -mquant : mquant; + block[k << 3] = ac_val2[k + 8] * scale; + if(!v->pquantizer && block[k << 3]) + block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant; } } i = 63; @@ -1884,17 +1884,14 @@ static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int c if(coded) { int last = 0, skip, value; - const uint8_t *zz_table; int k; - zz_table = wmv1_scantable[0]; - while (!last) { vc1_decode_ac_coeff(v, &last, &skip, &value, codingset); i += skip; if(i > 63) break; - block[zz_table[i++]] = value; + block[v->zz_8x8[0][i++]] = value; } /* apply AC prediction if needed */ @@ -1906,25 +1903,25 @@ static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int c if(dc_pred_dir) { //left for(k = 1; k < 8; k++) - block[k << 3] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; + block[k] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; } else { //top for(k = 1; k < 8; k++) - block[k] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; + block[k << 3] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; } } else { if(dc_pred_dir) { //left for(k = 1; k < 8; k++) - block[k << 3] += ac_val[k]; + block[k] += ac_val[k]; } else { //top for(k = 1; k < 8; k++) - block[k] += ac_val[k + 8]; + block[k << 3] += ac_val[k + 8]; } } } /* save AC coeffs for further prediction */ for(k = 1; k < 8; k++) { - ac_val2[k] = block[k << 3]; - ac_val2[k + 8] = block[k]; + ac_val2[k] = block[k]; + ac_val2[k + 8] = block[k << 3]; } /* scale AC coeffs */ @@ -1966,15 +1963,15 @@ static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int c if(use_pred) { if(dc_pred_dir) { //left for(k = 1; k < 8; k++) { - block[k << 3] = ac_val2[k] * scale; - if(!v->pquantizer && block[k << 3]) - block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant; + block[k] = ac_val2[k] * scale; + if(!v->pquantizer && block[k]) + block[k] += (block[k] < 0) ? -mquant : mquant; } } else { //top for(k = 1; k < 8; k++) { - block[k] = ac_val2[k + 8] * scale; - if(!v->pquantizer && block[k]) - block[k] += (block[k] < 0) ? -mquant : mquant; + block[k << 3] = ac_val2[k + 8] * scale; + if(!v->pquantizer && block[k << 3]) + block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant; } } i = 63; @@ -2035,7 +2032,7 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquan i += skip; if(i > 63) break; - idx = wmv1_scantable[0][i++]; + idx = v->zz_8x8[0][i++]; block[idx] = value * scale; if(!v->pquantizer) block[idx] += (block[idx] < 0) ? -mquant : mquant; @@ -3007,6 +3004,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) VC1Context *v = avctx->priv_data; MpegEncContext *s = &v->s; GetBitContext gb; + int i; if (!avctx->extradata_size || !avctx->extradata) return -1; if (!(avctx->flags & CODEC_FLAG_GRAY)) @@ -3025,6 +3023,13 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) if(ff_msmpeg4_decode_init(avctx) < 0) return -1; if (vc1_init_common(v) < 0) return -1; + for (i = 0; i < 64; i++) { +#define transpose(x) ((x>>3) | ((x&7)<<3)) + v->zz_8x8[0][i] = transpose(wmv1_scantable[0][i]); + v->zz_8x8[1][i] = transpose(wmv1_scantable[1][i]); + v->zz_8x8[2][i] = transpose(wmv1_scantable[2][i]); + v->zz_8x8[3][i] = transpose(wmv1_scantable[3][i]); + } avctx->coded_width = avctx->width; avctx->coded_height = avctx->height; |