Skip to content

Commit

Permalink
Add support for resampling audio with libavresample
Browse files Browse the repository at this point in the history
This currently has a bunch of limitations. The resampling can't be
reconfigured after the first call to GetAudio, and sample rate
conversions aren't supported.

Originally committed to SVN as r748.
  • Loading branch information
tgoyne committed Mar 24, 2013
1 parent 870a2f1 commit 40a4b8a
Show file tree
Hide file tree
Showing 17 changed files with 511 additions and 91 deletions.
24 changes: 12 additions & 12 deletions Makefile.am
Expand Up @@ -9,7 +9,7 @@ dist_doc_DATA = doc/ffms2-api.html doc/ffms2-changelog.html doc/style.css
INCLUDES = -I. -I$(top_srcdir)/include -I$(top_srcdir)/src/config @LIBAV_CFLAGS@ @ZLIB_CPPFLAGS@ -include config.h

lib_LTLIBRARIES = src/core/libffms2.la
src_core_libffms2_la_LIBADD = @LIBAV_LIBS@ @ZLIB_LDFLAGS@ -lz @LTUNDEF@
src_core_libffms2_la_LIBADD = @LIBAV_LIBS@ @AVRESAMPLE_LIBS@ @ZLIB_LDFLAGS@ -lz @LTUNDEF@
src_core_libffms2_la_SOURCES = \
src/core/audiosource.h \
src/core/audiosource.cpp \
Expand Down Expand Up @@ -39,17 +39,17 @@ src_core_libffms2_la_SOURCES = \
src/core/utils.cpp \
src/core/videosource.h \
src/core/videosource.cpp \
src/core/videoutils.h \
src/core/videoutils.cpp \
src/core/wave64writer.h \
src/core/wave64writer.cpp \
src/vapoursynth/VapourSynth.h \
src/vapoursynth/vapoursource.h \
src/vapoursynth/vapoursource.cpp \
src/vapoursynth/vapoursynth.cpp

include_HEADERS = $(top_srcdir)/include/ffms.h $(top_srcdir)/include/ffmscompat.h

src/core/videoutils.h \
src/core/videoutils.cpp \
src/core/wave64writer.h \
src/core/wave64writer.cpp \
src/vapoursynth/VapourSynth.h \
src/vapoursynth/vapoursource.h \
src/vapoursynth/vapoursource.cpp \
src/vapoursynth/vapoursynth.cpp

include_HEADERS = $(top_srcdir)/include/ffms.h $(top_srcdir)/include/ffmscompat.h

bin_PROGRAMS = src/index/ffmsindex
src_index_ffmsindex_SOURCES = src/index/ffmsindex.cpp
src_index_ffmsindex_LDADD = src/core/libffms2.la
7 changes: 5 additions & 2 deletions Makefile.in
@@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.12.5 from Makefile.am.
# Makefile.in generated by automake 1.12.6 from Makefile.am.
# @configure_input@

# Copyright (C) 1994-2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -218,6 +218,8 @@ AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AVRESAMPLE_CFLAGS = @AVRESAMPLE_CFLAGS@
AVRESAMPLE_LIBS = @AVRESAMPLE_LIBS@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
Expand Down Expand Up @@ -321,6 +323,7 @@ htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libavresample = @libavresample@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
Expand All @@ -347,7 +350,7 @@ pkgconfig_DATA = ffms2.pc
dist_doc_DATA = doc/ffms2-api.html doc/ffms2-changelog.html doc/style.css
INCLUDES = -I. -I$(top_srcdir)/include -I$(top_srcdir)/src/config @LIBAV_CFLAGS@ @ZLIB_CPPFLAGS@ -include config.h
lib_LTLIBRARIES = src/core/libffms2.la
src_core_libffms2_la_LIBADD = @LIBAV_LIBS@ @ZLIB_LDFLAGS@ -lz @LTUNDEF@
src_core_libffms2_la_LIBADD = @LIBAV_LIBS@ @AVRESAMPLE_LIBS@ @ZLIB_LDFLAGS@ -lz @LTUNDEF@
src_core_libffms2_la_SOURCES = \
src/core/audiosource.h \
src/core/audiosource.cpp \
Expand Down
6 changes: 3 additions & 3 deletions aclocal.m4
@@ -1,4 +1,4 @@
# generated automatically by aclocal 1.12.5 -*- Autoconf -*-
# generated automatically by aclocal 1.12.6 -*- Autoconf -*-

