[Mplayer-cvslog] CVS: main mencoder.c,1.102,1.103

Arpi of Ize arpi at mplayer.dev.hu
Fri Mar 29 00:45:36 CET 2002


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

Modified Files:
	mencoder.c 
Log Message:
2-pass encoding with libavcodec - untested

Index: mencoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/mencoder.c,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -r1.102 -r1.103
--- mencoder.c	28 Mar 2002 05:01:09 -0000	1.102
+++ mencoder.c	28 Mar 2002 23:45:33 -0000	1.103
@@ -1217,6 +1217,31 @@
 	lavc_venc_context.quality = lavc_param_vqscale;
     }
 
+    switch(pass){
+    case 1:
+	if (VbrControl_init_2pass_vbr_analysis(passtmpfile, lavc_param_vme) == -1)
+	{
+	    printf("2pass failed: filename=%s\n", passtmpfile);
+	    pass_working = 0;
+	}
+	else
+	    pass_working = 1;
+	break;
+    case 2:
+        if (VbrControl_init_2pass_vbr_encoding(passtmpfile,
+		    lavc_venc_context.bit_rate,
+		    lavc_venc_context.frame_rate,
+		    100, /* crispness */
+		    lavc_param_vme) == -1)
+	{
+	    printf("2pass failed: filename=%s\n", passtmpfile);
+	    pass_working = 0;
+	}
+	else
+	    pass_working = 1;
+	break;
+    }
+
     if (avcodec_open(&lavc_venc_context, lavc_venc_codec) != 0)
     {
 	printf(MSGTR_CantOpenCodec);
@@ -1654,8 +1679,34 @@
 	    break;
 	}
 
+    if(pass==2 && pass_working){	// handle 2-pass:
+	lavc_venc_context.flags|=CODEC_FLAG_QSCALE; // enable VBR
+	lavc_venc_context.quality=VbrControl_get_quant();
+#ifdef CODEC_FLAG_TYPE
+	lavc_venc_context.flags|=CODEC_FLAG_TYPE; // force keyframes
+	lavc_venc_context.key_frame=VbrControl_get_intra();
+	lavc_venc_context.gop_size=0x3fffffff;
+#else
+#error you should upgrade libavcodec... get latest CVS
+#endif
 	out_size = avcodec_encode_video(&lavc_venc_context, mux_v->buffer, mux_v->buffer_size,
 	    &lavc_venc_picture);
+	VbrControl_update_2pass_vbr_encoding(lavc_venc_context.mv_bits,
+	      lavc_venc_context.i_tex_bits+lavc_venc_context.p_tex_bits,
+	      8*out_size);
+    } else {
+	out_size = avcodec_encode_video(&lavc_venc_context, mux_v->buffer, mux_v->buffer_size,
+	    &lavc_venc_picture);
+
+	if(pass==1 && pass_working){
+	  VbrControl_update_2pass_vbr_analysis(lavc_venc_context.key_frame,
+	      lavc_venc_context.mv_bits,
+	      lavc_venc_context.i_tex_bits+lavc_venc_context.p_tex_bits,
+	      8*out_size, lavc_venc_context.quality);
+	}
+	
+    }
+
 	aviwrite_write_chunk(muxer,mux_v,muxer_f,out_size,lavc_venc_context.key_frame?0x10:0);
 #endif
     }




More information about the MPlayer-cvslog mailing list