In article <[EMAIL PROTECTED]>,
Francesco Romani <[EMAIL PROTECTED]> writes:
> On Mon, 5 Jun 2006 03:32:04 +0000 (UTC)
> [EMAIL PROTECTED] (Frederick Bruckman) wrote:
>
>> I also have a longer patch against 1.0.2 to use the Xvid 1.1 rate
>> controls. I won't post it here because it's not very interesting:
>> besides being out-of-date against CVS, it doesn't have the profile
>> support (yet), but I'd be happy to send it to anyone who wants to
>> work on it.
>
> I'm interested to this patch, but unfortunately I'm facing an issue on import
> layer (the infamous directory mode thing), so I can't work on this quickly.
> Feel free to post the patch above on this thread if you like.
Here you go. Some comments:
1) As I wrote, this is against 1.0.2. I've already adapted the
PAR fixup to CVS and posted a fix at the start of this thread.
2) I came up with MOD_VERSION v0.1.1 because I bumped a few times
tracking Xvid 1.1 betas. (I've never published this anywhere else,
so you could use any version number you like.)
3) The soname changes were all about choosing 1.1-beta(s) while
Xvid 1.0 was still installed, but with an eye toward future ABI
changes in the Xvid shared library. Know that xvidcore's install
target doesn't actually fix up the ELF symlinks, but I do, and
third party packagers could, so we should be prepared for all
possibilities. Please indulge the semi-cosmetic changes -- it was
much easier to copy and paste with the elements on seperate lines.
4) The point is to play around with the new vbv_ capabilities.
We probably need better examples. There seems to be a mistake
in the xvidcores built-in profiles: they make "vbv_size" a
multiple of 16368 instead of 16384. Perhaps they have a reason
for that, but it seems ugly. "vbv_maxrate" seems to be derated,
too, from the VMV maximum for [EMAIL PROTECTED] of 4860Mb = 4976640, but I
haven't been able to find a document that says what the DivX
Home Theatre Profile actually is, so I haven't pushed that one.
This works reasonably well with my bog standard Philips DVP642,
but more experiment/research is needed:
#
# DivX Home Theatre
#
vbv_size = 3145728
vbv_initial = 2359296
vbv_maxrate = 4854000
vbv_peakrate = 8000000
All I know about MPEG profiles, I learned from this document:
http://www.m4if.org/resources/profiles/index.html
so if anyone has better information, please speak up.
5) The new "xvid4.h" is straight from Xvid.
Index: export/export_xvid4.c
===================================================================
RCS file: /cvsroot/transcode/export/export_xvid4.c,v
retrieving revision 1.1.1.3
retrieving revision 1.6
diff -u -r1.1.1.3 -r1.6
--- export/export_xvid4.c 20 Oct 2005 04:18:48 -0000 1.1.1.3
+++ export/export_xvid4.c 4 Jun 2006 23:44:37 -0000 1.6
@@ -68,9 +68,9 @@
****************************************************************************/
#define MOD_NAME "export_xvid4.so"
-#define MOD_VERSION "v0.0.5 (2003-12-05)"
+#define MOD_VERSION "v0.1.1 (2006-03-13)"
#define MOD_CODEC \
-"(video) XviD 1.0.x series (aka API 4.0) | (audio) MPEG/AC3/PCM"
+"(video) XviD 1.1.x series (aka API 4.1) | (audio) MPEG/AC3/PCM"
static int verbose_flag = TC_QUIET;
static int capability_flag = TC_CAP_PCM |
TC_CAP_RGB |
@@ -90,6 +90,8 @@
#endif
#define XVID_CONFIG_FILE "xvid4.cfg"
+#include "probe_export.h"
+
/*****************************************************************************
* Local data
****************************************************************************/
@@ -673,7 +675,7 @@
{"averaging_period", &onepass->averaging_period,
CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
{"buffer", &onepass->buffer, CONF_TYPE_INT, CONF_MIN,
0, 0, NULL},
- /* section [cbr] */
+ /* section [vbr] */
{"vbr", "VBR settings", CONF_TYPE_SECTION, 0, 0, 0,
NULL},
{"keyframe_boost", &pass2->keyframe_boost,
CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL},
{"curve_compression_high",
&pass2->curve_compression_high, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL},
@@ -684,6 +686,10 @@
{"kfreduction", &pass2->kfreduction, CONF_TYPE_INT,
CONF_RANGE, 0, 100, NULL},
{"kfthreshold", &pass2->kfthreshold, CONF_TYPE_INT,
CONF_MIN, 0, 0, NULL},
{"container_frame_overhead",
&pass2->container_frame_overhead, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
+ {"vbv_size", &pass2->vbv_size, CONF_TYPE_INT, CONF_MIN,
0, 0, NULL},
+ {"vbv_initial", &pass2->vbv_initial, CONF_TYPE_INT,
CONF_MIN, 0, 0, NULL},
+ {"vbv_maxrate", &pass2->vbv_maxrate, CONF_TYPE_INT,
CONF_MIN, 0, 0, NULL},
+ {"vbv_peakrate", &pass2->vbv_peakrate, CONF_TYPE_INT,
CONF_MIN, 0, 0, NULL},
/* End of the config file */
{NULL, 0, 0, 0, 0, 0, NULL}
@@ -932,6 +938,10 @@
pass2->kfreduction = pass2cfg->kfreduction;
pass2->kfthreshold = pass2cfg->kfthreshold;
pass2->container_frame_overhead =
pass2cfg->container_frame_overhead;
+ pass2->vbv_size = pass2cfg->vbv_size;
+ pass2->vbv_initial = pass2cfg->vbv_initial;
+ pass2->vbv_maxrate = pass2cfg->vbv_maxrate;
+ pass2->vbv_peakrate = pass2cfg->vbv_peakrate;
/* Positive bitrate values are bitrates as usual but if the
* value is negative it is considered as being a total size
@@ -1031,15 +1041,16 @@
x->quant_intra_matrix = xcfg->quant_intra_matrix;
x->quant_inter_matrix = xcfg->quant_inter_matrix;
- /* pixel aspect ratio
- * transcode.c uses 0 for EXT instead of 15 */
- if ((vob->ex_par==0) &&
- (vob->ex_par_width==1) && (vob->ex_par_height==1))
- vob->ex_par = 1;
-
- x->par = (vob->ex_par==0)? XVID_PAR_EXT: vob->ex_par;
- x->par_width = vob->ex_par_width;
- x->par_height = vob->ex_par_height;
+ /* pixel aspect ratio */
+ if (probe_export_attributes & TC_PROBE_NO_EXPORT_PAR) {
+ if (vob->ex_par == 0) {
+ x->par = XVID_PAR_EXT;
+ x->par_width = vob->ex_par_width;
+ x->par_height = vob->ex_par_height;
+ } else {
+ x->par = vob->ex_par;
+ }
+ }
return;
}
@@ -1176,40 +1187,84 @@
#else
char *error;
#endif
- char soname[4][4096];
+ char modules[6][TC_BUF_MAX];
int i;
/* Reset pointers */
memset(xvid, 0, sizeof(xvid[0]));
- /* First we build all sonames we will try to load */
+ /*
+ * First one found better be right, else the codec initialization
+ * will fail with a version mismatch. If that happens, though, having
+ * the ELF symlinks in the search path gives the user the opportunity
+ * to make it right. Here is the order we will search:
+ *
+ * modules path + ELF major
+ * dlopen() defaults + ELF major
+ * modules path + exact major/minor
+ * dlopen() defaults + exact major/minor
+ * modules path + bare soname
+ * dlopen() defaults + bare soname
+ *
+ */
#ifdef SYSTEM_DARWIN
- snprintf(soname[0], 4095, "%s/%s.%d.%s", path, XVID_SHARED_LIB_BASE,
- XVID_API_MAJOR(XVID_API), XVID_SHARED_LIB_SUFX);
+ snprintf(modules[0], sizeof(modules[0]), "%s/%s.%d.%s", path,
+ XVID_SHARED_LIB_BASE,
+ XVID_API_MAJOR(XVID_API),
+ XVID_SHARED_LIB_SUFX);
#else
- snprintf(soname[0], 4095, "%s/%s.%s.%d", path, XVID_SHARED_LIB_BASE,
- XVID_SHARED_LIB_SUFX, XVID_API_MAJOR(XVID_API));
+ snprintf(modules[0], sizeof(modules[0]), "%s/%s.%s.%d", path,
+ XVID_SHARED_LIB_BASE,
+ XVID_SHARED_LIB_SUFX,
+ XVID_API_MAJOR(XVID_API));
#endif
#ifdef SYSTEM_DARWIN
- snprintf(soname[1], 4095, "%s.%d.%s", XVID_SHARED_LIB_BASE,
- XVID_API_MAJOR(XVID_API), XVID_SHARED_LIB_SUFX);
+ snprintf(modules[1], sizeof(modules[1]), "%s.%d.%s",
+ XVID_SHARED_LIB_BASE,
+ XVID_API_MAJOR(XVID_API),
+ XVID_SHARED_LIB_SUFX);
+#else
+ snprintf(modules[1], sizeof(modules[1]), "%s.%s.%d",
+ XVID_SHARED_LIB_BASE,
+ XVID_SHARED_LIB_SUFX,
+ XVID_API_MAJOR(XVID_API));
+#endif
+#ifdef SYSTEM_DARWIN
+ snprintf(modules[2], sizeof(modules[2]), "%s/%s.%d.%d.%s", path,
+ XVID_SHARED_LIB_BASE,
+ XVID_API_MAJOR(XVID_API), XVID_API_MINOR(XVID_API),
+ XVID_SHARED_LIB_SUFX);
+#else
+ snprintf(modules[2], sizeof(modules[2]), "%s/%s.%s.%d.%d", path,
+ XVID_SHARED_LIB_BASE,
+ XVID_SHARED_LIB_SUFX,
+ XVID_API_MAJOR(XVID_API), XVID_API_MINOR(XVID_API));
+#endif
+#ifdef SYSTEM_DARWIN
+ snprintf(modules[3], sizeof(modules[3]), "%s.%d.%d.%s",
+ XVID_SHARED_LIB_BASE,
+ XVID_API_MAJOR(XVID_API), XVID_API_MINOR(XVID_API),
+ XVID_SHARED_LIB_SUFX);
#else
- snprintf(soname[1], 4095, "%s.%s.%d", XVID_SHARED_LIB_BASE,
- XVID_SHARED_LIB_SUFX, XVID_API_MAJOR(XVID_API));
+ snprintf(modules[3], sizeof(modules[3]), "%s.%s.%d.%d",
+ XVID_SHARED_LIB_BASE,
+ XVID_SHARED_LIB_SUFX,
+ XVID_API_MAJOR(XVID_API), XVID_API_MINOR(XVID_API));
#endif
- snprintf(soname[2], 4095, "%s/%s.%s", path, XVID_SHARED_LIB_BASE,
+ snprintf(modules[4], sizeof(modules[4]), "%s/%s.%s", path,
+ XVID_SHARED_LIB_BASE,
XVID_SHARED_LIB_SUFX);
- snprintf(soname[3], 4095, "%s.%s", XVID_SHARED_LIB_BASE,
+ snprintf(modules[5], sizeof(modules[5]), "%s.%s",
+ XVID_SHARED_LIB_BASE,
XVID_SHARED_LIB_SUFX);
- /* Let's try each shared lib until success */
- for(i=0; i<4; i++) {
+ for(i=0; i<6; i++) {
if(verbose_flag & TC_DEBUG)
fprintf(stderr, "[%s] Trying to load shared lib %s\n",
- MOD_NAME, soname[i]);
+ MOD_NAME, modules[i]);
/* Try loading the shared lib */
- xvid->so = dlopen(soname[i], RTLD_GLOBAL| RTLD_LAZY);
+ xvid->so = dlopen(modules[i], RTLD_GLOBAL| RTLD_LAZY);
/* Test wether loading succeeded */
if(xvid->so != NULL)
@@ -1223,7 +1278,7 @@
}
if(verbose_flag & TC_DEBUG)
- fprintf(stderr, "[%s] Loaded %s\n", MOD_NAME, soname[i]);
+ fprintf(stderr, "[%s] Loaded %s\n", MOD_NAME, modules[i]);
/* Next step is to load xvidcore symbols
*
@@ -1237,7 +1292,7 @@
if(xvid->global == NULL && (error = dlerror()) != NULL) {
fprintf(stderr, "[%s] Error loading symbol (%s)\n", MOD_NAME,
error);
- fprintf(stderr, "[%s] Library \"%s\" looks like an old version
of libxvidcore\n", MOD_NAME, soname[i]);
+ fprintf(stderr, "[%s] Library \"%s\" looks like an old version
of libxvidcore\n", MOD_NAME, modules[i]);
fprintf(stderr, "[%s] You cannot use this module with this lib;
maybe -y xvid2 works\n", MOD_NAME);
return(-1);
}
Index: export/xvid4.cfg
===================================================================
RCS file: /cvsroot/transcode/export/xvid4.cfg,v
retrieving revision 1.1.1.3
retrieving revision 1.3
diff -u -r1.1.1.3 -r1.3
--- export/xvid4.cfg 20 Oct 2005 04:18:48 -0000 1.1.1.3
+++ export/xvid4.cfg 4 Jun 2006 21:01:39 -0000 1.3
@@ -492,6 +492,21 @@
container_frame_overhead = 24
+
+# New in Xvid 1.1.0.
+#
+# vbv_size is something like N * 16384 (N is 40, 80, 112...)
+# vbv_initial is something like N * 64 * 170
+#
+# The Video Rate Buffer Verifier in the MPEG-4 spec doesn't have a "maxrate"
+# or "peakrate": put what you like in there, or use the preset profiles.
+
+vbv_size = 0 # [in] buffer size (bits)
+vbv_initial = 0 # [in] initial buffer occupancy (bits)
+vbv_maxrate = 0 # [in] max processing bitrate (bits per second)
+vbv_peakrate = 0 # [in:opt] max average bitrate over 3 seconds (bits per
second)
+
+
##############################################################################
# Do not modify this tag comment
# arch-tag: bb7970c1-33fb-4c8c-8d1b-742ff2e53336 xvid config file
Index: export/xvid4.h
===================================================================
RCS file: /cvsroot/transcode/export/xvid4.h,v
retrieving revision 1.1.1.3
retrieving revision 1.4
diff -u -r1.1.1.3 -r1.4
--- export/xvid4.h 20 Oct 2005 04:18:48 -0000 1.1.1.3
+++ export/xvid4.h 14 Mar 2006 05:37:39 -0000 1.4
@@ -3,7 +3,7 @@
* XVID MPEG-4 VIDEO CODEC
* - XviD Main header file -
*
- * Copyright(C) 2001-2003 Peter Ross <[EMAIL PROTECTED]>
+ * Copyright(C) 2001-2004 Peter Ross <[EMAIL PROTECTED]>
*
* This program is free software ; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
* along with this program ; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: xvid4.h,v 1.8 2004/10/17 22:03:12 jacob Exp $
+ * $Id: xvid.h,v 1.51.2.2 2005/11/22 21:01:33 edgomez Exp $
*
****************************************************************************/
@@ -57,10 +57,8 @@
#define XVID_API_MAJOR(a) (((a)>>16) & 0xff)
#define XVID_API_MINOR(a) (((a)>> 0) & 0xff)
-#define XVID_VERSION XVID_MAKE_VERSION(1,0,-126)
-#define XVID_API XVID_MAKE_API(4, 0)
-
-#define XVID_UNSTABLE
+#define XVID_VERSION XVID_MAKE_VERSION(1,1,0)
+#define XVID_API XVID_MAKE_API(4, 1)
/* Bitstream Version
* this will be writen into the bitstream to allow easy detection of xvid
@@ -73,8 +71,7 @@
* doesnt hurt but not increasing it could cause difficulty for decoders in the
* future
*/
-#define XVID_BS_VERSION "0025"
-
+#define XVID_BS_VERSION 41
/*****************************************************************************
* error codes
@@ -96,7 +93,8 @@
/* colorspace values */
-#define XVID_CSP_USER (1<< 0) /* 4:2:0 planar (==I420, except for
pointers/strides) */
+#define XVID_CSP_PLANAR (1<< 0) /* 4:2:0 planar (==I420, except for
pointers/strides) */
+#define XVID_CSP_USER XVID_CSP_PLANAR
#define XVID_CSP_I420 (1<< 1) /* 4:2:0 planar */
#define XVID_CSP_YV12 (1<< 2) /* 4:2:0 planar */
#define XVID_CSP_YUY2 (1<< 3) /* 4:2:2 packed */
@@ -250,6 +248,12 @@
#define XVID_DEBLOCKY (1<<2) /* perform luma deblocking */
#define XVID_DEBLOCKUV (1<<3) /* perform chroma deblocking */
#define XVID_FILMEFFECT (1<<4) /* adds film grain */
+#define XVID_DERINGUV (1<<5) /* perform chroma deringing, requires
deblocking to work */
+#define XVID_DERINGY (1<<6) /* perform luma deringing, requires
deblocking to work */
+
+#define XVID_DEC_FAST (1<<29) /* disable postprocessing to decrease cpu
usage *todo* */
+#define XVID_DEC_DROP (1<<30) /* drop bframes to decrease cpu usage
*todo* */
+#define XVID_DEC_PREROLL (1<<31) /* decode as fast as you can, don't even
show output *todo* */
typedef struct {
int version;
@@ -257,6 +261,8 @@
void *bitstream; /* [in] bitstream (read from)*/
int length; /* [in] bitstream length */
xvid_image_t output; /* [in] output image (written to) */
+/* ------- v1.1.x ------- */
+ int brightness; /* [in] brightness offset (0=none) */
} xvid_dec_frame_t;
@@ -500,7 +506,7 @@
typedef struct {
int version;
- int bitrate; /* [in] bits per second */
+ int bitrate; /* [in] target bitrate (bits per second)
*/
char * filename; /* [in] first pass stats filename */
int keyframe_boost; /* [in] keyframe boost percentage:
[0..100] */
@@ -517,6 +523,13 @@
* 0 for
1<distance<kfthreshold */
int container_frame_overhead; /* [in] How many bytes the controller has
to compensate per frame due to container format overhead */
+
+/* ------- v1.1.x ------- */
+ int vbv_size; /* [in] buffer size (bits) */
+ int vbv_initial; /* [in] initial buffer occupancy (bits) */
+ int vbv_maxrate; /* [in] max processing bitrate (bits per
second) */
+ int vbv_peakrate; /* [in:opt] max average bitrate over 3
seconds (bits per second) */
+
}xvid_plugin_2pass2_t;
/*****************************************************************************
@@ -578,7 +591,8 @@
#define XVID_GLOBAL_VOL_AT_IVOP (1<<3) /* write vol at every ivop:
WIN32/divx compatibility */
#define XVID_GLOBAL_FORCE_VOL (1<<4) /* when vol-based parameters are
changed, insert an ivop NOT recommended */
#endif
-
+#define XVID_GLOBAL_DIVX5_USERDATA (1<<5) /* write divx5 userdata string
+ this is implied if
XVID_GLOBAL_PACKED is set */
/*----------------------------------------------------------------------------
* "VOL" flags
@@ -592,6 +606,7 @@
#define XVID_VOL_QUARTERPEL (1<<2) /* enable quarterpel: frames will
encoded as quarterpel */
#define XVID_VOL_GMC (1<<3) /* enable GMC; frames will be checked
for gmc suitability */
#define XVID_VOL_REDUCED_ENABLE (1<<4) /* enable reduced resolution vops:
frames will be checked for rrv suitability */
+ /*
NOTE: the reduced resolution feature is not supported anymore. This flag will
have no effect! */
#define XVID_VOL_INTERLACING (1<<5) /* enable interlaced encoding */
@@ -613,6 +628,7 @@
#define XVID_VOP_HQACPRED (1<< 7) /* high quality ac prediction */
#define XVID_VOP_MODEDECISION_RD (1<< 8) /* enable DCT-ME and use it for
mode decision */
#define XVID_VOP_FAST_MODEDECISION_RD (1<<12) /* use simplified R-D mode
decision */
+#define XVID_VOP_RD_BVOP (1<<13) /* enable rate-distortion mode
decision in b-frames */
/* Only valid for vol_flags|=XVID_VOL_INTERLACING */
#define XVID_VOP_TOPFIELDFIRST (1<< 9) /* set top-field-first flag */
@@ -620,7 +636,7 @@
/* only valid for vol_flags|=XVID_VOL_REDUCED_ENABLED */
#define XVID_VOP_REDUCED (1<<11) /* reduced resolution vop */
-
+
/* NOTE: reduced resolution feature is not supported anymore. This
flag will have no effect! */
/*----------------------------------------------------------------------------
* "Motion" flags
Kind regards,
Frederick