# Copyright (C) 1996-2012 Free Software Foundation, Inc.

Expand Down Expand Up @@ -234,7 +234,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.12'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.12.5], [],
m4_if([$1], [1.12.6], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])

Expand All @@ -250,7 +250,7 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.12.5])dnl
[AM_AUTOMAKE_VERSION([1.12.6])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
Expand Down
4 changes: 4 additions & 0 deletions build-msvc/config.targets
Expand Up @@ -17,6 +17,10 @@
<ClCompile><PreprocessorDefinitions>WITH_PTHREAD_GC2;%(PreprocessorDefinitions)</PreprocessorDefinitions></ClCompile>
</ItemDefinitionGroup>

<ItemDefinitionGroup Condition="'$(WithAvResample)'=='true'">
<ClCompile><PreprocessorDefinitions>WITH_AVRESAMPLE;%(PreprocessorDefinitions)</PreprocessorDefinitions></ClCompile>
</ItemDefinitionGroup>

<ItemDefinitionGroup Condition="'$(ForkName)'=='libav'">
<ClCompile><PreprocessorDefinitions>FFMS_USE_FFMPEG_COMPAT;%(PreprocessorDefinitions)</PreprocessorDefinitions></ClCompile>
</ItemDefinitionGroup>
Expand Down
6 changes: 6 additions & 0 deletions build-msvc/config.xml
Expand Up @@ -42,4 +42,10 @@
Description="Was FFmpeg/libav built with pthreads rather than w32threads?"
/>

<BoolProperty
Name="WithAvResample"
DisplayName="Enable audio resampling"
Description="Requires libavresample 1.0.0 or newer"
/>

</Rule>
1 change: 1 addition & 0 deletions build-msvc/ffms2.vcxproj
Expand Up @@ -29,6 +29,7 @@
<OpencoreAmrNb>false</OpencoreAmrNb>
<OpencoreAmrWb>false</OpencoreAmrWb>
<WithPthread>false</WithPthread>
<WithAvResample>true</WithAvResample>
<ForkName>libav</ForkName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
Expand Down
8 changes: 6 additions & 2 deletions config.sub
Expand Up @@ -4,7 +4,7 @@
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012 Free Software Foundation, Inc.

timestamp='2012-10-10'
timestamp='2012-12-06'

# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
Expand Down Expand Up @@ -1026,7 +1026,11 @@ case $basic_machine in
basic_machine=i586-unknown
os=-pw32
;;
rdos)
rdos | rdos64)
basic_machine=x86_64-pc
os=-rdos
;;
rdos32)
basic_machine=i386-pc
os=-rdos
;;
Expand Down
135 changes: 124 additions & 11 deletions configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for ffms2 2.17.3.
# Generated by GNU Autoconf 2.69 for ffms2 2.17.4.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -587,8 +587,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='ffms2'
PACKAGE_TARNAME='ffms2'
PACKAGE_VERSION='2.17.3'
PACKAGE_STRING='ffms2 2.17.3'
PACKAGE_VERSION='2.17.4'
PACKAGE_STRING='ffms2 2.17.4'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''

Expand Down Expand Up @@ -634,6 +634,9 @@ am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
LTUNDEF
libavresample
AVRESAMPLE_LIBS
AVRESAMPLE_CFLAGS
LIBAV_LIBS
LIBAV_CFLAGS
pkgconfigdir
Expand Down Expand Up @@ -781,6 +784,7 @@ with_gnu_ld
with_sysroot
enable_libtool_lock
with_zlib
enable_avresample
'
ac_precious_vars='build_alias
host_alias
Expand All @@ -799,7 +803,9 @@ PKG_CONFIG
PKG_CONFIG_PATH
PKG_CONFIG_LIBDIR
LIBAV_CFLAGS
LIBAV_LIBS'
LIBAV_LIBS
AVRESAMPLE_CFLAGS
AVRESAMPLE_LIBS'


