[MPlayer-dev-eng] Credits VBR modes for xvid codec

German Gomez Garcia german at piraos.com
Thu Jan 30 20:54:33 CET 2003


	Hello,

	I've integrate VBR credits modes into ve_xvid.c, too trivial to
comment :-)

	Patch attached (also for the manpage)

	Best regards,

	- german

-- 
Send email with "SEND GPG KEY" as subject to receive my GnuPG public key.
-------------- next part --------------
--- DOCS/mplayer.1	2003-01-30 20:50:07.000000000 +0100
+++ DOCS/mplayer.1.new	2003-01-30 20:50:38.000000000 +0100
@@ -3136,6 +3136,26 @@
 (default=10, 2pass mode only)
 .IPs kfreduction=<0\-100>
 (default=30, 2pass mode only)
+.IPs credits_mode=<rate|quant|size>
+specify the vbr mode for credits
+.IPs credits_start=<begin-end>
+specify the starting credits range
+.IPs credits_end=<begin-end>
+specify the ending credits range
+.IPs credits_quant_ratio=<0-100>
+specify the quant ratio in credits_mode=rate (default=20) 
+.IPs credits_fixed_quant=<1-31>
+specify the fixed quant in credits_mode=quant (default=20) 
+.IPs credits_fixed_quant=<1-31>
+specify the fixed quant in credits_mode=quant (default=20) 
+.IPs credits_quant_i=<1-31>
+specify the fixed quant i in credits_mode=quant (default=20) 
+.IPs credits_quant_p=<1-31>
+specify the fixed quant p in credits_mode=quant (default=20) 
+.IPs credits_start_size=<value>
+specify the estimated size for the starting credits in credits_mode=size(default=0) 
+.IPs credits_end_size=<value>
+specify the estimated size for the ending credits in credits_mode=size(default=0) 
 .RE
 
 
--- libmpcodecs/ve_xvid.c.old	2003-01-30 20:48:51.000000000 +0100
+++ libmpcodecs/ve_xvid.c	2003-01-30 20:48:12.000000000 +0100
@@ -95,6 +95,15 @@
 static int xvidenc_me_colour = 0;
 static int xvidenc_reduced = 0;
 #endif
