Mercurial > libavcodec.hg
comparison h264.c @ 2844:5f20ab245501 libavcodec
prevent assert failures and infinite loops with broken streams
author | michael |
---|---|
date | Thu, 25 Aug 2005 00:01:57 +0000 |
parents | fd5d7c732c6b |
children | 40765c51a7a9 |
comparison
equal
deleted
inserted
replaced
2843:ea05470188e4 | 2844:5f20ab245501 |
---|---|
5361 if( ctx < 2 ) | 5361 if( ctx < 2 ) |
5362 ctx = 2; | 5362 ctx = 2; |
5363 else | 5363 else |
5364 ctx = 3; | 5364 ctx = 3; |
5365 val++; | 5365 val++; |
5366 if(val > 52) //prevent infinite loop | |
5367 return INT_MIN; | |
5366 } | 5368 } |
5367 | 5369 |
5368 if( val&0x01 ) | 5370 if( val&0x01 ) |
5369 return (val + 1)/2; | 5371 return (val + 1)/2; |
5370 else | 5372 else |
6546 if( IS_INTRA( s->current_picture.mb_type[mb_xy] ) || | 6548 if( IS_INTRA( s->current_picture.mb_type[mb_xy] ) || |
6547 IS_INTRA( s->current_picture.mb_type[mbn_xy] ) ) { | 6549 IS_INTRA( s->current_picture.mb_type[mbn_xy] ) ) { |
6548 bS[0] = bS[1] = bS[2] = bS[3] = 3; | 6550 bS[0] = bS[1] = bS[2] = bS[3] = 3; |
6549 } else { | 6551 } else { |
6550 // TODO | 6552 // TODO |
6551 assert(0); | 6553 av_log(h->s.avctx, AV_LOG_ERROR, "both non intra (TODO)\n"); |
6552 } | 6554 } |
6553 /* Filter edge */ | 6555 /* Filter edge */ |
6554 // Do not use s->qscale as luma quantizer because it has not the same | 6556 // Do not use s->qscale as luma quantizer because it has not the same |
6555 // value in IPCM macroblocks. | 6557 // value in IPCM macroblocks. |
6556 qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; | 6558 qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; |
6567 if( IS_INTRA( s->current_picture.mb_type[mb_xy] ) || | 6569 if( IS_INTRA( s->current_picture.mb_type[mb_xy] ) || |
6568 IS_INTRA( s->current_picture.mb_type[mbn_xy] ) ) { | 6570 IS_INTRA( s->current_picture.mb_type[mbn_xy] ) ) { |
6569 bS[0] = bS[1] = bS[2] = bS[3] = 3; | 6571 bS[0] = bS[1] = bS[2] = bS[3] = 3; |
6570 } else { | 6572 } else { |
6571 // TODO | 6573 // TODO |
6572 assert(0); | 6574 av_log(h->s.avctx, AV_LOG_ERROR, "both non intra (TODO)\n"); |
6573 } | 6575 } |
6574 /* Filter edge */ | 6576 /* Filter edge */ |
6575 // Do not use s->qscale as luma quantizer because it has not the same | 6577 // Do not use s->qscale as luma quantizer because it has not the same |
6576 // value in IPCM macroblocks. | 6578 // value in IPCM macroblocks. |
6577 qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; | 6579 qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; |
6699 if( ret >= 0 && h->mb_aff_frame ) { //FIXME optimal? or let mb_decode decode 16x32 ? | 6701 if( ret >= 0 && h->mb_aff_frame ) { //FIXME optimal? or let mb_decode decode 16x32 ? |
6700 s->mb_y++; | 6702 s->mb_y++; |
6701 | 6703 |
6702 if(ret>=0) ret = decode_mb_cabac(h); | 6704 if(ret>=0) ret = decode_mb_cabac(h); |
6703 | 6705 |
6704 hl_decode_mb(h); | 6706 if(ret>=0) hl_decode_mb(h); |
6705 s->mb_y--; | 6707 s->mb_y--; |
6706 } | 6708 } |
6707 eos = get_cabac_terminate( &h->cabac ); | 6709 eos = get_cabac_terminate( &h->cabac ); |
6708 | 6710 |
6709 if( ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 1) { | 6711 if( ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 1) { |