[MPlayer-dev-eng] [RFC] h264 ES parser problems

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Sep 16 18:50:06 CEST 2005


On Fri, Sep 16, 2005 at 06:44:27PM +0200, Reimar Döffinger wrote:
> Ok, a version with ideas taken from the parser in h264.c. I think it
> is not really correct but seems to work.
> When you comment out either the new breaks on top or on bottom it will
> still work.
> There is one weird thing though. From reading the specs I had concluded
> that if there is a NAL nr.9 it should be delievered before the frame
> data (this would happen if you moved these conditions up). But in this
> case MPlayer seems to just hang...

Oh, a new variant of the no-patch-syndrome: the zero-size-patch
syndrome...
-------------- next part --------------
Index: libmpdemux/video.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/video.c,v
retrieving revision 1.53
diff -u -r1.53 video.c
--- libmpdemux/video.c	26 Aug 2005 22:53:59 -0000	1.53
+++ libmpdemux/video.c	16 Sep 2005 16:48:20 -0000
@@ -517,10 +517,17 @@
             ((demuxer->file_format==DEMUXER_TYPE_MPEG_PS) && (sh_video->format==0x10000005))
   ){
       //
+        int first_start_found = 0;
         while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){
           int i=sync_video_packet(d_video);
           int pos = videobuf_len+4;
           if(!i) return -1;
+          if((i & ~0x60) == 0x101 || (i & ~0x60) == 0x102 ||
+             (i & ~0x60) == 0x105) { // VCL NAL with slice header
+            if (first_start_found && (demux_peekc(d_video) & 0x80))
+              break;
+            first_start_found = 1; // found start of "current" frame
+          }
           if(!read_video_packet(d_video)) return -1; // EOF
           if((i&~0x60) == 0x107 && i != 0x107) {
             h264_parse_sps(&picture, &(videobuffer[pos]), videobuf_len - pos);
@@ -532,7 +539,8 @@
             if(!i) return -1;
             if(!read_video_packet(d_video)) return -1; // EOF
           }
-          if((i&~0x60) == 0x101 || (i&~0x60) == 0x102 || (i&~0x60) == 0x105) break;
+          if((i & ~0x60) >= 0x106 && (i & ~0x60) <= 0x109) break;
+          if((i & ~0x60) >= 0x10e && (i & ~0x60) <= 0x112) break;
         }
 	*start=videobuffer; in_size=videobuf_len;
 	videobuf_len=0;
Index: libmpdemux/demuxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
retrieving revision 1.83
diff -u -r1.83 demuxer.h
--- libmpdemux/demuxer.h	3 Sep 2005 08:58:34 -0000	1.83
+++ libmpdemux/demuxer.h	16 Sep 2005 16:48:22 -0000
@@ -257,6 +257,9 @@
 int demux_read_data(demux_stream_t *ds,unsigned char* mem,int len);
 int demux_read_data_pack(demux_stream_t *ds,unsigned char* mem,int len);
 
+#define demux_peekc(ds) (\
+     (likely(ds->buffer_pos<ds->buffer_size)) ? ds->buffer[ds->buffer_pos] \
+     :((unlikely(!ds_fill_buffer(ds)))? (-1) : ds->buffer[ds->buffer_pos] ) )
 #if 1
 #define demux_getc(ds) (\
      (likely(ds->buffer_pos<ds->buffer_size)) ? ds->buffer[ds->buffer_pos++] \


More information about the MPlayer-dev-eng mailing list