+static char *xvidenc_credits_mode = "rate";
+static char *xvidenc_credits_start = NULL;
+static char *xvidenc_credits_end = NULL;
+static int xvidenc_credits_quant_ratio = 20;
+static int xvidenc_credits_fixed_quant = 20;
+static int xvidenc_credits_quant_i = 20;
+static int xvidenc_credits_quant_p = 20;
+static int xvidenc_credits_start_size = 0;
+static int xvidenc_credits_end_size = 0;
 
 struct config xvidencopts_conf[] = {
     { "pass", &xvidenc_pass, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL},
@@ -118,6 +127,7 @@
     { "debug", &xvidenc_debug, CONF_TYPE_FLAG, 0, 0, 1, NULL},
     { "hintedme", &xvidenc_hintedme, CONF_TYPE_FLAG, 0, 0, 1, NULL},
     { "hintfile", &xvidenc_hintfile, CONF_TYPE_STRING, 0, 0, 0, NULL},
+
 #ifdef XVID_API_UNSTABLE
     { "qpel", &xvidenc_qpel, CONF_TYPE_FLAG, 0, 0, 1, NULL},
     { "max_bframes", &xvidenc_max_bframes, CONF_TYPE_INT, CONF_RANGE, 0, 4, NULL},
@@ -127,6 +137,15 @@
     { "gmc", &xvidenc_gmc, CONF_TYPE_FLAG, 0, 0, 1, NULL},
     { "me_colour", &xvidenc_me_colour, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 #endif
+    { "credits_mode", &xvidenc_credits_mode, CONF_TYPE_STRING, 0, 0, 0, NULL},
+    { "credits_start", &xvidenc_credits_start, CONF_TYPE_STRING, 0, 0, 1, NULL},
+    { "credits_end", &xvidenc_credits_end, CONF_TYPE_STRING, 0, 0, 0, NULL},
+    { "credits_quant_ratio", &xvidenc_credits_quant_ratio, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL},
+    { "credits_fixed_quant", &xvidenc_credits_fixed_quant, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
+    { "credits_quant_i", &xvidenc_credits_quant_i, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
+    { "credits_quant_p", &xvidenc_credits_quant_p, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
+    { "credits_start_size", &xvidenc_credits_start_size, CONF_TYPE_INT, 0, 0, 0, NULL},
+    { "credits_end_size", &xvidenc_credits_end_size, CONF_TYPE_INT, 0, 0, 0, NULL},
     { NULL, NULL, 0, 0, 0, 0, NULL}
 };
 
@@ -147,6 +166,9 @@
     XVID_ENC_PARAM enc_param;
     struct vf_priv_s *fp = vf->priv;
     unsigned int min_iq, max_iq, min_pq, max_pq;
+    unsigned int credits_begin, credits_end;
+    char *credits_mode;
+
 
     fp->mux->bih->biWidth = width;
     fp->mux->bih->biHeight = height;
@@ -335,6 +357,61 @@
     fp->vbr_state.max_key_interval = enc_param.max_key_interval;
     fp->vbr_state.debug = xvidenc_debug;
 
+    switch(xvidenc_credits_mode[0])
+    {
+    default:
+    case 'r': 
+    case 'R': fp->vbr_state.credits_mode = VBR_CREDITS_MODE_RATE; 
+	      credits_mode = "RATE";
+	      break;
+    case 'q': 
+    case 'Q': fp->vbr_state.credits_mode = VBR_CREDITS_MODE_QUANT; 
+	      credits_mode = "QUANT";
+	      break;
+    case 's': 
+    case 'S': fp->vbr_state.credits_mode = VBR_CREDITS_MODE_SIZE; 
+	      credits_mode = "SIZE";
+	      break;
+    }
+
+    if (xvidenc_credits_start == NULL) {
+	credits_begin = credits_end = 0;
+    } else if (sscanf (xvidenc_credits_start, "%u-%u", &credits_begin, &credits_end) < 2) {
+	mp_msg (MSGT_MENCODER, MSGL_ERR, 
+		"xvid: ERROR: cannot parse \"credits_start=%s\"\n", xvidenc_credits_start);
+	return 0;
+    }
+    fp->vbr_state.credits_start = xvidenc_credits_start != NULL ? 1 : 0;
+    fp->vbr_state.credits_start_begin = credits_begin;
+    fp->vbr_state.credits_start_end = credits_end;
+
+    if (xvidenc_credits_end == NULL) {
+	credits_begin = credits_end = 0;
+    } else if (sscanf (xvidenc_credits_end, "%u-%u", &credits_begin, &credits_end) < 2) {
+	mp_msg (MSGT_MENCODER, MSGL_ERR, 
+		"xvid: ERROR: cannot parse \"credits_end=%s\"\n", xvidenc_credits_end);
+	return 0;
+    }
+    fp->vbr_state.credits_end = xvidenc_credits_end != NULL ? 1 : 0;
+    fp->vbr_state.credits_end_begin = credits_begin;
+    fp->vbr_state.credits_end_end = credits_end;
+
+    fp->vbr_state.credits_quant_ratio = xvidenc_credits_quant_ratio;
+    fp->vbr_state.credits_fixed_quant = xvidenc_credits_fixed_quant;
+    fp->vbr_state.credits_quant_i = xvidenc_credits_quant_i;
+    fp->vbr_state.credits_quant_p = xvidenc_credits_quant_p;
+    fp->vbr_state.credits_start_size = xvidenc_credits_start_size;
+    fp->vbr_state.credits_end_size = xvidenc_credits_end_size;
+    fp->vbr_state.credits_quant_ratio = xvidenc_credits_quant_ratio;
+    fp->vbr_state.credits_fixed_quant = xvidenc_credits_fixed_quant;
+    fp->vbr_state.credits_quant_i = xvidenc_credits_quant_i;
+    fp->vbr_state.credits_quant_p = xvidenc_credits_quant_p;
+    fp->vbr_state.credits_start_size = xvidenc_credits_start_size;
+    fp->vbr_state.credits_end_size = xvidenc_credits_end_size;
+
+    mp_msg (MSGT_MENCODER, MSGL_INFO, 
+	    "xvid: Enabling credits mode %s\n", credits_mode);
+
     vbrInit(&fp->vbr_state);
 
     return 1;


More information about the MPlayer-dev-eng mailing list