summaryrefslogtreecommitdiffstats
path: root/debian/transcode/transcode-1.1.7/encode
diff options
context:
space:
mode:
Diffstat (limited to 'debian/transcode/transcode-1.1.7/encode')
-rw-r--r--debian/transcode/transcode-1.1.7/encode/Makefile.am85
-rw-r--r--debian/transcode/transcode-1.1.7/encode/Makefile.in799
-rw-r--r--debian/transcode/transcode-1.1.7/encode/encode_copy.c160
-rw-r--r--debian/transcode/transcode-1.1.7/encode/encode_faac.c312
-rw-r--r--debian/transcode/transcode-1.1.7/encode/encode_lame.c456
-rw-r--r--debian/transcode/transcode-1.1.7/encode/encode_lavc.c1553
-rw-r--r--debian/transcode/transcode-1.1.7/encode/encode_lzo.c293
-rw-r--r--debian/transcode/transcode-1.1.7/encode/encode_null.c144
-rw-r--r--debian/transcode/transcode-1.1.7/encode/encode_x264.c1024
-rw-r--r--debian/transcode/transcode-1.1.7/encode/encode_xvid.c1078
-rw-r--r--debian/transcode/transcode-1.1.7/encode/lavc.cfg6
-rw-r--r--debian/transcode/transcode-1.1.7/encode/x264.cfg278
-rw-r--r--debian/transcode/transcode-1.1.7/encode/xvid.cfg510
13 files changed, 6698 insertions, 0 deletions
diff --git a/debian/transcode/transcode-1.1.7/encode/Makefile.am b/debian/transcode/transcode-1.1.7/encode/Makefile.am
new file mode 100644
index 00000000..826d0548
--- /dev/null
+++ b/debian/transcode/transcode-1.1.7/encode/Makefile.am
@@ -0,0 +1,85 @@
+# # Process this file with automake to produce Makefile.in.
+
+AM_CPPFLAGS = \
+ $(PTHREAD_CFLAGS) \
+ -DMOD_PATH=\"$(MOD_PATH)\" \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/src
+
+pkgdir = $(MOD_PATH)
+
+if HAVE_FAAC
+ENCODE_FAAC = encode_faac.la
+endif
+
+if HAVE_LAME
+ENCODE_LAME = encode_lame.la
+endif
+
+if HAVE_FFMPEG
+ENCODE_LAVC = encode_lavc.la
+endif
+
+if HAVE_LZO
+ENCODE_LZO = encode_lzo.la
+endif
+
+if HAVE_X264
+ENCODE_X264 = encode_x264.la
+endif
+
+if HAVE_XVID
+ENCODE_XVID = encode_xvid.la
+endif
+
+if ENABLE_EXPERIMENTAL
+pkg_LTLIBRARIES = \
+ encode_copy.la \
+ $(ENCODE_FAAC) \
+ $(ENCODE_LAME) \
+ $(ENCODE_LAVC) \
+ $(ENCODE_LZO) \
+ encode_null.la \
+ $(ENCODE_X264) \
+ $(ENCODE_XVID)
+endif
+
+encode_copy_la_SOURCES = encode_copy.c
+encode_copy_la_LDFLAGS = -module -avoid-version
+
+encode_faac_la_SOURCES = encode_faac.c
+encode_faac_la_CPPFLAGS = $(AM_CPPFLAGS) $(FAAC_CFLAGS)
+encode_faac_la_LDFLAGS = -module -avoid-version
+encode_faac_la_LIBADD = $(FAAC_LIBS)
+
+encode_lavc_la_SOURCES = encode_lavc.c
+encode_lavc_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBAVCODEC_CFLAGS)
+encode_lavc_la_LDFLAGS = -module -avoid-version
+encode_lavc_la_LIBADD = $(LIBAVCODEC_LIBS)
+
+encode_lame_la_SOURCES = encode_lame.c
+encode_lame_la_CPPFLAGS = $(AM_CPPFLAGS) $(LAME_CFLAGS)
+encode_lame_la_LDFLAGS = -module -avoid-version
+encode_lame_la_LIBADD = $(LAME_LIBS)
+
+encode_lzo_la_SOURCES = encode_lzo.c
+encode_lzo_la_CPPFLAGS = $(AM_CPPFLAGS) $(LZO_CFLAGS)
+encode_lzo_la_LDFLAGS = -module -avoid-version
+encode_lzo_la_LIBADD = $(LZO_LIBS)
+
+encode_null_la_SOURCES = encode_null.c
+encode_null_la_LDFLAGS = -module -avoid-version
+
+encode_x264_la_SOURCES = encode_x264.c
+encode_x264_la_CPPFLAGS = $(AM_CPPFLAGS) $(X264_CFLAGS)
+encode_x264_la_LDFLAGS = -module -avoid-version
+encode_x264_la_LIBADD = $(X264_LIBS)
+
+encode_xvid_la_SOURCES = encode_xvid.c
+encode_xvid_la_LDFLAGS = -module -avoid-version
+encode_xvid_la_LIBADD = $(XVID_LIBS)
+
+EXTRA_DIST = \
+ lavc.cfg \
+ x264.cfg \
+ xvid.cfg
diff --git a/debian/transcode/transcode-1.1.7/encode/Makefile.in b/debian/transcode/transcode-1.1.7/encode/Makefile.in
new file mode 100644
index 00000000..119904e7
--- /dev/null
+++ b/debian/transcode/transcode-1.1.7/encode/Makefile.in
@@ -0,0 +1,799 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# # Process this file with automake to produce Makefile.in.
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = encode
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pkgdir)"
+LTLIBRARIES = $(pkg_LTLIBRARIES)
+encode_copy_la_LIBADD =
+am_encode_copy_la_OBJECTS = encode_copy.lo
+encode_copy_la_OBJECTS = $(am_encode_copy_la_OBJECTS)
+encode_copy_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(encode_copy_la_LDFLAGS) $(LDFLAGS) -o $@
+@ENABLE_EXPERIMENTAL_TRUE@am_encode_copy_la_rpath = -rpath $(pkgdir)
+am__DEPENDENCIES_1 =
+encode_faac_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_encode_faac_la_OBJECTS = encode_faac_la-encode_faac.lo
+encode_faac_la_OBJECTS = $(am_encode_faac_la_OBJECTS)
+encode_faac_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(encode_faac_la_LDFLAGS) $(LDFLAGS) -o $@
+@ENABLE_EXPERIMENTAL_TRUE@@HAVE_FAAC_TRUE@am_encode_faac_la_rpath = \
+@ENABLE_EXPERIMENTAL_TRUE@@HAVE_FAAC_TRUE@ -rpath $(pkgdir)
+encode_lame_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_encode_lame_la_OBJECTS = encode_lame_la-encode_lame.lo
+encode_lame_la_OBJECTS = $(am_encode_lame_la_OBJECTS)
+encode_lame_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(encode_lame_la_LDFLAGS) $(LDFLAGS) -o $@
+@ENABLE_EXPERIMENTAL_TRUE@@HAVE_LAME_TRUE@am_encode_lame_la_rpath = \
+@ENABLE_EXPERIMENTAL_TRUE@@HAVE_LAME_TRUE@ -rpath $(pkgdir)
+encode_lavc_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_encode_lavc_la_OBJECTS = encode_lavc_la-encode_lavc.lo
+encode_lavc_la_OBJECTS = $(am_encode_lavc_la_OBJECTS)
+encode_lavc_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(encode_lavc_la_LDFLAGS) $(LDFLAGS) -o $@
+@ENABLE_EXPERIMENTAL_TRUE@@HAVE_FFMPEG_TRUE@am_encode_lavc_la_rpath = \
+@ENABLE_EXPERIMENTAL_TRUE@@HAVE_FFMPEG_TRUE@ -rpath $(pkgdir)
+encode_lzo_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_encode_lzo_la_OBJECTS = encode_lzo_la-encode_lzo.lo
+encode_lzo_la_OBJECTS = $(am_encode_lzo_la_OBJECTS)
+encode_lzo_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(encode_lzo_la_LDFLAGS) $(LDFLAGS) -o $@
+@ENABLE_EXPERIMENTAL_TRUE@@HAVE_LZO_TRUE@am_encode_lzo_la_rpath = \
+@ENABLE_EXPERIMENTAL_TRUE@@HAVE_LZO_TRUE@ -rpath $(pkgdir)
+encode_null_la_LIBADD =
+am_encode_null_la_OBJECTS = encode_null.lo
+encode_null_la_OBJECTS = $(am_encode_null_la_OBJECTS)
+encode_null_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(encode_null_la_LDFLAGS) $(LDFLAGS) -o $@
+@ENABLE_EXPERIMENTAL_TRUE@am_encode_null_la_rpath = -rpath $(pkgdir)
+encode_x264_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_encode_x264_la_OBJECTS = encode_x264_la-encode_x264.lo
+encode_x264_la_OBJECTS = $(am_encode_x264_la_OBJECTS)
+encode_x264_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(encode_x264_la_LDFLAGS) $(LDFLAGS) -o $@
+@ENABLE_EXPERIMENTAL_TRUE@@HAVE_X264_TRUE@am_encode_x264_la_rpath = \
+@ENABLE_EXPERIMENTAL_TRUE@@HAVE_X264_TRUE@ -rpath $(pkgdir)
+encode_xvid_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_encode_xvid_la_OBJECTS = encode_xvid.lo
+encode_xvid_la_OBJECTS = $(am_encode_xvid_la_OBJECTS)
+encode_xvid_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(encode_xvid_la_LDFLAGS) $(LDFLAGS) -o $@
+@ENABLE_EXPERIMENTAL_TRUE@@HAVE_XVID_TRUE@am_encode_xvid_la_rpath = \
+@ENABLE_EXPERIMENTAL_TRUE@@HAVE_XVID_TRUE@ -rpath $(pkgdir)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/autotools/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(encode_copy_la_SOURCES) $(encode_faac_la_SOURCES) \
+ $(encode_lame_la_SOURCES) $(encode_lavc_la_SOURCES) \
+ $(encode_lzo_la_SOURCES) $(encode_null_la_SOURCES) \
+ $(encode_x264_la_SOURCES) $(encode_xvid_la_SOURCES)
+DIST_SOURCES = $(encode_copy_la_SOURCES) $(encode_faac_la_SOURCES) \
+ $(encode_lame_la_SOURCES) $(encode_lavc_la_SOURCES) \
+ $(encode_lzo_la_SOURCES) $(encode_null_la_SOURCES) \
+ $(encode_x264_la_SOURCES) $(encode_xvid_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+A52_CFLAGS = @A52_CFLAGS@
+A52_LIBS = @A52_LIBS@
+ACLIB_LIBS = @ACLIB_LIBS@
+ACLOCAL = @ACLOCAL@
+ALTIVEC_CFLAGS = @ALTIVEC_CFLAGS@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AVILIB_LIBS = @AVILIB_LIBS@
+AWK = @AWK@
+BSDAV_CFLAGS = @BSDAV_CFLAGS@
+BSDAV_LIBS = @BSDAV_LIBS@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXXCPP = @CXXCPP@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLDARWIN_CFLAGS = @DLDARWIN_CFLAGS@
+DLDARWIN_LIBS = @DLDARWIN_LIBS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FAAC_CFLAGS = @FAAC_CFLAGS@
+FAAC_LIBS = @FAAC_LIBS@
+FGREP = @FGREP@
+FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
+FREETYPE2_LIBS = @FREETYPE2_LIBS@
+GREP = @GREP@
+IBP_LIBS = @IBP_LIBS@
+ICONV_CFLAGS = @ICONV_CFLAGS@
+ICONV_LIBS = @ICONV_LIBS@
+IMAGEMAGICK_CFLAGS = @IMAGEMAGICK_CFLAGS@
+IMAGEMAGICK_LIBS = @IMAGEMAGICK_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LAME_CFLAGS = @LAME_CFLAGS@
+LAME_LIBS = @LAME_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBAVCODEC_CFLAGS = @LIBAVCODEC_CFLAGS@
+LIBAVCODEC_LIBS = @LIBAVCODEC_LIBS@
+LIBAVFORMAT_CFLAGS = @LIBAVFORMAT_CFLAGS@
+LIBAVFORMAT_LIBS = @LIBAVFORMAT_LIBS@
+LIBDVDREAD_CFLAGS = @LIBDVDREAD_CFLAGS@
+LIBDVDREAD_LIBS = @LIBDVDREAD_LIBS@
+LIBDV_CFLAGS = @LIBDV_CFLAGS@
+LIBDV_LIBS = @LIBDV_LIBS@
+LIBJPEG_CFLAGS = @LIBJPEG_CFLAGS@
+LIBJPEG_LIBS = @LIBJPEG_LIBS@
+LIBMPEG2CONVERT_CFLAGS = @LIBMPEG2CONVERT_CFLAGS@
+LIBMPEG2CONVERT_LIBS = @LIBMPEG2CONVERT_LIBS@
+LIBMPEG2_CFLAGS = @LIBMPEG2_CFLAGS@
+LIBMPEG2_LIBS = @LIBMPEG2_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBPOSTPROC_CFLAGS = @LIBPOSTPROC_CFLAGS@
+LIBPOSTPROC_LIBS = @LIBPOSTPROC_LIBS@
+LIBQUICKTIME_CFLAGS = @LIBQUICKTIME_CFLAGS@
+LIBQUICKTIME_LIBS = @LIBQUICKTIME_LIBS@
+LIBS = @LIBS@
+LIBTCAUDIO_LIBS = @LIBTCAUDIO_LIBS@
+LIBTCVIDEO_LIBS = @LIBTCVIDEO_LIBS@
+LIBTC_LIBS = @LIBTC_LIBS@
+LIBTOOL = @LIBTOOL@
+LIBV4L2_CFLAGS = @LIBV4L2_CFLAGS@
+LIBV4L2_LIBS = @LIBV4L2_LIBS@
+LIBV4LCONVERT_CFLAGS = @LIBV4LCONVERT_CFLAGS@
+LIBV4LCONVERT_LIBS = @LIBV4LCONVERT_LIBS@
+LIBXML2_CFLAGS = @LIBXML2_CFLAGS@
+LIBXML2_LIBS = @LIBXML2_LIBS@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LZO_CFLAGS = @LZO_CFLAGS@
+LZO_LIBS = @LZO_LIBS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MJPEGTOOLS_CFLAGS = @MJPEGTOOLS_CFLAGS@
+MJPEGTOOLS_LIBS = @MJPEGTOOLS_LIBS@
+MKDIR_P = @MKDIR_P@
+MOD_PATH = @MOD_PATH@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OGG_CFLAGS = @OGG_CFLAGS@
+OGG_LIBS = @OGG_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_AWK = @PATH_TO_AWK@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PROF_PATH = @PROF_PATH@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PVM3_CFLAGS = @PVM3_CFLAGS@
+PVM3_LIBS = @PVM3_LIBS@
+PVM3_PVMGS = @PVM3_PVMGS@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIMD_FLAGS = @SIMD_FLAGS@
+STRIP = @STRIP@
+THEORA_CFLAGS = @THEORA_CFLAGS@
+THEORA_LIBS = @THEORA_LIBS@
+USE_DLDARWIN = @USE_DLDARWIN@
+VERSION = @VERSION@
+VORBIS_CFLAGS = @VORBIS_CFLAGS@
+VORBIS_LIBS = @VORBIS_LIBS@
+WAVLIB_LIBS = @WAVLIB_LIBS@
+X264_CFLAGS = @X264_CFLAGS@
+X264_LIBS = @X264_LIBS@
+XIO_CFLAGS = @XIO_CFLAGS@
+XIO_LIBS = @XIO_LIBS@
+XMKMF = @XMKMF@
+XVID_CFLAGS = @XVID_CFLAGS@
+XVID_LIBS = @XVID_LIBS@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+a52_config = @a52_config@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bsdav_config = @bsdav_config@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+faac_config = @faac_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+iconv_config = @iconv_config@
+imagemagick_config = @imagemagick_config@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+lame_config = @lame_config@
+libdir = @libdir@
+libdvdread_config = @libdvdread_config@
+libexecdir = @libexecdir@
+libjpeg_config = @libjpeg_config@
+libjpegmmx_config = @libjpegmmx_config@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lzo_config = @lzo_config@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pvm3_config = @pvm3_config@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+x_includes = @x_includes@
+x_libraries = @x_libraries@
+xvid_config = @xvid_config@
+AM_CPPFLAGS = \
+ $(PTHREAD_CFLAGS) \
+ -DMOD_PATH=\"$(MOD_PATH)\" \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/src
+
+pkgdir = $(MOD_PATH)
+@HAVE_FAAC_TRUE@ENCODE_FAAC = encode_faac.la
+@HAVE_LAME_TRUE@ENCODE_LAME = encode_lame.la
+@HAVE_FFMPEG_TRUE@ENCODE_LAVC = encode_lavc.la
+@HAVE_LZO_TRUE@ENCODE_LZO = encode_lzo.la
+@HAVE_X264_TRUE@ENCODE_X264 = encode_x264.la
+@HAVE_XVID_TRUE@ENCODE_XVID = encode_xvid.la
+@ENABLE_EXPERIMENTAL_TRUE@pkg_LTLIBRARIES = \
+@ENABLE_EXPERIMENTAL_TRUE@ encode_copy.la \
+@ENABLE_EXPERIMENTAL_TRUE@ $(ENCODE_FAAC) \
+@ENABLE_EXPERIMENTAL_TRUE@ $(ENCODE_LAME) \
+@ENABLE_EXPERIMENTAL_TRUE@ $(ENCODE_LAVC) \
+@ENABLE_EXPERIMENTAL_TRUE@ $(ENCODE_LZO) \
+@ENABLE_EXPERIMENTAL_TRUE@ encode_null.la \
+@ENABLE_EXPERIMENTAL_TRUE@ $(ENCODE_X264) \
+@ENABLE_EXPERIMENTAL_TRUE@ $(ENCODE_XVID)
+
+encode_copy_la_SOURCES = encode_copy.c
+encode_copy_la_LDFLAGS = -module -avoid-version
+encode_faac_la_SOURCES = encode_faac.c
+encode_faac_la_CPPFLAGS = $(AM_CPPFLAGS) $(FAAC_CFLAGS)
+encode_faac_la_LDFLAGS = -module -avoid-version
+encode_faac_la_LIBADD = $(FAAC_LIBS)
+encode_lavc_la_SOURCES = encode_lavc.c
+encode_lavc_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBAVCODEC_CFLAGS)
+encode_lavc_la_LDFLAGS = -module -avoid-version
+encode_lavc_la_LIBADD = $(LIBAVCODEC_LIBS)
+encode_lame_la_SOURCES = encode_lame.c
+encode_lame_la_CPPFLAGS = $(AM_CPPFLAGS) $(LAME_CFLAGS)
+encode_lame_la_LDFLAGS = -module -avoid-version
+encode_lame_la_LIBADD = $(LAME_LIBS)
+encode_lzo_la_SOURCES = encode_lzo.c
+encode_lzo_la_CPPFLAGS = $(AM_CPPFLAGS) $(LZO_CFLAGS)
+encode_lzo_la_LDFLAGS = -module -avoid-version
+encode_lzo_la_LIBADD = $(LZO_LIBS)
+encode_null_la_SOURCES = encode_null.c
+encode_null_la_LDFLAGS = -module -avoid-version
+encode_x264_la_SOURCES = encode_x264.c
+encode_x264_la_CPPFLAGS = $(AM_CPPFLAGS) $(X264_CFLAGS)
+encode_x264_la_LDFLAGS = -module -avoid-version
+encode_x264_la_LIBADD = $(X264_LIBS)
+encode_xvid_la_SOURCES = encode_xvid.c
+encode_xvid_la_LDFLAGS = -module -avoid-version
+encode_xvid_la_LIBADD = $(XVID_LIBS)
+EXTRA_DIST = \
+ lavc.cfg \
+ x264.cfg \
+ xvid.cfg
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu encode/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu encode/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pkgLTLIBRARIES: $(pkg_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkgdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgdir)"
+ @list='$(pkg_LTLIBRARIES)'; test -n "$(pkgdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkgdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkgdir)"; \
+ }
+
+uninstall-pkgLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkg_LTLIBRARIES)'; test -n "$(pkgdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkgdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkgdir)/$$f"; \
+ done
+
+clean-pkgLTLIBRARIES:
+ -test -z "$(pkg_LTLIBRARIES)" || rm -f $(pkg_LTLIBRARIES)
+ @list='$(pkg_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+encode_copy.la: $(encode_copy_la_OBJECTS) $(encode_copy_la_DEPENDENCIES)
+ $(encode_copy_la_LINK) $(am_encode_copy_la_rpath) $(encode_copy_la_OBJECTS) $(encode_copy_la_LIBADD) $(LIBS)
+encode_faac.la: $(encode_faac_la_OBJECTS) $(encode_faac_la_DEPENDENCIES)
+ $(encode_faac_la_LINK) $(am_encode_faac_la_rpath) $(encode_faac_la_OBJECTS) $(encode_faac_la_LIBADD) $(LIBS)
+encode_lame.la: $(encode_lame_la_OBJECTS) $(encode_lame_la_DEPENDENCIES)
+ $(encode_lame_la_LINK) $(am_encode_lame_la_rpath) $(encode_lame_la_OBJECTS) $(encode_lame_la_LIBADD) $(LIBS)
+encode_lavc.la: $(encode_lavc_la_OBJECTS) $(encode_lavc_la_DEPENDENCIES)
+ $(encode_lavc_la_LINK) $(am_encode_lavc_la_rpath) $(encode_lavc_la_OBJECTS) $(encode_lavc_la_LIBADD) $(LIBS)
+encode_lzo.la: $(encode_lzo_la_OBJECTS) $(encode_lzo_la_DEPENDENCIES)
+ $(encode_lzo_la_LINK) $(am_encode_lzo_la_rpath) $(encode_lzo_la_OBJECTS) $(encode_lzo_la_LIBADD) $(LIBS)
+encode_null.la: $(encode_null_la_OBJECTS) $(encode_null_la_DEPENDENCIES)
+ $(encode_null_la_LINK) $(am_encode_null_la_rpath) $(encode_null_la_OBJECTS) $(encode_null_la_LIBADD) $(LIBS)
+encode_x264.la: $(encode_x264_la_OBJECTS) $(encode_x264_la_DEPENDENCIES)
+ $(encode_x264_la_LINK) $(am_encode_x264_la_rpath) $(encode_x264_la_OBJECTS) $(encode_x264_la_LIBADD) $(LIBS)
+encode_xvid.la: $(encode_xvid_la_OBJECTS) $(encode_xvid_la_DEPENDENCIES)
+ $(encode_xvid_la_LINK) $(am_encode_xvid_la_rpath) $(encode_xvid_la_OBJECTS) $(encode_xvid_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encode_copy.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encode_faac_la-encode_faac.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encode_lame_la-encode_lame.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encode_lavc_la-encode_lavc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encode_lzo_la-encode_lzo.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encode_null.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encode_x264_la-encode_x264.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encode_xvid.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+encode_faac_la-encode_faac.lo: encode_faac.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(encode_faac_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT encode_faac_la-encode_faac.lo -MD -MP -MF $(DEPDIR)/encode_faac_la-encode_faac.Tpo -c -o encode_faac_la-encode_faac.lo `test -f 'encode_faac.c' || echo '$(srcdir)/'`encode_faac.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/encode_faac_la-encode_faac.Tpo $(DEPDIR)/encode_faac_la-encode_faac.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='encode_faac.c' object='encode_faac_la-encode_faac.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(encode_faac_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o encode_faac_la-encode_faac.lo `test -f 'encode_faac.c' || echo '$(srcdir)/'`encode_faac.c
+
+encode_lame_la-encode_lame.lo: encode_lame.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(encode_lame_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT encode_lame_la-encode_lame.lo -MD -MP -MF $(DEPDIR)/encode_lame_la-encode_lame.Tpo -c -o encode_lame_la-encode_lame.lo `test -f 'encode_lame.c' || echo '$(srcdir)/'`encode_lame.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/encode_lame_la-encode_lame.Tpo $(DEPDIR)/encode_lame_la-encode_lame.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='encode_lame.c' object='encode_lame_la-encode_lame.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(encode_lame_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o encode_lame_la-encode_lame.lo `test -f 'encode_lame.c' || echo '$(srcdir)/'`encode_lame.c
+
+encode_lavc_la-encode_lavc.lo: encode_lavc.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(encode_lavc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT encode_lavc_la-encode_lavc.lo -MD -MP -MF $(DEPDIR)/encode_lavc_la-encode_lavc.Tpo -c -o encode_lavc_la-encode_lavc.lo `test -f 'encode_lavc.c' || echo '$(srcdir)/'`encode_lavc.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/encode_lavc_la-encode_lavc.Tpo $(DEPDIR)/encode_lavc_la-encode_lavc.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='encode_lavc.c' object='encode_lavc_la-encode_lavc.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(encode_lavc_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o encode_lavc_la-encode_lavc.lo `test -f 'encode_lavc.c' || echo '$(srcdir)/'`encode_lavc.c
+
+encode_lzo_la-encode_lzo.lo: encode_lzo.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(encode_lzo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT encode_lzo_la-encode_lzo.lo -MD -MP -MF $(DEPDIR)/encode_lzo_la-encode_lzo.Tpo -c -o encode_lzo_la-encode_lzo.lo `test -f 'encode_lzo.c' || echo '$(srcdir)/'`encode_lzo.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/encode_lzo_la-encode_lzo.Tpo $(DEPDIR)/encode_lzo_la-encode_lzo.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='encode_lzo.c' object='encode_lzo_la-encode_lzo.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(encode_lzo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o encode_lzo_la-encode_lzo.lo `test -f 'encode_lzo.c' || echo '$(srcdir)/'`encode_lzo.c
+
+encode_x264_la-encode_x264.lo: encode_x264.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(encode_x264_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT encode_x264_la-encode_x264.lo -MD -MP -MF $(DEPDIR)/encode_x264_la-encode_x264.Tpo -c -o encode_x264_la-encode_x264.lo `test -f 'encode_x264.c' || echo '$(srcdir)/'`encode_x264.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/encode_x264_la-encode_x264.Tpo $(DEPDIR)/encode_x264_la-encode_x264.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='encode_x264.c' object='encode_x264_la-encode_x264.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(encode_x264_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o encode_x264_la-encode_x264.lo `test -f 'encode_x264.c' || echo '$(srcdir)/'`encode_x264.c
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(pkgdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkgLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pkgLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkgLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-pkgLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-pkgLTLIBRARIES install-ps \
+ install-ps-am install-strip installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+ uninstall-am uninstall-pkgLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/debian/transcode/transcode-1.1.7/encode/encode_copy.c b/debian/transcode/transcode-1.1.7/encode/encode_copy.c
new file mode 100644
index 00000000..ddfc085f
--- /dev/null
+++ b/debian/transcode/transcode-1.1.7/encode/encode_copy.c
@@ -0,0 +1,160 @@
+/*
+ * encode_copy.c -- passthrough A/V frames through deep copy.
+ * (C) 2005-2010 Francesco Romani <fromani at gmail dot com>
+ *
+ * This file is part of transcode, a video stream processing tool.
+ *
+ * transcode is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * transcode is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "transcode.h"
+#include "framebuffer.h"
+#include "libtc/optstr.h"
+
+#include "libtc/tcmodule-plugin.h"
+
+#define MOD_NAME "encode_copy.so"
+#define MOD_VERSION "v0.0.4 (2007-11-18)"
+#define MOD_CAP "copy (passthrough) A/V frames"
+
+#define MOD_FEATURES \
+ TC_MODULE_FEATURE_ENCODE|TC_MODULE_FEATURE_VIDEO|TC_MODULE_FEATURE_AUDIO
+
+#define MOD_FLAGS \
+ TC_MODULE_FLAG_RECONFIGURABLE
+
+static const char copy_help[] = ""
+ "Overview:\n"
+ " this module passthrough A/V frames copying them from input\n"
+ " to output.\n"
+ " For a faster passthrough consider usage of 'null' module.\n"
+ "Options:\n"
+ " help produce module overview and options explanations\n";
+
+
+static int copy_init(TCModuleInstance *self, uint32_t features)
+{
+ TC_MODULE_INIT_CHECK(self, MOD_FEATURES, features);
+
+ if (self == NULL) {
+ tc_log_error(MOD_NAME, "init: bad instance data reference");
+ return TC_ERROR;
+ }
+
+ if (verbose) {
+ tc_log_info(MOD_NAME, "%s %s", MOD_VERSION, MOD_CAP);
+ }
+ self->userdata = NULL;
+
+ return TC_OK;
+}
+
+static int copy_fini(TCModuleInstance *self)
+{
+ TC_MODULE_SELF_CHECK(self, "fini");
+
+ return TC_OK;
+}
+
+static int copy_inspect(TCModuleInstance *self,
+ const char *param, const char **value)
+{
+ TC_MODULE_SELF_CHECK(self, "inspect");
+
+ if (optstr_lookup(param, "help")) {
+ *value = copy_help;
+ }
+
+ return TC_OK;
+}
+
+static int copy_configure(TCModuleInstance *self,
+ const char *options, vob_t *vob)
+{
+ TC_MODULE_SELF_CHECK(self, "configure");
+
+ return TC_OK;
+}
+
+static int copy_stop(TCModuleInstance *self)
+{
+ TC_MODULE_SELF_CHECK(self, "stop");
+
+ return TC_OK;
+}
+
+static int copy_encode_video(TCModuleInstance *self,
+ vframe_list_t *inframe, vframe_list_t *outframe)
+{
+ TC_MODULE_SELF_CHECK(self, "encode_video");
+
+ if (inframe == NULL) {
+ outframe->video_len = 0;
+ } else {
+ vframe_copy(outframe, inframe, 1);
+ outframe->video_len = outframe->video_size;
+ }
+ return TC_OK;
+}
+
+static int copy_encode_audio(TCModuleInstance *self,
+ aframe_list_t *inframe, aframe_list_t *outframe)
+{
+ TC_MODULE_SELF_CHECK(self, "encode_audio");
+
+ if (inframe == NULL) {
+ outframe->audio_len = 0;
+ } else {
+ aframe_copy(outframe, inframe, 1);
+ outframe->audio_len = outframe->audio_size;
+ }
+ return TC_OK;
+}
+
+
+/*************************************************************************/
+
+static const uint32_t copy_codecs_in[] = { TC_CODEC_ANY, TC_CODEC_ERROR };
+static const uint32_t copy_codecs_out[] = { TC_CODEC_ANY, TC_CODEC_ERROR };
+TC_MODULE_CODEC_FORMATS(copy);
+
+TC_MODULE_INFO(copy);
+
+static const TCModuleClass copy_class = {
+ TC_MODULE_CLASS_HEAD(copy),
+
+ .init = copy_init,
+ .fini = copy_fini,
+ .configure = copy_configure,
+ .stop = copy_stop,
+ .inspect = copy_inspect,
+
+ .encode_video = copy_encode_video,
+ .encode_audio = copy_encode_audio,
+};
+
+TC_MODULE_ENTRY_POINT(copy);
+
+/*************************************************************************/
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * c-file-offsets: ((case-label . *) (statement-case-intro . *))
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+ */
diff --git a/debian/transcode/transcode-1.1.7/encode/encode_faac.c b/debian/transcode/transcode-1.1.7/encode/encode_faac.c
new file mode 100644
index 00000000..121175c1
--- /dev/null
+++ b/debian/transcode/transcode-1.1.7/encode/encode_faac.c
@@ -0,0 +1,312 @@
+/*
+ * encode_faac.c - encode audio frames using FAAC
+ * Written by Andrew Church <achurch@achurch.org>
+ *
+ * This file is part of transcode, a video stream processing tool.
+ * transcode is free software, distributable under the terms of the GNU
+ * General Public License (version 2 or later). See the file COPYING
+ * for details.
+ */
+
+#include "transcode.h"
+#include "libtc/libtc.h"
+#include "libtc/optstr.h"
+#include "libtc/tcmodule-plugin.h"
+
+#include <faac.h>
+
+#define MOD_NAME "encode_faac.so"
+#define MOD_VERSION "v0.1 (2006-10-11)"
+#define MOD_CAP "Encodes audio to AAC using FAAC (currently BROKEN)"
+#define MOD_AUTHOR "Andrew Church"
+
+#define MOD_FEATURES \
+ TC_MODULE_FEATURE_ENCODE|TC_MODULE_FEATURE_AUDIO
+
+#define MOD_FLAGS \
+ TC_MODULE_FLAG_RECONFIGURABLE
+
+/*************************************************************************/
+
+/* Local data structure: */
+
+typedef struct {
+ faacEncHandle handle;
+ unsigned long framesize; // samples per AAC frame
+ int bps; // bytes per sample
+ /* FAAC only takes complete frames as input, so we buffer as needed. */
+ uint8_t *audiobuf;
+ int audiobuf_len; // in samples
+} PrivateData;
+
+/*************************************************************************/
+/*************************************************************************/
+
+/* Module interface routines and data. */
+
+/*************************************************************************/
+
+/**
+ * faacmod_init: Initialize this instance of the module. See
+ * tcmodule-data.h for function details.
+ */
+
+static int faac_init(TCModuleInstance *self, uint32_t features)
+{
+ PrivateData *pd;
+
+ TC_MODULE_SELF_CHECK(self, "init");
+ TC_MODULE_INIT_CHECK(self, MOD_FEATURES, features);
+
+ self->userdata = pd = tc_malloc(sizeof(PrivateData));
+ if (!pd) {
+ tc_log_error(MOD_NAME, "init: out of memory!");
+ return TC_ERROR;
+ }
+ pd->handle = 0;
+ pd->audiobuf = NULL;
+
+ /* FIXME: shouldn't this test a specific flag? */
+ if (verbose) {
+ tc_log_info(MOD_NAME, "%s %s", MOD_VERSION, MOD_CAP);
+ if (verbose & TC_INFO) {
+ char *id, *copyright;
+ faacEncGetVersion(&id, &copyright);
+ tc_log_info(MOD_NAME, "Using FAAC %s", id);
+ }
+ }
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * faac_configure: Configure this instance of the module. See
+ * tcmodule-data.h for function details.
+ */
+
+static int faac_configure(TCModuleInstance *self,
+ const char *options, vob_t *vob)
+{
+ PrivateData *pd;
+ int samplerate = vob->mp3frequency ? vob->mp3frequency : vob->a_rate;
+ int ret;
+ unsigned long dummy;
+ faacEncConfiguration conf;
+
+ TC_MODULE_SELF_CHECK(self, "configure");
+
+ pd = self->userdata;
+
+ /* Save bytes per sample */
+ pd->bps = (vob->dm_chan * vob->dm_bits) / 8;
+
+ /* Create FAAC handle (freeing any old one that might be left over) */
+ if (pd->handle)
+ faacEncClose(pd->handle);
+ pd->handle = faacEncOpen(samplerate, vob->dm_chan, &pd->framesize, &dummy);
+ if (!pd->handle) {
+ tc_log_error(MOD_NAME, "FAAC initialization failed");
+ return TC_ERROR;
+ }
+
+ /* Set up our default audio parameters */
+ /* why can't just use a pointer here? -- FR */
+ /* Because the function returns a pointer to an internal buffer --AC */
+ conf = *faacEncGetCurrentConfiguration(pd->handle);
+ conf.mpegVersion = MPEG4;
+ conf.aacObjectType = MAIN;
+ conf.allowMidside = 1;
+ conf.useLfe = 0;
+ conf.useTns = 1;
+ conf.bitRate = vob->mp3bitrate / vob->dm_chan;
+ conf.bandWidth = 0; // automatic configuration
+ conf.quantqual = 100; // FIXME: quality should be a per-module setting
+ conf.outputFormat = 1;
+ if (vob->dm_bits != 16) {
+ tc_log_error(MOD_NAME, "Only 16-bit samples supported");
+ return TC_ERROR;
+ }
+ conf.inputFormat = FAAC_INPUT_16BIT;
+ conf.shortctl = SHORTCTL_NORMAL;
+
+ ret = optstr_get(options, "quality", "%li", &conf.quantqual);
+ if (ret >= 0) {
+ if (verbose >= TC_INFO) {
+ tc_log_info(MOD_NAME, "using quality=%li", conf.quantqual);
+ }
+ }
+
+ if (!faacEncSetConfiguration(pd->handle, &conf)) {
+ tc_log_error(MOD_NAME, "Failed to set FAAC configuration");
+ faacEncClose(pd->handle);
+ pd->handle = 0;
+ return TC_ERROR;
+ }
+
+ /* Allocate local audio buffer */
+ if (pd->audiobuf)
+ free(pd->audiobuf);
+ pd->audiobuf = tc_malloc(pd->framesize * pd->bps);
+ if (!pd->audiobuf) {
+ tc_log_error(MOD_NAME, "Unable to allocate audio buffer");
+ faacEncClose(pd->handle);
+ pd->handle = 0;
+ return TC_ERROR;
+ }
+
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * faac_inspect: Return the value of an option in this instance of the
+ * module. See tcmodule-data.h for function details.
+ */
+
+static int faac_inspect(TCModuleInstance *self,
+ const char *param, const char **value)
+{
+ static char buf[TC_BUF_MAX];
+
+ TC_MODULE_SELF_CHECK(self, "inspect");
+ TC_MODULE_SELF_CHECK(param, "inspect");
+
+ if (optstr_lookup(param, "help")) {
+ tc_snprintf(buf, sizeof(buf),
+ "Overview:\n"
+ " Encodes audio to AAC using the FAAC library.\n"
+ "Options:\n"
+ " quality: set encoder quality [0-100]\n");
+ *value = buf;
+ }
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * faac_stop: Reset this instance of the module. See tcmodule-data.h for
+ * function details.
+ */
+
+static int faac_stop(TCModuleInstance *self)
+{
+ PrivateData *pd;
+
+ TC_MODULE_SELF_CHECK(self, "stop");
+
+ pd = self->userdata;
+
+ if (pd->handle) {
+ faacEncClose(pd->handle);
+ pd->handle = NULL;
+ }
+
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * faac_fini: Clean up after this instance of the module. See
+ * tcmodule-data.h for function details.
+ */
+
+static int faac_fini(TCModuleInstance *self)
+{
+ TC_MODULE_SELF_CHECK(self, "fini");
+
+ faac_stop(self);
+ tc_free(self->userdata);
+ self->userdata = NULL;
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * faac_encode: Encode a frame of data. See tcmodule-data.h for
+ * function details.
+ */
+
+static int faac_encode(TCModuleInstance *self,
+ aframe_list_t *in, aframe_list_t *out)
+{
+ PrivateData *pd;
+ uint8_t *inptr;
+ int nsamples;
+
+ TC_MODULE_SELF_CHECK(self, "encode");
+
+ pd = self->userdata;
+
+ if (in) {
+ inptr = in->audio_buf;
+ nsamples = in->audio_size / pd->bps;
+ } else {
+ inptr = NULL;
+ nsamples = 0;
+ }
+ out->audio_len = 0;
+
+ while (pd->audiobuf_len + nsamples >= pd->framesize) {
+ int res;
+ const int tocopy = (pd->framesize - pd->audiobuf_len) * pd->bps;
+ ac_memcpy(pd->audiobuf + pd->audiobuf_len*pd->bps, inptr, tocopy);
+ inptr += tocopy;
+ nsamples -= tocopy / pd->bps;
+ pd->audiobuf_len = 0;
+ res = faacEncEncode(pd->handle, (int32_t *)pd->audiobuf, pd->framesize,
+ out->audio_buf + out->audio_len,
+ out->audio_size - out->audio_len);
+ if (res > out->audio_size - out->audio_len) {
+ tc_log_error(MOD_NAME,
+ "Output buffer overflow! Try a lower bitrate.");
+ return TC_ERROR;
+ }
+ out->audio_len += res;
+ }
+
+ if (nsamples > 0) {
+ ac_memcpy(pd->audiobuf + pd->audiobuf_len*pd->bps, inptr,
+ nsamples*pd->bps);
+ pd->audiobuf_len += nsamples;
+ }
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+static const TCCodecID faac_codecs_in[] = { TC_CODEC_PCM, TC_CODEC_ERROR };
+static const TCCodecID faac_codecs_out[] = { TC_CODEC_AAC, TC_CODEC_ERROR };
+TC_MODULE_CODEC_FORMATS(faac);
+
+TC_MODULE_INFO(faac);
+
+static const TCModuleClass faac_class = {
+ TC_MODULE_CLASS_HEAD(faac),
+
+ .init = faac_init,
+ .fini = faac_fini,
+ .configure = faac_configure,
+ .stop = faac_stop,
+ .inspect = faac_inspect,
+
+ .encode_audio = faac_encode,
+};
+
+TC_MODULE_ENTRY_POINT(faac);
+
+/*************************************************************************/
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * c-file-offsets: ((case-label . *) (statement-case-intro . *))
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+ */
diff --git a/debian/transcode/transcode-1.1.7/encode/encode_lame.c b/debian/transcode/transcode-1.1.7/encode/encode_lame.c
new file mode 100644
index 00000000..7d32529c
--- /dev/null
+++ b/debian/transcode/transcode-1.1.7/encode/encode_lame.c
@@ -0,0 +1,456 @@
+/*
+ * encode_lame.c - encode audio frames using lame
+ * Written by Andrew Church <achurch@achurch.org>
+ *
+ * This file is part of transcode, a video stream processing tool.
+ * transcode is free software, distributable under the terms of the GNU
+ * General Public License (version 2 or later). See the file COPYING
+ * for details.
+ */
+
+#include "transcode.h"
+#include "libtc/libtc.h"
+#include "libtc/optstr.h"
+#include "libtc/tcmodule-plugin.h"
+
+#include <lame/lame.h>
+
+#define MOD_NAME "encode_lame.so"
+#define MOD_VERSION "v1.1 (2006-11-01)"
+#define MOD_CAP "Encodes audio to MP3 using LAME"
+#define MOD_AUTHOR "Andrew Church"
+
+#define MOD_FEATURES \
+ TC_MODULE_FEATURE_ENCODE|TC_MODULE_FEATURE_AUDIO
+
+#define MOD_FLAGS \
+ TC_MODULE_FLAG_RECONFIGURABLE
+
+
+/*************************************************************************/
+
+/* Local data structure: */
+
+typedef struct {
+ lame_global_flags *lgf;
+ int bps; /* bytes per sample */
+ int channels;
+ int flush_flag;
+} PrivateData;
+
+/*************************************************************************/
+
+/**
+ * lame_log_error, lame_log_msg, lame_log_debug: Internal logging
+ * functions for LAME.
+ *
+ * Parameters:
+ * format: Log message format string.
+ * args: Log message format arguments.
+ * Return value:
+ * None.
+ */
+
+static void lame_log_error(const char *format, va_list args)
+{
+ char buf[TC_BUF_MAX];
+ tc_vsnprintf(buf, sizeof(buf), format, args);
+ tc_log_error(MOD_NAME, "%s", buf);
+}
+
+static void lame_log_msg(const char *format, va_list args)
+{
+ if (verbose & TC_INFO) {
+ char buf[TC_BUF_MAX];
+ tc_vsnprintf(buf, sizeof(buf), format, args);
+ tc_log_info(MOD_NAME, "%s", buf);
+ }
+}
+
+static void lame_log_debug(const char *format, va_list args)
+{
+ if (verbose & TC_DEBUG) {
+ char buf[TC_BUF_MAX];
+ tc_vsnprintf(buf, sizeof(buf), format, args);
+ tc_log_msg(MOD_NAME, "%s", buf);
+ }
+}
+
+/*************************************************************************/
+/*************************************************************************/
+
+/* Module interface routines and data. */
+
+/*************************************************************************/
+
+/**
+ * lamemod_init: Initialize this instance of the module. See
+ * tcmodule-data.h for function details. Note the name of this function--
+ * we don't want to conflict with libmp3lame's lame_init().
+ */
+
+static int lamemod_init(TCModuleInstance *self, uint32_t features)
+{
+ PrivateData *pd;
+
+ TC_MODULE_SELF_CHECK(self, "init");
+ TC_MODULE_INIT_CHECK(self, MOD_FEATURES, features);
+
+ self->userdata = pd = tc_malloc(sizeof(PrivateData));
+ if (!pd) {
+ tc_log_error(MOD_NAME, "init: out of memory!");
+ return TC_ERROR;
+ }
+ pd->lgf = NULL;
+
+ /* FIXME: shouldn't this test a specific flag? */
+ if (verbose) {
+ tc_log_info(MOD_NAME, "%s %s", MOD_VERSION, MOD_CAP);
+ if (verbose & TC_INFO)
+ tc_log_info(MOD_NAME, "Using LAME %s", get_lame_version());
+ }
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * lame_configure: Configure this instance of the module. See
+ * tcmodule-data.h for function details.
+ */
+
+static int lame_configure(TCModuleInstance *self,
+ const char *options, vob_t *vob)
+{
+ PrivateData *pd;
+ int samplerate = vob->mp3frequency ? vob->mp3frequency : vob->a_rate;
+ int quality;
+ MPEG_mode mode;
+
+ TC_MODULE_SELF_CHECK(self, "configure");
+ pd = self->userdata;
+
+ pd->flush_flag = vob->encoder_flush;
+ /* Save bytes per sample */
+ pd->bps = (vob->dm_chan * vob->dm_bits) / 8;
+ /* And audio channels */
+ pd->channels = vob->dm_chan;
+
+ /* Create LAME object (freeing any old one that might be left over) */
+ if (pd->lgf)
+ lame_close(pd->lgf);
+ pd->lgf = lame_init();
+ if (!pd->lgf) {
+ tc_log_error(MOD_NAME, "LAME initialization failed");
+ return TC_ERROR;
+ }
+
+ /* Set up logging functions (assume no failure) */
+ lame_set_errorf(pd->lgf, lame_log_error);
+ lame_set_msgf (pd->lgf, lame_log_msg );
+ lame_set_debugf(pd->lgf, lame_log_debug);
+
+ /* Set up audio parameters */
+ if (vob->dm_bits != 16) {
+ tc_log_error(MOD_NAME, "Only 16-bit samples supported");
+ return TC_ERROR;
+ }
+ if (lame_set_in_samplerate(pd->lgf, samplerate) < 0) {
+ tc_log_error(MOD_NAME, "lame_set_in_samplerate(%d) failed",samplerate);
+ return TC_ERROR;
+ }
+ if (lame_set_num_channels(pd->lgf, pd->channels) < 0) {
+ tc_log_error(MOD_NAME, "lame_set_num_channels(%d) failed",
+ pd->channels);
+ return TC_ERROR;
+ }
+ if (lame_set_scale(pd->lgf, vob->volume) < 0) {
+ tc_log_error(MOD_NAME, "lame_set_scale(%f) failed", vob->volume);
+ return TC_ERROR;
+ }
+ if (lame_set_bWriteVbrTag(pd->lgf, (vob->a_vbr!=0)) < 0) {
+ tc_log_error(MOD_NAME, "lame_set_bWriteVbrTag(%d) failed",
+ (vob->a_vbr!=0));
+ return TC_ERROR;
+ }
+ quality = (int)TC_CLAMP(vob->mp3quality, 0.0, 9.0);
+ if (lame_set_quality(pd->lgf, quality) < 0) {
+ tc_log_error(MOD_NAME, "lame_set_quality(%d) failed", quality);
+ return TC_ERROR;
+ }
+ switch (vob->mp3mode) {
+ case 0: mode = JOINT_STEREO; break;
+ case 1: mode = STEREO; break;
+ case 2: mode = MONO; break;
+ default:
+ tc_log_warn(MOD_NAME,"Invalid audio mode, defaulting to joint stereo");
+ mode = JOINT_STEREO;
+ break;
+ }
+ /* FIXME: add coherency check with given audio channels? */
+ if (lame_set_mode(pd->lgf, mode) < 0) {
+ tc_log_error(MOD_NAME, "lame_set_mode(%d) failed", mode);
+ return TC_ERROR;
+ }
+ if (lame_set_brate(pd->lgf, vob->mp3bitrate) < 0) {
+ tc_log_error(MOD_NAME, "lame_set_brate(%d) failed", vob->mp3bitrate);
+ return TC_ERROR;
+ }
+ /* Ugly preset handling */
+ if (vob->lame_preset) {
+ preset_mode preset;
+ int fast = 0;
+ char *s = strchr(vob->lame_preset, ',');
+ if (s) {
+ *s++ = 0;
+ if (strcmp(s, "fast") == 0)
+ fast = 1;
+ }
+ if (strcmp(vob->lame_preset, "standard") == 0) {
+ preset = (fast ? STANDARD_FAST : STANDARD);
+ vob->a_vbr = 1;
+ } else if (strcmp(vob->lame_preset, "medium") == 0) {
+ preset = (fast ? MEDIUM_FAST : MEDIUM);
+ vob->a_vbr = 1;
+ } else if (strcmp(vob->lame_preset, "extreme") == 0) {
+ preset = (fast ? EXTREME_FAST : EXTREME);
+ vob->a_vbr = 1;
+ } else if (strcmp(vob->lame_preset, "insane") == 0) {
+ preset = INSANE;
+ vob->a_vbr = 1;
+ } else {
+ preset = strtol(vob->lame_preset, &s, 10);
+ if (*s || preset < 8 || preset > 320) {
+ tc_log_error(MOD_NAME, "Invalid preset \"%s\"",
+ vob->lame_preset);
+ return TC_ERROR;
+ } else {
+ vob->a_vbr = 1;
+ }
+ }
+ if (lame_set_preset(pd->lgf, preset) < 0) {
+ tc_log_error(MOD_NAME, "lame_set_preset(%d) failed", preset);
+ return TC_ERROR;
+ }
+ } // if (vob->lame_preset)
+ /* Acceleration setting failures aren't fatal */
+ if (lame_set_asm_optimizations(pd->lgf, MMX, (tc_accel&AC_MMX )?1:0) < 0)
+ tc_log_warn(MOD_NAME, "lame_set_asm_optimizations(MMX,%d) failed",
+ (tc_accel&AC_MMX)?1:0);
+ if (lame_set_asm_optimizations(pd->lgf, AMD_3DNOW,
+ (tc_accel&AC_3DNOW)?1:0) < 0)
+ tc_log_warn(MOD_NAME, "lame_set_asm_optimizations(3DNOW,%d) failed",
+ (tc_accel&AC_3DNOW)?1:0);
+ if (lame_set_asm_optimizations(pd->lgf, SSE, (tc_accel&AC_SSE )?1:0) < 0)
+ tc_log_warn(MOD_NAME, "lame_set_asm_optimizations(SSE,%d) failed",
+ (tc_accel&AC_SSE)?1:0);
+ /* FIXME: this function is documented as "for testing only"--should we
+ * really expose it to the user? */
+ if (!vob->bitreservoir && lame_set_disable_reservoir(pd->lgf, 1) < 0) {
+ tc_log_error(MOD_NAME, "lame_set_disable_reservoir(1) failed");
+ return TC_ERROR;
+ }
+ if (lame_set_VBR(pd->lgf, vob->a_vbr ? vbr_default : vbr_off) < 0) {
+ tc_log_error(MOD_NAME, "lame_set_VBR(%d) failed",
+ vob->a_vbr ? vbr_default : vbr_off);
+ return TC_ERROR;
+ }
+ if (vob->a_vbr) {
+ /* FIXME: we should have a separate VBR quality control */
+ if (lame_set_VBR_q(pd->lgf, quality) < 0) {
+ tc_log_error(MOD_NAME, "lame_set_VBR_q(%d) failed", quality);
+ return TC_ERROR;
+ }
+ }
+
+ /* Initialize encoder */
+ if (lame_init_params(pd->lgf) < 0) {
+ tc_log_error(MOD_NAME, "lame_init_params() failed");
+ return TC_ERROR;
+ }
+
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * lame_inspect: Return the value of an option in this instance of the
+ * module. See tcmodule-data.h for function details.
+ */
+
+static int lame_inspect(TCModuleInstance *self,
+ const char *param, const char **value)
+{
+ static char buf[TC_BUF_MAX];
+
+ TC_MODULE_SELF_CHECK(self, "inspect");
+ TC_MODULE_SELF_CHECK(param, "inspect");
+
+ if (optstr_lookup(param, "help")) {
+ tc_snprintf(buf, sizeof(buf),
+ "Overview:\n"
+ " Encodes audio to MP3 using the LAME library.\n"
+ "No options available.\n");
+ *value = buf;
+ }
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * lame_stop: Reset this instance of the module. See tcmodule-data.h for
+ * function details.
+ */
+
+static int lame_stop(TCModuleInstance *self)
+{
+ PrivateData *pd;
+
+ TC_MODULE_SELF_CHECK(self, "stop");
+
+ pd = self->userdata;
+
+ if (pd->lgf) {
+ lame_close(pd->lgf);
+ pd->lgf = NULL;
+ }
+
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * lame_fini: Clean up after this instance of the module. See
+ * tcmodule-data.h for function details.
+ */
+
+static int lame_fini(TCModuleInstance *self)
+{
+ TC_MODULE_SELF_CHECK(self, "fini");
+
+ lame_stop(self);
+ tc_free(self->userdata);
+ self->userdata = NULL;
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * lame_encode: Encode a frame of data. See tcmodule-data.h for
+ * function details.
+ */
+
+#define LAME_FLUSH_BUFFER_SIZE 7200 /* from lame/lame.h */
+
+static int lame_encode(TCModuleInstance *self,
+ aframe_list_t *in, aframe_list_t *out)
+{
+ PrivateData *pd;
+ int res;
+
+ TC_MODULE_SELF_CHECK(self, "encode");
+ if (out == NULL) {
+ tc_log_error(MOD_NAME, "no output buffer supplied");
+ return TC_ERROR;
+ }
+
+ pd = self->userdata;
+
+ if (in == NULL) {
+ /* flush request */
+ if (!pd->flush_flag) {
+ /* No-flush option given, so don't do anything */
+ out->audio_len = 0;
+ return TC_OK;
+ }
+ if (out->audio_size < LAME_FLUSH_BUFFER_SIZE) {
+ /* paranoia is a virtue */
+ tc_log_error(MOD_NAME, "output buffer too small for"
+ " flushing (%i|%i)",
+ out->audio_size,
+ LAME_FLUSH_BUFFER_SIZE);
+ return TC_ERROR;
+ }
+
+ /*
+ * Looks like _nogap should behave better when
+ * splitting/rotating output files.
+ * Moreover, our streams should'nt contain any ID3 tag,
+ * -- FR
+ */
+ res = lame_encode_flush_nogap(pd->lgf, out->audio_buf, 0);
+ if (verbose & TC_DEBUG) {
+ tc_log_info(MOD_NAME, "flushing %d audio bytes", res);
+ }
+ } else {
+ /* regular encoding */
+ if (pd->channels == 1) { /* mono */
+ res = lame_encode_buffer(pd->lgf,
+ (short *)(in->audio_buf),
+ (short *)(in->audio_buf),
+ in->audio_size / pd->bps,
+ out->audio_buf,
+ out->audio_size);
+ } else { /* all stereo flavours */
+ res = lame_encode_buffer_interleaved(pd->lgf,
+ (short *)in->audio_buf,
+ in->audio_size / pd->bps,
+ out->audio_buf,
+ out->audio_size);
+ }
+
+ if (res < 0) {
+ if (verbose & TC_DEBUG) {
+ tc_log_error(MOD_NAME, "lame_encode_buffer_interleaved() failed"
+ " (%d: %s)", res,
+ res==-1 ? "output buffer overflow" :
+ res==-2 ? "out of memory" :
+ res==-3 ? "not initialized" :
+ res==-4 ? "psychoacoustic problems" : "unknown");
+ } else {
+ tc_log_error(MOD_NAME, "Audio encoding failed!");
+ }
+ return TC_ERROR;
+ }
+ }
+ out->audio_len = res;
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+static const TCCodecID lame_codecs_in[] = { TC_CODEC_PCM, TC_CODEC_ERROR };
+static const TCCodecID lame_codecs_out[] = { TC_CODEC_MP3, TC_CODEC_ERROR };
+TC_MODULE_CODEC_FORMATS(lame);
+
+TC_MODULE_INFO(lame);
+
+static const TCModuleClass lame_class = {
+ TC_MODULE_CLASS_HEAD(lame),
+
+ .init = lamemod_init,
+ .fini = lame_fini,
+ .configure = lame_configure,
+ .stop = lame_stop,
+ .inspect = lame_inspect,
+
+ .encode_audio = lame_encode,
+};
+
+TC_MODULE_ENTRY_POINT(lame);
+
+/*************************************************************************/
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * c-file-offsets: ((case-label . *) (statement-case-intro . *))
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+ */
diff --git a/debian/transcode/transcode-1.1.7/encode/encode_lavc.c b/debian/transcode/transcode-1.1.7/encode/encode_lavc.c
new file mode 100644
index 00000000..4d8eb0d6
--- /dev/null
+++ b/debian/transcode/transcode-1.1.7/encode/encode_lavc.c
@@ -0,0 +1,1553 @@
+/*
+ * encode_lavc.c -- encode A/V frames using libavcodec.
+ * (C) 2007-2010 Francesco Romani <fromani at gmail dot com>
+ *
+ * This file is part of transcode, a video stream processing tool.
+ *
+ * transcode is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * transcode is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "transcode.h"
+#include "framebuffer.h"
+#include "filter.h"
+
+#include "aclib/imgconvert.h"
+
+#include "libtc/optstr.h"
+#include "libtc/cfgfile.h"
+#include "libtc/ratiocodes.h"
+#include "libtc/tcframes.h"
+
+#include "libtc/tcmodule-plugin.h"
+
+#include "libtc/tcavcodec.h"
+
+#include <math.h>
+
+#define MOD_NAME "encode_lavc.so"
+#define MOD_VERSION "v0.0.7 (2007-10-27)"
+#define MOD_CAP "libavcodec based encoder (" LIBAVCODEC_IDENT ")"
+
+#define MOD_FEATURES \
+ TC_MODULE_FEATURE_ENCODE|TC_MODULE_FEATURE_VIDEO
+
+#define MOD_FLAGS \
+ TC_MODULE_FLAG_RECONFIGURABLE
+
+#define LAVC_CONFIG_FILE "lavc.cfg"
+#define PSNR_LOG_FILE "psnr.log"
+
+static const char tc_lavc_help[] = ""
+ "Overview:\n"
+ " this module uses libavcodec to encode given raw frames in\n"
+ " an huge variety of compressed formats, both audio and video.\n"
+ "Options:\n"
+ " help produce module overview and options explanations\n"
+ " list log out a list of supported A/V codecs\n";
+
+
+
+typedef struct tclavcconfigdata_ TCLavcConfigData;
+struct tclavcconfigdata_ {
+ int thread_count;
+
+ /*
+ * following options can't be sect directly on AVCodeContext,
+ * we need some buffering and translation.
+ */
+ int vrate_tolerance;
+ int rc_min_rate;
+ int rc_max_rate;
+ int rc_buffer_size;
+ int lmin;
+ int lmax;
+ int me_method;
+
+ /* same as above for flags */
+ struct {
+ uint32_t mv0;
+ uint32_t cbp;
+ uint32_t qpel;
+ uint32_t alt;
+ uint32_t vdpart;
+ uint32_t naq;
+ uint32_t ilme;
+ uint32_t ildct;
+ uint32_t aic;
+ uint32_t aiv;
+ uint32_t umv;
+ uint32_t psnr;
+ uint32_t trell;
+ uint32_t gray;
+ uint32_t v4mv;
+ uint32_t closedgop;
+ } flags;
+
+ /*
+ * special flags: flags that triggers more than a setting
+ * FIXME: not yet supported
+ */
+ int turbo_setup;
+};
+
+typedef struct tclavcprivatedata_ TCLavcPrivateData;
+
+/* this is to reduce if()s in out encode_video() */
+typedef void (*PreEncodeVideoFn)(struct tclavcprivatedata_ *pd,
+ vframe_list_t *vframe);
+
+struct tclavcprivatedata_ {
+ int vcodec_id;
+ TCCodecID tc_pix_fmt;
+
+ AVFrame ff_venc_frame;
+ AVCodecContext ff_vcontext;
+
+ AVCodec *ff_vcodec;
+
+ TCLavcConfigData confdata;
+
+ struct {
+ int active;
+ int top_first;
+ } interlacing;
+
+ uint16_t inter_matrix[TC_MATRIX_SIZE];
+ uint16_t intra_matrix[TC_MATRIX_SIZE];
+
+ FILE *stats_file;
+ FILE *psnr_file;
+
+ vframe_list_t *vframe_buf;
+ /* for colorspace conversions in prepare functions */
+ PreEncodeVideoFn pre_encode_video;
+
+ int flush_flag;
+};
+
+/*************************************************************************/
+
+static const TCCodecID tc_lavc_codecs_in[] = {
+ TC_CODEC_YUV420P, TC_CODEC_YUV422P, TC_CODEC_RGB,
+ TC_CODEC_ERROR
+};
+
+
+
+#define FF_VCODEC_ID(pd) (tc_lavc_internal_codecs[(pd)->vcodec_id])
+#define TC_VCODEC_ID(pd) (tc_lavc_codecs_out[(pd)->vcodec_id])
+
+/* WARNING: the two arrays below MUST BE KEPT SYNCHRONIZED! */
+
+static const TCCodecID tc_lavc_codecs_out[] = {
+ TC_CODEC_MPEG1VIDEO, TC_CODEC_MPEG2VIDEO, TC_CODEC_MPEG4VIDEO,
+ TC_CODEC_H263I, TC_CODEC_H263P,
+ TC_CODEC_H264,
+ TC_CODEC_WMV1, TC_CODEC_WMV2,
+ TC_CODEC_RV10,
+ TC_CODEC_HUFFYUV, TC_CODEC_FFV1,
+ TC_CODEC_DV,
+ TC_CODEC_MJPEG, TC_CODEC_LJPEG,
+ TC_CODEC_MP42, TC_CODEC_MP43,
+ TC_CODEC_ERROR
+};
+
+static const enum CodecID tc_lavc_internal_codecs[] = {
+ CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO, CODEC_ID_MPEG4,
+ CODEC_ID_H263I, CODEC_ID_H263P,
+ CODEC_ID_H264,
+ CODEC_ID_WMV1, CODEC_ID_WMV2,
+ CODEC_ID_RV10,
+ CODEC_ID_HUFFYUV, CODEC_ID_FFV1,
+ CODEC_ID_DVVIDEO,
+ CODEC_ID_MJPEG, CODEC_ID_LJPEG,
+ CODEC_ID_MSMPEG4V2, CODEC_ID_MSMPEG4V3,
+ CODEC_ID_NONE
+};
+
+static const TCFormatID tc_lavc_formats[] = { TC_FORMAT_ERROR };
+
+
+/*************************************************************************/
+
+/*
+ * following helper private functions adapt stuff and do proper
+ * colorspace conversion, if needed, preparing data for
+ * later real encoding
+ */
+
+/*
+ * pre_encode_video_yuv420p:
+ * pre_encode_video_yuv420p_huffyuv:
+ * pre_encode_video_yuv422p:
+ * pre_encode_video_yuv422p_huffyuv:
+ * pre_encode_video_rgb24:
+ * prepare internal structures for actual encoding, doing
+ * colorspace conversion and/or any needed adaptation.
+ *
+ * Parameters:
+ * pd: pointer to private module dataure
+ * vframe: pointer to *SOURCE* video data frame
+ * Return Value:
+ * none
+ * Preconditions:
+ * module initialized and configured;
+ * auxiliariy buffer space already allocated if needed
+ * (pix fmt != yuv420p)
+ * Postconditions:
+ * video data ready to be encoded through lavc.
+ */
+
+static void pre_encode_video_yuv420p(TCLavcPrivateData *pd,
+ vframe_list_t *vframe)
+{
+ avpicture_fill((AVPicture *)&pd->ff_venc_frame, vframe->video_buf,
+ PIX_FMT_YUV420P,
+ pd->ff_vcontext.width, pd->ff_vcontext.height);
+}
+
+
+static void pre_encode_video_yuv420p_huffyuv(TCLavcPrivateData *pd,
+ vframe_list_t *vframe)
+{
+ uint8_t *src[3] = { NULL, NULL, NULL };
+
+ YUV_INIT_PLANES(src, vframe->video_buf,
+ IMG_YUV_DEFAULT,
+ pd->ff_vcontext.width, pd->ff_vcontext.height);
+ avpicture_fill((AVPicture *)&pd->ff_venc_frame, pd->vframe_buf->video_buf,
+ PIX_FMT_YUV422P,
+ pd->ff_vcontext.width, pd->ff_vcontext.height);
+ ac_imgconvert(src, IMG_YUV_DEFAULT,
+ pd->ff_venc_frame.data, IMG_YUV422P,
+ pd->ff_vcontext.width, pd->ff_vcontext.height);
+}
+
+static void pre_encode_video_yuv422p(TCLavcPrivateData *pd,
+ vframe_list_t *vframe)
+{
+ uint8_t *src[3] = { NULL, NULL, NULL };
+
+ YUV_INIT_PLANES(src, vframe->video_buf,
+ IMG_YUV422P,
+ pd->ff_vcontext.width, pd->ff_vcontext.height);
+ avpicture_fill((AVPicture *)&pd->ff_venc_frame, pd->vframe_buf->video_buf,
+ PIX_FMT_YUV420P,
+ pd->ff_vcontext.width, pd->ff_vcontext.height);
+ ac_imgconvert(src, IMG_YUV422P,
+ pd->ff_venc_frame.data, IMG_YUV420P,
+ pd->ff_vcontext.width, pd->ff_vcontext.height);
+}
+
+
+static void pre_encode_video_yuv422p_huffyuv(TCLavcPrivateData *pd,
+ vframe_list_t *vframe)
+{
+ avpicture_fill((AVPicture *)&pd->ff_venc_frame, vframe->video_buf,
+ PIX_FMT_YUV422P,
+ pd->ff_vcontext.width, pd->ff_vcontext.height);
+
+}
+
+
+static void pre_encode_video_rgb24(TCLavcPrivateData *pd,
+ vframe_list_t *vframe)
+{
+ avpicture_fill((AVPicture *)&pd->ff_venc_frame, pd->vframe_buf->video_buf,
+ PIX_FMT_YUV420P,
+ pd->ff_vcontext.width, pd->ff_vcontext.height);
+ ac_imgconvert(&vframe->video_buf, IMG_RGB_DEFAULT,
+ pd->ff_venc_frame.data, IMG_YUV420P,
+ pd->ff_vcontext.width, pd->ff_vcontext.height);
+}
+
+
+
+/*************************************************************************/
+
+/* more helpers */
+
+/*
+ * tc_codec_is_supported:
+ * scan the module supported output codec looking for given one.
+ *
+ * Parameters:
+ * codec: codec id to check against supported codec list.
+ * Return Value:
+ * >= 0: index of codec, if supported, in output list
+ * TC_NULL_MATCH: given codec isn't supported.
+ */
+static int tc_codec_is_supported(TCCodecID codec)
+{
+ int i = 0, ret = TC_NULL_MATCH;
+
+ for (i = 0; tc_lavc_codecs_out[i] != TC_CODEC_ERROR; i++) {
+ if (codec == tc_lavc_codecs_out[i]) {
+ ret = i;
+ break;
+ }
+ }
+ return ret;
+}
+
+#if !defined(INFINITY) && defined(HUGE_VAL)
+#define INFINITY HUGE_VAL
+#endif
+
+/*
+ * psnr:
+ * compute the psnr value of given data.
+ *
+ * Parameters:
+ * d: value to be computed
+ * Return value:
+ * psnr of `d'
+ */
+static double psnr(double d) {
+ if (d == 0) {
+ return INFINITY;
+ }
+ return -10.0 * log(d) / log(10);
+}
+
+/*
+ * tc_lavc_list_codecs:
+ * (NOT Thread safe. But do anybody cares since
+ * transcode encoder(.c) is single-threaded today
+ * and in any foreseable future?)
+ * return a buffer listing all supported codecs with
+ * respective name and short description.
+ *
+ * Parameters:
+ * None
+ * Return Value:
+ * Read-only pointer to a char buffer holding the
+ * description data. Buffer is guaranted valid
+ * at least until next call of this function.
+ * You NEVER need to tc_free() the pointer.
+ */
+static const char* tc_lavc_list_codecs(void)
+{
+ /* XXX: I feel a bad taste */
+ static char buf[TC_BUF_MAX];
+ static int ready = TC_FALSE;
+
+ if (!ready) {
+ size_t used = 0;
+ int i = 0;
+
+ for (i = 0; tc_lavc_codecs_out[i] != TC_CODEC_ERROR; i++) {
+ char sbuf[TC_BUF_MIN];
+ size_t slen = 0;
+
+ tc_snprintf(sbuf, sizeof(sbuf), "%15s: %s\n",
+ tc_codec_to_string(tc_lavc_codecs_out[i]),
+ tc_codec_to_comment(tc_lavc_codecs_out[i]));
+ slen = strlen(sbuf);
+ if (used + slen <= sizeof(buf)) {
+ strlcpy(buf + used, sbuf, sizeof(buf) - used);
+ used += slen;
+ /* chomp final '\0' except for first round */
+ } else {
+ tc_log_error(MOD_NAME, "too much codecs! this should happen. "
+ "Please file a bug report.");
+ strlcpy(buf, "internal error", sizeof(buf));
+ }
+ }
+ ready = TC_TRUE;
+ }
+ return buf;
+}
+
+
+/*
+ * tc_lavc_read_matrices:
+ * read and fill internal (as in internal module data)
+ * custom quantization matrices from data stored on
+ * disk files, using given paths, then passes them
+ * to libavcodec for usage in encoders if loading was
+ * succesfull.
+ *
+ * Parameters:
+ * pd: pointer to module private data to use.
+ * intra_matrix_file: path of file containing intra matrix data.
+ * inter_matrix_file: path of file containing inter matrix data.
+ * Return Value:
+ * None
+ * Side Effects:
+ * 0-2 files on disk are opend, read, closed
+ */
+static void tc_lavc_read_matrices(TCLavcPrivateData *pd,
+ const char *intra_matrix_file,
+ const char *inter_matrix_file)
+{
+ if (intra_matrix_file != NULL && strlen(intra_matrix_file) > 0) {
+ /* looks like we've got something... */
+ int ret = tc_read_matrix(intra_matrix_file, NULL, pd->inter_matrix);
+ if (ret == 0) {
+ /* ok, let's give this to lavc */
+ pd->ff_vcontext.intra_matrix = pd->inter_matrix;
+ } else {
+ tc_log_warn(MOD_NAME, "error while reading intra matrix from"
+ " %s", intra_matrix_file);
+ pd->ff_vcontext.intra_matrix = NULL; /* paranoia */
+ }
+ }
+
+ if (inter_matrix_file != NULL && strlen(inter_matrix_file) > 0) {
+ /* looks like we've got something... */
+ int ret = tc_read_matrix(inter_matrix_file, NULL, pd->inter_matrix);
+ if (ret == 0) {
+ /* ok, let's give this to lavc */
+ pd->ff_vcontext.inter_matrix = pd->inter_matrix;
+ } else {
+ tc_log_warn(MOD_NAME, "error while reading inter matrix from"
+ " %s", inter_matrix_file);
+ pd->ff_vcontext.inter_matrix = NULL; /* paranoia */
+ }
+ }
+}
+
+/*
+ * tc_lavc_load_filters:
+ * request to transcode core filters needed by given parameters.
+ *
+ * Parameters:
+ * pd: pointer to module private data.
+ * Return Value:
+ * None.
+ */
+static void tc_lavc_load_filters(TCLavcPrivateData *pd)
+{
+ if (TC_VCODEC_ID(pd) == TC_CODEC_MJPEG
+ || TC_VCODEC_ID(pd) == TC_CODEC_LJPEG) {
+ int handle;
+
+ tc_log_info(MOD_NAME, "output is mjpeg or ljpeg, extending range from "
+ "YUV420P to YUVJ420P (full range)");
+
+ handle = tc_filter_add("levels", "input=16-240");
+ if (!handle) {
+ tc_log_warn(MOD_NAME, "cannot load levels filter");
+ }
+ }
+}
+
+/*************************************************************************/
+/* PSNR-log stuff */
+
+#define PSNR_REQUESTED(PD) ((PD)->confdata.flags.psnr)
+
+/*
+ * psnr_open:
+ * open psnr log file and prepare internal data to write out
+ * PSNR stats
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * Return Value:
+ * TC_OK: succesfull (log file open and avalaible and so on)
+ * TC_ERROR: otherwise
+ */
+static int psnr_open(TCLavcPrivateData *pd)
+{
+ pd->psnr_file = NULL;
+
+ pd->psnr_file = fopen(PSNR_LOG_FILE, "w");
+ if (pd->psnr_file != NULL) {
+ /* add a little reminder */
+ fprintf(pd->psnr_file, "# Num Qual Size Y U V Tot Type");
+ } else {
+ tc_log_warn(MOD_NAME, "can't open psnr log file '%s'",
+ PSNR_LOG_FILE);
+ return TC_ERROR;
+ }
+ return TC_OK;
+}
+
+#define PFRAME(PD) ((PD)->ff_vcontext.coded_frame)
+
+/*
+ * psnr_write:
+ * fetch and write to log file, if avalaible, PSNR statistics
+ * for last encoded frames. Format is human-readable.
+ * If psnr log file isn't avalaible, silently doesn nothing.
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * size: size (bytes) of last encoded frame.
+ * Return Value:
+ * None.
+ */
+static void psnr_write(TCLavcPrivateData *pd, int size)
+{
+ if (pd->psnr_file != NULL) {
+ const char pict_type[5] = { '?', 'I', 'P', 'B', 'S' };
+ double f = pd->ff_vcontext.width * pd->ff_vcontext.height * 255.0 * 255.0;
+ double err[3] = {
+ PFRAME(pd)->error[0],
+ PFRAME(pd)->error[1],
+ PFRAME(pd)->error[2]
+ };
+
+ fprintf(pd->psnr_file, "%6d, %2d, %6d, %2.2f,"
+ " %2.2f, %2.2f, %2.2f %c\n",
+ PFRAME(pd)->coded_picture_number, PFRAME(pd)->quality, size,
+ psnr(err[0] / f),
+ psnr(err[1] * 4 / f), /* FIXME */
+ psnr(err[2] * 4 / f), /* FIXME */
+ psnr((err[0] + err[1] + err[2]) / (f * 1.5)),
+ pict_type[PFRAME(pd)->pict_type]);
+ }
+}
+
+#undef PFRAME
+
+/*
+ * psnr_close:
+ * close psnr log file, free acquired resource.
+ * It's safe to perform this call even if psnr_open()
+ * was NOT called previously.
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * Return Value:
+ * TC_OK: succesfull (log file closed correctly)
+ * TC_ERROR: otherwise
+ */
+static int psnr_close(TCLavcPrivateData *pd)
+{
+ if (pd->psnr_file != NULL) {
+ if (fclose(pd->psnr_file) != 0) {
+ return TC_ERROR;
+ }
+ }
+ return TC_OK;
+}
+
+/*
+ * psnr_print:
+ * tc_log out summary of *overall* PSNR stats.
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * Return Value:
+ * None.
+ */
+static void psnr_print(TCLavcPrivateData *pd)
+{
+ double f = pd->ff_vcontext.width * pd->ff_vcontext.height * 255.0 * 255.0;
+
+ f *= pd->ff_vcontext.coded_frame->coded_picture_number;
+
+#define ERROR pd->ff_vcontext.error
+ tc_log_info(MOD_NAME, "PSNR: Y:%2.2f, Cb:%2.2f, Cr:%2.2f, All:%2.2f",
+ psnr(ERROR[0] / f),
+ /* FIXME: this is correct if pix_fmt != YUV420P */
+ psnr(ERROR[1] * 4 / f),
+ psnr(ERROR[2] * 4 / f),
+ psnr((ERROR[0] + ERROR[1] + ERROR[2]) / (f * 1.5)));
+#undef ERROR
+}
+
+
+/*************************************************************************/
+/*
+ * configure() helpers, libavcodec allow very detailed
+ * configuration step
+ */
+
+/*
+ * tc_lavc_set_pix_fmt:
+ * choose the right pixel format and setup all internal module
+ * fields depending on this value.
+ * Please note that this function SHALL NOT allocate resources
+ * (i.e.: buffers) that's job of other specific functions.
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * vob: pointer to vob_t structure.
+ * Return Value:
+ * TC_OK: succesfull;
+ * TC_ERROR: wrong/erroneous/unsupported pixel format.
+ *
+ * FIXME: move to TC_CODEC_* colorspaces
+ */
+static int tc_lavc_set_pix_fmt(TCLavcPrivateData *pd, const vob_t *vob)
+{
+ switch (vob->im_v_codec) {
+ case CODEC_YUV:
+ if (TC_VCODEC_ID(pd) == TC_CODEC_HUFFYUV) {
+ pd->tc_pix_fmt = TC_CODEC_YUV422P;
+ pd->ff_vcontext.pix_fmt = PIX_FMT_YUV422P;
+ pd->pre_encode_video = pre_encode_video_yuv420p_huffyuv;
+ } else {
+ pd->tc_pix_fmt = TC_CODEC_YUV420P;
+ pd->ff_vcontext.pix_fmt = (TC_VCODEC_ID(pd) == TC_CODEC_MJPEG)
+ ? PIX_FMT_YUVJ420P
+ : PIX_FMT_YUV420P;
+ pd->pre_encode_video = pre_encode_video_yuv420p;
+ }
+ break;
+ case CODEC_YUV422:
+ pd->tc_pix_fmt = TC_CODEC_YUV422P;
+ pd->ff_vcontext.pix_fmt = (TC_VCODEC_ID(pd) == TC_CODEC_MJPEG)
+ ? PIX_FMT_YUVJ422P
+ : PIX_FMT_YUV422P;
+ if (TC_VCODEC_ID(pd) == TC_CODEC_HUFFYUV) {
+ pd->pre_encode_video = pre_encode_video_yuv422p_huffyuv;
+ } else {
+ pd->pre_encode_video = pre_encode_video_yuv422p;
+ }
+ break;
+ case CODEC_RGB:
+ pd->tc_pix_fmt = TC_CODEC_RGB;
+ pd->ff_vcontext.pix_fmt = (TC_VCODEC_ID(pd) == TC_CODEC_HUFFYUV)
+ ? PIX_FMT_YUV422P
+ : (TC_VCODEC_ID(pd) == TC_CODEC_MJPEG)
+ ? PIX_FMT_YUVJ420P
+ : PIX_FMT_YUV420P;
+ pd->pre_encode_video = pre_encode_video_rgb24;
+ break;
+ default:
+ tc_log_warn(MOD_NAME, "Unknown pixel format %i", vob->im_v_codec);
+ return TC_ERROR;
+ }
+
+ tc_log_info(MOD_NAME, "internal pixel format: %s",
+ tc_codec_to_string(pd->tc_pix_fmt));
+ return TC_OK;
+}
+
+
+#define CAN_DO_MULTIPASS(FLAG) do { \
+ if (!(FLAG)) { \
+ tc_log_error(MOD_NAME, "This codec does not support multipass " \
+ "encoding."); \
+ return TC_ERROR; \
+ } \
+} while (0)
+
+/*
+ * tc_lavc_init_multipass:
+ * setup internal (avcodec) parameters for multipass translating
+ * values from vob_t structure, and handle multipass log file data,
+ * reading it or creating it if needed.
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * vob: pointer to vob_t structure.
+ * Return Value:
+ * TC_OK: succesfull
+ * TC_ERROR: error (mostly I/O related; reason will tc_log*()'d out)
+ * Side effects:
+ * A file on disk will be open'd, and possibly read.
+ * Seeks are possible as well.
+ */
+static int tc_lavc_init_multipass(TCLavcPrivateData *pd, const vob_t *vob)
+{
+ int multipass_flag = tc_codec_is_multipass(TC_VCODEC_ID(pd));
+ pd->stats_file = NULL;
+ size_t fsize = 0;
+
+ switch (vob->divxmultipass) {
+ case 1:
+ CAN_DO_MULTIPASS(multipass_flag);
+ pd->ff_vcontext.flags |= CODEC_FLAG_PASS1;
+ pd->stats_file = fopen(vob->divxlogfile, "w");
+ if (pd->stats_file == NULL) {
+ tc_log_error(MOD_NAME, "could not create 2pass log file"
+ " \"%s\".", vob->divxlogfile);
+ return TC_ERROR;
+ }
+ break;
+ case 2:
+ CAN_DO_MULTIPASS(multipass_flag);
+ pd->ff_vcontext.flags |= CODEC_FLAG_PASS2;
+ pd->stats_file = fopen(vob->divxlogfile, "r");
+ if (pd->stats_file == NULL){
+ tc_log_error(MOD_NAME, "could not open 2pass log file \"%s\""
+ " for reading.", vob->divxlogfile);
+ return TC_ERROR;
+ }
+ /* FIXME: we're optimistic here, don't we? */
+ fseek(pd->stats_file, 0, SEEK_END);
+ fsize = ftell(pd->stats_file);
+ fseek(pd->stats_file, 0, SEEK_SET);
+
+ pd->ff_vcontext.stats_in = tc_malloc(fsize + 1);
+ if (pd->ff_vcontext.stats_in == NULL) {
+ tc_log_error(MOD_NAME, "can't get memory for multipass log");
+ fclose(pd->stats_file);
+ return TC_ERROR;
+ }
+
+ if (fread(pd->ff_vcontext.stats_in, fsize, 1, pd->stats_file) < 1) {
+ tc_log_error(MOD_NAME, "Could not read the complete 2pass log"
+ " file \"%s\".", vob->divxlogfile);
+ return TC_ERROR;
+ }
+ pd->ff_vcontext.stats_in[fsize] = 0; /* paranoia */
+ fclose(pd->stats_file);
+ break;
+ case 3:
+ /* fixed qscale :p */
+ pd->ff_vcontext.flags |= CODEC_FLAG_QSCALE;
+ pd->ff_venc_frame.quality = vob->divxbitrate;
+ break;
+ }
+ return TC_OK;
+}
+
+#undef CAN_DO_MULTIPASS
+
+/*
+ * tc_lavc_fini_multipass:
+ * release multipass resources, most notably but NOT exclusively
+ * close log file open'd on disk.
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * Return Value:
+ * None.
+ */
+static void tc_lavc_fini_multipass(TCLavcPrivateData *pd)
+{
+ if (pd->ff_vcontext.stats_in != NULL) {
+ tc_free(pd->ff_vcontext.stats_in);
+ pd->ff_vcontext.stats_in = NULL;
+ }
+ if (pd->stats_file != NULL) {
+ fclose(pd->stats_file); /* XXX */
+ pd->stats_file = NULL;
+ }
+}
+
+/*
+ * tc_lavc_init_rc_override:
+ * parse Rate Control override string given in format understood
+ * by libavcodec and store result in internal avcodec context.
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * str: RC override string to parse.
+ * Return Value:
+ * None.
+ * Side Effects:
+ * some memory will be allocated.
+ */
+static void tc_lavc_init_rc_override(TCLavcPrivateData *pd, const char *str)
+{
+ int i = 0;
+
+ if (str != NULL && strlen(str) > 0) {
+ const char *p = str;
+
+ for (i = 0; p != NULL; i++) {
+ int start, end, q;
+ int e = sscanf(p, "%i,%i,%i", &start, &end, &q);
+
+ if (e != 3) {
+ tc_log_warn(MOD_NAME, "Error parsing rc_override (ignored)");
+ return;
+ }
+ pd->ff_vcontext.rc_override =
+ tc_realloc(pd->ff_vcontext.rc_override,
+ sizeof(RcOverride) * (i + 1)); /* XXX */
+ pd->ff_vcontext.rc_override[i].start_frame = start;
+ pd->ff_vcontext.rc_override[i].end_frame = end;
+ if (q > 0) {
+ pd->ff_vcontext.rc_override[i].qscale = q;
+ pd->ff_vcontext.rc_override[i].quality_factor = 1.0;
+ } else {
+ pd->ff_vcontext.rc_override[i].qscale = 0;
+ pd->ff_vcontext.rc_override[i].quality_factor = -q / 100.0;
+ }
+ p = strchr(p, '/');
+ if (p != NULL) {
+ p++;
+ }
+ }
+ }
+ pd->ff_vcontext.rc_override_count = i;
+}
+
+/*
+ * tc_lavc_fini_rc_override:
+ * free Rate Control override resources acquired by
+ * former call of tc_lavc_init_rc_override.
+ * It's safe to call this function even if
+ * tc_lavc_init_rc_override was NOT called previously.
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * Return Value:
+ * None.
+ */
+static void tc_lavc_fini_rc_override(TCLavcPrivateData *pd)
+{
+ if (pd->ff_vcontext.rc_override != NULL) {
+ tc_free(pd->ff_vcontext.rc_override);
+ pd->ff_vcontext.rc_override = NULL;
+ }
+}
+
+/*
+ * tc_lavc_init_buf:
+ * allocate internal colorspace conversion buffer, if needed
+ * (depending by internal pixel format),
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * vob: pointer to vob_t structure.
+ * Return Value:
+ * TC_OK: succesfull
+ * TC_ERROR: error (can't allocate buffers)
+ * Preconditions:
+ * INTERNAL pixel format already determined using
+ * tc_lavc_set_pix_fmt().
+ */
+
+static int tc_lavc_init_buf(TCLavcPrivateData *pd, const vob_t *vob)
+{
+ if (pd->tc_pix_fmt != TC_CODEC_YUV420P) { /*yuv420p it's our default */
+ pd->vframe_buf = tc_new_video_frame(vob->im_v_width, vob->im_v_height,
+ pd->tc_pix_fmt, TC_TRUE);
+ if (pd->vframe_buf == NULL) {
+ tc_log_warn(MOD_NAME, "unable to allocate internal vframe buffer");
+ return TC_ERROR;
+ }
+ }
+ return TC_OK;
+}
+
+/* release internal colorspace conversion buffers. */
+#define tc_lavc_fini_buf(PD) do { \
+ if ((PD) != NULL && (PD)->vframe_buf != NULL) { \
+ tc_del_video_frame((PD)->vframe_buf); \
+ } \
+} while (0)
+
+
+/*
+ * tc_lavc_settings_from_vob:
+ * translate vob settings and store them in module
+ * private data and in avcodec context, in correct format.
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * vob: pointer to vob_t structure.
+ * Return Value:
+ * TC_OK: succesfull
+ * TC_ERROR: error (various reasons, all will be tc_log*()'d out)
+ * Side Effects:
+ * various helper subroutines will be called.
+ */
+static int tc_lavc_settings_from_vob(TCLavcPrivateData *pd, const vob_t *vob)
+{
+ int ret = 0;
+
+ pd->ff_vcontext.bit_rate = vob->divxbitrate * 1000;
+ pd->ff_vcontext.width = vob->ex_v_width;
+ pd->ff_vcontext.height = vob->ex_v_height;
+ pd->ff_vcontext.qmin = vob->min_quantizer;
+ pd->ff_vcontext.qmax = vob->max_quantizer;
+
+ if (vob->export_attributes & TC_EXPORT_ATTRIBUTE_GOP) {
+ pd->ff_vcontext.gop_size = vob->divxkeyframes;
+ } else {
+ if (TC_VCODEC_ID(pd) == TC_CODEC_MPEG1VIDEO
+ || TC_VCODEC_ID(pd) == TC_CODEC_MPEG2VIDEO) {
+ pd->ff_vcontext.gop_size = 15; /* conservative default for mpeg1/2 svcd/dvd */
+ } else {
+ pd->ff_vcontext.gop_size = 250; /* reasonable default for mpeg4 (and others) */
+ }
+ }
+
+ ret = tc_find_best_aspect_ratio(vob,
+ &pd->ff_vcontext.sample_aspect_ratio.num,
+ &pd->ff_vcontext.sample_aspect_ratio.den,
+ MOD_NAME);
+ if (ret != TC_OK) {
+ tc_log_error(MOD_NAME, "unable to find sane value for SAR");
+ return TC_ERROR;
+ }
+ ret = tc_frc_code_to_ratio(vob->ex_frc,
+ &pd->ff_vcontext.time_base.den,
+ &pd->ff_vcontext.time_base.num);
+ /* watch out here */
+ if (ret == TC_NULL_MATCH) {
+ /* legacy */
+ if ((vob->ex_fps > 29) && (vob->ex_fps < 30)) {
+ pd->ff_vcontext.time_base.den = 30000;
+ pd->ff_vcontext.time_base.num = 1001;
+ } else {
+ pd->ff_vcontext.time_base.den = (int)(vob->ex_fps * 1000.0);
+ pd->ff_vcontext.time_base.num = 1000;
+ }
+ }
+
+ switch(vob->encode_fields) {
+ case TC_ENCODE_FIELDS_TOP_FIRST:
+ pd->interlacing.active = 1;
+ pd->interlacing.top_first = 1;
+ break;
+ case TC_ENCODE_FIELDS_BOTTOM_FIRST:
+ pd->interlacing.active = 1;
+ pd->interlacing.top_first = 0;
+ break;
+ default: /* progressive / unknown */
+ pd->interlacing.active = 0;
+ pd->interlacing.top_first = 0;
+ break;
+ }
+
+ ret = tc_lavc_set_pix_fmt(pd, vob);
+ if (ret != TC_OK) {
+ return ret;
+ }
+ return tc_lavc_init_multipass(pd, vob);
+}
+
+#define PCTX(field) &(pd->ff_vcontext.field)
+#define PAUX(field) &(pd->confdata.field)
+
+/*
+ * tc_lavc_config_defaults:
+ * setup sane values for auxiliary config, and setup *transcode's*
+ * AVCodecContext default settings.
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * Return Value:
+ * None
+ */
+static void tc_lavc_config_defaults(TCLavcPrivateData *pd)
+{
+ /* first of all reinitialize lavc data */
+ avcodec_get_context_defaults(&pd->ff_vcontext);
+
+ pd->confdata.thread_count = 1;
+
+ pd->confdata.vrate_tolerance = 8 * 1000;
+ pd->confdata.rc_min_rate = 0;
+ pd->confdata.rc_max_rate = 0;
+ pd->confdata.rc_buffer_size = 0;
+ pd->confdata.lmin = 2;
+ pd->confdata.lmax = 31;
+ pd->confdata.me_method = ME_EPZS;
+
+ memset(&pd->confdata.flags, 0, sizeof(pd->confdata.flags));
+ pd->confdata.turbo_setup = 0;
+
+ /*
+ * context *transcode* (not libavcodec) defaults
+ */
+ pd->ff_vcontext.mb_qmin = 2;
+ pd->ff_vcontext.mb_qmax = 31;
+ pd->ff_vcontext.max_qdiff = 3;
+ pd->ff_vcontext.max_b_frames = 0;
+ pd->ff_vcontext.me_range = 0;
+ pd->ff_vcontext.mb_decision = 0;
+ pd->ff_vcontext.scenechange_threshold = 0;
+ pd->ff_vcontext.scenechange_factor = 1;
+ pd->ff_vcontext.b_frame_strategy = 0;
+ pd->ff_vcontext.b_sensitivity = 40;
+ pd->ff_vcontext.brd_scale = 0;
+ pd->ff_vcontext.bidir_refine = 0;
+ pd->ff_vcontext.rc_strategy = 2;
+ pd->ff_vcontext.b_quant_factor = 1.25;
+ pd->ff_vcontext.i_quant_factor = 0.8;
+ pd->ff_vcontext.b_quant_offset = 1.25;
+ pd->ff_vcontext.i_quant_offset = 0.0;
+ pd->ff_vcontext.qblur = 0.5;
+ pd->ff_vcontext.qcompress = 0.5;
+ pd->ff_vcontext.mpeg_quant = 0;
+ pd->ff_vcontext.rc_initial_cplx = 0.0;
+ pd->ff_vcontext.rc_qsquish = 1.0;
+ pd->ff_vcontext.luma_elim_threshold = 0;
+ pd->ff_vcontext.chroma_elim_threshold = 0;
+ pd->ff_vcontext.strict_std_compliance = 0;
+ pd->ff_vcontext.dct_algo = FF_DCT_AUTO;
+ pd->ff_vcontext.idct_algo = FF_IDCT_AUTO;
+ pd->ff_vcontext.lumi_masking = 0.0;
+ pd->ff_vcontext.dark_masking = 0.0;
+ pd->ff_vcontext.temporal_cplx_masking = 0.0;
+ pd->ff_vcontext.spatial_cplx_masking = 0.0;
+ pd->ff_vcontext.p_masking = 0.0;
+ pd->ff_vcontext.border_masking = 0.0;
+ pd->ff_vcontext.me_pre_cmp = 0;
+ pd->ff_vcontext.me_cmp = 0;
+ pd->ff_vcontext.me_sub_cmp = 0;
+ pd->ff_vcontext.ildct_cmp = FF_CMP_SAD;
+ pd->ff_vcontext.pre_dia_size = 0;
+ pd->ff_vcontext.dia_size = 0;
+ pd->ff_vcontext.mv0_threshold = 256;
+ pd->ff_vcontext.last_predictor_count = 0;
+ pd->ff_vcontext.pre_me = 1;
+ pd->ff_vcontext.me_subpel_quality = 8;
+ pd->ff_vcontext.refs = 1;
+ pd->ff_vcontext.intra_quant_bias = FF_DEFAULT_QUANT_BIAS;
+ pd->ff_vcontext.inter_quant_bias = FF_DEFAULT_QUANT_BIAS;
+ pd->ff_vcontext.noise_reduction = 0;
+ pd->ff_vcontext.quantizer_noise_shaping = 0;
+ pd->ff_vcontext.flags = 0;
+}
+
+
+/* FIXME: it is too nasty? */
+#define SET_FLAG(pd, field) (pd)->ff_vcontext.flags |= (pd)->confdata.flags.field
+
+/*
+ * tc_lavc_dispatch_settings:
+ * translate auxiliary configuration into context values;
+ * also does some consistency verifications.
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * vob: pointer to vob_t structure.
+ * Return Value:
+ * None.
+ */
+static void tc_lavc_dispatch_settings(TCLavcPrivateData *pd)
+{
+ /* some translation... */
+ pd->ff_vcontext.bit_rate_tolerance = pd->confdata.vrate_tolerance * 1000;
+ pd->ff_vcontext.rc_min_rate = pd->confdata.rc_min_rate * 1000;
+ pd->ff_vcontext.rc_max_rate = pd->confdata.rc_max_rate * 1000;
+ pd->ff_vcontext.rc_buffer_size = pd->confdata.rc_buffer_size * 1024;
+ pd->ff_vcontext.lmin = (int)(FF_QP2LAMBDA * pd->confdata.lmin + 0.5);
+ pd->ff_vcontext.lmax = (int)(FF_QP2LAMBDA * pd->confdata.lmax + 0.5);
+ pd->ff_vcontext.me_method = ME_ZERO + pd->confdata.me_method;
+
+ pd->ff_vcontext.flags = 0;
+ SET_FLAG(pd, mv0);
+ SET_FLAG(pd, cbp);
+ SET_FLAG(pd, qpel);
+ SET_FLAG(pd, alt);
+ SET_FLAG(pd, vdpart);
+ SET_FLAG(pd, naq);
+ SET_FLAG(pd, ilme);
+ SET_FLAG(pd, ildct);
+ SET_FLAG(pd, aic);
+ SET_FLAG(pd, aiv);
+ SET_FLAG(pd, umv);
+ SET_FLAG(pd, psnr);
+ SET_FLAG(pd, trell);
+ SET_FLAG(pd, gray);
+ SET_FLAG(pd, v4mv);
+ SET_FLAG(pd, closedgop);
+
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
+ /* FIXME: coherency check */
+ if (pd->ff_vcontext.rtp_payload_size > 0) {
+ pd->ff_vcontext.rtp_mode = 1;
+ }
+#endif
+ if (pd->confdata.flags.closedgop) {
+ pd->ff_vcontext.scenechange_threshold = 1000000;
+ }
+ if (pd->interlacing.active) {
+ /* enforce interlacing */
+ pd->ff_vcontext.flags |= CODEC_FLAG_INTERLACED_DCT;
+ pd->ff_vcontext.flags |= CODEC_FLAG_INTERLACED_ME;
+ }
+}
+
+#undef SET_FLAG
+
+
+/*
+ * tc_lavc_read_config:
+ * read configuration values from
+ * 1) configuration file (if found)
+ * 2) command line (overrides configuration file in case
+ * of conflicts).
+ * Also read related informations like RC override string
+ * and custom quantization matrices; translate all settings
+ * in libavcodec-friendly values (if needed), then finally
+ * perform some coherency checks and feed avcodec context
+ * with gathered data.
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * options: command line options of *THIS MODULE*.
+ * Return Value:
+ * TC_OK: succesfull
+ * TC_ERROR: error. Mostly I/O related or badly broken
+ * (meaningless) value. Exact reason will tc_log*()'d out.
+ * Side Effects:
+ * Quite a lot, since various (and quite complex) subroutines
+ * are involved. Most notably, various files can be opened/read/closed
+ * on disk, and some memory could be allocated.
+ *
+ * FIXME: I'm a bit worried about heavy stack usage of this function...
+ */
+static int tc_lavc_read_config(TCLavcPrivateData *pd,
+ const char *options, const vob_t *vob)
+{
+ char intra_matrix_file[PATH_MAX] = { '\0' };
+ char inter_matrix_file[PATH_MAX] = { '\0' };
+ char rc_override_buf[TC_BUF_MIN] = { '\0' }; /* XXX */
+ /*
+ * Please note that option names are INTENTIONALLY identical/similar
+ * to mplayer/mencoder ones
+ */
+ TCConfigEntry lavc_conf[] = {
+ { "threads", PAUX(thread_count), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 7 },
+ // need special handling
+ // { "keyint", PCTX(gop_size), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 1000 },
+ // handled by transcode core
+ // { "vbitrate", PCTX(bit_rate), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, INT_MAX },
+ // handled by transcode core
+ // { "vqmin", PCTX(qmin), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 60 },
+ // handled by transcode core
+ // { "vqmax", PCTX(qmax), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 60 },
+ // handled by transcode core
+ { "mbqmin", PCTX(mb_qmin), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 60 },
+ { "mbqmax", PCTX(mb_qmax), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 60 },
+ { "lmin", PAUX(lmin), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.01, 255.0 },
+ { "lmax", PAUX(lmax), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.01, 255.0 },
+ { "vqdiff", PCTX(max_qdiff), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 31 },
+ { "vmax_b_frames", PCTX(max_b_frames), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, FF_MAX_B_FRAMES },
+ { "vme", PAUX(me_method), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 16, },
+ { "me_range", PCTX(me_range), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 16000 },
+ { "mbd", PCTX(mb_decision), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 3 },
+ { "sc_threshold", PCTX(scenechange_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -1000000, 1000000 },
+ { "sc_factor", PCTX(scenechange_factor), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 16 },
+ { "vb_strategy", PCTX(b_frame_strategy), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10 },
+ { "b_sensitivity", PCTX(b_sensitivity), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 100 },
+ { "brd_scale", PCTX(brd_scale), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10 },
+ { "bidir_refine", PCTX(bidir_refine), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 4 },
+ // { "aspect", },
+ // handled by transcode core
+ { "vratetol", PAUX(vrate_tolerance), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 4, 24000000 },
+ { "vrc_maxrate", PAUX(rc_max_rate), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 24000000 },
+ { "vrc_minrate", PAUX(rc_min_rate), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 24000000 },
+ { "vrc_buf_size", PAUX(rc_buffer_size), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 4, 24000000 },
+ { "vrc_strategy", PCTX(rc_strategy), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2 },
+ { "vb_qfactor", PCTX(b_quant_factor), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, -31.0, 31.0 },
+ { "vi_qfactor", PCTX(i_quant_factor), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, -31.0, 31.0 },
+ { "vb_qoffset", PCTX(b_quant_offset), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 31.0 },
+ { "vi_qoffset", PCTX(i_quant_offset), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 31.0 },
+ { "vqblur", PCTX(qblur), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0 },
+ { "vqcomp", PCTX(qcompress), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0 },
+ { "mpeg_quant", PCTX(mpeg_quant), TCCONF_TYPE_FLAG, 0, 0, 1 },
+ // { "vrc_eq", }, // not yet supported
+ { "vrc_override", rc_override_buf, TCCONF_TYPE_STRING, 0, 0, 0 },
+ { "vrc_init_cplx", PCTX(rc_initial_cplx), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 9999999.0 },
+ // { "vrc_init_occupancy", }, // not yet supported
+ { "vqsquish", PCTX(rc_qsquish), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 99.0 },
+ { "vlelim", PCTX(luma_elim_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
+ { "vcelim", PCTX(chroma_elim_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
+ { "vstrict", PCTX(strict_std_compliance), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -99, 99 },
+ { "vpsize", PCTX(rtp_payload_size), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100000000 },
+ { "dct", PCTX(dct_algo), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 10 },
+ { "idct", PCTX(idct_algo), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 20 },
+ { "lumi_mask", PCTX(lumi_masking), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0 },
+ { "dark_mask", PCTX(dark_masking), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0 },
+ { "tcplx_mask", PCTX(temporal_cplx_masking), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0 },
+ { "scplx_mask", PCTX(spatial_cplx_masking), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0 },
+ { "p_mask", PCTX(p_masking), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0 },
+ { "border_mask", PCTX(border_masking), TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, 0.0, 1.0 },
+ { "pred", PCTX(prediction_method), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 4 },
+ { "precmp", PCTX(me_pre_cmp), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2000 },
+ { "cmp", PCTX(me_cmp), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2000 },
+ { "subcmp", PCTX(me_sub_cmp), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2000 },
+ { "ildctcmp", PCTX(ildct_cmp), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2000 },
+ { "predia", PCTX(pre_dia_size), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -2000, 2000 },
+ { "dia", PCTX(dia_size), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -2000, 2000 },
+ { "mv0_threshold", PCTX(mv0_threshold), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 1000 },
+ { "last_pred", PCTX(last_predictor_count), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2000 },
+ { "pre_me", PCTX(pre_me), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 2000},
+ { "subq", PCTX(me_subpel_quality), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 8 },
+ { "refs", PCTX(refs), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 8 },
+ { "ibias", PCTX(intra_quant_bias), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512 },
+ { "pbias", PCTX(inter_quant_bias), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -512, 512 },
+ { "nr", PCTX(noise_reduction), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 1000000},
+ { "qns", PCTX(quantizer_noise_shaping), TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 3 },
+ { "inter_matrix_file", inter_matrix_file, TCCONF_TYPE_STRING, 0, 0, 0 },
+ { "intra_matrix_file", intra_matrix_file, TCCONF_TYPE_STRING, 0, 0, 0 },
+
+ { "mv0", PAUX(flags.mv0), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_MV0 },
+ { "cbp", PAUX(flags.cbp), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_CBP_RD },
+ { "qpel", PAUX(flags.qpel), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_QPEL },
+ { "alt", PAUX(flags.alt), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_ALT_SCAN },
+ { "ilme", PAUX(flags.ilme), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_ME },
+ { "ildct", PAUX(flags.ildct), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_INTERLACED_DCT },
+ { "naq", PAUX(flags.naq), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_NORMALIZE_AQP },
+ { "vdpart", PAUX(flags.vdpart), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART },
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
+ { "aic", PAUX(flags.aic), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_AIC },
+#else
+ { "aic", PAUX(flags.aic), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_AC_PRED },
+#endif
+ { "aiv", PAUX(flags.aiv), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_AIV },
+ { "umv", PAUX(flags.umv), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_H263P_UMV },
+ { "psnr", PAUX(flags.psnr), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PSNR },
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
+ { "trell", PAUX(flags.trell), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_TRELLIS_QUANT },
+#else
+ { "trell", PCTX(trellis), TCCONF_TYPE_FLAG, 0, 0, 1 },
+#endif
+ { "gray", PAUX(flags.gray), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_GRAY },
+ { "v4mv", PAUX(flags.v4mv), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_4MV },
+ { "closedgop", PAUX(flags.closedgop), TCCONF_TYPE_FLAG, 0, 0, CODEC_FLAG_CLOSED_GOP },
+
+ // { "turbo", PAUX(turbo_setup), TCCONF_TYPE_FLAG, 0, 0, 1 }, // not yet supported
+ /* End of the config file */
+ { NULL, 0, 0, 0, 0, 0 }
+ };
+
+ module_read_config(LAVC_CONFIG_FILE,
+ tc_codec_to_string(vob->ex_v_codec),
+ lavc_conf, MOD_NAME);
+
+ if (options && strlen(options) > 0) {
+ size_t i = 0, n = 0;
+ char **opts = tc_strsplit(options, ':', &n);
+
+ if (opts == NULL) {
+ tc_log_error(MOD_NAME, "can't split option string");
+ return TC_ERROR;
+ }
+ for (i = 0; i < n; i++) {
+ if (!module_read_config_line(opts[i], lavc_conf, MOD_NAME)) {
+ tc_log_error(MOD_NAME, "error parsing module options (%s)",
+ opts[i]);
+ tc_strfreev(opts);
+ return TC_ERROR;
+ }
+ }
+ tc_strfreev(opts);
+ }
+
+ /* gracefully go ahead if no matrices are given */
+ tc_lavc_read_matrices(pd, intra_matrix_file, inter_matrix_file);
+ /* gracefully go ahead if no rc override is given */
+ tc_lavc_init_rc_override(pd, rc_override_buf);
+
+ if (verbose >= TC_DEBUG) {
+ module_print_config(lavc_conf, MOD_NAME);
+ }
+ /* only now we can do this safely */
+ tc_lavc_dispatch_settings(pd);
+
+ return TC_OK;
+}
+
+#undef PCTX
+#undef PAUX
+
+/*
+ * tc_lavc_write_logs:
+ * write on disk file encoding logs. That means encoder
+ * multipass log file, but that can also include PSNR
+ * statistics, if requested.
+ *
+ * Parameters:
+ * pd: pointer to private module data.
+ * size: size of last encoded frame.
+ * Return Value:
+ * TC_OK: succesfull
+ * TC_ERROR: I/O error. Exact reason will tc_log*()'d out.
+ */
+static int tc_lavc_write_logs(TCLavcPrivateData *pd, int size)
+{
+ /* store stats if there are any */
+ if (pd->ff_vcontext.stats_out != NULL && pd->stats_file != NULL) {
+ int ret = fprintf(pd->stats_file, "%s",
+ pd->ff_vcontext.stats_out);
+ if (ret < 0) {
+ tc_log_warn(MOD_NAME, "error while writing multipass log file");
+ return TC_ERROR;
+ }
+ }
+
+ if (PSNR_REQUESTED(pd)) {
+ /* errors not fatal, they can be ignored */
+ psnr_write(pd, size);
+ }
+
+ return TC_OK;
+}
+
+/*************************************************************************/
+/* see libtc/tcmodule-data.h for functions meaning and purposes */
+
+
+static int tc_lavc_init(TCModuleInstance *self, uint32_t features)
+{
+ TCLavcPrivateData *pd = NULL;
+
+ TC_MODULE_SELF_CHECK(self, "init");
+ TC_MODULE_INIT_CHECK(self, MOD_FEATURES, features);
+
+ pd = tc_malloc(sizeof(TCLavcPrivateData));
+ if (pd == NULL) {
+ tc_log_error(MOD_NAME, "unable to allocate private data");
+ return TC_ERROR;
+ }
+
+ /* enforce NULL-ness of dangerous (segfault-friendly) stuff */
+ pd->psnr_file = NULL;
+ pd->stats_file = NULL;
+
+ if (verbose) {
+ tc_log_info(MOD_NAME, "%s %s", MOD_VERSION, MOD_CAP);
+ }
+ self->userdata = pd;
+
+ return TC_OK;
+}
+
+
+static int tc_lavc_fini(TCModuleInstance *self)
+{
+ TC_MODULE_SELF_CHECK(self, "fini");
+
+ /* _stop() does the magic; FIXME: recall from here? */
+ tc_free(self->userdata);
+ self->userdata = NULL;
+
+ return TC_OK;
+}
+
+
+#define ABORT_IF_NOT_OK(RET) do { \
+ if ((RET) != TC_OK) { \
+ goto failed; \
+ } \
+} while (0)
+
+
+static int tc_lavc_configure(TCModuleInstance *self,
+ const char *options, vob_t *vob)
+{
+ const char *vcodec_name = tc_codec_to_string(vob->ex_v_codec);
+ TCLavcPrivateData *pd = NULL;
+ int ret = TC_OK;
+
+ TC_MODULE_SELF_CHECK(self, "configure");
+ TC_MODULE_SELF_CHECK(options, "configure"); /* paranoia */
+
+ pd = self->userdata;
+
+ pd->flush_flag = vob->encoder_flush;
+
+ /* FIXME: move into core? */
+ TC_INIT_LIBAVCODEC;
+
+ avcodec_get_frame_defaults(&pd->ff_venc_frame);
+ /*
+ * auxiliary config data needs to be blanked too
+ * before any other operation
+ */
+ tc_lavc_config_defaults(pd);
+
+ /*
+ * we must do first since we NEED valid vcodec_name
+ * ASAP to read right section of configuration file.
+ */
+ pd->vcodec_id = tc_codec_is_supported(vob->ex_v_codec);
+ if (pd->vcodec_id == TC_NULL_MATCH) {
+ tc_log_error(MOD_NAME, "unsupported codec `%s'", vcodec_name);
+ return TC_ERROR;
+ }
+ if (verbose) {
+ tc_log_info(MOD_NAME, "using video codec '%s'", vcodec_name);
+ }
+
+ ret = tc_lavc_settings_from_vob(pd, vob);
+ ABORT_IF_NOT_OK(ret);
+
+ /* calling WARNING: order matters here */
+ ret = tc_lavc_init_buf(pd, vob);
+ ABORT_IF_NOT_OK(ret);
+
+ ret = tc_lavc_read_config(pd, options, vob);
+ ABORT_IF_NOT_OK(ret);
+
+ tc_lavc_load_filters(pd);
+
+ if (verbose) {
+ tc_log_info(MOD_NAME, "using %i thread%s",
+ pd->confdata.thread_count,
+ (pd->confdata.thread_count > 1) ?"s" :"");
+ }
+ avcodec_thread_init(&pd->ff_vcontext, pd->confdata.thread_count);
+
+ pd->ff_vcodec = avcodec_find_encoder(FF_VCODEC_ID(pd));
+ if (pd->ff_vcodec == NULL) {
+ tc_log_error(MOD_NAME, "unable to find a libavcodec encoder for `%s'",
+ tc_codec_to_string(TC_VCODEC_ID(pd)));
+ goto failed;
+ }
+
+ TC_LOCK_LIBAVCODEC;
+ ret = avcodec_open(&pd->ff_vcontext, pd->ff_vcodec);
+ TC_UNLOCK_LIBAVCODEC;
+
+ if (ret < 0) {
+ tc_log_error(MOD_NAME, "avcodec_open() failed");
+ goto failed;
+ }
+ /* finally, pass up the extradata, if any */
+ self->extradata = pd->ff_vcontext.extradata;
+ self->extradata_size = pd->ff_vcontext.extradata_size;
+
+ if (PSNR_REQUESTED(pd)) {
+ /* errors already logged, and they can be ignored */
+ psnr_open(pd);
+ pd->confdata.flags.psnr = 0; /* no longer requested :^) */
+ }
+ return TC_OK;
+
+failed:
+ tc_lavc_fini_buf(pd);
+ return TC_ERROR;
+}
+
+#undef ABORT_IF_NOT_OK
+
+
+static int tc_lavc_inspect(TCModuleInstance *self,
+ const char *param, const char **value)
+{
+ TC_MODULE_SELF_CHECK(self, "inspect");
+ TC_MODULE_SELF_CHECK(value, "inspect");
+
+ if (optstr_lookup(param, "help")) {
+ *value = tc_lavc_help;
+ }
+
+ if (optstr_lookup(param, "vcodec")) {
+ *value = "must be selected by user\n";
+ }
+
+ if (optstr_lookup(param, "list")) {
+ *value = tc_lavc_list_codecs();
+ }
+ return TC_OK;
+}
+
+static int tc_lavc_stop(TCModuleInstance *self)
+{
+ TCLavcPrivateData *pd = NULL;
+
+ TC_MODULE_SELF_CHECK(self, "stop");
+
+ pd = self->userdata;
+
+ tc_lavc_fini_buf(pd);
+
+ if (PSNR_REQUESTED(pd)) {
+ psnr_print(pd);
+ psnr_close(pd);
+ }
+
+ tc_lavc_fini_rc_override(pd);
+ /* ok, now really start the real teardown */
+ tc_lavc_fini_multipass(pd);
+
+ if (pd->ff_vcodec != NULL) {
+ avcodec_close(&pd->ff_vcontext);
+ pd->ff_vcodec = NULL;
+ }
+
+ return TC_OK;
+}
+
+static int tc_lavc_flush_video(TCModuleInstance *self,
+ vframe_list_t *outframe)
+{
+ outframe->video_len = 0;
+ return TC_OK;
+}
+
+
+static int tc_lavc_encode_video(TCModuleInstance *self,
+ vframe_list_t *inframe,
+ vframe_list_t *outframe)
+{
+ TCLavcPrivateData *pd = NULL;
+
+ TC_MODULE_SELF_CHECK(self, "encode_video");
+
+ pd = self->userdata;
+
+ if (inframe == NULL && pd->flush_flag) {
+ return tc_lavc_flush_video(self, outframe); // FIXME
+ }
+
+ pd->ff_venc_frame.interlaced_frame = pd->interlacing.active;
+ pd->ff_venc_frame.top_field_first = pd->interlacing.top_first;
+
+ pd->pre_encode_video(pd, inframe);
+
+ TC_LOCK_LIBAVCODEC;
+ outframe->video_len = avcodec_encode_video(&pd->ff_vcontext,
+ outframe->video_buf,
+ inframe->video_size,
+ &pd->ff_venc_frame);
+ TC_UNLOCK_LIBAVCODEC;
+
+ if (outframe->video_len < 0) {
+ tc_log_warn(MOD_NAME, "encoder error: size (%i)",
+ outframe->video_len);
+ return TC_ERROR;
+ }
+
+ if (pd->ff_vcontext.coded_frame->key_frame) {
+ outframe->attributes |= TC_FRAME_IS_KEYFRAME;
+ }
+
+ return tc_lavc_write_logs(pd, outframe->video_len);
+}
+
+
+/*************************************************************************/
+
+TC_MODULE_CODEC_FORMATS(tc_lavc);
+TC_MODULE_INFO(tc_lavc);
+
+static const TCModuleClass tc_lavc_class = {
+ TC_MODULE_CLASS_HEAD(tc_lavc),
+
+ .init = tc_lavc_init,
+ .fini = tc_lavc_fini,
+ .configure = tc_lavc_configure,
+ .stop = tc_lavc_stop,
+ .inspect = tc_lavc_inspect,
+
+ .encode_video = tc_lavc_encode_video,
+};
+
+extern const TCModuleClass *tc_plugin_setup(void)
+{
+ return &tc_lavc_class;
+}
+
+/*************************************************************************/
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * c-file-offsets: ((case-label . *) (statement-case-intro . *))
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+ */
diff --git a/debian/transcode/transcode-1.1.7/encode/encode_lzo.c b/debian/transcode/transcode-1.1.7/encode/encode_lzo.c
new file mode 100644
index 00000000..b1200fbc
--- /dev/null
+++ b/debian/transcode/transcode-1.1.7/encode/encode_lzo.c
@@ -0,0 +1,293 @@
+/*
+ * encode_lzo.c -- encode video frames individually using LZO.
+ * (C) 2005-2010 Francesco Romani <fromani at gmail dot com>
+ *
+ * This file is part of transcode, a video stream processing tool.
+ *
+ * transcode is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * transcode is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "transcode.h"
+#include "aclib/imgconvert.h"
+#include "libtc/optstr.h"
+#include "libtc/tc_lzo.h"
+#include "libtc/tcmodule-plugin.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define MOD_NAME "encode_lzo.so"
+#define MOD_VERSION "v0.0.2 (2007-10-27)"
+#define MOD_CAP "LZO lossless video encoder"
+
+#define MOD_FEATURES \
+ TC_MODULE_FEATURE_ENCODE|TC_MODULE_FEATURE_VIDEO
+
+#define MOD_FLAGS \
+ TC_MODULE_FLAG_RECONFIGURABLE
+
+
+/* tc_lzo_ prefix was used to avoid any possible name clash with liblzo? */
+
+static const char tc_lzo_help[] = ""
+ "Overview:\n"
+ " this module encodes raw RGB/YUV video frames in LZO, using liblzo V2.\n"
+ "Options:\n"
+ " help produce module overview and options explanations\n";
+
+typedef struct {
+ lzo_byte work_mem[LZO1X_1_MEM_COMPRESS];
+ /* needed by encoder to work properly */
+
+ int codec;
+ int flush_flag;
+} LZOPrivateData;
+
+static int tc_lzo_configure(TCModuleInstance *self,
+ const char *options, vob_t *vob)
+{
+ LZOPrivateData *pd = NULL;
+ int ret;
+
+ TC_MODULE_SELF_CHECK(self, "configure");
+
+ pd = self->userdata;
+ pd->codec = vob->im_v_codec;
+ pd->flush_flag = vob->encoder_flush;
+
+ ret = lzo_init();
+ if (ret != LZO_E_OK) {
+ tc_log_error(MOD_NAME, "configure: failed to initialize"
+ " LZO encoder");
+ return TC_ERROR;
+ }
+
+ return TC_OK;
+}
+
+static int tc_lzo_stop(TCModuleInstance *self)
+{
+ LZOPrivateData *pd = NULL;
+
+ TC_MODULE_SELF_CHECK(self, "stop");
+
+ pd = self->userdata;
+
+ return TC_OK;
+}
+
+static int tc_lzo_init(TCModuleInstance *self, uint32_t features)
+{
+ LZOPrivateData *pd = NULL;
+
+ TC_MODULE_SELF_CHECK(self, "init");
+ TC_MODULE_INIT_CHECK(self, MOD_FEATURES, features);
+
+ pd = tc_malloc(sizeof(LZOPrivateData));
+ if (!pd) {
+ tc_log_error(MOD_NAME, "init: can't allocate private data");
+ return TC_ERROR;
+ }
+ /* sane defaults */
+ pd->codec = CODEC_YUV;
+
+ self->userdata = pd;
+ if (verbose) {
+ tc_log_info(MOD_NAME, "%s %s", MOD_VERSION, MOD_CAP);
+ }
+ return TC_OK;
+}
+
+static int tc_lzo_fini(TCModuleInstance *self)
+{
+ TC_MODULE_SELF_CHECK(self, "fini");
+
+ tc_lzo_stop(self);
+
+ tc_free(self->userdata);
+ self->userdata = NULL;
+ return TC_OK;
+}
+
+static int tc_lzo_inspect(TCModuleInstance *self,
+ const char *param, const char **value)
+{
+ LZOPrivateData *pd = NULL;
+
+ TC_MODULE_SELF_CHECK(self, "inspect");
+
+ pd = self->userdata;
+
+ if (optstr_lookup(param, "help")) {
+ *value = tc_lzo_help;
+ }
+
+ return TC_OK;
+}
+
+/* ------------------------------------------------------------
+ *
+ * encode and export
+ *
+ * ------------------------------------------------------------*/
+
+/* assert(len(data) >= TC_LZ_HDR_SIZE) */
+static void tc_lzo_put_header(tc_lzo_header_t *hdr, void *data)
+{
+ /* always CPU byte order */
+ uint32_t *ptr = data;
+
+ *(ptr) = hdr->magic;
+ *(ptr + 1) = hdr->size;
+ *(ptr + 2) = hdr->flags;
+ *(ptr + 3) = (uint32_t)(hdr->method << 24 | hdr->level << 16 | hdr->pad);
+}
+
+/* maybe translation should go away */
+static int tc_lzo_format_translate(int tc_codec)
+{
+ int ret;
+ switch (tc_codec) {
+ case CODEC_YUV:
+ ret = TC_LZO_FORMAT_YUV420P;
+ break;
+ case CODEC_YUY2:
+ ret = TC_LZO_FORMAT_YUY2;
+ break;
+ case CODEC_RGB:
+ ret = TC_LZO_FORMAT_RGB24;
+ break;
+ default:
+ /* shouldn't happen */
+ ret = 0;
+ break;
+ }
+ return ret;
+}
+
+static int tc_lzo_flush(TCModuleInstance *self,
+ vframe_list_t *outframe)
+{
+ outframe->video_len = 0;
+ return TC_OK;
+}
+
+
+static int tc_lzo_encode_video(TCModuleInstance *self,
+ vframe_list_t *inframe, vframe_list_t *outframe)
+{
+ LZOPrivateData *pd = NULL;
+ lzo_uint out_len = 0;
+ tc_lzo_header_t hdr;
+ int ret;
+
+ TC_MODULE_SELF_CHECK(self, "encode_video");
+
+ pd = self->userdata;
+
+ if (inframe == NULL && pd->flush_flag) {
+ return tc_lzo_flush(self, outframe); // FIXME
+ }
+
+ /* invariants */
+ hdr.magic = TC_CODEC_LZO2;
+ hdr.method = 1;
+ hdr.level = 1;
+ hdr.pad = 0;
+ hdr.flags = 0; /* sane default */
+
+ ret = lzo1x_1_compress(inframe->video_buf, inframe->video_size,
+ outframe->video_buf + TC_LZO_HDR_SIZE,
+ &out_len, pd->work_mem);
+ if (ret != LZO_E_OK) {
+ /* this should NEVER happen */
+ tc_log_warn(MOD_NAME, "encode_video: LZO compression failed"
+ " (errcode=%i)", ret);
+ return TC_ERROR;
+ }
+
+ /* check for an incompressible block */
+ if (out_len >= inframe->video_size) {
+ hdr.flags |= TC_LZO_NOT_COMPRESSIBLE;
+ out_len = inframe->video_size;
+ }
+ hdr.size = out_len;
+
+ hdr.flags |= tc_lzo_format_translate(pd->codec);
+ /* always put header */
+ tc_lzo_put_header(&hdr, outframe->video_buf);
+
+ if (hdr.flags & TC_LZO_NOT_COMPRESSIBLE) {
+ /* inframe data not compressible: outframe will hold a copy */
+ if (verbose >= TC_DEBUG) {
+ tc_log_info(MOD_NAME, "encode_video: block contains"
+ " incompressible data");
+ }
+ ac_memcpy(outframe->video_buf + TC_LZO_HDR_SIZE,
+ inframe->video_buf, out_len);
+ } else {
+ /* outframe data already in place */
+ if (verbose >= TC_DEBUG) {
+ tc_log_info(MOD_NAME, "encode_video: compressed %lu bytes"
+ " into %lu bytes",
+ (unsigned long)inframe->video_size,
+ (unsigned long)out_len);
+ }
+ }
+
+ /* only keyframes */
+ outframe->video_len = out_len + TC_LZO_HDR_SIZE;
+ outframe->attributes |= TC_FRAME_IS_KEYFRAME;
+
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+static const TCCodecID tc_lzo_codecs_in[] = {
+ TC_CODEC_YUY2, TC_CODEC_RGB, TC_CODEC_YUV420P, TC_CODEC_ERROR
+};
+static const TCCodecID tc_lzo_codecs_out[] = {
+ TC_CODEC_LZO2, TC_CODEC_ERROR
+};
+TC_MODULE_CODEC_FORMATS(tc_lzo);
+
+TC_MODULE_INFO(tc_lzo);
+
+static const TCModuleClass tc_lzo_class = {
+ TC_MODULE_CLASS_HEAD(tc_lzo),
+
+ .init = tc_lzo_init,
+ .fini = tc_lzo_fini,
+ .configure = tc_lzo_configure,
+ .stop = tc_lzo_stop,
+ .inspect = tc_lzo_inspect,
+
+ .encode_video = tc_lzo_encode_video,
+};
+
+TC_MODULE_ENTRY_POINT(tc_lzo)
+
+/*************************************************************************/
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * c-file-offsets: ((case-label . *) (statement-case-intro . *))
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+ */
diff --git a/debian/transcode/transcode-1.1.7/encode/encode_null.c b/debian/transcode/transcode-1.1.7/encode/encode_null.c
new file mode 100644
index 00000000..747fdba1
--- /dev/null
+++ b/debian/transcode/transcode-1.1.7/encode/encode_null.c
@@ -0,0 +1,144 @@
+/*
+ * encode_null.c -- produces empty (as in zero-sized) A/V frames.
+ * (C) 2005-2010 Francesco Romani <fromani at gmail dot com>
+ *
+ * This file is part of transcode, a video stream processing tool.
+ *
+ * transcode is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * transcode is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "transcode.h"
+#include "framebuffer.h"
+#include "libtc/optstr.h"
+
+#include "libtc/tcmodule-plugin.h"
+
+#define MOD_NAME "encode_null.so"
+#define MOD_VERSION "v0.0.3 (2005-06-05)"
+#define MOD_CAP "null (fake) A/V encoder"
+
+#define MOD_FEATURES \
+ TC_MODULE_FEATURE_ENCODE|TC_MODULE_FEATURE_VIDEO|TC_MODULE_FEATURE_AUDIO
+
+#define MOD_FLAGS \
+ TC_MODULE_FLAG_RECONFIGURABLE
+
+
+static const char null_help[] = ""
+ "Overview:\n"
+ " this module absorbs provided A/V frames and produces fake,"
+ " empty \"encoded\" frames.\n"
+ "Options:\n"
+ " help produce module overview and options explanations\n";
+
+static int null_init(TCModuleInstance *self, uint32_t features)
+{
+ TC_MODULE_SELF_CHECK(self, "init");
+ TC_MODULE_INIT_CHECK(self, MOD_FEATURES, features);
+
+ if (verbose) {
+ tc_log_info(MOD_NAME, "%s %s", MOD_VERSION, MOD_CAP);
+ }
+ self->userdata = NULL;
+
+ return TC_OK;
+}
+
+static int null_fini(TCModuleInstance *self)
+{
+ TC_MODULE_SELF_CHECK(self, "fini");
+
+ return TC_OK;
+}
+
+static int null_configure(TCModuleInstance *self,
+ const char *options, vob_t *vob)
+{
+ TC_MODULE_SELF_CHECK(self, "configure");
+
+ return TC_OK;
+}
+
+static int null_inspect(TCModuleInstance *self,
+ const char *param, const char **value)
+{
+ TC_MODULE_SELF_CHECK(self, "inspect");
+
+ if (optstr_lookup(param, "help")) {
+ *value = null_help;
+ }
+
+ return TC_OK;
+}
+
+static int null_stop(TCModuleInstance *self)
+{
+ TC_MODULE_SELF_CHECK(self, "stop");
+
+ return TC_OK;
+}
+
+static int null_encode_video(TCModuleInstance *self,
+ vframe_list_t *inframe, vframe_list_t *outframe)
+{
+ TC_MODULE_SELF_CHECK(self, "encode_video");
+
+ outframe->video_len = 0;
+ return TC_OK;
+}
+
+static int null_encode_audio(TCModuleInstance *self,
+ aframe_list_t *inframe, aframe_list_t *outframe)
+{
+ TC_MODULE_SELF_CHECK(self, "encode_audio");
+
+ outframe->audio_len = 0;
+ return TC_OK;
+}
+
+
+/*************************************************************************/
+
+static const TCCodecID null_codecs_in[] = { TC_CODEC_ANY, TC_CODEC_ERROR };
+static const TCCodecID null_codecs_out[] = { TC_CODEC_ANY, TC_CODEC_ERROR };
+TC_MODULE_CODEC_FORMATS(null);
+
+TC_MODULE_INFO(null);
+
+static const TCModuleClass null_class = {
+ TC_MODULE_CLASS_HEAD(null),
+
+ .init = null_init,
+ .fini = null_fini,
+ .configure = null_configure,
+ .stop = null_stop,
+ .inspect = null_inspect,
+
+ .encode_video = null_encode_video,
+ .encode_audio = null_encode_audio,
+};
+
+TC_MODULE_ENTRY_POINT(null)
+/*************************************************************************/
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * c-file-offsets: ((case-label . *) (statement-case-intro . *))
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+ */
diff --git a/debian/transcode/transcode-1.1.7/encode/encode_x264.c b/debian/transcode/transcode-1.1.7/encode/encode_x264.c
new file mode 100644
index 00000000..b8eac09a
--- /dev/null
+++ b/debian/transcode/transcode-1.1.7/encode/encode_x264.c
@@ -0,0 +1,1024 @@
+/*
+ * encode_x264.c - encodes video using the x264 library
+ * Written by Christian Bodenstedt, with NMS adaptation and other changes
+ * by Andrew Church
+ *
+ * This file is part of transcode, a video stream processing tool.
+ * transcode is free software, distributable under the terms of the GNU
+ * General Public License (version 2 or later). See the file COPYING
+ * for details.
+ */
+
+/*
+ * Many parts of this file are taken from FFMPEGs "libavcodec/x264.c",
+ * which is licensed under LGPL. Other sources of information were
+ * "export_ffmpeg.c", X264s "x264.c" and MPlayers "libmpcodecs/ve_x264.c"
+ * (all licensed GPL afaik).
+ */
+
+
+#include "transcode.h"
+#include "aclib/ac.h"
+#include "libtc/libtc.h"
+#include "libtc/cfgfile.h"
+#include "libtc/optstr.h"
+#include "libtc/tcmodule-plugin.h"
+#include "libtc/ratiocodes.h"
+
+#include <x264.h>
+#if X264_BUILD < 65
+# error x264 version 65 or later is required
+#endif
+
+
+#define MOD_NAME "encode_x264.so"
+#define MOD_VERSION "v0.3.2s (2010-01-02)"
+#define MOD_CAP "x264 encoder"
+
+#define MOD_FEATURES \
+ TC_MODULE_FEATURE_ENCODE|TC_MODULE_FEATURE_VIDEO
+
+#define MOD_FLAGS \
+ TC_MODULE_FLAG_RECONFIGURABLE
+
+
+/* Module configuration file */
+#define X264_CONFIG_FILE "x264.cfg"
+
+/* Private data for this module */
+typedef struct {
+ int framenum;
+ int interval;
+ int width;
+ int height;
+ int flush_flag;
+ x264_param_t x264params;
+ x264_t *enc;
+ int twopass_bug_workaround; // Work around x264 logfile generation bug?
+ char twopass_log_path[4096]; // Logfile path (for 2-pass bug workaround)
+} X264PrivateData;
+
+/* Static structure to provide pointers for configuration entries */
+static struct confdata_struct {
+ x264_param_t x264params;
+ /* Dummy fields for obsolete options */
+ int dummy_direct_8x8;
+ int dummy_bidir_me;
+ int dummy_brdo;
+ /* Local parameters */
+ int twopass_bug_workaround;
+} confdata;
+
+/*************************************************************************/
+
+/* This array describes all option-names, pointers to where their
+ * values are stored and the allowed ranges. It's needed to parse the
+ * x264.cfg file using libtc. */
+
+/* Use e.g. OPTION("overscan", vui.i_overscan) for x264params.vui.i_overscan */
+#define OPTION(field,name,type,flag,low,high) \
+ {name, &confdata.x264params.field, (type), (flag), (low), (high)},
+
+/* Option to turn a flag on or off; the off version will have "no" prepended */
+#define OPT_FLAG(field,name) \
+ OPTION(field, name, TCCONF_TYPE_FLAG, 0, 0, 1) \
+ OPTION(field, "no" name, TCCONF_TYPE_FLAG, 0, 1, 0)
+/* Integer option with range */
+#define OPT_RANGE(field,name,low,high) \
+ OPTION(field, name, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, (low), (high))
+/* Floating-point option */
+#define OPT_FLOAT(field,name) \
+ OPTION(field, name, TCCONF_TYPE_FLOAT, 0, 0, 0)
+/* Floating-point option with range */
+#define OPT_RANGF(field,name,low,high) \
+ OPTION(field, name, TCCONF_TYPE_FLOAT, TCCONF_FLAG_RANGE, (low), (high))
+/* String option */
+#define OPT_STR(field,name) \
+ OPTION(field, name, TCCONF_TYPE_STRING, 0, 0, 0)
+/* Dummy entry that doesn't generate an option (placeholder) */
+#define OPT_NONE(field) /*nothing*/
+
+static TCConfigEntry conf[] ={
+
+ /* CPU flags */
+
+ /* CPU acceleration flags (we leave the x264 default alone) */
+ OPT_NONE (cpu)
+ /* Divide each frame into multiple slices, encode in parallel */
+ OPT_RANGE(i_threads, "threads", 1, 4)
+
+ /* Video Properties */
+
+ OPT_NONE (i_width)
+ OPT_NONE (i_height)
+ OPT_NONE (i_csp) /* CSP of encoded bitstream, only i420 supported */
+ /* H.264 level (1.0 ... 5.1) */
+ OPT_RANGE(i_level_idc, "level_idc", 10, 51)
+ OPT_NONE (i_frame_total) /* number of frames to encode if known, else 0 */
+
+ /* they will be reduced to be 0 < x <= 65535 and prime */
+ OPT_NONE (vui.i_sar_height)
+ OPT_NONE (vui.i_sar_width)
+
+ /* 0=undef, 1=show, 2=crop */
+ OPT_RANGE(vui.i_overscan, "overscan", 0, 2)
+
+ /* 0=component 1=PAL 2=NTSC 3=SECAM 4=Mac 5=undef */
+ OPT_RANGE(vui.i_vidformat, "vidformat", 0, 5)
+ OPT_FLAG (vui.b_fullrange, "fullrange")
+ /* 1=bt709 2=undef 4=bt470m 5=bt470bg 6=smpte170m 7=smpte240m 8=film */
+ OPT_RANGE(vui.i_colorprim, "colorprim", 0, 8)
+ /* 1..7 as above, 8=linear, 9=log100, 10=log316 */
+ OPT_RANGE(vui.i_transfer, "transfer", 0, 10)
+ /* 0=GBR 1=bt709 2=undef 4=fcc 5=bt470bg 6=smpte170m 7=smpte240m 8=YCgCo */
+ OPT_RANGE(vui.i_colmatrix, "colmatrix", 0, 8)
+ /* ??? */
+ OPT_RANGE(vui.i_chroma_loc, "chroma_loc", 0, 5)
+
+ OPT_NONE (i_fps_num)
+ OPT_NONE (i_fps_den)
+
+ /* Bitstream parameters */
+
+ /* Maximum number of reference frames */
+ OPT_RANGE(i_frame_reference, "frameref", 1, 16)
+ /* Force an IDR keyframe at this interval */
+ OPT_RANGE(i_keyint_max, "keyint", 1,999999)
+ OPT_RANGE(i_keyint_max, "keyint_max", 1,999999)
+ /* Scenecuts closer together than this are coded as I, not IDR. */
+ OPT_RANGE(i_keyint_min, "keyint_min", 1,999999)
+ /* How aggressively to insert extra I frames */
+ OPT_RANGE(i_scenecut_threshold, "scenecut", -1, 100)
+ /* How many B-frames between 2 reference pictures */
+ OPT_RANGE(i_bframe, "bframes", 0, 16)
+ /* Use adaptive B-frame encoding */
+ OPT_FLAG (i_bframe_adaptive, "b_adapt")
+
+ /* How often B-frames are used */
+ OPT_RANGE(i_bframe_bias, "b_bias", -90, 100)
+ /* Keep some B-frames as references */
+#if X264_BUILD >= 78
+ OPT_RANGE(i_bframe_pyramid, "b_pyramid", 0, 2)
+#else
+ OPT_FLAG (b_bframe_pyramid, "b_pyramid")
+#endif
+
+ /* Use deblocking filter */
+ OPT_FLAG (b_deblocking_filter, "deblock")
+ /* [-6, 6] -6 light filter, 6 strong */
+ OPT_RANGE(i_deblocking_filter_alphac0,"deblockalpha", -6, 6)
+ /* [-6, 6] idem */
+ OPT_RANGE(i_deblocking_filter_beta, "deblockbeta", -6, 6)
+
+ /* Use context-adaptive binary arithmetic coding */
+ OPT_FLAG (b_cabac, "cabac")
+ /* Initial data for CABAC? */
+ OPT_RANGE(i_cabac_init_idc, "cabac_init_idc", 0, 2)
+
+#if X264_BUILD >= 89
+ /* Add NAL HRD parameters to the bitstream */
+ OPT_FLAG (i_nal_hrd, "nal_hrd")
+#endif
+
+ /* Enable interlaced encoding (--encode_fields) */
+ OPT_NONE (b_interlaced)
+#if X264_BUILD >= 89
+ /* First field (1=top, 0=bottom) (--encode_fields) */
+ OPT_NONE (b_tff)
+#endif
+
+ /* Quantization matrix selection: 0=flat 1=JVT 2=custom */
+ OPT_RANGE(i_cqm_preset, "cqm", 0, 2)
+ /* Custom quant matrix filename */
+ OPT_STR (psz_cqm_file, "cqm_file")
+ /* Quant matrix arrays set up by library */
+
+ /* Logging */
+
+ OPT_NONE (pf_log)
+ OPT_NONE (p_log_private)
+ OPT_NONE (i_log_level)
+ OPT_NONE (b_visualize)
+
+ /* Encoder analyser parameters */
+
+ /* Partition selection (we always enable everything) */
+ OPT_NONE (analyse.intra)
+ OPT_NONE (analyse.inter)
+ /* Allow integer 8x8 DCT transforms */
+ OPT_FLAG (analyse.b_transform_8x8, "8x8dct")
+ /* Implicit weighting for B-frames */
+ OPT_FLAG (analyse.b_weighted_bipred, "weight_b")
+ /* Spatial vs temporal MV prediction, 0=none 1=spatial 2=temporal 3=auto */
+ OPT_RANGE(analyse.i_direct_mv_pred, "direct_pred", 0, 3)
+ /* QP difference between chroma and luma */
+ OPT_RANGE(analyse.i_chroma_qp_offset, "chroma_qp_offset",-12, 12)
+
+ /* Motion estimation algorithm to use (X264_ME_*) 0=dia 1=hex 2=umh 3=esa*/
+ OPT_RANGE(analyse.i_me_method, "me", 0, 3)
+ /* Integer pixel motion estimation search range (from predicted MV) */
+ OPT_RANGE(analyse.i_me_range, "me_range", 4, 64)
+ /* Maximum length of a MV (in pixels), 32-2048 or -1=auto */
+ OPT_RANGE(analyse.i_mv_range, "mv_range", -1, 2048)
+ /* Subpixel motion estimation quality: 1=fast, 9=best */
+ OPT_RANGE(analyse.i_subpel_refine, "subq", 1, 9)
+ /* Chroma ME for subpel and mode decision in P-frames */
+ OPT_FLAG (analyse.b_chroma_me, "chroma_me")
+ /* Allow each MB partition in P-frames to have its own reference number */
+ OPT_FLAG (analyse.b_mixed_references, "mixed_refs")
+ /* Trellis RD quantization */
+ OPT_RANGE(analyse.i_trellis, "trellis", 0, 2)
+ /* Early SKIP detection on P-frames */
+ OPT_FLAG (analyse.b_fast_pskip, "fast_pskip")
+ /* Transform coefficient thresholding on P-frames */
+ OPT_FLAG (analyse.b_dct_decimate, "dct_decimate")
+ /* Noise reduction */
+ OPT_RANGE(analyse.i_noise_reduction, "nr", 0, 65536)
+ /* Compute PSNR stats, at the cost of a few % of CPU time */
+ OPT_FLAG (analyse.b_psnr, "psnr")
+ /* Compute SSIM stats, at the cost of a few % of CPU time */
+ OPT_FLAG (analyse.b_ssim, "ssim")
+
+ /* Rate control parameters */
+
+ /* QP value for constant-quality encoding (to be a transcode option,
+ * eventually--FIXME) */
+ OPT_NONE (rc.i_qp_constant)
+ /* Minimum allowed QP value */
+ OPT_RANGE(rc.i_qp_min, "qp_min", 0, 51)
+ /* Maximum allowed QP value */
+ OPT_RANGE(rc.i_qp_max, "qp_max", 0, 51)
+ /* Maximum QP difference between frames */
+ OPT_RANGE(rc.i_qp_step, "qp_step", 0, 50)
+ /* Bitrate (transcode -w) */
+ OPT_NONE (rc.i_bitrate)
+ /* Nominal QP for 1-pass VBR */
+ OPT_RANGF(rc.f_rf_constant, "crf", 0, 51)
+ /* Allowed variance from average bitrate */
+ OPT_FLOAT(rc.f_rate_tolerance, "ratetol")
+ /* Maximum local bitrate (kbit/s) */
+ OPT_RANGE(rc.i_vbv_max_bitrate, "vbv_maxrate", 0,240000)
+ /* Size of VBV buffer for CBR encoding */
+ OPT_RANGE(rc.i_vbv_buffer_size, "vbv_bufsize", 0,240000)
+ /* Initial occupancy of VBV buffer */
+ OPT_RANGF(rc.f_vbv_buffer_init, "vbv_init", 0.0, 1.0)
+ /* QP ratio between I and P frames */
+ OPT_FLOAT(rc.f_ip_factor, "ip_ratio")
+ /* QP ratio between P and B frames */
+ OPT_FLOAT(rc.f_pb_factor, "pb_ratio")
+
+ /* Complexity blurring before QP compression */
+ OPT_RANGF(rc.f_complexity_blur, "cplx_blur", 0.0, 999.0)
+ /* QP curve compression: 0.0 = constant bitrate, 1.0 = constant quality */
+ OPT_RANGF(rc.f_qcompress, "qcomp", 0.0, 1.0)
+ /* QP blurring after compression */
+ OPT_RANGF(rc.f_qblur, "qblur", 0.0, 99.0)
+ /* Rate control override zones (not supported by transcode) */
+ OPT_NONE (rc.zones)
+ OPT_NONE (rc.i_zones)
+ /* Alternate method of specifying zones */
+ OPT_STR (rc.psz_zones, "zones")
+
+ /* Other parameters */
+
+ OPT_FLAG (b_aud, "aud")
+ OPT_NONE (b_repeat_headers)
+ OPT_NONE (i_sps_id)
+
+ /* Module configuration options (which do not affect encoding) */
+
+ {"2pass_bug_workaround", &confdata.twopass_bug_workaround,
+ TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"no2pass_bug_workaround", &confdata.twopass_bug_workaround,
+ TCCONF_TYPE_FLAG, 0, 1, 0},
+
+ /* Obsolete options (scheduled for future removal) */
+
+ {"direct_8x8", &confdata.dummy_direct_8x8, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"nodirect_8x8", &confdata.dummy_direct_8x8, TCCONF_TYPE_FLAG, 0, 1, 0},
+ {"bidir_me", &confdata.dummy_bidir_me, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"nobidir_me", &confdata.dummy_bidir_me, TCCONF_TYPE_FLAG, 0, 1, 0},
+ {"brdo", &confdata.dummy_brdo, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"nobrdo", &confdata.dummy_brdo, TCCONF_TYPE_FLAG, 0, 1, 0},
+
+ {NULL}
+};
+
+/*************************************************************************/
+/*************************************************************************/
+
+/**
+ * x264_log: Logging routine for x264 library.
+ *
+ * Parameters:
+ * userdata: Unused.
+ * level: x264 log level (X264_LOG_*).
+ * format: Log message format string.
+ * args: Log message format arguments.
+ * Return value:
+ * None.
+ */
+
+static void x264_log(void *userdata, int level, const char *format,
+ va_list args)
+{
+ TCLogLevel tclevel;
+ char buf[TC_BUF_MAX];
+
+ if (!format)
+ return;
+ switch (level) {
+ case X264_LOG_ERROR:
+ tclevel = TC_LOG_ERR;
+ break;
+ case X264_LOG_WARNING:
+ tclevel = TC_LOG_WARN;
+ break;
+ case X264_LOG_INFO:
+ if (!(verbose & TC_INFO))
+ return;
+ tclevel = TC_LOG_INFO;
+ break;
+ case X264_LOG_DEBUG:
+ if (!(verbose & TC_DEBUG))
+ return;
+ tclevel = TC_LOG_MSG;
+ break;
+ default:
+ return;
+ }
+ tc_vsnprintf(buf, sizeof(buf), format, args);
+ buf[strcspn(buf,"\r\n")] = 0; /* delete trailing newline */
+ tc_log(tclevel, MOD_NAME, "%s", buf);
+}
+
+/*************************************************************************/
+
+/**
+ * x264params_set_multipass: Does all settings related to multipass.
+ *
+ * Parameters:
+ * pass: 0 = single pass
+ * 1 = 1st pass
+ * 2 = 2nd pass (final pass of multipass encoding)
+ * 3 = Nth pass (intermediate passes of multipass encoding)
+ * statsfilename: where to read and write multipass stat data.
+ * Return value:
+ * Always 0.
+ * Preconditions:
+ * params != NULL
+ * pass == 0 || statsfilename != NULL
+ */
+
+static int x264params_set_multipass(x264_param_t *params,
+ int pass, const char *statsfilename)
+{
+ /* Drop the const and hope that x264 treats it as const anyway */
+ params->rc.psz_stat_in = (char *)statsfilename;
+ params->rc.psz_stat_out = (char *)statsfilename;
+
+ switch (pass) {
+ default:
+ params->rc.b_stat_write = 0;
+ params->rc.b_stat_read = 0;
+ break;
+ case 1:
+ params->rc.b_stat_write = 1;
+ params->rc.b_stat_read = 0;
+ break;
+ case 2:
+ params->rc.b_stat_write = 0;
+ params->rc.b_stat_read = 1;
+ break;
+ case 3:
+ params->rc.b_stat_write = 1;
+ params->rc.b_stat_read = 1;
+ break;
+ }
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * x264params_check: Checks or corrects some strange combinations of
+ * settings done in x264params.
+ *
+ * Parameters:
+ * params: x264_param_t structure to check
+ * Return value:
+ * 0 on success, nonzero otherwise.
+ */
+
+static int x264params_check(x264_param_t *params)
+{
+ /* don't know if these checks are really needed, but they won't hurt */
+ if (params->rc.i_qp_min > params->rc.i_qp_constant) {
+ params->rc.i_qp_min = params->rc.i_qp_constant;
+ }
+ if (params->rc.i_qp_max < params->rc.i_qp_constant) {
+ params->rc.i_qp_max = params->rc.i_qp_constant;
+ }
+
+ if (params->rc.i_rc_method == X264_RC_ABR) {
+ if ((params->rc.i_vbv_max_bitrate > 0)
+ != (params->rc.i_vbv_buffer_size > 0)
+ ) {
+ tc_log_error(MOD_NAME,
+ "VBV requires both vbv_maxrate and vbv_bufsize.");
+ return TC_ERROR;
+ }
+ }
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * x264params_set_by_vob: Handle transcode CLI and tc-autodetection
+ * dependent entries in x264_param_t.
+ *
+ * This method copies various values from transcodes vob_t structure to
+ * x264 $params. That means all settings that can be done through
+ * transcodes CLI or autodetection are applied to x264s $params here
+ * (and I hope nowhere else).
+ *
+ * Parameters:
+ * params: x264_param_t structure to apply changes to
+ * vob: transcodes vob_t structure to copy values from
+ * Return value:
+ * 0 on success, nonzero otherwise.
+ * Preconditions:
+ * params != NULL
+ * vob != NULL
+ */
+
+static int x264params_set_by_vob(x264_param_t *params, const vob_t *vob)
+{
+ /* Set video/bitstream parameters */
+
+ params->i_width = vob->ex_v_width;
+ params->i_height = vob->ex_v_height;
+ params->b_interlaced = (vob->encode_fields==TC_ENCODE_FIELDS_TOP_FIRST
+ || vob->encode_fields==TC_ENCODE_FIELDS_BOTTOM_FIRST);
+#if X264_BUILD >= 89
+ params->b_tff = (vob->encode_fields==TC_ENCODE_FIELDS_TOP_FIRST);
+#endif
+
+ if (params->rc.f_rf_constant != 0) {
+ params->rc.i_rc_method = X264_RC_CRF;
+ } else {
+ params->rc.i_rc_method = X264_RC_ABR;
+ }
+ params->rc.i_bitrate = vob->divxbitrate; /* what a name */
+
+ if (TC_NULL_MATCH == tc_frc_code_to_ratio(vob->ex_frc,
+ &params->i_fps_num,
+ &params->i_fps_den)
+ ) {
+ if (vob->ex_fps > 29.9 && vob->ex_fps < 30) {
+ params->i_fps_num = 30000;
+ params->i_fps_den = 1001;
+ } else if (vob->ex_fps > 23.9 && vob->ex_fps < 24) {
+ params->i_fps_num = 24000;
+ params->i_fps_den = 1001;
+ } else if (vob->ex_fps > 59.9 && vob->ex_fps < 60) {
+ params->i_fps_num = 60000;
+ params->i_fps_den = 1001;
+ } else {
+ params->i_fps_num = vob->ex_fps * 1000;
+ params->i_fps_den = 1000;
+ }
+ }
+
+ if (0 != tc_find_best_aspect_ratio(vob,
+ &params->vui.i_sar_width,
+ &params->vui.i_sar_height,
+ MOD_NAME)
+ ) {
+ tc_log_error(MOD_NAME, "unable to find sane value for SAR");
+ return TC_ERROR;
+ }
+
+ /* Set logging function and acceleration flags */
+ params->pf_log = x264_log;
+ params->p_log_private = NULL;
+ params->cpu &= ~(X264_CPU_MMX
+ | X264_CPU_MMXEXT
+ | X264_CPU_SSE
+ | X264_CPU_SSE2
+ | X264_CPU_SSE3
+ | X264_CPU_SSSE3
+ | X264_CPU_SSE4
+ | X264_CPU_SSE42
+ | X264_CPU_LZCNT);
+ if (tc_accel & AC_MMX) params->cpu |= X264_CPU_MMX;
+ if (tc_accel & AC_MMXEXT) params->cpu |= X264_CPU_MMXEXT;
+ if (tc_accel & AC_SSE) params->cpu |= X264_CPU_SSE;
+ if (tc_accel & AC_SSE2) params->cpu |= X264_CPU_SSE2;
+ if (tc_accel & AC_SSE3) params->cpu |= X264_CPU_SSE3;
+ if (tc_accel & AC_SSSE3) params->cpu |= X264_CPU_SSSE3;
+ if (tc_accel & AC_SSE41) params->cpu |= X264_CPU_SSE4;
+ if (tc_accel & AC_SSE42) params->cpu |= X264_CPU_SSE42;
+ if (tc_accel & AC_SSE4A) params->cpu |= X264_CPU_LZCNT;
+
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * do_2pass_bug_workaround: Work around a bug present in at least x264
+ * versions 65 through 67 which causes invalid frame numbers to be written
+ * to the 2-pass logfile.
+ *
+ * Parameters:
+ * path: Logfile pathname.
+ * Return value:
+ * 0 on success, nonzero otherwise.
+ * Preconditions:
+ * path != NULL
+ */
+
+static int do_2pass_bug_workaround(const char *path)
+{
+ FILE *fp;
+ char *buffer;
+ long filesize, nread, offset;
+ long nframes;
+
+ fp = fopen(path, "r+");
+ if (!fp) {
+ tc_log_warn(MOD_NAME, "Failed to open 2-pass logfile '%s': %s",
+ path, strerror(errno));
+ goto error_return;
+ }
+
+ /* x264 treats the logfile as a single, semicolon-separated buffer
+ * rather than a series of lines, so do the same here. */
+
+ /* Read in the logfile data */
+ if (fseek(fp, 0, SEEK_END) != 0) {
+ tc_log_warn(MOD_NAME, "Seek to end of 2-pass logfile failed: %s",
+ strerror(errno));
+ goto error_close_file;
+ }
+ filesize = ftell(fp);
+ if (filesize < 0) {
+ tc_log_warn(MOD_NAME, "Get size of 2-pass logfile failed: %s",
+ strerror(errno));
+ goto error_close_file;
+ }
+ buffer = malloc(filesize);
+ if (!buffer) {
+ tc_log_warn(MOD_NAME, "No memory for 2-pass logfile buffer"
+ " (%ld bytes)", filesize);
+ goto error_close_file;
+ }
+ if (fseek(fp, 0, SEEK_SET) != 0) {
+ tc_log_warn(MOD_NAME, "Seek to beginning of 2-pass logfile failed: %s",
+ strerror(errno));
+ goto error_free_buffer;
+ }
+ nread = fread(buffer, 1, filesize, fp);
+ if (nread != filesize) {
+ tc_log_warn(MOD_NAME, "Short read on 2-pass logfile (expected %ld"
+ " bytes, got %ld)", filesize, nread);
+ goto error_free_buffer;
+ }
+
+ /* Count the number of frames */
+ nframes = 0;
+ offset = 0;
+ if (strncmp(buffer, "#options:", 9) == 0) { // just like x264
+ offset = strcspn(buffer, "\n") + 1;
+ }
+ for (; offset < filesize; offset++) {
+ if (buffer[offset] == ';') {
+ nframes++;
+ }
+ }
+
+ /* Go through the frame list and check for out-of-range frame numbers */
+ offset = 0;
+ if (strncmp(buffer, "#options:", 9) == 0) {
+ offset = strcspn(buffer, "\n") + 1;
+ }
+ while (offset < filesize) {
+ long framenum;
+ char *s;
+ if (strncmp(&buffer[offset], "in:", 3) != 0) {
+ tc_log_warn(MOD_NAME, "Can't parse 2-pass logfile at offset %ld,"
+ " giving up.", offset);
+ offset = filesize; // Don't truncate the file
+ break;
+ }
+ framenum = strtol(&buffer[offset+3], &s, 10);
+ if ((s && *s != ' ') || framenum < 0) {
+ tc_log_warn(MOD_NAME, "Can't parse 2-pass logfile at offset %ld,"
+ " giving up.", offset+3);
+ offset = filesize; // Don't truncate the file
+ break;
+ }
+ if (framenum >= nframes) {
+ tc_log_warn(MOD_NAME, "Truncating corrupt x264 logfile:");
+ tc_log_warn(MOD_NAME, " in(%ld) >= nframes(%ld) at offset %ld",
+ framenum, nframes, offset);
+ tc_log_warn(MOD_NAME, "Please report this bug to the x264"
+ " developers.");
+ break; // Truncate the file here
+ }
+ offset += strcspn(&buffer[offset], ";");
+ offset += strspn(&buffer[offset], ";\n");
+ }
+
+ /* Truncate the file if the bug was detected */
+ if (offset < filesize) {
+ if (ftruncate(fileno(fp), offset) != 0) {
+ tc_log_warn(MOD_NAME, "Failed to truncate 2-pass logfile: %s",
+ strerror(errno));
+ goto error_free_buffer;
+ }
+ }
+
+ /* Successful return */
+ free(buffer);
+ fclose(fp);
+ return 0;
+
+ /* Error handling */
+ error_free_buffer:
+ free(buffer);
+ error_close_file:
+ fclose(fp);
+ error_return:
+ return -1;
+}
+
+/*************************************************************************/
+/*************************************************************************/
+
+/* Module interface routines and data. */
+
+/*************************************************************************/
+
+/**
+ * x264_init: Initialize this instance of the module. See tcmodule-data.h
+ * for function details.
+ */
+
+static int x264_init(TCModuleInstance *self, uint32_t features)
+{
+ X264PrivateData *pd = NULL;
+
+ TC_MODULE_SELF_CHECK(self, "init");
+ TC_MODULE_INIT_CHECK(self, MOD_FEATURES, features);
+
+ pd = tc_malloc(sizeof(X264PrivateData));
+ if (!pd) {
+ tc_log_error(MOD_NAME, "init: out of memory!");
+ return TC_ERROR;
+ }
+ pd->framenum = 0;
+ pd->enc = NULL;
+
+ if (verbose) {
+ tc_log_info(MOD_NAME, "%s %s", MOD_VERSION, MOD_CAP);
+ }
+ self->userdata = pd;
+
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * x264_fini: Clean up after this instance of the module. See
+ * tcmodule-data.h for function details.
+ */
+
+static int x264_fini(TCModuleInstance *self)
+{
+ X264PrivateData *pd = NULL;
+
+ TC_MODULE_SELF_CHECK(self, "fini");
+
+ pd = self->userdata;
+
+ if (pd->enc) {
+ x264_encoder_close(pd->enc);
+ pd->enc = NULL;
+ }
+
+ tc_free(self->userdata);
+ self->userdata = NULL;
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * x264_configure: Configure this instance of the module. See
+ * tcmodule-data.h for function details.
+ */
+
+static int x264_configure(TCModuleInstance *self,
+ const char *options, vob_t *vob)
+{
+ X264PrivateData *pd = NULL;
+ char *s;
+
+ TC_MODULE_SELF_CHECK(self, "configure");
+
+ pd = self->userdata;
+
+ pd->flush_flag = vob->encoder_flush;
+
+ /* Initialize parameter block */
+ memset(&confdata, 0, sizeof(confdata));
+ x264_param_default(&confdata.x264params);
+
+ /* Parameters not (yet) settable via options: */
+ confdata.x264params.analyse.intra = ~0;
+ confdata.x264params.analyse.inter = ~0;
+
+ /* Watch for obsolete options being set */
+ confdata.dummy_direct_8x8 = -1;
+ confdata.dummy_bidir_me = -1;
+ confdata.dummy_brdo = -1;
+
+ /* Read settings from configuration file */
+ module_read_config(X264_CONFIG_FILE, NULL, conf, MOD_NAME);
+
+ /* Parse options given in -y option string (format:
+ * "name1=value1:name2=value2:...") */
+ for (s = (vob->ex_v_string ? strtok(vob->ex_v_string,":") : NULL);
+ s != NULL;
+ s = strtok(NULL,":")
+ ) {
+ if (!module_read_config_line(s, conf, MOD_NAME)) {
+ tc_log_error(MOD_NAME, "Error parsing module options");
+ return TC_ERROR;
+ }
+ }
+
+ /* Complain about obsolete options being set */
+ if (confdata.dummy_direct_8x8 != -1) {
+ tc_log_warn(MOD_NAME, "Option direct_8x8 is obsolete, and is now"
+ " always active.");
+ }
+ if (confdata.dummy_bidir_me != -1) {
+ tc_log_warn(MOD_NAME,
+ "Option bidir_me is obsolete in x264 version 65.\n"
+ " bidir_me will be automatically applied when"
+ " subq >= 5.");
+ }
+ if (confdata.dummy_brdo != -1) {
+ tc_log_warn(MOD_NAME,
+ "Option bidir_me is obsolete in x264 version 65.\n"
+ " brdo will be automatically applied when subq >= 7.");
+ }
+
+ /* Save multipass logfile name if 2-pass bug workaround was requested */
+ if (confdata.twopass_bug_workaround
+ && (vob->divxmultipass == 1 || vob->divxmultipass == 3)
+ ) {
+ const size_t strsize = strlen(vob->divxlogfile) + 1;
+ if (strsize > sizeof(pd->twopass_log_path)) {
+ tc_log_error(MOD_NAME, "2-pass logfile path too long.\n"
+ " Use a shorter pathname or disable the"
+ " 2pass_bug_workaround option.");
+ return TC_ERROR;
+ }
+ ac_memcpy(pd->twopass_log_path, vob->divxlogfile, strsize);
+ pd->twopass_bug_workaround = 1;
+ } else {
+ pd->twopass_bug_workaround = 0;
+ }
+
+ /* Apply extra settings to $x264params */
+ if (0 != x264params_set_multipass(&confdata.x264params, vob->divxmultipass,
+ vob->divxlogfile)
+ ) {
+ tc_log_error(MOD_NAME, "Failed to apply multipass settings.");
+ return TC_ERROR;
+ }
+
+ /* Copy parameter block to module private data */
+ ac_memcpy(&pd->x264params, &confdata.x264params, sizeof(pd->x264params));
+
+ /* Apply transcode CLI and autodetected values from $vob to
+ * $x264params. This is done as the last step to make transcode CLI
+ * override any settings done before. */
+ if (0 != x264params_set_by_vob(&pd->x264params, vob)) {
+ tc_log_error(MOD_NAME, "Failed to evaluate vob_t values.");
+ return TC_ERROR;
+ }
+
+ /* Test if the set parameters fit together. */
+ if (0 != x264params_check(&pd->x264params)) {
+ return TC_ERROR;
+ }
+
+ /* Now we've set all parameters gathered from transcode and the config
+ * file to $x264params. Let's give some status report and finally open
+ * the encoder. */
+ if (verbose >= TC_DEBUG) {
+ module_print_config(conf, MOD_NAME);
+ }
+
+ pd->enc = x264_encoder_open(&pd->x264params);
+ if (!pd->enc) {
+ tc_log_error(MOD_NAME, "x264_encoder_open() returned NULL - sorry.");
+ return TC_ERROR;
+ }
+
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * x264_stop: Reset this instance of the module. See tcmodule-data.h for
+ * function details.
+ */
+
+static int x264_stop(TCModuleInstance *self)
+{
+ X264PrivateData *pd = NULL;
+
+ TC_MODULE_SELF_CHECK(self, "stop");
+
+ pd = self->userdata;
+
+ if (pd->enc) {
+ x264_encoder_close(pd->enc);
+ pd->enc = NULL;
+ }
+
+ if (pd->twopass_bug_workaround) {
+ do_2pass_bug_workaround(pd->twopass_log_path);
+ }
+
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * x264_inspect: Return the value of an option in this instance of the
+ * module. See tcmodule-data.h for function details.
+ */
+
+static int x264_inspect(TCModuleInstance *self,
+ const char *param, const char **value)
+{
+ X264PrivateData *pd = NULL;
+ static char buf[TC_BUF_MAX];
+
+ TC_MODULE_SELF_CHECK(self, "inspect");
+ TC_MODULE_SELF_CHECK(param, "inspect");
+ TC_MODULE_SELF_CHECK(value, "inspect");
+
+ pd = self->userdata;
+
+ if (optstr_lookup(param, "help")) {
+ tc_snprintf(buf, sizeof(buf),
+"Overview:\n"
+" Encodes video in h.264 format using the x264 library.\n"
+"Options available:\n"
+" All options in x264.cfg can be specified on the command line\n"
+" using the format: -y x264=name1=value1:name2=value2:...\n");
+ *value = buf;
+ }
+ /* FIXME: go through the option list to find a match to param */
+
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+/**
+ * x264_encode_video: Decode a frame of data. See tcmodule-data.h for
+ * function details.
+ */
+
+static int x264_encode_video(TCModuleInstance *self,
+ vframe_list_t *inframe, vframe_list_t *outframe)
+{
+ X264PrivateData *pd;
+ x264_nal_t *nal;
+ x264_picture_t pic, pic_out;
+ int nnal, i, ret;
+
+ TC_MODULE_SELF_CHECK(self, "encode_video");
+
+ pd = self->userdata;
+
+ pd->framenum++;
+
+ memset(&pic, 0, sizeof(pic));
+ memset(&pic_out, 0, sizeof(pic_out));
+
+ if (inframe == NULL) {
+ outframe->video_len = 0;
+ return TC_OK;
+ }
+
+ pic.img.i_csp = X264_CSP_I420;
+ pic.img.i_plane = 3;
+
+ pic.img.plane[0] = inframe->video_buf;
+ pic.img.i_stride[0] = inframe->v_width;
+
+ pic.img.plane[1] = pic.img.plane[0]
+ + inframe->v_width*inframe->v_height;
+ pic.img.i_stride[1] = inframe->v_width / 2;
+
+ pic.img.plane[2] = pic.img.plane[1]
+ + (inframe->v_width/2)*(inframe->v_height/2);
+ pic.img.i_stride[2] = inframe->v_width / 2;
+
+
+ pic.i_type = X264_TYPE_AUTO;
+ pic.i_qpplus1 = 0;
+ /* FIXME: Is this pts-handling ok? I don't have a clue how
+ * PTS/DTS handling works. Does it matter, when no muxing is
+ * done? */
+ pic.i_pts = (int64_t) pd->framenum * pd->x264params.i_fps_den;
+
+ ret = x264_encoder_encode(pd->enc, &nal, &nnal, &pic, &pic_out);
+#if X264_BUILD >= 76
+ if (ret < 0) {
+#else
+ if (ret != 0) {
+#endif
+ return TC_ERROR;
+ }
+
+ outframe->video_len = 0;
+ for (i = 0; i < nnal; i++) {
+ int size = outframe->video_size - outframe->video_len;
+ if (size <= 0) {
+ tc_log_error(MOD_NAME, "output buffer overflow");
+ return TC_ERROR;
+ }
+#if X264_BUILD >= 76
+ ac_memcpy(outframe->video_buf + outframe->video_len, nal[i].p_payload, nal[i].i_payload);
+ outframe->video_len += nal[i].i_payload;
+#else
+ ret = x264_nal_encode(outframe->video_buf + outframe->video_len,
+ &size, 1, &nal[i]);
+ if (ret < 0 || size > outframe->video_size - outframe->video_len) {
+ tc_log_error(MOD_NAME, "output buffer overflow");
+ break;
+ }
+ outframe->video_len += size;
+#endif
+ }
+
+ /* FIXME: ok, that sucks. How to reformat it ina better way? -- fromani */
+ if ((pic_out.i_type == X264_TYPE_IDR)
+ || (pic_out.i_type == X264_TYPE_I
+ && pd->x264params.i_frame_reference == 1
+ && !pd->x264params.i_bframe)) {
+ outframe->attributes |= TC_FRAME_IS_KEYFRAME;
+ }
+
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+static const TCCodecID x264_codecs_in[] = { TC_CODEC_YUV420P, TC_CODEC_ERROR };
+static const TCCodecID x264_codecs_out[] = { TC_CODEC_H264, TC_CODEC_ERROR };
+TC_MODULE_CODEC_FORMATS(x264);
+
+TC_MODULE_INFO(x264);
+
+static const TCModuleClass x264_class = {
+ TC_MODULE_CLASS_HEAD(x264),
+
+ .init = x264_init,
+ .fini = x264_fini,
+ .configure = x264_configure,
+ .stop = x264_stop,
+ .inspect = x264_inspect,
+
+ .encode_video = x264_encode_video,
+};
+
+TC_MODULE_ENTRY_POINT(x264)
+
+/*************************************************************************/
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * c-file-offsets: ((case-label . *) (statement-case-intro . *))
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+ */
+
diff --git a/debian/transcode/transcode-1.1.7/encode/encode_xvid.c b/debian/transcode/transcode-1.1.7/encode/encode_xvid.c
new file mode 100644
index 00000000..ebeae7d9
--- /dev/null
+++ b/debian/transcode/transcode-1.1.7/encode/encode_xvid.c
@@ -0,0 +1,1078 @@
+/*****************************************************************************
+ * - XviD Transcode Export Module -
+ *
+ * Copyright (C) 2001-2003 - Thomas Oestreich
+ *
+ * Author : Edouard Gomez <ed.gomez@free.fr>
+ *
+ * Port to transcode 1.1.0+ Module System:
+ * (C) 2005-2010 Francesco Romani <fromani at gmail dot com>
+ *
+ * This file is part of transcode, a video stream processing tool
+ *
+ * transcode is free software ; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation ; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY ; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program ; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Includes
+ ****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <math.h>
+
+#include "transcode.h"
+#include "libtcvideo/tcvideo.h"
+#include "libtc/cfgfile.h"
+#include "libtc/optstr.h"
+#include "libtc/tcmodule-plugin.h"
+#include "libtc/tccodecs.h"
+
+#include <xvid.h>
+
+/*
+ * notes:
+ * - tc_xvid_ prefix is used to avoid any possible name clash with XviD code
+ * - export_xvid4.c was a really nice and well-written module, this module
+ * is largely based on such module and share a large portion of code with
+ * it. So hopefully it should work nicely :)
+ * - handling of dynamic loading of further shared objects (XviD codec, here)
+ * isn't optimal, such details should be handled by libtc.
+ * libdldarwin too should be merged with libtc, or maybe we should switch
+ * to libtool wizardry.
+ */
+/*****************************************************************************
+ * Transcode module binding functions and strings
+ ****************************************************************************/
+
+#define MOD_NAME "encode_xvid.so"
+#define MOD_VERSION "v0.0.6 (2008-03-14)"
+#define MOD_CAP "XviD 1.1.x encoder"
+
+#define MOD_FEATURES \
+ TC_MODULE_FEATURE_ENCODE|TC_MODULE_FEATURE_VIDEO
+
+#define MOD_FLAGS \
+ TC_MODULE_FLAG_RECONFIGURABLE
+
+
+#define XVID_CONFIG_FILE "xvid.cfg"
+
+static const char xvid_help[] = ""
+ "Overview:\n"
+ " this module encodes raw RGB/YUV video frames in MPEG4, using XviD.\n"
+ " XviD is a high quality/performance ISO MPEG4 codec.\n"
+ "Options:\n"
+ " help produce module overview and options explanations\n";
+
+/*****************************************************************************
+ * XviD symbols grouped in a nice struct.
+ ****************************************************************************/
+
+typedef int (*xvid_function_t)(void *handle, int opt,
+ void *param1, void *param2);
+
+/*****************************************************************************
+ * Transcode module private data
+ ****************************************************************************/
+
+typedef struct {
+ /* Instance related global vars */
+ void *instance;
+ xvid_gbl_init_t xvid_gbl_init;
+ xvid_enc_create_t xvid_enc_create;
+ xvid_enc_frame_t xvid_enc_frame;
+
+ /* This data must survive local block scope, so here it is */
+ xvid_enc_plugin_t plugins[7];
+ xvid_enc_zone_t zones[2];
+ xvid_plugin_single_t onepass;
+ xvid_plugin_2pass1_t pass1;
+ xvid_plugin_2pass2_t pass2;
+
+ /* Options from the config file */
+ xvid_enc_create_t cfg_create;
+ xvid_enc_frame_t cfg_frame;
+ xvid_plugin_single_t cfg_onepass;
+ xvid_plugin_2pass2_t cfg_pass2;
+ char *cfg_intra_matrix_file;
+ char *cfg_inter_matrix_file;
+ char *cfg_quant_method;
+ int cfg_packed;
+ int cfg_closed_gop;
+ int cfg_interlaced;
+ int cfg_quarterpel;
+ int cfg_gmc;
+ int cfg_trellis;
+ int cfg_cartoon;
+ int cfg_hqacpred;
+ int cfg_chromame;
+ int cfg_vhq;
+ int cfg_bvhq;
+ int cfg_motion;
+ int cfg_stats;
+ int cfg_greyscale;
+ int cfg_turbo;
+ int cfg_full1pass;
+ int cfg_lumimask;
+
+ /* MPEG4 stream buffer */
+ int stream_size;
+ uint8_t *stream;
+
+ /* Stats accumulators */
+ int frames;
+ int64_t sse_y;
+ int64_t sse_u;
+ int64_t sse_v;
+
+ /* Image format conversion handle */
+ TCVHandle tcvhandle;
+
+ int flush_flag;
+} XviDPrivateData;
+
+static const char *errorstring(int err);
+static void reset_module(XviDPrivateData *mod);
+static void cleanup_module(XviDPrivateData *mod);
+static void read_config_file(XviDPrivateData *mod);
+static void dispatch_settings(XviDPrivateData *mod);
+static void set_create_struct(XviDPrivateData *mod, const vob_t *vob);
+static void set_frame_struct(XviDPrivateData *mod, vob_t *vob,
+ const vframe_list_t *inframe,
+ vframe_list_t *outframe);
+
+/***************************************************************************/
+
+static int tc_xvid_configure(TCModuleInstance *self,
+ const char *options, vob_t *vob)
+{
+ int ret;
+ XviDPrivateData *pd = NULL;
+
+ TC_MODULE_SELF_CHECK(self, "configure");
+ TC_MODULE_SELF_CHECK(vob, "configure"); /* uhu, hackish? */
+
+ pd = self->userdata;
+
+ pd->flush_flag = vob->encoder_flush;
+
+ /* Load the config file settings */
+ read_config_file(pd);
+
+ /* Dispatch settings to xvid structures that hold the config ready to
+ * be copied to encoder structures */
+ dispatch_settings(pd);
+
+ /* Init the xvidcore lib */
+ memset(&pd->xvid_gbl_init, 0, sizeof(xvid_gbl_init_t));
+ pd->xvid_gbl_init.version = XVID_VERSION;
+
+ ret = xvid_global(NULL, XVID_GBL_INIT, &pd->xvid_gbl_init, NULL);
+ if (ret < 0) {
+ tc_log_error(MOD_NAME, "configure: library initialization failed");
+ return TC_ERROR;
+ }
+
+ /* Combine both the config settings with the transcode direct options
+ * into the final xvid_enc_create_t struct */
+ set_create_struct(pd, vob);
+ ret = xvid_encore(NULL, XVID_ENC_CREATE, &pd->xvid_enc_create, NULL);
+
+ if (ret < 0) {
+ tc_log_error(MOD_NAME, "configure: encoder initialization failed"
+ " (XviD returned %i)", ret);
+ return TC_ERROR;
+ }
+
+ /* Attach returned instance */
+ pd->instance = pd->xvid_enc_create.handle;
+
+ return TC_OK;
+}
+
+
+static int tc_xvid_init(TCModuleInstance *self, uint32_t features)
+{
+ XviDPrivateData *pd = NULL;
+ vob_t *vob = tc_get_vob();
+
+ TC_MODULE_SELF_CHECK(self, "init");
+ TC_MODULE_INIT_CHECK(self, MOD_FEATURES, features);
+
+ /* Check frame dimensions */
+ if (vob->ex_v_width % 2 || vob->ex_v_height % 2) {
+ tc_log_warn(MOD_NAME, "init: only even dimensions allowed (%dx%d)",
+ vob->ex_v_width, vob->ex_v_height);
+ return TC_ERROR;
+ }
+
+ pd = tc_malloc(sizeof(XviDPrivateData));
+ if (!pd) {
+ tc_log_error(MOD_NAME, "init: can't allocate XviD private data");
+ return TC_ERROR;
+ }
+
+ /* Buffer allocation
+ * We allocate width*height*bpp/8 to "receive" the compressed stream
+ * I don't think the codec will ever return more than that. It's and
+ * encoder, so if it fails delivering smaller frames than original
+ * ones, something really odd occurs somewhere and i prefer the
+ * application crash */
+ if (vob->im_v_codec == CODEC_RGB || vob->im_v_codec == CODEC_YUV422) {
+ pd->tcvhandle = tcv_init();
+ if (!pd->tcvhandle) {
+ tc_log_warn(MOD_NAME, "init: tcv_init failed");
+ goto init_failed;
+ }
+ }
+
+ reset_module(pd);
+ self->userdata = pd;
+
+ if (verbose) {
+ tc_log_info(MOD_NAME, "%s %s", MOD_VERSION, MOD_CAP);
+ }
+ return TC_OK;
+
+init_failed:
+ tc_free(pd);
+ self->userdata = NULL; /* paranoia */
+ return TC_ERROR;
+}
+
+static int tc_xvid_inspect(TCModuleInstance *self,
+ const char *param, const char **value)
+{
+ TC_MODULE_SELF_CHECK(self, "inspect");
+
+ if (optstr_lookup(param, "help")) {
+ *value = xvid_help;
+ }
+
+ return TC_OK;
+}
+
+static int tc_xvid_flush(TCModuleInstance *self, vframe_list_t *outframe)
+{
+ int bytes;
+ xvid_enc_stats_t xvid_enc_stats;
+ vob_t *vob = tc_get_vob();
+ XviDPrivateData *pd = NULL;
+
+ TC_MODULE_SELF_CHECK(self, "encode_video");
+
+ pd = self->userdata;
+
+ /* Init the stat structure */
+ memset(&xvid_enc_stats, 0, sizeof(xvid_enc_stats_t));
+ xvid_enc_stats.version = XVID_VERSION;
+
+ /* Combine both the config settings with the transcode direct options
+ * into the final xvid_enc_frame_t struct */
+ set_frame_struct(pd, vob, NULL, outframe);
+
+ bytes = xvid_encore(pd->instance, XVID_ENC_ENCODE,
+ &pd->xvid_enc_frame, &xvid_enc_stats);
+
+ outframe->video_len = bytes;
+ if (bytes > 0) {
+ /* Extract stats info */
+ if (xvid_enc_stats.type > 0 && pd->cfg_stats) {
+ pd->frames++;
+ pd->sse_y += xvid_enc_stats.sse_y;
+ pd->sse_u += xvid_enc_stats.sse_u;
+ pd->sse_v += xvid_enc_stats.sse_v;
+ }
+
+ if (pd->xvid_enc_frame.out_flags & XVID_KEYFRAME) {
+ outframe->attributes |= TC_FRAME_IS_KEYFRAME;
+ }
+ }
+ return TC_OK;
+}
+
+
+static int tc_xvid_encode_video(TCModuleInstance *self,
+ vframe_list_t *inframe, vframe_list_t *outframe)
+{
+ int bytes;
+ xvid_enc_stats_t xvid_enc_stats;
+ vob_t *vob = tc_get_vob();
+ XviDPrivateData *pd = NULL;
+
+ TC_MODULE_SELF_CHECK(self, "encode_video");
+
+ pd = self->userdata;
+
+ if (inframe == NULL && pd->flush_flag) {
+ return tc_xvid_flush(self, outframe); // FIXME
+ }
+
+ /* Init the stat structure */
+ memset(&xvid_enc_stats, 0, sizeof(xvid_enc_stats_t));
+ xvid_enc_stats.version = XVID_VERSION;
+
+ if(vob->im_v_codec == CODEC_YUV422) {
+ /* Convert to UYVY */
+ tcv_convert(pd->tcvhandle, inframe->video_buf, inframe->video_buf,
+ vob->ex_v_width, vob->ex_v_height, IMG_YUV422P, IMG_UYVY);
+ } else if (vob->im_v_codec == CODEC_RGB) {
+ /* Convert to BGR (why isn't RGB supported??) */
+ tcv_convert(pd->tcvhandle, inframe->video_buf, inframe->video_buf,
+ vob->ex_v_width, vob->ex_v_height, IMG_RGB24, IMG_BGR24);
+ }
+ /* Combine both the config settings with the transcode direct options
+ * into the final xvid_enc_frame_t struct */
+ set_frame_struct(pd, vob, inframe, outframe);
+
+ bytes = xvid_encore(pd->instance, XVID_ENC_ENCODE,
+ &pd->xvid_enc_frame, &xvid_enc_stats);
+
+ /* Error handling */
+ if (bytes < 0) {
+ tc_log_error(MOD_NAME, "encode_video: xvidcore returned"
+ " an error: \"%s\"",
+ errorstring(bytes));
+ return TC_ERROR;
+ }
+ outframe->video_len = bytes;
+
+ /* Extract stats info */
+ if (xvid_enc_stats.type > 0 && pd->cfg_stats) {
+ pd->frames++;
+ pd->sse_y += xvid_enc_stats.sse_y;
+ pd->sse_u += xvid_enc_stats.sse_u;
+ pd->sse_v += xvid_enc_stats.sse_v;
+ }
+
+ /* XviD Core rame buffering handling
+ * We must make sure audio A/V is still good and does not run away */
+ if (bytes == 0) {
+ outframe->attributes |= TC_FRAME_IS_DELAYED;
+ return TC_OK;
+ }
+
+ if (pd->xvid_enc_frame.out_flags & XVID_KEYFRAME) {
+ outframe->attributes |= TC_FRAME_IS_KEYFRAME;
+ }
+
+ return TC_OK;
+}
+
+#define SSE2PSNR(sse, width, height) \
+((!(sse)) ? (99.0f) : (48.131f - 10*(float)log10((float)(sse)/((float)((width)*(height))))))
+
+static int tc_xvid_stop(TCModuleInstance *self)
+{
+ int ret;
+ XviDPrivateData *pd = NULL;
+
+ TC_MODULE_SELF_CHECK(self, "stop");
+
+ pd = self->userdata;
+
+ /* ToDo: Can we flush the last frames here ? */
+
+ if (pd->instance != NULL) {
+ /* Destroy the encoder instance */
+ ret = xvid_encore(pd->instance, XVID_ENC_DESTROY, NULL, NULL);
+ if (ret < 0) {
+ tc_log_warn(MOD_NAME, "stop: encoder instance releasing failed");
+ return TC_ERROR;
+ }
+
+ /* Print stats before resting the complete module structure */
+ if (pd->cfg_stats) {
+ if(pd->frames > 0) {
+ pd->sse_y /= pd->frames;
+ pd->sse_u /= pd->frames;
+ pd->sse_v /= pd->frames;
+ } else {
+ pd->sse_y = 0;
+ pd->sse_u = 0;
+ pd->sse_v = 0;
+ }
+
+ tc_log_info(MOD_NAME,
+ "psnr y = %.2f dB, "
+ "psnr u = %.2f dB, "
+ "psnr v = %.2f dB",
+ SSE2PSNR(pd->sse_y,
+ pd->xvid_enc_create.width,
+ pd->xvid_enc_create.height),
+ SSE2PSNR(pd->sse_u,
+ pd->xvid_enc_create.width/2,
+ pd->xvid_enc_create.height/2),
+ SSE2PSNR(pd->sse_v,
+ pd->xvid_enc_create.width/2,
+ pd->xvid_enc_create.height/2));
+ }
+ pd->instance = NULL;
+ }
+ return TC_OK;
+}
+#undef SSE2PSNR
+
+static int tc_xvid_fini(TCModuleInstance *self)
+{
+ XviDPrivateData *pd = NULL;
+
+ TC_MODULE_SELF_CHECK(self, "fini");
+
+ tc_xvid_stop(self);
+
+ pd = self->userdata;
+
+ /* Free all dynamic memory allocated in the module structure */
+ cleanup_module(pd);
+
+ /* This is the last function according to the transcode API
+ * this should be safe to reset the module structure */
+ reset_module(pd);
+
+ tc_free(self->userdata);
+ self->userdata = NULL;
+
+ return TC_OK;
+}
+
+/*************************************************************************/
+
+static const TCCodecID tc_xvid_codecs_in[] = {
+ TC_CODEC_RGB, TC_CODEC_YUV422P, TC_CODEC_YUV420P,
+ TC_CODEC_ERROR
+};
+
+static const TCCodecID tc_xvid_codecs_out[] = {
+ TC_CODEC_MPEG4VIDEO,
+ TC_CODEC_ERROR
+};
+
+TC_MODULE_CODEC_FORMATS(tc_xvid);
+
+TC_MODULE_INFO(tc_xvid);
+
+static const TCModuleClass xvid_class = {
+ TC_MODULE_CLASS_HEAD(tc_xvid),
+
+ .init = tc_xvid_init,
+ .fini = tc_xvid_fini,
+ .configure = tc_xvid_configure,
+ .stop = tc_xvid_stop,
+ .inspect = tc_xvid_inspect,
+
+ .encode_video = tc_xvid_encode_video
+};
+
+TC_MODULE_ENTRY_POINT(xvid)
+
+
+/*****************************************************************************
+ * Transcode module helper functions
+ ****************************************************************************/
+
+static void reset_module(XviDPrivateData *mod)
+{
+ /* Default options */
+ mod->cfg_packed = 0;
+ mod->cfg_closed_gop = 1;
+ mod->cfg_interlaced = 0;
+ mod->cfg_quarterpel = 0;
+ mod->cfg_gmc = 0;
+ mod->cfg_trellis = 0;
+ mod->cfg_cartoon = 0;
+ mod->cfg_hqacpred = 1;
+ mod->cfg_chromame = 1;
+ mod->cfg_vhq = 1;
+ mod->cfg_bvhq = 0;
+ mod->cfg_motion = 6;
+ mod->cfg_turbo = 0;
+ mod->cfg_full1pass = 0;
+ mod->cfg_stats = 0;
+ mod->cfg_greyscale = 0;
+ mod->cfg_quant_method = "h263";
+ mod->cfg_create.max_bframes = 1;
+ mod->cfg_create.bquant_ratio = 150;
+ mod->cfg_create.bquant_offset = 100;
+ mod->cfg_lumimask = 0;
+}
+
+static void cleanup_module(XviDPrivateData *mod)
+{
+
+ /* Free tcvideo handle */
+ if (mod->tcvhandle != NULL) {
+ tcv_free(mod->tcvhandle);
+ mod->tcvhandle = NULL;
+ }
+
+ /* Release stream buffer memory */
+ if(mod->stream != NULL) {
+ free(mod->stream);
+ mod->stream = NULL;
+ }
+
+ /* Release the matrix file name string */
+ if(mod->cfg_inter_matrix_file != NULL) {
+ tc_free(mod->cfg_inter_matrix_file);
+ mod->cfg_inter_matrix_file = NULL;
+ }
+
+ /* Release the matrix definition */
+ if(mod->cfg_frame.quant_inter_matrix != NULL) {
+ tc_free(mod->cfg_frame.quant_inter_matrix);
+ mod->cfg_frame.quant_inter_matrix = NULL;
+ }
+
+ /* Release the matrix file name string */
+ if(mod->cfg_intra_matrix_file != NULL) {
+ tc_free(mod->cfg_intra_matrix_file);
+ mod->cfg_intra_matrix_file = NULL;
+ }
+
+ /* Release the matrix definition */
+ if(mod->cfg_frame.quant_intra_matrix != NULL) {
+ tc_free(mod->cfg_frame.quant_intra_matrix);
+ mod->cfg_frame.quant_intra_matrix = NULL;
+ }
+}
+
+/*****************************************************************************
+ * Configuration functions
+ *
+ * They fill the .cfg_xxx members of the module structure.
+ * - read_config_file reads the values from the config file and sets .cfg_xxx
+ * members of the module structure.
+ * - dispatch_settings uses the values retrieved by read_config_file and
+ * turns them into XviD settings in the cfg_xxx xvid structure available
+ * in the module structure.
+ * - set_create_struct sets a xvid_enc_create structure according to the
+ * settings generated by the two previous functions calls.
+ * - set_frame_struct same as above for a xvid_enc_frame_t struct.
+ ****************************************************************************/
+
+#define INTRA_MATRIX 0
+#define INTER_MATRIX 1
+
+static void load_matrix(XviDPrivateData *mod, int type)
+{
+ xvid_enc_frame_t *frame = &mod->cfg_frame;
+ const char *filename = (type == INTER_MATRIX)
+ ?mod->cfg_inter_matrix_file
+ :mod->cfg_intra_matrix_file;
+ uint8_t *matrix = NULL;
+
+ if (!filename) {
+ return;
+ }
+
+ matrix = tc_malloc(TC_MATRIX_SIZE);
+ if (matrix != NULL) {
+ int ret = tc_read_matrix(filename, matrix, NULL);
+
+ if (ret == 0) {
+ tc_log_info(MOD_NAME, "Loaded %s matrix (switching to "
+ "mpeg quantization type)",
+ (type == INTER_MATRIX) ?"Inter" :"Intra");
+ //print_matrix(matrix, NULL);
+ //free(mod->cfg_quant_method);
+ mod->cfg_quant_method = "mpeg";
+ } else {
+ tc_free(matrix);
+ matrix = NULL;
+ }
+ }
+
+ if (type == INTER_MATRIX) {
+ frame->quant_inter_matrix = matrix;
+ } else {
+ frame->quant_intra_matrix = matrix;
+ }
+}
+
+static void read_config_file(XviDPrivateData *mod)
+{
+ xvid_plugin_single_t *onepass = &mod->cfg_onepass;
+ xvid_plugin_2pass2_t *pass2 = &mod->cfg_pass2;
+ xvid_enc_create_t *create = &mod->cfg_create;
+ xvid_enc_frame_t *frame = &mod->cfg_frame;
+
+ TCConfigEntry xvid_config[] = {
+ /* Section [features] */
+// {"features", "Feature settings", TCCONF_TYPE_SECTION, 0, 0, 0},
+ {"quant_type", &mod->cfg_quant_method, TCCONF_TYPE_STRING, 0, 0, 0},
+ {"motion", &mod->cfg_motion, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 6},
+ {"chromame", &mod->cfg_chromame, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"vhq", &mod->cfg_vhq, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 4},
+ {"bvhq", &mod->cfg_bvhq, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"max_bframes", &create->max_bframes, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 20},
+ {"bquant_ratio", &create->bquant_ratio, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 200},
+ {"bquant_offset", &create->bquant_offset, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 200},
+ {"bframe_threshold", &frame->bframe_threshold, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, -255, 255},
+ {"quarterpel", &mod->cfg_quarterpel, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"gmc", &mod->cfg_gmc, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"trellis", &mod->cfg_trellis, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"packed", &mod->cfg_packed, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"closed_gop", &mod->cfg_closed_gop, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"interlaced", &mod->cfg_interlaced, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"cartoon", &mod->cfg_cartoon, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"hqacpred", &mod->cfg_hqacpred, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"frame_drop_ratio", &create->frame_drop_ratio, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100},
+ {"stats", &mod->cfg_stats, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"greyscale", &mod->cfg_greyscale, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"turbo", &mod->cfg_turbo, TCCONF_TYPE_FLAG, 0, 0, 1},
+#if XVID_API >= XVID_MAKE_API(4,1)
+ {"threads", &create->num_threads, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 8},
+#endif
+ {"full1pass", &mod->cfg_full1pass, TCCONF_TYPE_FLAG, 0, 0, 1},
+ {"luminance_masking", &mod->cfg_lumimask, TCCONF_TYPE_FLAG, 0, 0, 1},
+
+ /* section [quantizer] */
+// {"quantizer", "Quantizer settings", TCCONF_TYPE_SECTION, 0, 0, 0},
+ {"min_iquant", &create->min_quant[0], TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 31},
+ {"max_iquant", &create->max_quant[0], TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 31},
+ {"min_pquant", &create->min_quant[1], TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 31},
+ {"max_pquant", &create->max_quant[1], TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 31},
+ {"min_bquant", &create->min_quant[2], TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 31},
+ {"max_bquant", &create->max_quant[2], TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 1, 31},
+ {"quant_intra_matrix", &mod->cfg_intra_matrix_file, TCCONF_TYPE_STRING, 0, 0, 100},
+ {"quant_inter_matrix", &mod->cfg_inter_matrix_file, TCCONF_TYPE_STRING, 0, 0, 100},
+
+ /* section [cbr] */
+// {"cbr", "CBR settings", TCCONF_TYPE_SECTION, 0, 0, 0},
+ {"reaction_delay_factor", &onepass->reaction_delay_factor, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100},
+ {"averaging_period", &onepass->averaging_period, TCCONF_TYPE_INT, TCCONF_FLAG_MIN, 0, 0},
+ {"buffer", &onepass->buffer, TCCONF_TYPE_INT, TCCONF_FLAG_MIN, 0, 0},
+
+ /* section [vbr] */
+// {"vbr", "VBR settings", TCCONF_TYPE_SECTION, 0, 0, 0},
+ {"keyframe_boost", &pass2->keyframe_boost, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100},
+ {"curve_compression_high", &pass2->curve_compression_high, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100},
+ {"curve_compression_low", &pass2->curve_compression_low, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100},
+ {"overflow_control_strength", &pass2->overflow_control_strength, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100},
+ {"max_overflow_improvement", &pass2->max_overflow_improvement, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100},
+ {"max_overflow_degradation", &pass2->max_overflow_degradation, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100},
+ {"kfreduction", &pass2->kfreduction, TCCONF_TYPE_INT, TCCONF_FLAG_RANGE, 0, 100},
+ {"kfthreshold", &pass2->kfthreshold, TCCONF_TYPE_INT, TCCONF_FLAG_MIN, 0, 0},
+ {"container_frame_overhead", &pass2->container_frame_overhead, TCCONF_TYPE_INT, TCCONF_FLAG_MIN, 0, 0},
+
+ /* End of the config file */
+ {NULL, 0, 0, 0, 0, 0}
+ };
+
+ /* Read the values */
+ module_read_config(XVID_CONFIG_FILE, NULL, xvid_config, MOD_NAME);
+
+ /* Print the values */
+ if (verbose & TC_DEBUG) {
+ module_print_config(xvid_config, MOD_NAME);
+ }
+
+ return;
+}
+
+static void dispatch_settings(XviDPrivateData *mod)
+{
+
+ xvid_enc_create_t *create = &mod->cfg_create;
+ xvid_enc_frame_t *frame = &mod->cfg_frame;
+
+ const int motion_presets[7] =
+ {
+ 0,
+ 0,
+ 0,
+ 0,
+ XVID_ME_HALFPELREFINE16,
+ XVID_ME_HALFPELREFINE16 | XVID_ME_ADVANCEDDIAMOND16,
+ XVID_ME_HALFPELREFINE16 | XVID_ME_EXTSEARCH16 |
+ XVID_ME_HALFPELREFINE8 | XVID_ME_USESQUARES16
+ };
+
+
+ /* Dispatch all settings having an impact on the "create" structure */
+ create->global = 0;
+
+ if (mod->cfg_packed) {
+ create->global |= XVID_GLOBAL_PACKED;
+ }
+ if (mod->cfg_closed_gop) {
+ create->global |= XVID_GLOBAL_CLOSED_GOP;
+ }
+ if (mod->cfg_stats) {
+ create->global |= XVID_GLOBAL_EXTRASTATS_ENABLE;
+ }
+ /* Dispatch all settings having an impact on the "frame" structure */
+ frame->vol_flags = 0;
+ frame->vop_flags = 0;
+ frame->motion = 0;
+
+ frame->vop_flags |= XVID_VOP_HALFPEL;
+ frame->motion |= motion_presets[mod->cfg_motion];
+
+ if (mod->cfg_stats) {
+ frame->vol_flags |= XVID_VOL_EXTRASTATS;
+ }
+ if (mod->cfg_greyscale) {
+ frame->vop_flags |= XVID_VOP_GREYSCALE;
+ }
+ if (mod->cfg_cartoon) {
+ frame->vop_flags |= XVID_VOP_CARTOON;
+ frame->motion |= XVID_ME_DETECT_STATIC_MOTION;
+ }
+
+ load_matrix(mod, INTRA_MATRIX);
+ load_matrix(mod, INTER_MATRIX);
+
+ if (!strcasecmp(mod->cfg_quant_method, "mpeg")) {
+ frame->vol_flags |= XVID_VOL_MPEGQUANT;
+ }
+ if (mod->cfg_quarterpel) {
+ frame->vol_flags |= XVID_VOL_QUARTERPEL;
+ frame->motion |= XVID_ME_QUARTERPELREFINE16;
+ frame->motion |= XVID_ME_QUARTERPELREFINE8;
+ }
+ if (mod->cfg_gmc) {
+ frame->vol_flags |= XVID_VOL_GMC;
+ frame->motion |= XVID_ME_GME_REFINE;
+ }
+ if (mod->cfg_interlaced) {
+ frame->vol_flags |= XVID_VOL_INTERLACING;
+ }
+ if (mod->cfg_trellis) {
+ frame->vop_flags |= XVID_VOP_TRELLISQUANT;
+ }
+ if (mod->cfg_hqacpred) {
+ frame->vop_flags |= XVID_VOP_HQACPRED;
+ }
+ if (mod->cfg_motion > 4) {
+ frame->vop_flags |= XVID_VOP_INTER4V;
+ }
+ if (mod->cfg_chromame) {
+ frame->motion |= XVID_ME_CHROMA_PVOP;
+ frame->motion |= XVID_ME_CHROMA_BVOP;
+ }
+ if (mod->cfg_vhq >= 1) {
+ frame->vop_flags |= XVID_VOP_MODEDECISION_RD;
+ }
+ if (mod->cfg_vhq >= 2) {
+ frame->motion |= XVID_ME_HALFPELREFINE16_RD;
+ frame->motion |= XVID_ME_QUARTERPELREFINE16_RD;
+ }
+ if (mod->cfg_vhq >= 3) {
+ frame->motion |= XVID_ME_HALFPELREFINE8_RD;
+ frame->motion |= XVID_ME_QUARTERPELREFINE8_RD;
+ frame->motion |= XVID_ME_CHECKPREDICTION_RD;
+ }
+ if (mod->cfg_vhq >= 4) {
+ frame->motion |= XVID_ME_EXTSEARCH_RD;
+ }
+ if (mod->cfg_turbo) {
+ frame->motion |= XVID_ME_FASTREFINE16;
+ frame->motion |= XVID_ME_FASTREFINE8;
+ frame->motion |= XVID_ME_SKIP_DELTASEARCH;
+ frame->motion |= XVID_ME_FAST_MODEINTERPOLATE;
+ frame->motion |= XVID_ME_BFRAME_EARLYSTOP;
+ }
+ if (mod->cfg_bvhq) {
+#if XVID_API >= XVID_MAKE_API(4,1)
+ frame->vop_flags |= XVID_VOP_RD_BVOP;
+#endif
+ }
+
+ /* motion level == 0 means no motion search which is equivalent to
+ * intra coding only */
+ if (mod->cfg_motion == 0) {
+ frame->type = XVID_TYPE_IVOP;
+ } else {
+ frame->type = XVID_TYPE_AUTO;
+ }
+
+ return;
+}
+
+static void set_create_struct(XviDPrivateData *mod, const vob_t *vob)
+{
+ xvid_enc_create_t *x = &mod->xvid_enc_create;
+ xvid_enc_create_t *xcfg = &mod->cfg_create;
+
+ memset(x, 0, sizeof(xvid_enc_create_t));
+ x->version = XVID_VERSION;
+
+ /* Global encoder options */
+ x->global = xcfg->global;
+
+ /* Width and Height */
+ x->width = vob->ex_v_width;
+ x->height = vob->ex_v_height;
+
+ /* Max keyframe interval */
+ x->max_key_interval = vob->divxkeyframes;
+
+ /* FPS : we take care of non integer values */
+ if ((vob->ex_fps - (int)vob->ex_fps) == 0) {
+ x->fincr = 1;
+ x->fbase = (int)vob->ex_fps;
+ } else {
+ x->fincr = 1001;
+ x->fbase = (int)(1001 * vob->ex_fps);
+ }
+
+ /* BFrames settings */
+ x->max_bframes = xcfg->max_bframes;
+ x->bquant_ratio = xcfg->bquant_ratio;
+ x->bquant_offset = xcfg->bquant_offset;
+
+ /* Frame dropping factor */
+ x->frame_drop_ratio = xcfg->frame_drop_ratio;
+
+ /* Quantizers */
+ x->min_quant[0] = xcfg->min_quant[0];
+ x->min_quant[1] = xcfg->min_quant[1];
+ x->min_quant[2] = xcfg->min_quant[2];
+ x->max_quant[0] = xcfg->max_quant[0];
+ x->max_quant[1] = xcfg->max_quant[1];
+ x->max_quant[2] = xcfg->max_quant[2];
+
+ /* Encodings zones
+ * ToDo?: Allow zones definitions */
+ memset(mod->zones, 0, sizeof(mod->zones));
+ x->zones = mod->zones;
+
+ if (1 == vob->divxmultipass && mod->cfg_full1pass)
+ {
+ x->zones[0].frame = 0;
+ x->zones[0].mode = XVID_ZONE_QUANT;
+ x->zones[0].increment = 200;
+ x->zones[0].base = 100;
+ x->num_zones = 1;
+ } else {
+ x->num_zones = 0;
+ }
+
+ /* Plugins */
+ memset(mod->plugins, 0, sizeof(mod->plugins));
+ x->plugins = mod->plugins;
+ x->num_plugins = 0;
+
+ /* Initialize rate controller plugin */
+
+ /* This is the first pass of a Two pass process */
+ if (vob->divxmultipass == 1) {
+ xvid_plugin_2pass1_t *pass1 = &mod->pass1;
+
+ memset(pass1, 0, sizeof(xvid_plugin_2pass1_t));
+ pass1->version = XVID_VERSION;
+ pass1->filename = (char*)vob->divxlogfile; /* XXX: ugh */
+
+ x->plugins[x->num_plugins].func = xvid_plugin_2pass1;
+ x->plugins[x->num_plugins].param = pass1;
+ x->num_plugins++;
+ }
+
+ /* This is the second pass of a Two pass process */
+ if (vob->divxmultipass == 2) {
+ xvid_plugin_2pass2_t *pass2 = &mod->pass2;
+ xvid_plugin_2pass2_t *pass2cfg = &mod->cfg_pass2;
+
+ memset(pass2, 0, sizeof(xvid_plugin_2pass2_t));
+ pass2->version = XVID_VERSION;
+ pass2->filename = (char*)vob->divxlogfile; /* XXX: ugh */
+
+ /* Apply config file settings if any, or all 0s which lets XviD
+ * apply its defaults */
+ pass2->keyframe_boost = pass2cfg->keyframe_boost;
+ pass2->curve_compression_high = pass2cfg->curve_compression_high;
+ pass2->curve_compression_low = pass2cfg->curve_compression_low;
+ pass2->overflow_control_strength = pass2cfg->overflow_control_strength;
+ pass2->max_overflow_improvement = pass2cfg->max_overflow_improvement;
+ pass2->max_overflow_degradation = pass2cfg->max_overflow_degradation;
+ pass2->kfreduction = pass2cfg->kfreduction;
+ pass2->kfthreshold = pass2cfg->kfthreshold;
+ pass2->container_frame_overhead = pass2cfg->container_frame_overhead;
+
+ /* Positive bitrate values are bitrates as usual but if the
+ * value is negative it is considered as being a total size
+ * to reach (in kilobytes) */
+ if (vob->divxbitrate > 0) {
+ pass2->bitrate = vob->divxbitrate*1000;
+ } else {
+ pass2->bitrate = vob->divxbitrate;
+ }
+ x->plugins[x->num_plugins].func = xvid_plugin_2pass2;
+ x->plugins[x->num_plugins].param = pass2;
+ x->num_plugins++;
+ }
+
+ /* This is a single pass encoding: either a CBR pass or a constant
+ * quantizer pass */
+ if (vob->divxmultipass == 0 || vob->divxmultipass == 3) {
+ xvid_plugin_single_t *onepass = &mod->onepass;
+ xvid_plugin_single_t *cfgonepass = &mod->cfg_onepass;
+
+ memset(onepass, 0, sizeof(xvid_plugin_single_t));
+ onepass->version = XVID_VERSION;
+ onepass->bitrate = vob->divxbitrate*1000;
+
+ /* Apply config file settings if any, or all 0s which lets XviD
+ * apply its defaults */
+ onepass->reaction_delay_factor = cfgonepass->reaction_delay_factor;
+ onepass->averaging_period = cfgonepass->averaging_period;
+ onepass->buffer = cfgonepass->buffer;
+
+ /* Quantizer mode uses the same plugin, we have only to define
+ * a constant quantizer zone beginning at frame 0 */
+ if (vob->divxmultipass == 3) {
+ x->zones[x->num_zones].mode = XVID_ZONE_QUANT;
+ x->zones[x->num_zones].frame = 1;
+ x->zones[x->num_zones].increment = vob->divxbitrate;
+ x->zones[x->num_zones].base = 1;
+ x->num_zones++;
+ }
+
+
+ x->plugins[x->num_plugins].func = xvid_plugin_single;
+ x->plugins[x->num_plugins].param = onepass;
+ x->num_plugins++;
+ }
+
+ if (mod->cfg_lumimask) {
+#if XVID_API >= XVID_MAKE_API(4,1)
+ x->plugins[x->num_plugins].func = xvid_plugin_lumimasking;
+ x->plugins[x->num_plugins].param = NULL;
+ x->num_plugins++;
+#endif
+ }
+
+ return;
+}
+
+static void set_frame_struct(XviDPrivateData *mod, vob_t *vob,
+ const vframe_list_t *inframe, vframe_list_t *outframe)
+{
+ xvid_enc_frame_t *x = &mod->xvid_enc_frame;
+ xvid_enc_frame_t *xcfg = &mod->cfg_frame;
+
+ memset(x, 0, sizeof(xvid_enc_frame_t));
+ x->version = XVID_VERSION;
+
+ /* Bind output buffer */
+ x->bitstream = outframe->video_buf;
+
+ if (!inframe) { /* flush request */
+ x->length = -1;
+ x->input.csp = XVID_CSP_NULL;
+ x->input.plane[0] = NULL;
+// x->input.plane[1] = NULL;
+// x->input.plane[2] = NULL;
+ x->input.stride[0] = 0;
+// x->input.stride[1] = 0;
+// x->input.stride[2] = 0;
+ } else {
+ x->length = outframe->video_size;
+
+ /* Bind source frame */
+ x->input.plane[0] = inframe->video_buf;
+ if (vob->im_v_codec == CODEC_RGB) {
+ x->input.csp = XVID_CSP_BGR;
+ x->input.stride[0] = vob->ex_v_width*3;
+ } else if (vob->im_v_codec == CODEC_YUV422) {
+ x->input.csp = XVID_CSP_UYVY;
+ x->input.stride[0] = vob->ex_v_width*2;
+ } else {
+ x->input.csp = XVID_CSP_I420;
+ x->input.stride[0] = vob->ex_v_width;
+ }
+ }
+ /* Set up core's VOL level features */
+ x->vol_flags = xcfg->vol_flags;
+
+ /* Set up core's VOP level features */
+ x->vop_flags = xcfg->vop_flags;
+
+ /* Frame type -- let core decide for us */
+ x->type = xcfg->type;
+
+ /* Force the right quantizer -- It is internally managed by RC
+ * plugins */
+ x->quant = 0;
+
+ /* Set up motion estimation flags */
+ x->motion = xcfg->motion;
+
+ /* We don't use special matrices */
+ 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) {
+ 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;
+ /* par_{width,height} already set to zero above */
+ }
+ return;
+}
+
+/*****************************************************************************
+ * Returns an error string corresponding to the XviD err code
+ ****************************************************************************/
+
+static const char *errorstring(int err)
+{
+ const char *error;
+
+ switch(err) {
+ case XVID_ERR_FAIL:
+ error = "General fault";
+ break;
+ case XVID_ERR_MEMORY:
+ error = "Memory allocation error";
+ break;
+ case XVID_ERR_FORMAT:
+ error = "File format error";
+ break;
+ case XVID_ERR_VERSION:
+ error = "Structure version not supported";
+ break;
+ case XVID_ERR_END:
+ error = "End of stream reached";
+ break;
+ default:
+ error = "Unknown";
+ }
+
+ return error;
+}
+
+/*************************************************************************/
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * c-file-offsets: ((case-label . *) (statement-case-intro . *))
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+ */
diff --git a/debian/transcode/transcode-1.1.7/encode/lavc.cfg b/debian/transcode/transcode-1.1.7/encode/lavc.cfg
new file mode 100644
index 00000000..13fbc33f
--- /dev/null
+++ b/debian/transcode/transcode-1.1.7/encode/lavc.cfg
@@ -0,0 +1,6 @@
+###########################################################################
+# transcode's libavcodec encoder configuration file sample #
+###########################################################################
+#
+# FIXME: write me, with examples and explanations :)
+#
diff --git a/debian/transcode/transcode-1.1.7/encode/x264.cfg b/debian/transcode/transcode-1.1.7/encode/x264.cfg
new file mode 100644
index 00000000..c08641ff
--- /dev/null
+++ b/debian/transcode/transcode-1.1.7/encode/x264.cfg
@@ -0,0 +1,278 @@
+###############################
+# General encoding parameters #
+###############################
+
+# threads = <N>
+# Sets the number of threads to be used for processing. N must be
+# between 1 and 4 inclusive.
+#threads = 1
+
+# 2pass_bug_workaround
+# Enables a workaround for an x264 bug which sometimes causes the
+# second pass of a 2-pass encode to fail while reading the 2-pass
+# logfile.
+2pass_bug_workaround
+
+
+###########################
+# Video stream properties #
+###########################
+
+# level_idc = <N>
+# Sets the H.264 level to use for encoding. N can be any of the
+# following (note that the resolutions given are only examples; see
+# e.g. http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC):
+#
+# N Level Max. bitrate Resolution (WxH@FPS)
+# -- ----- ------------ ------------
+# 10 1 64 kbit/s 176x144@15
+# 11 1.1 192 kbit/s 320x240@10
+# 12 1.2 384 kbit/s 320x240@20
+# 13 1.3 768 kbit/s 352x288@30
+# 20 2 2 Mbit/s 352x288@30
+# 21 2.1 4 Mbit/s 352x480@30
+# 22 2.2 4 Mbit/s 720x480@15
+# 30 3 10 Mbit/s 720x480@30
+# 31 3.1 14 Mbit/s 1280x720@30
+# 32 3.2 20 Mbit/s 1280x720@60
+# 40 4 20 Mbit/s 1920x1088@30
+# 41 4.1 50 Mbit/s 1920x1088@30
+# 42 4.2 50 Mbit/s 1920x1088@60
+# 50 5 135 Mbit/s 2560x1920@30
+# 51 5.1 240 Mbit/s 4096x2048@30
+#level_idc = 51
+
+# overscan = <N>
+# vidformat = <N>
+# fullrange | nofullrange
+# colorprim = <N>
+# transfer = <N>
+# colmatrix = <N>
+# chroma_loc = <N>
+# Set H.264 VUI properties. See the source code for details.
+#overscan = 0
+#vidformat = 5
+#nofullrange
+#colorprim = 2
+#transfer = 2
+#colmatrix = 2
+#chroma_loc = 0
+
+
+########################
+# Bitstream parameters #
+########################
+
+# frameref = <N>
+# Specifies the maximum number of reference frames to use (1-16).
+#frameref = 1
+
+# keyint_min = <N>
+# keyint_max = <N>
+# Specify the minimum and maximum keyframe intervals.
+#keyint_min = 25
+#keyint_max = 250
+
+# scenecut = <N>
+# Specifies the scene change detection threshold as a percentage
+# (0-100), or -1 to disable.
+#scenecut = 40
+
+# bframes = <N>
+# Specifies the number of B-frames between two reference frames (0-16).
+#bframes = 0
+
+# b_adapt | nob_adapt
+# Specifies whether or not to use adaptive B-frame encoding.
+#b_adapt
+
+# b_bias = <N>
+# Influences how often B-frames are used. <N> is from -90 to 100
+# inclusive.
+#b_bias = 0
+
+# b_pyramid | nob_pyramid
+# Specifies whether to allow B-frames to be used as references.
+#nob_pyramid
+
+# deblock | nodeblock
+# Selects whether to use the deblocking filter.
+# deblockalpha = <A>
+# deblockbeta = <B>
+# Specify parameters for the deblocking filter. <A> and <B> are
+# between -6 and 6 inclusive.
+#deblock
+#deblockalpha = 0
+#deblockbeta = 0
+
+# cabac | nocabac
+# Selects whether to use CABAC (context-adaptive binary arithmetic
+# coding).
+# cabac_init_idc = <N>
+# Specifies an internal CABAC parameter.
+#cabac
+#cabac_init_idc = 0
+
+# cqm = <N>
+# Specifies the type of quantization matrices to use:
+# 0: Flat matrices
+# 1: JVT matrices
+# 2: Custom matrices
+# cqm_file = <path>
+# Specifies the pathname for the custom matrix file with "cqm 2".
+#cqm = 0
+#cqm_file = /dev/null
+
+
+###############################
+# Encoder analyzer parameters #
+###############################
+
+# 8x8dct | no8x8dct
+# Specifies whether to allow integer 8x8 DCT transforms.
+#no8x8dct
+
+# weight_b | noweight_b
+# Specifies whether to use implicit weighting for B-frames.
+#noweight_b
+
+# direct_pred = <N>
+# Selects the type of motion vector (MV) prediction to use:
+# 0: none, 1: spatial, 2: temporal, 3: auto
+#direct_pred = 1
+
+# direct_8x8 | nodirect_8x8
+# Specifies whether to DISallow 4x4 direct partitions. Default depends
+# on level_idc.
+#nodirect_8x8
+
+# chroma_qp_offset = <N>
+# Specifies the QP offset between chroma and luma (-12 to +12).
+#chroma_qp_offset = 0
+
+# me = <N>
+# Selects the motion estimation algorithm to use:
+# 0: diagonal search, radius 1 (fast)
+# 1: hexagonal search, radius 2
+# 2: uneven multi-hexagon search
+# 3: exhaustive search (slow)
+#me = 1
+
+# me_range = <N>
+# Specifies the motion estimation search range (from the predicted MV),
+# 4 to 64 inclusive.
+#me_range = 16
+
+# mv_range = <N>
+# Specifies the maximum length of a motion vector, 32-2048 pixels.
+# Default depends on level_idc.
+#mv_range = 512
+
+# subq = <N>
+# Specifies the subpixel motion estimation quality, from 1 (fastest)
+# to 7 (best).
+#subq = 5
+
+# chroma_me | nochroma_me
+# Specifies whether to use chroma in motion estimation.
+#chroma_me
+
+# mixed_refs | nomixed_refs
+# Specifies whether to allow macroblock partitions in P-frames to have
+# individual references.
+#nomixed_refs
+
+# trellis = <N>
+# Specifies whether to use trellis RD quantization. Requires CABAC.
+# <N> is one of:
+# 0: disabled
+# 1: enabled only for final encoding of a macroblock
+# 2: enabled for all mode decisions
+#trellis = 0
+
+# fast_pskip | nofast_pskip
+# Specifies whether to use early SKIP detection for P-frames.
+#fast_pskip
+
+# dct_decimate | nodct_decimate
+# Specifies whether to use transform coefficient thresholding on P-frames.
+#dct_decimate
+
+# nr = <N>
+# Specifies noise reduction level (0-65536).
+#nr = 0
+
+# psnr | nopsnr
+# ssim | nossim
+# Specify whether to calculate PSNR/SSIM statistics (consumes some CPU
+# time).
+#psnr
+#ssim
+
+
+###########################
+# Rate control parameters #
+###########################
+
+# qp_min = <N>
+# qp_max = <N>
+# Specify the minimum and maximum allowed QP values (0-51, 0=lossless).
+# qp_step = <N>
+# Specifies the maximum difference between QP in consecutive frames.
+#qp_min = 10
+#qp_max = 51
+#qp_step = 4
+
+# crf = <N>
+# Specifies the nominal QP for 1-pass VBR encoding.
+#crf = 0
+
+# ratetol = <N>
+# Specifies the allowed variance from the average bitrate.
+#ratetol = 1.0
+
+# vbv_maxrate = <N>
+# Specifies the maximum allowed local bitrate, in kbit/s.
+#vbv_maxrate = 0
+
+# vbv_bufsize = <N>
+# Specifies the size of the VBV buffer for CBR encoding, in kbit.
+#vbv_bufsize = 0
+
+# vbv_init = <N>
+# Specifies the initial occupancy of the VBV buffer as a decimal value.
+#vbv_init = 0.9
+
+# ip_ratio = <N>
+# Specifies the QP ratio between I-frames and P-frames.
+#ip_ratio = 1.4
+
+# pb_ratio
+# Specifies the QP ratio between P-frames and B-frames.
+#pb_ratio = 1.3
+
+# rc_eq = <string>
+# Specifies the rate control equation.
+#rc_eq = blurCplx^(1-qComp)
+
+# qcomp = <N>
+# Specifies the QP curve compression ratio. 0.0 gives constant bitrate
+# encoding, while 1.0 gives constant quality encoding.
+#qcomp = 0.6
+
+# cplx_blur = <N>
+# Specifies the amount by which to blur complexity before QP compression.
+#cplx_blur = 20.0
+
+# qblur = <N>
+# Specifies the amount by which to blur the QP value after QP compression.
+#qblur = 0.5
+
+# zones = <string>
+# Specifies exceptions to the rate control handling for particular
+# frame ranges. The string is a slash-separated sequence of zones,
+# where each zone takes the form "start-frame,end-frame,option".
+# "start-frame" and "end-frame" define the zone, and "option" is one of:
+# q=<QP>: force QP to <QP> (0-51)
+# b=<factor>: multiply bitrate by <factor> (decimal value)
+#zones = 0,100,q=10/200,300,b=1.5
diff --git a/debian/transcode/transcode-1.1.7/encode/xvid.cfg b/debian/transcode/transcode-1.1.7/encode/xvid.cfg
new file mode 100644
index 00000000..6d6202fd
--- /dev/null
+++ b/debian/transcode/transcode-1.1.7/encode/xvid.cfg
@@ -0,0 +1,510 @@
+# ############################################################################
+# XviD 1.0 configuration file for transcode
+# ############################################################################
+
+
+# ----------------------------------------------------------------------------
+#
+# Section: Features
+#
+# The fist section of this configuration file concerns what is labeled as
+# "features". This allows you to turn on/off some options to adapt XviD to
+# your needs.
+# ----------------------------------------------------------------------------
+
+[features]
+
+# MPEG4 allows two methods to compress the image, the first one is derived
+# from h263, the other one is inspired by the MPEG2 matrix quantization.
+#
+# NB: defaults to h263 if a typing mistake is done.
+# defaults to mpeg if custom matrices filenames are specified.
+#
+# Values = h263 | mpeg
+
+quant_type = h263
+
+
+# This option controls the motion estimation subsystem. The higher the value,
+# the more precise the estimation should be. The more precise the motion
+# estimation is, the more bits can be saved. Precision is gained at the
+# expense of CPU time so decrease this setting if you need realtime encoding.
+#
+# Values = [0..6]
+#
+# 0 None
+# 1 Very Low
+# 2 Low
+# 3 Medium
+# 4 High
+# 5 Very High
+# 6 Ultra High
+#
+# Default = 6
+
+motion = 6
+
+# Motion estimation involves lot of refinement steps. Usually these steps help
+# reaching better quality, but not by much, and they use a fair amount of CPU.
+# So if you want to speedup Motion Estimation by skipping some refinement steps
+# and using simplified ME functions, you can activate the turbo mode.
+#
+# This setting turns on the ME turbo mode.
+#
+# Values = 0 (no) | 1 (yes)
+# Default = 0
+
+turbo = 0
+
+# The usual motion estimation algorithm uses only the luminance information
+# to find the best motion vector. However for some video material, using
+# the chromatic planes can help find better vectors.
+#
+# This setting turns on/off the use of chroma planes for Motion Estimation
+#
+# Values = 0 (no) | 1 (yes)
+# Default = 1
+
+chromame = 1
+
+
+# The motion search algorithm is based on a search in the usual color domain
+# and tries to find a motion vector that minimizes the difference between
+# the reference frame and the encoded frame.
+#
+# Activating this setting, XviD will also use the frequency domain (DCT) to
+# search a motion vector that minimizes not only the spatial difference but
+# also the encoding length of the block. The higher, the more precise and more
+# CPU intensive
+#
+# Values = [0..4]
+#
+# 0 Disabled
+# 1 Mode decision
+# 2 Limited search
+# 3 Medium search
+# 4 Wide search
+#
+# Default = 1
+
+vhq = 1
+
+
+# BFrames are the third type of frames available in MPEG4, they are predicted
+# thanks to 2 reference frames. Thus, bframes help usually in two cases:
+# 1/ saving bitrate w/o loss of quality
+# 2/ increasing the quality for a same bitrate
+#
+# This setting controls how many bframes the xvid encoder can output in a row.
+#
+# You must be aware that the higher max_bframes is, the more distant reference
+# frames are from each other. Thus prediction of reference frames become hard
+# and results in poor quality. If the reference frames have poor quality, so
+# the bframes will have. So as a rule of thumb, this setting has to be tuned
+# according to your exact needs. CVommon values are [0..2] for "natural movies
+# and a bit higher values for anime/cartoons with great amounts of constant color
+# areas.
+#
+# Values = >=0 (0 disables bframes usage)
+# Default = 1
+
+max_bframes = 1
+
+
+# As explained before, BFrames are highly correlated to its reference frames
+# Thus XviD computes their quantizer to its reference's quantizers.
+#
+# This two settings allow you to tune the formula:
+#
+# Values = [0..200]
+# Default = ratio 150 & offset 100
+
+bquant_ratio = 150
+bquant_offset = 100
+
+
+# Sometimes BFrames do not look good, and introduce artefacts when most of the
+# frame is static and some small zones have high motion (a static scene with a
+# man talking, his mouth will probably look bad if what is surrounding the man
+# and his mouth is completly static)
+#
+# This setting allow you to favorize or not, the use of bframes. The higher the
+# value, the more a bframe has chance to be used.
+#
+# Values [-255..255]
+# Default = 0
+
+bframe_threshold = 0
+
+
+# MPEG4 uses a half pixel precision for its motion search by default. The
+# standard proposes a mode where encoders are allowed to use quarter pixel
+# precision.
+#
+# This option usually results in sharper image. But it has great impact on
+# bitrate and sometimes the higher use of bitrate will prevent it from giving
+# a better image quality at a fixed bitrate. The better is to test w and w/o it
+# and choose after this test, if it's worth activting it.
+#
+# Values = 0 (no) | 1 (yes)
+# Default = 0
+
+quarterpel = 0
+
+
+# Makes XviD generates Sprite Frame which describe best Pan/Zoom/Rotating
+# images. Deciding wether or not you must activate it depends highly on the
+# video material
+#
+# Values = 0 (no) | 1 (yes)
+# Default = 0
+
+gmc = 0
+
+
+# Trellis Quantization is a kind of adaptive quantization method that saves
+# bits modifying quantized coefficients to make them more compressable by the
+# entropy encoder.
+#
+# Its impact on quality is good, and if VHQ uses too much CPU for you, this
+# setting can be a good alternative to save a few bits (and gain quality at
+# fixed bitrate) at a minimum expense.
+# than VHQ
+#
+# Values = 0 (no) | 1 (yes)
+# Default = 0
+
+trellis = 0
+
+
+# Depending on the container and frontend API, sometimes it is good to ask XviD
+# to group the first bframe of a group with its forward reference frame, that
+# prevents A/V desync
+#
+# This setting would be useful if it was used with VFW 1.1 encoders (Windows)
+# because this API does not allow audio contention when no video frames are
+# output.
+#
+# But transcode does not suffer from that API problem and the xvid4 module
+# informs transcode to delay frames when needed, so this option is mostly not
+# needed with transcode.
+#
+# Values = 0 (no) | 1 (yes)
+# Default = 0
+
+packed = 0
+
+
+# A GOP is a Group Of Pictures. Its bounded by two Intra Frames.
+#
+# This option controls if XviD must close a GOP, which means that a GOP is
+# independent from the next GOP. This implies just that the last frame of
+# the GOP is eiter a PFrame or a SFrame but not a BFrame. This is usually
+# a good idea to turn on the option
+#
+# Values = 0 (no) | 1 (yes)
+# Default = 1
+
+closed_gop = 1
+
+
+# For interlaced video material, turn this option to on.
+#
+# Values = 0 (no) | 1 (yes)
+# Default = 0
+
+interlaced = 0
+
+
+# Activate this if your encoded sequence is an Anime/Cartoon. It modifies some
+# XviD internal thresholds so XviD takes better decisions on frame types and
+# motion vectors for flat looking cartoons.
+#
+# Values = 0 (no) | 1 (yes)
+# Default = 0
+
+cartoon = 0
+
+
+# Activates High Quality AC coefficient prediction from neighboor blocks.
+#
+# Values = 0 (no) | 1 (yes)
+# Default = 1
+
+hqacpred = 1
+
+
+# XviD keeps track of block coding type (skipped, predicted, intra). The skipped
+# block counter can be used to choose wether a frame is so close to its reference
+# that it can be _completly_ skipped.
+#
+# This setting allows you to choose the (100 - value) threshold for skipping a
+# frame.
+#
+# Values = [0..100] (0 -> never skip a frame, 100 -> skip all frames)
+# Default = 0
+
+frame_drop_ratio = 0
+
+# XviD discard chroma planes bitstream so the encoded video is greyscale only.
+# Note that this does not speed up encoding, that just prevent chroma data
+# from being written in the last stage of encoding.
+#
+# This setting enable Chroma color discarding.
+#
+# Values = 0 (no) | 1 (yes)
+# Default = 0
+
+greyscale = 0
+
+# For testing purposes, or quality measurement, XviD can return some stats
+# about the encoded frames.
+#
+# This option activates PSNR measurement, the average PSNR is displayed at the
+# end of the encoding session. This option is probably something a Joe user
+# does not really care. This option makes the encoding a bit slower.
+#
+# Values = 0 (no) | 1 (yes)
+# Default = 0
+
+stats = 0
+
+# When doing the first pass of a 2-pass encode, the encoder takes some
+# shortcuts and does not produce a full quality encode. Must users have
+# no reason to do this, since the first pass is usually discarded.
+#
+# Setting this option forces the encoder to produce a full quality first
+# pass at Q2. Enabling this makes the first pass a lot slower, and should
+# only be enabled if you're using the resuts of the first pass for something.
+#
+# Values = 0 (standard first pass) | 1 (full quality first pass)
+# Default = 0
+
+full1pass = 0
+
+# ----------------------------------------------------------------------------
+#
+# Section: Quantizer
+#
+# This section allows you to tune quantizing process.
+# ----------------------------------------------------------------------------
+
+[quantizer]
+
+# The next 6 settings control the valid range of quantizers for a specific frame
+# type
+#
+# a [2..31] range is probably good for all sequences, you can decrease the higher
+# bound limit if you notice some scenes with artefacts. However, restricting the
+# valid range can make the bitrate controller fails to achieve the desired bitrate
+#
+# Use this ranges with MUCH care
+#
+# Values = [0..31]
+# 1-> small quantizer -> better quality
+# 31-> high quantizer -> bad quality
+# 0 has a special meaning, it lets XviD uses its own default values
+
+min_iquant = 2
+max_iquant = 31
+min_pquant = 2
+max_pquant = 31
+min_bquant = 2
+max_bquant = 31
+
+# With the MPEG quantization method you can provide custom matrices optimized
+# your video material.
+#
+# A matrix file is just a file where 64 decimal values ranged in 1..255 are
+# specified separated by space chars (newline, space, tabs)
+#
+# The 8x8 matrix is then rebuilt like that
+#
+# [ first coeff, second coeff, ... eighth coeff]
+# [ ninth coeff, ... ]
+# [ ... ]
+# [ ]
+# [ ]
+# [ ]
+# [ ]
+# [ ]
+#
+# Value = filename of the matrix
+# Default : none (no custom matrix)
+
+#quant_intra_matrix =
+#quant_inter_matrix =
+
+
+# ----------------------------------------------------------------------------
+#
+# Section: CBR
+#
+# This section allows you to tune the Constant Bitrate settings.
+# ----------------------------------------------------------------------------
+
+[cbr]
+
+# This parameter controls the delay in frames before the CBR rate controller
+# will react to bitrate changes and will try to compensate the change to obtain
+# a constant bitrate over an averaging range of frames (see below).
+#
+# Value = >=0
+# Default = 16
+# 0 has a special meaning, it lets XviD uses its own default values
+
+reaction_delay_factor = 16
+
+
+# Real CBR is hard to achieve. Depending on the video material, bitrate can be
+# variable, and hard to predict. That's why XviD uses an averaging period for
+# which it guarantees a given amount of bits (minus a small variation).
+#
+# This settings express the "number of frames" for which XviD averages bitrate
+# and tries to achieve CBR.
+#
+# Value = >=0
+# Default = 100
+# 0 has a special meaning, it lets XviD uses its own default values
+
+averaging_period = 100
+
+
+# Todo: find its exact meaning
+#
+# Value = >=0
+# Default = 100
+# 0 has a special meaning, it lets XviD uses its own default values
+
+buffer = 100
+
+# ----------------------------------------------------------------------------
+#
+# Section: VBR
+#
+# This section allows you to tune the Variable Bitrate controller settings.
+# (2nd pass control in simpler words)
+# ----------------------------------------------------------------------------
+
+[vbr]
+
+# The two pass algorithm scales the initial bitrate curve to obtain one that
+# respect both the user target bitrate and the natural shape of the first pass
+# curve. However it is possible to give an additionnal amount of bits for Intra
+# frames.
+#
+# This setting tells how many additional amount of bits, Intra Frames are
+# supposed to be given (this "bossting" amount of bits is compensated by
+# subtracting the same amount of bits from other frame types pool)
+#
+# Value = [0..100]
+# Default = 0
+
+keyframe_boost = 0
+
+
+# This settigs control how much the upper part of the curve has to get closer
+# to the average bitrate value. The upper part of the curve is the set of values
+# that are higher than the curve average. It is expressed in %.
+#
+# Think of that setting like a shrinking factor for the upper part of the
+# curve.
+#
+# Value = [0..100]
+# Default = 0
+
+curve_compression_high = 0
+
+
+# This settigs control how much the lower part of the curve has to get closer
+# to the average bitrate value. The lower part of the curve is the set of values
+# that are lower than the curve average. It is expressed in %.
+#
+# Think of that setting like a growing factor for the lower part of the
+# curve.
+#
+# Value = [0..100]
+# Default = 0
+
+curve_compression_low = 0
+
+
+# During two pass, a scaled bitrate curve is computed. The difference between
+# that expected curve and the result obtained during encoding is called
+# overflow. Obviously, the two pass Rate Controller tries to compensate
+# that overflow distributing it over next frames to be encoded.
+#
+# This setting controls how much overflow is distributed at each new frame.
+# Low values allow lazy overflow control, big rate bursts are compensated more
+# slowly (could lead to lack of precision for small clips). High values
+# make RC compensate very hard the overflow, this can have a very bad impact on
+# quality during rate bursts.
+#
+# NB: This setting impacts quality a lot, play with it carefully !
+#
+# Value = [0..100]
+# Default = 0
+# 0 has a special meaning, it lets XviD uses its own default values
+
+overflow_control_strength = 5
+
+# During the frame bit allocation, overflow control may increase the frame
+# size. This parameter controls how much the overflow control is allowed
+# to increase the frame size in percent compared to the ideal curve allocation
+#
+# Value = >=0
+# Default = 60
+# 0 has a special meaning, it lets XviD uses its own default values
+
+max_overflow_improvement = 5
+
+
+# During the frame bit allocation, overflow control may decrease the frame
+# size. This parameter controls how much the overflow control is allowed
+# to decrease the frame size in percent compared to the ideal curve allocation
+#
+# Value = >=0
+# Default = 60
+# 0 has a special meaning, it lets XviD uses its own default values
+
+max_overflow_degradation = 5
+
+
+# This reduction factor is the maximum allowed keyframe penalty applied to
+# a frame in a ivop sequence. The more the frame is distant from the last
+# ivop in the consecutive ivop sequence, the more penalty it is applied.
+# This ensures a maximum bitrate allocation to the last ivop, thus favorizing
+# a good reference frame for following p/s/b vops.
+#
+# Value = >=0
+# Default = 20
+# 0 has a special meaning, it lets XviD uses its own default values
+
+kfreduction = 20
+
+
+# Distance between two ivops so that it is not decresed its bit allocation by
+# the ivop reduction mechanism.
+#
+# Value = >=0
+# Default = 1
+# 0 has a special meaning, it lets XviD uses its own default values
+
+kfthreshold = 1
+
+
+# Most of the time users express their target bitrate for video w/o taking care
+# of the video container overhead. This small but (mostly) constant overhead
+# can make the target file size is not respected (oversized result). We decided
+# to allow users to set the amount of overhead per frame the container generates
+# (give only an average per frame)
+#
+# Value = >=0
+# Default = 24 (AVI frame average overhead per frame in bytes)
+# 0 has a special meaning, it lets XviD uses its own default values
+
+container_frame_overhead = 24
+
+##############################################################################
+# Do not modify this tag comment
+# arch-tag: bb7970c1-33fb-4c8c-8d1b-742ff2e53336 xvid config file