static const uint16_t table_mb_intra[64][2];
-static inline int decode210(GetBitContext *gb){
- if (get_bits1(gb))
- return 0;
- else
- return 2 - get_bits1(gb);
-}
-
/**
* Init VC-1 specific tables and VC1Context members
* @param v The VC1Context to initialize
if (v->profile == PROFILE_ADVANCED)
{
+ v->zz_8x4 = ff_vc1_adv_progressive_8x4_zz;
+ v->zz_4x8 = ff_vc1_adv_progressive_4x8_zz;
return decode_sequence_header_adv(v, gb);
}
else
{
+ v->zz_8x4 = ff_vc1_simple_progressive_8x4_zz;
+ v->zz_4x8 = ff_vc1_simple_progressive_4x8_zz;
v->res_sm = get_bits(gb, 2); //reserved
if (v->res_sm)
{
v->res_fasttx = get_bits1(gb);
if (!v->res_fasttx)
{
- v->s.dsp.vc1_inv_trans_8x8 = simple_idct;
+ v->s.dsp.vc1_inv_trans_8x8 = ff_simple_idct;
+ v->s.dsp.vc1_inv_trans_8x4 = ff_simple_idct84_add;
+ v->s.dsp.vc1_inv_trans_4x8 = ff_simple_idct48_add;
+ v->s.dsp.vc1_inv_trans_4x4 = ff_simple_idct44_add;
}
v->fastuvmc = get_bits1(gb); //common
/* Quantizer stuff */
pqindex = get_bits(gb, 5);
+ if(!pqindex) return -1;
if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
v->pq = ff_vc1_pquant_table[0][pqindex];
else
}
}
pqindex = get_bits(gb, 5);
+ if(!pqindex) return -1;
v->pqindex = pqindex;
if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
v->pq = ff_vc1_pquant_table[0][pqindex];
/** Decode P block
*/
-static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquant, int ttmb, int first_block)
+static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquant, int ttmb, int first_block,
+ uint8_t *dst, int linesize, int skip_block)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &s->gb;
if(!v->pquantizer)
block[idx] += (block[idx] < 0) ? -mquant : mquant;
}
- s->dsp.vc1_inv_trans_8x8(block);
+ if(!skip_block){
+ s->dsp.vc1_inv_trans_8x8(block);
+ s->dsp.add_pixels_clamped(block, dst, linesize);
+ }
break;
case TT_4X4:
for(j = 0; j < 4; j++) {
if(!v->pquantizer)
block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant;
}
- if(!(subblkpat & (1 << (3 - j))))
- s->dsp.vc1_inv_trans_4x4(block, j);
+ if(!(subblkpat & (1 << (3 - j))) && !skip_block)
+ s->dsp.vc1_inv_trans_4x4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off);
}
break;
case TT_8X4:
i += skip;
if(i > 31)
break;
- if(v->profile < PROFILE_ADVANCED)
- idx = ff_vc1_simple_progressive_8x4_zz[i++];
- else
- idx = ff_vc1_adv_progressive_8x4_zz[i++];
- block[idx + off] = value * scale;
+ idx = v->zz_8x4[i++]+off;
+ block[idx] = value * scale;
if(!v->pquantizer)
- block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant;
+ block[idx] += (block[idx] < 0) ? -mquant : mquant;
}
- if(!(subblkpat & (1 << (1 - j))))
- s->dsp.vc1_inv_trans_8x4(block, j);
+ if(!(subblkpat & (1 << (1 - j))) && !skip_block)
+ s->dsp.vc1_inv_trans_8x4(dst + j*4*linesize, linesize, block + off);
}
break;
case TT_4X8:
i += skip;
if(i > 31)
break;
- if(v->profile < PROFILE_ADVANCED)
- idx = ff_vc1_simple_progressive_4x8_zz[i++];
- else
- idx = ff_vc1_adv_progressive_4x8_zz[i++];
- block[idx + off] = value * scale;
+ idx = v->zz_4x8[i++]+off;
+ block[idx] = value * scale;
if(!v->pquantizer)
- block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant;
+ block[idx] += (block[idx] < 0) ? -mquant : mquant;
}
- if(!(subblkpat & (1 << (1 - j))))
- s->dsp.vc1_inv_trans_4x8(block, j);
+ if(!(subblkpat & (1 << (1 - j))) && !skip_block)
+ s->dsp.vc1_inv_trans_4x8(dst + j*4, linesize, block + off);
}
break;
}
s->dsp.vc1_v_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2));
}
} else if(val) {
- vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block);
+ 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));
if(!v->ttmbf && ttmb < 8) ttmb = -1;
first_block = 0;
- if((i<4) || !(s->flags & CODEC_FLAG_GRAY))
- s->dsp.add_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize);
}
}
}
s->dsp.vc1_v_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2));
}
} else if(is_coded[i]) {
- status = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block);
+ 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));
if(!v->ttmbf && ttmb < 8) ttmb = -1;
first_block = 0;
- if((i<4) || !(s->flags & CODEC_FLAG_GRAY))
- s->dsp.add_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize);
}
}
return status;
if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;
s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2));
} else if(val) {
- vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block);
+ 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));
if(!v->ttmbf && ttmb < 8) ttmb = -1;
first_block = 0;
- if((i<4) || !(s->flags & CODEC_FLAG_GRAY))
- s->dsp.add_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize);
}
}
}
/** Find VC-1 marker in buffer
* @return position where next marker starts or end of buffer if no marker found
*/
-static av_always_inline uint8_t* find_next_marker(uint8_t *src, uint8_t *end)
+static av_always_inline const uint8_t* find_next_marker(const uint8_t *src, const uint8_t *end)
{
uint32_t mrk = 0xFFFFFFFF;
return end;
}
-static av_always_inline int vc1_unescape_buffer(uint8_t *src, int size, uint8_t *dst)
+static av_always_inline int vc1_unescape_buffer(const uint8_t *src, int size, uint8_t *dst)
{
int dsize = 0, i;
av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count);
}
} else { // VC1/WVC1
- uint8_t *start = avctx->extradata, *end = avctx->extradata + avctx->extradata_size;
- uint8_t *next; int size, buf2_size;
+ const uint8_t *start = avctx->extradata;
+ uint8_t *end = avctx->extradata + avctx->extradata_size;
+ const uint8_t *next;
+ int size, buf2_size;
uint8_t *buf2 = NULL;
- int seq_inited = 0, ep_inited = 0;
+ int seq_initialized = 0, ep_initialized = 0;
if(avctx->extradata_size < 16) {
av_log(avctx, AV_LOG_ERROR, "Extradata size too small: %i\n", avctx->extradata_size);
av_free(buf2);
return -1;
}
- seq_inited = 1;
+ seq_initialized = 1;
break;
case VC1_CODE_ENTRYPOINT:
if(decode_entry_point(avctx, &gb) < 0){
av_free(buf2);
return -1;
}
- ep_inited = 1;
+ ep_initialized = 1;
break;
}
}
av_free(buf2);
- if(!seq_inited || !ep_inited){
+ if(!seq_initialized || !ep_initialized){
av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n");
return -1;
}
*/
static int vc1_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- uint8_t *buf, int buf_size)
+ const uint8_t *buf, int buf_size)
{
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if(IS_MARKER(AV_RB32(buf))){ /* frame starts with marker and needs to be parsed */
- uint8_t *start, *end, *next;
+ const uint8_t *start, *end, *next;
int size;
next = buf;
}
}
}else if(v->interlace && ((buf[0] & 0xC0) == 0xC0)){ /* WVC1 interlaced stores both fields divided by marker */
- uint8_t *divider;
+ const uint8_t *divider;
divider = find_next_marker(buf, buf + buf_size);
if((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD){
}
/* Return the Picture timestamp as the frame number */
- /* we subtract 1 because it is added on utils.c */
+ /* we subtract 1 because it is added on utils.c */
avctx->frame_number = s->picture_number - 1;
av_free(buf2);
av_freep(&v->acpred_plane);
av_freep(&v->over_flags_plane);
av_freep(&v->mb_type_base);
+ ff_intrax8_common_end(&v->x8);
return 0;
}