[MPlayer-dev-eng] [RFC] h264 ES parser problems
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Sep 16 19:12:13 CEST 2005
Hi,
On Fri, Sep 16, 2005 at 06:44:27PM +0200, Reimar Döffinger wrote:
> 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...
Well, that was stupid... it only returned empty frames in that case...
The attached version ensures progress and puts the nr.9 NALs in front.
I'd expect this to be rather safe, do you think it is okay to apply?
Or have more samples to test?
Greetings,
Reimar Döffinger
-------------- 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 17:04:28 -0000
@@ -517,6 +517,7 @@
((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;
@@ -532,7 +533,16 @@
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) == 0x101 || (i&~0x60) == 0x102 || (i&~0x60) == 0x105)
+ first_start_found = 1; // found start of "current" frame
+ i = sync_video_packet(d_video) & ~0x60; // code of next packet
+ if(i >= 0x106 && i <= 0x109) break;
+ if(i >= 0x10e && i <= 0x112) break;
+ if(i == 0x101 || i == 0x102 || i == 0x105) {
+ // VCL NAL with slice header
+ if (first_start_found && (demux_peekc(d_video) & 0x80))
+ 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 17:04:29 -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