comparison 4xm.c @ 5635:8ca682e4911d libavcodec

fix segfault with dracula.4xm closes issue132
author michael
date Wed, 05 Sep 2007 01:14:17 +0000
parents c94931b2f2e5
children 20fc1ce6b106
comparison
equal deleted inserted replaced
5634:9960732c7d7b 5635:8ca682e4911d
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][index].table, BLOCK_TYPE_VLC_BITS, 1);
304 uint16_t *start= f->last_picture.data[0];
305 uint16_t *end= start + stride*(f->avctx->height-h+1) - (1<<log2w);
304 306
305 assert(code>=0 && code<=6); 307 assert(code>=0 && code<=6);
306 308
307 if(code == 0){ 309 if(code == 0){
308 src += f->mv[ *f->bytestream++ ]; 310 src += f->mv[ *f->bytestream++ ];
311 if(start > src || src > end){
312 av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
313 return;
314 }
309 mcdc(dst, src, log2w, h, stride, 1, 0); 315 mcdc(dst, src, log2w, h, stride, 1, 0);
310 }else if(code == 1){ 316 }else if(code == 1){
311 log2h--; 317 log2h--;
312 decode_p_block(f, dst , src , log2w, log2h, stride); 318 decode_p_block(f, dst , src , log2w, log2h, stride);
313 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);
317 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);
318 }else if(code == 3 && f->version==0){ 324 }else if(code == 3 && f->version==0){
319 mcdc(dst, src, log2w, h, stride, 1, 0); 325 mcdc(dst, src, log2w, h, stride, 1, 0);
320 }else if(code == 4){ 326 }else if(code == 4){
321 src += f->mv[ *f->bytestream++ ]; 327 src += f->mv[ *f->bytestream++ ];
328 if(start > src || src > end){
329 av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n");
330 return;
331 }
322 mcdc(dst, src, log2w, h, stride, 1, le2me_16(*f->wordstream++)); 332 mcdc(dst, src, log2w, h, stride, 1, le2me_16(*f->wordstream++));
323 }else if(code == 5){ 333 }else if(code == 5){
324 mcdc(dst, src, log2w, h, stride, 0, le2me_16(*f->wordstream++)); 334 mcdc(dst, src, log2w, h, stride, 0, le2me_16(*f->wordstream++));
325 }else if(code == 6){ 335 }else if(code == 6){
326 if(log2w){ 336 if(log2w){