diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2008-07-23 02:12:54 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2008-07-23 02:12:54 +0000 |
commit | 26b86e47c010029d7ca7c7264f710c240d85339a (patch) | |
tree | 2732c7024aedbe0dbae06073ffaf02e5ba20efbb /libavcodec | |
parent | e44e48372ba8d3eac2ec0340cc2a883aa9786a59 (diff) | |
download | ffmpeg-26b86e47c010029d7ca7c7264f710c240d85339a.tar.gz |
Support gaps in the frame num.
Fixes at least:
MR3_TANDBERG_B.264
MR4_TANDBERG_C.264
MR5_TANDBERG_C.264
Originally committed as revision 14339 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/h264.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 0236eb422f..b8db9263ee 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3539,6 +3539,12 @@ static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ pic= remove_long(h, j); if(pic) unreference_pic(h, pic, 0); } + s->current_picture_ptr->poc= + s->current_picture_ptr->field_poc[0]= + s->current_picture_ptr->field_poc[1]= + h->poc_lsb= + h->poc_msb= + h->frame_num= s->current_picture_ptr->frame_num= 0; break; default: assert(0); @@ -3599,7 +3605,7 @@ static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ "number of reference frames exceeds max (probably " "corrupt input), discarding one\n"); - if (h->long_ref_count) { + if (h->long_ref_count && !h->short_ref_count) { for (i = 0; i < 16; ++i) if (h->long_ref[i]) break; @@ -4018,6 +4024,16 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ } if(h0->current_slice == 0){ + while(h->frame_num != h->prev_frame_num && + h->frame_num != (h->prev_frame_num+1)%(1<<h->sps.log2_max_frame_num)){ + av_log(NULL, AV_LOG_DEBUG, "Frame num gap %d %d\n", h->frame_num, h->prev_frame_num); + frame_start(h); + h->prev_frame_num++; + h->prev_frame_num %= 1<<h->sps.log2_max_frame_num; + s->current_picture_ptr->frame_num= h->prev_frame_num; + execute_ref_pic_marking(h, NULL, 0); + } + /* See if we have a decoded first field looking for a pair... */ if (s0->first_field) { assert(s0->current_picture_ptr); @@ -7738,7 +7754,7 @@ static int decode_frame(AVCodecContext *avctx, //FIXME factorize this with the output code below out = h->delayed_pic[0]; out_idx = 0; - for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame; i++) + for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame && h->delayed_pic[i]->poc; i++) if(h->delayed_pic[i]->poc < out->poc){ out = h->delayed_pic[i]; out_idx = i; @@ -7821,13 +7837,13 @@ static int decode_frame(AVCodecContext *avctx, s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264; s->current_picture_ptr->pict_type= s->pict_type; - h->prev_frame_num_offset= h->frame_num_offset; - h->prev_frame_num= h->frame_num; if(!s->dropable) { + execute_ref_pic_marking(h, h->mmco, h->mmco_index); h->prev_poc_msb= h->poc_msb; h->prev_poc_lsb= h->poc_lsb; - execute_ref_pic_marking(h, h->mmco, h->mmco_index); } + h->prev_frame_num_offset= h->frame_num_offset; + h->prev_frame_num= h->frame_num; /* * FIXME: Error handling code does not seem to support interlaced @@ -7887,7 +7903,7 @@ static int decode_frame(AVCodecContext *avctx, out = h->delayed_pic[0]; out_idx = 0; - for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame; i++) + for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame && h->delayed_pic[i]->poc; i++) if(h->delayed_pic[i]->poc < out->poc){ out = h->delayed_pic[i]; out_idx = i; |