[MPlayer-cvslog] CVS: main/libmpdemux muxer_avi.c, 1.34, 1.35 muxer_lavf.c, 1.21, 1.22 muxer_mpeg.c, 1.30, 1.31 muxer_rawaudio.c, 1.3, 1.4 muxer_rawvideo.c, 1.6, 1.7 muxer.c, 1.13, 1.14 muxer.h, 1.17, 1.18

Michael Niedermayer CVS syncmail at mplayerhq.hu
Thu Jan 26 20:32:10 CET 2006


CVS change done by Michael Niedermayer CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv10013/libmpdemux

Modified Files:
	muxer_avi.c muxer_lavf.c muxer_mpeg.c muxer_rawaudio.c 
	muxer_rawvideo.c muxer.c muxer.h 
Log Message:
change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer


Index: muxer_avi.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer_avi.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- muxer_avi.c	12 Jan 2006 20:04:34 -0000	1.34
+++ muxer_avi.c	26 Jan 2006 19:32:07 -0000	1.35
@@ -191,7 +191,7 @@
 
 static void avifile_write_header(muxer_t *muxer);
 
-static void avifile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags){
+static void avifile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags, double dts, double pts){
     off_t rifflen;
     muxer_t *muxer=s->muxer;
     struct avi_stream_info *si = s->priv;

Index: muxer_lavf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer_lavf.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- muxer_lavf.c	25 Jan 2006 20:55:47 -0000	1.21
+++ muxer_lavf.c	26 Jan 2006 19:32:07 -0000	1.22
@@ -248,7 +248,7 @@
 	}
 }
 
-static void write_chunk(muxer_stream_t *stream, size_t len, unsigned int flags)
+static void write_chunk(muxer_stream_t *stream, size_t len, unsigned int flags, double dts, double pts)
 {
 	muxer_t *muxer = (muxer_t*) stream->muxer;
 	muxer_priv_t *priv = (muxer_priv_t *) muxer->priv;

Index: muxer_mpeg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer_mpeg.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- muxer_mpeg.c	12 Jan 2006 20:04:34 -0000	1.30
+++ muxer_mpeg.c	26 Jan 2006 19:32:07 -0000	1.31
@@ -2349,7 +2349,7 @@
 
 
 
-static void mpegfile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags){
+static void mpegfile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags, double dts_arg, double pts_arg){
   size_t ptr=0, sz = 0;
   uint64_t pts, tmp;
   muxer_t *muxer = s->muxer;

Index: muxer_rawaudio.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer_rawaudio.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- muxer_rawaudio.c	21 Nov 2005 22:53:14 -0000	1.3
+++ muxer_rawaudio.c	26 Jan 2006 19:32:07 -0000	1.4
@@ -45,7 +45,7 @@
     return s;
 }
 
-static void rawaudiofile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags){
+static void rawaudiofile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags, double dts, double pts){
     muxer_t *muxer=s->muxer;
 
     // write out the chunk:

Index: muxer_rawvideo.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer_rawvideo.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- muxer_rawvideo.c	21 Nov 2005 22:53:14 -0000	1.6
+++ muxer_rawvideo.c	26 Jan 2006 19:32:07 -0000	1.7
@@ -50,7 +50,7 @@
     }
 }
 
