diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-08-20 07:36:52 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-08-20 07:47:42 +0400 |
commit | 76c3fff2f37c5d8ad0e2fb0b403ec2625a198694 (patch) | |
tree | 790262520801f9e6c5ccd9cdb03e044de2e7230b /libavcodec | |
parent | 9e5f79ed8a978450744caceaeec06ef37669d59d (diff) |
h264: Workaround invalid MPEG-TS broadcasts
Fixes seeking to the first keyframe
Fixes Ticket1029
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/h264.c | 6 | ||||
-rw-r--r-- | libavcodec/h264.h | 5 |
2 files changed, 11 insertions, 0 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 42de03333f..5d9758b236 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3867,11 +3867,17 @@ again: if ((err = decode_slice_header(hx, h))) break; + if (h->sei_recovery_frame_cnt >= 0 && (h->frame_num != h->sei_recovery_frame_cnt || hx->slice_type_nos != AV_PICTURE_TYPE_I)) + h->valid_recovery_point++; + if ( h->sei_recovery_frame_cnt >= 0 && ( h->recovery_frame<0 || ((h->recovery_frame - h->frame_num) & ((1 << h->sps.log2_max_frame_num)-1)) > h->sei_recovery_frame_cnt)) { h->recovery_frame = (h->frame_num + h->sei_recovery_frame_cnt) % (1 << h->sps.log2_max_frame_num); + + if (!h->valid_recovery_point) + h->recovery_frame = h->frame_num; } s->current_picture_ptr->f.key_frame |= diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 23dcccf50f..4d07a8ac4d 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -580,6 +580,11 @@ typedef struct H264Context { */ int recovery_frame; + /** + * Are the SEI recovery points looking valid. + */ + int valid_recovery_point; + int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag |