[MPlayer-cvslog] r26069 - in trunk/libmpdemux: demuxer.c demuxer.h

nicodvb subversion at mplayerhq.hu
Sat Feb 23 11:31:44 CET 2008


Author: nicodvb
Date: Sat Feb 23 11:31:44 2008
New Revision: 26069

Log:
New member in demuxer_t: reference_clock.
If it's != MP_NOPTS_VALUE ds_fill_buffer() will keep
on demuxing until the pts of the next_pts is <= reference_clock.
It guarantees the compliance with the buffering model indicated
by the transmitter of the multiplex and a long-time stability
of playback (at least for me).
In any case up to a maximum of 64 packets are accumulated to prevent
memory hogging and leaks.


Modified:
   trunk/libmpdemux/demuxer.c
   trunk/libmpdemux/demuxer.h

Modified: trunk/libmpdemux/demuxer.c
==============================================================================
--- trunk/libmpdemux/demuxer.c	(original)
+++ trunk/libmpdemux/demuxer.c	Sat Feb 23 11:31:44 2008
@@ -206,6 +206,7 @@ demuxer_t* new_demuxer(stream_t *stream,
   memset(d,0,sizeof(demuxer_t));
   d->stream=stream;
   d->stream_pts = MP_NOPTS_VALUE;
+  d->reference_clock = MP_NOPTS_VALUE;
   d->movi_start=stream->start_pos;
   d->movi_end=stream->end_pos;
   d->seekable=1;
@@ -405,6 +406,7 @@ int demux_fill_buffer(demuxer_t *demux,d
 // return value:
 //     0 = EOF
 //     1 = successful
+#define MAX_ACUMULATED_PACKETS 64
 int ds_fill_buffer(demux_stream_t *ds){
   demuxer_t *demux=ds->demuxer;
   if(ds->current) free_demux_packet(ds->current);
@@ -418,6 +420,13 @@ int ds_fill_buffer(demux_stream_t *ds){
   while(1){
     if(ds->packs){
       demux_packet_t *p=ds->first;
+      if(demux->reference_clock != MP_NOPTS_VALUE) {
+        if((p->pts != MP_NOPTS_VALUE) && (p->pts > demux->reference_clock)
+            && (ds->packs < MAX_ACUMULATED_PACKETS)) {
+            if(demux_fill_buffer(demux,ds))
+              continue;
+        }
+      }
       // copy useful data:
       ds->buffer=p->buffer;
       ds->buffer_pos=0;

Modified: trunk/libmpdemux/demuxer.h
==============================================================================
--- trunk/libmpdemux/demuxer.h	(original)
+++ trunk/libmpdemux/demuxer.h	Sat Feb 23 11:31:44 2008
@@ -194,6 +194,7 @@ typedef struct demuxer_st {
   off_t movi_end;
   stream_t *stream;
   double stream_pts;       // current stream pts, if applicable (e.g. dvd)
+  double reference_clock;
   char *filename; ///< Needed by avs_check_file
   int synced;  // stream synced (used by mpeg)
   int type;    // demuxer type: mpeg PS, mpeg ES, avi, avi-ni, avi-nini, asf



More information about the MPlayer-cvslog mailing list