[MPlayer-dev-eng] [PATCH] making xvid options lavc compatible

Dominik 'Rathann' Mierzejewski dominik at rangers.eu.org
Tue Sep 28 03:41:39 CEST 2004


Oops, this should have gone to -dev-eng, instead of -docs.

I wanted to test lavc vs xvid encoding of some anime and used a script to
automate things and use the largest possible common subset of encoding
options. To my annoyance, I discovered that
1. many options have slightly different names, even though they mean
   exactly the same
2. bitrate setting option in ve_xvid4.c doesn't follow the rules described
   in manpage (i.e. if bitrate > 16000, then it's in bits/s, not kbits),
   unlike lavc and the old ve_xvid.c do.

Here's a patch that tries to address these issues.

R.

-- 
MPlayer RPMs maintainer: http://greysector.rangers.eu.org/mplayer/
"I am Grey. I stand between the candle and the star. We are Grey.
 We stand between the darkness ... and the light."
        -- Delenn in Grey Council in Babylon 5:"Babylon Squared"
-------------- next part --------------
Index: DOCS/man/en/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/man/en/mplayer.1,v
retrieving revision 1.754
diff -u -r1.754 mplayer.1
--- DOCS/man/en/mplayer.1	27 Sep 2004 21:04:42 -0000	1.754
+++ DOCS/man/en/mplayer.1	28 Sep 2004 01:19:58 -0000
@@ -6317,17 +6317,17 @@
 Enable rtjpeg encoding.
 .
 .
-.SS xvidenc (\-xvidencopts)
+.SS xvid (\-xvidencopts)
 .
 There are three modes available: constant bitrate (CBR), fixed quantizer and
 2pass.
 .
 .TP
-.B pass=<1|2>
+.B vpass=<1|2>
 Specify the pass in 2pass mode.
 .
 .TP
-.B bitrate=<value>
+.B vbitrate=<value>
 Sets the bitrate to be used in kbits/\:second if <16000 or in bits/\:second
 if >16000.
 If <value> is negative, XviD will use its absolute value as the target size
@@ -6335,7 +6335,7 @@
 (CBR or 2pass mode, default: 687 kbits/\:s)
 .
 .TP
-.B fixed_quant=<1\-31>
+.B vqscale=<1\-31>
 Switch to fixed quantizer mode and specify the quantizer to be used.
 .
 .TP
@@ -6479,7 +6479,7 @@
 Generate DivX5 compatible B frames (default: on).
 .
 .TP
-.B max_bframes=<0\-4>
+.B vmax_b_frames=<0\-4>
 Maximum number of B frames to put between I/\:P frames (default: 0).
 .
 .TP
@@ -6534,7 +6534,7 @@
 dependent on the source material.
 .
 .TP
-.B trellis
+.B trell
 Trellis Quantization is a kind of adaptive quantization method that
 saves bits by modifying quantized coefficients to make them more
 compressible by the entropy encoder.
Index: libmpcodecs/ve_xvid4.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ve_xvid4.c,v
retrieving revision 1.8
diff -u -r1.8 ve_xvid4.c
--- libmpcodecs/ve_xvid4.c	13 Jul 2004 18:09:58 -0000	1.8
+++ libmpcodecs/ve_xvid4.c	28 Sep 2004 01:19:59 -0000
@@ -203,9 +203,9 @@
 m_option_t xvidencopts_conf[] =
 {
 	/* Standard things mencoder should be able to treat directly */
-	{"bitrate", &xvidenc_bitrate, CONF_TYPE_INT, 0, 0, 0, NULL},
-	{"pass", &xvidenc_pass, CONF_TYPE_INT, CONF_RANGE, 1, 2, NULL},
-	{"fixed_quant", &xvidenc_quantizer, CONF_TYPE_FLOAT, CONF_RANGE, 1, 31, NULL},
+	{"vbitrate", &xvidenc_bitrate, CONF_TYPE_INT, 0, 0, 0, NULL},
+	{"vpass", &xvidenc_pass, CONF_TYPE_INT, CONF_RANGE, 1, 2, NULL},
+	{"vqscale", &xvidenc_quantizer, CONF_TYPE_FLOAT, CONF_RANGE, 1, 31, NULL},
 
 	/* Features */
 	{"quant_type", &xvidenc_quant_method, CONF_TYPE_STRING, 0, 0, 0, NULL},
@@ -213,20 +213,20 @@
 	{"chroma_me", &xvidenc_chromame, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"chroma_opt", &xvidenc_chroma_opt, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"vhq", &xvidenc_vhq, CONF_TYPE_INT, CONF_RANGE, 0, 4, NULL},
-	{"max_bframes", &xvidenc_max_bframes, CONF_TYPE_INT, CONF_RANGE, 0, 20, NULL},
+	{"vmax_b_frames", &xvidenc_max_bframes, CONF_TYPE_INT, CONF_RANGE, 0, 20, NULL},
 	{"bquant_ratio", &xvidenc_bquant_ratio, CONF_TYPE_INT, CONF_RANGE, 0, 200, NULL},
 	{"bquant_offset", &xvidenc_bquant_offset, CONF_TYPE_INT, CONF_RANGE, 0, 200, NULL},
 	{"bf_threshold", &xvidenc_bframe_threshold, CONF_TYPE_INT, CONF_RANGE, -255, 255, NULL},
 	{"qpel", &xvidenc_quarterpel, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"gmc", &xvidenc_gmc, CONF_TYPE_FLAG, 0, 0, 1, NULL},
-	{"trellis", &xvidenc_trellis, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+	{"trell", &xvidenc_trellis, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"packed", &xvidenc_packed, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"closed_gop", &xvidenc_closed_gop, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"interlacing", &xvidenc_interlaced, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"cartoon", &xvidenc_cartoon, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"hq_ac", &xvidenc_hqacpred, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"frame_drop_ratio", &xvidenc_frame_drop_ratio, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL},
-	{"max_key_interval", &xvidenc_max_key_interval, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
+	{"keyint", &xvidenc_max_key_interval, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
 	{"greyscale", &xvidenc_greyscale, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"turbo", &xvidenc_turbo, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"debug", &xvidenc_debug, CONF_TYPE_INT , 0 ,0,-1,NULL},
@@ -712,7 +712,8 @@
 	 * The single pass plugin
 	 * ---------------------------------------------------------------- */
 
-	onepass->bitrate = xvidenc_bitrate;
+	if (xvidenc_bitrate > 16000) onepass->bitrate = xvidenc_bitrate;
+	else onepass->bitrate = xvidenc_bitrate*1000;
 	onepass->reaction_delay_factor = xvidenc_cbr_reaction_delay_factor;
 	onepass->averaging_period = xvidenc_cbr_averaging_period;
 	onepass->buffer = xvidenc_cbr_buffer;
@@ -983,7 +984,8 @@
 
 		/* There is not much left to initialize after dispatch settings */
 		onepass->version = XVID_VERSION;
-		onepass->bitrate = xvidenc_bitrate*1000;
+		if (xvidenc_bitrate > 16000) onepass->bitrate = xvidenc_bitrate;
+		else onepass->bitrate = xvidenc_bitrate*1000;
 
 		/* Quantizer mode uses the same plugin, we have only to define
 		 * a constant quantizer zone beginning at frame 0 */
@@ -1006,7 +1008,7 @@
 		} else {
 			mp_msg(MSGT_MENCODER, MSGL_INFO,
 			       "xvid: CBR Rate Control -- bitrate=%dkbit/s\n",
-			       xvidenc_bitrate);
+			       xvidenc_bitrate>16000?xvidenc_bitrate/1000:xvidenc_bitrate);
 		}
 
 		create->plugins[create->num_plugins].func  = xvid_plugin_single;
@@ -1042,10 +1044,11 @@
 		 * value is negative it is considered as being a total size
 		 * to reach (in kilobytes) */
 		if(xvidenc_bitrate > 0) {
-			pass2->bitrate  = xvidenc_bitrate*1000;
+			if(xvidenc_bitrate > 16000) pass2->bitrate = xvidenc_bitrate;
+			else pass2->bitrate = xvidenc_bitrate*1000;
 			mp_msg(MSGT_MENCODER, MSGL_INFO,
 			       "xvid: 2Pass Rate Control -- 2nd pass -- bitrate=%dkbit/s\n",
-			       xvidenc_bitrate);
+			       xvidenc_bitrate>16000?xvidenc_bitrate/1000:xvidenc_bitrate);
 		} else {
 			pass2->bitrate  = xvidenc_bitrate;
 			mp_msg(MSGT_MENCODER, MSGL_INFO,


More information about the MPlayer-dev-eng mailing list