-static void rawvideofile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags){
+static void rawvideofile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags, double dts, double pts){
     muxer_t *muxer=s->muxer;
 
     // write out the chunk:

Index: muxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- muxer.c	9 Jan 2006 19:35:44 -0000	1.13
+++ muxer.c	26 Jan 2006 19:32:07 -0000	1.14
@@ -52,9 +52,12 @@
 /* buffer frames until we either:
  * (a) have at least one frame from each stream
  * (b) run out of memory */
-void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags) {
+void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags, double dts, double pts) {
+    if(dts == MP_NOPTS_VALUE) dts= s->timer;
+    if(pts == MP_NOPTS_VALUE) pts= s->timer; // this is wrong
+
     if (s->muxer->muxbuf_skip_buffer) {
-      s->muxer->cont_write_chunk(s, len, flags);
+      s->muxer->cont_write_chunk(s, len, flags, dts, pts);
     }
     else {
       int num = s->muxer->muxbuf_num++;
@@ -70,7 +73,8 @@
       
       /* buffer this frame */
       buf->stream = s;
-      buf->timer = s->timer;
+      buf->dts= dts;
+      buf->pts= pts;
       buf->len = len;
       buf->flags = flags;
       buf->buffer = malloc(len * sizeof (unsigned char));
@@ -89,11 +93,6 @@
       
       /* see if we can flush buffer now */
       if (s->muxer->muxbuf_skip_buffer) {
-        muxbuf_t *tmp_buf = malloc(sizeof(muxbuf_t));
-        if (!tmp_buf) {
-          mp_msg(MSGT_MUXER, MSGL_FATAL, MSGTR_MuxbufMallocErr);
-          return;
-        }
         mp_msg(MSGT_MUXER, MSGL_V, MSGTR_MuxbufSending, s->muxer->muxbuf_num);
         
         /* fix parameters for all streams */
@@ -109,23 +108,23 @@
         
         /* send all buffered frames to muxer */
         for (num = 0; num < s->muxer->muxbuf_num; ++num) {
+          muxbuf_t tmp_buf;
           buf = s->muxer->muxbuf + num;
           s = buf->stream;
           
           /* 1. save timer and buffer (might have changed by now) */
-          tmp_buf->timer = s->timer;
-          tmp_buf->buffer = s->buffer;
+          tmp_buf.dts = s->timer;
+          tmp_buf.buffer = s->buffer;
           
           /* 2. move stored timer and buffer into stream and mux it */
-          s->timer = buf->timer;
+          s->timer = buf->dts;
           s->buffer = buf->buffer;
-          s->muxer->cont_write_chunk(s, buf->len, buf->flags);
+          s->muxer->cont_write_chunk(s, buf->len, buf->flags, buf->dts, buf->pts);
           
           /* 3. restore saved timer and buffer */
-          s->timer = tmp_buf->timer;
-          s->buffer = tmp_buf->buffer;
+          s->timer = tmp_buf.dts;
+          s->buffer = tmp_buf.buffer;
         }
-        free(tmp_buf);
         
         free(s->muxer->muxbuf);
         s->muxer->muxbuf_num = 0;

Index: muxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- muxer.h	25 Jan 2006 01:17:57 -0000	1.17
+++ muxer.h	26 Jan 2006 19:32:07 -0000	1.18
@@ -76,7 +76,7 @@
   int muxbuf_skip_buffer;
   // functions:
   void (*fix_stream_parameters)(muxer_stream_t *);
-  void (*cont_write_chunk)(muxer_stream_t *,size_t,unsigned int);
+  void (*cont_write_chunk)(muxer_stream_t *,size_t,unsigned int, double dts, double pts);
   void (*cont_write_header)(struct muxer_t *);
   void (*cont_write_index)(struct muxer_t *);
   muxer_stream_t* (*cont_new_stream)(struct muxer_t *,int);
@@ -87,17 +87,19 @@
 /* muxer frame buffer */
 typedef struct muxbuf_t {
   muxer_stream_t *stream; /* pointer back to corresponding stream */
-  double timer; /* snapshot of stream timer */
+  double dts; /* decode timestamp / time at which this packet should be feeded into the decoder */
+  double pts; /* presentation timestamp / time at which the data in this packet will be presented to the user */
   unsigned char *buffer;
   size_t len;
   unsigned int flags;
 } muxbuf_t;
 
+#define MP_NOPTS_VALUE (-1LL<<63) //both int64_t and double should be able to represent this exactly
 
 muxer_t *muxer_new_muxer(int type,FILE *);
 #define muxer_new_stream(muxer,a) muxer->cont_new_stream(muxer,a)
 #define muxer_stream_fix_parameters(muxer, a) muxer->fix_stream_parameters(a)
-void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags);
+void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags, double dts, double pts);
 #define muxer_write_header(muxer) muxer->cont_write_header(muxer)
 #define muxer_write_index(muxer) muxer->cont_write_index(muxer)
 




More information about the MPlayer-cvslog mailing list