[Mplayer-cvslog] CVS: main/libmpcodecs ve_lavc.c,1.77,1.78

Michael Niedermayer CVS michael at mplayerhq.hu
Tue Oct 7 13:45:41 CEST 2003


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

Modified Files:
	ve_lavc.c 
Log Message:
use lagrange multipler instead of qscale 


Index: ve_lavc.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ve_lavc.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- ve_lavc.c	4 Oct 2003 17:28:59 -0000	1.77
+++ ve_lavc.c	7 Oct 2003 11:45:09 -0000	1.78
@@ -58,11 +58,13 @@
 static int lavc_param_mb_decision = 0; /* default is realtime encoding */
 static int lavc_param_v4mv = 0;
 static int lavc_param_vme = 4;
-static int lavc_param_vqscale = 0;
+static float lavc_param_vqscale = 0.0;
 static int lavc_param_vqmin = 2;
 static int lavc_param_vqmax = 31;
 static int lavc_param_mb_qmin = 2;
 static int lavc_param_mb_qmax = 31;
+static float lavc_param_lmin = 2;
+static float lavc_param_lmax = 31;
 static int lavc_param_vqdiff = 3;
 static float lavc_param_vqcompress = 0.5;
 static float lavc_param_vqblur = 0.5;
@@ -143,11 +145,13 @@
 	{"mbd", &lavc_param_mb_decision, CONF_TYPE_INT, CONF_RANGE, 0, 9, NULL},
 	{"v4mv", &lavc_param_v4mv, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"vme", &lavc_param_vme, CONF_TYPE_INT, CONF_RANGE, 0, 5, NULL},
-	{"vqscale", &lavc_param_vqscale, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
+	{"vqscale", &lavc_param_vqscale, CONF_TYPE_FLOAT, CONF_RANGE, 0.01, 255.0, NULL},
 	{"vqmin", &lavc_param_vqmin, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
 	{"vqmax", &lavc_param_vqmax, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
 	{"mbqmin", &lavc_param_mb_qmin, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
 	{"mbqmax", &lavc_param_mb_qmax, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
+	{"lmin", &lavc_param_lmin, CONF_TYPE_FLOAT, CONF_RANGE, 0.01, 255.0, NULL},
+	{"lmax", &lavc_param_lmax, CONF_TYPE_FLOAT, CONF_RANGE, 0.01, 255.0, NULL},
 	{"vqdiff", &lavc_param_vqdiff, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
 	{"vqcomp", &lavc_param_vqcompress, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 1.0, NULL},
 	{"vqblur", &lavc_param_vqblur, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 1.0, NULL},
@@ -248,6 +252,10 @@
 #define mux_v (vf->priv->mux)
 #define lavc_venc_context (vf->priv->context)
 
+#if LIBAVCODEC_BUILD < 4684
+#define FF_QP2LAMBDA 1
+#endif
+
 static int config(struct vf_instance_s* vf,
         int width, int height, int d_width, int d_height,
 	unsigned int flags, unsigned int outfmt){
@@ -283,6 +291,10 @@
     lavc_venc_context->mb_qmin= lavc_param_mb_qmin;
     lavc_venc_context->mb_qmax= lavc_param_mb_qmax;
 #endif
+#if LIBAVCODEC_BUILD >= 4684
+    lavc_venc_context->lmin= (int)(FF_QP2LAMBDA * lavc_param_lmin + 0.5);
+    lavc_venc_context->lmax= (int)(FF_QP2LAMBDA * lavc_param_lmax + 0.5);
+#endif
     lavc_venc_context->max_qdiff= lavc_param_vqdiff;
     lavc_venc_context->qcompress= lavc_param_vqcompress;
     lavc_venc_context->qblur= lavc_param_vqblur;
@@ -547,12 +559,12 @@
     /* fixed qscale :p */
     if (lavc_param_vqscale)
     {
-	printf("Using constant qscale = %d (VBR)\n", lavc_param_vqscale);
+	printf("Using constant qscale = %f (VBR)\n", lavc_param_vqscale);
 	lavc_venc_context->flags |= CODEC_FLAG_QSCALE;
 #if LIBAVCODEC_BUILD >= 4668
-        lavc_venc_context->global_quality= FF_QUALITY_SCALE * lavc_param_vqscale;
+        lavc_venc_context->global_quality= 
 #endif
-	vf->priv->pic->quality = lavc_param_vqscale;
+	vf->priv->pic->quality = (int)(FF_QP2LAMBDA * lavc_param_vqscale + 0.5);
     }
 
     if (avcodec_open(lavc_venc_context, vf->priv->codec) != 0) {
@@ -679,7 +691,7 @@
 	    }
 	    quality /= w * h;
 	} else 
-	    quality = lavc_venc_context->coded_frame->quality;
+	    quality = lavc_venc_context->coded_frame->quality / (float)FF_QP2LAMBDA;
 
         fprintf(fvstats, "%6d, %2.2f, %6d, %2.2f, %2.2f, %2.2f, %2.2f %c\n",
             lavc_venc_context->coded_frame->coded_picture_number,



More information about the MPlayer-cvslog mailing list