Mercurial > mplayer.hg
changeset 32574:59ecb59c86cc
Expose the VBV options of xvid encoder to the command line interface.
Also remove incorrect multiply of debug option.
Patch by Lasse Collin < lasse point collin at tukaani point org>.
author | iive |
---|---|
date | Sat, 27 Nov 2010 19:15:54 +0000 |
parents | 77c851105750 |
children | 322c6c3a57eb |
files | DOCS/man/en/mplayer.1 libmpcodecs/ve_xvid4.c |
diffstat | 2 files changed, 71 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1 Sat Nov 27 18:06:45 2010 +0000 +++ b/DOCS/man/en/mplayer.1 Sat Nov 27 19:15:54 2010 +0000 @@ -10276,7 +10276,7 @@ . .PP .sp 1 -The following option is only available in Xvid 1.1.x. +The following options are only available in Xvid 1.1.x and later. . .TP .B bvhq=<0|1> @@ -10286,9 +10286,32 @@ This produces nicer-looking B-frames while incurring almost no performance penalty (default: 1). . +.TP +.B vbv_bufsize=<0...> (two pass mode only) +Specify the video buffering verifier (VBV) buffer size in bits +(default: 0 \- VBV check disabled). +VBV allows restricting peak bitrate to make the video play properly +on hardware players. +For example, the Home profile uses vbv_bufsize=3145728. +If you set vbv_bufsize you should set also vbv_maxrate. +Note that there is no vbv_peakrate because Xvid does not actually +use it for bitrate controlling; the other VBV options are enough +to restrict the peak bitrate. +. +.TP +.B vbv_initial=<0...vbv_bufsize> (two pass mode only) +Specify the initial fill of the VBV buffer in bits +(default: 75% of vbv_bufsize). +The default is probably what you want. +. +.TP +.B vbv_maxrate=<0...> (two pass mode only) +Specify the maximum processing rate in bits/s (default: 0). +For example, the Home profile uses vbv_maxrate=4854000. +. .PP .sp 1 -The following option is only available in the 1.2.x version of Xvid. +The following option is only available in Xvid 1.2.x and later. . .TP .B threads=<0\-n>
--- a/libmpcodecs/ve_xvid4.c Sat Nov 27 18:06:45 2010 +0000 +++ b/libmpcodecs/ve_xvid4.c Sat Nov 27 19:15:54 2010 +0000 @@ -209,6 +209,10 @@ static int xvidenc_vbr_kfthreshold = 0; static int xvidenc_vbr_container_frame_overhead = 24; /* mencoder uses AVI container */ +static int xvidenc_vbv_size = 0; +static int xvidenc_vbv_initial = 0; +static int xvidenc_vbv_maxrate = 0; + // commandline profile option string - default to unrestricted static char *xvidenc_profile = "unrestricted"; @@ -296,6 +300,11 @@ {"kfthreshold", &xvidenc_vbr_kfthreshold, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL}, {"container_frame_overhead", &xvidenc_vbr_container_frame_overhead, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL}, + /* section [vbv] */ + {"vbv_bufsize", &xvidenc_vbv_size, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL}, + {"vbv_initial", &xvidenc_vbv_initial, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL}, + {"vbv_maxrate", &xvidenc_vbv_maxrate, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL}, + /* Section Aspect Ratio */ {"par", &xvidenc_par, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"par_width", &xvidenc_par_width, CONF_TYPE_INT, CONF_RANGE, 0, 255, NULL}, @@ -775,13 +784,44 @@ /* VBV */ #if XVID_API >= XVID_MAKE_API(4,1) - pass2->vbv_size = selected_profile->max_vbv_size; - pass2->vbv_initial = (selected_profile->max_vbv_size*3)>>2; /* 75% */ - pass2->vbv_maxrate = selected_profile->max_bitrate; - pass2->vbv_peakrate = selected_profile->vbv_peakrate*3; + if(xvidenc_vbv_size > 0) { + if(selected_profile->max_vbv_size > 0 && xvidenc_vbv_size > selected_profile->max_vbv_size) { + mp_msg(MSGT_MENCODER,MSGL_ERR, + "xvid:[ERROR] Selected profile limits vbv_bufsize <= %d\n", selected_profile->max_vbv_size); + return BAD; + } + + pass2->vbv_size = xvidenc_vbv_size; + } else { + pass2->vbv_size = selected_profile->max_vbv_size; + } + + if(xvidenc_vbv_initial > 0) { + if(xvidenc_vbv_initial > pass2->vbv_size) { + mp_msg(MSGT_MENCODER,MSGL_ERR, + "xvid:[ERROR] vbv_initial must be <= vbv_bufsize\n"); + return BAD; + } + + pass2->vbv_initial = xvidenc_vbv_initial; + } else { + pass2->vbv_initial = (pass2->vbv_size*3)>>2; /* 75% */ + } + + if(xvidenc_vbv_maxrate > 0) { + if(selected_profile->max_bitrate > 0 && xvidenc_vbv_maxrate > selected_profile->max_bitrate) { + mp_msg(MSGT_MENCODER,MSGL_ERR, + "xvid:[ERROR] Selected profile limits vbv_maxrate <= %d\n", selected_profile->max_bitrate); + return BAD; + } + + pass2->vbv_maxrate = xvidenc_vbv_maxrate; + } else { + pass2->vbv_maxrate = selected_profile->max_bitrate; + } + + pass2->vbv_peakrate = selected_profile->vbv_peakrate; /* Useless */ #endif -// XXX: xvidcore currently provides a "peak bits over 3 seconds" constraint. -// according to the latest dxn literature, a 1 second constraint is now used create->profile = selected_profile->id;