[Mplayer-cvslog] CVS: main cfg-common.h,1.1,1.2 cfg-mencoder.h,1.2,1.3 cfg-mplayer.h,1.98,1.99 mencoder.c,1.16,1.17

Arpi of Ize arpi at mplayer.dev.hu
Sat Nov 3 01:44:26 CET 2001


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

Modified Files:
	cfg-common.h cfg-mencoder.h cfg-mplayer.h mencoder.c 
Log Message:
divx4 2-pass support, -frames option

Index: cfg-common.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-common.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cfg-common.h	2 Nov 2001 00:32:35 -0000	1.1
+++ cfg-common.h	3 Nov 2001 00:44:02 -0000	1.2
@@ -53,6 +53,8 @@
 
 // ------------------------- a-v sync options --------------------
 
+	{"frames", &play_n_frames, CONF_TYPE_INT, CONF_MIN, 0, 0},
+
 	{"mc", &default_max_pts_correction, CONF_TYPE_FLOAT, CONF_RANGE, 0, 10},
 	{"fps", &force_fps, CONF_TYPE_FLOAT, CONF_MIN, 0, 0},
 	{"srate", &force_srate, CONF_TYPE_INT, CONF_RANGE, 1000, 8*48000},

Index: cfg-mencoder.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mencoder.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- cfg-mencoder.h	2 Nov 2001 03:22:33 -0000	1.2
+++ cfg-mencoder.h	3 Nov 2001 00:44:02 -0000	1.3
@@ -19,6 +19,7 @@
 	{"key", &divx4_param.max_key_interval, CONF_TYPE_INT, CONF_MIN,0,0},
 	{"deinterlace", &divx4_param.deinterlace, CONF_TYPE_FLAG, 0,0,1},
 	{"q", &divx4_param.quality, CONF_TYPE_INT, CONF_RANGE, 1, 5},
+	{"crispness", &divx4_crispness, CONF_TYPE_INT, CONF_RANGE,0,100},
 	{"help", "TODO: divx4opts help!\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0},
 	{NULL, NULL, 0, 0, 0, 0}
 };
@@ -46,6 +47,8 @@
 
 	{"oac", &out_audio_codec, CONF_TYPE_STRING, 0, 0, 0},
 	{"ovc", &out_video_codec, CONF_TYPE_STRING, 0, 0, 0},
+
+	{"pass", &pass, CONF_TYPE_INT, CONF_RANGE,0,2},
 	
 	{"divx4opts", divx4opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0},
 	{"lameopts", lameopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0},

Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- cfg-mplayer.h	2 Nov 2001 00:32:35 -0000	1.98
+++ cfg-mplayer.h	3 Nov 2001 00:44:02 -0000	1.99
@@ -148,7 +148,6 @@
 
 	{"autoq", &auto_quality, CONF_TYPE_INT, CONF_RANGE, 0, 100},
 
-	{"frames", &play_n_frames, CONF_TYPE_INT, CONF_MIN, 0, 0},
 	{"benchmark", &benchmark, CONF_TYPE_FLAG, 0, 0, 1},
 	
 	{"dumpfile", &stream_dump_name, CONF_TYPE_STRING, 0, 0, 0},

Index: mencoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/mencoder.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- mencoder.c	2 Nov 2001 20:05:36 -0000	1.16
+++ mencoder.c	3 Nov 2001 00:44:02 -0000	1.17
@@ -26,6 +26,7 @@
 #include "dec_video.h"
 
 #include <encore2.h>
+#include "divx4_vbr.h"
 
 #include <lame/lame.h>
 
@@ -77,6 +78,11 @@
 char* mp3_filename=NULL;
 char* ac3_filename=NULL;
 
+static int pass=0;
+static char* passtmpfile="divx2pass.log";
+
+static int play_n_frames=-1;
+
 char *out_audio_codec=NULL; // override audio codec
 char *out_video_codec=NULL; // override video codec
 
@@ -84,6 +90,7 @@
 //#include "libmpeg2/mpeg2_internal.h"
 
 ENC_PARAM divx4_param;
+int divx4_crispness=100;
 
 int lame_param_quality=0; // best
 int lame_param_vbr=vbr_default;
@@ -251,6 +258,14 @@
   }
 }
 
