}
static void init_vlcs(FourXContext *f){
- static int done = 0;
int i;
- if (!done) {
- done = 1;
-
- for(i=0; i<4; i++){
- init_vlc(&block_type_vlc[i], BLOCK_TYPE_VLC_BITS, 7,
- &block_type_tab[i][0][1], 2, 1,
- &block_type_tab[i][0][0], 2, 1);
- }
+ for(i=0; i<4; i++){
+ init_vlc(&block_type_vlc[i], BLOCK_TYPE_VLC_BITS, 7,
+ &block_type_tab[i][0][1], 2, 1,
+ &block_type_tab[i][0][0], 2, 1, 1);
}
}
uint16_t *src= (uint16_t*)f->last_picture.data[0];
uint16_t *dst= (uint16_t*)f->current_picture.data[0];
const int stride= f->current_picture.linesize[0]>>1;
- const int bitstream_size= get32(buf+8);
- const int bytestream_size= get32(buf+16);
- const int wordstream_size= get32(buf+12);
+ const unsigned int bitstream_size= get32(buf+8);
+ const unsigned int bytestream_size= get32(buf+16);
+ const unsigned int wordstream_size= get32(buf+12);
- if(bitstream_size+ bytestream_size+ wordstream_size + 20 != length)
- printf("lengths %d %d %d %d\n", bitstream_size, bytestream_size, wordstream_size,
+ if(bitstream_size+ bytestream_size+ wordstream_size + 20 != length
+ || bitstream_size > (1<<26)
+ || bytestream_size > (1<<26)
+ || wordstream_size > (1<<26)
+ ){
+ av_log(f->avctx, AV_LOG_ERROR, "lengths %d %d %d %d\n", bitstream_size, bytestream_size, wordstream_size,
bitstream_size+ bytestream_size+ wordstream_size - length);
+ return -1;
+ }
f->bitstream_buffer= av_fast_realloc(f->bitstream_buffer, &f->bitstream_buffer_size, bitstream_size + FF_INPUT_BUFFER_PADDING_SIZE);
f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (uint32_t*)(buf + 20), bitstream_size/4);
}
if(bitstream_size != (get_bits_count(&f->gb)+31)/32*4)
- printf(" %d %d %d bytes left\n",
+ av_log(f->avctx, AV_LOG_ERROR, " %d %d %d bytes left\n",
bitstream_size - (get_bits_count(&f->gb)+31)/32*4,
bytestream_size - (f->bytestream - (buf + 20 + bitstream_size + wordstream_size)),
wordstream_size - (((uint8_t*)f->wordstream) - (buf + 20 + bitstream_size))
/* DC coef */
val = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3);
if (val>>4){
- printf("error dc run != 0\n");
+ av_log(f->avctx, AV_LOG_ERROR, "error dc run != 0\n");
}
if(val)
level = get_xbits(&f->gb, code & 0xf);
i += code >> 4;
if (i >= 64) {
- printf("run %d oveflow\n", i);
+ av_log(f->avctx, AV_LOG_ERROR, "run %d oveflow\n", i);
return 0;
}
for(i=4; i<6; i++) idct(block[i]);
}
+/* Note transform is:
+y= ( 1b + 4g + 2r)/14
+cb=( 3b - 2g - 1r)/14
+cr=(-1b - 4g + 5r)/14
+*/
for(y=0; y<8; y++){
for(x=0; x<8; x++){
DCTELEM *temp= block[(x>>2) + 2*(y>>2)] + 2*(x&3) + 2*8*(y&3); //FIXME optimize
for(node= j; up[node] != -1; node= up[node]){
bits += flag[node]<<len;
len++;
- if(len > 31) printf("vlc length overflow\n"); //can this happen at all ?
+ if(len > 31) av_log(f->avctx, AV_LOG_ERROR, "vlc length overflow\n"); //can this happen at all ?
}
bits_tab[j]= bits;
init_vlc(&f->pre_vlc, ACDC_VLC_BITS, 257,
len_tab , 1, 1,
- bits_tab, 4, 4);
+ bits_tab, 4, 4, 0);
return ptr;
}
const int height= f->avctx->height;
uint16_t *dst= (uint16_t*)f->current_picture.data[0];
const int stride= f->current_picture.linesize[0]>>1;
- const int bitstream_size= get32(buf);
- const int token_count= get32(buf + bitstream_size + 8);
- int prestream_size= 4*get32(buf + bitstream_size + 4);
+ const unsigned int bitstream_size= get32(buf);
+ const int token_count __attribute__((unused)) = get32(buf + bitstream_size + 8);
+ unsigned int prestream_size= 4*get32(buf + bitstream_size + 4);
uint8_t *prestream= buf + bitstream_size + 12;
- if(prestream_size + bitstream_size + 12 != length)
- fprintf(stderr, "size missmatch %d %d %d\n", prestream_size, bitstream_size, length);
+ if(prestream_size + bitstream_size + 12 != length
+ || bitstream_size > (1<<26)
+ || prestream_size > (1<<26)){
+ av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d %d\n", prestream_size, bitstream_size, length);
+ return -1;
+ }
prestream= read_huffman_tables(f, prestream);
}
if(get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3) != 256)
- printf("end missmatch\n");
+ av_log(f->avctx, AV_LOG_ERROR, "end mismatch\n");
return 0;
}
AVFrame *p, temp;
int i, frame_4cc, frame_size;
- *data_size = 0;
-
- /* special case for last picture */
- if (buf_size == 0) {
- return 0;
- }
-
frame_4cc= get32(buf);
if(buf_size != get32(buf+4)+8){
- fprintf(stderr, "size missmatch %d %d\n", buf_size, get32(buf+4));
+ av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d\n", buf_size, get32(buf+4));
}
if(frame_4cc == ff_get_fourcc("cfrm")){
for(i=0; i<CFRAME_BUFFER_COUNT; i++){
if(f->cfrm[i].id && f->cfrm[i].id < avctx->frame_number)
- printf("lost c frame %d\n", f->cfrm[i].id);
+ av_log(f->avctx, AV_LOG_ERROR, "lost c frame %d\n", f->cfrm[i].id);
}
for(i=0; i<CFRAME_BUFFER_COUNT; i++){
frame_size= cfrm->size;
if(id != avctx->frame_number){
- printf("cframe id missmatch %d %d\n", id, avctx->frame_number);
+ av_log(f->avctx, AV_LOG_ERROR, "cframe id mismatch %d %d\n", id, avctx->frame_number);
}
cfrm->size= cfrm->id= 0;
p->reference= 1;
if(avctx->get_buffer(avctx, p) < 0){
- fprintf(stderr, "get_buffer() failed\n");
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
if(decode_p_frame(f, buf, frame_size) < 0)
return -1;
}else if(frame_4cc == ff_get_fourcc("snd_")){
- printf("ignoring snd_ chunk length:%d\n", buf_size);
+ av_log(avctx, AV_LOG_ERROR, "ignoring snd_ chunk length:%d\n", buf_size);
}else{
- printf("ignoring unknown chunk length:%d\n", buf_size);
+ av_log(avctx, AV_LOG_ERROR, "ignoring unknown chunk length:%d\n", buf_size);
}
#if 0
}
free_vlc(&f->pre_vlc);
- avcodec_default_free_buffers(avctx);
-
return 0;
}