[Mplayer-cvslog] CVS: main cfg-mencoder.h,1.59,1.60 mencoder.c,1.193,1.194

Arpi of Ize arpi at mplayerhq.hu
Fri Dec 27 23:43:49 CET 2002


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

Modified Files:
	cfg-mencoder.h mencoder.c 
Log Message:
the long-waited MUXER layer, and new MPEG-PS muxer
patch by Andriy N. Gritsenko <andrej at lucky.net>


Index: cfg-mencoder.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mencoder.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- cfg-mencoder.h	26 Dec 2002 12:48:18 -0000	1.59
+++ cfg-mencoder.h	27 Dec 2002 22:43:15 -0000	1.60
@@ -129,6 +129,16 @@
 	{NULL, NULL, 0, 0, 0, 0, NULL}
 };
 
+struct config of_conf[]={
+	{"avi", &out_file_format, CONF_TYPE_FLAG, 0, 0, MUXER_TYPE_AVI, NULL},
+	{"mpeg", &out_file_format, CONF_TYPE_FLAG, 0, 0, MUXER_TYPE_MPEG, NULL},
+	{"help", "\nAvailable output formats:\n"
+	"   avi      - Microsoft Audio/Video Interleaved\n"
+	"   mpeg     - MPEG-1 system stream format\n"
+	"\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
+	{NULL, NULL, 0, 0, 0, 0, NULL}
+};
+
 static config_t mencoder_opts[]={
 	/* name, pointer, type, flags, min, max */
 	{"include", cfg_include, CONF_TYPE_FUNC_PARAM, CONF_NOSAVE, 0, 0, NULL}, /* this must be the first!!! */
@@ -155,6 +165,9 @@
 	// output audio/video codec selection
 	{"oac", oac_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
 	{"ovc", ovc_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+
+	// output file format
+	{"of", of_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
 
 	// override FOURCC in output file
 	{"ffourcc", &force_fourcc, CONF_TYPE_STRING, 0, 4, 4, NULL},

Index: mencoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/mencoder.c,v
retrieving revision 1.193
retrieving revision 1.194
diff -u -r1.193 -r1.194
--- mencoder.c	21 Dec 2002 22:16:48 -0000	1.193
+++ mencoder.c	27 Dec 2002 22:43:15 -0000	1.194
@@ -47,7 +47,7 @@
 #include "libmpdemux/demuxer.h"
 #include "libmpdemux/stheader.h"
 #include "libmpdemux/mp3_hdr.h"
-#include "libmpdemux/aviwrite.h"
+#include "libmpdemux/muxer.h"
 
 
 #include "libvo/video_out.h"
@@ -108,6 +108,8 @@
 static int out_audio_codec=-1;
 static int out_video_codec=-1;
 
+int out_file_format=MUXER_TYPE_AVI;	// default to AVI
+
 // audio stream skip/resync functions requires only for seeking.
 // (they should be implemented in the audio codec layer)
 //void skip_audio_frame(sh_audio_t *sh_audio){}
@@ -301,12 +303,12 @@
     interrupted=1;
 }
 
-static aviwrite_t* muxer=NULL;
+static muxer_t* muxer=NULL;
 static FILE* muxer_f=NULL;
 
 // callback for ve_*.c:
-void mencoder_write_chunk(aviwrite_stream_t *s,int len,unsigned int flags){
-    aviwrite_write_chunk(muxer,s,muxer_f,len,flags);
+void mencoder_write_chunk(muxer_stream_t *s,int len,unsigned int flags){
+    muxer_write_chunk(muxer,s,muxer_f,len,flags);
 }
 
 extern void print_wave_header(WAVEFORMATEX *h);
@@ -335,8 +337,8 @@
 uint32_t duplicatedframes=0;
 uint32_t badframes=0;
 
-aviwrite_stream_t* mux_a=NULL;
-aviwrite_stream_t* mux_v=NULL;
+muxer_stream_t* mux_a=NULL;
+muxer_stream_t* mux_v=NULL;
 off_t muxer_f_size=0;
 
 #ifdef HAVE_MP3LAME
@@ -600,11 +602,11 @@
   mencoder_exit(1,NULL);
 }
 
-muxer=aviwrite_new_muxer();
+muxer=muxer_new_muxer(out_file_format);
 
 // ============= VIDEO ===============
 
-mux_v=aviwrite_new_stream(muxer,AVIWRITE_TYPE_VIDEO);
+mux_v=muxer_new_stream(muxer,MUXER_TYPE_VIDEO);
 
 mux_v->buffer_size=0x200000; // 2MB
 mux_v->buffer=malloc(mux_v->buffer_size);
@@ -698,7 +700,7 @@
 // ============= AUDIO ===============
 if(sh_audio){
 
-mux_a=aviwrite_new_stream(muxer,AVIWRITE_TYPE_AUDIO);
+mux_a=muxer_new_stream(muxer,MUXER_TYPE_AUDIO);
 
 mux_a->buffer_size=0x100000; //16384;
 mux_a->buffer=malloc(mux_a->buffer_size);
@@ -809,7 +811,7 @@
 } // if(sh_audio)
 
 printf(MSGTR_WritingAVIHeader);
-aviwrite_write_header(muxer,muxer_f);
+muxer_write_header(muxer,muxer_f);
 
 decoded_frameno=0;
 
@@ -877,6 +879,18 @@
 //    if(demuxer2) demux_seek(demuxer2, d, 1);
 }
 
+if (out_file_format == MUXER_TYPE_MPEG)
+	{
+	if (audio_preload > 0.4) {
+	  fprintf(stderr,"Limiting audio preload to 0.4s\n");
+	  audio_preload = 0.4;
+	}
+	if (audio_density < 4) {
+	  fprintf(stderr,"Increasing audio density to 4\n");
+	  audio_preload = 4;
+	}
+	}
+
 if(tv_param_on == 1) 
 	{
 	fprintf(stderr,"Forcing audio preload to 0, max pts correction to 0\n");
@@ -983,7 +997,7 @@
 	    }
 	}
 	if(len<=0) break; // EOF?
-	aviwrite_write_chunk(muxer,mux_a,muxer_f,len,0x10);
+	muxer_write_chunk(muxer,mux_a,muxer_f,len,0x10);
 	if(!mux_a->h.dwSampleSize && mux_a->timer>0)
 	    mux_a->wf->nAvgBytesPerSec=0.5f+(double)mux_a->size/mux_a->timer; // avg bps (VBR)
 	if(mux_a->buffer_len>=len){
@@ -1063,11 +1077,11 @@
 switch(mux_v->codec){
 case VCODEC_COPY:
     mux_v->buffer=start;
-    if(skip_flag<=0) aviwrite_write_chunk(muxer,mux_v,muxer_f,in_size,(sh_video->ds->flags&1)?0x10:0);
+    if(skip_flag<=0) muxer_write_chunk(muxer,mux_v,muxer_f,in_size,(sh_video->ds->flags&1)?0x10:0);
     break;
 case VCODEC_FRAMENO:
     mux_v->buffer=(unsigned char *)&decoded_frameno; // tricky
-    if(skip_flag<=0) aviwrite_write_chunk(muxer,mux_v,muxer_f,sizeof(int),0x10);
+    if(skip_flag<=0) muxer_write_chunk(muxer,mux_v,muxer_f,sizeof(int),0x10);
     break;
 default:
     // decode_video will callback down to ve_*.c encoders, through the video filters
@@ -1078,7 +1092,7 @@
 	// unwanted skipping of a frame, what to do?
 	if(skip_limit==0){
 	    // skipping not allowed -> write empty frame:
-	    aviwrite_write_chunk(muxer,mux_v,muxer_f,0,0);
+	    muxer_write_chunk(muxer,mux_v,muxer_f,0,0);
 	} else {
 	    // skipping allowed -> skip it and distriubute timer error:
 	    v_timer_corr-=(float)mux_v->h.dwScale/mux_v->h.dwRate;
@@ -1095,7 +1109,7 @@
 	if(!tv_param_on && !verbose) printf(MSGTR_DuplicateFrames,-skip_flag);
     while(skip_flag<0){
 	duplicatedframes++;
-	aviwrite_write_chunk(muxer,mux_v,muxer_f,0,0);
+	muxer_write_chunk(muxer,mux_v,muxer_f,0,0);
 	++skip_flag;
     }
 } else
@@ -1254,11 +1268,11 @@
 #endif
 
 printf(MSGTR_WritingAVIIndex);
-aviwrite_write_index(muxer,muxer_f);
+muxer_write_index(muxer,muxer_f);
 muxer_f_size=ftello(muxer_f);
 printf(MSGTR_FixupAVIHeader);
 fseek(muxer_f,0,SEEK_SET);
-aviwrite_write_header(muxer,muxer_f); // update header
+muxer_write_header(muxer,muxer_f); // update header
 if(ferror(muxer_f) || fclose(muxer_f) != 0) {
     mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile, out_filename);
     mencoder_exit(1, NULL);




More information about the MPlayer-cvslog mailing list