Imported Upstream version 0.9.5

Erik Walthinsen <>
Charles 'Buck' Krasic <>
James Bowman <>
Scott F. Johnston <>
Stefan Lucke <>
Daniel Kobras <>
Peter Schlaile <>
Arne Schirmacher <>
Thom van Os <>
Andreas Wacker <>
Artur Zaprzala <>
Dan Dennedy <>
This diff is collapsed.
/* libdv
* Copyright (C) <1999> Erik Walthinsen <>
* Charles 'Buck' Krasic <>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* Library General Public License for more details.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
This diff is collapsed.
Basic Installation
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `' is used to create `configure' by a program
called `autoconf'. You only need `' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
Installation Names
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/' if it exists, then
`PREFIX/etc/' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
`configure' recognizes the following options to control how it
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
Print a summary of the options to `configure', and exit.
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.
SUBDIRS = libdv playdv encodedv
AUX_DIST = $(ac_aux_dir)/config.guess \
$(ac_aux_dir)/config.sub \
$(ac_aux_dir)/install-sh \
$(ac_aux_dir)/ltconfig \
$(ac_aux_dir)/ \
$(ac_aux_dir)/missing \
$(ac_aux_dir)/depcomp \
EXTRA_DIST = bootstrap COPYRIGHT README.encoder README.dvconnect \
MAINTAINERCLEANFILES = aclocal.m4 configure \ config.log config.status $(AUX_DIST)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libdv.pc
rpm: dist
rpm -ta @PACKAGE@-@VERSION@.tar.gz
(cd $(distdir) && if [ ! -d $(ac_aux_dir); then mkdir $(ac_aux_dir); fi)
for file in $(AUX_DIST) $(AUX_DIST_EXTRA); do \
cp $$file $(distdir)/$$file; \
rm -f libdv*.tar.gz
rm -rf autom*.cache
This diff is collapsed.
The best place to keep up with events is to check the libdv mailing
This is LibDV, a GPL codec for DV video.
LibDV now uses the GNU "Autotools" for building.
BUILDING from CVS checkout
The CVS repository does not contain files generated by the autotools,
so you need to run the bootstrap script*:
You can ignore the following error messages:
automake: installing `config/install-sh'
error while copying
automake: installing `config/mkinstalldirs'
error while copying
automake: installing `config/missing'
error while copying
After that, you can do this to build the library and the example
./configure --enable-maintainer-mode
The maintainer-mode is if you are on a system that has recent
autotools installed, and you wish to make changes to the build
The makefile generated by the autotools is very large, so the more
useful targets don't jump out at you. Here are a few.
Build a "tar.gz" distribution file:
make dist
Build a rpm package file. This requires you run as root, or you
setup your ~/.rpmmacros to allow building rpms without root:
make rpm
Clean up objects and binaries:
make clean
Clean up including files generated by autotools, which should return
the working directory state to be like it as after a CVS checkout:
make maintainer-clean
* The autotools book ( recommends
"bootstrap" instead of
NTSC Setup/Pedestal
The decoder's add_ntsc_setup option should only be used
by North American NTSC users when viewing the video on your computer
monitor. It should never be used when transcoding, image processing,
or rendering.
The encoder's rem_ntsc_setup (rem=remove) should be used
only in the rare case that an image has had 7.5 IRE setup artificially
added. During post-production, accounting for setup should be avoided.
It is the responsibility of the analog output of your DV equipment to
add setup where appropriate. If your DV equipment lacks this option,
then use a processing amplifier.
These options--both for decoding
and encoding--are always ignored for PAL video.
For more information see Adam Wilt's DV FAQ:
Luma and Chroma Clamping
ITU-R 601 specifies that the legal range for luma is 16-235 and
for chroma is 16-240 regardless of NTSC, PAL, or setup issues. However,
some users take advantage of the footroom or headroom below or above
these ranges to encode additional information for things such as
luma keying. The luma and chroma clamp options permit the range checking
to be disabled to preserve the superblack and superwhite.
For more information read Charles' Poyton's Color FAQ:
and his white paper "Merging Computing with Studio Video:
Converting Between R'G'B' and 4:2:2":
dvconnect is a small utility to send / capture raw data from / to the
camcorder over an OHCI complient IEEE 1394 firewire adapter. It has to be
an OHCI adapter since we use the video1394 interface. (It could be done for
receiving without it, but for sending it's the only way to go!)
You should also install the latest Linux Kernel version (> 2.4.12 I think)
since otherwise the necessary patches for DV _sending_ are not included.
dvconnect was written to be simple and fast.
If it doesn't work for you, you might want to check out dvgrab from
Arne Schirmacher... (
Since the video1394 interface is not fully developed, you have to do some
parameter twiddling to make it work.
First, do
modprobe ohci1394
modprobe video1394
Then try to catch some test-video data using:
dvconnect >test.dv
Verify, using playdv if you are in doubt.
If that worked, try
dvconnect -s --syt-offset=OFFSET <test.dv
to send the data back to your camcorder. Where OFFSET is some number between
10000-26000. The default is 11000 (should work for everyone, but
in fact it doesn't...) You know, that you got it, when the picture in the view
finder stands still and no gray boxes are jumping around anymore.
If your harddisk is not fast enough or your system is under load then you
can control the user-space memory buffer using -b and the kernel buffer
using -k.
The kernel buffer should be large enough to bring dvconnect over
one scheduler slice. (approx 1/10 second)
The user-space memory buffer should be large enough to compensate
for varying disk transfer rates. (defaults to 10 seconds on PAL)
dvconnect will always warn you, if you got broken frames but
only if it is in capture mode!
This is a small explanation of the statistics tables generated by encodedv:
CYCLE are the cycles in the quantization loop until a matching QNO is found
(affects speed)
RUNS/CYCLE (for 3-pass VLC) : Tries to skip quantisation steps if it is
clear that a _lot_ more bits are needed. Makes things faster but
maybe quality drops a little bit. Smaller values mean better quality and
larger values mean that you gained some speed.
QNO is the quantization number. Larger values mean lesser quantization
(15=no quantization at all!) and better quality. You will notice, that
there are gaps between the values in the statistics. (Especially if
you choose "--vlc-passes=3", where qnos are most likely 15 or 8.)
This is normal behaviour since depending on the quantization CLASS
some QNOs don't gain you anything and are therefore skipped. There are
even codes, that _never_ gain you anything regardless of the chosen
CLASS is the quantization class. (Greater values mean higher quantization.)
This is used to quantizise larger AC coefficients more than smaller ones.
For now, we use the following table
max AC-value
0 - 11 | 12 - 23 | 24 - 35 | >35
Y 0 | 1 | 2 | 3
CR 1 | 2 | 3 | 3
CB 2 | 3 | 3 | 3
from the IEC documentation (which is only given for reference.)
If you want to improve this, keep the following in mind:
* These classes are chosen with the vlc code lengths in mind.
There is one code length for codes between 0..11, for 12..23 etc.
* You _have_ to use class 3 for AC coeffs. larger than 255, since they
can't get encoded otherwise.
* It is sensible to quantizise CR and CB values more than Y values.
(a) they don't matter that much and b) their bit budget is therefore
* Larger classes give you finer control over the QNO.
* Smaller classes don't have necessarily better quality since you may
be encoding quantization noise. That's from the IEC document. I don't
know, why they consider picture details with extremely small
coefficients as noise, but I agree that large coefficients don't
really need all the lower bits.
VLC OVERF is the number of vlc_encoder overflows you encountered. That means
that some AC coefficients simply aren't encoded!
At best it means your picture is somewhat blurred and at worst it has
a very psychedelic touch...
This should only happen in two cases
a) if you use "--vlc-passes==1,2" and QNO 0
b) static_qno since the simple heuristic used can fail easily
DCT MODE is the DCT mode chosen. DCT248 is used for fast moving sequences,
where the two fields encoded differ a lot. DCT88 has generally better
quality. The decision is based on the accumulated differences between
the two fields that are larger than a hard coded threshold divided
by the same difference in x direction. This makes sure that spotlights
are encoded with DCT 88 and not with DCT 248.
Something like (sum_i abs(field1[i] - field2[i])) /
sum_i abs(block[i+1] - block[i])) > dct_248_limit
- finally go to the library and get the header block specifications ;-)
- think of a better way to implement static_qno for 1,3 vlc passes
- do correct synchronisation between audio and video (synchronise
against system clock since we can't be sure, that the soundcard
clock is 100% accurate)
- skip frames correctly
- find a way to detect NTSC / PAL for video or finally add a
force-video-format option.
[ This file is way out of date ]
- MMX ycrcb conversion to rgb
- combine multiplies across weight/quant/idct prescale (?)
- parse:
- re-arrange data so that coeff blocks are all one big array
(alignment + one big memset (mmx!) at beginning of segment)
- more efficient bookkeeping (vs current brute force mark and sweep)
in second and third passes of parse
- still optimize vlc:
- combine lookup tables that use the same index:
- first level of classes, class_index_mask, class_index_rshift
(all indexed by maxbits)
- vlc_lookups, vlc_index_mask, vlc_index_rshift (all indexed by class)
- sign_mask, sign_rshift (indexed by vlc len)
- think about optimizing vlc/getbits interface based on a few
- there are three lookups in vlc of the form ((bits & mask) >> shift) are really doing this:
bitstream_show_skip(bs,skip,len) // show len bits, beginning skip bits from current position
- if we add that interface, and then mmx getbits, this could free registers
for better tuning the rest of the vlc lookup code.
- note that start and len are bounded to the range 0-16, it might pay
to ensure that after flush, show can always count on at least 16 bits
remaining in bs->current_word
- (there are multiple shows for each flush - eliminates branch in show)
- since we parse a whole video segment before we do idcts, we can reserve
mmx registers for getbits state for the entire duration of parsing a video segment
- note that bitstream state is re-initialized everytime we start a new video segment
- mmx version of 248 idct
- tune cache footprint: access input and output withouth polluting L1
- get everything working in Windows and use VTune to analyze and
improve x86 performance.
- there is none!
- the contents of this file has/will move to the project task list
on sourceforge.
This diff is collapsed.
#! /bin/bash
# Local settings for autotools, set them
# as appropriate for your system.
export AUTOCONF=autoconf-2.53
export AUTOHEADER=autoheader-2.53
export AUTOMAKE=automake-1.5
export ACLOCAL=aclocal-1.5
export LIBTOOLIZE=libtoolize
export LIBTOOL=libtool
# End of local settings
function autoconf_version_msg() {
echo "You must have autoconf 2.50 or greater to bootstrap $package."
echo "Get the latest version from"
($AUTOCONF --version) < /dev/null > /dev/null 2>&1 || {
autoconf_major=`$AUTOCONF --version | head -n 1 | sed 's/^[^0-9]*//' | sed 's/\([0-9]*\).\([0-9]*\)/\1/'`
autoconf_minor=`$AUTOCONF --version | head -n 1 | sed 's/^[^0-9]*//' | sed 's/\([0-9]*\).\([0-9]*\)/\2/'`
if [ $autoconf_major -le 2 ]; then
if [ $autoconf_major -lt 2 ]; then
elif [ $autoconf_minor -lt 50 ]; then
function automake_version_msg () {
echo "You must have automake 1.5 or greater to bootstrap $package."
echo "Get the latest version from"
($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
automake_major=`$AUTOMAKE --version | head -n 1 | sed 's/^.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\(-[^-]*\)*/\1/'`
automake_minor=`$AUTOMAKE --version | head -n 1 | sed 's/^.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\(-[^-]*\)*/\2/'`
if [ $automake_major -le 1 ]; then
if [ $automake_major -lt 1 ]; then
elif [ $automake_minor -lt 5 ]; then
function libtool_version_msg () {
echo "You must have libtool 1.4 or greater to bootstrap $package."
echo "Get the latest version from"
($LIBTOOL --version) < /dev/null > /dev/null 2>&1 || {
libtool_version=`$LIBTOOL --version | sed 's/^.* \([0-9\.]*\) .*$/\1/'`
libtool_major=`echo $libtool_version | cut -d. -f1`
libtool_minor=`echo $libtool_version | cut -d. -f2`
if [ $libtool_major -le 1 ]; then
if [ $libtool_major -lt 1 ]; then
elif [ $libtool_minor -lt 4 ]; then
function pkgconfig_version_msg () {
echo "You must have pkg-config 0.7.0 or greater to bootstrap $package."
echo "I got mine from"
(pkg-config --version) < /dev/null > /dev/null 2>&1 || {
pkgconfig_major=`pkg-config --version | sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'`
pkgconfig_minor=`pkg-config --version | sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'`
if [ $pkgconfig_major -lt 1 ]; then
if [ $pkgconfig_minor -lt 7 ]; then
# Sigh, we need this here because of SDL_PATH_CONFIG in
function sdl_version_msg () {
echo "You must have SDL installed to bootstrap $package."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at"
(sdl-config --version) < /dev/null > /dev/null 2>&1 || {
if test "$DIE" -eq 1; then
exit 1
test -f $srcfile || {
echo "You must run this script in the top-level $package directory"
exit 1
set -x
$LIBTOOLIZE --force --copy
$AUTOMAKE --foreign --copy --add-missing
This diff is collapsed.
/* Generated from by autoheader. */
/* Define as 1 if host is an IA32 */
#undef ARCH_X86
/* Define to indicate DEBUGGING is enabled possibly with a level */
#undef DEBUG
/* Define to 1 if you have the <dlfcn.h> header file. */
/* Define to 1 if you have the <fcntl.h> header file. */
/* Define to 1 if you have the `getpagesize' function. */
/* Define to 1 if you have the `gettimeofday' function. */
/* Define to 1 if you have the <inttypes.h> header file. */
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
/* Define to 1 if you have the `popt' library (-lpopt). */
/* Define if you have the `Xv' library (-lXv). */
/* Define to 1 if you have the <linux/videodev.h> header file. */
/* Define to 1 if you have the <memory.h> header file. */
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define as 1 if you have libsdl */
#undef HAVE_SDL
/* Define to 1 if you have the <stdint.h> header file. */
/* Define to 1 if you have the <stdlib.h> header file. */
/* Define to 1 if you have the <strings.h> header file. */