+// set some defaults, before parsing configfile/commandline:
+divx4_param.min_quantizer = 2;
+divx4_param.max_quantizer = 31;
+divx4_param.rc_period = 2000;
+divx4_param.rc_reaction_period = 10;
+divx4_param.rc_reaction_ratio  = 20;
+
+
   num_filenames=parse_command_line(conf, argc, argv, envp, &filenames);
   if(num_filenames<0) exit(1); // error parsing cmdline
   if(!num_filenames && !vcd_track && !dvd_title){
@@ -496,6 +511,30 @@
     divx4_param.handle=NULL;
     encore(NULL,ENC_OPT_INIT,&divx4_param,NULL);
     enc_handle=divx4_param.handle;
+    switch(out_fmt){
+    case IMGFMT_YV12:	enc_frame.colorspace=ENC_CSP_YV12; break;
+    case IMGFMT_IYUV:
+    case IMGFMT_I420:	enc_frame.colorspace=ENC_CSP_I420; break;
+    case IMGFMT_YUY2:	enc_frame.colorspace=ENC_CSP_YUY2; break;
+    case IMGFMT_UYVY:	enc_frame.colorspace=ENC_CSP_UYVY; break;
+    case IMGFMT_RGB24:
+    case IMGFMT_BGR24:
+    	enc_frame.colorspace=ENC_CSP_RGB24; break;
+    default:
+	mp_msg(MSGT_MENCODER,MSGL_ERR,"divx4: unsupported out_fmt!\n");
+    }
+    switch(pass){
+    case 1:
+	VbrControl_init_2pass_vbr_analysis(passtmpfile, divx4_param.quality);
+	break;
+    case 2:
+        VbrControl_init_2pass_vbr_encoding(passtmpfile,
+					 divx4_param.bitrate,
+					 divx4_param.framerate,
+					 divx4_crispness,
+					 divx4_param.quality);
+	break;
+    }
     break;
 }
 
@@ -542,6 +581,11 @@
     int in_size;
     int skip_flag=0; // 1=skip  -1=duplicate
 
+    if(play_n_frames>=0){
+      --play_n_frames;
+      if(play_n_frames<0) break;
+    }
+
 if(sh_audio){
     // get audio:
     while(mux_a->timer-audio_preload<mux_v->timer){
@@ -650,21 +694,28 @@
     enc_frame.image=vo_image_ptr;
     enc_frame.bitstream=mux_v->buffer;
     enc_frame.length=mux_v->buffer_size;
-    switch(out_fmt){
-    case IMGFMT_YV12:	enc_frame.colorspace=ENC_CSP_YV12; break;
-    case IMGFMT_IYUV:
-    case IMGFMT_I420:	enc_frame.colorspace=ENC_CSP_I420; break;
-    case IMGFMT_YUY2:	enc_frame.colorspace=ENC_CSP_YUY2; break;
-    case IMGFMT_UYVY:	enc_frame.colorspace=ENC_CSP_UYVY; break;
-    case IMGFMT_RGB24:
-    case IMGFMT_BGR24:
-    	enc_frame.colorspace=ENC_CSP_RGB24; break;
-    }
+    enc_frame.mvs=NULL;
     enc_frame.quant=0;
     enc_frame.intra=0;
-    enc_frame.mvs=NULL;
+    if(pass==2){	// handle 2-pass:
+	enc_frame.quant = VbrControl_get_quant();
+	enc_frame.intra = VbrControl_get_intra();
+	encore(enc_handle,ENC_OPT_ENCODE_VBR,&enc_frame,&enc_result);
+        VbrControl_update_2pass_vbr_encoding(enc_result.motion_bits,
+					    enc_result.texture_bits,
+					    enc_result.total_bits);
+    } else {
+	encore(enc_handle,ENC_OPT_ENCODE,&enc_frame,&enc_result);
+	if(pass==1){
+	  VbrControl_update_2pass_vbr_analysis(enc_result.is_key_frame, 
+					       enc_result.motion_bits, 
+					       enc_result.texture_bits, 
+					       enc_result.total_bits, 
+					       enc_result.quantizer);
+	}
+    }
+    
 //    printf("encoding...\n");
-    encore(enc_handle,ENC_OPT_ENCODE,&enc_frame,&enc_result);
 //    printf("  len=%d  key:%d  qualt:%d  \n",enc_frame.length,enc_result.is_key_frame,enc_result.quantizer);
     aviwrite_write_chunk(muxer,mux_v,muxer_f,enc_frame.length,enc_result.is_key_frame?0x10:0);
     break;




More information about the MPlayer-cvslog mailing list