comparison 4xm.c @ 5636:20fc1ce6b106 libavcodec

fix decoding of dracula.4xm before diego complains
author michael
date Wed, 05 Sep 2007 01:21:32 +0000
parents 8ca682e4911d
children 879b1015a20f
comparison
equal deleted inserted replaced
5635:8ca682e4911d 5636:20fc1ce6b106
247 247
248 static void init_mv(FourXContext *f){ 248 static void init_mv(FourXContext *f){
249 int i; 249 int i;
250 250
251 for(i=0; i<256; i++){ 251 for(i=0; i<256; i++){
252 if(f->version) 252 if(f->version>1)
253 f->mv[i] = mv[i][0] + mv[i][1] *f->current_picture.linesize[0]/2; 253 f->mv[i] = mv[i][0] + mv[i][1] *f->current_picture.linesize[0]/2;
254 else 254 else
255 f->mv[i] = (i&15) - 8 + ((i>>4)-8)*f->current_picture.linesize[0]/2; 255 f->mv[i] = (i&15) - 8 + ((i>>4)-8)*f->current_picture.linesize[0]/2;
256 } 256 }
257 } 257 }
298 } 298 }
299 299
300 static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, int log2w, int log2h, int stride){ 300 static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, int log2w, int log2h, int stride){
301 const int index= size2index[log2h][log2w]; 301 const int index= size2index[log2h][log2w];
302 const int h= 1<<log2h; 302 const int h= 1<<log2h;
303 int code= get_vlc2(&f->gb, block_type_vlc[1-f->version][index].table, BLOCK_TYPE_VLC_BITS, 1); 303 int code= get_vlc2(&f->gb, block_type_vlc[1-(f->version>1)][index].table, BLOCK_TYPE_VLC_BITS, 1);
304 uint16_t *start= f->last_picture.data[0]; 304 uint16_t *start= f->last_picture.data[0];
305 uint16_t *end= start + stride*(f->avctx->height-h+1) - (1<<log2w); 305 uint16_t *end= start + stride*(f->avctx->height-h+1) - (1<<log2w);
306 306
307 assert(code>=0 && code<=6); 307 assert(code>=0 && code<=6);
308 308
319 decode_p_block(f, dst + (stride<<log2h), src + (stride<<log2h), log2w, log2h, stride); 319 decode_p_block(f, dst + (stride<<log2h), src + (stride<<log2h), log2w, log2h, stride);
320 }else if(code == 2){ 320 }else if(code == 2){
321 log2w--; 321 log2w--;
322 decode_p_block(f, dst , src , log2w, log2h, stride); 322 decode_p_block(f, dst , src , log2w, log2h, stride);
323 decode_p_block(f, dst + (1<<log2w), src + (1<<log2w), log2w, log2h, stride); 323 decode_p_block(f, dst + (1<<log2w), src + (1<<log2w), log2w, log2h, stride);
324 }else if(code == 3 && f->version==0){ 324 }else if(code == 3 && f->version<2){
325 mcdc(dst, src, log2w, h, stride, 1, 0); 325 mcdc(dst, src, log2w, h, stride, 1, 0);
326 }else if(code == 4){ 326 }else if(code == 4){
327 src += f->mv[ *f->bytestream++ ]; 327 src += f->mv[ *f->bytestream++ ];
328 if(start > src || src > end){ 328 if(start > src || src > end){
329 av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n"); 329 av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
354 uint16_t *src= (uint16_t*)f->last_picture.data[0]; 354 uint16_t *src= (uint16_t*)f->last_picture.data[0];
355 uint16_t *dst= (uint16_t*)f->current_picture.data[0]; 355 uint16_t *dst= (uint16_t*)f->current_picture.data[0];
356 const int stride= f->current_picture.linesize[0]>>1; 356 const int stride= f->current_picture.linesize[0]>>1;
357 unsigned int bitstream_size, bytestream_size, wordstream_size, extra; 357 unsigned int bitstream_size, bytestream_size, wordstream_size, extra;
358 358
359 if(f->version){ 359 if(f->version>1){
360 extra=20; 360 extra=20;
361 bitstream_size= get32(buf+8); 361 bitstream_size= get32(buf+8);
362 wordstream_size= get32(buf+12); 362 wordstream_size= get32(buf+12);
363 bytestream_size= get32(buf+16); 363 bytestream_size= get32(buf+16);
364 }else{ 364 }else{
802 if(avctx->extradata_size != 4 || !avctx->extradata) { 802 if(avctx->extradata_size != 4 || !avctx->extradata) {
803 av_log(avctx, AV_LOG_ERROR, "extradata wrong or missing\n"); 803 av_log(avctx, AV_LOG_ERROR, "extradata wrong or missing\n");
804 return 1; 804 return 1;
805 } 805 }
806 806
807 f->version= AV_RL32(avctx->extradata) == 0x40000; 807 f->version= AV_RL32(avctx->extradata)>>16;
808 common_init(avctx); 808 common_init(avctx);
809 init_vlcs(f); 809 init_vlcs(f);
810 810
811 if(f->version) avctx->pix_fmt= PIX_FMT_RGB565; 811 if(f->version>2) avctx->pix_fmt= PIX_FMT_RGB565;
812 else avctx->pix_fmt= PIX_FMT_RGB555; 812 else avctx->pix_fmt= PIX_FMT_RGB555;
813 813
814 return 0; 814 return 0;
815 } 815 }
816 816
817 817