Mercurial > libavcodec.hg
comparison h264.c @ 11125:1f13ac0e696b libavcodec
Try to support truncated h264 frames mixed with mpeg pes headers in mkv.
Fixes issue1585
author | michael |
---|---|
date | Fri, 12 Feb 2010 19:25:23 +0000 |
parents | 7e5d7873fad9 |
children | af73d215879d |
comparison
equal
deleted
inserted
replaced
11124:85a1b00a2413 | 11125:1f13ac0e696b |
---|---|
2255 if(ret>=0) ff_h264_hl_decode_mb(h); | 2255 if(ret>=0) ff_h264_hl_decode_mb(h); |
2256 s->mb_y--; | 2256 s->mb_y--; |
2257 } | 2257 } |
2258 eos = get_cabac_terminate( &h->cabac ); | 2258 eos = get_cabac_terminate( &h->cabac ); |
2259 | 2259 |
2260 if((s->workaround_bugs & FF_BUG_TRUNCATED) && h->cabac.bytestream > h->cabac.bytestream_end + 2){ | |
2261 ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask); | |
2262 return 0; | |
2263 } | |
2260 if( ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 2) { | 2264 if( ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 2) { |
2261 av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d, bytestream (%td)\n", s->mb_x, s->mb_y, h->cabac.bytestream_end - h->cabac.bytestream); | 2265 av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d, bytestream (%td)\n", s->mb_x, s->mb_y, h->cabac.bytestream_end - h->cabac.bytestream); |
2262 ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask); | 2266 ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask); |
2263 return -1; | 2267 return -1; |
2264 } | 2268 } |
2490 | 2494 |
2491 ptr= ff_h264_decode_nal(hx, buf + buf_index, &dst_length, &consumed, next_avc - buf_index); | 2495 ptr= ff_h264_decode_nal(hx, buf + buf_index, &dst_length, &consumed, next_avc - buf_index); |
2492 if (ptr==NULL || dst_length < 0){ | 2496 if (ptr==NULL || dst_length < 0){ |
2493 return -1; | 2497 return -1; |
2494 } | 2498 } |
2499 i= buf_index + consumed; | |
2500 if((s->workaround_bugs & FF_BUG_AUTODETECT) && i+3<next_avc && | |
2501 buf[i]==0x00 && buf[i+1]==0x00 && buf[i+2]==0x01 && buf[i+3]==0xE0) | |
2502 s->workaround_bugs |= FF_BUG_TRUNCATED; | |
2503 | |
2504 if(!(s->workaround_bugs & FF_BUG_TRUNCATED)){ | |
2495 while(ptr[dst_length - 1] == 0 && dst_length > 0) | 2505 while(ptr[dst_length - 1] == 0 && dst_length > 0) |
2496 dst_length--; | 2506 dst_length--; |
2507 } | |
2497 bit_length= !dst_length ? 0 : (8*dst_length - ff_h264_decode_rbsp_trailing(h, ptr + dst_length - 1)); | 2508 bit_length= !dst_length ? 0 : (8*dst_length - ff_h264_decode_rbsp_trailing(h, ptr + dst_length - 1)); |
2498 | 2509 |
2499 if(s->avctx->debug&FF_DEBUG_STARTCODE){ | 2510 if(s->avctx->debug&FF_DEBUG_STARTCODE){ |
2500 av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d at %d/%d length %d\n", hx->nal_unit_type, buf_index, buf_size, dst_length); | 2511 av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d at %d/%d length %d\n", hx->nal_unit_type, buf_index, buf_size, dst_length); |
2501 } | 2512 } |