[Mplayer-cvslog] CVS: main/libmpdemux muxer.c,1.2,1.3 muxer.h,1.6,1.7 muxer_avi.c,1.14,1.15 muxer_mpeg.c,1.1,1.2

Arpi of Ize arpi at mplayerhq.hu
Sun Jan 19 01:33:15 CET 2003


Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv28738

Modified Files:
	muxer.c muxer.h muxer_avi.c muxer_mpeg.c 
Log Message:
Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
patch by Andriy N. Gritsenko <andrej at lucky.net>


Index: muxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- muxer.c	28 Dec 2002 00:48:07 -0000	1.2
+++ muxer.c	19 Jan 2003 00:33:11 -0000	1.3
@@ -14,9 +14,10 @@
 
 #include "muxer.h"
 
-muxer_t* muxer_new_muxer(int type){
+muxer_t *muxer_new_muxer(int type,FILE *f){
     muxer_t* muxer=malloc(sizeof(muxer_t));
     memset(muxer,0,sizeof(muxer_t));
+    muxer->file = f;
     switch (type) {
       case MUXER_TYPE_MPEG:
 	muxer_init_muxer_mpeg(muxer);

Index: muxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- muxer.h	27 Dec 2002 22:43:20 -0000	1.6
+++ muxer.h	19 Jan 2003 00:33:11 -0000	1.7
@@ -34,6 +34,8 @@
   // mpeg specific:
   unsigned int gop_start; // frame number of this GOP start
   size_t ipb[3]; // sizes of I/P/B frames
+  // muxer of that stream
+  struct muxer_t *muxer;
 } muxer_stream_t;
 
 typedef struct {
@@ -57,17 +59,18 @@
   //int num_streams;
   muxer_stream_t* def_v;  // default video stream (for general headers)
   muxer_stream_t* streams[MUXER_MAX_STREAMS];
-  void (*cont_write_chunk)(struct muxer_t *,muxer_stream_t *,FILE *,size_t,unsigned int);
-  void (*cont_write_header)(struct muxer_t *,FILE *);
-  void (*cont_write_index)(struct muxer_t *,FILE *);
+  void (*cont_write_chunk)(muxer_stream_t *,size_t,unsigned int);
+  void (*cont_write_header)(struct muxer_t *);
+  void (*cont_write_index)(struct muxer_t *);
   muxer_stream_t* (*cont_new_stream)(struct muxer_t *,int);
+  FILE* file;
 } muxer_t;
 
-muxer_t* muxer_new_muxer(int type);
+muxer_t *muxer_new_muxer(int type,FILE *);
 #define muxer_new_stream(muxer,a) muxer->cont_new_stream(muxer,a)
-#define muxer_write_chunk(muxer,a,b,c,d) muxer->cont_write_chunk(muxer,a,b,c,d)
-#define muxer_write_header(muxer,f) muxer->cont_write_header(muxer,f)
-#define muxer_write_index(muxer,f) muxer->cont_write_index(muxer,f)
+#define muxer_write_chunk(a,b,c) a->muxer->cont_write_chunk(a,b,c)
+#define muxer_write_header(muxer) muxer->cont_write_header(muxer)
+#define muxer_write_index(muxer) muxer->cont_write_index(muxer)
 
 void muxer_init_muxer_avi(muxer_t *);
 void muxer_init_muxer_mpeg(muxer_t *);

Index: muxer_avi.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer_avi.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- muxer_avi.c	28 Dec 2002 00:48:07 -0000	1.14
+++ muxer_avi.c	19 Jan 2003 00:33:11 -0000	1.15
@@ -30,6 +30,7 @@
 
 static muxer_stream_t* avifile_new_stream(muxer_t *muxer,int type){
     muxer_stream_t* s;
+    if (!muxer) return NULL;
     if(muxer->avih.dwStreams>=MUXER_MAX_STREAMS){
 	printf("Too many streams! increase MUXER_MAX_STREAMS !\n");
 	return NULL;
@@ -42,6 +43,7 @@
     s->id=muxer->avih.dwStreams;
     s->timer=0.0;
     s->size=0;
+    s->muxer=muxer;
     switch(type){
     case MUXER_TYPE_VIDEO:
       s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'d','c');
@@ -88,7 +90,8 @@
 }
 }
 
-static void avifile_write_chunk(muxer_t *muxer,muxer_stream_t *s, FILE *f,size_t len,unsigned int flags){
+static void avifile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags){
+    muxer_t *muxer=s->muxer;
 
     // add to the index:
     if(muxer->idx_pos>=muxer->idx_size){
@@ -97,12 +100,12 @@
     }
     muxer->idx[muxer->idx_pos].ckid=s->ckid;
     muxer->idx[muxer->idx_pos].dwFlags=flags; // keyframe?
-    muxer->idx[muxer->idx_pos].dwChunkOffset=ftell(f)-(muxer->movi_start-4);
+    muxer->idx[muxer->idx_pos].dwChunkOffset=ftell(muxer->file)-(muxer->movi_start-4);
     muxer->idx[muxer->idx_pos].dwChunkLength=len;
     ++muxer->idx_pos;
 
     // write out the chunk:
-    write_avi_chunk(f,s->ckid,len,s->buffer); /* unsigned char */
+    write_avi_chunk(muxer->file,s->ckid,len,s->buffer); /* unsigned char */
 
     // alter counters:
     if(s->h.dwSampleSize){
@@ -135,11 +138,12 @@
 // muxer->streams[i]->wf->cbSize
 #define WFSIZE(wf) (sizeof(WAVEFORMATEX)+(((wf)->cbSize)?((wf)->cbSize-2):0))
 
-static void avifile_write_header(muxer_t *muxer,FILE *f){
+static void avifile_write_header(muxer_t *muxer){
   uint32_t riff[3];
   unsigned int i;
   unsigned int hdrsize;
   muxer_info_t info[16];
+  FILE *f=muxer->file;
 
   // RIFF header:
   riff[0]=mmioFOURCC('R','I','F','F');
@@ -275,19 +279,19 @@
   muxer->movi_start=ftell(f);
 }
 
-static void avifile_write_index(muxer_t *muxer,FILE *f){
-  muxer->movi_end=ftell(f);
+static void avifile_write_index(muxer_t *muxer){
+  muxer->movi_end=ftell(muxer->file);
   if(muxer->idx && muxer->idx_pos>0){
       int i;
       // fixup index entries:
 //      for(i=0;i<muxer->idx_pos;i++) muxer->idx[i].dwChunkOffset-=muxer->movi_start-4;
       // write index chunk:
       for (i=0; i<muxer->idx_pos; i++) le2me_AVIINDEXENTRY((&muxer->idx[i]));
-      write_avi_chunk(f,ckidAVINEWINDEX,16*muxer->idx_pos,muxer->idx); /* AVIINDEXENTRY */
+      write_avi_chunk(muxer->file,ckidAVINEWINDEX,16*muxer->idx_pos,muxer->idx); /* AVIINDEXENTRY */
       for (i=0; i<muxer->idx_pos; i++) le2me_AVIINDEXENTRY((&muxer->idx[i]));
       muxer->avih.dwFlags|=AVIF_HASINDEX;
   }
-  muxer->file_end=ftell(f);
+  muxer->file_end=ftell(muxer->file);
 }
 
 void muxer_init_muxer_avi(muxer_t *muxer){

Index: muxer_mpeg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer_mpeg.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- muxer_mpeg.c	27 Dec 2002 22:43:20 -0000	1.1
+++ muxer_mpeg.c	19 Jan 2003 00:33:11 -0000	1.2
@@ -32,6 +32,7 @@
 static muxer_stream_t* mpegfile_new_stream(muxer_t *muxer,int type){
   muxer_stream_t *s;
 
+  if (!muxer) return NULL;
   if(muxer->avih.dwStreams>=MUXER_MAX_STREAMS){
     printf("Too many streams! increase MUXER_MAX_STREAMS !\n");
     return NULL;
@@ -75,6 +76,7 @@
   s->id=muxer->avih.dwStreams;
   s->timer=0.0;
   s->size=0;
+  s->muxer=muxer;
   muxer->avih.dwStreams++;
   return s;
 }
@@ -239,10 +241,13 @@
   write_mpeg_ts (s->b_buffer+7, dts, 0x10);
 }
 
-static void mpegfile_write_chunk(muxer_t *muxer,muxer_stream_t *s,FILE *f,size_t len,unsigned int flags){
+static void mpegfile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags){
   size_t ptr=0, sz;
   unsigned int pts=0;
+  muxer_t *muxer = s->muxer;
+  FILE *f;
 
+  f = muxer->file;
   if (s->type == MUXER_TYPE_VIDEO) { // try to recognize frame type...
     if (s->buffer[0] != 0 || s->buffer[1] != 0 || s->buffer[2] != 1 || len<6) {
       printf ("Unknown block type, possibly non-MPEG stream!\n");
@@ -358,13 +363,14 @@
   }
 }
 
-static void mpegfile_write_header(muxer_t *muxer,FILE *f){
+static void mpegfile_write_header(muxer_t *muxer){
   unsigned int i;
   size_t sz = MUXER_MPEG_BLOCKSIZE-24;
   unsigned char buff[12];
   muxer_stream_t *s = muxer->streams[0];
   uint32_t l1;
   uint16_t l2;
+  FILE *f = muxer->file;
 
   if (s == NULL)
     return; // no streams!?
@@ -407,7 +413,7 @@
   muxer->movi_end = MUXER_MPEG_BLOCKSIZE;
 }
 
-static void mpegfile_write_index(muxer_t *muxer,FILE *f){
+static void mpegfile_write_index(muxer_t *muxer){
   unsigned int i;
   unsigned int rsr;
 
@@ -415,9 +421,9 @@
   // finish all but one video and audio streams
   rsr = muxer->sysrate; // reserve it since it's silly change it at that point
   for (i = 0; i < muxer->avih.dwStreams-1; i++)
-    write_mpeg_block (muxer, muxer->streams[i], f, NULL, 0, 0);
+    write_mpeg_block (muxer, muxer->streams[i], muxer->file, NULL, 0, 0);
   // end sequence: ISO-11172-End (0x1b9) and finish very last block
-  write_mpeg_block (muxer, muxer->streams[i], f, NULL, 0, 1);
+  write_mpeg_block (muxer, muxer->streams[i], muxer->file, NULL, 0, 1);
 //fprintf (stderr, "PTS to SCR delay: min %u.%03u, max %u.%03u\n",
 //	mpeg_min_delay/90000, (mpeg_min_delay/90)%1000,
 //	mpeg_max_delay/90000, (mpeg_max_delay/90)%1000);



More information about the MPlayer-cvslog mailing list