# Initialize some variables set by options.
Expand Down Expand Up @@ -1340,7 +1346,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures ffms2 2.17.3 to adapt to many kinds of systems.
\`configure' configures ffms2 2.17.4 to adapt to many kinds of systems.

Usage: $0 [OPTION]... [VAR=VALUE]...

Expand Down Expand Up @@ -1410,7 +1416,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of ffms2 2.17.3:";;
short | recursive ) echo "Configuration of ffms2 2.17.4:";;
esac
cat <<\_ACEOF

Expand All @@ -1433,6 +1439,7 @@ Optional Features:
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--enable-avresample use libavresample for audio resampling

Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
Expand Down Expand Up @@ -1464,6 +1471,10 @@ Some influential environment variables:
LIBAV_CFLAGS
C compiler flags for LIBAV, overriding pkg-config
LIBAV_LIBS linker flags for LIBAV, overriding pkg-config
AVRESAMPLE_CFLAGS
C compiler flags for AVRESAMPLE, overriding pkg-config
AVRESAMPLE_LIBS
linker flags for AVRESAMPLE, overriding pkg-config

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Expand Down Expand Up @@ -1531,7 +1542,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
ffms2 configure 2.17.3
ffms2 configure 2.17.4
generated by GNU Autoconf 2.69

Copyright (C) 2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -2071,7 +2082,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by ffms2 $as_me 2.17.3, which was
It was created by ffms2 $as_me 2.17.4, which was
generated by GNU Autoconf 2.69. Invocation command line was

$ $0 $@
Expand Down Expand Up @@ -2897,7 +2908,7 @@ fi

# Define the identity of the package.
PACKAGE='ffms2'
VERSION='2.17.3'
VERSION='2.17.4'


cat >>confdefs.h <<_ACEOF
Expand Down Expand Up @@ -15987,6 +15998,108 @@ fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext

# Check whether --enable-avresample was given.
if test "${enable_avresample+set}" = set; then :
enableval=$enable_avresample;
fi

if test x$enable_avresample != xno; then :


pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for AVRESAMPLE" >&5
$as_echo_n "checking for AVRESAMPLE... " >&6; }

if test -n "$AVRESAMPLE_CFLAGS"; then
pkg_cv_AVRESAMPLE_CFLAGS="$AVRESAMPLE_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libavresample >= 1.0.0\""; } >&5
($PKG_CONFIG --exists --print-errors "libavresample >= 1.0.0") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_AVRESAMPLE_CFLAGS=`$PKG_CONFIG --cflags "libavresample >= 1.0.0" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test -n "$AVRESAMPLE_LIBS"; then
pkg_cv_AVRESAMPLE_LIBS="$AVRESAMPLE_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libavresample >= 1.0.0\""; } >&5
($PKG_CONFIG --exists --print-errors "libavresample >= 1.0.0") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_AVRESAMPLE_LIBS=`$PKG_CONFIG --libs "libavresample >= 1.0.0" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi



if test $pkg_failed = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }

if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
AVRESAMPLE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libavresample >= 1.0.0" 2>&1`
else
AVRESAMPLE_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libavresample >= 1.0.0" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$AVRESAMPLE_PKG_ERRORS" >&5


if test x$enable_avresample = xyes; then :
as_fn_error $? "--enable-avresample was specified, but avresample 1.0.0+ could not be found." "$LINENO" 5
fi
enable_avresample=no

elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }

if test x$enable_avresample = xyes; then :
as_fn_error $? "--enable-avresample was specified, but avresample 1.0.0+ could not be found." "$LINENO" 5
fi
enable_avresample=no

else
AVRESAMPLE_CFLAGS=$pkg_cv_AVRESAMPLE_CFLAGS
AVRESAMPLE_LIBS=$pkg_cv_AVRESAMPLE_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
enable_avresample=yes
fi

fi

if test x$enable_avresample; then :
libavresample="libavresample"

$as_echo "#define WITH_AVRESAMPLE 1" >>confdefs.h

fi





{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wl,-Bsymbolic is needed" >&5
$as_echo_n "checking whether -Wl,-Bsymbolic is needed... " >&6; }
if test "$enable_shared" = yes; then
Expand Down Expand Up @@ -16621,7 +16734,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by ffms2 $as_me 2.17.3, which was
This file was extended by ffms2 $as_me 2.17.4, which was
generated by GNU Autoconf 2.69. Invocation command line was

CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -16687,7 +16800,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
ffms2 config.status 2.17.3
ffms2 config.status 2.17.4
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

Expand Down

0 comments on commit 40a4b8a

Please sign in to comment.