[Mplayer-cvslog] CVS: main/libmpcodecs ve_xvid.c,1.7,1.8
Rémi Guyomarch CVS
rguyom at mplayerhq.hu
Sun Nov 17 14:01:09 CET 2002
Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv14946/libmpcodecs
Modified Files:
ve_xvid.c
Log Message:
Implements [min|max]_[i|p]quantizer.
Better default for min_key_interval.
Index: ve_xvid.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ve_xvid.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ve_xvid.c 14 Nov 2002 21:57:34 -0000 1.7
+++ ve_xvid.c 17 Nov 2002 13:01:06 -0000 1.8
@@ -59,13 +59,17 @@
static int xvidenc_rc_averaging_period = -1;
static int xvidenc_rc_buffer = -1;
static int xvidenc_min_quantizer = 2;
-static int xvidenc_max_quantizer = -1;
-static int xvidenc_min_key_interval = 0;
+static int xvidenc_max_quantizer = 31;
+static int xvidenc_min_iquantizer = -1;
+static int xvidenc_max_iquantizer = -1;
+static int xvidenc_min_pquantizer = -1;
+static int xvidenc_max_pquantizer = -1;
+static int xvidenc_min_key_interval = -1;
static int xvidenc_max_key_interval = -1;
static int xvidenc_mpeg_quant = 0;
static int xvidenc_mod_quant = 0;
static int xvidenc_lumi_mask = 0;
-static int xvidenc_keyframe_boost = 0;
+static int xvidenc_keyframe_boost = -1;
static int xvidenc_kfthreshold = -1;
static int xvidenc_kfreduction = -1;
static int xvidenc_fixed_quant = 0;
@@ -83,6 +87,10 @@
{ "rc_buffer", &xvidenc_rc_buffer, CONF_TYPE_INT, 0, 0, 0, NULL},
{ "min_quantizer", &xvidenc_min_quantizer, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
{ "max_quantizer", &xvidenc_max_quantizer, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
+ { "min_iquantizer", &xvidenc_min_iquantizer, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
+ { "max_iquantizer", &xvidenc_max_iquantizer, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
+ { "min_pquantizer", &xvidenc_min_pquantizer, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
+ { "max_pquantizer", &xvidenc_max_pquantizer, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
{ "min_key_interval", &xvidenc_min_key_interval, CONF_TYPE_INT, 0, 0, 0, NULL}, /* for XVID_MODE_2PASS_2 */
{ "max_key_interval", &xvidenc_max_key_interval, CONF_TYPE_INT, 0, 0, 0, NULL},
{ "mpeg_quant", &xvidenc_mpeg_quant, CONF_TYPE_FLAG, 0, 0, 1, NULL},
@@ -137,12 +145,17 @@
enc_param.rc_reaction_delay_factor = xvidenc_rc_reaction_delay_factor;
enc_param.rc_averaging_period = xvidenc_rc_averaging_period;
enc_param.rc_buffer = xvidenc_rc_buffer;
+ if (xvidenc_min_quantizer >= xvidenc_max_quantizer) {
+ mp_msg (MSGT_MENCODER, MSGL_INFO,
+ "min_quantizer (%d) must be less than max_quantizer (%d)\n",
+ xvidenc_min_quantizer, xvidenc_max_quantizer);
+ return 0;
+ }
enc_param.min_quantizer = xvidenc_min_quantizer;
enc_param.max_quantizer = xvidenc_max_quantizer;
- if( xvidenc_max_key_interval > 0 )
- enc_param.max_key_interval = xvidenc_max_key_interval;
- else
- enc_param.max_key_interval = 10 * enc_param.fbase / enc_param.fincr;
+ if( xvidenc_max_key_interval <= 0 )
+ xvidenc_max_key_interval = 10 * enc_param.fbase / enc_param.fincr;
+ enc_param.max_key_interval = xvidenc_max_key_interval;
switch (xvid_encore(NULL, XVID_ENC_CREATE, &enc_param, NULL)) {
case XVID_ERR_FAIL:
mp_msg(MSGT_MENCODER,MSGL_ERR, "xvid: encoder creation failed\n");
@@ -212,6 +225,44 @@
// initialize VBR engine
// =====================
vbrSetDefaults(&fp->vbr_state);
+ if (xvidenc_min_key_interval < 0)
+ xvidenc_min_key_interval = fp->vbr_state.min_key_interval;
+ if (xvidenc_min_iquantizer < 0)
+ xvidenc_min_iquantizer = fp->vbr_state.min_iquant;
+ if (xvidenc_max_iquantizer < 0)
+ xvidenc_max_iquantizer = fp->vbr_state.max_iquant;
+ if (xvidenc_min_pquantizer < 0)
+ xvidenc_min_pquantizer = fp->vbr_state.min_pquant;
+ if (xvidenc_max_pquantizer < 0)
+ xvidenc_max_pquantizer = fp->vbr_state.max_pquant;
+
+ // min/max validation
+ if (xvidenc_min_key_interval > xvidenc_max_key_interval) {
+ mp_msg (MSGT_MENCODER, MSGL_ERR,
+ "min_key_interval (%d) must be less than max_key_interval (%d)\n",
+ xvidenc_min_key_interval, xvidenc_max_key_interval);
+ return 0;
+ }
+ if (xvidenc_min_quantizer >= xvidenc_max_quantizer) {
+ mp_msg (MSGT_MENCODER, MSGL_ERR,
+ "min_quantizer (%d) must be less than max_quantizer (%d)\n",
+ xvidenc_min_quantizer, xvidenc_max_quantizer);
+ return 0;
+ }
+ if (xvidenc_min_iquantizer >= xvidenc_max_iquantizer) {
+ mp_msg (MSGT_MENCODER, MSGL_ERR,
+ "min_iquantizer (%d) must be less than max_iquantizer (%d)\n",
+ xvidenc_min_iquantizer, xvidenc_max_iquantizer);
+ return 0;
+ }
+ if (xvidenc_min_pquantizer >= xvidenc_max_pquantizer) {
+ mp_msg (MSGT_MENCODER, MSGL_ERR,
+ "min_pquantizer (%d) must be less than max_pquantizer (%d)\n",
+ xvidenc_min_pquantizer, xvidenc_max_pquantizer);
+ return 0;
+ }
+
+ // pass
if (xvidenc_pass == 0) {
if (xvidenc_fixed_quant >= 1) {
fp->vbr_state.mode = VBR_MODE_FIXED_QUANT;
@@ -225,21 +276,26 @@
fp->vbr_state.mode = VBR_MODE_2PASS_2;
else
return -1;
+
+ // misc
fp->vbr_state.fps = (double)enc_param.fbase / enc_param.fincr;
fp->vbr_state.filename = passtmpfile;
fp->vbr_state.desired_bitrate = enc_param.rc_bitrate;
- fp->vbr_state.min_iquant = fp->vbr_state.min_pquant = enc_param.min_quantizer;
- fp->vbr_state.max_iquant = fp->vbr_state.max_pquant = enc_param.max_quantizer;
- if (xvidenc_keyframe_boost)
+ fp->vbr_state.min_iquant = xvidenc_min_iquantizer >= 1 ? xvidenc_min_iquantizer : xvidenc_min_quantizer;
+ fp->vbr_state.max_iquant = xvidenc_max_iquantizer >= 1 ? xvidenc_max_iquantizer : xvidenc_max_quantizer;
+ fp->vbr_state.min_pquant = xvidenc_min_pquantizer >= 1 ? xvidenc_min_pquantizer : xvidenc_min_quantizer;
+ fp->vbr_state.max_pquant = xvidenc_max_pquantizer >= 1 ? xvidenc_max_pquantizer : xvidenc_max_quantizer;
+ if (xvidenc_keyframe_boost >= 0)
fp->vbr_state.keyframe_boost = xvidenc_keyframe_boost;
if (xvidenc_kfthreshold >= 0)
fp->vbr_state.kftreshold = xvidenc_kfthreshold;
if (xvidenc_kfreduction >= 0)
fp->vbr_state.kfreduction = xvidenc_kfreduction;
- if (xvidenc_min_key_interval)
+ if (xvidenc_min_key_interval >= 0)
fp->vbr_state.min_key_interval = xvidenc_min_key_interval;
fp->vbr_state.max_key_interval = enc_param.max_key_interval;
fp->vbr_state.debug = xvidenc_debug;
+
vbrInit(&fp->vbr_state);
return 1;
More information about the MPlayer-cvslog
mailing list