Reimar Döffinger <[email protected]> added the comment:

On Fri, Oct 29, 2010 at 07:32:37PM +0000, Reimar Döffinger wrote:
> As a quick hack, below patch "fixes" most error messages when
> treating it like a "normal" H.264 stream.

Updated hack that avoids all warnings, proving that this is a
the correct way to parse this file.
Index: libavcodec/h264_parser.c
===================================================================
--- libavcodec/h264_parser.c    (revision 25603)
+++ libavcodec/h264_parser.c    (working copy)
@@ -69,7 +69,7 @@
             else if(buf[i]) state = 7;
             else            state>>=1; //2->1, 1->0, 0->0
         }else if(state<=5){
-            int v= buf[i] & 0x1F;
+            int v= buf[i] & 0x9F;
             if(v==6 || v==7 || v==8 || v==9){
                 if(pc->frame_start_found){
                     i++;
@@ -150,6 +150,7 @@
             break;

         init_get_bits(&h->s.gb, ptr, 8*dst_length);
+        if (!(h->nal_ref_idc & 4))
         switch(h->nal_unit_type) {
         case NAL_SPS:
             ff_h264_decode_seq_parameter_set(h);
Index: libavcodec/h264.c
===================================================================
--- libavcodec/h264.c   (revision 25603)
+++ libavcodec/h264.c   (working copy)
@@ -2837,6 +2837,8 @@
         if(  (s->hurry_up == 1 && h->nal_ref_idc  == 0) //FIXME do not discard 
SEI id
            ||(avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc  == 0))
             continue;
+        if (hx->nal_ref_idc & 4) // invalid
+            continue;

       again:
         err = 0;

________________________________________________
FFmpeg issue tracker <[email protected]>
<https://roundup.ffmpeg.org/issue2333>
________________________________________________

Reply via email to