Mercurial > libavcodec.hg
comparison h263.c @ 364:6b6332e7008a libavcodec
segfault fix for b-frame encoding with height%16!=0
author | michaelni |
---|---|
date | Sun, 05 May 2002 19:03:24 +0000 |
parents | 71792167020c |
children | fdeec2834c79 |
comparison
equal
deleted
inserted
replaced
363:ff766a367974 | 364:6b6332e7008a |
---|---|
364 if ((cbp | motion_x | motion_y) == 0 && s->mv_type==MV_TYPE_16X16) { | 364 if ((cbp | motion_x | motion_y) == 0 && s->mv_type==MV_TYPE_16X16) { |
365 /* check if the B frames can skip it too, as we must skip it if we skip here | 365 /* check if the B frames can skip it too, as we must skip it if we skip here |
366 why didnt they just compress the skip-mb bits instead of reusing them ?! */ | 366 why didnt they just compress the skip-mb bits instead of reusing them ?! */ |
367 if(s->max_b_frames>0){ | 367 if(s->max_b_frames>0){ |
368 int i; | 368 int i; |
369 const int offset= (s->mb_x + s->mb_y*s->linesize)*16; | 369 int x,y, offset; |
370 uint8_t *p_pic= s->new_picture[0] + offset; | 370 uint8_t *p_pic; |
371 | |
372 x= s->mb_x*16; | |
373 y= s->mb_y*16; | |
374 if(x+16 > s->width) x= s->width-16; | |
375 if(y+16 > s->height) y= s->height-16; | |
376 | |
377 offset= x + y*s->linesize; | |
378 p_pic= s->new_picture[0] + offset; | |
379 | |
371 s->mb_skiped=1; | 380 s->mb_skiped=1; |
372 for(i=0; i<s->max_b_frames; i++){ | 381 for(i=0; i<s->max_b_frames; i++){ |
373 uint8_t *b_pic; | 382 uint8_t *b_pic; |
374 int diff; | 383 int diff; |
375 | 384 |
376 if(s->coded_order[i+1].pict_type!=B_TYPE) break; | 385 if(s->coded_order[i+1].pict_type!=B_TYPE) break; |
377 | 386 |
378 b_pic= s->coded_order[i+1].picture[0] + offset; | 387 b_pic= s->coded_order[i+1].picture[0] + offset; |
379 diff= pix_abs16x16(p_pic, b_pic, s->linesize); | 388 diff= pix_abs16x16(p_pic, b_pic, s->linesize); |
380 if(diff>s->qscale*70){ | 389 if(diff>s->qscale*70){ //FIXME check that 70 is optimal |
381 s->mb_skiped=0; | 390 s->mb_skiped=0; |
382 break; | 391 break; |
383 } | 392 } |
384 } | 393 } |
385 }else | 394 }else |
392 s->last_bits++; | 401 s->last_bits++; |
393 s->skip_count++; | 402 s->skip_count++; |
394 return; | 403 return; |
395 } | 404 } |
396 } | 405 } |
406 | |
397 put_bits(&s->pb, 1, 0); /* mb coded */ | 407 put_bits(&s->pb, 1, 0); /* mb coded */ |
398 if(s->mv_type==MV_TYPE_16X16){ | 408 if(s->mv_type==MV_TYPE_16X16){ |
399 cbpc = cbp & 3; | 409 cbpc = cbp & 3; |
400 put_bits(&s->pb, | 410 put_bits(&s->pb, |
401 inter_MCBPC_bits[cbpc], | 411 inter_MCBPC_bits[cbpc], |
2038 my = h263_decode_motion(s, s->last_mv[0][0][1], s->f_code); | 2048 my = h263_decode_motion(s, s->last_mv[0][0][1], s->f_code); |
2039 s->last_mv[0][0][0]= s->mv[0][0][0] = mx; | 2049 s->last_mv[0][0][0]= s->mv[0][0][0] = mx; |
2040 s->last_mv[0][0][1]= s->mv[0][0][1] = my; | 2050 s->last_mv[0][0][1]= s->mv[0][0][1] = my; |
2041 PRINT_MB_TYPE("F"); | 2051 PRINT_MB_TYPE("F"); |
2042 break; | 2052 break; |
2043 default: return -1; | 2053 default: |
2054 printf("illegal MB_type\n"); | |
2055 return -1; | |
2044 } | 2056 } |
2045 } else { /* I-Frame */ | 2057 } else { /* I-Frame */ |
2046 cbpc = get_vlc(&s->gb, &intra_MCBPC_vlc); | 2058 cbpc = get_vlc(&s->gb, &intra_MCBPC_vlc); |
2047 if (cbpc < 0) | 2059 if (cbpc < 0) |
2048 return -1; | 2060 return -1; |