h264: Workaround invalid MPEG-TS broadcasts
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 20 Aug 2012 03:36:52 +0000 (05:36 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 20 Aug 2012 03:47:42 +0000 (05:47 +0200)
Fixes seeking to the first keyframe
Fixes Ticket1029

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/h264.c
libavcodec/h264.h

index 42de033..5d9758b 100644 (file)
@@ -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 |=
index 23dcccf..4d07a8a 100644 (file)
@@ -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