Mercurial > libavcodec.hg
comparison vc1.c @ 5997:90de28dfd8d6 libavcodec
Switch VC-1 decoder to output decoded residual immediately.
| author | kostya |
|---|---|
| date | Sat, 08 Dec 2007 10:41:18 +0000 |
| parents | 34f551bd0509 |
| children | 17883162bd18 |
comparison
equal
deleted
inserted
replaced
| 5996:9319837c5d02 | 5997:90de28dfd8d6 |
|---|---|
| 2882 return 0; | 2882 return 0; |
| 2883 } | 2883 } |
| 2884 | 2884 |
| 2885 /** Decode P block | 2885 /** Decode P block |
| 2886 */ | 2886 */ |
| 2887 static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquant, int ttmb, int first_block) | 2887 static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquant, int ttmb, int first_block, |
| 2888 uint8_t *dst, int linesize, int skip_block) | |
| 2888 { | 2889 { |
| 2889 MpegEncContext *s = &v->s; | 2890 MpegEncContext *s = &v->s; |
| 2890 GetBitContext *gb = &s->gb; | 2891 GetBitContext *gb = &s->gb; |
| 2891 int i, j; | 2892 int i, j; |
| 2892 int subblkpat = 0; | 2893 int subblkpat = 0; |
| 2928 idx = ff_vc1_simple_progressive_8x8_zz[i++]; | 2929 idx = ff_vc1_simple_progressive_8x8_zz[i++]; |
| 2929 block[idx] = value * scale; | 2930 block[idx] = value * scale; |
| 2930 if(!v->pquantizer) | 2931 if(!v->pquantizer) |
| 2931 block[idx] += (block[idx] < 0) ? -mquant : mquant; | 2932 block[idx] += (block[idx] < 0) ? -mquant : mquant; |
| 2932 } | 2933 } |
| 2933 s->dsp.vc1_inv_trans_8x8(block); | 2934 if(!skip_block){ |
| 2935 s->dsp.vc1_inv_trans_8x8(block); | |
| 2936 s->dsp.add_pixels_clamped(block, dst, linesize); | |
| 2937 } | |
| 2934 break; | 2938 break; |
| 2935 case TT_4X4: | 2939 case TT_4X4: |
| 2936 for(j = 0; j < 4; j++) { | 2940 for(j = 0; j < 4; j++) { |
| 2937 last = subblkpat & (1 << (3 - j)); | 2941 last = subblkpat & (1 << (3 - j)); |
| 2938 i = 0; | 2942 i = 0; |
| 2945 idx = ff_vc1_simple_progressive_4x4_zz[i++]; | 2949 idx = ff_vc1_simple_progressive_4x4_zz[i++]; |
| 2946 block[idx + off] = value * scale; | 2950 block[idx + off] = value * scale; |
| 2947 if(!v->pquantizer) | 2951 if(!v->pquantizer) |
| 2948 block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant; | 2952 block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant; |
| 2949 } | 2953 } |
| 2950 if(!(subblkpat & (1 << (3 - j)))) | 2954 if(!(subblkpat & (1 << (3 - j))) && !skip_block) |
| 2951 s->dsp.vc1_inv_trans_4x4(block, j); | 2955 s->dsp.vc1_inv_trans_4x4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off); |
| 2952 } | 2956 } |
| 2953 break; | 2957 break; |
| 2954 case TT_8X4: | 2958 case TT_8X4: |
| 2955 for(j = 0; j < 2; j++) { | 2959 for(j = 0; j < 2; j++) { |
| 2956 last = subblkpat & (1 << (1 - j)); | 2960 last = subblkpat & (1 << (1 - j)); |
| 2967 idx = ff_vc1_adv_progressive_8x4_zz[i++]; | 2971 idx = ff_vc1_adv_progressive_8x4_zz[i++]; |
| 2968 block[idx + off] = value * scale; | 2972 block[idx + off] = value * scale; |
| 2969 if(!v->pquantizer) | 2973 if(!v->pquantizer) |
| 2970 block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant; | 2974 block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant; |
| 2971 } | 2975 } |
| 2972 if(!(subblkpat & (1 << (1 - j)))) | 2976 if(!(subblkpat & (1 << (1 - j))) && !skip_block) |
| 2973 s->dsp.vc1_inv_trans_8x4(block, j); | 2977 s->dsp.vc1_inv_trans_8x4(dst + j*4*linesize, linesize, block + off); |
| 2974 } | 2978 } |
| 2975 break; | 2979 break; |
| 2976 case TT_4X8: | 2980 case TT_4X8: |
| 2977 for(j = 0; j < 2; j++) { | 2981 for(j = 0; j < 2; j++) { |
| 2978 last = subblkpat & (1 << (1 - j)); | 2982 last = subblkpat & (1 << (1 - j)); |
| 2989 idx = ff_vc1_adv_progressive_4x8_zz[i++]; | 2993 idx = ff_vc1_adv_progressive_4x8_zz[i++]; |
| 2990 block[idx + off] = value * scale; | 2994 block[idx + off] = value * scale; |
| 2991 if(!v->pquantizer) | 2995 if(!v->pquantizer) |
| 2992 block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant; | 2996 block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant; |
| 2993 } | 2997 } |
| 2994 if(!(subblkpat & (1 << (1 - j)))) | 2998 if(!(subblkpat & (1 << (1 - j))) && !skip_block) |
| 2995 s->dsp.vc1_inv_trans_4x8(block, j); | 2999 s->dsp.vc1_inv_trans_4x8(dst + j*4, linesize, block + off); |
| 2996 } | 3000 } |
| 2997 break; | 3001 break; |
| 2998 } | 3002 } |
| 2999 return 0; | 3003 return 0; |
| 3000 } | 3004 } |
| 3099 s->dsp.vc1_h_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); | 3103 s->dsp.vc1_h_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); |
| 3100 if(v->a_avail) | 3104 if(v->a_avail) |
| 3101 s->dsp.vc1_v_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); | 3105 s->dsp.vc1_v_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); |
| 3102 } | 3106 } |
| 3103 } else if(val) { | 3107 } else if(val) { |
| 3104 vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block); | 3108 vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY)); |
| 3105 if(!v->ttmbf && ttmb < 8) ttmb = -1; | 3109 if(!v->ttmbf && ttmb < 8) ttmb = -1; |
| 3106 first_block = 0; | 3110 first_block = 0; |
| 3107 if((i<4) || !(s->flags & CODEC_FLAG_GRAY)) | |
| 3108 s->dsp.add_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize); | |
| 3109 } | 3111 } |
| 3110 } | 3112 } |
| 3111 } | 3113 } |
| 3112 else //Skipped | 3114 else //Skipped |
| 3113 { | 3115 { |
| 3201 s->dsp.vc1_h_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); | 3203 s->dsp.vc1_h_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); |
| 3202 if(v->a_avail) | 3204 if(v->a_avail) |
| 3203 s->dsp.vc1_v_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); | 3205 s->dsp.vc1_v_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); |
| 3204 } | 3206 } |
| 3205 } else if(is_coded[i]) { | 3207 } else if(is_coded[i]) { |
| 3206 status = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block); | 3208 status = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY)); |
| 3207 if(!v->ttmbf && ttmb < 8) ttmb = -1; | 3209 if(!v->ttmbf && ttmb < 8) ttmb = -1; |
| 3208 first_block = 0; | 3210 first_block = 0; |
| 3209 if((i<4) || !(s->flags & CODEC_FLAG_GRAY)) | |
| 3210 s->dsp.add_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize); | |
| 3211 } | 3211 } |
| 3212 } | 3212 } |
| 3213 return status; | 3213 return status; |
| 3214 } | 3214 } |
| 3215 else //Skipped MB | 3215 else //Skipped MB |
| 3375 if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; | 3375 if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; |
| 3376 s->dsp.vc1_inv_trans_8x8(s->block[i]); | 3376 s->dsp.vc1_inv_trans_8x8(s->block[i]); |
| 3377 if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1; | 3377 if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1; |
| 3378 s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); | 3378 s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); |
| 3379 } else if(val) { | 3379 } else if(val) { |
| 3380 vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block); | 3380 vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY)); |
| 3381 if(!v->ttmbf && ttmb < 8) ttmb = -1; | 3381 if(!v->ttmbf && ttmb < 8) ttmb = -1; |
| 3382 first_block = 0; | 3382 first_block = 0; |
| 3383 if((i<4) || !(s->flags & CODEC_FLAG_GRAY)) | |
| 3384 s->dsp.add_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize); | |
| 3385 } | 3383 } |
| 3386 } | 3384 } |
| 3387 } | 3385 } |
| 3388 | 3386 |
| 3389 /** Decode blocks of I-frame | 3387 /** Decode blocks of I-frame |
