--- ffmpeg-0.6.orig/debian/README.upstream-upgrade
+++ ffmpeg-0.6/debian/README.upstream-upgrade
@@ -0,0 +1,38 @@
+
+Checklist and howto for ffmpeg upstream upgrades:
+
+Needed packages:
+
+ apt-get install devscripts git-buildpackage pristine-tar
+
+Stage in a tmp directory:
+
+ mkdir /tmp/f ; cd /tmp/f
+ git clone git://git.debian.org/git/pkg-multimedia/ffmpeg.git
+ cd ffmpeg
+ branches="master.unstripped pristine-tar upstream upstream.unstripped"
+ for b in $branches; do git checkout -b $b origin/$b ; done
+
+Prepare the environment:
+
+ SVNDATE=`date +%Y%m%d`
+ git checkout master
+
+Fetch and commit the new upstream version:
+
+ debian/rules get-orig-source SVN_VERSION=${SVNDATE}
+ git-import-orig ../ffmpeg_0.6~svn${SVNDATE}.orig.tar.gz
+
+Check and note the svn revision numbers from
+ffmpeg/{libswscale,}.svnrevision in debian/changelog
+
+ git diff upstream^ Changelog libavcodec/allcodecs.c libavformat/allformats.c
+
+Document new formats additions in debian/changelog
+
+Build, test, and compare against the the version already in the archive:
+ - headers in the -dev packages with
+ - soname in the libraries
+ - formats.txt in the libavcodecs package
+
+Finialize debian/changelog, package should be upload ready now
--- ffmpeg-0.6.orig/debian/copyright
+++ ffmpeg-0.6/debian/copyright
@@ -0,0 +1,96 @@
+SVN snapshots are downloaded with subversion from the ffmpeg SVN at:
+
+
+Upstream Authors: Fabrice Bellard
+ Alex Beregszaszi
+ BERO
+ Mario Brito
+ Ronald Bultje
+ Tim Ferguson
+ Brian Foley
+ Arpad Gereoffy
+ Philip Gladstone
+ Vladimir Gneushev
+ Wolfgang Hesseler
+ Falk Hueffner
+ Zdenek Kabelac
+ Robin Kay
+ Todd Kirby
+ Nick Kurshev
+ Mike Melanson
+ Michael Niedermayer
+ François Revol
+ Roman Shaposhnik
+ Dieter Shirley
+ Juan J. Sierralta
+ Ewald Snel
+ Leon van Stuivenberg
+ Roberto Togni
+ Lionel Ulmer
+
+Copyright (c) 2000-2004 Fabrice Bellard et al.
+
+The following files are licensed under the GNU GPL, as clarified below:
+
+ * ffmpeg.c
+ * libavcodec:
+ + dtsdec.c
+ + i386/idct_mmx.c
+ + liba52/*.[ch]
+ * libavformat:
+ + x11grab.c
+ + gxfenc.c
+ * libpostproc:
+ + postprocess_internal.h
+ + postprocess_altivec_template.c
+ + postprocess.h
+ + postprocess_template.c
+ + postprocess.c
+ + mangle.h
+ * libswscale:
+ + swscale.c
+ + swscale-example.c
+ + yuv2rgb_template.c
+ + swscale_altivec_template.c
+ + yuv2rgb_altivec.c
+ + swscale_template.c
+ + rgb2rgb_template.c
+ + rgb2rgb.c
+ + cs_test.c
+ + yuv2rgb_mlib.c
+ + yuv2rgb.c
+
+ | This library 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 library 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
+ | Lesser 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+The rest of the code is licensed under the GNU LGPL:
+
+ | This library is free software; you can redistribute it and/or
+ | modify it under the terms of the GNU Lesser General Public License as
+ | published by the Free Software Foundation; either version 2.1 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
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ | Lesser 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+On Debian GNU/Linux systems, the complete text of the GNU General Public
+License can be found in `/usr/share/common-licenses/GPL' and the text of the
+GNU Lesser General Public License is in `/usr/share/common-licenses/LGPL'.
+
--- ffmpeg-0.6.orig/debian/rules
+++ ffmpeg-0.6/debian/rules
@@ -0,0 +1,151 @@
+#!/usr/bin/make -f
+
+include /usr/share/quilt/quilt.make
+
+EPOCH=4:
+DEB_SOURCE := $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
+DEB_VERSION := $(shell dpkg-parsechangelog | sed -n 's/^Version: //p')
+UPSTREAM_VERSION := $(shell echo $(DEB_VERSION) | sed -r 's/[^:]+://; s/-[^-]+$$//')
+SHLIBS_VERSION := 4:0.6-1~
+
+LIB_PKGS := $(shell sed -nr 's/^Package:[[:space:]]*(lib(avutil|avcodec|avdevice|avformat|avfilter|postproc|swscale)(-extra-)?[0-9]+)[[:space:]]*$$/\1/p' debian/control)
+
+# Support multiple makes at once
+ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+NUMJOBS = -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+else
+# on i386 and amd64, we query the system unless overriden by DEB_BUILD_OPTIONS
+ifeq ($(DEB_HOST_ARCH),i386)
+NUMJOBS := -j$(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
+else ifeq ($(DEB_HOST_ARCH),amd64)
+NUMJOBS := -j$(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
+endif
+endif
+
+include debian/confflags
+
+$(info FLAVORS = $(FLAVORS))
+$(info DEB_BUILD_OPTIONS = $(DEB_BUILD_OPTIONS))
+$(info CFLAGS = $(CFLAGS))
+
+snapshot_version:
+ [ ! -r .svnrevision ] || \
+ cp .svnrevision $@
+ touch $@
+
+configure-%: configure-stamp-%
+configure-stamp-%: $(QUILT_STAMPFN) snapshot_version
+ dh_testdir
+ mkdir -p debian-$*
+ cd debian-$* && CFLAGS="$(CFLAGS)" $(CURDIR)/configure \
+ $($*_build_confflags) $(extra_$*_build_confflags)
+ touch $@
+
+build-%: build-stamp-%
+build-stamp-%: configure-stamp-%
+ dh_testdir
+ $(MAKE) -C debian-$* $(NUMJOBS)
+ touch $@
+
+debian-shared/tools/qt-faststart: build-stamp-shared
+ $(MAKE) -C debian-shared tools/qt-faststart
+
+build-doxy: build-doxy-stamp
+build-doxy-stamp: $(QUILT_STAMPFN)
+ dh_testdir
+ doxygen
+ touch $@
+
+build: build-stamp
+build-stamp: $(addprefix build-stamp-, $(FLAVORS)) debian-shared/tools/qt-faststart
+ touch $@
+
+clean: clean-real unpatch
+clean-real:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp $(addprefix build-stamp-, $(FLAVORS)) \
+ $(addprefix configure-stamp-, $(FLAVORS)) patch-stamp \
+ build-doxy-stamp
+ rm -rf $(addprefix debian-, $(FLAVORS)) doxy
+ dh_clean
+
+get-orig-source:
+ dh_testdir
+ sh debian/get-orig-source.sh -d $(SVN_VERSION)
+
+# The trailing newline is important!
+define install_flavor
+ $(MAKE) -C debian-$(1) install DESTDIR=$(CURDIR)/debian/tmp \
+ mandir=$(CURDIR)/debian/tmp/usr/share/man
+
+endef
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_prep
+ dh_installdirs -ptmp usr/share/doc/ffmpeg/html etc
+ dh_installdirs -ptmp usr/share/doc/ffmpeg-doc/html
+ $(foreach flavor,$(FLAVORS),$(call install_flavor,$(flavor)))
+ install -m 644 -D debian-shared/doc/*.html debian/tmp/usr/share/doc/ffmpeg/html/
+ # don't fail on binary-indep only builds.
+ [ ! -d doxy ] || cp doxy/html/* debian/tmp/usr/share/doc/ffmpeg-doc/html
+ install -m 644 -D doc/ffserver.conf debian/tmp/etc/
+ install -m 644 -D debian-shared/tools/qt-faststart debian/tmp/usr/bin/qt-faststart
+ dh_install -Xusr/share/doc/ffmpeg-doc -Xusr/share/doc/ffmpeg \
+ --fail-missing --sourcedir=debian/tmp
+
+formats.txt: install
+ env LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(CURDIR)/debian/tmp/usr/lib" \
+ debian/tmp/usr/bin/ffmpeg -formats | tee $@
+
+codecs.txt: install
+ env LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(CURDIR)/debian/tmp/usr/lib" \
+ debian/tmp/usr/bin/ffmpeg -codecs | tee $@
+
+binary-indep: build-doxy install
+
+binary-arch: build install codecs.txt formats.txt
+ dh_testdir
+ dh_testroot
+ dh_installman -pffmpeg debian/qt-faststart.1
+ dh_installdocs $(extradoc) doc/optimization.txt
+ dh_installdocs -A MAINTAINERS CREDITS doc/TODO
+ dh_installdocs -A debian/README.Debian
+ dh_installdocs -p libavcodec52 codecs.txt
+ dh_installdocs -p libavformat52 formats.txt
+ dh_installexamples -pffmpeg doc/ffserver.conf debian/recordshow.sh
+ dh_installexamples -plibavcodec-dev libavcodec/api-example.c
+ dh_installchangelogs Changelog
+ dh_lintian
+ dh_link
+ dh_compress
+ dh_fixperms
+ dh_strip --dbg-package=ffmpeg-dbg
+
+# strict internal dependencies
+ for pkg in $(LIB_PKGS); do \
+ upkg=$$(echo "$$pkg" | sed -r 's/([0-9]+)$$/-extra-\1/'); \
+ dh_makeshlibs -p"$$pkg" -V"$$pkg (>= $(DEB_VERSION)) | $$upkg (>= $(EPOCH)$(UPSTREAM_VERSION)), $$pkg (<< $(EPOCH)$(UPSTREAM_VERSION)-99) | $$upkg (<< $(EPOCH)$(UPSTREAM_VERSION)-99)"; \
+ done
+ env LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(CURDIR)/debian/tmp/usr/lib" \
+ dh_shlibdeps
+# target dependencies for external packages
+ for pkg in $(LIB_PKGS); do \
+ upkg=$$(echo "$$pkg" | sed -r 's/([0-9]+)$$/-extra-\1/'); \
+ dh_makeshlibs -p"$$pkg" -V"$$pkg (>= $(SHLIBS_VERSION)) | $$upkg (>= $(SHLIBS_VERSION))"; \
+ done
+ dh_installdeb
+ dh_gencontrol -- -Vlib1394-dev="$(lib1394-dev)"
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+
+.PHONY: build $(addprefix build-, $(FLAVORS)) build-doxy \
+ clean clean-real \
+ configure $(addprefix configure-, $(FLAVORS)) \
+ binary binary-indep binary-arch \
+ install \
+ get-orig-source
--- ffmpeg-0.6.orig/debian/README.Debian
+++ ffmpeg-0.6/debian/README.Debian
@@ -0,0 +1,235 @@
+lintian override shlib-with-non-pic-codeshlib-with-non-pic-code
+==================================================================
+
+The lintian overrides for the non-pic shared libs error messages is not
+really a matter of silencing lintian. The general idea is that the
+override would serve as an indication that we know about the error
+message and we're avoiding any bug reports or complaints by others about
+the errors.
+
+We are aware that this override is too strict. It should only cover the
+i386 architecture, as we know that the upstream build system will
+produce PIC libraries where necessary. Only architectures like i386 will
+be built non-PIC, mainly for performance reasons.
+
+ -- Reinhard Tartler , Mon, 27 Jul 2009 12:08:55 +0200
+
+FFmpeg package names
+====================
+
+The ffmpeg packaging has seen many renames in the course of its history.
+Looking for more stable names, the ffmpeg maintainers agreed on moving to
+a naming scheme which would fit known use cases and avoid confusion.
+
+Some of the constraints and proposed solutions on the new names follow:
+
+ 1. Distributions such as Debian and Ubuntu want to carry multiple version of
+ the package to fit component divisions and please users; e.g. an
+ Ubuntu/universe and an Ubuntu/multiverse version, or a Debian/main and a
+ Debian/non-free version. It is conceived that there are usually two
+ variants of the ffmpeg package in these distributions: a) the vanilla
+ version shipped in the most permissible component if possible and b) a
+ 'stripped' package suitable for the most constrained component.
+
+ For details why such a stripping is necessary in the first place, please
+ look further below in this document ("Disabled MPEG encoders").
+
+ 2. Packages from distributions and third party repositories such as the popular
+ debian-multimedia.org shouldn't interfere but coexist nicely. If these
+ repositories want to provide an alternate version of the source package,
+ they could do so with their own source and binary package names. It is
+ hoped that providing the vanilla source in one of the source packages will
+ remove the need to fork ffmpeg in these third party repositories.
+
+ 3. The libraries built by various source packages shall be ABI compatible as
+ to allow packages built against the most constrained component to run
+ against the more permissible components; for instance vlc if built against
+ ffmpeg in main shall be able to run against the ffmpeg libraries from
+ non-free. The plan here is to use shlibs tricks to allow to install one
+ lib or the other. The shlibs would look like:
+ lib-name-in-main-99 (>= 1.2.3) | lib-name-in-non-free-99 (>= 1.2.3)
+ This scheme can be extended for third party repositories if it still needs
+ to be.
+
+For consistency at this date, Debian is missing a ffmpeg-extra source
+package and Ubuntu had two source packages in the same component for a
+short time. The binary package names are not unified and shlibs do not
+allow to install one or the other library.
+
+To avoid gratuitous package renames, the proposed changes against the above
+packages are:
+
+ * For Debian and Ubuntu the binary packages in the 'main' component will
+ keep their original names without any additional marker.
+
+ * The extra (unstripped) replacement packages in the 'non-free'
+ (Debian) and 'multiverse' (ubuntu) component will be built from a
+ source package named 'ffmpeg-extra'. The resulting binary packages
+ carry an '-extra-' marker in the name right between the library name
+ and its SONAME.
+
+ * Ubuntu will track the ffmpeg packages in Debian and tries to minimize the
+ diff for maintenance reason.
+
+ * If you disagree with the naming, please speak up on
+ pkg-multimedia-maintainers@lists.alioth.debian.org
+
+ -- Reinhard Tartler , Sun, 26 Jul 2009 10:38:10 +0200
+
+
+Disabled MPEG encoders
+======================
+
+On Debconf 7, the ffmpeg maintainers had a conversation with James Troup
+from the ftpteam about mpeg encoders in the ffmpeg package. The ftpteam
+was pretty surprised about the accepted encoders, and admitted that they
+were accepted by accident. We therefore had no choice but removing
+them. We agreed on a plan that rather disables than removes the
+encoders, for details see debian/strip.sh, rendering those encoders
+unusable.
+
+Currently the following video encoders are disabled in the ffmpeg
+package: H263, H264, MPEG2 video, MPEG4 and MS-MPEG4. No *decoders* are
+disabled in any the ffmpeg package!
+
+The plan is to provide a source package called 'ffmpeg-extra', which builds
+drop-in replacement binary package with the mpeg encoders enabled. Ideally, we
+would be allowed to include those mpeg encoders enabled in non-free, but we
+haven't heared back from the ftpteam about that idea.
+
+
+ -- Reinhard Tartler , Sun, 20 Apr 2008 08:43:23 +0200
+
+
+Further patent issues with ffmpeg
+=================================
+
+In addition to the aforementioned MPEG encoders, some patents related to
+ffmpeg which seem to be enforced against open source software cover the
+following codec technologies and file formats:
+
+ * MP3 encoding
+ * AAC encoding
+ * the ASF file format
+
+ I did not activate MP3 encoding (through LAME) in libavcodec, nor AAC
+encoding (through FAAC). However, since I have found no real enforcement
+of the mysterious ASF file format patents, I did not deactivate ASF support in
+libavformat. More details on these three issues are given in the following
+paragraphs:
+
+
+The MP3 audio coding format
+===========================
+
+ Much has already been said about MP3 and the huge patent portfolio of
+the MPEG members, especially the Fraunhofer institute. Eric Scheirer's
+MPEG, Patents, and Audio Coding FAQ [1.1] is an attempt to "inject
+some sanity in what is becoming an increasingly heated discussion
+about patent rights surrounding MPEG technology, especially for audio
+compression". It also has a few words about other patented products
+covered in this document.
+
+[1.1] http://web.media.mit.edu/~eds/mpeg-patents-faq
+
+
+The AAC audio coding format
+===========================
+
+ Dolby's AAC (Advanced Audio Coding) is covered by patents owned by
+Dolby Laboratories, AT&T Laboratories, Fraunhofer Institute and Sony
+Corp.
+
+ The FAAC project was threatened by the AAC license consortium. Press
+report about how "an opensource project was closed down due to pressures
+from the AAC license consortium which requires a lumpsum payment of
+10,000 USD plus a per-copy payment of 1.35 USD, thus effectively banning
+free software implementations. The policies surrounding AAC also harm
+interoperability [2.2]." This was related by Heise [2.3] and FFII has
+a page about the Dolby threat [2.1] as well as additional information
+about MPEG-related patents [2.4].
+
+ The author stopped distributing the FAAC binaries, but still provides
+full source code and CVS access. To my knowledge he has not been
+threatened again. I also read on a web forum [2.5] that Cisco's lawyers
+claim that their LGPL distribution of AAC software in MPEG4IP is
+completely legal and that Dolby cannot forbid such distribution.
+
+[2.1] http://swpat.ffii.org/patents/effects/dolby/index.en.html
+[2.2] http://www.xiph.org/archives/vorbis-dev/200011/0286.html
+[2.3] http://www.heise.de/newsticker/data/vza-20.11.00-000/
+[2.4] http://swpat.ffii.org/patents/effects/mpeg/index.en.html
+[2.5] http://www.hydrogenaudio.org/index.php?showtopic=310&
+
+
+The ASF file encapsulation format
+=================================
+
+ Microsoft obtained a patent on the ASF (Active Stream Format) audio
+file format on March 21, 2000:
+
+ | United States Patent 6,041,345 Levi , et al. March 21, 2000
+ |
+ | Active stream format for holding multiple media streams
+ |
+ | Abstract An active stream format is defined and adopted for a
+ | logical structure that encapsulates multiple data streams. The data
+ | streams may be of different media. The data of the data streams
+ | is partitioned into packets that are suitable for transmission
+ | over a transport medium. The packets may include error correcting
+ | information. The packets may also include clock licenses for
+ | dictating the advancement of a clock when the data streams are
+ | rendered. The format of ASF facilitates flexibility and choice
+ | of packet size and in specifying maximum bit rate at which data
+ | may be rendered. Error concealment strategies may be employed in
+ | the packetization of data to distribute portions of samples to
+ | multiple packets. Property information may be replicated and stored
+ | in separate packets to enhance its error tolerance. The format
+ | facilitates dynamic definition of media types and the packetization
+ | of data in such dynamically defined data types within the format.
+
+ This patent is rumoured to have been enforced at least once, though
+only through what I'd call non-hostile intimidation. Avery Lee, the
+VirtualDub author, removed ASF support from his software after a phone
+call from a Microsoft employee that he relates in his 5/12/2000 news
+[3.1].
+
+ However I could not find evidence of an official threat: all I could
+find on the web seemed to be interpretations of the VirtualDub author's
+article, for instance on Advogato [3.2], CPT [3.3] or FFII [3.4]. Avery
+Lee states that the phone call was from a programmer, not from the
+legal department. There does not seem to be an official statement from
+Microsoft.
+
+[3.1] http://web.archive.org/web/20000817222620/http://www.geocities.com/virtualdub/virtualdub_news.html
+[3.2] http://www.advogato.com/article/101.html
+[3.3] http://www.cptech.org/ip/business/software/audio.html
+[3.4] http://swpat.ffii.org/patents/effects/asf/index.en.html
+
+
+License of the Debian ffmpeg packages
+=====================================
+
+The license for the whole work is the GPL, not the LGPL, because GPL-only
+parts of ffmpeg were activated -- namely libpostproc, libswscale, x11grab and
+(optionally) libfaad2. If you need LGPL versions of the libraries, please
+comment out the appropriate line in debian/confflags.
+
+
+Differences with unofficial ffmpeg packages
+===========================================
+
+ There are popular unofficial ffmpeg packages at the following URL:
+
+ http://www.debian-multimedia.org/
+
+ I have nothing to do with these packages and it would be very tedious
+for me to track their changes. Given that my official packages use a
+Debian-specific naming scheme for libraries, you should be able to
+install at least the shared library packages together.
+
+ Before submitting a bug report, please make sure it is related to the
+Debian packages and not those unofficial packages.
+
+
+ -- Sam Hocevar Thu, 30 Mar 2006 10:23:16 +0200
--- ffmpeg-0.6.orig/debian/libavdevice52.lintian-overrides
+++ ffmpeg-0.6/debian/libavdevice52.lintian-overrides
@@ -0,0 +1,3 @@
+# Overriding these fpic lintian errors. Please see bug #528080.
+libavdevice52: shlib-with-non-pic-code usr/lib/i686/cmov/libavdevice.so.52.2.0
+libavdevice52: shlib-with-non-pic-code usr/lib/libavdevice.so.52.2.0
--- ffmpeg-0.6.orig/debian/control
+++ ffmpeg-0.6/debian/control
@@ -0,0 +1,258 @@
+Source: ffmpeg
+Section: libs
+Priority: optional
+Maintainer: Ubuntu Core Developers
+XSBC-Original-Maintainer: Debian multimedia packages maintainers
+Uploaders: Sam Hocevar (Debian packages) ,
+ Loic Minier ,
+ Reinhard Tartler ,
+ Fabian Greffrath ,
+ Andres Mejia
+DM-Upload-Allowed: yes
+Standards-Version: 3.9.0
+Vcs-Git: git://git.debian.org/git/pkg-multimedia/ffmpeg.git
+Vcs-Browser: http://git.debian.org/?p=pkg-multimedia/ffmpeg.git;a=summary
+Homepage: http://ffmpeg.org/
+Build-Depends-Indep: doxygen
+Build-Depends: debhelper (>= 7),
+ libasound2-dev [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386],
+ libbz2-dev,
+ libdc1394-22-dev [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386],
+ libfreetype6-dev,
+ libgsm1-dev,
+ libimlib2-dev,
+ libraw1394-dev [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386],
+ libschroedinger-dev,
+ libsdl1.2-dev,
+ libspeex-dev,
+ libtheora-dev (>> 0.0.0.alpha4),
+ libvorbis-dev,
+ libx11-dev,
+ libxext-dev,
+ libxfixes-dev,
+ libvdpau-dev,
+ libvpx-dev,
+ libxvmc-dev,
+ quilt,
+ texi2html,
+ yasm [i386 amd64],
+ libva-dev,
+ zlib1g-dev
+
+Package: ffmpeg
+Section: video
+Architecture: any
+Replaces: libavcodec52 (<< ${source:Version}),
+ libavcodec-extra-52 (<< 4:0.6~)
+Depends: ${shlibs:Depends},
+ ${misc:Depends}
+Conflicts: ffprobe
+Description: multimedia player, server and encoder
+ This package contains the ffplay multimedia player, the ffserver streaming
+ server and the ffmpeg audio and video encoder. They support most existing
+ file formats (AVI, MPEG, OGG, Matroska, ASF...) and encoding formats (MPEG,
+ DivX, MPEG4, AC3, DV...).
+
+Package: ffmpeg-dbg
+Section: debug
+Priority: extra
+Architecture: any
+Depends: libavutil50 (= ${binary:Version}),
+ libavcodec52 (= ${binary:Version}),
+ libavdevice52 (= ${binary:Version}),
+ libpostproc51 (= ${binary:Version}),
+ libavformat52 (= ${binary:Version}),
+ libswscale0 (= ${binary:Version}),
+ ffmpeg (= ${binary:Version}),
+ ${misc:Depends}
+Description: Debug symbols for ffmpeg related packages
+ This package contains debug data of the ffmpeg related shared libraries.
+ .
+ Most people will not need this package. Please install it to produce useful
+ stacktraces to help debugging the ffmpeg library.
+
+Package: ffmpeg-doc
+Section: doc
+Architecture: all
+Depends: ${misc:Depends}
+Description: documentation of the ffmpeg API
+ This package contains the html doxygen documentation of the ffmpeg API.
+
+Package: libavutil50
+Architecture: any
+Depends: ${shlibs:Depends},
+ ${misc:Depends}
+Description: ffmpeg utility library
+ This is the common utility library from the ffmpeg project. It is required
+ by all other ffmpeg libraries.
+ .
+ This package contains a Debian-specific version of the libavutil shared
+ object that should only be used by Debian packages.
+
+Package: libavcodec52
+Architecture: any
+Depends: ${shlibs:Depends},
+ ${misc:Depends}
+Replaces: ffmpeg (<< 4:0.5.1-1)
+Description: ffmpeg codec library
+ This is the codec library from the ffmpeg project. It supports most existing
+ encoding formats (MPEG, DivX, MPEG4, AC3, DV...).
+ .
+ This package contains a Debian-specific version of the libavcodec shared
+ object that should only be used by Debian packages.
+
+Package: libavdevice52
+Architecture: any
+Depends: ${shlibs:Depends},
+ ${misc:Depends}
+Description: ffmpeg device handling library
+ This is the device handling library from the ffmpeg project.
+ .
+ This package contains a Debian-specific version of the libavdevice shared
+ object that should only be used by Debian packages.
+
+Package: libavformat52
+Architecture: any
+Depends: ${shlibs:Depends},
+ ${misc:Depends}
+Breaks: libavcodec51 (<< 3:0.svn20090303-1)
+Description: ffmpeg file format library
+ This is the demuxer library from the ffmpeg project. It supports most
+ existing file formats (AVI, MPEG, OGG, Matroska, ASF...).
+ .
+ This package contains a Debian-specific version of the libavformat shared
+ object that should only be used by Debian packages.
+
+Package: libavfilter1
+Architecture: any
+Depends: ${shlibs:Depends},
+ ${misc:Depends}
+Description: ffmpeg video filtering library
+ This is the video filtering library from the ffmpeg project.
+ .
+ This package contains a Debian-specific version of the libavfilter shared
+ object that should only be used by Debian packages.
+
+Package: libpostproc51
+Architecture: any
+Depends: ${shlibs:Depends},
+ ${misc:Depends}
+Description: ffmpeg video postprocessing library
+ This is the video postprocessing library from the ffmpeg project.
+ .
+ This package contains a Debian-specific version of the libpostproc shared
+ object that should only be used by Debian packages.
+
+Package: libswscale0
+Architecture: any
+Depends: ${shlibs:Depends},
+ ${misc:Depends}
+Description: ffmpeg video scaling library
+ This is the video scaling library from the ffmpeg project.
+ .
+ This package contains a Debian-specific version of the libswscale shared
+ object that should only be used by Debian packages.
+
+Package: libavutil-dev
+Section: libdevel
+Architecture: any
+Depends: libavutil50 (>= ${binary:Version}) | libavutil-extra-50 (>= ${source:Upstream-Version}),
+ libavutil50 (<= ${source:Upstream-Version}-99) | libavutil-extra-50 (<= ${source:Upstream-Version}-99),
+ ${misc:Depends}
+Description: development files for libavutil
+ This is the common utility library from the ffmpeg project. It is required
+ by all other ffmpeg libraries.
+ .
+ This package contains the header files and static libraries needed to
+ compile applications or shared objects that use libavutil.
+
+Package: libavcodec-dev
+Section: libdevel
+Architecture: any
+Depends: libavcodec52 (>= ${binary:Version}) | libavcodec-extra-52 (>= ${source:Upstream-Version}),
+ libavcodec52 (<= ${source:Upstream-Version}-99) | libavcodec-extra-52 (<= ${source:Upstream-Version}-99),
+ libavutil-dev (= ${binary:Version}),
+ ${misc:Depends}
+Suggests: libfaad-dev,
+ libgsm1-dev,
+ libogg-dev,
+ libschroedinger-dev,
+ libspeex-dev,
+ libtheora-dev (>> 0.0.0.alpha4),
+ libvorbis-dev,
+ libx11-dev,
+ libxext-dev,
+ zlib1g-dev,
+ ${lib1394-dev}
+Description: development files for libavcodec
+ This is the codec library from the ffmpeg project. It supports most existing
+ encoding formats (MPEG, DivX, MPEG4, AC3, DV...).
+ .
+ This package contains the header files and static libraries needed to
+ compile applications or shared objects that use libavcodec.
+
+Package: libavdevice-dev
+Section: libdevel
+Architecture: any
+Depends: libavdevice52 (>= ${binary:Version}) | libavdevice-extra-52 (>= ${source:Upstream-Version}),
+ libavdevice52 (<= ${source:Upstream-Version}-99) | libavdevice-extra-52 (<= ${source:Upstream-Version}-99),
+ libavformat-dev (= ${binary:Version}),
+ ${misc:Depends}
+Description: development files for libavdevice
+ This is the device handling library from the ffmpeg project.
+ .
+ This package contains the header files and static libraries needed to
+ compile applications or shared objects that use libavdevice.
+
+Package: libavformat-dev
+Section: libdevel
+Architecture: any
+Depends: libavformat52 (>= ${binary:Version}) | libavformat-extra-52 (>= ${source:Upstream-Version}),
+ libavformat52 (<= ${source:Upstream-Version}-99) | libavformat-extra-52 (<= ${source:Upstream-Version}-99),
+ libavcodec-dev (= ${binary:Version}),
+ ${misc:Depends}
+Description: development files for libavformat
+ This is the demuxer library from the ffmpeg project. It supports most
+ existing file formats (AVI, MPEG, OGG, Matroska, ASF...).
+ .
+ This package contains the header files and static libraries needed to
+ compile applications or shared objects that use libavformat.
+
+Package: libavfilter-dev
+Section: libdevel
+Architecture: any
+Depends: libavfilter1 (>= ${binary:Version}) | libavfilter-extra-1 (>= ${source:Upstream-Version}),
+ libavfilter1 (<= ${source:Upstream-Version}-99) | libavfilter-extra-1 (<= ${source:Upstream-Version}-99),
+ libavcodec-dev (= ${binary:Version}),
+ ${misc:Depends}
+Description: development files for libavfilter
+ This is the video filtering library from the ffmpeg project.
+ .
+ This package contains the header files and static libraries needed to
+ compile applications or shared objects that use libavfilter.
+
+Package: libpostproc-dev
+Section: libdevel
+Architecture: any
+Depends: libpostproc51 (>= ${binary:Version}) | libpostproc-extra-51 (>= ${source:Upstream-Version}),
+ libpostproc51 (<= ${source:Upstream-Version}-99) | libpostproc-extra-51 (<= ${source:Upstream-Version}-99),
+ libavutil-dev (= ${binary:Version}),
+ ${misc:Depends}
+Description: development files for libpostproc
+ This is the video postprocessing library from the ffmpeg project.
+ .
+ This package contains the header files and static libraries needed to
+ compile applications or shared objects that use libpostproc.
+
+Package: libswscale-dev
+Section: libdevel
+Architecture: any
+Depends: libswscale0 (>= ${binary:Version}) | libswscale-extra-0 (>= ${source:Upstream-Version}),
+ libswscale0 (<= ${source:Upstream-Version}-99) | libswscale-extra-0 (<= ${source:Upstream-Version}-99),
+ libavutil-dev (= ${binary:Version}),
+ ${misc:Depends}
+Description: development files for libswscale
+ This is the video scaling library from the ffmpeg project.
+ .
+ This package contains the header files and static libraries needed to
+ compile applications or shared objects that use libswscale.
--- ffmpeg-0.6.orig/debian/get-orig-source.sh
+++ ffmpeg-0.6/debian/get-orig-source.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+#
+# Script to create a 'pristine' tarball for the debian ffmpeg source package
+# Copyright (C) 2008, 2009, 2010 Reinhard Tartler
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# 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.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+set -eu
+
+usage() {
+ cat >&2 <&2
+}
+
+error () {
+ echo "$1" >&2
+ exit 1;
+}
+
+set +e
+PARAMS=`getopt hd: "$@"`
+if test $? -ne 0; then usage; exit 1; fi;
+set -e
+
+eval set -- "$PARAMS"
+
+DEBUG=false
+SVNDATE=
+
+while test $# -gt 0
+do
+ case $1 in
+ -h) usage; exit 1 ;;
+ -d) SVNDATE=$2; shift ;;
+ --) shift ; break ;;
+ *) echo "Internal error!" ; exit 1 ;;
+ esac
+ shift
+done
+
+# sanity checks now
+dh_testdir
+
+if [ -z $SVNDATE ]; then
+ error "you need to specify an svn date. e.g. 20081230 for Dec 29. 2008"
+fi
+
+TARBALL=../ffmpeg_0.6~svn${SVNDATE}.orig.tar.gz
+PACKAGENAME=ffmpeg
+
+TMPDIR=`mktemp -d`
+trap 'rm -rf ${TMPDIR}' EXIT
+
+baseurl="svn://svn.ffmpeg.org/ffmpeg/branches/0.6"
+
+echo "fetching source from ${baseurl}"
+
+svn export -r{${SVNDATE}} \
+ --ignore-externals \
+ ${baseurl} \
+ ${TMPDIR}/${PACKAGENAME}
+
+svn info -r{${SVNDATE}} \
+ ${baseurl} \
+ | awk '/^Revision/ {print $2}' \
+ > ${TMPDIR}/${PACKAGENAME}/.svnrevision
+
+tar czf ${TARBALL} -C ${TMPDIR} ${PACKAGENAME}
+
+echo "Created tarball for version ${SVNDATE} in ${TARBALL}"
--- ffmpeg-0.6.orig/debian/confflags
+++ ffmpeg-0.6/debian/confflags
@@ -0,0 +1,206 @@
+# -*- mode: makefile -*-
+# vim:syntax=make
+
+# build a static version on every architecture in the 'debian' ffmpeg package
+FLAVORS := static
+
+# shared is generic, i.e. without arch specific opcodes
+FLAVORS += shared
+
+export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+export DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
+
+SVNREVISION=$(shell cat .svnrevision 2>/dev/null || echo "UNKNOWN")
+
+# this is only used for the check_asm macro
+ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
+ CC := gcc
+else
+ CC := $(DEB_HOST_GNU_TYPE)-gcc
+endif
+
+# this outputs 0 or 1 depending on whether a piece of assembly can be compiled
+# with the *default* gcc flags; this is used to test the toolchain *default*
+# configuration
+check_asm = $(shell echo 'void foo(void) { __asm__ volatile("$(1)"); }' | $(CC) -x c -c - -o /dev/null 2>/dev/null && echo 1 || echo 0)
+
+# the other flavors always build dynamic versions
+# Also, disable architecture-specific optimizations for default shared build
+ifeq ($(DEB_HOST_ARCH),armel)
+ # whether the toolchain *default* configuration includes vfp and neon
+ vfp_asm := fadds s0, s0, s0
+ has_vfp := $(call check_asm, $(vfp_asm))
+ neon_asm := vadd.i16 q0, q0, q0
+ has_neon := $(call check_asm, $(neon_asm))
+
+ # only build
+ ifneq ($(has_vfp),1)
+ FLAVORS += vfp
+ endif
+ ifneq ($(has_neon),1)
+ FLAVORS += neon
+ endif
+else ifeq ($(DEB_HOST_ARCH),i386)
+ FLAVORS += cmov
+else ifeq ($(DEB_HOST_ARCH),powerpc)
+ FLAVORS += altivec
+ nooptflags += --disable-altivec
+else ifeq ($(DEB_HOST_ARCH),sparc)
+ FLAVORS += vis
+ nooptflags += --disable-vis
+endif
+
+$(info Building FLAVORS=$(FLAVORS))
+
+define cond_enable
+ $(shell test -r $(1) && echo --enable-$(2) )
+endef
+
+# variant that also require --enable-version3
+define cond_enable_v3
+ $(shell test -r $(1) && echo --enable-$(2) --enable-version3 )
+endef
+
+# variant that also require --enable-nonfree
+define cond_enable_nf
+ $(shell test -r $(1) && echo --enable-$(2) --enable-nonfree )
+endef
+
+# Configuration flags causing the libs to be GPL tainted
+gpl_confflags += --enable-gpl
+gpl_confflags += --enable-postproc
+gpl_confflags += --enable-x11grab
+
+# there is no libfaad in ubuntu/main, on in ubuntu/multiverse
+gpl_confflags += $(call cond_enable,/usr/include/faad.h,libfaad)
+
+# Common configuration flags
+confflags += --extra-version='$(DEB_VERSION)'
+confflags += --prefix=/usr
+confflags += --enable-avfilter
+confflags += --enable-avfilter-lavf
+confflags += --enable-vdpau
+confflags += --enable-bzlib
+confflags += --enable-libgsm
+confflags += --enable-libschroedinger
+confflags += --enable-libspeex
+confflags += --enable-libtheora
+confflags += --enable-libvorbis
+confflags += --enable-vaapi
+confflags += --enable-pthreads
+confflags += --enable-zlib
+confflags += --enable-libvpx
+confflags += --disable-stripping
+confflags += --enable-runtime-cpudetect
+ifeq ($(DEB_HOST_ARCH),armel)
+# this is required on Ubuntu lucid as it defaults to thumb2 and ffmpeg has
+# plenty of incompatible assembly; not sure how to detect that properly
+confflags += --extra-cflags="-marm -fPIC -DPIC"
+endif
+ifeq ($(DEB_HOST_ARCH),powerpc)
+confflags += --enable-pic
+endif
+confflags += $(extra_common_confflags)
+
+# this part below is intended for the 'ffmpeg' package in ubuntu/multiverse
+gpl_confflags += $(call cond_enable,/usr/include/xvid.h,libxvid)
+gpl_confflags += $(call cond_enable,/usr/include/x264.h,libx264)
+gpl_confflags += $(call cond_enable,/usr/include/librtmp/http.h,librtmp)
+confflags += $(call cond_enable,/usr/include/lame/lame.h,libmp3lame)
+
+# Opencore-amr requires GPL v3
+v3_confflags += $(call cond_enable_v3,/usr/include/opencore-amrnb/interf_dec.h,libopencore-amrnb)
+v3_confflags += $(call cond_enable_v3,/usr/include/opencore-amrwb/dec_if.h,libopencore-amrwb)
+
+# AAC is considered non-free upstream
+confflags += $(call cond_enable_nf,/usr/include/faac.h,libfaac)
+
+# comment out following line for LGPL versions of the libraries
+confflags += $(gpl_confflags)
+confflags += $(v3_confflags)
+
+# Enable IEEE 1394 (FireWire) support on Linux only
+ifneq (,$(findstring linux,$(DEB_HOST_GNU_TYPE)))
+ confflags += --enable-libdc1394
+ lib1394-dev += libraw1394-dev, libdc1394-22-dev
+endif
+
+# XXX this probably needs fixing
+CFLAGS :=
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+# Various parts of ffmpeg (and swscale) FTBFS when compiling with -fPIC
+# and with mmx code enabled.
+ confflags += --disable-optimizations
+ confflags += --disable-mmx
+endif
+
+# Configuration flags for the static libraries
+static_build_confflags += $(confflags)
+
+# Configuration flags for the non-optimized shared libraries
+shared_build_confflags += $(confflags)
+# amd64 has no problems with optimized shared libs. i386 and arm do.
+ifneq ($(DEB_HOST_ARCH),amd64)
+shared_build_confflags += $(nooptflags)
+endif
+shared_build_confflags += --enable-shared
+shared_build_confflags += --disable-static
+
+## armel architecture specific
+# Configuration flags for the optimised shared libraries
+vfp_build_confflags += $(confflags)
+vfp_build_confflags += --shlibdir=/usr/lib/vfp
+vfp_build_confflags += --enable-shared
+vfp_build_confflags += --disable-static
+vfp_build_confflags += --extra-cflags="-mfpu=vfp -mfloat-abi=softfp"
+vfp_build_confflags += --disable-ffmpeg
+vfp_build_confflags += --disable-ffplay
+# NB: NEON always implies v7+ and ffmpeg's NEON implementation requires VFP
+neon_build_confflags += $(confflags)
+neon_build_confflags += --shlibdir=/usr/lib/neon/vfp
+neon_build_confflags += --extra-cflags="-mfpu=neon -mfloat-abi=softfp -fPIC -DPIC"
+neon_build_confflags += --enable-shared
+neon_build_confflags += --disable-static
+neon_build_confflags += --disable-ffmpeg
+neon_build_confflags += --disable-ffplay
+
+## i386 architecture specific
+# Configuration flags for the optimized shared libraries
+cmov_build_confflags += $(confflags)
+cmov_build_confflags += $(nooptflags)
+cmov_build_confflags += --shlibdir=/usr/lib/i686/cmov
+cmov_build_confflags += --cpu='i686'
+cmov_build_confflags += --enable-shared
+cmov_build_confflags += --disable-static
+cmov_build_confflags += --disable-ffmpeg
+cmov_build_confflags += --disable-ffplay
+
+## powerpc architecture specific
+# Configuration flags for the optimized shared libraries
+altivec_build_confflags += $(confflags)
+altivec_build_confflags += --shlibdir=/usr/lib/altivec
+altivec_build_confflags += --cpu='g4'
+altivec_build_confflags += --enable-shared
+altivec_build_confflags += --disable-static
+altivec_build_confflags += --enable-altivec
+altivec_build_confflags += --disable-ffmpeg
+altivec_build_confflags += --disable-ffplay
+
+## sparc architecture specific
+# Configuration flags for the optimized shared libraries
+vis_build_confflags += $(confflags)
+vis_build_confflags += --shlibdir=/usr/lib/v9
+vis_build_confflags += --cpu='sparc64'
+vis_build_confflags += --enable-shared
+vis_build_confflags += --disable-static
+vis_build_confflags += --extra-cflags="-fPIC -DPIC"
+vis_build_confflags += --disable-ffmpeg
+vis_build_confflags += --disable-ffplay
+
+# Additional documentation for PowerPC
+ifneq (,$(findstring powerpc,$(DEB_BUILD_GNU_TYPE)))
+ extradoc := doc/ffmpeg_powerpc_performance_evaluation_howto.txt
+endif
+
--- ffmpeg-0.6.orig/debian/libavutil50.lintian-overrides
+++ ffmpeg-0.6/debian/libavutil50.lintian-overrides
@@ -0,0 +1,3 @@
+# Overriding these fpic lintian errors. Please see bug #528080.
+libavutil50: shlib-with-non-pic-code usr/lib/i686/cmov/libavutil.so.50.15.1
+libavutil50: shlib-with-non-pic-code usr/lib/libavutil.so.50.15.1
--- ffmpeg-0.6.orig/debian/gbp.conf
+++ ffmpeg-0.6/debian/gbp.conf
@@ -0,0 +1,6 @@
+[DEFAULT]
+upstream-branch = upstream
+debian-branch = ubuntu
+upstream-tag = upstream/%(version)s
+debian-tag = debian/%(version)s
+pristine-tar = True
--- ffmpeg-0.6.orig/debian/libavutil50.install
+++ ffmpeg-0.6/debian/libavutil50.install
@@ -0,0 +1 @@
+usr/lib/{,*/,*/*/}libavutil.so.*
--- ffmpeg-0.6.orig/debian/libswscale-dev.install
+++ ffmpeg-0.6/debian/libswscale-dev.install
@@ -0,0 +1,4 @@
+usr/include/libswscale
+usr/lib/libswscale.a
+usr/lib/{,*/,*/*/}libswscale.so
+usr/lib/pkgconfig/libswscale.pc
--- ffmpeg-0.6.orig/debian/libavfilter1.lintian-overrides
+++ ffmpeg-0.6/debian/libavfilter1.lintian-overrides
@@ -0,0 +1,3 @@
+# Overriding these fpic lintian errors. Please see bug #528080.
+libavfilter1: shlib-with-non-pic-code usr/lib/i686/cmov/libavfilter.so.1.19.0
+libavfilter1: shlib-with-non-pic-code usr/lib/libavfilter.so.1.19.0
--- ffmpeg-0.6.orig/debian/libavutil-dev.install
+++ ffmpeg-0.6/debian/libavutil-dev.install
@@ -0,0 +1,4 @@
+usr/include/libavutil
+usr/lib/libavutil.a
+usr/lib/{,*/,*/*/}libavutil.so
+usr/lib/pkgconfig/libavutil.pc
--- ffmpeg-0.6.orig/debian/ffmpeg-doc.doc-base
+++ ffmpeg-0.6/debian/ffmpeg-doc.doc-base
@@ -0,0 +1,9 @@
+Document: ffmpeg-doc
+Title: ffmpeg API Documentation
+Author: FFmpeg Developers
+Abstract: This is the main documentation for the ffmpeg API.
+Section: Programming
+
+Format: HTML
+Index: /usr/share/doc/ffmpeg-doc/html/index.html
+Files: /usr/share/doc/ffmpeg-doc/html/*.html
--- ffmpeg-0.6.orig/debian/ffmpeg-doc.docs
+++ ffmpeg-0.6/debian/ffmpeg-doc.docs
@@ -0,0 +1 @@
+debian/tmp/usr/share/doc/ffmpeg-doc/html
--- ffmpeg-0.6.orig/debian/qt-faststart.1
+++ ffmpeg-0.6/debian/qt-faststart.1
@@ -0,0 +1,36 @@
+.\" Hey, EMACS: -*- nroff -*-
+.\" First parameter, NAME, should be all caps
+.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
+.\" other parameters are allowed: see man(7), man(1)
+.TH QT-FASTSTART 1 "May 10, 2009"
+.\" Please adjust this date whenever revising the manpage.
+.\"
+.\" Some roff macros, for reference:
+.\" .nh disable hyphenation
+.\" .hy enable hyphenation
+.\" .ad l left justify
+.\" .ad b justify to both left and right margins
+.\" .nf disable filling
+.\" .fi enable filling
+.\" .br insert line break
+.\" .sp insert n+1 empty lines
+.\" for manpage-specific macros, see man(7)
+.SH NAME
+qt-faststart \- utility for Quicktime files
+.SH SYNOPSIS
+.B qt-faststart
+.br
+.SH DESCRIPTION
+\fBqt-faststart\fP is a utility that rearranges a Quicktime file such that the
+moov atom is in front of the data, thus facilitating network streaming.
+.SH OPTIONS
+Options processed by the executable:
+.TP
+\fB\\fR
+The source Quicktime file.
+.TP
+\fB\\fR
+The destination Quicktime file.
+.SH AUTHOR
+This manual page was written by Andres Mejia
+for the Debian GNU/Linux system, but may be used by others.
--- ffmpeg-0.6.orig/debian/libpostproc51.install
+++ ffmpeg-0.6/debian/libpostproc51.install
@@ -0,0 +1 @@
+usr/lib/{,*/,*/*/}libpostproc.so.*
--- ffmpeg-0.6.orig/debian/libavformat52.lintian-overrides
+++ ffmpeg-0.6/debian/libavformat52.lintian-overrides
@@ -0,0 +1,3 @@
+# Overriding these fpic lintian errors. Please see bug #528080.
+libavformat52: shlib-with-non-pic-code usr/lib/i686/cmov/libavformat.so.52.64.2
+libavformat52: shlib-with-non-pic-code usr/lib/libavformat.so.52.64.2
--- ffmpeg-0.6.orig/debian/compat
+++ ffmpeg-0.6/debian/compat
@@ -0,0 +1 @@
+7
--- ffmpeg-0.6.orig/debian/libavdevice-dev.install
+++ ffmpeg-0.6/debian/libavdevice-dev.install
@@ -0,0 +1,4 @@
+usr/include/libavdevice
+usr/lib/libavdevice.a
+usr/lib/{,*/,*/*/}libavdevice.so
+usr/lib/pkgconfig/libavdevice.pc
--- ffmpeg-0.6.orig/debian/libswscale0.install
+++ ffmpeg-0.6/debian/libswscale0.install
@@ -0,0 +1 @@
+usr/lib/{,*/,*/*/}libswscale.so.*
--- ffmpeg-0.6.orig/debian/libavdevice52.install
+++ ffmpeg-0.6/debian/libavdevice52.install
@@ -0,0 +1 @@
+usr/lib/{,*/,*/*/}libavdevice.so.*
--- ffmpeg-0.6.orig/debian/README.source
+++ ffmpeg-0.6/debian/README.source
@@ -0,0 +1,57 @@
+1) Usage of the quilt patch tracking system
+
+This package uses quilt to manage all modifications to the upstream
+source. Changes are stored in the source package as diffs in
+debian/patches and applied during the build.
+
+For more information about quilt, see /usr/share/doc/quilt/README.source
+
+2) Former stripping of the source code
+
+In the past, Debian used to ship "stripped" ffmpeg packages, i.e. the
+source code of the ffmpeg-debian package has been modified to disable
+specific codecs (mostly encoders like H263, H264, MPEG2 video, MPEG4 and
+MS-MPEG4) whose usage may represent patent infringement in certain
+jurisdictions. To serve the purpose to remain free of patented encoding
+technologies, the modifications to the ffmpeg source code have been done
+in a "non-reversible" way by removing several lines from the source code
+before packaging the release tarball. To reflect this divergence from
+upstream ffmpeg, the Debian package has been renamed to ffmpeg-debian.
+However, please note that only the code calling the affected codecs was
+removed in previous versions to make them unavailable to the resulting
+ffmpeg libraries. No encoder code was actually ever removed from the
+Debian packages!
+
+Several complications have come along with the aforementioned measures:
+* Further packaging hacks (e.g. debian/fixup-config.sh) have become
+ necessary in order to build the source code without the stripped
+ encoders.
+* It was impossible to rebuild unstripped packages for private usage
+ from the ffmpeg-debian source code
+* Ffmpeg upstream was not very happy about Debian redistributing a
+ stripped fork of their code, to say the least.
+
+Nowadays, while the situation remains pretty unchanged with regard to
+the patent threat, the ffmpeg build system has seen a lot of
+improvements. It now provides the possibility to explicitly disable
+specific codecs from the libraries at configure time, allowing disabling
+some patent encumbered codecs without the need to strip the source code.
+The effect on the resulting binary packages would remain the same as
+before.
+
+Regarding the source code, however, this would mean some significant
+improvements:
+* There is no more need to strip the source code in order to disable the
+ codecs and to apply further Debian-specific hacks to still make it
+ compile cleanly.
+* In order to rebuild unstripped ffmpeg libraries for private usage, it
+ would be sufficient to comment out a few configure flags.
+* Debian would not need to fork the ffmpeg source code anymore and call
+ their packages by a different name.
+
+Therefore, the pkg-multimedia-maintainers (the maintainers of the ffmpeg
+packages in Debian) decided to not strip the ffmpeg source code in
+further releases anymore but disable the patent encumbered codecs during
+the configure phase of the packages as intended upstream. We are sure
+this is the right thing to do with regard to the aforementioned
+advantages for both our users and ourselves as maintainers.
--- ffmpeg-0.6.orig/debian/libavformat52.install
+++ ffmpeg-0.6/debian/libavformat52.install
@@ -0,0 +1 @@
+usr/lib/{,*/,*/*/}libavformat.so.*
--- ffmpeg-0.6.orig/debian/libavfilter1.install
+++ ffmpeg-0.6/debian/libavfilter1.install
@@ -0,0 +1 @@
+usr/lib/{,*/,*/*/}libavfilter.so.*
--- ffmpeg-0.6.orig/debian/libpostproc51.lintian-overrides
+++ ffmpeg-0.6/debian/libpostproc51.lintian-overrides
@@ -0,0 +1,3 @@
+# Overriding these fpic lintian errors. Please see bug #528080.
+libpostproc51: shlib-with-non-pic-code usr/lib/i686/cmov/libpostproc.so.51.2.0
+libpostproc51: shlib-with-non-pic-code usr/lib/libpostproc.so.51.2.0
--- ffmpeg-0.6.orig/debian/ffmpeg.install
+++ ffmpeg-0.6/debian/ffmpeg.install
@@ -0,0 +1,4 @@
+etc
+usr/bin
+usr/share/man
+usr/share/ffmpeg/*.ffpreset
--- ffmpeg-0.6.orig/debian/libavformat-dev.install
+++ ffmpeg-0.6/debian/libavformat-dev.install
@@ -0,0 +1,4 @@
+usr/include/libavformat
+usr/lib/libavformat.a
+usr/lib/{,*/,*/*/}libavformat.so
+usr/lib/pkgconfig/libavformat.pc
--- ffmpeg-0.6.orig/debian/libswscale0.lintian-overrides
+++ ffmpeg-0.6/debian/libswscale0.lintian-overrides
@@ -0,0 +1,3 @@
+# Overriding these fpic lintian errors. Please see bug #528080.
+libswscale0: shlib-with-non-pic-code usr/lib/i686/cmov/libswscale.so.0.11.0
+libswscale0: shlib-with-non-pic-code usr/lib/libswscale.so.0.11.0
--- ffmpeg-0.6.orig/debian/clean
+++ ffmpeg-0.6/debian/clean
@@ -0,0 +1,5 @@
+config-extra-includes.h
+EXTRA
+codecs.txt
+formats.txt
+snapshot_version
--- ffmpeg-0.6.orig/debian/watch
+++ ffmpeg-0.6/debian/watch
@@ -0,0 +1,3 @@
+version=3
+opts="uversionmangle=s/.*-snapshot//i" \
+http://www.ffmpeg.org/releases/ffmpeg-(.*)\.tar\.bz2
--- ffmpeg-0.6.orig/debian/source.lintian-overrides
+++ ffmpeg-0.6/debian/source.lintian-overrides
@@ -0,0 +1,4 @@
+# The dependencies for packages within ffmpeg are different than the
+# dependencies for packages that depend on the ffmpeg libraries.
+ffmpeg source: debian-rules-calls-debhelper-in-odd-order dh_makeshlibs (line 174)
+ffmpeg source: debian-rules-calls-debhelper-in-odd-order dh_makeshlibs (line 178)
--- ffmpeg-0.6.orig/debian/libavcodec52.install
+++ ffmpeg-0.6/debian/libavcodec52.install
@@ -0,0 +1 @@
+usr/lib/{,*/,*/*/}libavcodec.so.*
--- ffmpeg-0.6.orig/debian/libavfilter-dev.install
+++ ffmpeg-0.6/debian/libavfilter-dev.install
@@ -0,0 +1,4 @@
+usr/include/libavfilter
+usr/lib/libavfilter.a
+usr/lib/{,*/,*/*/}libavfilter.so
+usr/lib/pkgconfig/libavfilter.pc
--- ffmpeg-0.6.orig/debian/ffmpeg.docs
+++ ffmpeg-0.6/debian/ffmpeg.docs
@@ -0,0 +1 @@
+debian/tmp/usr/share/doc/ffmpeg/html
--- ffmpeg-0.6.orig/debian/libpostproc-dev.install
+++ ffmpeg-0.6/debian/libpostproc-dev.install
@@ -0,0 +1,4 @@
+usr/include/libpostproc
+usr/lib/libpostproc.a
+usr/lib/{,*/,*/*/}libpostproc.so
+usr/lib/pkgconfig/libpostproc.pc
--- ffmpeg-0.6.orig/debian/recordshow.sh
+++ ffmpeg-0.6/debian/recordshow.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+# Copyright 2008, Daniel Dickinson
+#
+# This script script (which depends on xawtv for the v4lctl command to
+# select channel) and crontab show how one can record tv shows using
+# ffmpeg.
+
+STATION="$1"
+TODAY=$(date +"%A %B %d %Y")
+SHOWLENGTH="$2"
+SHOWDIR="$3"
+SHOWNAME="$4"
+
+function err_exit {
+ EXITCODE=$1
+ shift
+ echo $* 1>&2
+ exit $EXITCODE
+}
+
+BADPARAM=FALSE
+
+if [ -z "STATION" ]; then
+ BADPARAM=TRUE
+fi
+
+if [ -z "$SHOWDIR" ]; then
+ BADPARAM=TRUE
+fi
+
+if [ -z "$SHOWLENGTH" ]; then
+ BADPARAM=TRUE
+fi
+
+if [ "$BADPARAM" != "FALSE" ]; then
+ err_exit 2 "Usage: recordshow.sh station show-length show-dir [show-name]"
+fi
+
+if [ -z "$SHOWNAME" ]; then
+ BASEFILENAME="$SHOWDIR/$TODAY"
+else
+ BASEFILENAME="$SHOWDIR/$SHOWNAME-$TODAY"
+fi
+
+SECONDS=$(echo $SHOWLENGTH | cut -f3 -d:)
+MINUTES=$(echo $SHOWLENGTH | cut -f2 -d:)
+HOURS=$(echo $SHOWLENGTH | cut -f1 -d:)
+
+TOTALSECONDS=0
+
+TOTALSECONDS=$(expr $(expr $(expr $HOURS '*' 3600) + $(expr $MINUTES '*' 60)) + $SECONDS)
+
+/usr/bin/v4lctl setstation $1 >/dev/null || err_exit 1 "Unable to set station (channel) $STATION"
+/usr/bin/v4lctl volume mute off >/dev/null || err_exit 4 "Unable to unmute audio"
+/usr/bin/ffmpeg -y -tvstd ntsc -t "$TOTALSECONDS" -s 480x352 -re -deinterlace -f video4linux2 -i /dev/video0 -f audio_device -i /dev/dsp -ac 2 -s 768x576 -f mpegts -acodec mp2 -vcodec mpeg1video "$BASEFILENAME.mpegts" >/dev/null 2>&1 || err_exit 3 "Error recording show $BASEFILENAME to mpeg2 transport stream"
+/usr/bin/v4lctl volume mute on >/dev/null || err_exit 5 "Unable to mute audio"
+
--- ffmpeg-0.6.orig/debian/libavcodec52.lintian-overrides
+++ ffmpeg-0.6/debian/libavcodec52.lintian-overrides
@@ -0,0 +1,3 @@
+# Overriding these fpic lintian errors. Please see bug #528080.
+libavcodec52: shlib-with-non-pic-code usr/lib/i686/cmov/libavcodec.so.52.72.2
+libavcodec52: shlib-with-non-pic-code usr/lib/libavcodec.so.52.72.2
--- ffmpeg-0.6.orig/debian/changelog
+++ ffmpeg-0.6/debian/changelog
@@ -0,0 +1,1725 @@
+ffmpeg (4:0.6-2ubuntu6) maverick; urgency=low
+
+ * fix dependency on libswscale-extra-0, LP: #637895
+
+ -- Reinhard Tartler Tue, 05 Oct 2010 21:25:53 +0200
+
+ffmpeg (4:0.6-2ubuntu5) maverick; urgency=low
+
+ * Add flic video patch. Fixes CVE-2010-3429
+
+ -- Reinhard Tartler Tue, 05 Oct 2010 21:11:41 +0200
+
+ffmpeg (4:0.6-2ubuntu4) maverick; urgency=low
+
+ * Configure with --enable-pic on powerpc. LP: #654666.
+
+ -- Matthias Klose Mon, 04 Oct 2010 19:39:46 +0200
+
+ffmpeg (4:0.6-2ubuntu3) maverick; urgency=low
+
+ * add libxfixes-dev to build-depends, LP: #631103
+
+ -- Dominic Evans Fri, 10 Sep 2010 14:21:23 +0100
+
+ffmpeg (4:0.6-2ubuntu2) maverick; urgency=low
+
+ * weaken the dependencies for the -extra package
+
+ -- Reinhard Tartler Sun, 11 Jul 2010 20:38:27 -0400
+
+ffmpeg (4:0.6-2ubuntu1) maverick; urgency=low
+
+ * merge from debian/experimental. remaining changes:
+ - don't disable encoders
+ - don't build against libfaad, libdirac, librtmp and libopenjpeg (all in universe)
+
+ -- Reinhard Tartler Sun, 11 Jul 2010 11:00:54 -0400
+
+ffmpeg (4:0.6-2) experimental; urgency=low
+
+ [ Fabian Greffrath ]
+ * Enable RTMP[E] support via librtmp.
+ * Disable aac encoder, see README.Debian.
+ * Fix obsolete-relation-form for the internal dependencies.
+ * Merge debian/README.Source into debian/README.source and add section
+ headers.
+ * Remove obsoleted support for the non-free libamr-nb/wb.
+
+ [ Reinhard Tartler ]
+ * enable runtime-cpudetect
+ * conditionally build against opencore-amr if installed in the build
+ environment
+ * update upstream url in debian/copyright
+ * fix usage documentation in debian/get-orig-source.sh
+ * update dep3 headers for debian/patches/900_doxyfile
+ * add proper replaces for moving presets back to ffmpeg
+ * make debian/patches gbp-pq friendly
+ * Add VP80 fourcc to libavformat/riff.c
+ * Backport-AAC-HE-v2
+ * bump Standards-Version, no changes needed
+
+ -- Reinhard Tartler Tue, 29 Jun 2010 09:07:56 +0200
+
+ffmpeg (4:0.6-1ubuntu1) maverick; urgency=low
+
+ * merge from debian/experimental. remaining changes:
+ - don't disable encoders
+ - don't build against libfaad, libdirac and libopenjpeg (all in universe)
+ * new upstream release
+ - internal vorbis encoder is disabled. LP: #585330
+ - includes native AMR-NB decoder, LP: #93849
+ - api-example is fixed: LP: #557319
+
+ -- Reinhard Tartler Wed, 16 Jun 2010 12:53:24 +0200
+
+ffmpeg (4:0.6-1) experimental; urgency=low
+
+ * new upstream release
+ - adds VP8 support via libvpx, Closes: #582274
+ * depend on libavfilter-extra-1 instead of -0, Closes: #583728
+ * add conflicts to the ffprobe package, it has been merged upstream now
+
+ -- Reinhard Tartler Wed, 16 Jun 2010 09:25:28 +0200
+
+ffmpeg (4:0.6~svn20100505-1ubuntu2) maverick; urgency=low
+
+ * add proper replaces, fixes: LP: #587369
+ * fix typo in dependency on libavfilter-extra-1. LP: #587431
+
+ -- Reinhard Tartler Thu, 03 Jun 2010 11:33:32 +0200
+
+ffmpeg (4:0.6~svn20100505-1ubuntu1) maverick; urgency=low
+
+ * merge from debian/experimental. remaining changes:
+ - don't disable encoders
+ - don't build against libfaad, libdirac and libopenjpeg (all in universe)
+
+ -- Reinhard Tartler Wed, 26 May 2010 00:01:17 +0200
+
+ffmpeg (4:0.6~svn20100505-1) experimental; urgency=low
+
+ * update to new upstream. Closes: #569727
+ - fixes various segfaults and other minor feature improvements
+ Closes: #374931, #522449, #501891, #559712, #420231, #369127, #538082,
+ #298095, #294422, #561553, #525385, #495274, #420230
+ LP: #305286, #457106, #529200, #301723, #305315, #336479, #420230,
+ #412063, #428912, #432181, #440591, #453732, #453732, #453732,
+ #514259, #515243, #521472, #530186, #530186, #197842, #483317,
+ #483317, #539407, #280098, #331255, #566107, #569823, #570305,
+ #573190
+ * Fixup lintian overrides for new upstream snapshot
+ * Bump Standards-Version to 3.8.4
+ * Many upstream changes, see upstream Changelog for details
+
+ -- Reinhard Tartler Sun, 24 Jan 2010 21:24:56 +0100
+
+ffmpeg (4:0.5.1-1ubuntu1) lucid; urgency=low
+
+ * merge from debian. remaining changes:
+ - don't disable encoders
+ - don't build against libfaad, libdirac and libopenjpeg (all in universe)
+
+ -- Reinhard Tartler Thu, 04 Mar 2010 10:34:37 +0100
+
+ffmpeg (4:0.5.1-1) unstable; urgency=low
+
+ * new upstream release:
+ - clarifies documentation on metadata, Closes: #570050, LP: #501729
+ - further security backports, Closes: #570713
+ * adapt to new versioning scheme
+ * use '<<' instead of '<' relationship for internal shlib file
+ * merge changes from ubuntu packaging
+ * drop wmapro backport again as discussed with upstream. The unrelated
+ changes seem too risky for a stable release.
+
+ -- Reinhard Tartler Wed, 03 Mar 2010 22:28:24 +0100
+
+ffmpeg (4:0.5+svn20090706-6) unstable; urgency=low
+
+ [ Fabian Greffrath ]
+ * debian/patches/901-fix-misc-typos.patch: New patch taken from
+ upstream GIT (slightly modified) to fix some spelling errors.
+ * Document our calling of debhelper programs in an odd order in
+ debian/rules.
+
+ [ Reinhard Tartler ]
+ * document some unattributed patches
+ * enable cpu autodetection in libswscale, Closes: #567725, LP: #386397
+
+ [ Christopher Martin ]
+ * backport wmapro codec from ffmpeg trunk
+
+ -- Reinhard Tartler Sun, 31 Jan 2010 16:53:47 +0100
+
+ffmpeg (4:0.5+svn20090706-5ubuntu2) lucid; urgency=low
+
+ * tighten build dependency on new x264 package
+ * add x264 backport for ffmpeg 0.5
+ * install presets in 'libavcodec package' instead of 'ffmpeg' binary,
+ see git history for rationale of this change
+
+ -- Reinhard Tartler Wed, 17 Feb 2010 08:37:17 +0100
+
+ffmpeg (4:0.5+svn20090706-5ubuntu1) lucid; urgency=low
+
+ * merge from debian, remaining changes:
+ - dont disable internal encoders
+ - disabled extra depedencies (come with ffmpeg-extra)
+ - libdirac
+ - libopenjpeg
+
+ -- Reinhard Tartler Sat, 16 Jan 2010 10:12:15 +0100
+
+ffmpeg (4:0.5+svn20090706-5) unstable; urgency=medium
+
+ * Upload to unstable
+ * Urgency medium because of fixed RC bugs (security issues)
+
+ -- Reinhard Tartler Fri, 22 Jan 2010 16:04:39 +0000
+
+ffmpeg (4:0.5+svn20090706-4) experimental; urgency=low
+
+ [ Loïc Minier ]
+ * Use default toolchain setup on ARM flavors for noopt and only add FPU
+ CFLAGS in the VFP and NEON flavors; this is ok since internally, cpu will
+ be set to "generic" but -march=generic or -mcpu=generic will NOT be added
+ to the build flags.
+ * Build all armel flavours with -marm since ffmpeg has a lot of hand crafted
+ assembly which doesn't build in the new lucid default mode (Thumb 2);
+ LP: #488267
+ * Build all armel flavours with -fPIC -DPIC instead of just the neon flavour
+ as the new flags/toolchain require this in Ubuntu lucid.
+ * Build some assembly test code -- just like configure -- to decide whether
+ the *default* toolchain uses vfp or neon to decided whether to build the
+ vfp and neon flavors.
+ * Drop --disable/--enable opt flags such as --disable-neon or
+ --enable-armvfp on ARM since the upstream configure script will do the
+ right thing when the proper flags are set.
+
+ -- Loïc Minier Wed, 13 Jan 2010 12:57:32 +0100
+
+ffmpeg (4:0.5+svn20090706-3) experimental; urgency=low
+
+ [ Loïc Minier ]
+ * Disable more autodetecter ARM arch features
+ * Enable neon flavour
+ * Update NEON confflags to assume v7 and VFP
+ * Add backported NEON patches from ffmpeg trunk
+ * Pass proper --cpu and --extra-flags on armel
+ * Pass -fPIC -DPIC to neon pass
+
+ [ Fabian Greffrath ]
+ * Initialize the FLAVORS variable to static instead of appending to
+ it. Also, we do not support the internalencoders variable anymore.
+
+ [ Andres Mejia ]
+ * Remove unused patches from packaging.
+ * Update Vcs-* entries to new location.
+ * Bump Standards-Version to 3.8.3.
+
+ [ Reinhard Tartler ]
+ * change shlibs file to make applications depend on the -extra- packages
+ * loosen dependencies further, so that the -dev packages remain
+ installable even if ffmpeg-extra is 'out-of-date'
+ * add patch for issue1245: Make arguments of av_set_pts_info() unsigned.
+ * Support constant-quant encoding for libtheora, LP: #356322
+ * increase swscale compile time width (VOF/VOFW), LP: #443264
+ * Backports of various security patches, Closes: #550442, including:
+ - backport fixes for vorbis_dec
+ - backport oggparsevorbis fix
+ - backport vp3 fixes
+ - backport ffv1 fix
+ - libavcodec/mpegaudiodec.c backports
+ - h264 security backports
+ - backported libavformat/mov.c security fixes
+ - backported libavformat/oggdec.c security fixes
+ - backport svn r18016 aka 'MOV-Support-stz2-Compact-Sample-Size-Box'
+ to fix FTBFS
+ * enable symbol versioning
+ * bump shlibs version
+ * add README.source describing how this source package manages patches
+ * make sure the ${misc:Depends} substvar is used for each binary package
+
+ -- Reinhard Tartler Wed, 06 Jan 2010 16:27:40 +0100
+
+ffmpeg (4:0.5+svn20090706-2ubuntu5~ppa2) lucid; urgency=low
+
+ * export *all* symbols of libswscale, fixes FTBFS in mplayer
+
+ -- Reinhard Tartler Sat, 02 Jan 2010 23:37:21 +0100
+
+ffmpeg (4:0.5+svn20090706-2ubuntu5~ppa1) lucid; urgency=low
+
+ * Imported Debian patch 0.5+svn20090706-2ubuntu4
+ * revert gbp.conf to point to lucid branch
+ * enable symbol versioning
+ * bump shlibs version
+
+ -- Reinhard Tartler Sat, 02 Jan 2010 15:03:09 +0100
+
+ffmpeg (4:0.5+svn20090706-2ubuntu4) lucid; urgency=low
+
+ * add build dependency on 'yasm', since it is now moved to main.
+
+ -- Reinhard Tartler Mon, 21 Dec 2009 23:57:34 +0100
+
+ffmpeg (4:0.5+svn20090706-2ubuntu3) lucid; urgency=low
+
+ * security backports from ffmpeg trunk (Closes: #550442)
+ - libavcodec/mpegaudiodec
+ - libavcodec/vorbis_dec
+ - libavcodec/ffv1
+ - libavcodec/vp3
+ - libavcodec/h264
+ - libavformat/mov
+ - libavformat/oggdec
+ - libavformat/oggparsevorbis
+
+ -- Reinhard Tartler Thu, 05 Nov 2009 20:31:29 +0100
+
+ffmpeg (4:0.5+svn20090706-2ubuntu2) karmic; urgency=low
+
+ [ Reinhard Tartler ]
+ * Make arguments of av_set_pts_info() unsigned.
+ * update debian/changelog
+ * use patch for issue1245 from git.ffmpeg.org
+ * Support constant-quant encoding for libtheora, LP: #356322
+ * increase swscale compile time width (VOF/VOFW), LP: #443264
+
+ [ Loïc Minier ]
+ * Update config for karmic's armel toolchain.
+ * Enable neon flavour; LP: #383240.
+ * Update NEON confflags to assume v7 and VFP.
+ * Add backported NEON patches from ffmpeg trunk; see debian/patches/neon/.
+ * Pass proper --cpu and --extra-flags on armel.
+ * Pass -fPIC -DPIC to neon pass.
+
+ -- Loïc Minier Tue, 13 Oct 2009 23:56:04 +0200
+
+ffmpeg (4:0.5+svn20090706-2ubuntu1) karmic; urgency=low
+
+ * merge from debian. Remaining changes:
+ - disabled output decoders: faad, openjpeg, dirac (all not in main)
+ - build arm vfp variant
+ - don't build depend on yasm.
+ * fix dependencies on -extra packages: LP: #418705, #416348
+ * no need to remove mpeg encoders in the ubuntu package, unless we hear
+ otherwise from some patent owner. This brings back the mpeg2video
+ encoder is available. cf. formats.txt.gz LP: #416585
+
+ -- Reinhard Tartler Wed, 26 Aug 2009 11:20:03 +0200
+
+ffmpeg (4:0.5+svn20090706-2) unstable; urgency=low
+
+ [ Fabian Greffrath ]
+ * Enable support for libdirac, now that it has entered Debian.
+
+ [ Andres Mejia ]
+ * Fix ordering of FLAVORS that are installed. (Closes: #543595)
+
+ [ Reinhard Tartler ]
+ * prepare new upload
+ * simply debian/confflags by removing the case of renaming the source
+ package
+
+ -- Reinhard Tartler Wed, 26 Aug 2009 09:12:49 +0200
+
+ffmpeg (4:0.5+svn20090706-1ubuntu3) karmic; urgency=low
+
+ * update the dependencies of the -dev packages for the
+ unstripped -> extra renaming
+
+ -- Reinhard Tartler Tue, 25 Aug 2009 16:37:23 +0200
+
+ffmpeg (4:0.5+svn20090706-1ubuntu2) karmic; urgency=low
+
+ * really drop libopenjpeg from build depends.
+
+ -- Reinhard Tartler Tue, 25 Aug 2009 08:17:17 +0200
+
+ffmpeg (4:0.5+svn20090706-1ubuntu1) karmic; urgency=low
+
+ * merge from debian. Remaining changes:
+ - don't build-depend on libfaad-dev, disabling faad decoder.
+ - build arm vfp variant
+ - don't build libopenjpeg support (not in main)
+ * change shlibs file to make applications depend on the -extra- packages.
+ * don't build depend on yasm.
+
+ -- Reinhard Tartler Sat, 15 Aug 2009 18:18:23 +0200
+
+ffmpeg (4:0.5+svn20090706-1) unstable; urgency=low
+
+ * preparing new upstream version, 0.5 release branch, rev 19352
+ - this version is capable of compiling swscale in LGPL mode
+ * rename source package back
+ - The replacement package with the 'missing bits' will be called
+ 'ffmpeg-extra'
+ - simplify README.upstream-upgrade
+ - rename the source package from 'ffmpeg-debian' -> 'ffmpeg'
+ * fix aac playback regression, thanks to Matthew Wakeling for reporting
+ (Closes: #540729)
+ * fix seeking in DIF (DV) movies
+ Thanks to Dan Dennedy for identifying the patch! (Closes: #540424)
+ * debian/rules:
+ - merge cond_enable_nf macro from master.extra branch
+ - don't disable ffserver in various optimized variants
+ - don't disable building of statically linked helper binaries
+ - simply by removing the case of renaming the source package
+ - change the shlibs file: s/-unstripped-/-extra-/
+
+ -- Reinhard Tartler Thu, 13 Aug 2009 12:48:27 +0200
+
+ffmpeg-debian (4:0.5+svn20090609-2) unstable; urgency=low
+
+ [ Fabian Greffrath ]
+ * Remove .install files for unstripped packages that we do not build
+ from this branch anyway.
+ * Remove debian/fixup-config.sh which was only a hack needed to repair
+ the crippled config.h
+ * Finally remove strip.sh.
+
+ [ Andres Mejia ]
+ * Add vdpau support by including vdpau headers in deb packaging.
+ (Closes: #511544)
+ * Don't disable encoders if internalencoders is set in
+ DEB_BUILD_OPTIONS.
+ * Enable yasm for i386 and amd64.
+
+ [ Reinhard Tartler ]
+ * clarifications suggested by upstream in README.Source
+ * refresh patches
+
+ [ Fabian Greffrath ]
+ * Document the copyright notice and license for the VDPAU headers in
+ debian/copyright.
+ * Remove parallel make support from debian/confflags, it's overridden
+ in debian/rules anyway.
+ * Quote opts in debian/watch.
+ * Bump debhelper compat to 7.
+ * Clean up clean target in debian/rules in favour of debian/clean.
+ * Replace "dh_clean -k" by dh_prep.
+
+ [ Reinhard Tartler ]
+ * remove duplicated libxvmc-dev build dependency
+ * sort build dependencies alphabetically
+ * remove section numbering from README.Debian
+ * add note about the lintian override
+
+ -- Reinhard Tartler Thu, 13 Aug 2009 12:46:46 +0200
+
+ffmpeg-debian (4:0.5+svn20090609-1ubuntu3) karmic; urgency=low
+
+ * do not forcefully enable objenjpeg, it is not avaiable in this build
+ anyway
+ * don't build against faac in any case, it is deemed non-free
+
+ -- Reinhard Tartler Sat, 25 Jul 2009 09:15:12 +0200
+
+ffmpeg-debian (4:0.5+svn20090609-1ubuntu2) karmic; urgency=low
+
+ * remove libopenjpeg-dev from build depends (fixes FTBFS)
+ * remove duplicate libxvmc-dev build-dependency
+
+ -- Reinhard Tartler Fri, 24 Jul 2009 21:53:47 +0200
+
+ffmpeg-debian (4:0.5+svn20090609-1ubuntu1) karmic; urgency=low
+
+ * merge from debian. Remaining changes:
+ - don't build-depend on libfaad-dev, disabling faad decoder.
+ - build arm vfp variant
+ * update gbp.conf
+ * move gbp.conf to debian/
+
+ -- Reinhard Tartler Sat, 18 Jul 2009 10:55:24 +0200
+
+ffmpeg-debian (4:0.5+svn20090609-1) unstable; urgency=low
+
+ [ Andres Mejia ]
+ * Add myself to Uploaders list.
+ * Reorder when dh_strip is done so qt-faststart is also
+ stripped.
+ * Update to control files.
+ * Add new confflags for new build dependencies.
+ * Use .docs files to add ffmpeg and ffmpeg-doc documentation.
+ * Use .docs files for installing documentation.
+ * Add comment to 900_doxyfile patch.
+ * Add man page for qt-faststart.
+ * Bump version in changelog to prepare new release
+ * Fix FTBFS for ffmpeg source package with -dev packages (Closes: #527761)
+ * Use dh_lintian to install lintian overrides
+ * Update comment on fpic-* patches
+ * Build-Depend on debhelper (>= 6.0.7~) for dh_lintian.
+ * Add lintian overrides for remaining fpic lintian errors.
+ * Shorten comment on lintian-overrides.
+ * Allow passing in extra confflags, removes the need for fix-fpic
+ DEB_BUILD_OPTIONS.
+ * Fix FTBFS on kfreebsd. (Closes: #528591)
+ * Include patches to allow us to use opencore-amr libraries.
+
+ [ Reinhard Tartler ]
+ * remove debian/control.* mechanism
+ * improve patch description for debian/patches/100_kfreebsd
+
+ [ Andres Mejia ]
+ * Add lintian overrides for ffmpeg-debian source warnings.
+ * Only use .svnrevision if it's readable.
+ * Update source lintian-overrides for modifications to debian/rules.
+ * Add fix for FTBFS for GNU Hurd OS. Thanks Marc Dequènes.
+ (Closes: #530436)
+
+ [ Felipe Sateler ]
+ * Don't add -unstripped to the unstripped variant version number
+ in debian/README.upstream-upgrade.
+ * In the same file, pass explicit version to git-import-orig
+
+ [ Fabian Greffrath ]
+ * Cleaned up debian/watch file.
+ * Add notes why we no longer strip the orig.tar.gz.
+
+ [ Andres Mejia ]
+ * Fix watch file to ignore daily snapshots.
+ * Make get-orig-source.sh executable.
+
+ [ Reinhard Tartler ]
+ * add patch for qtrle encoding (Closes: #530016)
+ * Enable xvmc support by adding libxvmc-dev to build dependencies
+ * really add libopenjpeg-dev to build depends, actually enabling
+ the openjpeg decoder.
+ * reorganise README.Debian for the new plan [tm]
+ * no longer strip the source on upstream upgrades
+ * Imported Upstream version 0.5+svn20090609
+ * adjust notes in README.upstream-upgrade for the now unstripped
+ debian source package
+ * remove hack to build with stripped sources
+ * bump standards version, no changes needed
+
+ -- Reinhard Tartler Sun, 05 Jul 2009 22:52:43 +0200
+
+ffmpeg-debian (4:0.5+svn20090420-2) unstable; urgency=low
+
+ * debian/control: fix dependencies for libavutil-dev and libavfilter-dev
+ so that they can be used with the unstripped variants properly.
+ * debian/rules: set nooptflags only for relevant architectures.
+ * explicitly disable 'dangerous' encoders on the --configure line.
+ * fix SHLIBS_VERSION in debian/rules (Closes: #527350).
+
+ -- Reinhard Tartler Mon, 04 May 2009 07:41:19 +0200
+
+ffmpeg-debian (4:0.5+svn20090420-1) unstable; urgency=low
+
+ [ Fabian Greffrath ]
+ * Merge the contents of patents.txt into README.Debian and change some
+ paragraphs to (hopefully) add some more clarity on the removed encoders
+ and the package naming scheme. Based on suggestions by Xavier Douville
+ , thank you very much for the review. (Closes: #519025)
+ * Reorder some confflags to account for GPL licensed libraries.
+ * Remove patents.txt
+ * Explicitely mention that no decoders are disabled in our packages.
+
+ [ Loïc Minier ]
+ * Disable more autodetecter ARM arch features
+ * Add neon and vfp flavors to armel disabled for now
+ * vfp CFLAGS: add "-mfpu=vfp -mfloat-abi=softfp"
+
+ [ Reinhard Tartler ]
+ * New Upstream Version (svn revision 18630)
+ * bump epoch as 0.5 was released. Future version will use '+' to indicate
+ that the package is based on a release branch and '~' to indicate that
+ the package is based on the 'trunk' branch.
+ * update from the upstream release branch to generate a new upstream
+ tarball.
+ * add a git-buildpackage config file at debian/gbp.conf
+ * beautify identification string
+ * debian/rules: bump epoch to '4'
+ * update section names in control file
+ * update upstream svn server url
+ * fixup get-orig-source rules in debian/rules
+ * create right filenames for the orig.tar.gz files
+ * update README.upstream-upgrate for new versioning scheme
+ * remove debian/005_release_branch_changes.diff
+ * remove reference to 020_visibility_patch
+ * install the upstream license file and release notes
+ * allow -dev packages be installed with the unstripped variants
+ Closes: #526007, LP: #312898
+ * be more careful with svn:externals in debian/get-orig-source.sh.
+ (Closes: #525348)
+
+ -- Reinhard Tartler Sat, 02 May 2009 09:09:54 +0200
+
+ffmpeg-debian (3:0.svn20090303-1ubuntu6) jaunty; urgency=low
+
+ * vfp CFLAGS: add "-mfpu=vfp -mfloat-abi=softfp".
+
+ -- Loic Minier Fri, 10 Apr 2009 21:34:29 +0200
+
+ffmpeg-debian (3:0.svn20090303-1ubuntu5) jaunty; urgency=low
+
+ * Disable more autodetected ARM arch features.
+ * Add neon and vfp flavors to armel disabled for now.
+ * Enable vfp pass on armel; leave the neon disabled.
+
+ -- Loïc Minier Fri, 10 Apr 2009 17:58:52 +0200
+
+ffmpeg-debian (3:0.svn20090303-1ubuntu4) jaunty; urgency=low
+
+ * brown paperbag upload. Actually include the patch intended for the
+ last upload.
+
+ -- Reinhard Tartler Sat, 21 Mar 2009 14:55:46 +0100
+
+ffmpeg-debian (3:0.svn20090303-1ubuntu3) jaunty; urgency=low
+
+ * don't disable ffserver in specialised flavors. Fixes LP: #345370
+
+ -- Reinhard Tartler Sat, 21 Mar 2009 14:52:25 +0100
+
+ffmpeg-debian (3:0.svn20090303-1ubuntu2) jaunty; urgency=low
+
+ * No-change rebuild to fix lpia shared library dependencies.
+
+ -- Colin Watson Thu, 19 Mar 2009 17:26:36 +0000
+
+ffmpeg-debian (3:0.svn20090303-1ubuntu1) jaunty; urgency=low
+
+ * FFE granted in LP: #340303.
+
+ * merge from debian/unstable.
+ * remaining changes to debian:
+ - don't build-depend on libfaad-dev, disabling faad decoder.
+
+ -- Reinhard Tartler Fri, 13 Mar 2009 08:54:33 +0100
+
+ffmpeg-debian (3:0.svn20090303-1) unstable; urgency=low
+
+ * New Upstream Version (svn revision 17737 libswscale revision 28799)
+ - Electronic Arts TQI decoder
+ - OpenJPEG based JPEG 2000 decoder
+ - NC (NC4600) camera file demuxer
+ - Gopher client support
+ - MXF D-10 muxer
+ - generic metadata API
+ * debian/get-orig-source.sh: Track the version 0.5 release branch. The
+ version number does not really reflect this, but this package is
+ actually very close to the 0.5 release branch.
+ * various cleanups to improve get-orig-source.sh
+ * Remove liba52 from the suggests field in debian/control.ffmpeg, as
+ ffmpeg does no longer use it since upload 0.svn20080206-10.
+ * Fix the Vcs-Git urls to the correct locations.
+ * The libavformat52 now links against libavcodec52, which breaks
+ applications that *ALSO* link against libavcodec51. Adding a
+ Breaks: libavcodec51 should prevent this and (hopefully) Closes: #516885.
+ * improve parallel builds on SMP/multicores by supporting the parallel
+ flag in DEB_BUILD_OPTIONS, and default to the number of available CPUs
+ on i386 and amd64.
+ * Drop unapplied patches from debian/patches.
+ * bump shlibs version.
+
+ -- Reinhard Tartler Tue, 03 Mar 2009 21:01:25 +0100
+
+ffmpeg-debian (3:0.svn20090204-3) unstable; urgency=low
+
+ [ Fabian Greffrath ]
+ * remove libasound2-dev from build-depends on non-Linux archs
+
+ [ Reinhard Tartler ]
+ * fix postinst generation by calling dh_installdeb after dh_makeshlibs
+ * upload to unstable
+
+ -- Reinhard Tartler Sun, 22 Feb 2009 09:32:49 +0100
+
+ffmpeg-debian (3:0.svn20090204-2ubuntu1) jaunty; urgency=low
+
+ * merge from debian. Remaining changes:
+ - don't build depend on libfaad-dev
+
+ -- Reinhard Tartler Thu, 05 Feb 2009 21:22:01 +0100
+
+ffmpeg-debian (3:0.svn20090204-2) experimental; urgency=low
+
+ * add libxvmc-dev to build-depends in the 'ffmpeg' variant
+ * add libasound2-dev to build-depends. This means that ffplay is now able to
+ actually play using alsa directly instead only via libsdl
+ * add epochs for the "internal" shlibs dependencies
+
+ -- Reinhard Tartler Thu, 05 Feb 2009 20:30:05 +0100
+
+ffmpeg-debian (3:0.svn20090204-1) experimental; urgency=low
+
+ [ Reinhard Tartler ]
+ * New Upstream Version (svn revision 16978 libswscale revision 28461)
+
+ Upstream Changes:
+ - R3D REDCODE demuxer
+ - ALSA support for playback and record
+
+ * strighten internal dependencies by using a shlibs.local file
+ Closes: #512844, #512466
+ * New upstream version reintroduces a compatibility symbol ff_gcd
+ Closes: #512946
+ * Bump shlibs because of changes of the Metadata API in libavformat.
+ Actually no other package should use them yet, but let's better play safe
+ here...
+ * no longer install dsputil.h. It exposes lots of function that are private
+ to ffmpeg and may change on any new upstream revision. Please get in touch
+ with the ffmpeg maintainers if you maintain packages that rely on that
+ ffmpeg internal headers like this.
+ * simplify debian/confflags by doing autodetection of headers:
+ - xvid.h
+ - lame/lame.h
+ - faac.h
+ - x264.h
+ - vdpau/vdpau.h
+ Also remove the setting externalcodecs from DEB_BUILD_OPTIONS. The codecs
+ will be enabled as soon as the headers are installed on the filesystem,
+ so there is no need in enabling that separately.
+ * install ffpresets in /usr/share/ffmpeg/. Currently only presets for
+ x264 are avaiable, so a libx264 enabled libavcodec (like
+ libavcodec-unstripped-52) is needed to actually use them.
+
+ [ Fabian Greffrath ]
+ * Enabled Speex decoding via libspeex.
+ * Use an alternative approach to achieve strict internal dependencies
+ by calling dh_makeshlibs twice in debian/rules instead of a
+ debian/shlibs.local file.
+
+ -- Reinhard Tartler Sun, 01 Feb 2009 19:54:27 +0100
+
+ffmpeg-debian (3:0.svn20090119-1ubuntu1) jaunty; urgency=low
+
+ * merge from debian. LP: #318501
+ * new version fixes CVE-2008-3230, LP: #253767
+
+ -- Reinhard Tartler Tue, 20 Jan 2009 09:20:53 +0100
+
+ffmpeg-debian (3:0.svn20090119-1) experimental; urgency=low
+
+ * New Upstream Version (svn revision 16681 libswscale revision 28341)
+ * update Vcs-Git tags. Packaging has now moved to git
+ * updates to packaging that faciliate building the unstripped and ubuntu
+ variants of this package
+ * enable xvmc support
+
+ Upstream Changes:
+ - SVQ3 watermark decoding support
+ - hybrid WavPack support
+
+ -- Reinhard Tartler Tue, 20 Jan 2009 00:55:26 +0100
+
+ffmpeg-debian (3:0.svn20090110-1) experimental; urgency=low
+
+ * new upstream svn snapshot (svn revision 16508, libswscale revision 28286)
+
+ Upstream Changes:
+ - RV30 and RV40 decoder
+ - QCELP / PureVoice decoder
+
+ * removed patch 050_fix_pkgconfig_files.patch. Merged upstream
+ * disabled patch 020_visibility_patch. It needs to be adapted to the new
+ upstream changes. Hopefully it will get merged into ffmpeg properly.
+ * install formats.txt in the libavcodec52 package to document what
+ formats this version of ffmpeg has enabled.
+
+ -- Reinhard Tartler Sun, 11 Jan 2009 20:55:48 +0100
+
+ffmpeg-debian (3:0.svn20081115-1ubuntu1) jaunty; urgency=low
+
+ * merge from debian.
+ * keep myself in the maintainer field. If you are touching this or the
+ 'ffmpeg' package in multiverse, please get in touch with me. Both
+ source packages come from the same packaging branch.
+ * drop dependency on faad.
+
+ -- Reinhard Tartler Sat, 15 Nov 2008 19:44:29 +0100
+
+ffmpeg-debian (3:0.svn20081115-1) experimental; urgency=low
+
+ * new upstream svn snapshot (svn revision 15824, libswscale revision 27910)
+ * bump standards version to version 3.8.0, no changes needed
+ * Adjust pkg-files to no longer put unnecessary dependencies in the generated
+ .pc files. Closes: #504220
+
+ -- Reinhard Tartler Mon, 10 Nov 2008 21:37:16 +0100
+
+ffmpeg-debian (3:0.svn20081108-1ubuntu3) jaunty; urgency=low
+
+ * really disable faad support completely.
+
+ -- Reinhard Tartler Mon, 10 Nov 2008 10:58:01 +0100
+
+ffmpeg-debian (3:0.svn20081108-1ubuntu2) jaunty; urgency=low
+
+ * drop the patch to dlopen faad at runtime for now. it needs more
+ polishing, and we can have that functionality easier with the 'ffmpeg'
+ source package that will appear in multiverse.
+
+ -- Reinhard Tartler Mon, 10 Nov 2008 10:31:47 +0100
+
+ffmpeg-debian (3:0.svn20081108-1ubuntu1) jaunty; urgency=low
+
+ * merge from debian.
+ * keep myself in the maintainer field. If you are touching this or the
+ 'ffmpeg' package in multiverse, please get in touch with me. Both
+ source packages come from the same packaging branch.
+ * drop dependency on faad.
+ * import patches from old packaging to dlopen libfaad at runtime.
+
+ -- Reinhard Tartler Mon, 10 Nov 2008 07:31:16 +0100
+
+ffmpeg-debian (3:0.svn20081108-1) experimental; urgency=low
+
+ * upstream svn snapshot (svn revision 15786, libswscale revision 27900).
+ * apply visibility patch from ffmpeg-devel mailing list. This reduces the
+ number of symbols that are exposed to other applications. Please file
+ bugs if applications fail to link against ffmpeg because of that.
+ * remove 001_fixup_version.diff patch and use upstream --extra-version
+ configure flag instead.
+ * now really remove 015_img_convert.patch from source package.
+
+ -- Reinhard Tartler Sat, 08 Nov 2008 16:38:23 +0100
+
+ffmpeg-debian (3:0.svn20080925-1) experimental; urgency=low
+
+ [ Loic Minier ]
+ * Tweak sed versions regexps to deal with epochs and upstream revisions with
+ dashes and be generally stricter.
+ * Large cleanup to rules logic: drop some cruft, rewrite some small chunks
+ in a slightly more readable manner, whitespaces, .PHONY fixes,
+ internalencoders handling, shlibs logic...
+ * Rename SRC_VERSION to UPSTREAM_VERSION in rules.
+ * Use DEB_SOURCE from the Source: field of dpkg-parsechangelog's output
+ instead of hardcoding the name of the source.
+
+ [ Reinhard Tartler ]
+ * new svn snapshot (svn revision 15404, libswscale revision 27636).
+ * SONAME change: libavcodec51 -> libavcodec52
+ * drop old scaler (imgres/imgconvert). Upstream is about to remove it
+ completely.
+ - reporter claims that a newer snapshot fixes a crash in the dca decoder.
+ Thanks to "Alexander E. Patrakov" (Closes: #496612)
+ * reenable h261 encoder (Closes: #459073)
+
+ [ Fabian Greffrath ]
+ * debian/{ffmpeg,lib*-dev}.install:
+ + Simplified, e.g. install the whole /usr/include/ sub-directory for each
+ particular library instead of single header files one by one.
+ * debian/control, debian/confflags:
+ + Enabled Dirac support via libschroedinger. (Closes: #499785)
+ * debian/changelog:
+ + Added an epoch needed for Ubuntu.
+ * debian/control:
+ + Removed Conflicts and Replaces against packages that either aren't even
+ in Debian 4.0 "Etch" anymore or that use the deprecated naming scheme
+ from .
+ + Since ffmpeg-config has been removed from our packages, all inter-package
+ Conflicts and Replaces may be removed, too.
+ + Removed Build-Conflicts against libdc1394-13-dev, because
+ libdc1394-22-dev already does this for us.
+ + Updated inter-package dependencies and demoted Depends on external
+ library packages to Suggests, since we shouldn't encourage package
+ maintainers to link statically against libav*.
+ * debian/confflags, debian/control, debian/rules, debian/libavfilter*:
+ + Built libavfilter and disabled vhook in turn (Closes: #499787).
+
+ [ Loic Minier ]
+ * Remove debug echo which broke shlibs, sorry.
+ * Fix Vcs-* control fields; thanks Gerfried Fuchs.
+ * Mention upstream SVN in debian/copyright; thanks Gerfried Fuchs;
+ closes: #499914.
+
+ -- Reinhard Tartler Sat, 06 Sep 2008 20:07:01 +0200
+
+ffmpeg-debian (0.svn20080206-12) unstable; urgency=low
+
+ * enable vhook in all flavors. (Closes: #490272, LP: #260296)
+ * make ffmpeg output a proper version number. (Closes: #496133, #483923)
+
+ -- Reinhard Tartler Sat, 23 Aug 2008 10:49:10 +0200
+
+ffmpeg-debian (0.svn20080206-11) unstable; urgency=low
+
+ [ Reinhard Tartler ]
+ * new patch: patches/010_fix_ftbfs_hppa.diff: On hppa shared objects
+ do required object files to be build "-fPIC -DPIC". Patch taken
+ from upstream svn.
+ * bugfix: libraries linked with libX11 on GNU/kFreeBSD. Thanks to
+ Aurelien Jarno for the patch. (Closes: #487252)
+
+ [ Fabian Greffrath ]
+ * debian/confflags, debian/control:
+ + Build-Depend on libdc1394-22-dev explicitely and add
+ Build-Conflicts on libdc1394-13-dev (Closes: #490319).
+
+ -- Reinhard Tartler Wed, 16 Jul 2008 10:41:49 +0200
+
+ffmpeg-debian (0.svn20080206-10) unstable; urgency=high
+
+ * enable mmx and sse3 in builds. These CPU features are autodetected
+ at runtime on amd64 and i386 using the 'cpuid' instrcution.
+ (Closes: #489732)
+ * disable support for liba52-dev. ffmpeg has its own implementation.
+ * don't add -fPIC -DPIC forcefully to ./configure. upstream claim that
+ the configure script gets this right on all architectures itself.
+ * Add patch 020_bug489965_bufferoverflow_str_demuxer.diff. Fixes a
+ buffer overflow in the STR demuxer. Thanks to Moritz Muehlenhoff for
+ reporting the issue. (Closes: #489965)
+ * Raising severity to high because of security issue.
+ * rework the shlibs file. Make applications linking against libraries
+ produced by this source package generate an alternate dependency on
+ the 'unstripped' variants of this package. They actually do not exist
+ yet at this point, but this way reverse dependencies are enabled to
+ use them when they eventually appear.
+
+ -- Reinhard Tartler Wed, 09 Jul 2008 14:04:06 +0200
+
+ffmpeg-debian (0.svn20080206-9) unstable; urgency=low
+
+ [ Reinhard Tartler ]
+ * cleanup 010_proper_rpath.diff: remove spurious linker search paths.
+ * debian/strip.sh: no need to remove the glue code for x264 and xvid.
+ However, since that code is not built in debian anyway, the orig.tar.gz
+ was not rebuilt with this change.
+ * provide mmx-enabled shared objects on amd64. AFAIK all amd64 machines
+ do support MMX.
+ * Provide optimized versions of the libraries along the unoptimized
+ ones. They are installed in machines and architecture specific
+ directories. Optimized for further target will be added per request,
+ please file bugs to request them.
+ * rename the source package (again), this time on upstream's request.
+ The former name was considered insulting by upstream, because it
+ somewhat indicated the original source was somehow 'non-free', which is
+ not the case. The new name now represents that we modified the package
+ so that it becomes acceptable for debian.
+ * Cleanups in debian/rules file.
+ * Add verbose explanations about the renaming in README.Debian.
+
+ [ Fabian Greffrath ]
+ * debian/control:
+ + Added Conflicts and Replaces against obsolete library packages from
+ wearing the 'cvs' suffix in their names
+ (Closes: #484585, #484586, #484587, #484776, #484778).
+ + Added doxygen to Build-Depends.
+ + Introduced new package 'ffmpeg-doc' that contains html doxygen
+ documentation of the ffmpeg API (Closes: #438369).
+ + Changed Build-Depends from libdc1394-13-dev to libdc1394-22-dev,
+ which is supported upstream since r11501.
+ * debian/ffmpeg-doc.install:
+ + Added.
+ * debian/rules:
+ + Build and install html doxygen documentation.
+ + Avoid dependency of build-stamp rule on phony targets.
+ * debian/libavutil-dev.install, debian/rules,
+ debian/patches/010_ffmpeg-config.diff:
+ + Removed ffmpeg-config, use pkg-config instead (maintainers of affected
+ packages have been informed, see #487917 to #487922).
+
+ [ Darren Salt ]
+ * Added patch 900_doxyfile: tell doxyfile to ignore debian* directories.
+ * debian/rules:
+ - Reworked building so that separate source & build directories are
+ used. This makes cleanup simpler and speeds up maintenance by avoiding
+ complete rebuilds when using "debuild binary".
+ - Removed some file installation 'cp' commands, made unnecessary due to
+ the build reworking.
+ - Unpatching is now done *after* cleaning.
+
+ -- Reinhard Tartler Mon, 30 Jun 2008 15:27:50 +0200
+
+ffmpeg-free (0.svn20080206-8) unstable; urgency=low
+
+ [ Fabian Greffrath ]
+
+ * debian/control:
+ + Added Conflicts and Replaces on libavutil-dev (<< 0.svn20080206-7)
+ to libavcodec-dev (Closes: #483548).
+
+ [ Reinhard Tartler ]
+
+ * remove patches from the debian package as disussed with upstream:
+ - 005_runtime_cpudetect.diff: it is supposed to fix runtime cpu detection
+ on i386. The code (and the define) has undergone large refactoring wrt.
+ the define RUNTIME_CPUDETECT. It is very likely to have undisired
+ side-effects with this version of ffmpeg. It therefore seem more safe
+ to me to actually remove this patch for now, and reinvestigate the
+ problems that occur, if they do. (Related to: #482717)
+ - 005_m68k_workaround.diff: works around bugs in gcc for m68k.
+ - 006_mips_pthreads.diff: was an workaround for (now fixed) #428741.
+ - 020_fix_sws_scale_crash: patch has been rejected upstream:
+ http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2008-May/047846.html
+ - 054_h264_mmx_chroma_mc_crash.diff. According to upstream, this has
+ been fixed in a different way and is not reproducible. Verified that
+ the file referenced in bug #404176 does not crash anymore even
+ without this patch.
+ * new patch: 015_reenable-img_convert.diff. Unlike previous version of this
+ patch, this uses a more lightweight approach. With building imgresample, a
+ few symbol clashes occur with libswscale. We therefore strip off symbols
+ that are already provided by libswscale. (Closes: #483960).
+ * remove 011_link_plugins.diff. It is completely unnecessary now.
+ * refactor quilt usage: use /usr/share/quilt/quilt.make.
+ * support building in paralell. make snippet taken from the qemu package.
+ * cleanups in debian/rules.
+ * Move ffmpeg-config back to libavutil. This way we can avoid a circular
+ dependency between libavutil-dev and libavcodec-dev. (Closes: #484132).
+ libavcodec uses libavutil internally, so this dependency cannot be avoided.
+ * disable altivec, at least for now. (Closes: #482717)
+ * always compile with --disable-strip. We strip the binaries afterwards using
+ dh_strip anyways.
+ * Remove depdency substitutions ${shlibs:Depends} and ${misc:Depends} from the
+ -dev packages.
+
+ -- Reinhard Tartler Wed, 04 Jun 2008 00:04:08 +0200
+
+ffmpeg-free (0.svn20080206-7) unstable; urgency=low
+
+ * debian/control:
+ + Removed unnecessary Conflicts and Replaces from libswscale0
+ (Closes: #481908), thanks Guillem Jover.
+ + Made libavutil-dev depend on libavcodec-dev.
+ * debian/libavcodec.install, debian/libavutil.install:
+ + Moved ffmpeg-config (script and manpage) from libavutil-dev to
+ libavcodec-dev (really Closes: #482213, #482214).
+
+ -- Fabian Greffrath Tue, 28 May 2008 16:02:03 +0200
+
+ffmpeg-free (0.svn20080206-6) unstable; urgency=low
+
+ * Bug fix: "libavg: FTBFS: ld: cannot find -ldts", thanks to Lucas
+ Nussbaum (Closes: #482213, 482214). Fixed by removing -ldts from
+ ffmpeg-config.
+
+ -- Reinhard Tartler Tue, 27 May 2008 12:45:10 +0200
+
+ffmpeg-free (0.svn20080206-5) unstable; urgency=low
+
+ [ Fabian Greffrath ]
+ * debian/control:
+ + Fixed dependency typo, libswscale0 conflicts with libswsacle1d but not
+ libswscale1d (Closes: #481908).
+
+ [ Reinhard Tartler ]
+ * disable 015_build_imgresample.diff. Please port all applications
+ needing the symbols sws_{scale,getContext},
+ sws_{getCachedContext,freeContext} to use libswscale instead.
+ * downgrade debhelper depencency to level 5. We don't use any of the
+ level 6 features, and level 5 faciliates backporting to earlier
+ releases massively.
+ * remove unapplied patches from source to reduce the size of the
+ .diff.gz. The old patches can be retrieved from branches in our svn.
+
+ -- Reinhard Tartler Thu, 22 May 2008 09:26:06 +0200
+
+ffmpeg-free (0.svn20080206-4) unstable; urgency=low
+
+ * debian/rules:
+ + Moved confflags, that result in GPL versions of the libraries, into a
+ dedicated variable gpl_confflags. Add this to the common confflags.
+ + Moved --prefix=/usr to the common confflags.
+ + Added some comments and whitespace (nothing special).
+ + Renamed the "risky" keyword to "internalencoders". Set this in
+ DEB_BUILD_OPTIONS in order to create and build from an unstripped tarball
+ in the get-orig-source and build rules (Closes: #478010).
+ + Introduced the "externalcodecs" keyword. Set this in DEB_BUILD_OPTIONS to
+ enable support for additional codecs via external libraries.
+ + Commented out the amr?b codecs among the external codecs, because the
+ resulting packages will be unredistributable.
+
+ -- Fabian Greffrath Tue, 29 Apr 2008 09:07:11 +0100
+
+ffmpeg-free (0.svn20080206-3) experimental; urgency=low
+
+ * install qt-faststart. Thanks Stefan Hermann for the patch from ubuntu.
+ (Closes: #470484)
+ * Reenable 020_fix_libswscale_pic_code, fixes FTBFS on amd64.
+ * Reenable altivec, fixes FTBFS on powerpc.
+ * Add some notes about the removed mpeg encoders (Closes: #440702)
+
+ -- Reinhard Tartler Fri, 18 Apr 2008 23:02:24 +0200
+
+ffmpeg-free (0.svn20080206-2) experimental; urgency=low
+
+ [ Reinhard Tartler ]
+ * patches/020_fix_sws_scale_crash: if sws_scale is given an invalid context
+ (e.g. a null pointer), the function will crash because of a null pointer
+ dereference. Add a check for that here.
+ * add Conflicts/Replaces for libswscale1d.
+ * Due to the fact that we no longer build the shared version of ffmpeg with
+ mmx optimisations, the following patches have been dropped:
+ - 020_mmx_optims.diff
+ - 020_mmx_pic_code.diff
+ - 020_disable_snow_mmx_in_pic.diff
+ - 020_fix_libswscale_pic_code
+
+ [ Fabian Greffrath ]
+ * debian/control:
+ + Added libx11-dev and libxext-dev to Build-Depends.
+ * debian/rules:
+ + Build with --enable-x11grab (Closes: #441983).
+ + Build ffmpeg and shared libraries with --extra-cflags="-fPIC -DPIC"
+ (feeling confident that this closes: #472613) and "drop the surgery
+ regarding Makefile.pic and config.mak.pic".
+ + In this context, cleaned up build rule: Run '$(MAKE)' and '$(MAKE) clean'
+ from the top source directory instead of diving into the library
+ directories; force move during backup and recovery of the static
+ libraries; let the build rule itself depend on config-extra-includes.h
+ (instead of build-stamp) to avoid being run again from the binary rule;
+ some more minor changes of cosmetic type.
+ + Renamed config-extra-includes rule to config-extra-includes.h to
+ reflect the file name of the created file (also changed to override it
+ instead of appending) and to avoid the rule to be run twice.
+ + Disabled all architecture-specific optimizations for the time being.
+
+ -- Fabian Greffrath Fri, 1 Apr 2008 17:22:00 +0100
+
+ffmpeg-free (0.svn20080206-1) experimental; urgency=low
+
+ [ Reinhard Tartler ]
+ * new upstream release (Closes: #471136)
+ * refreshed patches
+ * libogg was dropped upstream
+ * no longer install integer.h, as it is not part of the public API (see
+ upstream r11642).
+ * no longer install rtp.h, as it is not part of the public API (see
+ upstream r11505).
+ * install crc.h and sha1.h to libavutil-dev, since it is part of the
+ public API now.
+ * introduce new package: libavdevice52 and libavdevice-dev.
+ * Implemented debian/get-orig-source.sh and adjusted the get-orig-source
+ target in debian/rules to use that.
+ * fix invocation of the testsuite.
+ * bump standards version to 3.7.3 (no changes needed).
+ * add script recordshow.sh (Closes: 461434). Thanks to
+ Daniel Dickinson
+ * Introdcue binary package ffmpeg-dbg, which contains debugging symbols
+ of the shared library packages.
+
+ [ Fabian Greffrath ]
+ * debian/changelog:
+ + Source is exported from SVN, not CVS. Reflect this in the versioning
+ scheme (Closes: #468319).
+ * debian/control:
+ + Changed Build-Depends to liba52-0.7.4-dev | liba52-dev.
+ + Improved descriptions and dependencies for libavdevice packages.
+ * debian/control, debian/compat:
+ + Bumped debhelper Build-Depends to (>= 6.0.0).
+ * debian/control, debian/*.install:
+ + Adopted shared library package names to upstream SONAMEs.
+ * debian/README.Debian:
+ + Updated, since AAC decoding (through FAAD) is now enabled.
+ + Updated URL for unofficial ffmpeg packages.
+ * debian/rules:
+ + Reordered confflags to optionally build LGPL versions of the libraries.
+ + Removed trailing whitespace.
+ + Removed unused strip rule.
+ + Added libxvidcore4-dev to weak-build-deps and fixed confflags
+ in DEB_BUILD_OPTIONS=risky accordingly.
+ + Added a get-orig-source rule to reproduce the source tarball. Produce an
+ unstripped tarball if DEB_BUILD_OPTIONS=risky.
+ + Do not run debian/fixup-config.sh if DEB_BUILD_OPTIONS=risky.
+ * debian/patches/011_link_plugins.diff:
+ + Updated to link all plugins against libavutil since they all use symbols
+ from this library. Resolves "symbols found in none of the libraries"
+ warnings from dpkg-shlibdeps.
+
+ -- Reinhard Tartler Thu, 20 Mar 2008 17:57:21 +0100
+
+ffmpeg-free (0.cvs20071007-4) experimental; urgency=low
+
+ [ Fabian Greffrath ]
+ * debian/control:
+ + Wrapped Uploaders, Build-Depends and Depends,
+ Conflicts and Replaces fields.
+ + Added libfaad-dev to Build-Depends.
+ + Added Homepage field.
+ + Added ${misc:Depends} to all Depends.
+ * debian/rules:
+ + Enabled faad support via libfaad
+ (Closes: #400094, #418230, #447089, #448068, #449387).
+ + Added libmp3lame-dev to weak-build-deps in DEB_BUILD_OPTIONS=risky.
+ + Added support for amrnb, amrwb and x264 (Closes: #432170) in
+ DEB_BUILD_OPTIONS=risky.
+
+ [ Reinhard Tartler ]
+ * added Fabian Greffrath to Uploaders
+
+ -- Reinhard Tartler Thu, 20 Mar 2008 15:55:11 +0100
+
+ffmpeg-free (0.cvs20071007-3) experimental; urgency=low
+
+ * disable armv6 code generation. Thanks to Joey Hess for the patch
+ (Closes: #438923).
+
+ -- Reinhard Tartler Sun, 13 Jan 2008 23:28:25 +0100
+
+ffmpeg-free (0.cvs20071007-2) experimental; urgency=low
+
+ * restore soname on libavutil. got dropped on previous upload.
+ * Bug fix: "needs libavutil-dev headers but doesn't depend on it",
+ thanks to rmh@aybabtu.com (Closes: #434494). This was actually already
+ fixed in a previous upload.
+ * build dependencies in debian/control are now multiline.
+ * Drop the XS- from the Vcs-Browser and Vcs-Svn field.
+
+ -- Reinhard Tartler Sun, 16 Dec 2007 21:36:49 +0100
+
+ffmpeg-free (0.cvs20071007-1) experimental; urgency=low
+
+ * new upstream snapshot, using the same day as the mplayer release
+ * Refreshing patches:
+ -005_altivec_flags.diff: dropped, merged upstream
+ -005_m68k_workaround.diff: refreshed
+ -005_runtime_cpudetect.diff: refreshed
+ -006_mips_pthreads.diff: refreshed
+ -010_proper_rpath.diff: refreshed
+ -010_shared_library_versioning.diff: refreshed
+ -011_link_plugins.diff: refreshed (moved to top level makefile)
+ -015_build_imgresample.diff: refreshed
+ -020_disable_snow_mmx_in_pic.diff: refreshed
+ -020_fix_libswscale_pic_code.diff: refreshed
+ -020_mmx_optims.diff: refreshed
+ -020_mmx_pic_code.diff: refreshed
+ -040_early_altivec_detection.diff: disabled, doesn't apply anymore
+ -040_only_use_maltivec_when_needed.diff disabled, (causes ftbfs, needs revising)
+ -040_only_use_maltivec_when_needed.diff: refresh
+ -051_mjpeg_gray_support.diff, removed applied upstream
+ -053_rm_demux_crash.diff removed, applied upstream.
+ -060_fix_avi_skip.diff removed, does not apply anymore
+ * remove --enable-libdts. ffmpeg now has an internal dts decoder since
+ r9051 (2007-05-17). It seems that at least some packages link to libdts and
+ rely on the transitive dependency via ffmpeg. Please add explicit dependencies
+ on libdts instead!
+ * Don't ignore errors in upstream Makefile. Bug found via lintian.
+
+ -- Reinhard Tartler Wed, 05 Dec 2007 17:33:34 +0100
+
+ffmpeg-free (0.cvs20070307-7) UNRELEASED; urgency=low
+
+ * debian/patches/051_mjpeg_gray_support.diff:
+ + Support grayscale MJPEG streams as sent by Axis cameras.
+
+ -- Sam Hocevar (Debian packages) Tue, 31 Jul 2007 18:55:31 +0200
+
+ffmpeg-free (0.cvs20070307-6) unstable; urgency=low
+
+ * Rename the source package. We are (again) no longer shipping the
+ 'real' upstream source of ffmpeg.
+ * Add debian/strip.sh to strip ffmpeg upstream source disabling mpeg
+ based encoders as discussed with ftp-master at debconf7
+ * update XS-Vcs tags in debian/control.
+ * make ffmpeg binNMU-able by using ${binary:Version} rather than
+ ${Source-Version}
+
+ -- Reinhard Tartler Sat, 23 Jun 2007 15:11:21 +0100
+
+ffmpeg (0.cvs20070307-5) unstable; urgency=low
+
+ * upload to unstable
+ * remove x264 support, as it has been removed from unstable
+
+ -- Reinhard Tartler Wed, 30 May 2007 15:19:20 +0200
+
+ffmpeg (0.cvs20070307-4) experimental; urgency=low
+
+ * added myself to uploaders
+
+ * 020_fix_libswscale_pic_code:
+ + added, avoid some MMX code to avoid PIC code
+
+ [ Sam Hocevar ]
+
+ * fixed path in library installation.
+
+ -- Reinhard Tartler Wed, 11 Apr 2007 23:17:47 +0200
+
+ffmpeg (0.cvs20070307-3) experimental; urgency=low
+
+ * debian/patches/015_build_imgresample.diff:
+ + Build imgresample functions even with swscaler activated, or legacy
+ applications will stop working.
+
+ * debian/patches/053_rm_demux_crash.diff:
+ + New patch: fix a double free with corrupted rm files (Closes: #379922).
+
+ * debian/patches/054_h264_mmx_chroma_mc_crash.diff:
+ + New patch: workaround for a buffer overflow in the MMX H264 chroma
+ motion compensation until upstream fixes it properly (Closes: #404176).
+
+ * debian/patches/300_c++_compliant_headers.diff:
+ + Define INT64_C() when the system headers don't provide it, for instance
+ when building C++ code.
+
+ * debian/control:
+ + Set pkg-multimedia-maintainers as main maintainer.
+ + Updated VCS fields.
+ * debian/rules:
+ + Huge cleanup.
+
+ -- Sam Hocevar (Debian packages) Wed, 14 Mar 2007 19:40:42 +0100
+
+ffmpeg (0.cvs20070307-2) experimental; urgency=low
+
+ * debian/rules:
+ + Activate x264 support now that it is in unstable.
+ * debian/control:
+ + Build-depend on libx264-dev.
+
+ -- Sam Hocevar (Debian packages) Mon, 12 Mar 2007 21:10:45 +0100
+
+ffmpeg (0.cvs20070307-1) experimental; urgency=low
+
+ [ Sam Hocevar ]
+
+ * New upstream snapshot (Closes: #403330, #404788).
+ * This snapshot fixes numerous file parsing crashes (Closes: #404176,
+ Closes: #407003, #396282, #365006, #403398).
+
+ * debian/patches/010_proper_rpath.diff:
+ + New patch. Link objects with the libraries that we generate, not the
+ ones installed on the system.
+
+ * debian/patches/010_shared_library_versioning.diff:
+ + Strip unneeded prefix from .pc files (Closes: #404758).
+
+ * debian/patches/011_link_plugins.diff:
+ + New patch. Link vhook plugins with the appropriate libraries.
+
+ * debian/patches/013_strip_unneeded_linker_flags.diff:
+ + Remove unneeded -l flags from .pc files (Closes: #373986).
+
+ * debian/patches/020_mmx_optims.diff:
+ * debian/patches/020_disable_snow_mmx_in_pic.diff:
+ + Sync patches.
+
+ * debian/patches/020_really_use_liba52.diff:
+ * debian/patches/050_h264-misc-security-fixes.diff:
+ * debian/patches/051_asf-misc-security-fixes.diff:
+ + Drop patches, applied upstream or no longer relevant.
+
+ * debian/patches/040_only_use_maltivec_when_needed.diff:
+ + Upgraded patch to cover libswscale.
+
+ * debian/libavcodec-dev.install:
+ + Ship lzo.h and random.h.
+
+ * debian/rules:
+ + Fix syntax for a few --enable flags.
+ + Only ship ffmpeg_powerpc_performance_evaluation_howto.txt.gz on
+ powerpc machines (Closes: #385079).
+ + Readded --enable-libtheora, it's here again.
+ + Activate --enable-swscaler (Closes: #399141, #398442).
+
+ [ Reinhard Tartler ]
+
+ * debian/rules:
+ + Ignore libswscale.pc and rgb2rgb.h.
+
+ * debian/libavcodec-dev.install:
+ + Ship fifo.h and opt.h.
+
+ * debian/patches/005_altivec_flags.diff:
+ * debian/patches/005_m68k_workaround.diff:
+ * debian/patches/005_runtime_cpudetect.diff:
+ * debian/patches/006_mips_pthreads.diff:
+ * debian/patches/020_really_use_liba52.diff:
+ + Sync patches.
+
+ * debian/patches/007_disable_ffmpeg_option.diff:
+ * debian/patches/030_arm_cpu_detect.diff:
+ * debian/patches/030_arm_workaround.diff:
+ + Drop patches, applied upstream or no longer relevant.
+
+ -- Sam Hocevar (Debian packages) Fri, 9 Mar 2007 15:13:16 +0100
+
+ffmpeg (0.cvs20060823-7) unstable; urgency=high
+
+ * debian/patches/040_only_use_maltivec_when_needed.diff:
+ + Fix a static function prototype that prevented programs using libpostproc
+ from working on PowerPC (Closes: #412214).
+
+ * debian/control:
+ + Added Xs-Vcs-Browser and XS-Vcs-Svn fields.
+
+ -- Sam Hocevar (Debian packages) Thu, 8 Mar 2007 17:51:37 +0100
+
+ffmpeg (0.cvs20060823-6) unstable; urgency=high
+
+ * Upload to unstable.
+
+ -- Loic Minier Thu, 1 Feb 2007 21:36:47 +0100
+
+ffmpeg (0.cvs20060823-5) testing-proposed-updates; urgency=high
+
+ [ Loïc Minier ]
+ * Add myself to Uploaders.
+ * Exclude firewire libs from ffmpeg-config under kFreeBSD; based on a patch
+ by Petr Salinger; closes: #399701.
+ * Fix handling of debug in DEB_BUILD_OPTIONS; thanks Andreas Henriksson;
+ closes: #406474.
+ * SECURITY: New patch, 050_h264-misc-security-fixes, to properly check the
+ sps and pps ids before use and to check more bitstram values and fix
+ potential security holes; from upstream SVN r7585, r7586, and r7591.
+ * SECURITY: New patch, 051_asf-misc-security-fixes, to properly check
+ packet sizes, chunk sizes, and fragment positions; from upstream SVN r7640
+ and r7650.
+
+ [ Sam Hocevar ]
+ * debian/copyright:
+ + Fix typo and clarify licensing terms (Closes: #398235).
+ * debian/README.Debian:
+ + Removed mention of ffmpeg-config now that we ship .pc files.
+ * debian/patches/020_mmx_optims.diff:
+ + New patch, fix FTBFS with DEB_BUILD_OPTIONS=debug.
+ * debian/patches/040_early_altivec_detection.diff:
+ + New patch, detect AltiVec earlier on and only once so that we don't
+ risk using signal handlers in a multithreaded environment or when
+ the caller already installed a SIGILL handler.
+ * debian/patches/040_only_use_maltivec_when_needed.diff:
+ + New patch, only use -maltivec with files that use AltiVec intrinsics,
+ and make sure no codepath leads to these files on a non-AltiVec
+ machine (Closes: #405926).
+ * debian/patches/060_fix_avi_skip.diff:
+ + New patch, courtesy of Ben Hutchings: do not attempt to skip the ODML
+ if the current seek offset is already beyond it (Closes: #383734).
+
+ -- Sam Hocevar (Debian packages) Mon, 29 Jan 2007 16:58:44 +0100
+
+ffmpeg (0.cvs20060823-4) unstable; urgency=high
+
+ * Maintainer upload.
+ * Acknowledging NMU (Closes: #386458).
+
+ * High urgency because of FTBFS fix.
+
+ * debian/patches/030_arm_workaround.diff:
+ + New patch courtesy of Aurélien Jarno: disable the broken ARM assembly
+ code in libavcodec/mpegaudiodec.c.
+
+ * debian/patches/030_arm_cpu_detect.diff:
+ + New patch courtesy of Aurélien Jarno: correctly detect the newer ARM
+ CPUs.
+
+ -- Sam Hocevar (Debian packages) Sun, 24 Sep 2006 23:38:29 +0200
+
+ffmpeg (0.cvs20060823-3.1) unstable; urgency=medium
+
+ * Non-maintainer upload.
+ * Fix variable substitution trick in debian/rules (Closes: #386458).
+
+ -- Luk Claes Fri, 15 Sep 2006 21:29:07 +0200
+
+ffmpeg (0.cvs20060823-3) unstable; urgency=low
+
+ * debian/rules:
+ + Take local packages into account when computing shlibs dependencies, so
+ that ffplay/ffserver depend on the proper libraries (Closes: #386029).
+
+ -- Sam Hocevar (Debian packages) Tue, 5 Sep 2006 17:44:00 +0200
+
+ffmpeg (0.cvs20060823-2) unstable; urgency=low
+
+ * debian/patches/020_really_use_liba52.diff:
+ + New patch: link with the shared liba52 instead of the built-in one.
+
+ * debian/patches/006_mips_pthreads.diff:
+ + New patch: link libraries with -lpthreads on Linux MIPS because of a
+ known ld bug.
+
+ * debian/patches/007_disable_ffmpeg_option.diff:
+ + New patch: add a --disable-ffmpeg option.
+
+ -- Sam Hocevar (Debian packages) Wed, 30 Aug 2006 18:36:52 +0200
+
+ffmpeg (0.cvs20060823-1) unstable; urgency=low
+
+ * New SVN snapshot (Closes: #368904).
+ * debian/control:
+ + Set policy to 3.7.2.
+ + Do not build 1394 support on GNU/kFreeBSD or Hurd. Patch courtesy of
+ Petr Salinger (Closes: #372290).
+ * debian/rules:
+ + Minor cleanup.
+ + Removed --enable-theora, upstream dropped that option.
+
+ * debian/patches/020_mmx_intrinsics.diff:
+ + Disabled intrinsics workaround because it is no longer necessary and it
+ causes trouble with some codecs such as H264 (Closes: #373765).
+
+ -- Sam Hocevar (Debian packages) Wed, 23 Aug 2006 12:09:58 +0200
+
+ffmpeg (0.cvs20060329-4) unstable; urgency=low
+
+ * debian/control:
+ + Make each -dev package depend on the corresponding shared library
+ package (Closes: #361348).
+ + Moved libavutil files from libavformat-dev to libavcodec-dev which is
+ the real common dependency (Closes: #361269).
+
+ -- Sam Hocevar (Debian packages) Sun, 9 Apr 2006 15:23:37 +0200
+
+ffmpeg (0.cvs20060329-3) unstable; urgency=low
+
+ * debian/rules: that build system is hopeless. We now run configure and
+ make twice, backup static libraries inbetween, then update timestamps
+ to fool make. That should fix the FTBFS (Closes: #361215).
+
+ -- Sam Hocevar (Debian packages) Fri, 7 Apr 2006 11:33:15 +0200
+
+ffmpeg (0.cvs20060329-2) unstable; urgency=low
+
+ * debian/rules: fixed Makefile.pic generation.
+
+ -- Sam Hocevar (Debian packages) Thu, 6 Apr 2006 16:37:05 +0200
+
+ffmpeg (0.cvs20060329-1) unstable; urgency=low
+
+ * New CVS snapshot.
+ * Upstream fixed a double free in img.c (Closes: #351455).
+ * Upstream fixed the libvorbisenc dependency in libavcodec.pc
+ (Closes: #357352).
+
+ * debian/rules:
+ + Activated threading support (Closes: #335677).
+ + Manually reinstall dsputil.h.
+
+ * debian/README.Debian:
+ + Removed mention of --plugin-libs.
+ + Added a note about the unofficial packages (Closes: #306752).
+
+ * 020_disable_snow_mmx_in_pic.diff: (new patch) disable MMX acceleration in
+ the Snow encoder in PIC mode.
+
+ -- Sam Hocevar (Debian packages) Thu, 30 Mar 2006 10:41:17 +0200
+
+ffmpeg (0.cvs20060306-3) unstable; urgency=low
+
+ * Switched patch system to quilt.
+ * debian/control:
+ + Build-depend on quilt.
+
+ * 005_altivec_flags.diff: (new patch from old diff.gz) proper gcc flags to
+ only generate AltiVec code when explicitely asked.
+
+ * 005_m68k_workaround.diff: (new patch from old diff.gz) use -O2 instead of
+ -O3 on m68k.
+
+ * 005_runtime_cpudetect.diff: (new patch from old diff.gz) fix runtime CPU
+ detection on m68k and x86.
+
+ * 010_ffmpeg-config.diff: (new patch from old diff.gz) the ffmpeg-config
+ script and associated manpage (legacy).
+
+ * 010_shared_library_versioning.diff: (new patch from old diff.gz) use a
+ Debian-specific scheme for shared library versioning to avoid spreading
+ libraries incompatible with every other version.
+
+ * 020_mmx_intrinsics.diff: (new patch from old diff.gz) use MMX intrinsics
+ in dsputil_mmx.c because gcc is unable to compute some register constraints
+ in PIC mode.
+
+ * 020_mmx_pic_code.diff: (new patch from old diff.gz) ported some MMX code
+ to be PIC.
+
+ -- Sam Hocevar (Debian packages) Wed, 29 Mar 2006 18:53:35 +0200
+
+ffmpeg (0.cvs20060306-2) unstable; urgency=low
+
+ * ffmpeg-config.in: removed references to _pic libraries.
+
+ -- Sam Hocevar (Debian packages) Fri, 17 Mar 2006 20:08:29 +0100
+
+ffmpeg (0.cvs20060306-1) unstable; urgency=low
+
+ * New CVS snapshot.
+ * Upstream now properly installs dsputil.h (Closes: #354391).
+ * debian/control:
+ + Distribute shared versions of the libraries with a Debian-specific
+ soname.
+ * debian/rules:
+ + Removed all custom PIC rules.
+ + Moved ffmpeg-config to libavformat-dev instead of libavcodec-dev so that
+ it is present by default (Closes: #350750).
+ + Include apiexample.c in libavcodec-dev (Closes: #350027).
+
+ -- Sam Hocevar (Debian packages) Mon, 6 Mar 2006 11:05:26 +0100
+
+ffmpeg (0.cvs20050918-6) unstable; urgency=low
+
+ * Developer upload.
+ * Acknowledge NMU. Thanks to Samuel Mimram (Closes: #342207).
+ * configure:
+ + Set RUNTIME_CPUDETECT (except on m68k where it ICEs and on x86 where it
+ fails to build some asm constructs) (Closes: #337846).
+ * debian/rules:
+ + Make the build process aware of DEB_BUILD_OPTIONS, thanks to Timo
+ Lindfors (Closes: #338895).
+
+ -- Sam Hocevar (Debian packages) Sat, 21 Jan 2006 16:51:26 +0100
+
+ffmpeg (0.cvs20050918-5.1) unstable; urgency=low
+
+ * NMU.
+ * Fix exploitable heap overflow in libavcodec's handling of images with
+ PIX_FMT_PAL8 pixel formats (CVE-2005-4048), closes: #342207.
+
+ -- Samuel Mimram Sun, 15 Jan 2006 14:44:36 +0100
+
+ffmpeg (0.cvs20050918-5) unstable; urgency=low
+
+ * ffmpeg-config.1: fixed the examples and added a note that static libraries
+ should be put after the objects that refer to them (Closes: #339803).
+
+ -- Sam Hocevar (Debian packages) Fri, 18 Nov 2005 23:58:16 +0100
+
+ffmpeg (0.cvs20050918-4) unstable; urgency=low
+
+ * configure:
+ + Tell the configure script about m68k, ia64 and others.
+
+ -- Sam Hocevar (Debian packages) Thu, 22 Sep 2005 14:43:59 +0200
+
+ffmpeg (0.cvs20050918-3) unstable; urgency=low
+
+ * configure:
+ + Use -O2 instead of -O3 on m68k to avoid ICEs.
+
+ -- Sam Hocevar (Debian packages) Tue, 20 Sep 2005 17:33:14 +0200
+
+ffmpeg (0.cvs20050918-2) unstable; urgency=low
+
+ * libavcodec/i386/dsputil_mmx.c:
+ + Reworked the MMX intrinsics.
+ * tests/libav.regression.ref:
+ + Minor cosmetic fix to use double-digit numbers in test sequences.
+ * debian/control:
+ + PowerPC no longer needs to use gcc-3.4, since 4.x is the default.
+ * libavcodec/Makefile:
+ + Removed special compilation case for HPPA now that we use 4.x.
+
+ -- Sam Hocevar (Debian packages) Sun, 18 Sep 2005 17:43:48 +0200
+
+ffmpeg (0.cvs20050918-1) unstable; urgency=low
+
+ * New CVS snapshot.
+ * Upstream applied most Debian patches.
+ * configure:
+ + Do not use -mabi=altivec (-maltivec is enough for our AltiVec code) so
+ that our code still runs on a G3 computer (Closes: #319151).
+ * debian/rules:
+ + When not cross-compiling, run the regression tests (Closes: #292102).
+ * debian/changelog:
+ + Updated the FSF address.
+ * ffmpeg-config.in:
+ + Fixed avcodec linkage (Closes: #328505).
+ * libavcodec/i386/mpegvideo_mmx_template.c:
+ + Applied patch from Tobias Grimm to fix the PIC MMX code for MPEG
+ encoding (Closes: #318493).
+ * libavcodec/i386/dsputil_mmx.c:
+ + Applied patch from Joshua Kwan to fix the AMD64 build (Closes: #324026).
+ + Reworked that patch so that it still compiles on x86.
+
+ -- Sam Hocevar (Debian packages) Fri, 16 Sep 2005 13:03:47 +0200
+
+ffmpeg (0.cvs20050811-2) unstable; urgency=low
+
+ * ffmpeg-config.in: added a missing -lgsm.
+
+ -- Sam Hocevar (Debian packages) Mon, 22 Aug 2005 19:51:53 +0200
+
+ffmpeg (0.cvs20050811-1) unstable; urgency=low
+
+ * New CVS snapshot.
+ * Upstream fixed an integer overflow in the MPEG encoder (Closes: #320150).
+ * debian/rules:
+ + Activated libgsm support.
+ + Fixed theora support.
+ + Switched installation method to dh_install.
+ * Applied patch from Christian Aichinger and others to fix the clobbering
+ of the %ebx register during build (Closes: #319563).
+
+ -- Sam Hocevar (Debian packages) Thu, 11 Aug 2005 14:22:03 +0200
+
+ffmpeg (0.cvs20050626-2) unstable; urgency=low
+
+ * ffmpeg-config.in: fixed the theora link that caused FTBFS.
+
+ -- Sam Hocevar (Debian packages) Fri, 1 Jul 2005 17:20:59 +0200
+
+ffmpeg (0.cvs20050626-1) unstable; urgency=low
+
+ * New CVS snapshot.
+ * debian/control:
+ + Set policy to 3.6.2.1.
+ * debian/rules:
+ + Fixed Vorbis support (Closes: #306023).
+ + Patch by Jonas Smedegaard : conditionally enable these
+ unofficial libraries if DEB_BUILD_OPTIONS includes "risky":
+ o Mpeg2 layer 3 / MP3 (liblame-dev).
+ o FAAD (libfaad2-dev).
+ o FAAC (libfaac-dev).
+ o XviD (libxvidcore-dev).
+ + Activated theora support.
+ + Activated IEEE 1394 support (Closes: #296737).
+
+ -- Sam Hocevar (Debian packages) Sun, 26 Jun 2005 15:46:54 +0200
+
+ffmpeg (0.cvs20050313-2) unstable; urgency=low
+
+ * libavcodec/libpostproc/postprocess_template.c
+ libavcodec/i386/mpegvideo_mmx_template.c: fixed my PIC MMX code (Closes: #299700).
+ * debian/rules: use gcc-3.4 on PowerPC (Closes: #300686).
+
+ -- Sam Hocevar (Debian packages) Mon, 21 Mar 2005 23:38:46 +0100
+
+ffmpeg (0.cvs20050313-1) unstable; urgency=low
+
+ * New CVS snapshot.
+ * configure: fixed the builtin vector test (Closes: #293284), thanks
+ to Jacob L. Anawalt.
+ * libavcodec/libpostproc/postprocess_template.c
+ libavcodec/i386/mpegvideo_mmx_template.c: fixed MMX code so that it can
+ be compiled in PIC mode, and reactivated MMX (Closes: #290447, #290358).
+
+ -- Sam Hocevar (Debian packages) Sat, 12 Mar 2005 18:34:29 +0100
+
+ffmpeg (0.cvs20050121-1) unstable; urgency=low
+
+ * New CVS snapshot.
+ * This snapshot fixes integer overflows that may lead to arbitrary code
+ execution (Closes: #291566).
+
+ -- Sam Hocevar (Debian packages) Fri, 21 Jan 2005 17:41:47 +0100
+
+ffmpeg (0.cvs20050108-1) unstable; urgency=low
+
+ * Re-done tarball snapshot so that it does not contain binaries.
+ * ffmpeg-config.in:
+ + Added missing -lvorbisenc (Closes: #289030).
+ * debian/rules:
+ + Install missing headers that are not in the install rule: bwswap.h,
+ dsputil.h, os_support.h (Closes: #289033).
+
+ -- Sam Hocevar (Debian packages) Sat, 8 Jan 2005 11:30:58 +0100
+
+ffmpeg (0.cvs20050106-1) unstable; urgency=low
+
+ * New upstream snapshot.
+ * The extern/static declaration conflict was fixed upstream (Closes: #288906).
+
+ -- Sam Hocevar (Debian packages) Thu, 6 Jan 2005 15:44:49 +0100
+
+ffmpeg (0.cvs20040716-2) unstable; urgency=low
+
+ * debian/rules:
+ + Include missing rtp.h / rtsp.h in libavformat-dev.
+ * ffmpeg-config.in:
+ + Added -lz to the libavcodec linking flags.
+ + Added -ldts / -ldts_pic, -la52, -lvorbis to the libavcodec linking flags.
+
+ -- Sam Hocevar (Debian packages) Tue, 17 Aug 2004 13:27:41 +0200
+
+ffmpeg (0.cvs20040716-1) unstable; urgency=low
+
+ * Initial release (Closes: #199266).
+
+ -- Sam Hocevar (Debian packages) Fri, 16 Jul 2004 12:47:27 +0200
+
--- ffmpeg-0.6.orig/debian/libavcodec-dev.install
+++ ffmpeg-0.6/debian/libavcodec-dev.install
@@ -0,0 +1,4 @@
+usr/include/libavcodec
+usr/lib/libavcodec.a
+usr/lib/{,*/,*/*/}libavcodec.so
+usr/lib/pkgconfig/libavcodec.pc
--- ffmpeg-0.6.orig/debian/patches/series
+++ ffmpeg-0.6/debian/patches/series
@@ -0,0 +1,4 @@
+0001-Add-VP80-fourcc.patch
+0002-Tweak-doxygen-config.patch
+0003-Backport-AAC-HE-v2.patch
+fix-CVE-2010-3429.patch
--- ffmpeg-0.6.orig/debian/patches/0001-Add-VP80-fourcc.patch
+++ ffmpeg-0.6/debian/patches/0001-Add-VP80-fourcc.patch
@@ -0,0 +1,24 @@
+From: Reinhard Tartler
+Date: Mon, 28 Jun 2010 23:12:40 +0200
+Subject: [PATCH] Add VP80 fourcc
+
+Patch by Google
+
+backport r23193 by conrad
+---
+ libavformat/riff.c | 1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
+diff --git a/libavformat/riff.c b/libavformat/riff.c
+index 04b7108..64464ca 100644
+--- a/libavformat/riff.c
++++ b/libavformat/riff.c
+@@ -183,6 +183,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
+ { CODEC_ID_VP6, MKTAG('V', 'P', '6', '2') },
+ { CODEC_ID_VP6F, MKTAG('V', 'P', '6', 'F') },
+ { CODEC_ID_VP6F, MKTAG('F', 'L', 'V', '4') },
++ { CODEC_ID_VP8, MKTAG('V', 'P', '8', '0') },
+ { CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') },
+ { CODEC_ID_ASV2, MKTAG('A', 'S', 'V', '2') },
+ { CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') },
+--
--- ffmpeg-0.6.orig/debian/patches/fix-CVE-2010-3429.patch
+++ ffmpeg-0.6/debian/patches/fix-CVE-2010-3429.patch
@@ -0,0 +1,101 @@
+From: michael
+Subject: Fix several security issues in flicvideo.c
+
+This fixes CVE-2010-3429
+
+backport r25223 by michael
+
+--- a/libavcodec/flicvideo.c
++++ b/libavcodec/flicvideo.c
+@@ -159,7 +159,7 @@ static int flic_decode_frame_8BPP(AVCode
+ int pixel_skip;
+ int pixel_countdown;
+ unsigned char *pixels;
+- int pixel_limit;
++ unsigned int pixel_limit;
+
+ s->frame.reference = 1;
+ s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
+@@ -253,10 +253,13 @@ static int flic_decode_frame_8BPP(AVCode
+ av_log(avctx, AV_LOG_ERROR, "Undefined opcode (%x) in DELTA_FLI\n", line_packets);
+ } else if ((line_packets & 0xC000) == 0x8000) {
+ // "last byte" opcode
+- pixels[y_ptr + s->frame.linesize[0] - 1] = line_packets & 0xff;
++ pixel_ptr= y_ptr + s->frame.linesize[0] - 1;
++ CHECK_PIXEL_PTR(0);
++ pixels[pixel_ptr] = line_packets & 0xff;
+ } else {
+ compressed_lines--;
+ pixel_ptr = y_ptr;
++ CHECK_PIXEL_PTR(0);
+ pixel_countdown = s->avctx->width;
+ for (i = 0; i < line_packets; i++) {
+ /* account for the skip bytes */
+@@ -268,7 +271,7 @@ static int flic_decode_frame_8BPP(AVCode
+ byte_run = -byte_run;
+ palette_idx1 = buf[stream_ptr++];
+ palette_idx2 = buf[stream_ptr++];
+- CHECK_PIXEL_PTR(byte_run);
++ CHECK_PIXEL_PTR(byte_run * 2);
+ for (j = 0; j < byte_run; j++, pixel_countdown -= 2) {
+ pixels[pixel_ptr++] = palette_idx1;
+ pixels[pixel_ptr++] = palette_idx2;
+@@ -298,6 +301,7 @@ static int flic_decode_frame_8BPP(AVCode
+ stream_ptr += 2;
+ while (compressed_lines > 0) {
+ pixel_ptr = y_ptr;
++ CHECK_PIXEL_PTR(0);
+ pixel_countdown = s->avctx->width;
+ line_packets = buf[stream_ptr++];
+ if (line_packets > 0) {
+@@ -453,7 +457,7 @@ static int flic_decode_frame_15_16BPP(AV
+ int pixel_countdown;
+ unsigned char *pixels;
+ int pixel;
+- int pixel_limit;
++ unsigned int pixel_limit;
+
+ s->frame.reference = 1;
+ s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
+@@ -503,6 +507,7 @@ static int flic_decode_frame_15_16BPP(AV
+ } else {
+ compressed_lines--;
+ pixel_ptr = y_ptr;
++ CHECK_PIXEL_PTR(0);
+ pixel_countdown = s->avctx->width;
+ for (i = 0; i < line_packets; i++) {
+ /* account for the skip bytes */
+@@ -514,13 +519,13 @@ static int flic_decode_frame_15_16BPP(AV
+ byte_run = -byte_run;
+ pixel = AV_RL16(&buf[stream_ptr]);
+ stream_ptr += 2;
+- CHECK_PIXEL_PTR(byte_run);
++ CHECK_PIXEL_PTR(2 * byte_run);
+ for (j = 0; j < byte_run; j++, pixel_countdown -= 2) {
+ *((signed short*)(&pixels[pixel_ptr])) = pixel;
+ pixel_ptr += 2;
+ }
+ } else {
+- CHECK_PIXEL_PTR(byte_run);
++ CHECK_PIXEL_PTR(2 * byte_run);
+ for (j = 0; j < byte_run; j++, pixel_countdown--) {
+ *((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[stream_ptr]);
+ stream_ptr += 2;
+@@ -611,7 +616,7 @@ static int flic_decode_frame_15_16BPP(AV
+ if (byte_run > 0) {
+ pixel = AV_RL16(&buf[stream_ptr]);
+ stream_ptr += 2;
+- CHECK_PIXEL_PTR(byte_run);
++ CHECK_PIXEL_PTR(2 * byte_run);
+ for (j = 0; j < byte_run; j++) {
+ *((signed short*)(&pixels[pixel_ptr])) = pixel;
+ pixel_ptr += 2;
+@@ -622,7 +627,7 @@ static int flic_decode_frame_15_16BPP(AV
+ }
+ } else { /* copy pixels if byte_run < 0 */
+ byte_run = -byte_run;
+- CHECK_PIXEL_PTR(byte_run);
++ CHECK_PIXEL_PTR(2 * byte_run);
+ for (j = 0; j < byte_run; j++) {
+ *((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[stream_ptr]);
+ stream_ptr += 2;
--- ffmpeg-0.6.orig/debian/patches/0002-Tweak-doxygen-config.patch
+++ ffmpeg-0.6/debian/patches/0002-Tweak-doxygen-config.patch
@@ -0,0 +1,23 @@
+From: Reinhard Tartler
+Date: Mon, 28 Jun 2010 22:43:55 +0200
+Subject: [PATCH] Tweak doxygen config
+
+exclude some directories we use for packaging from doxygen documentation
+---
+ Doxyfile | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/Doxyfile b/Doxyfile
+index ee233b9..1251d34 100644
+--- a/Doxyfile
++++ b/Doxyfile
+@@ -359,7 +359,7 @@ RECURSIVE = YES
+ # excluded from the INPUT source files. This way you can easily exclude a
+ # subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+-EXCLUDE =
++EXCLUDE = debian debian-shared debian-static debian-cmov .pc .git
+
+ # The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
+ # that are symbolic links (a Unix filesystem feature) are excluded from the input.
+--
--- ffmpeg-0.6.orig/debian/patches/0003-Backport-AAC-HE-v2.patch
+++ ffmpeg-0.6/debian/patches/0003-Backport-AAC-HE-v2.patch
@@ -0,0 +1,6774 @@
+From: Reinhard Tartler
+Subject: [PATCH] Backport AAC-HE-v2
+
+merge all revision that are related for aac encoder and decoder from trunk
+
+this patch is under consideration for the upcoming 0.6.1 release
+
+--- a/libavcodec/aac.c
++++ /dev/null
+@@ -1,2108 +0,0 @@
+-/*
+- * AAC decoder
+- * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
+- * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com )
+- *
+- * This file is part of FFmpeg.
+- *
+- * FFmpeg is free software; you can redistribute it and/or
+- * modify it under the terms of the GNU Lesser General Public
+- * License as published by the Free Software Foundation; either
+- * version 2.1 of the License, or (at your option) any later version.
+- *
+- * FFmpeg 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
+- * Lesser General Public License for more details.
+- *
+- * You should have received a copy of the GNU Lesser General Public
+- * License along with FFmpeg; if not, write to the Free Software
+- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+- */
+-
+-/**
+- * @file
+- * AAC decoder
+- * @author Oded Shimon ( ods15 ods15 dyndns org )
+- * @author Maxim Gavrilov ( maxim.gavrilov gmail com )
+- */
+-
+-/*
+- * supported tools
+- *
+- * Support? Name
+- * N (code in SoC repo) gain control
+- * Y block switching
+- * Y window shapes - standard
+- * N window shapes - Low Delay
+- * Y filterbank - standard
+- * N (code in SoC repo) filterbank - Scalable Sample Rate
+- * Y Temporal Noise Shaping
+- * N (code in SoC repo) Long Term Prediction
+- * Y intensity stereo
+- * Y channel coupling
+- * Y frequency domain prediction
+- * Y Perceptual Noise Substitution
+- * Y Mid/Side stereo
+- * N Scalable Inverse AAC Quantization
+- * N Frequency Selective Switch
+- * N upsampling filter
+- * Y quantization & coding - AAC
+- * N quantization & coding - TwinVQ
+- * N quantization & coding - BSAC
+- * N AAC Error Resilience tools
+- * N Error Resilience payload syntax
+- * N Error Protection tool
+- * N CELP
+- * N Silence Compression
+- * N HVXC
+- * N HVXC 4kbits/s VR
+- * N Structured Audio tools
+- * N Structured Audio Sample Bank Format
+- * N MIDI
+- * N Harmonic and Individual Lines plus Noise
+- * N Text-To-Speech Interface
+- * Y Spectral Band Replication
+- * Y (not in this code) Layer-1
+- * Y (not in this code) Layer-2
+- * Y (not in this code) Layer-3
+- * N SinuSoidal Coding (Transient, Sinusoid, Noise)
+- * N (planned) Parametric Stereo
+- * N Direct Stream Transfer
+- *
+- * Note: - HE AAC v1 comprises LC AAC with Spectral Band Replication.
+- * - HE AAC v2 comprises LC AAC with Spectral Band Replication and
+- Parametric Stereo.
+- */
+-
+-
+-#include "avcodec.h"
+-#include "internal.h"
+-#include "get_bits.h"
+-#include "dsputil.h"
+-#include "fft.h"
+-#include "lpc.h"
+-
+-#include "aac.h"
+-#include "aactab.h"
+-#include "aacdectab.h"
+-#include "cbrt_tablegen.h"
+-#include "sbr.h"
+-#include "aacsbr.h"
+-#include "mpeg4audio.h"
+-#include "aac_parser.h"
+-
+-#include
+-#include
+-#include
+-#include
+-
+-#if ARCH_ARM
+-# include "arm/aac.h"
+-#endif
+-
+-union float754 {
+- float f;
+- uint32_t i;
+-};
+-
+-static VLC vlc_scalefactors;
+-static VLC vlc_spectral[11];
+-
+-static const char overread_err[] = "Input buffer exhausted before END element found\n";
+-
+-static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
+-{
+- if (ac->tag_che_map[type][elem_id]) {
+- return ac->tag_che_map[type][elem_id];
+- }
+- if (ac->tags_mapped >= tags_per_config[ac->m4ac.chan_config]) {
+- return NULL;
+- }
+- switch (ac->m4ac.chan_config) {
+- case 7:
+- if (ac->tags_mapped == 3 && type == TYPE_CPE) {
+- ac->tags_mapped++;
+- return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2];
+- }
+- case 6:
+- /* Some streams incorrectly code 5.1 audio as SCE[0] CPE[0] CPE[1] SCE[1]
+- instead of SCE[0] CPE[0] CPE[0] LFE[0]. If we seem to have
+- encountered such a stream, transfer the LFE[0] element to SCE[1] */
+- if (ac->tags_mapped == tags_per_config[ac->m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) {
+- ac->tags_mapped++;
+- return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0];
+- }
+- case 5:
+- if (ac->tags_mapped == 2 && type == TYPE_CPE) {
+- ac->tags_mapped++;
+- return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1];
+- }
+- case 4:
+- if (ac->tags_mapped == 2 && ac->m4ac.chan_config == 4 && type == TYPE_SCE) {
+- ac->tags_mapped++;
+- return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
+- }
+- case 3:
+- case 2:
+- if (ac->tags_mapped == (ac->m4ac.chan_config != 2) && type == TYPE_CPE) {
+- ac->tags_mapped++;
+- return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0];
+- } else if (ac->m4ac.chan_config == 2) {
+- return NULL;
+- }
+- case 1:
+- if (!ac->tags_mapped && type == TYPE_SCE) {
+- ac->tags_mapped++;
+- return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][0];
+- }
+- default:
+- return NULL;
+- }
+-}
+-
+-/**
+- * Check for the channel element in the current channel position configuration.
+- * If it exists, make sure the appropriate element is allocated and map the
+- * channel order to match the internal FFmpeg channel layout.
+- *
+- * @param che_pos current channel position configuration
+- * @param type channel element type
+- * @param id channel element id
+- * @param channels count of the number of channels in the configuration
+- *
+- * @return Returns error status. 0 - OK, !0 - error
+- */
+-static av_cold int che_configure(AACContext *ac,
+- enum ChannelPosition che_pos[4][MAX_ELEM_ID],
+- int type, int id,
+- int *channels)
+-{
+- if (che_pos[type][id]) {
+- if (!ac->che[type][id] && !(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
+- return AVERROR(ENOMEM);
+- ff_aac_sbr_ctx_init(&ac->che[type][id]->sbr);
+- if (type != TYPE_CCE) {
+- ac->output_data[(*channels)++] = ac->che[type][id]->ch[0].ret;
+- if (type == TYPE_CPE) {
+- ac->output_data[(*channels)++] = ac->che[type][id]->ch[1].ret;
+- }
+- }
+- } else {
+- if (ac->che[type][id])
+- ff_aac_sbr_ctx_close(&ac->che[type][id]->sbr);
+- av_freep(&ac->che[type][id]);
+- }
+- return 0;
+-}
+-
+-/**
+- * Configure output channel order based on the current program configuration element.
+- *
+- * @param che_pos current channel position configuration
+- * @param new_che_pos New channel position configuration - we only do something if it differs from the current one.
+- *
+- * @return Returns error status. 0 - OK, !0 - error
+- */
+-static av_cold int output_configure(AACContext *ac,
+- enum ChannelPosition che_pos[4][MAX_ELEM_ID],
+- enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
+- int channel_config, enum OCStatus oc_type)
+-{
+- AVCodecContext *avctx = ac->avccontext;
+- int i, type, channels = 0, ret;
+-
+- memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
+-
+- if (channel_config) {
+- for (i = 0; i < tags_per_config[channel_config]; i++) {
+- if ((ret = che_configure(ac, che_pos,
+- aac_channel_layout_map[channel_config - 1][i][0],
+- aac_channel_layout_map[channel_config - 1][i][1],
+- &channels)))
+- return ret;
+- }
+-
+- memset(ac->tag_che_map, 0, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
+- ac->tags_mapped = 0;
+-
+- avctx->channel_layout = aac_channel_layout[channel_config - 1];
+- } else {
+- /* Allocate or free elements depending on if they are in the
+- * current program configuration.
+- *
+- * Set up default 1:1 output mapping.
+- *
+- * For a 5.1 stream the output order will be:
+- * [ Center ] [ Front Left ] [ Front Right ] [ LFE ] [ Surround Left ] [ Surround Right ]
+- */
+-
+- for (i = 0; i < MAX_ELEM_ID; i++) {
+- for (type = 0; type < 4; type++) {
+- if ((ret = che_configure(ac, che_pos, type, i, &channels)))
+- return ret;
+- }
+- }
+-
+- memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
+- ac->tags_mapped = 4 * MAX_ELEM_ID;
+-
+- avctx->channel_layout = 0;
+- }
+-
+- avctx->channels = channels;
+-
+- ac->output_configured = oc_type;
+-
+- return 0;
+-}
+-
+-/**
+- * Decode an array of 4 bit element IDs, optionally interleaved with a stereo/mono switching bit.
+- *
+- * @param cpe_map Stereo (Channel Pair Element) map, NULL if stereo bit is not present.
+- * @param sce_map mono (Single Channel Element) map
+- * @param type speaker type/position for these channels
+- */
+-static void decode_channel_map(enum ChannelPosition *cpe_map,
+- enum ChannelPosition *sce_map,
+- enum ChannelPosition type,
+- GetBitContext *gb, int n)
+-{
+- while (n--) {
+- enum ChannelPosition *map = cpe_map && get_bits1(gb) ? cpe_map : sce_map; // stereo or mono map
+- map[get_bits(gb, 4)] = type;
+- }
+-}
+-
+-/**
+- * Decode program configuration element; reference: table 4.2.
+- *
+- * @param new_che_pos New channel position configuration - we only do something if it differs from the current one.
+- *
+- * @return Returns error status. 0 - OK, !0 - error
+- */
+-static int decode_pce(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
+- GetBitContext *gb)
+-{
+- int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc, sampling_index;
+- int comment_len;
+-
+- skip_bits(gb, 2); // object_type
+-
+- sampling_index = get_bits(gb, 4);
+- if (ac->m4ac.sampling_index != sampling_index)
+- av_log(ac->avccontext, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n");
+-
+- num_front = get_bits(gb, 4);
+- num_side = get_bits(gb, 4);
+- num_back = get_bits(gb, 4);
+- num_lfe = get_bits(gb, 2);
+- num_assoc_data = get_bits(gb, 3);
+- num_cc = get_bits(gb, 4);
+-
+- if (get_bits1(gb))
+- skip_bits(gb, 4); // mono_mixdown_tag
+- if (get_bits1(gb))
+- skip_bits(gb, 4); // stereo_mixdown_tag
+-
+- if (get_bits1(gb))
+- skip_bits(gb, 3); // mixdown_coeff_index and pseudo_surround
+-
+- decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_FRONT, gb, num_front);
+- decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_SIDE, gb, num_side );
+- decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_BACK, gb, num_back );
+- decode_channel_map(NULL, new_che_pos[TYPE_LFE], AAC_CHANNEL_LFE, gb, num_lfe );
+-
+- skip_bits_long(gb, 4 * num_assoc_data);
+-
+- decode_channel_map(new_che_pos[TYPE_CCE], new_che_pos[TYPE_CCE], AAC_CHANNEL_CC, gb, num_cc );
+-
+- align_get_bits(gb);
+-
+- /* comment field, first byte is length */
+- comment_len = get_bits(gb, 8) * 8;
+- if (get_bits_left(gb) < comment_len) {
+- av_log(ac->avccontext, AV_LOG_ERROR, overread_err);
+- return -1;
+- }
+- skip_bits_long(gb, comment_len);
+- return 0;
+-}
+-
+-/**
+- * Set up channel positions based on a default channel configuration
+- * as specified in table 1.17.
+- *
+- * @param new_che_pos New channel position configuration - we only do something if it differs from the current one.
+- *
+- * @return Returns error status. 0 - OK, !0 - error
+- */
+-static av_cold int set_default_channel_config(AACContext *ac,
+- enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
+- int channel_config)
+-{
+- if (channel_config < 1 || channel_config > 7) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "invalid default channel configuration (%d)\n",
+- channel_config);
+- return -1;
+- }
+-
+- /* default channel configurations:
+- *
+- * 1ch : front center (mono)
+- * 2ch : L + R (stereo)
+- * 3ch : front center + L + R
+- * 4ch : front center + L + R + back center
+- * 5ch : front center + L + R + back stereo
+- * 6ch : front center + L + R + back stereo + LFE
+- * 7ch : front center + L + R + outer front left + outer front right + back stereo + LFE
+- */
+-
+- if (channel_config != 2)
+- new_che_pos[TYPE_SCE][0] = AAC_CHANNEL_FRONT; // front center (or mono)
+- if (channel_config > 1)
+- new_che_pos[TYPE_CPE][0] = AAC_CHANNEL_FRONT; // L + R (or stereo)
+- if (channel_config == 4)
+- new_che_pos[TYPE_SCE][1] = AAC_CHANNEL_BACK; // back center
+- if (channel_config > 4)
+- new_che_pos[TYPE_CPE][(channel_config == 7) + 1]
+- = AAC_CHANNEL_BACK; // back stereo
+- if (channel_config > 5)
+- new_che_pos[TYPE_LFE][0] = AAC_CHANNEL_LFE; // LFE
+- if (channel_config == 7)
+- new_che_pos[TYPE_CPE][1] = AAC_CHANNEL_FRONT; // outer front left + outer front right
+-
+- return 0;
+-}
+-
+-/**
+- * Decode GA "General Audio" specific configuration; reference: table 4.1.
+- *
+- * @return Returns error status. 0 - OK, !0 - error
+- */
+-static int decode_ga_specific_config(AACContext *ac, GetBitContext *gb,
+- int channel_config)
+-{
+- enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
+- int extension_flag, ret;
+-
+- if (get_bits1(gb)) { // frameLengthFlag
+- av_log_missing_feature(ac->avccontext, "960/120 MDCT window is", 1);
+- return -1;
+- }
+-
+- if (get_bits1(gb)) // dependsOnCoreCoder
+- skip_bits(gb, 14); // coreCoderDelay
+- extension_flag = get_bits1(gb);
+-
+- if (ac->m4ac.object_type == AOT_AAC_SCALABLE ||
+- ac->m4ac.object_type == AOT_ER_AAC_SCALABLE)
+- skip_bits(gb, 3); // layerNr
+-
+- memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
+- if (channel_config == 0) {
+- skip_bits(gb, 4); // element_instance_tag
+- if ((ret = decode_pce(ac, new_che_pos, gb)))
+- return ret;
+- } else {
+- if ((ret = set_default_channel_config(ac, new_che_pos, channel_config)))
+- return ret;
+- }
+- if ((ret = output_configure(ac, ac->che_pos, new_che_pos, channel_config, OC_GLOBAL_HDR)))
+- return ret;
+-
+- if (extension_flag) {
+- switch (ac->m4ac.object_type) {
+- case AOT_ER_BSAC:
+- skip_bits(gb, 5); // numOfSubFrame
+- skip_bits(gb, 11); // layer_length
+- break;
+- case AOT_ER_AAC_LC:
+- case AOT_ER_AAC_LTP:
+- case AOT_ER_AAC_SCALABLE:
+- case AOT_ER_AAC_LD:
+- skip_bits(gb, 3); /* aacSectionDataResilienceFlag
+- * aacScalefactorDataResilienceFlag
+- * aacSpectralDataResilienceFlag
+- */
+- break;
+- }
+- skip_bits1(gb); // extensionFlag3 (TBD in version 3)
+- }
+- return 0;
+-}
+-
+-/**
+- * Decode audio specific configuration; reference: table 1.13.
+- *
+- * @param data pointer to AVCodecContext extradata
+- * @param data_size size of AVCCodecContext extradata
+- *
+- * @return Returns error status. 0 - OK, !0 - error
+- */
+-static int decode_audio_specific_config(AACContext *ac, void *data,
+- int data_size)
+-{
+- GetBitContext gb;
+- int i;
+-
+- init_get_bits(&gb, data, data_size * 8);
+-
+- if ((i = ff_mpeg4audio_get_config(&ac->m4ac, data, data_size)) < 0)
+- return -1;
+- if (ac->m4ac.sampling_index > 12) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index);
+- return -1;
+- }
+-
+- skip_bits_long(&gb, i);
+-
+- switch (ac->m4ac.object_type) {
+- case AOT_AAC_MAIN:
+- case AOT_AAC_LC:
+- if (decode_ga_specific_config(ac, &gb, ac->m4ac.chan_config))
+- return -1;
+- break;
+- default:
+- av_log(ac->avccontext, AV_LOG_ERROR, "Audio object type %s%d is not supported.\n",
+- ac->m4ac.sbr == 1? "SBR+" : "", ac->m4ac.object_type);
+- return -1;
+- }
+- return 0;
+-}
+-
+-/**
+- * linear congruential pseudorandom number generator
+- *
+- * @param previous_val pointer to the current state of the generator
+- *
+- * @return Returns a 32-bit pseudorandom integer
+- */
+-static av_always_inline int lcg_random(int previous_val)
+-{
+- return previous_val * 1664525 + 1013904223;
+-}
+-
+-static av_always_inline void reset_predict_state(PredictorState *ps)
+-{
+- ps->r0 = 0.0f;
+- ps->r1 = 0.0f;
+- ps->cor0 = 0.0f;
+- ps->cor1 = 0.0f;
+- ps->var0 = 1.0f;
+- ps->var1 = 1.0f;
+-}
+-
+-static void reset_all_predictors(PredictorState *ps)
+-{
+- int i;
+- for (i = 0; i < MAX_PREDICTORS; i++)
+- reset_predict_state(&ps[i]);
+-}
+-
+-static void reset_predictor_group(PredictorState *ps, int group_num)
+-{
+- int i;
+- for (i = group_num - 1; i < MAX_PREDICTORS; i += 30)
+- reset_predict_state(&ps[i]);
+-}
+-
+-static av_cold int aac_decode_init(AVCodecContext *avccontext)
+-{
+- AACContext *ac = avccontext->priv_data;
+- int i;
+-
+- ac->avccontext = avccontext;
+- ac->m4ac.sample_rate = avccontext->sample_rate;
+-
+- if (avccontext->extradata_size > 0) {
+- if (decode_audio_specific_config(ac, avccontext->extradata, avccontext->extradata_size))
+- return -1;
+- }
+-
+- avccontext->sample_fmt = SAMPLE_FMT_S16;
+-
+- AAC_INIT_VLC_STATIC( 0, 304);
+- AAC_INIT_VLC_STATIC( 1, 270);
+- AAC_INIT_VLC_STATIC( 2, 550);
+- AAC_INIT_VLC_STATIC( 3, 300);
+- AAC_INIT_VLC_STATIC( 4, 328);
+- AAC_INIT_VLC_STATIC( 5, 294);
+- AAC_INIT_VLC_STATIC( 6, 306);
+- AAC_INIT_VLC_STATIC( 7, 268);
+- AAC_INIT_VLC_STATIC( 8, 510);
+- AAC_INIT_VLC_STATIC( 9, 366);
+- AAC_INIT_VLC_STATIC(10, 462);
+-
+- ff_aac_sbr_init();
+-
+- dsputil_init(&ac->dsp, avccontext);
+-
+- ac->random_state = 0x1f2e3d4c;
+-
+- // -1024 - Compensate wrong IMDCT method.
+- // 32768 - Required to scale values to the correct range for the bias method
+- // for float to int16 conversion.
+-
+- if (ac->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) {
+- ac->add_bias = 385.0f;
+- ac->sf_scale = 1. / (-1024. * 32768.);
+- ac->sf_offset = 0;
+- } else {
+- ac->add_bias = 0.0f;
+- ac->sf_scale = 1. / -1024.;
+- ac->sf_offset = 60;
+- }
+-
+-#if !CONFIG_HARDCODED_TABLES
+- for (i = 0; i < 428; i++)
+- ff_aac_pow2sf_tab[i] = pow(2, (i - 200) / 4.);
+-#endif /* CONFIG_HARDCODED_TABLES */
+-
+- INIT_VLC_STATIC(&vlc_scalefactors,7,FF_ARRAY_ELEMS(ff_aac_scalefactor_code),
+- ff_aac_scalefactor_bits, sizeof(ff_aac_scalefactor_bits[0]), sizeof(ff_aac_scalefactor_bits[0]),
+- ff_aac_scalefactor_code, sizeof(ff_aac_scalefactor_code[0]), sizeof(ff_aac_scalefactor_code[0]),
+- 352);
+-
+- ff_mdct_init(&ac->mdct, 11, 1, 1.0);
+- ff_mdct_init(&ac->mdct_small, 8, 1, 1.0);
+- // window initialization
+- ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
+- ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
+- ff_init_ff_sine_windows(10);
+- ff_init_ff_sine_windows( 7);
+-
+- cbrt_tableinit();
+-
+- return 0;
+-}
+-
+-/**
+- * Skip data_stream_element; reference: table 4.10.
+- */
+-static int skip_data_stream_element(AACContext *ac, GetBitContext *gb)
+-{
+- int byte_align = get_bits1(gb);
+- int count = get_bits(gb, 8);
+- if (count == 255)
+- count += get_bits(gb, 8);
+- if (byte_align)
+- align_get_bits(gb);
+-
+- if (get_bits_left(gb) < 8 * count) {
+- av_log(ac->avccontext, AV_LOG_ERROR, overread_err);
+- return -1;
+- }
+- skip_bits_long(gb, 8 * count);
+- return 0;
+-}
+-
+-static int decode_prediction(AACContext *ac, IndividualChannelStream *ics,
+- GetBitContext *gb)
+-{
+- int sfb;
+- if (get_bits1(gb)) {
+- ics->predictor_reset_group = get_bits(gb, 5);
+- if (ics->predictor_reset_group == 0 || ics->predictor_reset_group > 30) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "Invalid Predictor Reset Group.\n");
+- return -1;
+- }
+- }
+- for (sfb = 0; sfb < FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[ac->m4ac.sampling_index]); sfb++) {
+- ics->prediction_used[sfb] = get_bits1(gb);
+- }
+- return 0;
+-}
+-
+-/**
+- * Decode Individual Channel Stream info; reference: table 4.6.
+- *
+- * @param common_window Channels have independent [0], or shared [1], Individual Channel Stream information.
+- */
+-static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
+- GetBitContext *gb, int common_window)
+-{
+- if (get_bits1(gb)) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "Reserved bit set.\n");
+- memset(ics, 0, sizeof(IndividualChannelStream));
+- return -1;
+- }
+- ics->window_sequence[1] = ics->window_sequence[0];
+- ics->window_sequence[0] = get_bits(gb, 2);
+- ics->use_kb_window[1] = ics->use_kb_window[0];
+- ics->use_kb_window[0] = get_bits1(gb);
+- ics->num_window_groups = 1;
+- ics->group_len[0] = 1;
+- if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
+- int i;
+- ics->max_sfb = get_bits(gb, 4);
+- for (i = 0; i < 7; i++) {
+- if (get_bits1(gb)) {
+- ics->group_len[ics->num_window_groups - 1]++;
+- } else {
+- ics->num_window_groups++;
+- ics->group_len[ics->num_window_groups - 1] = 1;
+- }
+- }
+- ics->num_windows = 8;
+- ics->swb_offset = ff_swb_offset_128[ac->m4ac.sampling_index];
+- ics->num_swb = ff_aac_num_swb_128[ac->m4ac.sampling_index];
+- ics->tns_max_bands = ff_tns_max_bands_128[ac->m4ac.sampling_index];
+- ics->predictor_present = 0;
+- } else {
+- ics->max_sfb = get_bits(gb, 6);
+- ics->num_windows = 1;
+- ics->swb_offset = ff_swb_offset_1024[ac->m4ac.sampling_index];
+- ics->num_swb = ff_aac_num_swb_1024[ac->m4ac.sampling_index];
+- ics->tns_max_bands = ff_tns_max_bands_1024[ac->m4ac.sampling_index];
+- ics->predictor_present = get_bits1(gb);
+- ics->predictor_reset_group = 0;
+- if (ics->predictor_present) {
+- if (ac->m4ac.object_type == AOT_AAC_MAIN) {
+- if (decode_prediction(ac, ics, gb)) {
+- memset(ics, 0, sizeof(IndividualChannelStream));
+- return -1;
+- }
+- } else if (ac->m4ac.object_type == AOT_AAC_LC) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "Prediction is not allowed in AAC-LC.\n");
+- memset(ics, 0, sizeof(IndividualChannelStream));
+- return -1;
+- } else {
+- av_log_missing_feature(ac->avccontext, "Predictor bit set but LTP is", 1);
+- memset(ics, 0, sizeof(IndividualChannelStream));
+- return -1;
+- }
+- }
+- }
+-
+- if (ics->max_sfb > ics->num_swb) {
+- av_log(ac->avccontext, AV_LOG_ERROR,
+- "Number of scalefactor bands in group (%d) exceeds limit (%d).\n",
+- ics->max_sfb, ics->num_swb);
+- memset(ics, 0, sizeof(IndividualChannelStream));
+- return -1;
+- }
+-
+- return 0;
+-}
+-
+-/**
+- * Decode band types (section_data payload); reference: table 4.46.
+- *
+- * @param band_type array of the used band type
+- * @param band_type_run_end array of the last scalefactor band of a band type run
+- *
+- * @return Returns error status. 0 - OK, !0 - error
+- */
+-static int decode_band_types(AACContext *ac, enum BandType band_type[120],
+- int band_type_run_end[120], GetBitContext *gb,
+- IndividualChannelStream *ics)
+-{
+- int g, idx = 0;
+- const int bits = (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) ? 3 : 5;
+- for (g = 0; g < ics->num_window_groups; g++) {
+- int k = 0;
+- while (k < ics->max_sfb) {
+- uint8_t sect_end = k;
+- int sect_len_incr;
+- int sect_band_type = get_bits(gb, 4);
+- if (sect_band_type == 12) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "invalid band type\n");
+- return -1;
+- }
+- while ((sect_len_incr = get_bits(gb, bits)) == (1 << bits) - 1)
+- sect_end += sect_len_incr;
+- sect_end += sect_len_incr;
+- if (get_bits_left(gb) < 0) {
+- av_log(ac->avccontext, AV_LOG_ERROR, overread_err);
+- return -1;
+- }
+- if (sect_end > ics->max_sfb) {
+- av_log(ac->avccontext, AV_LOG_ERROR,
+- "Number of bands (%d) exceeds limit (%d).\n",
+- sect_end, ics->max_sfb);
+- return -1;
+- }
+- for (; k < sect_end; k++) {
+- band_type [idx] = sect_band_type;
+- band_type_run_end[idx++] = sect_end;
+- }
+- }
+- }
+- return 0;
+-}
+-
+-/**
+- * Decode scalefactors; reference: table 4.47.
+- *
+- * @param global_gain first scalefactor value as scalefactors are differentially coded
+- * @param band_type array of the used band type
+- * @param band_type_run_end array of the last scalefactor band of a band type run
+- * @param sf array of scalefactors or intensity stereo positions
+- *
+- * @return Returns error status. 0 - OK, !0 - error
+- */
+-static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb,
+- unsigned int global_gain,
+- IndividualChannelStream *ics,
+- enum BandType band_type[120],
+- int band_type_run_end[120])
+-{
+- const int sf_offset = ac->sf_offset + (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE ? 12 : 0);
+- int g, i, idx = 0;
+- int offset[3] = { global_gain, global_gain - 90, 100 };
+- int noise_flag = 1;
+- static const char *sf_str[3] = { "Global gain", "Noise gain", "Intensity stereo position" };
+- for (g = 0; g < ics->num_window_groups; g++) {
+- for (i = 0; i < ics->max_sfb;) {
+- int run_end = band_type_run_end[idx];
+- if (band_type[idx] == ZERO_BT) {
+- for (; i < run_end; i++, idx++)
+- sf[idx] = 0.;
+- } else if ((band_type[idx] == INTENSITY_BT) || (band_type[idx] == INTENSITY_BT2)) {
+- for (; i < run_end; i++, idx++) {
+- offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
+- if (offset[2] > 255U) {
+- av_log(ac->avccontext, AV_LOG_ERROR,
+- "%s (%d) out of range.\n", sf_str[2], offset[2]);
+- return -1;
+- }
+- sf[idx] = ff_aac_pow2sf_tab[-offset[2] + 300];
+- }
+- } else if (band_type[idx] == NOISE_BT) {
+- for (; i < run_end; i++, idx++) {
+- if (noise_flag-- > 0)
+- offset[1] += get_bits(gb, 9) - 256;
+- else
+- offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
+- if (offset[1] > 255U) {
+- av_log(ac->avccontext, AV_LOG_ERROR,
+- "%s (%d) out of range.\n", sf_str[1], offset[1]);
+- return -1;
+- }
+- sf[idx] = -ff_aac_pow2sf_tab[offset[1] + sf_offset + 100];
+- }
+- } else {
+- for (; i < run_end; i++, idx++) {
+- offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
+- if (offset[0] > 255U) {
+- av_log(ac->avccontext, AV_LOG_ERROR,
+- "%s (%d) out of range.\n", sf_str[0], offset[0]);
+- return -1;
+- }
+- sf[idx] = -ff_aac_pow2sf_tab[ offset[0] + sf_offset];
+- }
+- }
+- }
+- }
+- return 0;
+-}
+-
+-/**
+- * Decode pulse data; reference: table 4.7.
+- */
+-static int decode_pulses(Pulse *pulse, GetBitContext *gb,
+- const uint16_t *swb_offset, int num_swb)
+-{
+- int i, pulse_swb;
+- pulse->num_pulse = get_bits(gb, 2) + 1;
+- pulse_swb = get_bits(gb, 6);
+- if (pulse_swb >= num_swb)
+- return -1;
+- pulse->pos[0] = swb_offset[pulse_swb];
+- pulse->pos[0] += get_bits(gb, 5);
+- if (pulse->pos[0] > 1023)
+- return -1;
+- pulse->amp[0] = get_bits(gb, 4);
+- for (i = 1; i < pulse->num_pulse; i++) {
+- pulse->pos[i] = get_bits(gb, 5) + pulse->pos[i - 1];
+- if (pulse->pos[i] > 1023)
+- return -1;
+- pulse->amp[i] = get_bits(gb, 4);
+- }
+- return 0;
+-}
+-
+-/**
+- * Decode Temporal Noise Shaping data; reference: table 4.48.
+- *
+- * @return Returns error status. 0 - OK, !0 - error
+- */
+-static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns,
+- GetBitContext *gb, const IndividualChannelStream *ics)
+-{
+- int w, filt, i, coef_len, coef_res, coef_compress;
+- const int is8 = ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE;
+- const int tns_max_order = is8 ? 7 : ac->m4ac.object_type == AOT_AAC_MAIN ? 20 : 12;
+- for (w = 0; w < ics->num_windows; w++) {
+- if ((tns->n_filt[w] = get_bits(gb, 2 - is8))) {
+- coef_res = get_bits1(gb);
+-
+- for (filt = 0; filt < tns->n_filt[w]; filt++) {
+- int tmp2_idx;
+- tns->length[w][filt] = get_bits(gb, 6 - 2 * is8);
+-
+- if ((tns->order[w][filt] = get_bits(gb, 5 - 2 * is8)) > tns_max_order) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.\n",
+- tns->order[w][filt], tns_max_order);
+- tns->order[w][filt] = 0;
+- return -1;
+- }
+- if (tns->order[w][filt]) {
+- tns->direction[w][filt] = get_bits1(gb);
+- coef_compress = get_bits1(gb);
+- coef_len = coef_res + 3 - coef_compress;
+- tmp2_idx = 2 * coef_compress + coef_res;
+-
+- for (i = 0; i < tns->order[w][filt]; i++)
+- tns->coef[w][filt][i] = tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];
+- }
+- }
+- }
+- }
+- return 0;
+-}
+-
+-/**
+- * Decode Mid/Side data; reference: table 4.54.
+- *
+- * @param ms_present Indicates mid/side stereo presence. [0] mask is all 0s;
+- * [1] mask is decoded from bitstream; [2] mask is all 1s;
+- * [3] reserved for scalable AAC
+- */
+-static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb,
+- int ms_present)
+-{
+- int idx;
+- if (ms_present == 1) {
+- for (idx = 0; idx < cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb; idx++)
+- cpe->ms_mask[idx] = get_bits1(gb);
+- } else if (ms_present == 2) {
+- memset(cpe->ms_mask, 1, cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb * sizeof(cpe->ms_mask[0]));
+- }
+-}
+-
+-#ifndef VMUL2
+-static inline float *VMUL2(float *dst, const float *v, unsigned idx,
+- const float *scale)
+-{
+- float s = *scale;
+- *dst++ = v[idx & 15] * s;
+- *dst++ = v[idx>>4 & 15] * s;
+- return dst;
+-}
+-#endif
+-
+-#ifndef VMUL4
+-static inline float *VMUL4(float *dst, const float *v, unsigned idx,
+- const float *scale)
+-{
+- float s = *scale;
+- *dst++ = v[idx & 3] * s;
+- *dst++ = v[idx>>2 & 3] * s;
+- *dst++ = v[idx>>4 & 3] * s;
+- *dst++ = v[idx>>6 & 3] * s;
+- return dst;
+-}
+-#endif
+-
+-#ifndef VMUL2S
+-static inline float *VMUL2S(float *dst, const float *v, unsigned idx,
+- unsigned sign, const float *scale)
+-{
+- union float754 s0, s1;
+-
+- s0.f = s1.f = *scale;
+- s0.i ^= sign >> 1 << 31;
+- s1.i ^= sign << 31;
+-
+- *dst++ = v[idx & 15] * s0.f;
+- *dst++ = v[idx>>4 & 15] * s1.f;
+-
+- return dst;
+-}
+-#endif
+-
+-#ifndef VMUL4S
+-static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
+- unsigned sign, const float *scale)
+-{
+- unsigned nz = idx >> 12;
+- union float754 s = { .f = *scale };
+- union float754 t;
+-
+- t.i = s.i ^ (sign & 1<<31);
+- *dst++ = v[idx & 3] * t.f;
+-
+- sign <<= nz & 1; nz >>= 1;
+- t.i = s.i ^ (sign & 1<<31);
+- *dst++ = v[idx>>2 & 3] * t.f;
+-
+- sign <<= nz & 1; nz >>= 1;
+- t.i = s.i ^ (sign & 1<<31);
+- *dst++ = v[idx>>4 & 3] * t.f;
+-
+- sign <<= nz & 1; nz >>= 1;
+- t.i = s.i ^ (sign & 1<<31);
+- *dst++ = v[idx>>6 & 3] * t.f;
+-
+- return dst;
+-}
+-#endif
+-
+-/**
+- * Decode spectral data; reference: table 4.50.
+- * Dequantize and scale spectral data; reference: 4.6.3.3.
+- *
+- * @param coef array of dequantized, scaled spectral data
+- * @param sf array of scalefactors or intensity stereo positions
+- * @param pulse_present set if pulses are present
+- * @param pulse pointer to pulse data struct
+- * @param band_type array of the used band type
+- *
+- * @return Returns error status. 0 - OK, !0 - error
+- */
+-static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024],
+- GetBitContext *gb, const float sf[120],
+- int pulse_present, const Pulse *pulse,
+- const IndividualChannelStream *ics,
+- enum BandType band_type[120])
+-{
+- int i, k, g, idx = 0;
+- const int c = 1024 / ics->num_windows;
+- const uint16_t *offsets = ics->swb_offset;
+- float *coef_base = coef;
+- int err_idx;
+-
+- for (g = 0; g < ics->num_windows; g++)
+- memset(coef + g * 128 + offsets[ics->max_sfb], 0, sizeof(float) * (c - offsets[ics->max_sfb]));
+-
+- for (g = 0; g < ics->num_window_groups; g++) {
+- unsigned g_len = ics->group_len[g];
+-
+- for (i = 0; i < ics->max_sfb; i++, idx++) {
+- const unsigned cbt_m1 = band_type[idx] - 1;
+- float *cfo = coef + offsets[i];
+- int off_len = offsets[i + 1] - offsets[i];
+- int group;
+-
+- if (cbt_m1 >= INTENSITY_BT2 - 1) {
+- for (group = 0; group < g_len; group++, cfo+=128) {
+- memset(cfo, 0, off_len * sizeof(float));
+- }
+- } else if (cbt_m1 == NOISE_BT - 1) {
+- for (group = 0; group < g_len; group++, cfo+=128) {
+- float scale;
+- float band_energy;
+-
+- for (k = 0; k < off_len; k++) {
+- ac->random_state = lcg_random(ac->random_state);
+- cfo[k] = ac->random_state;
+- }
+-
+- band_energy = ac->dsp.scalarproduct_float(cfo, cfo, off_len);
+- scale = sf[idx] / sqrtf(band_energy);
+- ac->dsp.vector_fmul_scalar(cfo, cfo, scale, off_len);
+- }
+- } else {
+- const float *vq = ff_aac_codebook_vector_vals[cbt_m1];
+- const uint16_t *cb_vector_idx = ff_aac_codebook_vector_idx[cbt_m1];
+- VLC_TYPE (*vlc_tab)[2] = vlc_spectral[cbt_m1].table;
+- const int cb_size = ff_aac_spectral_sizes[cbt_m1];
+- OPEN_READER(re, gb);
+-
+- switch (cbt_m1 >> 1) {
+- case 0:
+- for (group = 0; group < g_len; group++, cfo+=128) {
+- float *cf = cfo;
+- int len = off_len;
+-
+- do {
+- int code;
+- unsigned cb_idx;
+-
+- UPDATE_CACHE(re, gb);
+- GET_VLC(code, re, gb, vlc_tab, 8, 2);
+-
+- if (code >= cb_size) {
+- err_idx = code;
+- goto err_cb_overflow;
+- }
+-
+- cb_idx = cb_vector_idx[code];
+- cf = VMUL4(cf, vq, cb_idx, sf + idx);
+- } while (len -= 4);
+- }
+- break;
+-
+- case 1:
+- for (group = 0; group < g_len; group++, cfo+=128) {
+- float *cf = cfo;
+- int len = off_len;
+-
+- do {
+- int code;
+- unsigned nnz;
+- unsigned cb_idx;
+- uint32_t bits;
+-
+- UPDATE_CACHE(re, gb);
+- GET_VLC(code, re, gb, vlc_tab, 8, 2);
+-
+- if (code >= cb_size) {
+- err_idx = code;
+- goto err_cb_overflow;
+- }
+-
+-#if MIN_CACHE_BITS < 20
+- UPDATE_CACHE(re, gb);
+-#endif
+- cb_idx = cb_vector_idx[code];
+- nnz = cb_idx >> 8 & 15;
+- bits = SHOW_UBITS(re, gb, nnz) << (32-nnz);
+- LAST_SKIP_BITS(re, gb, nnz);
+- cf = VMUL4S(cf, vq, cb_idx, bits, sf + idx);
+- } while (len -= 4);
+- }
+- break;
+-
+- case 2:
+- for (group = 0; group < g_len; group++, cfo+=128) {
+- float *cf = cfo;
+- int len = off_len;
+-
+- do {
+- int code;
+- unsigned cb_idx;
+-
+- UPDATE_CACHE(re, gb);
+- GET_VLC(code, re, gb, vlc_tab, 8, 2);
+-
+- if (code >= cb_size) {
+- err_idx = code;
+- goto err_cb_overflow;
+- }
+-
+- cb_idx = cb_vector_idx[code];
+- cf = VMUL2(cf, vq, cb_idx, sf + idx);
+- } while (len -= 2);
+- }
+- break;
+-
+- case 3:
+- case 4:
+- for (group = 0; group < g_len; group++, cfo+=128) {
+- float *cf = cfo;
+- int len = off_len;
+-
+- do {
+- int code;
+- unsigned nnz;
+- unsigned cb_idx;
+- unsigned sign;
+-
+- UPDATE_CACHE(re, gb);
+- GET_VLC(code, re, gb, vlc_tab, 8, 2);
+-
+- if (code >= cb_size) {
+- err_idx = code;
+- goto err_cb_overflow;
+- }
+-
+- cb_idx = cb_vector_idx[code];
+- nnz = cb_idx >> 8 & 15;
+- sign = SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12);
+- LAST_SKIP_BITS(re, gb, nnz);
+- cf = VMUL2S(cf, vq, cb_idx, sign, sf + idx);
+- } while (len -= 2);
+- }
+- break;
+-
+- default:
+- for (group = 0; group < g_len; group++, cfo+=128) {
+- float *cf = cfo;
+- uint32_t *icf = (uint32_t *) cf;
+- int len = off_len;
+-
+- do {
+- int code;
+- unsigned nzt, nnz;
+- unsigned cb_idx;
+- uint32_t bits;
+- int j;
+-
+- UPDATE_CACHE(re, gb);
+- GET_VLC(code, re, gb, vlc_tab, 8, 2);
+-
+- if (!code) {
+- *icf++ = 0;
+- *icf++ = 0;
+- continue;
+- }
+-
+- if (code >= cb_size) {
+- err_idx = code;
+- goto err_cb_overflow;
+- }
+-
+- cb_idx = cb_vector_idx[code];
+- nnz = cb_idx >> 12;
+- nzt = cb_idx >> 8;
+- bits = SHOW_UBITS(re, gb, nnz) << (32-nnz);
+- LAST_SKIP_BITS(re, gb, nnz);
+-
+- for (j = 0; j < 2; j++) {
+- if (nzt & 1< 8) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "error in spectral data, ESC overflow\n");
+- return -1;
+- }
+-
+-#if MIN_CACHE_BITS < 21
+- LAST_SKIP_BITS(re, gb, b + 1);
+- UPDATE_CACHE(re, gb);
+-#else
+- SKIP_BITS(re, gb, b + 1);
+-#endif
+- b += 4;
+- n = (1 << b) + SHOW_UBITS(re, gb, b);
+- LAST_SKIP_BITS(re, gb, b);
+- *icf++ = cbrt_tab[n] | (bits & 1<<31);
+- bits <<= 1;
+- } else {
+- unsigned v = ((const uint32_t*)vq)[cb_idx & 15];
+- *icf++ = (bits & 1<<31) | v;
+- bits <<= !!v;
+- }
+- cb_idx >>= 4;
+- }
+- } while (len -= 2);
+-
+- ac->dsp.vector_fmul_scalar(cfo, cfo, sf[idx], off_len);
+- }
+- }
+-
+- CLOSE_READER(re, gb);
+- }
+- }
+- coef += g_len << 7;
+- }
+-
+- if (pulse_present) {
+- idx = 0;
+- for (i = 0; i < pulse->num_pulse; i++) {
+- float co = coef_base[ pulse->pos[i] ];
+- while (offsets[idx + 1] <= pulse->pos[i])
+- idx++;
+- if (band_type[idx] != NOISE_BT && sf[idx]) {
+- float ico = -pulse->amp[i];
+- if (co) {
+- co /= sf[idx];
+- ico = co / sqrtf(sqrtf(fabsf(co))) + (co > 0 ? -ico : ico);
+- }
+- coef_base[ pulse->pos[i] ] = cbrtf(fabsf(ico)) * ico * sf[idx];
+- }
+- }
+- }
+- return 0;
+-
+-err_cb_overflow:
+- av_log(ac->avccontext, AV_LOG_ERROR,
+- "Read beyond end of ff_aac_codebook_vectors[%d][]. index %d >= %d\n",
+- band_type[idx], err_idx, ff_aac_spectral_sizes[band_type[idx]]);
+- return -1;
+-}
+-
+-static av_always_inline float flt16_round(float pf)
+-{
+- union float754 tmp;
+- tmp.f = pf;
+- tmp.i = (tmp.i + 0x00008000U) & 0xFFFF0000U;
+- return tmp.f;
+-}
+-
+-static av_always_inline float flt16_even(float pf)
+-{
+- union float754 tmp;
+- tmp.f = pf;
+- tmp.i = (tmp.i + 0x00007FFFU + (tmp.i & 0x00010000U >> 16)) & 0xFFFF0000U;
+- return tmp.f;
+-}
+-
+-static av_always_inline float flt16_trunc(float pf)
+-{
+- union float754 pun;
+- pun.f = pf;
+- pun.i &= 0xFFFF0000U;
+- return pun.f;
+-}
+-
+-static av_always_inline void predict(AACContext *ac, PredictorState *ps, float *coef,
+- int output_enable)
+-{
+- const float a = 0.953125; // 61.0 / 64
+- const float alpha = 0.90625; // 29.0 / 32
+- float e0, e1;
+- float pv;
+- float k1, k2;
+-
+- k1 = ps->var0 > 1 ? ps->cor0 * flt16_even(a / ps->var0) : 0;
+- k2 = ps->var1 > 1 ? ps->cor1 * flt16_even(a / ps->var1) : 0;
+-
+- pv = flt16_round(k1 * ps->r0 + k2 * ps->r1);
+- if (output_enable)
+- *coef += pv * ac->sf_scale;
+-
+- e0 = *coef / ac->sf_scale;
+- e1 = e0 - k1 * ps->r0;
+-
+- ps->cor1 = flt16_trunc(alpha * ps->cor1 + ps->r1 * e1);
+- ps->var1 = flt16_trunc(alpha * ps->var1 + 0.5 * (ps->r1 * ps->r1 + e1 * e1));
+- ps->cor0 = flt16_trunc(alpha * ps->cor0 + ps->r0 * e0);
+- ps->var0 = flt16_trunc(alpha * ps->var0 + 0.5 * (ps->r0 * ps->r0 + e0 * e0));
+-
+- ps->r1 = flt16_trunc(a * (ps->r0 - k1 * e0));
+- ps->r0 = flt16_trunc(a * e0);
+-}
+-
+-/**
+- * Apply AAC-Main style frequency domain prediction.
+- */
+-static void apply_prediction(AACContext *ac, SingleChannelElement *sce)
+-{
+- int sfb, k;
+-
+- if (!sce->ics.predictor_initialized) {
+- reset_all_predictors(sce->predictor_state);
+- sce->ics.predictor_initialized = 1;
+- }
+-
+- if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) {
+- for (sfb = 0; sfb < ff_aac_pred_sfb_max[ac->m4ac.sampling_index]; sfb++) {
+- for (k = sce->ics.swb_offset[sfb]; k < sce->ics.swb_offset[sfb + 1]; k++) {
+- predict(ac, &sce->predictor_state[k], &sce->coeffs[k],
+- sce->ics.predictor_present && sce->ics.prediction_used[sfb]);
+- }
+- }
+- if (sce->ics.predictor_reset_group)
+- reset_predictor_group(sce->predictor_state, sce->ics.predictor_reset_group);
+- } else
+- reset_all_predictors(sce->predictor_state);
+-}
+-
+-/**
+- * Decode an individual_channel_stream payload; reference: table 4.44.
+- *
+- * @param common_window Channels have independent [0], or shared [1], Individual Channel Stream information.
+- * @param scale_flag scalable [1] or non-scalable [0] AAC (Unused until scalable AAC is implemented.)
+- *
+- * @return Returns error status. 0 - OK, !0 - error
+- */
+-static int decode_ics(AACContext *ac, SingleChannelElement *sce,
+- GetBitContext *gb, int common_window, int scale_flag)
+-{
+- Pulse pulse;
+- TemporalNoiseShaping *tns = &sce->tns;
+- IndividualChannelStream *ics = &sce->ics;
+- float *out = sce->coeffs;
+- int global_gain, pulse_present = 0;
+-
+- /* This assignment is to silence a GCC warning about the variable being used
+- * uninitialized when in fact it always is.
+- */
+- pulse.num_pulse = 0;
+-
+- global_gain = get_bits(gb, 8);
+-
+- if (!common_window && !scale_flag) {
+- if (decode_ics_info(ac, ics, gb, 0) < 0)
+- return -1;
+- }
+-
+- if (decode_band_types(ac, sce->band_type, sce->band_type_run_end, gb, ics) < 0)
+- return -1;
+- if (decode_scalefactors(ac, sce->sf, gb, global_gain, ics, sce->band_type, sce->band_type_run_end) < 0)
+- return -1;
+-
+- pulse_present = 0;
+- if (!scale_flag) {
+- if ((pulse_present = get_bits1(gb))) {
+- if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "Pulse tool not allowed in eight short sequence.\n");
+- return -1;
+- }
+- if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "Pulse data corrupt or invalid.\n");
+- return -1;
+- }
+- }
+- if ((tns->present = get_bits1(gb)) && decode_tns(ac, tns, gb, ics))
+- return -1;
+- if (get_bits1(gb)) {
+- av_log_missing_feature(ac->avccontext, "SSR", 1);
+- return -1;
+- }
+- }
+-
+- if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present, &pulse, ics, sce->band_type) < 0)
+- return -1;
+-
+- if (ac->m4ac.object_type == AOT_AAC_MAIN && !common_window)
+- apply_prediction(ac, sce);
+-
+- return 0;
+-}
+-
+-/**
+- * Mid/Side stereo decoding; reference: 4.6.8.1.3.
+- */
+-static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe)
+-{
+- const IndividualChannelStream *ics = &cpe->ch[0].ics;
+- float *ch0 = cpe->ch[0].coeffs;
+- float *ch1 = cpe->ch[1].coeffs;
+- int g, i, group, idx = 0;
+- const uint16_t *offsets = ics->swb_offset;
+- for (g = 0; g < ics->num_window_groups; g++) {
+- for (i = 0; i < ics->max_sfb; i++, idx++) {
+- if (cpe->ms_mask[idx] &&
+- cpe->ch[0].band_type[idx] < NOISE_BT && cpe->ch[1].band_type[idx] < NOISE_BT) {
+- for (group = 0; group < ics->group_len[g]; group++) {
+- ac->dsp.butterflies_float(ch0 + group * 128 + offsets[i],
+- ch1 + group * 128 + offsets[i],
+- offsets[i+1] - offsets[i]);
+- }
+- }
+- }
+- ch0 += ics->group_len[g] * 128;
+- ch1 += ics->group_len[g] * 128;
+- }
+-}
+-
+-/**
+- * intensity stereo decoding; reference: 4.6.8.2.3
+- *
+- * @param ms_present Indicates mid/side stereo presence. [0] mask is all 0s;
+- * [1] mask is decoded from bitstream; [2] mask is all 1s;
+- * [3] reserved for scalable AAC
+- */
+-static void apply_intensity_stereo(ChannelElement *cpe, int ms_present)
+-{
+- const IndividualChannelStream *ics = &cpe->ch[1].ics;
+- SingleChannelElement *sce1 = &cpe->ch[1];
+- float *coef0 = cpe->ch[0].coeffs, *coef1 = cpe->ch[1].coeffs;
+- const uint16_t *offsets = ics->swb_offset;
+- int g, group, i, k, idx = 0;
+- int c;
+- float scale;
+- for (g = 0; g < ics->num_window_groups; g++) {
+- for (i = 0; i < ics->max_sfb;) {
+- if (sce1->band_type[idx] == INTENSITY_BT || sce1->band_type[idx] == INTENSITY_BT2) {
+- const int bt_run_end = sce1->band_type_run_end[idx];
+- for (; i < bt_run_end; i++, idx++) {
+- c = -1 + 2 * (sce1->band_type[idx] - 14);
+- if (ms_present)
+- c *= 1 - 2 * cpe->ms_mask[idx];
+- scale = c * sce1->sf[idx];
+- for (group = 0; group < ics->group_len[g]; group++)
+- for (k = offsets[i]; k < offsets[i + 1]; k++)
+- coef1[group * 128 + k] = scale * coef0[group * 128 + k];
+- }
+- } else {
+- int bt_run_end = sce1->band_type_run_end[idx];
+- idx += bt_run_end - i;
+- i = bt_run_end;
+- }
+- }
+- coef0 += ics->group_len[g] * 128;
+- coef1 += ics->group_len[g] * 128;
+- }
+-}
+-
+-/**
+- * Decode a channel_pair_element; reference: table 4.4.
+- *
+- * @param elem_id Identifies the instance of a syntax element.
+- *
+- * @return Returns error status. 0 - OK, !0 - error
+- */
+-static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe)
+-{
+- int i, ret, common_window, ms_present = 0;
+-
+- common_window = get_bits1(gb);
+- if (common_window) {
+- if (decode_ics_info(ac, &cpe->ch[0].ics, gb, 1))
+- return -1;
+- i = cpe->ch[1].ics.use_kb_window[0];
+- cpe->ch[1].ics = cpe->ch[0].ics;
+- cpe->ch[1].ics.use_kb_window[1] = i;
+- ms_present = get_bits(gb, 2);
+- if (ms_present == 3) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "ms_present = 3 is reserved.\n");
+- return -1;
+- } else if (ms_present)
+- decode_mid_side_stereo(cpe, gb, ms_present);
+- }
+- if ((ret = decode_ics(ac, &cpe->ch[0], gb, common_window, 0)))
+- return ret;
+- if ((ret = decode_ics(ac, &cpe->ch[1], gb, common_window, 0)))
+- return ret;
+-
+- if (common_window) {
+- if (ms_present)
+- apply_mid_side_stereo(ac, cpe);
+- if (ac->m4ac.object_type == AOT_AAC_MAIN) {
+- apply_prediction(ac, &cpe->ch[0]);
+- apply_prediction(ac, &cpe->ch[1]);
+- }
+- }
+-
+- apply_intensity_stereo(cpe, ms_present);
+- return 0;
+-}
+-
+-/**
+- * Decode coupling_channel_element; reference: table 4.8.
+- *
+- * @param elem_id Identifies the instance of a syntax element.
+- *
+- * @return Returns error status. 0 - OK, !0 - error
+- */
+-static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che)
+-{
+- int num_gain = 0;
+- int c, g, sfb, ret;
+- int sign;
+- float scale;
+- SingleChannelElement *sce = &che->ch[0];
+- ChannelCoupling *coup = &che->coup;
+-
+- coup->coupling_point = 2 * get_bits1(gb);
+- coup->num_coupled = get_bits(gb, 3);
+- for (c = 0; c <= coup->num_coupled; c++) {
+- num_gain++;
+- coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE;
+- coup->id_select[c] = get_bits(gb, 4);
+- if (coup->type[c] == TYPE_CPE) {
+- coup->ch_select[c] = get_bits(gb, 2);
+- if (coup->ch_select[c] == 3)
+- num_gain++;
+- } else
+- coup->ch_select[c] = 2;
+- }
+- coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1);
+-
+- sign = get_bits(gb, 1);
+- scale = pow(2., pow(2., (int)get_bits(gb, 2) - 3));
+-
+- if ((ret = decode_ics(ac, sce, gb, 0, 0)))
+- return ret;
+-
+- for (c = 0; c < num_gain; c++) {
+- int idx = 0;
+- int cge = 1;
+- int gain = 0;
+- float gain_cache = 1.;
+- if (c) {
+- cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb);
+- gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0;
+- gain_cache = pow(scale, -gain);
+- }
+- if (coup->coupling_point == AFTER_IMDCT) {
+- coup->gain[c][0] = gain_cache;
+- } else {
+- for (g = 0; g < sce->ics.num_window_groups; g++) {
+- for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) {
+- if (sce->band_type[idx] != ZERO_BT) {
+- if (!cge) {
+- int t = get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
+- if (t) {
+- int s = 1;
+- t = gain += t;
+- if (sign) {
+- s -= 2 * (t & 0x1);
+- t >>= 1;
+- }
+- gain_cache = pow(scale, -t) * s;
+- }
+- }
+- coup->gain[c][idx] = gain_cache;
+- }
+- }
+- }
+- }
+- }
+- return 0;
+-}
+-
+-/**
+- * Parse whether channels are to be excluded from Dynamic Range Compression; reference: table 4.53.
+- *
+- * @return Returns number of bytes consumed.
+- */
+-static int decode_drc_channel_exclusions(DynamicRangeControl *che_drc,
+- GetBitContext *gb)
+-{
+- int i;
+- int num_excl_chan = 0;
+-
+- do {
+- for (i = 0; i < 7; i++)
+- che_drc->exclude_mask[num_excl_chan++] = get_bits1(gb);
+- } while (num_excl_chan < MAX_CHANNELS - 7 && get_bits1(gb));
+-
+- return num_excl_chan / 7;
+-}
+-
+-/**
+- * Decode dynamic range information; reference: table 4.52.
+- *
+- * @param cnt length of TYPE_FIL syntactic element in bytes
+- *
+- * @return Returns number of bytes consumed.
+- */
+-static int decode_dynamic_range(DynamicRangeControl *che_drc,
+- GetBitContext *gb, int cnt)
+-{
+- int n = 1;
+- int drc_num_bands = 1;
+- int i;
+-
+- /* pce_tag_present? */
+- if (get_bits1(gb)) {
+- che_drc->pce_instance_tag = get_bits(gb, 4);
+- skip_bits(gb, 4); // tag_reserved_bits
+- n++;
+- }
+-
+- /* excluded_chns_present? */
+- if (get_bits1(gb)) {
+- n += decode_drc_channel_exclusions(che_drc, gb);
+- }
+-
+- /* drc_bands_present? */
+- if (get_bits1(gb)) {
+- che_drc->band_incr = get_bits(gb, 4);
+- che_drc->interpolation_scheme = get_bits(gb, 4);
+- n++;
+- drc_num_bands += che_drc->band_incr;
+- for (i = 0; i < drc_num_bands; i++) {
+- che_drc->band_top[i] = get_bits(gb, 8);
+- n++;
+- }
+- }
+-
+- /* prog_ref_level_present? */
+- if (get_bits1(gb)) {
+- che_drc->prog_ref_level = get_bits(gb, 7);
+- skip_bits1(gb); // prog_ref_level_reserved_bits
+- n++;
+- }
+-
+- for (i = 0; i < drc_num_bands; i++) {
+- che_drc->dyn_rng_sgn[i] = get_bits1(gb);
+- che_drc->dyn_rng_ctl[i] = get_bits(gb, 7);
+- n++;
+- }
+-
+- return n;
+-}
+-
+-/**
+- * Decode extension data (incomplete); reference: table 4.51.
+- *
+- * @param cnt length of TYPE_FIL syntactic element in bytes
+- *
+- * @return Returns number of bytes consumed
+- */
+-static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt,
+- ChannelElement *che, enum RawDataBlockType elem_type)
+-{
+- int crc_flag = 0;
+- int res = cnt;
+- switch (get_bits(gb, 4)) { // extension type
+- case EXT_SBR_DATA_CRC:
+- crc_flag++;
+- case EXT_SBR_DATA:
+- if (!che) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "SBR was found before the first channel element.\n");
+- return res;
+- } else if (!ac->m4ac.sbr) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n");
+- skip_bits_long(gb, 8 * cnt - 4);
+- return res;
+- } else if (ac->m4ac.sbr == -1 && ac->output_configured == OC_LOCKED) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n");
+- skip_bits_long(gb, 8 * cnt - 4);
+- return res;
+- } else {
+- ac->m4ac.sbr = 1;
+- }
+- res = ff_decode_sbr_extension(ac, &che->sbr, gb, crc_flag, cnt, elem_type);
+- break;
+- case EXT_DYNAMIC_RANGE:
+- res = decode_dynamic_range(&ac->che_drc, gb, cnt);
+- break;
+- case EXT_FILL:
+- case EXT_FILL_DATA:
+- case EXT_DATA_ELEMENT:
+- default:
+- skip_bits_long(gb, 8 * cnt - 4);
+- break;
+- };
+- return res;
+-}
+-
+-/**
+- * Decode Temporal Noise Shaping filter coefficients and apply all-pole filters; reference: 4.6.9.3.
+- *
+- * @param decode 1 if tool is used normally, 0 if tool is used in LTP.
+- * @param coef spectral coefficients
+- */
+-static void apply_tns(float coef[1024], TemporalNoiseShaping *tns,
+- IndividualChannelStream *ics, int decode)
+-{
+- const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb);
+- int w, filt, m, i;
+- int bottom, top, order, start, end, size, inc;
+- float lpc[TNS_MAX_ORDER];
+-
+- for (w = 0; w < ics->num_windows; w++) {
+- bottom = ics->num_swb;
+- for (filt = 0; filt < tns->n_filt[w]; filt++) {
+- top = bottom;
+- bottom = FFMAX(0, top - tns->length[w][filt]);
+- order = tns->order[w][filt];
+- if (order == 0)
+- continue;
+-
+- // tns_decode_coef
+- compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0);
+-
+- start = ics->swb_offset[FFMIN(bottom, mmm)];
+- end = ics->swb_offset[FFMIN( top, mmm)];
+- if ((size = end - start) <= 0)
+- continue;
+- if (tns->direction[w][filt]) {
+- inc = -1;
+- start = end - 1;
+- } else {
+- inc = 1;
+- }
+- start += w * 128;
+-
+- // ar filter
+- for (m = 0; m < size; m++, start += inc)
+- for (i = 1; i <= FFMIN(m, order); i++)
+- coef[start] -= coef[start - i * inc] * lpc[i - 1];
+- }
+- }
+-}
+-
+-/**
+- * Conduct IMDCT and windowing.
+- */
+-static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce, float bias)
+-{
+- IndividualChannelStream *ics = &sce->ics;
+- float *in = sce->coeffs;
+- float *out = sce->ret;
+- float *saved = sce->saved;
+- const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128;
+- const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024;
+- const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128;
+- float *buf = ac->buf_mdct;
+- float *temp = ac->temp;
+- int i;
+-
+- // imdct
+- if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
+- if (ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE)
+- av_log(ac->avccontext, AV_LOG_WARNING,
+- "Transition from an ONLY_LONG or LONG_STOP to an EIGHT_SHORT sequence detected. "
+- "If you heard an audible artifact, please submit the sample to the FFmpeg developers.\n");
+- for (i = 0; i < 1024; i += 128)
+- ff_imdct_half(&ac->mdct_small, buf + i, in + i);
+- } else
+- ff_imdct_half(&ac->mdct, buf, in);
+-
+- /* window overlapping
+- * NOTE: To simplify the overlapping code, all 'meaningless' short to long
+- * and long to short transitions are considered to be short to short
+- * transitions. This leaves just two cases (long to long and short to short)
+- * with a little special sauce for EIGHT_SHORT_SEQUENCE.
+- */
+- if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) &&
+- (ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) {
+- ac->dsp.vector_fmul_window( out, saved, buf, lwindow_prev, bias, 512);
+- } else {
+- for (i = 0; i < 448; i++)
+- out[i] = saved[i] + bias;
+-
+- if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
+- ac->dsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, bias, 64);
+- ac->dsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, bias, 64);
+- ac->dsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, bias, 64);
+- ac->dsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, bias, 64);
+- ac->dsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, bias, 64);
+- memcpy( out + 448 + 4*128, temp, 64 * sizeof(float));
+- } else {
+- ac->dsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, bias, 64);
+- for (i = 576; i < 1024; i++)
+- out[i] = buf[i-512] + bias;
+- }
+- }
+-
+- // buffer update
+- if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
+- for (i = 0; i < 64; i++)
+- saved[i] = temp[64 + i] - bias;
+- ac->dsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 0, 64);
+- ac->dsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 0, 64);
+- ac->dsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 0, 64);
+- memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
+- } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) {
+- memcpy( saved, buf + 512, 448 * sizeof(float));
+- memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
+- } else { // LONG_STOP or ONLY_LONG
+- memcpy( saved, buf + 512, 512 * sizeof(float));
+- }
+-}
+-
+-/**
+- * Apply dependent channel coupling (applied before IMDCT).
+- *
+- * @param index index into coupling gain array
+- */
+-static void apply_dependent_coupling(AACContext *ac,
+- SingleChannelElement *target,
+- ChannelElement *cce, int index)
+-{
+- IndividualChannelStream *ics = &cce->ch[0].ics;
+- const uint16_t *offsets = ics->swb_offset;
+- float *dest = target->coeffs;
+- const float *src = cce->ch[0].coeffs;
+- int g, i, group, k, idx = 0;
+- if (ac->m4ac.object_type == AOT_AAC_LTP) {
+- av_log(ac->avccontext, AV_LOG_ERROR,
+- "Dependent coupling is not supported together with LTP\n");
+- return;
+- }
+- for (g = 0; g < ics->num_window_groups; g++) {
+- for (i = 0; i < ics->max_sfb; i++, idx++) {
+- if (cce->ch[0].band_type[idx] != ZERO_BT) {
+- const float gain = cce->coup.gain[index][idx];
+- for (group = 0; group < ics->group_len[g]; group++) {
+- for (k = offsets[i]; k < offsets[i + 1]; k++) {
+- // XXX dsputil-ize
+- dest[group * 128 + k] += gain * src[group * 128 + k];
+- }
+- }
+- }
+- }
+- dest += ics->group_len[g] * 128;
+- src += ics->group_len[g] * 128;
+- }
+-}
+-
+-/**
+- * Apply independent channel coupling (applied after IMDCT).
+- *
+- * @param index index into coupling gain array
+- */
+-static void apply_independent_coupling(AACContext *ac,
+- SingleChannelElement *target,
+- ChannelElement *cce, int index)
+-{
+- int i;
+- const float gain = cce->coup.gain[index][0];
+- const float bias = ac->add_bias;
+- const float *src = cce->ch[0].ret;
+- float *dest = target->ret;
+- const int len = 1024 << (ac->m4ac.sbr == 1);
+-
+- for (i = 0; i < len; i++)
+- dest[i] += gain * (src[i] - bias);
+-}
+-
+-/**
+- * channel coupling transformation interface
+- *
+- * @param index index into coupling gain array
+- * @param apply_coupling_method pointer to (in)dependent coupling function
+- */
+-static void apply_channel_coupling(AACContext *ac, ChannelElement *cc,
+- enum RawDataBlockType type, int elem_id,
+- enum CouplingPoint coupling_point,
+- void (*apply_coupling_method)(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index))
+-{
+- int i, c;
+-
+- for (i = 0; i < MAX_ELEM_ID; i++) {
+- ChannelElement *cce = ac->che[TYPE_CCE][i];
+- int index = 0;
+-
+- if (cce && cce->coup.coupling_point == coupling_point) {
+- ChannelCoupling *coup = &cce->coup;
+-
+- for (c = 0; c <= coup->num_coupled; c++) {
+- if (coup->type[c] == type && coup->id_select[c] == elem_id) {
+- if (coup->ch_select[c] != 1) {
+- apply_coupling_method(ac, &cc->ch[0], cce, index);
+- if (coup->ch_select[c] != 0)
+- index++;
+- }
+- if (coup->ch_select[c] != 2)
+- apply_coupling_method(ac, &cc->ch[1], cce, index++);
+- } else
+- index += 1 + (coup->ch_select[c] == 3);
+- }
+- }
+- }
+-}
+-
+-/**
+- * Convert spectral data to float samples, applying all supported tools as appropriate.
+- */
+-static void spectral_to_sample(AACContext *ac)
+-{
+- int i, type;
+- float imdct_bias = (ac->m4ac.sbr <= 0) ? ac->add_bias : 0.0f;
+- for (type = 3; type >= 0; type--) {
+- for (i = 0; i < MAX_ELEM_ID; i++) {
+- ChannelElement *che = ac->che[type][i];
+- if (che) {
+- if (type <= TYPE_CPE)
+- apply_channel_coupling(ac, che, type, i, BEFORE_TNS, apply_dependent_coupling);
+- if (che->ch[0].tns.present)
+- apply_tns(che->ch[0].coeffs, &che->ch[0].tns, &che->ch[0].ics, 1);
+- if (che->ch[1].tns.present)
+- apply_tns(che->ch[1].coeffs, &che->ch[1].tns, &che->ch[1].ics, 1);
+- if (type <= TYPE_CPE)
+- apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling);
+- if (type != TYPE_CCE || che->coup.coupling_point == AFTER_IMDCT) {
+- imdct_and_windowing(ac, &che->ch[0], imdct_bias);
+- if (type == TYPE_CPE) {
+- imdct_and_windowing(ac, &che->ch[1], imdct_bias);
+- }
+- if (ac->m4ac.sbr > 0) {
+- ff_sbr_apply(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret);
+- }
+- }
+- if (type <= TYPE_CCE)
+- apply_channel_coupling(ac, che, type, i, AFTER_IMDCT, apply_independent_coupling);
+- }
+- }
+- }
+-}
+-
+-static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
+-{
+- int size;
+- AACADTSHeaderInfo hdr_info;
+-
+- size = ff_aac_parse_header(gb, &hdr_info);
+- if (size > 0) {
+- if (ac->output_configured != OC_LOCKED && hdr_info.chan_config) {
+- enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
+- memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
+- ac->m4ac.chan_config = hdr_info.chan_config;
+- if (set_default_channel_config(ac, new_che_pos, hdr_info.chan_config))
+- return -7;
+- if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, OC_TRIAL_FRAME))
+- return -7;
+- } else if (ac->output_configured != OC_LOCKED) {
+- ac->output_configured = OC_NONE;
+- }
+- if (ac->output_configured != OC_LOCKED)
+- ac->m4ac.sbr = -1;
+- ac->m4ac.sample_rate = hdr_info.sample_rate;
+- ac->m4ac.sampling_index = hdr_info.sampling_index;
+- ac->m4ac.object_type = hdr_info.object_type;
+- if (!ac->avccontext->sample_rate)
+- ac->avccontext->sample_rate = hdr_info.sample_rate;
+- if (hdr_info.num_aac_frames == 1) {
+- if (!hdr_info.crc_absent)
+- skip_bits(gb, 16);
+- } else {
+- av_log_missing_feature(ac->avccontext, "More than one AAC RDB per ADTS frame is", 0);
+- return -1;
+- }
+- }
+- return size;
+-}
+-
+-static int aac_decode_frame(AVCodecContext *avccontext, void *data,
+- int *data_size, AVPacket *avpkt)
+-{
+- const uint8_t *buf = avpkt->data;
+- int buf_size = avpkt->size;
+- AACContext *ac = avccontext->priv_data;
+- ChannelElement *che = NULL, *che_prev = NULL;
+- GetBitContext gb;
+- enum RawDataBlockType elem_type, elem_type_prev = TYPE_END;
+- int err, elem_id, data_size_tmp;
+- int buf_consumed;
+- int samples = 1024, multiplier;
+- int buf_offset;
+-
+- init_get_bits(&gb, buf, buf_size * 8);
+-
+- if (show_bits(&gb, 12) == 0xfff) {
+- if (parse_adts_frame_header(ac, &gb) < 0) {
+- av_log(avccontext, AV_LOG_ERROR, "Error decoding AAC frame header.\n");
+- return -1;
+- }
+- if (ac->m4ac.sampling_index > 12) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index);
+- return -1;
+- }
+- }
+-
+- // parse
+- while ((elem_type = get_bits(&gb, 3)) != TYPE_END) {
+- elem_id = get_bits(&gb, 4);
+-
+- if (elem_type < TYPE_DSE && !(che=get_che(ac, elem_type, elem_id))) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", elem_type, elem_id);
+- return -1;
+- }
+-
+- switch (elem_type) {
+-
+- case TYPE_SCE:
+- err = decode_ics(ac, &che->ch[0], &gb, 0, 0);
+- break;
+-
+- case TYPE_CPE:
+- err = decode_cpe(ac, &gb, che);
+- break;
+-
+- case TYPE_CCE:
+- err = decode_cce(ac, &gb, che);
+- break;
+-
+- case TYPE_LFE:
+- err = decode_ics(ac, &che->ch[0], &gb, 0, 0);
+- break;
+-
+- case TYPE_DSE:
+- err = skip_data_stream_element(ac, &gb);
+- break;
+-
+- case TYPE_PCE: {
+- enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
+- memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
+- if ((err = decode_pce(ac, new_che_pos, &gb)))
+- break;
+- if (ac->output_configured > OC_TRIAL_PCE)
+- av_log(avccontext, AV_LOG_ERROR,
+- "Not evaluating a further program_config_element as this construct is dubious at best.\n");
+- else
+- err = output_configure(ac, ac->che_pos, new_che_pos, 0, OC_TRIAL_PCE);
+- break;
+- }
+-
+- case TYPE_FIL:
+- if (elem_id == 15)
+- elem_id += get_bits(&gb, 8) - 1;
+- if (get_bits_left(&gb) < 8 * elem_id) {
+- av_log(avccontext, AV_LOG_ERROR, overread_err);
+- return -1;
+- }
+- while (elem_id > 0)
+- elem_id -= decode_extension_payload(ac, &gb, elem_id, che_prev, elem_type_prev);
+- err = 0; /* FIXME */
+- break;
+-
+- default:
+- err = -1; /* should not happen, but keeps compiler happy */
+- break;
+- }
+-
+- che_prev = che;
+- elem_type_prev = elem_type;
+-
+- if (err)
+- return err;
+-
+- if (get_bits_left(&gb) < 3) {
+- av_log(avccontext, AV_LOG_ERROR, overread_err);
+- return -1;
+- }
+- }
+-
+- spectral_to_sample(ac);
+-
+- multiplier = (ac->m4ac.sbr == 1) ? ac->m4ac.ext_sample_rate > ac->m4ac.sample_rate : 0;
+- samples <<= multiplier;
+- if (ac->output_configured < OC_LOCKED) {
+- avccontext->sample_rate = ac->m4ac.sample_rate << multiplier;
+- avccontext->frame_size = samples;
+- }
+-
+- data_size_tmp = samples * avccontext->channels * sizeof(int16_t);
+- if (*data_size < data_size_tmp) {
+- av_log(avccontext, AV_LOG_ERROR,
+- "Output buffer too small (%d) or trying to output too many samples (%d) for this frame.\n",
+- *data_size, data_size_tmp);
+- return -1;
+- }
+- *data_size = data_size_tmp;
+-
+- ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avccontext->channels);
+-
+- if (ac->output_configured)
+- ac->output_configured = OC_LOCKED;
+-
+- buf_consumed = (get_bits_count(&gb) + 7) >> 3;
+- for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++)
+- if (buf[buf_offset])
+- break;
+-
+- return buf_size > buf_offset ? buf_consumed : buf_size;
+-}
+-
+-static av_cold int aac_decode_close(AVCodecContext *avccontext)
+-{
+- AACContext *ac = avccontext->priv_data;
+- int i, type;
+-
+- for (i = 0; i < MAX_ELEM_ID; i++) {
+- for (type = 0; type < 4; type++) {
+- if (ac->che[type][i])
+- ff_aac_sbr_ctx_close(&ac->che[type][i]->sbr);
+- av_freep(&ac->che[type][i]);
+- }
+- }
+-
+- ff_mdct_end(&ac->mdct);
+- ff_mdct_end(&ac->mdct_small);
+- return 0;
+-}
+-
+-AVCodec aac_decoder = {
+- "aac",
+- AVMEDIA_TYPE_AUDIO,
+- CODEC_ID_AAC,
+- sizeof(AACContext),
+- aac_decode_init,
+- NULL,
+- aac_decode_close,
+- aac_decode_frame,
+- .long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"),
+- .sample_fmts = (const enum SampleFormat[]) {
+- SAMPLE_FMT_S16,SAMPLE_FMT_NONE
+- },
+- .channel_layouts = aac_channel_layout,
+-};
+--- a/libavcodec/aacenc.c
++++ b/libavcodec/aacenc.c
+@@ -201,13 +201,11 @@ static av_cold int aac_encode_init(AVCod
+ lengths[1] = ff_aac_num_swb_128[i];
+ ff_psy_init(&s->psy, avctx, 2, sizes, lengths);
+ s->psypp = ff_psy_preprocess_init(avctx);
+- s->coder = &ff_aac_coders[0];
++ s->coder = &ff_aac_coders[2];
+
+ s->lambda = avctx->global_quality ? avctx->global_quality : 120;
+-#if !CONFIG_HARDCODED_TABLES
+- for (i = 0; i < 428; i++)
+- ff_aac_pow2sf_tab[i] = pow(2, (i - 200)/4.);
+-#endif /* CONFIG_HARDCODED_TABLES */
++
++ ff_aac_tableinit();
+
+ if (avctx->channels > 5)
+ av_log(avctx, AV_LOG_ERROR, "This encoder does not yet enforce the restrictions on LFEs. "
+@@ -234,25 +232,21 @@ static void apply_window_and_mdct(AVCode
+ s->output[i] = sce->saved[i];
+ }
+ if (sce->ics.window_sequence[0] != LONG_START_SEQUENCE) {
+- j = channel;
+- for (i = 0; i < 1024; i++, j += avctx->channels) {
++ for (i = 0, j = channel; i < 1024; i++, j += avctx->channels) {
+ s->output[i+1024] = audio[j] * lwindow[1024 - i - 1];
+ sce->saved[i] = audio[j] * lwindow[i];
+ }
+ } else {
+- j = channel;
+- for (i = 0; i < 448; i++, j += avctx->channels)
++ for (i = 0, j = channel; i < 448; i++, j += avctx->channels)
+ s->output[i+1024] = audio[j];
+- for (i = 448; i < 576; i++, j += avctx->channels)
++ for (; i < 576; i++, j += avctx->channels)
+ s->output[i+1024] = audio[j] * swindow[576 - i - 1];
+ memset(s->output+1024+576, 0, sizeof(s->output[0]) * 448);
+- j = channel;
+- for (i = 0; i < 1024; i++, j += avctx->channels)
++ for (i = 0, j = channel; i < 1024; i++, j += avctx->channels)
+ sce->saved[i] = audio[j];
+ }
+ ff_mdct_calc(&s->mdct1024, sce->coeffs, s->output);
+ } else {
+- j = channel;
+ for (k = 0; k < 1024; k += 128) {
+ for (i = 448 + k; i < 448 + k + 256; i++)
+ s->output[i - 448 - k] = (i < 1024)
+@@ -262,8 +256,7 @@ static void apply_window_and_mdct(AVCode
+ s->dsp.vector_fmul_reverse(s->output+128, s->output+128, swindow, 128);
+ ff_mdct_calc(&s->mdct128, sce->coeffs + k, s->output);
+ }
+- j = channel;
+- for (i = 0; i < 1024; i++, j += avctx->channels)
++ for (i = 0, j = channel; i < 1024; i++, j += avctx->channels)
+ sce->saved[i] = audio[j];
+ }
+ }
+@@ -562,6 +555,7 @@ static int aac_encode_frame(AVCodecConte
+ cpe = &s->cpe[i];
+ for (j = 0; j < chans; j++) {
+ s->cur_channel = start_ch + j;
++ ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[j].coeffs, &wi[j]);
+ s->coder->search_for_quantizers(avctx, s, &cpe->ch[j], s->lambda);
+ }
+ cpe->common_window = 0;
+@@ -592,7 +586,6 @@ static int aac_encode_frame(AVCodecConte
+ }
+ for (j = 0; j < chans; j++) {
+ s->cur_channel = start_ch + j;
+- ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[j].coeffs, &wi[j]);
+ encode_individual_channel(avctx, s, &cpe->ch[j], cpe->common_window);
+ }
+ start_ch += chans;
+--- a/libavcodec/aacenc.h
++++ b/libavcodec/aacenc.h
+@@ -64,7 +64,7 @@ typedef struct AACEncContext {
+ int cur_channel;
+ int last_frame;
+ float lambda;
+- DECLARE_ALIGNED(16, int, qcoefs)[96][2]; ///< quantized coefficients
++ DECLARE_ALIGNED(16, int, qcoefs)[96]; ///< quantized coefficients
+ DECLARE_ALIGNED(16, float, scoefs)[1024]; ///< scaled coefficients
+ } AACEncContext;
+
+--- /dev/null
++++ b/libavcodec/aacdec.c
+@@ -0,0 +1,2142 @@
++/*
++ * AAC decoder
++ * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
++ * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com )
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++/**
++ * @file
++ * AAC decoder
++ * @author Oded Shimon ( ods15 ods15 dyndns org )
++ * @author Maxim Gavrilov ( maxim.gavrilov gmail com )
++ */
++
++/*
++ * supported tools
++ *
++ * Support? Name
++ * N (code in SoC repo) gain control
++ * Y block switching
++ * Y window shapes - standard
++ * N window shapes - Low Delay
++ * Y filterbank - standard
++ * N (code in SoC repo) filterbank - Scalable Sample Rate
++ * Y Temporal Noise Shaping
++ * N (code in SoC repo) Long Term Prediction
++ * Y intensity stereo
++ * Y channel coupling
++ * Y frequency domain prediction
++ * Y Perceptual Noise Substitution
++ * Y Mid/Side stereo
++ * N Scalable Inverse AAC Quantization
++ * N Frequency Selective Switch
++ * N upsampling filter
++ * Y quantization & coding - AAC
++ * N quantization & coding - TwinVQ
++ * N quantization & coding - BSAC
++ * N AAC Error Resilience tools
++ * N Error Resilience payload syntax
++ * N Error Protection tool
++ * N CELP
++ * N Silence Compression
++ * N HVXC
++ * N HVXC 4kbits/s VR
++ * N Structured Audio tools
++ * N Structured Audio Sample Bank Format
++ * N MIDI
++ * N Harmonic and Individual Lines plus Noise
++ * N Text-To-Speech Interface
++ * Y Spectral Band Replication
++ * Y (not in this code) Layer-1
++ * Y (not in this code) Layer-2
++ * Y (not in this code) Layer-3
++ * N SinuSoidal Coding (Transient, Sinusoid, Noise)
++ * Y Parametric Stereo
++ * N Direct Stream Transfer
++ *
++ * Note: - HE AAC v1 comprises LC AAC with Spectral Band Replication.
++ * - HE AAC v2 comprises LC AAC with Spectral Band Replication and
++ Parametric Stereo.
++ */
++
++
++#include "avcodec.h"
++#include "internal.h"
++#include "get_bits.h"
++#include "dsputil.h"
++#include "fft.h"
++#include "lpc.h"
++
++#include "aac.h"
++#include "aactab.h"
++#include "aacdectab.h"
++#include "cbrt_tablegen.h"
++#include "sbr.h"
++#include "aacsbr.h"
++#include "mpeg4audio.h"
++#include "aac_parser.h"
++
++#include
++#include
++#include
++#include
++
++#if ARCH_ARM
++# include "arm/aac.h"
++#endif
++
++union float754 {
++ float f;
++ uint32_t i;
++};
++
++static VLC vlc_scalefactors;
++static VLC vlc_spectral[11];
++
++static const char overread_err[] = "Input buffer exhausted before END element found\n";
++
++static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
++{
++ /* Some buggy encoders appear to set all elem_ids to zero and rely on
++ channels always occurring in the same order. This is expressly forbidden
++ by the spec but we will try to work around it.
++ */
++ int err_printed = 0;
++ while (ac->tags_seen_this_frame[type][elem_id] && elem_id < MAX_ELEM_ID) {
++ if (ac->output_configured < OC_LOCKED && !err_printed) {
++ av_log(ac->avctx, AV_LOG_WARNING, "Duplicate channel tag found, attempting to remap.\n");
++ err_printed = 1;
++ }
++ elem_id++;
++ }
++ if (elem_id == MAX_ELEM_ID)
++ return NULL;
++ ac->tags_seen_this_frame[type][elem_id] = 1;
++
++ if (ac->tag_che_map[type][elem_id]) {
++ return ac->tag_che_map[type][elem_id];
++ }
++ if (ac->tags_mapped >= tags_per_config[ac->m4ac.chan_config]) {
++ return NULL;
++ }
++ switch (ac->m4ac.chan_config) {
++ case 7:
++ if (ac->tags_mapped == 3 && type == TYPE_CPE) {
++ ac->tags_mapped++;
++ return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2];
++ }
++ case 6:
++ /* Some streams incorrectly code 5.1 audio as SCE[0] CPE[0] CPE[1] SCE[1]
++ instead of SCE[0] CPE[0] CPE[1] LFE[0]. If we seem to have
++ encountered such a stream, transfer the LFE[0] element to the SCE[1]'s mapping */
++ if (ac->tags_mapped == tags_per_config[ac->m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) {
++ ac->tags_mapped++;
++ return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0];
++ }
++ case 5:
++ if (ac->tags_mapped == 2 && type == TYPE_CPE) {
++ ac->tags_mapped++;
++ return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1];
++ }
++ case 4:
++ if (ac->tags_mapped == 2 && ac->m4ac.chan_config == 4 && type == TYPE_SCE) {
++ ac->tags_mapped++;
++ return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
++ }
++ case 3:
++ case 2:
++ if (ac->tags_mapped == (ac->m4ac.chan_config != 2) && type == TYPE_CPE) {
++ ac->tags_mapped++;
++ return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0];
++ } else if (ac->m4ac.chan_config == 2) {
++ return NULL;
++ }
++ case 1:
++ if (!ac->tags_mapped && type == TYPE_SCE) {
++ ac->tags_mapped++;
++ return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][0];
++ }
++ default:
++ return NULL;
++ }
++}
++
++/**
++ * Check for the channel element in the current channel position configuration.
++ * If it exists, make sure the appropriate element is allocated and map the
++ * channel order to match the internal FFmpeg channel layout.
++ *
++ * @param che_pos current channel position configuration
++ * @param type channel element type
++ * @param id channel element id
++ * @param channels count of the number of channels in the configuration
++ *
++ * @return Returns error status. 0 - OK, !0 - error
++ */
++static av_cold int che_configure(AACContext *ac,
++ enum ChannelPosition che_pos[4][MAX_ELEM_ID],
++ int type, int id,
++ int *channels)
++{
++ if (che_pos[type][id]) {
++ if (!ac->che[type][id] && !(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
++ return AVERROR(ENOMEM);
++ ff_aac_sbr_ctx_init(&ac->che[type][id]->sbr);
++ if (type != TYPE_CCE) {
++ ac->output_data[(*channels)++] = ac->che[type][id]->ch[0].ret;
++ if (type == TYPE_CPE ||
++ (type == TYPE_SCE && ac->m4ac.ps == 1)) {
++ ac->output_data[(*channels)++] = ac->che[type][id]->ch[1].ret;
++ }
++ }
++ } else {
++ if (ac->che[type][id])
++ ff_aac_sbr_ctx_close(&ac->che[type][id]->sbr);
++ av_freep(&ac->che[type][id]);
++ }
++ return 0;
++}
++
++/**
++ * Configure output channel order based on the current program configuration element.
++ *
++ * @param che_pos current channel position configuration
++ * @param new_che_pos New channel position configuration - we only do something if it differs from the current one.
++ *
++ * @return Returns error status. 0 - OK, !0 - error
++ */
++static av_cold int output_configure(AACContext *ac,
++ enum ChannelPosition che_pos[4][MAX_ELEM_ID],
++ enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
++ int channel_config, enum OCStatus oc_type)
++{
++ AVCodecContext *avctx = ac->avctx;
++ int i, type, channels = 0, ret;
++
++ if (new_che_pos != che_pos)
++ memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
++
++ if (channel_config) {
++ for (i = 0; i < tags_per_config[channel_config]; i++) {
++ if ((ret = che_configure(ac, che_pos,
++ aac_channel_layout_map[channel_config - 1][i][0],
++ aac_channel_layout_map[channel_config - 1][i][1],
++ &channels)))
++ return ret;
++ }
++
++ memset(ac->tag_che_map, 0, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
++ ac->tags_mapped = 0;
++
++ avctx->channel_layout = aac_channel_layout[channel_config - 1];
++ } else {
++ /* Allocate or free elements depending on if they are in the
++ * current program configuration.
++ *
++ * Set up default 1:1 output mapping.
++ *
++ * For a 5.1 stream the output order will be:
++ * [ Center ] [ Front Left ] [ Front Right ] [ LFE ] [ Surround Left ] [ Surround Right ]
++ */
++
++ for (i = 0; i < MAX_ELEM_ID; i++) {
++ for (type = 0; type < 4; type++) {
++ if ((ret = che_configure(ac, che_pos, type, i, &channels)))
++ return ret;
++ }
++ }
++
++ memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
++ ac->tags_mapped = 4 * MAX_ELEM_ID;
++
++ avctx->channel_layout = 0;
++ }
++
++ avctx->channels = channels;
++
++ ac->output_configured = oc_type;
++
++ return 0;
++}
++
++/**
++ * Decode an array of 4 bit element IDs, optionally interleaved with a stereo/mono switching bit.
++ *
++ * @param cpe_map Stereo (Channel Pair Element) map, NULL if stereo bit is not present.
++ * @param sce_map mono (Single Channel Element) map
++ * @param type speaker type/position for these channels
++ */
++static void decode_channel_map(enum ChannelPosition *cpe_map,
++ enum ChannelPosition *sce_map,
++ enum ChannelPosition type,
++ GetBitContext *gb, int n)
++{
++ while (n--) {
++ enum ChannelPosition *map = cpe_map && get_bits1(gb) ? cpe_map : sce_map; // stereo or mono map
++ map[get_bits(gb, 4)] = type;
++ }
++}
++
++/**
++ * Decode program configuration element; reference: table 4.2.
++ *
++ * @param new_che_pos New channel position configuration - we only do something if it differs from the current one.
++ *
++ * @return Returns error status. 0 - OK, !0 - error
++ */
++static int decode_pce(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
++ GetBitContext *gb)
++{
++ int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc, sampling_index;
++ int comment_len;
++
++ skip_bits(gb, 2); // object_type
++
++ sampling_index = get_bits(gb, 4);
++ if (ac->m4ac.sampling_index != sampling_index)
++ av_log(ac->avctx, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n");
++
++ num_front = get_bits(gb, 4);
++ num_side = get_bits(gb, 4);
++ num_back = get_bits(gb, 4);
++ num_lfe = get_bits(gb, 2);
++ num_assoc_data = get_bits(gb, 3);
++ num_cc = get_bits(gb, 4);
++
++ if (get_bits1(gb))
++ skip_bits(gb, 4); // mono_mixdown_tag
++ if (get_bits1(gb))
++ skip_bits(gb, 4); // stereo_mixdown_tag
++
++ if (get_bits1(gb))
++ skip_bits(gb, 3); // mixdown_coeff_index and pseudo_surround
++
++ decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_FRONT, gb, num_front);
++ decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_SIDE, gb, num_side );
++ decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_BACK, gb, num_back );
++ decode_channel_map(NULL, new_che_pos[TYPE_LFE], AAC_CHANNEL_LFE, gb, num_lfe );
++
++ skip_bits_long(gb, 4 * num_assoc_data);
++
++ decode_channel_map(new_che_pos[TYPE_CCE], new_che_pos[TYPE_CCE], AAC_CHANNEL_CC, gb, num_cc );
++
++ align_get_bits(gb);
++
++ /* comment field, first byte is length */
++ comment_len = get_bits(gb, 8) * 8;
++ if (get_bits_left(gb) < comment_len) {
++ av_log(ac->avctx, AV_LOG_ERROR, overread_err);
++ return -1;
++ }
++ skip_bits_long(gb, comment_len);
++ return 0;
++}
++
++/**
++ * Set up channel positions based on a default channel configuration
++ * as specified in table 1.17.
++ *
++ * @param new_che_pos New channel position configuration - we only do something if it differs from the current one.
++ *
++ * @return Returns error status. 0 - OK, !0 - error
++ */
++static av_cold int set_default_channel_config(AACContext *ac,
++ enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
++ int channel_config)
++{
++ if (channel_config < 1 || channel_config > 7) {
++ av_log(ac->avctx, AV_LOG_ERROR, "invalid default channel configuration (%d)\n",
++ channel_config);
++ return -1;
++ }
++
++ /* default channel configurations:
++ *
++ * 1ch : front center (mono)
++ * 2ch : L + R (stereo)
++ * 3ch : front center + L + R
++ * 4ch : front center + L + R + back center
++ * 5ch : front center + L + R + back stereo
++ * 6ch : front center + L + R + back stereo + LFE
++ * 7ch : front center + L + R + outer front left + outer front right + back stereo + LFE
++ */
++
++ if (channel_config != 2)
++ new_che_pos[TYPE_SCE][0] = AAC_CHANNEL_FRONT; // front center (or mono)
++ if (channel_config > 1)
++ new_che_pos[TYPE_CPE][0] = AAC_CHANNEL_FRONT; // L + R (or stereo)
++ if (channel_config == 4)
++ new_che_pos[TYPE_SCE][1] = AAC_CHANNEL_BACK; // back center
++ if (channel_config > 4)
++ new_che_pos[TYPE_CPE][(channel_config == 7) + 1]
++ = AAC_CHANNEL_BACK; // back stereo
++ if (channel_config > 5)
++ new_che_pos[TYPE_LFE][0] = AAC_CHANNEL_LFE; // LFE
++ if (channel_config == 7)
++ new_che_pos[TYPE_CPE][1] = AAC_CHANNEL_FRONT; // outer front left + outer front right
++
++ return 0;
++}
++
++/**
++ * Decode GA "General Audio" specific configuration; reference: table 4.1.
++ *
++ * @return Returns error status. 0 - OK, !0 - error
++ */
++static int decode_ga_specific_config(AACContext *ac, GetBitContext *gb,
++ int channel_config)
++{
++ enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
++ int extension_flag, ret;
++
++ if (get_bits1(gb)) { // frameLengthFlag
++ av_log_missing_feature(ac->avctx, "960/120 MDCT window is", 1);
++ return -1;
++ }
++
++ if (get_bits1(gb)) // dependsOnCoreCoder
++ skip_bits(gb, 14); // coreCoderDelay
++ extension_flag = get_bits1(gb);
++
++ if (ac->m4ac.object_type == AOT_AAC_SCALABLE ||
++ ac->m4ac.object_type == AOT_ER_AAC_SCALABLE)
++ skip_bits(gb, 3); // layerNr
++
++ memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
++ if (channel_config == 0) {
++ skip_bits(gb, 4); // element_instance_tag
++ if ((ret = decode_pce(ac, new_che_pos, gb)))
++ return ret;
++ } else {
++ if ((ret = set_default_channel_config(ac, new_che_pos, channel_config)))
++ return ret;
++ }
++ if ((ret = output_configure(ac, ac->che_pos, new_che_pos, channel_config, OC_GLOBAL_HDR)))
++ return ret;
++
++ if (extension_flag) {
++ switch (ac->m4ac.object_type) {
++ case AOT_ER_BSAC:
++ skip_bits(gb, 5); // numOfSubFrame
++ skip_bits(gb, 11); // layer_length
++ break;
++ case AOT_ER_AAC_LC:
++ case AOT_ER_AAC_LTP:
++ case AOT_ER_AAC_SCALABLE:
++ case AOT_ER_AAC_LD:
++ skip_bits(gb, 3); /* aacSectionDataResilienceFlag
++ * aacScalefactorDataResilienceFlag
++ * aacSpectralDataResilienceFlag
++ */
++ break;
++ }
++ skip_bits1(gb); // extensionFlag3 (TBD in version 3)
++ }
++ return 0;
++}
++
++/**
++ * Decode audio specific configuration; reference: table 1.13.
++ *
++ * @param data pointer to AVCodecContext extradata
++ * @param data_size size of AVCCodecContext extradata
++ *
++ * @return Returns error status. 0 - OK, !0 - error
++ */
++static int decode_audio_specific_config(AACContext *ac, void *data,
++ int data_size)
++{
++ GetBitContext gb;
++ int i;
++
++ init_get_bits(&gb, data, data_size * 8);
++
++ if ((i = ff_mpeg4audio_get_config(&ac->m4ac, data, data_size)) < 0)
++ return -1;
++ if (ac->m4ac.sampling_index > 12) {
++ av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index);
++ return -1;
++ }
++ if (ac->m4ac.sbr == 1 && ac->m4ac.ps == -1)
++ ac->m4ac.ps = 1;
++
++ skip_bits_long(&gb, i);
++
++ switch (ac->m4ac.object_type) {
++ case AOT_AAC_MAIN:
++ case AOT_AAC_LC:
++ if (decode_ga_specific_config(ac, &gb, ac->m4ac.chan_config))
++ return -1;
++ break;
++ default:
++ av_log(ac->avctx, AV_LOG_ERROR, "Audio object type %s%d is not supported.\n",
++ ac->m4ac.sbr == 1? "SBR+" : "", ac->m4ac.object_type);
++ return -1;
++ }
++ return 0;
++}
++
++/**
++ * linear congruential pseudorandom number generator
++ *
++ * @param previous_val pointer to the current state of the generator
++ *
++ * @return Returns a 32-bit pseudorandom integer
++ */
++static av_always_inline int lcg_random(int previous_val)
++{
++ return previous_val * 1664525 + 1013904223;
++}
++
++static av_always_inline void reset_predict_state(PredictorState *ps)
++{
++ ps->r0 = 0.0f;
++ ps->r1 = 0.0f;
++ ps->cor0 = 0.0f;
++ ps->cor1 = 0.0f;
++ ps->var0 = 1.0f;
++ ps->var1 = 1.0f;
++}
++
++static void reset_all_predictors(PredictorState *ps)
++{
++ int i;
++ for (i = 0; i < MAX_PREDICTORS; i++)
++ reset_predict_state(&ps[i]);
++}
++
++static void reset_predictor_group(PredictorState *ps, int group_num)
++{
++ int i;
++ for (i = group_num - 1; i < MAX_PREDICTORS; i += 30)
++ reset_predict_state(&ps[i]);
++}
++
++#define AAC_INIT_VLC_STATIC(num, size) \
++ INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \
++ ff_aac_spectral_bits[num], sizeof( ff_aac_spectral_bits[num][0]), sizeof( ff_aac_spectral_bits[num][0]), \
++ ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \
++ size);
++
++static av_cold int aac_decode_init(AVCodecContext *avctx)
++{
++ AACContext *ac = avctx->priv_data;
++
++ ac->avctx = avctx;
++ ac->m4ac.sample_rate = avctx->sample_rate;
++
++ if (avctx->extradata_size > 0) {
++ if (decode_audio_specific_config(ac, avctx->extradata, avctx->extradata_size))
++ return -1;
++ }
++
++ avctx->sample_fmt = SAMPLE_FMT_S16;
++
++ AAC_INIT_VLC_STATIC( 0, 304);
++ AAC_INIT_VLC_STATIC( 1, 270);
++ AAC_INIT_VLC_STATIC( 2, 550);
++ AAC_INIT_VLC_STATIC( 3, 300);
++ AAC_INIT_VLC_STATIC( 4, 328);
++ AAC_INIT_VLC_STATIC( 5, 294);
++ AAC_INIT_VLC_STATIC( 6, 306);
++ AAC_INIT_VLC_STATIC( 7, 268);
++ AAC_INIT_VLC_STATIC( 8, 510);
++ AAC_INIT_VLC_STATIC( 9, 366);
++ AAC_INIT_VLC_STATIC(10, 462);
++
++ ff_aac_sbr_init();
++
++ dsputil_init(&ac->dsp, avctx);
++
++ ac->random_state = 0x1f2e3d4c;
++
++ // -1024 - Compensate wrong IMDCT method.
++ // 32768 - Required to scale values to the correct range for the bias method
++ // for float to int16 conversion.
++
++ if (ac->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) {
++ ac->add_bias = 385.0f;
++ ac->sf_scale = 1. / (-1024. * 32768.);
++ ac->sf_offset = 0;
++ } else {
++ ac->add_bias = 0.0f;
++ ac->sf_scale = 1. / -1024.;
++ ac->sf_offset = 60;
++ }
++
++ ff_aac_tableinit();
++
++ INIT_VLC_STATIC(&vlc_scalefactors,7,FF_ARRAY_ELEMS(ff_aac_scalefactor_code),
++ ff_aac_scalefactor_bits, sizeof(ff_aac_scalefactor_bits[0]), sizeof(ff_aac_scalefactor_bits[0]),
++ ff_aac_scalefactor_code, sizeof(ff_aac_scalefactor_code[0]), sizeof(ff_aac_scalefactor_code[0]),
++ 352);
++
++ ff_mdct_init(&ac->mdct, 11, 1, 1.0);
++ ff_mdct_init(&ac->mdct_small, 8, 1, 1.0);
++ // window initialization
++ ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
++ ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
++ ff_init_ff_sine_windows(10);
++ ff_init_ff_sine_windows( 7);
++
++ cbrt_tableinit();
++
++ return 0;
++}
++
++/**
++ * Skip data_stream_element; reference: table 4.10.
++ */
++static int skip_data_stream_element(AACContext *ac, GetBitContext *gb)
++{
++ int byte_align = get_bits1(gb);
++ int count = get_bits(gb, 8);
++ if (count == 255)
++ count += get_bits(gb, 8);
++ if (byte_align)
++ align_get_bits(gb);
++
++ if (get_bits_left(gb) < 8 * count) {
++ av_log(ac->avctx, AV_LOG_ERROR, overread_err);
++ return -1;
++ }
++ skip_bits_long(gb, 8 * count);
++ return 0;
++}
++
++static int decode_prediction(AACContext *ac, IndividualChannelStream *ics,
++ GetBitContext *gb)
++{
++ int sfb;
++ if (get_bits1(gb)) {
++ ics->predictor_reset_group = get_bits(gb, 5);
++ if (ics->predictor_reset_group == 0 || ics->predictor_reset_group > 30) {
++ av_log(ac->avctx, AV_LOG_ERROR, "Invalid Predictor Reset Group.\n");
++ return -1;
++ }
++ }
++ for (sfb = 0; sfb < FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[ac->m4ac.sampling_index]); sfb++) {
++ ics->prediction_used[sfb] = get_bits1(gb);
++ }
++ return 0;
++}
++
++/**
++ * Decode Individual Channel Stream info; reference: table 4.6.
++ *
++ * @param common_window Channels have independent [0], or shared [1], Individual Channel Stream information.
++ */
++static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
++ GetBitContext *gb, int common_window)
++{
++ if (get_bits1(gb)) {
++ av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n");
++ memset(ics, 0, sizeof(IndividualChannelStream));
++ return -1;
++ }
++ ics->window_sequence[1] = ics->window_sequence[0];
++ ics->window_sequence[0] = get_bits(gb, 2);
++ ics->use_kb_window[1] = ics->use_kb_window[0];
++ ics->use_kb_window[0] = get_bits1(gb);
++ ics->num_window_groups = 1;
++ ics->group_len[0] = 1;
++ if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
++ int i;
++ ics->max_sfb = get_bits(gb, 4);
++ for (i = 0; i < 7; i++) {
++ if (get_bits1(gb)) {
++ ics->group_len[ics->num_window_groups - 1]++;
++ } else {
++ ics->num_window_groups++;
++ ics->group_len[ics->num_window_groups - 1] = 1;
++ }
++ }
++ ics->num_windows = 8;
++ ics->swb_offset = ff_swb_offset_128[ac->m4ac.sampling_index];
++ ics->num_swb = ff_aac_num_swb_128[ac->m4ac.sampling_index];
++ ics->tns_max_bands = ff_tns_max_bands_128[ac->m4ac.sampling_index];
++ ics->predictor_present = 0;
++ } else {
++ ics->max_sfb = get_bits(gb, 6);
++ ics->num_windows = 1;
++ ics->swb_offset = ff_swb_offset_1024[ac->m4ac.sampling_index];
++ ics->num_swb = ff_aac_num_swb_1024[ac->m4ac.sampling_index];
++ ics->tns_max_bands = ff_tns_max_bands_1024[ac->m4ac.sampling_index];
++ ics->predictor_present = get_bits1(gb);
++ ics->predictor_reset_group = 0;
++ if (ics->predictor_present) {
++ if (ac->m4ac.object_type == AOT_AAC_MAIN) {
++ if (decode_prediction(ac, ics, gb)) {
++ memset(ics, 0, sizeof(IndividualChannelStream));
++ return -1;
++ }
++ } else if (ac->m4ac.object_type == AOT_AAC_LC) {
++ av_log(ac->avctx, AV_LOG_ERROR, "Prediction is not allowed in AAC-LC.\n");
++ memset(ics, 0, sizeof(IndividualChannelStream));
++ return -1;
++ } else {
++ av_log_missing_feature(ac->avctx, "Predictor bit set but LTP is", 1);
++ memset(ics, 0, sizeof(IndividualChannelStream));
++ return -1;
++ }
++ }
++ }
++
++ if (ics->max_sfb > ics->num_swb) {
++ av_log(ac->avctx, AV_LOG_ERROR,
++ "Number of scalefactor bands in group (%d) exceeds limit (%d).\n",
++ ics->max_sfb, ics->num_swb);
++ memset(ics, 0, sizeof(IndividualChannelStream));
++ return -1;
++ }
++
++ return 0;
++}
++
++/**
++ * Decode band types (section_data payload); reference: table 4.46.
++ *
++ * @param band_type array of the used band type
++ * @param band_type_run_end array of the last scalefactor band of a band type run
++ *
++ * @return Returns error status. 0 - OK, !0 - error
++ */
++static int decode_band_types(AACContext *ac, enum BandType band_type[120],
++ int band_type_run_end[120], GetBitContext *gb,
++ IndividualChannelStream *ics)
++{
++ int g, idx = 0;
++ const int bits = (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) ? 3 : 5;
++ for (g = 0; g < ics->num_window_groups; g++) {
++ int k = 0;
++ while (k < ics->max_sfb) {
++ uint8_t sect_end = k;
++ int sect_len_incr;
++ int sect_band_type = get_bits(gb, 4);
++ if (sect_band_type == 12) {
++ av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n");
++ return -1;
++ }
++ while ((sect_len_incr = get_bits(gb, bits)) == (1 << bits) - 1)
++ sect_end += sect_len_incr;
++ sect_end += sect_len_incr;
++ if (get_bits_left(gb) < 0) {
++ av_log(ac->avctx, AV_LOG_ERROR, overread_err);
++ return -1;
++ }
++ if (sect_end > ics->max_sfb) {
++ av_log(ac->avctx, AV_LOG_ERROR,
++ "Number of bands (%d) exceeds limit (%d).\n",
++ sect_end, ics->max_sfb);
++ return -1;
++ }
++ for (; k < sect_end; k++) {
++ band_type [idx] = sect_band_type;
++ band_type_run_end[idx++] = sect_end;
++ }
++ }
++ }
++ return 0;
++}
++
++/**
++ * Decode scalefactors; reference: table 4.47.
++ *
++ * @param global_gain first scalefactor value as scalefactors are differentially coded
++ * @param band_type array of the used band type
++ * @param band_type_run_end array of the last scalefactor band of a band type run
++ * @param sf array of scalefactors or intensity stereo positions
++ *
++ * @return Returns error status. 0 - OK, !0 - error
++ */
++static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb,
++ unsigned int global_gain,
++ IndividualChannelStream *ics,
++ enum BandType band_type[120],
++ int band_type_run_end[120])
++{
++ const int sf_offset = ac->sf_offset + (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE ? 12 : 0);
++ int g, i, idx = 0;
++ int offset[3] = { global_gain, global_gain - 90, 100 };
++ int noise_flag = 1;
++ static const char *sf_str[3] = { "Global gain", "Noise gain", "Intensity stereo position" };
++ for (g = 0; g < ics->num_window_groups; g++) {
++ for (i = 0; i < ics->max_sfb;) {
++ int run_end = band_type_run_end[idx];
++ if (band_type[idx] == ZERO_BT) {
++ for (; i < run_end; i++, idx++)
++ sf[idx] = 0.;
++ } else if ((band_type[idx] == INTENSITY_BT) || (band_type[idx] == INTENSITY_BT2)) {
++ for (; i < run_end; i++, idx++) {
++ offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
++ if (offset[2] > 255U) {
++ av_log(ac->avctx, AV_LOG_ERROR,
++ "%s (%d) out of range.\n", sf_str[2], offset[2]);
++ return -1;
++ }
++ sf[idx] = ff_aac_pow2sf_tab[-offset[2] + 300];
++ }
++ } else if (band_type[idx] == NOISE_BT) {
++ for (; i < run_end; i++, idx++) {
++ if (noise_flag-- > 0)
++ offset[1] += get_bits(gb, 9) - 256;
++ else
++ offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
++ if (offset[1] > 255U) {
++ av_log(ac->avctx, AV_LOG_ERROR,
++ "%s (%d) out of range.\n", sf_str[1], offset[1]);
++ return -1;
++ }
++ sf[idx] = -ff_aac_pow2sf_tab[offset[1] + sf_offset + 100];
++ }
++ } else {
++ for (; i < run_end; i++, idx++) {
++ offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
++ if (offset[0] > 255U) {
++ av_log(ac->avctx, AV_LOG_ERROR,
++ "%s (%d) out of range.\n", sf_str[0], offset[0]);
++ return -1;
++ }
++ sf[idx] = -ff_aac_pow2sf_tab[ offset[0] + sf_offset];
++ }
++ }
++ }
++ }
++ return 0;
++}
++
++/**
++ * Decode pulse data; reference: table 4.7.
++ */
++static int decode_pulses(Pulse *pulse, GetBitContext *gb,
++ const uint16_t *swb_offset, int num_swb)
++{
++ int i, pulse_swb;
++ pulse->num_pulse = get_bits(gb, 2) + 1;
++ pulse_swb = get_bits(gb, 6);
++ if (pulse_swb >= num_swb)
++ return -1;
++ pulse->pos[0] = swb_offset[pulse_swb];
++ pulse->pos[0] += get_bits(gb, 5);
++ if (pulse->pos[0] > 1023)
++ return -1;
++ pulse->amp[0] = get_bits(gb, 4);
++ for (i = 1; i < pulse->num_pulse; i++) {
++ pulse->pos[i] = get_bits(gb, 5) + pulse->pos[i - 1];
++ if (pulse->pos[i] > 1023)
++ return -1;
++ pulse->amp[i] = get_bits(gb, 4);
++ }
++ return 0;
++}
++
++/**
++ * Decode Temporal Noise Shaping data; reference: table 4.48.
++ *
++ * @return Returns error status. 0 - OK, !0 - error
++ */
++static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns,
++ GetBitContext *gb, const IndividualChannelStream *ics)
++{
++ int w, filt, i, coef_len, coef_res, coef_compress;
++ const int is8 = ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE;
++ const int tns_max_order = is8 ? 7 : ac->m4ac.object_type == AOT_AAC_MAIN ? 20 : 12;
++ for (w = 0; w < ics->num_windows; w++) {
++ if ((tns->n_filt[w] = get_bits(gb, 2 - is8))) {
++ coef_res = get_bits1(gb);
++
++ for (filt = 0; filt < tns->n_filt[w]; filt++) {
++ int tmp2_idx;
++ tns->length[w][filt] = get_bits(gb, 6 - 2 * is8);
++
++ if ((tns->order[w][filt] = get_bits(gb, 5 - 2 * is8)) > tns_max_order) {
++ av_log(ac->avctx, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.\n",
++ tns->order[w][filt], tns_max_order);
++ tns->order[w][filt] = 0;
++ return -1;
++ }
++ if (tns->order[w][filt]) {
++ tns->direction[w][filt] = get_bits1(gb);
++ coef_compress = get_bits1(gb);
++ coef_len = coef_res + 3 - coef_compress;
++ tmp2_idx = 2 * coef_compress + coef_res;
++
++ for (i = 0; i < tns->order[w][filt]; i++)
++ tns->coef[w][filt][i] = tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];
++ }
++ }
++ }
++ }
++ return 0;
++}
++
++/**
++ * Decode Mid/Side data; reference: table 4.54.
++ *
++ * @param ms_present Indicates mid/side stereo presence. [0] mask is all 0s;
++ * [1] mask is decoded from bitstream; [2] mask is all 1s;
++ * [3] reserved for scalable AAC
++ */
++static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb,
++ int ms_present)
++{
++ int idx;
++ if (ms_present == 1) {
++ for (idx = 0; idx < cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb; idx++)
++ cpe->ms_mask[idx] = get_bits1(gb);
++ } else if (ms_present == 2) {
++ memset(cpe->ms_mask, 1, cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb * sizeof(cpe->ms_mask[0]));
++ }
++}
++
++#ifndef VMUL2
++static inline float *VMUL2(float *dst, const float *v, unsigned idx,
++ const float *scale)
++{
++ float s = *scale;
++ *dst++ = v[idx & 15] * s;
++ *dst++ = v[idx>>4 & 15] * s;
++ return dst;
++}
++#endif
++
++#ifndef VMUL4
++static inline float *VMUL4(float *dst, const float *v, unsigned idx,
++ const float *scale)
++{
++ float s = *scale;
++ *dst++ = v[idx & 3] * s;
++ *dst++ = v[idx>>2 & 3] * s;
++ *dst++ = v[idx>>4 & 3] * s;
++ *dst++ = v[idx>>6 & 3] * s;
++ return dst;
++}
++#endif
++
++#ifndef VMUL2S
++static inline float *VMUL2S(float *dst, const float *v, unsigned idx,
++ unsigned sign, const float *scale)
++{
++ union float754 s0, s1;
++
++ s0.f = s1.f = *scale;
++ s0.i ^= sign >> 1 << 31;
++ s1.i ^= sign << 31;
++
++ *dst++ = v[idx & 15] * s0.f;
++ *dst++ = v[idx>>4 & 15] * s1.f;
++
++ return dst;
++}
++#endif
++
++#ifndef VMUL4S
++static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
++ unsigned sign, const float *scale)
++{
++ unsigned nz = idx >> 12;
++ union float754 s = { .f = *scale };
++ union float754 t;
++
++ t.i = s.i ^ (sign & 1<<31);
++ *dst++ = v[idx & 3] * t.f;
++
++ sign <<= nz & 1; nz >>= 1;
++ t.i = s.i ^ (sign & 1<<31);
++ *dst++ = v[idx>>2 & 3] * t.f;
++
++ sign <<= nz & 1; nz >>= 1;
++ t.i = s.i ^ (sign & 1<<31);
++ *dst++ = v[idx>>4 & 3] * t.f;
++
++ sign <<= nz & 1; nz >>= 1;
++ t.i = s.i ^ (sign & 1<<31);
++ *dst++ = v[idx>>6 & 3] * t.f;
++
++ return dst;
++}
++#endif
++
++/**
++ * Decode spectral data; reference: table 4.50.
++ * Dequantize and scale spectral data; reference: 4.6.3.3.
++ *
++ * @param coef array of dequantized, scaled spectral data
++ * @param sf array of scalefactors or intensity stereo positions
++ * @param pulse_present set if pulses are present
++ * @param pulse pointer to pulse data struct
++ * @param band_type array of the used band type
++ *
++ * @return Returns error status. 0 - OK, !0 - error
++ */
++static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024],
++ GetBitContext *gb, const float sf[120],
++ int pulse_present, const Pulse *pulse,
++ const IndividualChannelStream *ics,
++ enum BandType band_type[120])
++{
++ int i, k, g, idx = 0;
++ const int c = 1024 / ics->num_windows;
++ const uint16_t *offsets = ics->swb_offset;
++ float *coef_base = coef;
++ int err_idx;
++
++ for (g = 0; g < ics->num_windows; g++)
++ memset(coef + g * 128 + offsets[ics->max_sfb], 0, sizeof(float) * (c - offsets[ics->max_sfb]));
++
++ for (g = 0; g < ics->num_window_groups; g++) {
++ unsigned g_len = ics->group_len[g];
++
++ for (i = 0; i < ics->max_sfb; i++, idx++) {
++ const unsigned cbt_m1 = band_type[idx] - 1;
++ float *cfo = coef + offsets[i];
++ int off_len = offsets[i + 1] - offsets[i];
++ int group;
++
++ if (cbt_m1 >= INTENSITY_BT2 - 1) {
++ for (group = 0; group < g_len; group++, cfo+=128) {
++ memset(cfo, 0, off_len * sizeof(float));
++ }
++ } else if (cbt_m1 == NOISE_BT - 1) {
++ for (group = 0; group < g_len; group++, cfo+=128) {
++ float scale;
++ float band_energy;
++
++ for (k = 0; k < off_len; k++) {
++ ac->random_state = lcg_random(ac->random_state);
++ cfo[k] = ac->random_state;
++ }
++
++ band_energy = ac->dsp.scalarproduct_float(cfo, cfo, off_len);
++ scale = sf[idx] / sqrtf(band_energy);
++ ac->dsp.vector_fmul_scalar(cfo, cfo, scale, off_len);
++ }
++ } else {
++ const float *vq = ff_aac_codebook_vector_vals[cbt_m1];
++ const uint16_t *cb_vector_idx = ff_aac_codebook_vector_idx[cbt_m1];
++ VLC_TYPE (*vlc_tab)[2] = vlc_spectral[cbt_m1].table;
++ const int cb_size = ff_aac_spectral_sizes[cbt_m1];
++ OPEN_READER(re, gb);
++
++ switch (cbt_m1 >> 1) {
++ case 0:
++ for (group = 0; group < g_len; group++, cfo+=128) {
++ float *cf = cfo;
++ int len = off_len;
++
++ do {
++ int code;
++ unsigned cb_idx;
++
++ UPDATE_CACHE(re, gb);
++ GET_VLC(code, re, gb, vlc_tab, 8, 2);
++
++ if (code >= cb_size) {
++ err_idx = code;
++ goto err_cb_overflow;
++ }
++
++ cb_idx = cb_vector_idx[code];
++ cf = VMUL4(cf, vq, cb_idx, sf + idx);
++ } while (len -= 4);
++ }
++ break;
++
++ case 1:
++ for (group = 0; group < g_len; group++, cfo+=128) {
++ float *cf = cfo;
++ int len = off_len;
++
++ do {
++ int code;
++ unsigned nnz;
++ unsigned cb_idx;
++ uint32_t bits;
++
++ UPDATE_CACHE(re, gb);
++ GET_VLC(code, re, gb, vlc_tab, 8, 2);
++
++ if (code >= cb_size) {
++ err_idx = code;
++ goto err_cb_overflow;
++ }
++
++#if MIN_CACHE_BITS < 20
++ UPDATE_CACHE(re, gb);
++#endif
++ cb_idx = cb_vector_idx[code];
++ nnz = cb_idx >> 8 & 15;
++ bits = SHOW_UBITS(re, gb, nnz) << (32-nnz);
++ LAST_SKIP_BITS(re, gb, nnz);
++ cf = VMUL4S(cf, vq, cb_idx, bits, sf + idx);
++ } while (len -= 4);
++ }
++ break;
++
++ case 2:
++ for (group = 0; group < g_len; group++, cfo+=128) {
++ float *cf = cfo;
++ int len = off_len;
++
++ do {
++ int code;
++ unsigned cb_idx;
++
++ UPDATE_CACHE(re, gb);
++ GET_VLC(code, re, gb, vlc_tab, 8, 2);
++
++ if (code >= cb_size) {
++ err_idx = code;
++ goto err_cb_overflow;
++ }
++
++ cb_idx = cb_vector_idx[code];
++ cf = VMUL2(cf, vq, cb_idx, sf + idx);
++ } while (len -= 2);
++ }
++ break;
++
++ case 3:
++ case 4:
++ for (group = 0; group < g_len; group++, cfo+=128) {
++ float *cf = cfo;
++ int len = off_len;
++
++ do {
++ int code;
++ unsigned nnz;
++ unsigned cb_idx;
++ unsigned sign;
++
++ UPDATE_CACHE(re, gb);
++ GET_VLC(code, re, gb, vlc_tab, 8, 2);
++
++ if (code >= cb_size) {
++ err_idx = code;
++ goto err_cb_overflow;
++ }
++
++ cb_idx = cb_vector_idx[code];
++ nnz = cb_idx >> 8 & 15;
++ sign = SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12);
++ LAST_SKIP_BITS(re, gb, nnz);
++ cf = VMUL2S(cf, vq, cb_idx, sign, sf + idx);
++ } while (len -= 2);
++ }
++ break;
++
++ default:
++ for (group = 0; group < g_len; group++, cfo+=128) {
++ float *cf = cfo;
++ uint32_t *icf = (uint32_t *) cf;
++ int len = off_len;
++
++ do {
++ int code;
++ unsigned nzt, nnz;
++ unsigned cb_idx;
++ uint32_t bits;
++ int j;
++
++ UPDATE_CACHE(re, gb);
++ GET_VLC(code, re, gb, vlc_tab, 8, 2);
++
++ if (!code) {
++ *icf++ = 0;
++ *icf++ = 0;
++ continue;
++ }
++
++ if (code >= cb_size) {
++ err_idx = code;
++ goto err_cb_overflow;
++ }
++
++ cb_idx = cb_vector_idx[code];
++ nnz = cb_idx >> 12;
++ nzt = cb_idx >> 8;
++ bits = SHOW_UBITS(re, gb, nnz) << (32-nnz);
++ LAST_SKIP_BITS(re, gb, nnz);
++
++ for (j = 0; j < 2; j++) {
++ if (nzt & 1< 8) {
++ av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n");
++ return -1;
++ }
++
++#if MIN_CACHE_BITS < 21
++ LAST_SKIP_BITS(re, gb, b + 1);
++ UPDATE_CACHE(re, gb);
++#else
++ SKIP_BITS(re, gb, b + 1);
++#endif
++ b += 4;
++ n = (1 << b) + SHOW_UBITS(re, gb, b);
++ LAST_SKIP_BITS(re, gb, b);
++ *icf++ = cbrt_tab[n] | (bits & 1<<31);
++ bits <<= 1;
++ } else {
++ unsigned v = ((const uint32_t*)vq)[cb_idx & 15];
++ *icf++ = (bits & 1<<31) | v;
++ bits <<= !!v;
++ }
++ cb_idx >>= 4;
++ }
++ } while (len -= 2);
++
++ ac->dsp.vector_fmul_scalar(cfo, cfo, sf[idx], off_len);
++ }
++ }
++
++ CLOSE_READER(re, gb);
++ }
++ }
++ coef += g_len << 7;
++ }
++
++ if (pulse_present) {
++ idx = 0;
++ for (i = 0; i < pulse->num_pulse; i++) {
++ float co = coef_base[ pulse->pos[i] ];
++ while (offsets[idx + 1] <= pulse->pos[i])
++ idx++;
++ if (band_type[idx] != NOISE_BT && sf[idx]) {
++ float ico = -pulse->amp[i];
++ if (co) {
++ co /= sf[idx];
++ ico = co / sqrtf(sqrtf(fabsf(co))) + (co > 0 ? -ico : ico);
++ }
++ coef_base[ pulse->pos[i] ] = cbrtf(fabsf(ico)) * ico * sf[idx];
++ }
++ }
++ }
++ return 0;
++
++err_cb_overflow:
++ av_log(ac->avctx, AV_LOG_ERROR,
++ "Read beyond end of ff_aac_codebook_vectors[%d][]. index %d >= %d\n",
++ band_type[idx], err_idx, ff_aac_spectral_sizes[band_type[idx]]);
++ return -1;
++}
++
++static av_always_inline float flt16_round(float pf)
++{
++ union float754 tmp;
++ tmp.f = pf;
++ tmp.i = (tmp.i + 0x00008000U) & 0xFFFF0000U;
++ return tmp.f;
++}
++
++static av_always_inline float flt16_even(float pf)
++{
++ union float754 tmp;
++ tmp.f = pf;
++ tmp.i = (tmp.i + 0x00007FFFU + (tmp.i & 0x00010000U >> 16)) & 0xFFFF0000U;
++ return tmp.f;
++}
++
++static av_always_inline float flt16_trunc(float pf)
++{
++ union float754 pun;
++ pun.f = pf;
++ pun.i &= 0xFFFF0000U;
++ return pun.f;
++}
++
++static av_always_inline void predict(AACContext *ac, PredictorState *ps, float *coef,
++ int output_enable)
++{
++ const float a = 0.953125; // 61.0 / 64
++ const float alpha = 0.90625; // 29.0 / 32
++ float e0, e1;
++ float pv;
++ float k1, k2;
++
++ k1 = ps->var0 > 1 ? ps->cor0 * flt16_even(a / ps->var0) : 0;
++ k2 = ps->var1 > 1 ? ps->cor1 * flt16_even(a / ps->var1) : 0;
++
++ pv = flt16_round(k1 * ps->r0 + k2 * ps->r1);
++ if (output_enable)
++ *coef += pv * ac->sf_scale;
++
++ e0 = *coef / ac->sf_scale;
++ e1 = e0 - k1 * ps->r0;
++
++ ps->cor1 = flt16_trunc(alpha * ps->cor1 + ps->r1 * e1);
++ ps->var1 = flt16_trunc(alpha * ps->var1 + 0.5 * (ps->r1 * ps->r1 + e1 * e1));
++ ps->cor0 = flt16_trunc(alpha * ps->cor0 + ps->r0 * e0);
++ ps->var0 = flt16_trunc(alpha * ps->var0 + 0.5 * (ps->r0 * ps->r0 + e0 * e0));
++
++ ps->r1 = flt16_trunc(a * (ps->r0 - k1 * e0));
++ ps->r0 = flt16_trunc(a * e0);
++}
++
++/**
++ * Apply AAC-Main style frequency domain prediction.
++ */
++static void apply_prediction(AACContext *ac, SingleChannelElement *sce)
++{
++ int sfb, k;
++
++ if (!sce->ics.predictor_initialized) {
++ reset_all_predictors(sce->predictor_state);
++ sce->ics.predictor_initialized = 1;
++ }
++
++ if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) {
++ for (sfb = 0; sfb < ff_aac_pred_sfb_max[ac->m4ac.sampling_index]; sfb++) {
++ for (k = sce->ics.swb_offset[sfb]; k < sce->ics.swb_offset[sfb + 1]; k++) {
++ predict(ac, &sce->predictor_state[k], &sce->coeffs[k],
++ sce->ics.predictor_present && sce->ics.prediction_used[sfb]);
++ }
++ }
++ if (sce->ics.predictor_reset_group)
++ reset_predictor_group(sce->predictor_state, sce->ics.predictor_reset_group);
++ } else
++ reset_all_predictors(sce->predictor_state);
++}
++
++/**
++ * Decode an individual_channel_stream payload; reference: table 4.44.
++ *
++ * @param common_window Channels have independent [0], or shared [1], Individual Channel Stream information.
++ * @param scale_flag scalable [1] or non-scalable [0] AAC (Unused until scalable AAC is implemented.)
++ *
++ * @return Returns error status. 0 - OK, !0 - error
++ */
++static int decode_ics(AACContext *ac, SingleChannelElement *sce,
++ GetBitContext *gb, int common_window, int scale_flag)
++{
++ Pulse pulse;
++ TemporalNoiseShaping *tns = &sce->tns;
++ IndividualChannelStream *ics = &sce->ics;
++ float *out = sce->coeffs;
++ int global_gain, pulse_present = 0;
++
++ /* This assignment is to silence a GCC warning about the variable being used
++ * uninitialized when in fact it always is.
++ */
++ pulse.num_pulse = 0;
++
++ global_gain = get_bits(gb, 8);
++
++ if (!common_window && !scale_flag) {
++ if (decode_ics_info(ac, ics, gb, 0) < 0)
++ return -1;
++ }
++
++ if (decode_band_types(ac, sce->band_type, sce->band_type_run_end, gb, ics) < 0)
++ return -1;
++ if (decode_scalefactors(ac, sce->sf, gb, global_gain, ics, sce->band_type, sce->band_type_run_end) < 0)
++ return -1;
++
++ pulse_present = 0;
++ if (!scale_flag) {
++ if ((pulse_present = get_bits1(gb))) {
++ if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
++ av_log(ac->avctx, AV_LOG_ERROR, "Pulse tool not allowed in eight short sequence.\n");
++ return -1;
++ }
++ if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) {
++ av_log(ac->avctx, AV_LOG_ERROR, "Pulse data corrupt or invalid.\n");
++ return -1;
++ }
++ }
++ if ((tns->present = get_bits1(gb)) && decode_tns(ac, tns, gb, ics))
++ return -1;
++ if (get_bits1(gb)) {
++ av_log_missing_feature(ac->avctx, "SSR", 1);
++ return -1;
++ }
++ }
++
++ if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present, &pulse, ics, sce->band_type) < 0)
++ return -1;
++
++ if (ac->m4ac.object_type == AOT_AAC_MAIN && !common_window)
++ apply_prediction(ac, sce);
++
++ return 0;
++}
++
++/**
++ * Mid/Side stereo decoding; reference: 4.6.8.1.3.
++ */
++static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe)
++{
++ const IndividualChannelStream *ics = &cpe->ch[0].ics;
++ float *ch0 = cpe->ch[0].coeffs;
++ float *ch1 = cpe->ch[1].coeffs;
++ int g, i, group, idx = 0;
++ const uint16_t *offsets = ics->swb_offset;
++ for (g = 0; g < ics->num_window_groups; g++) {
++ for (i = 0; i < ics->max_sfb; i++, idx++) {
++ if (cpe->ms_mask[idx] &&
++ cpe->ch[0].band_type[idx] < NOISE_BT && cpe->ch[1].band_type[idx] < NOISE_BT) {
++ for (group = 0; group < ics->group_len[g]; group++) {
++ ac->dsp.butterflies_float(ch0 + group * 128 + offsets[i],
++ ch1 + group * 128 + offsets[i],
++ offsets[i+1] - offsets[i]);
++ }
++ }
++ }
++ ch0 += ics->group_len[g] * 128;
++ ch1 += ics->group_len[g] * 128;
++ }
++}
++
++/**
++ * intensity stereo decoding; reference: 4.6.8.2.3
++ *
++ * @param ms_present Indicates mid/side stereo presence. [0] mask is all 0s;
++ * [1] mask is decoded from bitstream; [2] mask is all 1s;
++ * [3] reserved for scalable AAC
++ */
++static void apply_intensity_stereo(ChannelElement *cpe, int ms_present)
++{
++ const IndividualChannelStream *ics = &cpe->ch[1].ics;
++ SingleChannelElement *sce1 = &cpe->ch[1];
++ float *coef0 = cpe->ch[0].coeffs, *coef1 = cpe->ch[1].coeffs;
++ const uint16_t *offsets = ics->swb_offset;
++ int g, group, i, k, idx = 0;
++ int c;
++ float scale;
++ for (g = 0; g < ics->num_window_groups; g++) {
++ for (i = 0; i < ics->max_sfb;) {
++ if (sce1->band_type[idx] == INTENSITY_BT || sce1->band_type[idx] == INTENSITY_BT2) {
++ const int bt_run_end = sce1->band_type_run_end[idx];
++ for (; i < bt_run_end; i++, idx++) {
++ c = -1 + 2 * (sce1->band_type[idx] - 14);
++ if (ms_present)
++ c *= 1 - 2 * cpe->ms_mask[idx];
++ scale = c * sce1->sf[idx];
++ for (group = 0; group < ics->group_len[g]; group++)
++ for (k = offsets[i]; k < offsets[i + 1]; k++)
++ coef1[group * 128 + k] = scale * coef0[group * 128 + k];
++ }
++ } else {
++ int bt_run_end = sce1->band_type_run_end[idx];
++ idx += bt_run_end - i;
++ i = bt_run_end;
++ }
++ }
++ coef0 += ics->group_len[g] * 128;
++ coef1 += ics->group_len[g] * 128;
++ }
++}
++
++/**
++ * Decode a channel_pair_element; reference: table 4.4.
++ *
++ * @param elem_id Identifies the instance of a syntax element.
++ *
++ * @return Returns error status. 0 - OK, !0 - error
++ */
++static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe)
++{
++ int i, ret, common_window, ms_present = 0;
++
++ common_window = get_bits1(gb);
++ if (common_window) {
++ if (decode_ics_info(ac, &cpe->ch[0].ics, gb, 1))
++ return -1;
++ i = cpe->ch[1].ics.use_kb_window[0];
++ cpe->ch[1].ics = cpe->ch[0].ics;
++ cpe->ch[1].ics.use_kb_window[1] = i;
++ ms_present = get_bits(gb, 2);
++ if (ms_present == 3) {
++ av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n");
++ return -1;
++ } else if (ms_present)
++ decode_mid_side_stereo(cpe, gb, ms_present);
++ }
++ if ((ret = decode_ics(ac, &cpe->ch[0], gb, common_window, 0)))
++ return ret;
++ if ((ret = decode_ics(ac, &cpe->ch[1], gb, common_window, 0)))
++ return ret;
++
++ if (common_window) {
++ if (ms_present)
++ apply_mid_side_stereo(ac, cpe);
++ if (ac->m4ac.object_type == AOT_AAC_MAIN) {
++ apply_prediction(ac, &cpe->ch[0]);
++ apply_prediction(ac, &cpe->ch[1]);
++ }
++ }
++
++ apply_intensity_stereo(cpe, ms_present);
++ return 0;
++}
++
++/**
++ * Decode coupling_channel_element; reference: table 4.8.
++ *
++ * @param elem_id Identifies the instance of a syntax element.
++ *
++ * @return Returns error status. 0 - OK, !0 - error
++ */
++static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che)
++{
++ int num_gain = 0;
++ int c, g, sfb, ret;
++ int sign;
++ float scale;
++ SingleChannelElement *sce = &che->ch[0];
++ ChannelCoupling *coup = &che->coup;
++
++ coup->coupling_point = 2 * get_bits1(gb);
++ coup->num_coupled = get_bits(gb, 3);
++ for (c = 0; c <= coup->num_coupled; c++) {
++ num_gain++;
++ coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE;
++ coup->id_select[c] = get_bits(gb, 4);
++ if (coup->type[c] == TYPE_CPE) {
++ coup->ch_select[c] = get_bits(gb, 2);
++ if (coup->ch_select[c] == 3)
++ num_gain++;
++ } else
++ coup->ch_select[c] = 2;
++ }
++ coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1);
++
++ sign = get_bits(gb, 1);
++ scale = pow(2., pow(2., (int)get_bits(gb, 2) - 3));
++
++ if ((ret = decode_ics(ac, sce, gb, 0, 0)))
++ return ret;
++
++ for (c = 0; c < num_gain; c++) {
++ int idx = 0;
++ int cge = 1;
++ int gain = 0;
++ float gain_cache = 1.;
++ if (c) {
++ cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb);
++ gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0;
++ gain_cache = pow(scale, -gain);
++ }
++ if (coup->coupling_point == AFTER_IMDCT) {
++ coup->gain[c][0] = gain_cache;
++ } else {
++ for (g = 0; g < sce->ics.num_window_groups; g++) {
++ for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) {
++ if (sce->band_type[idx] != ZERO_BT) {
++ if (!cge) {
++ int t = get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
++ if (t) {
++ int s = 1;
++ t = gain += t;
++ if (sign) {
++ s -= 2 * (t & 0x1);
++ t >>= 1;
++ }
++ gain_cache = pow(scale, -t) * s;
++ }
++ }
++ coup->gain[c][idx] = gain_cache;
++ }
++ }
++ }
++ }
++ }
++ return 0;
++}
++
++/**
++ * Parse whether channels are to be excluded from Dynamic Range Compression; reference: table 4.53.
++ *
++ * @return Returns number of bytes consumed.
++ */
++static int decode_drc_channel_exclusions(DynamicRangeControl *che_drc,
++ GetBitContext *gb)
++{
++ int i;
++ int num_excl_chan = 0;
++
++ do {
++ for (i = 0; i < 7; i++)
++ che_drc->exclude_mask[num_excl_chan++] = get_bits1(gb);
++ } while (num_excl_chan < MAX_CHANNELS - 7 && get_bits1(gb));
++
++ return num_excl_chan / 7;
++}
++
++/**
++ * Decode dynamic range information; reference: table 4.52.
++ *
++ * @param cnt length of TYPE_FIL syntactic element in bytes
++ *
++ * @return Returns number of bytes consumed.
++ */
++static int decode_dynamic_range(DynamicRangeControl *che_drc,
++ GetBitContext *gb, int cnt)
++{
++ int n = 1;
++ int drc_num_bands = 1;
++ int i;
++
++ /* pce_tag_present? */
++ if (get_bits1(gb)) {
++ che_drc->pce_instance_tag = get_bits(gb, 4);
++ skip_bits(gb, 4); // tag_reserved_bits
++ n++;
++ }
++
++ /* excluded_chns_present? */
++ if (get_bits1(gb)) {
++ n += decode_drc_channel_exclusions(che_drc, gb);
++ }
++
++ /* drc_bands_present? */
++ if (get_bits1(gb)) {
++ che_drc->band_incr = get_bits(gb, 4);
++ che_drc->interpolation_scheme = get_bits(gb, 4);
++ n++;
++ drc_num_bands += che_drc->band_incr;
++ for (i = 0; i < drc_num_bands; i++) {
++ che_drc->band_top[i] = get_bits(gb, 8);
++ n++;
++ }
++ }
++
++ /* prog_ref_level_present? */
++ if (get_bits1(gb)) {
++ che_drc->prog_ref_level = get_bits(gb, 7);
++ skip_bits1(gb); // prog_ref_level_reserved_bits
++ n++;
++ }
++
++ for (i = 0; i < drc_num_bands; i++) {
++ che_drc->dyn_rng_sgn[i] = get_bits1(gb);
++ che_drc->dyn_rng_ctl[i] = get_bits(gb, 7);
++ n++;
++ }
++
++ return n;
++}
++
++/**
++ * Decode extension data (incomplete); reference: table 4.51.
++ *
++ * @param cnt length of TYPE_FIL syntactic element in bytes
++ *
++ * @return Returns number of bytes consumed
++ */
++static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt,
++ ChannelElement *che, enum RawDataBlockType elem_type)
++{
++ int crc_flag = 0;
++ int res = cnt;
++ switch (get_bits(gb, 4)) { // extension type
++ case EXT_SBR_DATA_CRC:
++ crc_flag++;
++ case EXT_SBR_DATA:
++ if (!che) {
++ av_log(ac->avctx, AV_LOG_ERROR, "SBR was found before the first channel element.\n");
++ return res;
++ } else if (!ac->m4ac.sbr) {
++ av_log(ac->avctx, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n");
++ skip_bits_long(gb, 8 * cnt - 4);
++ return res;
++ } else if (ac->m4ac.sbr == -1 && ac->output_configured == OC_LOCKED) {
++ av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n");
++ skip_bits_long(gb, 8 * cnt - 4);
++ return res;
++ } else if (ac->m4ac.ps == -1 && ac->output_configured < OC_LOCKED && ac->avctx->channels == 1) {
++ ac->m4ac.sbr = 1;
++ ac->m4ac.ps = 1;
++ output_configure(ac, ac->che_pos, ac->che_pos, ac->m4ac.chan_config, ac->output_configured);
++ } else {
++ ac->m4ac.sbr = 1;
++ }
++ res = ff_decode_sbr_extension(ac, &che->sbr, gb, crc_flag, cnt, elem_type);
++ break;
++ case EXT_DYNAMIC_RANGE:
++ res = decode_dynamic_range(&ac->che_drc, gb, cnt);
++ break;
++ case EXT_FILL:
++ case EXT_FILL_DATA:
++ case EXT_DATA_ELEMENT:
++ default:
++ skip_bits_long(gb, 8 * cnt - 4);
++ break;
++ };
++ return res;
++}
++
++/**
++ * Decode Temporal Noise Shaping filter coefficients and apply all-pole filters; reference: 4.6.9.3.
++ *
++ * @param decode 1 if tool is used normally, 0 if tool is used in LTP.
++ * @param coef spectral coefficients
++ */
++static void apply_tns(float coef[1024], TemporalNoiseShaping *tns,
++ IndividualChannelStream *ics, int decode)
++{
++ const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb);
++ int w, filt, m, i;
++ int bottom, top, order, start, end, size, inc;
++ float lpc[TNS_MAX_ORDER];
++
++ for (w = 0; w < ics->num_windows; w++) {
++ bottom = ics->num_swb;
++ for (filt = 0; filt < tns->n_filt[w]; filt++) {
++ top = bottom;
++ bottom = FFMAX(0, top - tns->length[w][filt]);
++ order = tns->order[w][filt];
++ if (order == 0)
++ continue;
++
++ // tns_decode_coef
++ compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0);
++
++ start = ics->swb_offset[FFMIN(bottom, mmm)];
++ end = ics->swb_offset[FFMIN( top, mmm)];
++ if ((size = end - start) <= 0)
++ continue;
++ if (tns->direction[w][filt]) {
++ inc = -1;
++ start = end - 1;
++ } else {
++ inc = 1;
++ }
++ start += w * 128;
++
++ // ar filter
++ for (m = 0; m < size; m++, start += inc)
++ for (i = 1; i <= FFMIN(m, order); i++)
++ coef[start] -= coef[start - i * inc] * lpc[i - 1];
++ }
++ }
++}
++
++/**
++ * Conduct IMDCT and windowing.
++ */
++static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce, float bias)
++{
++ IndividualChannelStream *ics = &sce->ics;
++ float *in = sce->coeffs;
++ float *out = sce->ret;
++ float *saved = sce->saved;
++ const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128;
++ const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024;
++ const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128;
++ float *buf = ac->buf_mdct;
++ float *temp = ac->temp;
++ int i;
++
++ // imdct
++ if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
++ if (ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE)
++ av_log(ac->avctx, AV_LOG_WARNING,
++ "Transition from an ONLY_LONG or LONG_STOP to an EIGHT_SHORT sequence detected. "
++ "If you heard an audible artifact, please submit the sample to the FFmpeg developers.\n");
++ for (i = 0; i < 1024; i += 128)
++ ff_imdct_half(&ac->mdct_small, buf + i, in + i);
++ } else
++ ff_imdct_half(&ac->mdct, buf, in);
++
++ /* window overlapping
++ * NOTE: To simplify the overlapping code, all 'meaningless' short to long
++ * and long to short transitions are considered to be short to short
++ * transitions. This leaves just two cases (long to long and short to short)
++ * with a little special sauce for EIGHT_SHORT_SEQUENCE.
++ */
++ if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) &&
++ (ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) {
++ ac->dsp.vector_fmul_window( out, saved, buf, lwindow_prev, bias, 512);
++ } else {
++ for (i = 0; i < 448; i++)
++ out[i] = saved[i] + bias;
++
++ if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
++ ac->dsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, bias, 64);
++ ac->dsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, bias, 64);
++ ac->dsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, bias, 64);
++ ac->dsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, bias, 64);
++ ac->dsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, bias, 64);
++ memcpy( out + 448 + 4*128, temp, 64 * sizeof(float));
++ } else {
++ ac->dsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, bias, 64);
++ for (i = 576; i < 1024; i++)
++ out[i] = buf[i-512] + bias;
++ }
++ }
++
++ // buffer update
++ if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
++ for (i = 0; i < 64; i++)
++ saved[i] = temp[64 + i] - bias;
++ ac->dsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 0, 64);
++ ac->dsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 0, 64);
++ ac->dsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 0, 64);
++ memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
++ } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) {
++ memcpy( saved, buf + 512, 448 * sizeof(float));
++ memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
++ } else { // LONG_STOP or ONLY_LONG
++ memcpy( saved, buf + 512, 512 * sizeof(float));
++ }
++}
++
++/**
++ * Apply dependent channel coupling (applied before IMDCT).
++ *
++ * @param index index into coupling gain array
++ */
++static void apply_dependent_coupling(AACContext *ac,
++ SingleChannelElement *target,
++ ChannelElement *cce, int index)
++{
++ IndividualChannelStream *ics = &cce->ch[0].ics;
++ const uint16_t *offsets = ics->swb_offset;
++ float *dest = target->coeffs;
++ const float *src = cce->ch[0].coeffs;
++ int g, i, group, k, idx = 0;
++ if (ac->m4ac.object_type == AOT_AAC_LTP) {
++ av_log(ac->avctx, AV_LOG_ERROR,
++ "Dependent coupling is not supported together with LTP\n");
++ return;
++ }
++ for (g = 0; g < ics->num_window_groups; g++) {
++ for (i = 0; i < ics->max_sfb; i++, idx++) {
++ if (cce->ch[0].band_type[idx] != ZERO_BT) {
++ const float gain = cce->coup.gain[index][idx];
++ for (group = 0; group < ics->group_len[g]; group++) {
++ for (k = offsets[i]; k < offsets[i + 1]; k++) {
++ // XXX dsputil-ize
++ dest[group * 128 + k] += gain * src[group * 128 + k];
++ }
++ }
++ }
++ }
++ dest += ics->group_len[g] * 128;
++ src += ics->group_len[g] * 128;
++ }
++}
++
++/**
++ * Apply independent channel coupling (applied after IMDCT).
++ *
++ * @param index index into coupling gain array
++ */
++static void apply_independent_coupling(AACContext *ac,
++ SingleChannelElement *target,
++ ChannelElement *cce, int index)
++{
++ int i;
++ const float gain = cce->coup.gain[index][0];
++ const float bias = ac->add_bias;
++ const float *src = cce->ch[0].ret;
++ float *dest = target->ret;
++ const int len = 1024 << (ac->m4ac.sbr == 1);
++
++ for (i = 0; i < len; i++)
++ dest[i] += gain * (src[i] - bias);
++}
++
++/**
++ * channel coupling transformation interface
++ *
++ * @param index index into coupling gain array
++ * @param apply_coupling_method pointer to (in)dependent coupling function
++ */
++static void apply_channel_coupling(AACContext *ac, ChannelElement *cc,
++ enum RawDataBlockType type, int elem_id,
++ enum CouplingPoint coupling_point,
++ void (*apply_coupling_method)(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index))
++{
++ int i, c;
++
++ for (i = 0; i < MAX_ELEM_ID; i++) {
++ ChannelElement *cce = ac->che[TYPE_CCE][i];
++ int index = 0;
++
++ if (cce && cce->coup.coupling_point == coupling_point) {
++ ChannelCoupling *coup = &cce->coup;
++
++ for (c = 0; c <= coup->num_coupled; c++) {
++ if (coup->type[c] == type && coup->id_select[c] == elem_id) {
++ if (coup->ch_select[c] != 1) {
++ apply_coupling_method(ac, &cc->ch[0], cce, index);
++ if (coup->ch_select[c] != 0)
++ index++;
++ }
++ if (coup->ch_select[c] != 2)
++ apply_coupling_method(ac, &cc->ch[1], cce, index++);
++ } else
++ index += 1 + (coup->ch_select[c] == 3);
++ }
++ }
++ }
++}
++
++/**
++ * Convert spectral data to float samples, applying all supported tools as appropriate.
++ */
++static void spectral_to_sample(AACContext *ac)
++{
++ int i, type;
++ float imdct_bias = (ac->m4ac.sbr <= 0) ? ac->add_bias : 0.0f;
++ for (type = 3; type >= 0; type--) {
++ for (i = 0; i < MAX_ELEM_ID; i++) {
++ ChannelElement *che = ac->che[type][i];
++ if (che) {
++ if (type <= TYPE_CPE)
++ apply_channel_coupling(ac, che, type, i, BEFORE_TNS, apply_dependent_coupling);
++ if (che->ch[0].tns.present)
++ apply_tns(che->ch[0].coeffs, &che->ch[0].tns, &che->ch[0].ics, 1);
++ if (che->ch[1].tns.present)
++ apply_tns(che->ch[1].coeffs, &che->ch[1].tns, &che->ch[1].ics, 1);
++ if (type <= TYPE_CPE)
++ apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling);
++ if (type != TYPE_CCE || che->coup.coupling_point == AFTER_IMDCT) {
++ imdct_and_windowing(ac, &che->ch[0], imdct_bias);
++ if (type == TYPE_CPE) {
++ imdct_and_windowing(ac, &che->ch[1], imdct_bias);
++ }
++ if (ac->m4ac.sbr > 0) {
++ ff_sbr_apply(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret);
++ }
++ }
++ if (type <= TYPE_CCE)
++ apply_channel_coupling(ac, che, type, i, AFTER_IMDCT, apply_independent_coupling);
++ }
++ }
++ }
++}
++
++static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
++{
++ int size;
++ AACADTSHeaderInfo hdr_info;
++
++ size = ff_aac_parse_header(gb, &hdr_info);
++ if (size > 0) {
++ if (ac->output_configured != OC_LOCKED && hdr_info.chan_config) {
++ enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
++ memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
++ ac->m4ac.chan_config = hdr_info.chan_config;
++ if (set_default_channel_config(ac, new_che_pos, hdr_info.chan_config))
++ return -7;
++ if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, OC_TRIAL_FRAME))
++ return -7;
++ } else if (ac->output_configured != OC_LOCKED) {
++ ac->output_configured = OC_NONE;
++ }
++ if (ac->output_configured != OC_LOCKED) {
++ ac->m4ac.sbr = -1;
++ ac->m4ac.ps = -1;
++ }
++ ac->m4ac.sample_rate = hdr_info.sample_rate;
++ ac->m4ac.sampling_index = hdr_info.sampling_index;
++ ac->m4ac.object_type = hdr_info.object_type;
++ if (!ac->avctx->sample_rate)
++ ac->avctx->sample_rate = hdr_info.sample_rate;
++ if (hdr_info.num_aac_frames == 1) {
++ if (!hdr_info.crc_absent)
++ skip_bits(gb, 16);
++ } else {
++ av_log_missing_feature(ac->avctx, "More than one AAC RDB per ADTS frame is", 0);
++ return -1;
++ }
++ }
++ return size;
++}
++
++static int aac_decode_frame(AVCodecContext *avctx, void *data,
++ int *data_size, AVPacket *avpkt)
++{
++ const uint8_t *buf = avpkt->data;
++ int buf_size = avpkt->size;
++ AACContext *ac = avctx->priv_data;
++ ChannelElement *che = NULL, *che_prev = NULL;
++ GetBitContext gb;
++ enum RawDataBlockType elem_type, elem_type_prev = TYPE_END;
++ int err, elem_id, data_size_tmp;
++ int buf_consumed;
++ int samples = 0, multiplier;
++ int buf_offset;
++
++ init_get_bits(&gb, buf, buf_size * 8);
++
++ if (show_bits(&gb, 12) == 0xfff) {
++ if (parse_adts_frame_header(ac, &gb) < 0) {
++ av_log(avctx, AV_LOG_ERROR, "Error decoding AAC frame header.\n");
++ return -1;
++ }
++ if (ac->m4ac.sampling_index > 12) {
++ av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index);
++ return -1;
++ }
++ }
++
++ memset(ac->tags_seen_this_frame, 0, sizeof(ac->tags_seen_this_frame));
++ // parse
++ while ((elem_type = get_bits(&gb, 3)) != TYPE_END) {
++ elem_id = get_bits(&gb, 4);
++
++ if (elem_type < TYPE_DSE) {
++ if (!(che=get_che(ac, elem_type, elem_id))) {
++ av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n",
++ elem_type, elem_id);
++ return -1;
++ }
++ samples = 1024;
++ }
++
++ switch (elem_type) {
++
++ case TYPE_SCE:
++ err = decode_ics(ac, &che->ch[0], &gb, 0, 0);
++ break;
++
++ case TYPE_CPE:
++ err = decode_cpe(ac, &gb, che);
++ break;
++
++ case TYPE_CCE:
++ err = decode_cce(ac, &gb, che);
++ break;
++
++ case TYPE_LFE:
++ err = decode_ics(ac, &che->ch[0], &gb, 0, 0);
++ break;
++
++ case TYPE_DSE:
++ err = skip_data_stream_element(ac, &gb);
++ break;
++
++ case TYPE_PCE: {
++ enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
++ memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
++ if ((err = decode_pce(ac, new_che_pos, &gb)))
++ break;
++ if (ac->output_configured > OC_TRIAL_PCE)
++ av_log(avctx, AV_LOG_ERROR,
++ "Not evaluating a further program_config_element as this construct is dubious at best.\n");
++ else
++ err = output_configure(ac, ac->che_pos, new_che_pos, 0, OC_TRIAL_PCE);
++ break;
++ }
++
++ case TYPE_FIL:
++ if (elem_id == 15)
++ elem_id += get_bits(&gb, 8) - 1;
++ if (get_bits_left(&gb) < 8 * elem_id) {
++ av_log(avctx, AV_LOG_ERROR, overread_err);
++ return -1;
++ }
++ while (elem_id > 0)
++ elem_id -= decode_extension_payload(ac, &gb, elem_id, che_prev, elem_type_prev);
++ err = 0; /* FIXME */
++ break;
++
++ default:
++ err = -1; /* should not happen, but keeps compiler happy */
++ break;
++ }
++
++ che_prev = che;
++ elem_type_prev = elem_type;
++
++ if (err)
++ return err;
++
++ if (get_bits_left(&gb) < 3) {
++ av_log(avctx, AV_LOG_ERROR, overread_err);
++ return -1;
++ }
++ }
++
++ spectral_to_sample(ac);
++
++ multiplier = (ac->m4ac.sbr == 1) ? ac->m4ac.ext_sample_rate > ac->m4ac.sample_rate : 0;
++ samples <<= multiplier;
++ if (ac->output_configured < OC_LOCKED) {
++ avctx->sample_rate = ac->m4ac.sample_rate << multiplier;
++ avctx->frame_size = samples;
++ }
++
++ data_size_tmp = samples * avctx->channels * sizeof(int16_t);
++ if (*data_size < data_size_tmp) {
++ av_log(avctx, AV_LOG_ERROR,
++ "Output buffer too small (%d) or trying to output too many samples (%d) for this frame.\n",
++ *data_size, data_size_tmp);
++ return -1;
++ }
++ *data_size = data_size_tmp;
++
++ if (samples)
++ ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avctx->channels);
++
++ if (ac->output_configured)
++ ac->output_configured = OC_LOCKED;
++
++ buf_consumed = (get_bits_count(&gb) + 7) >> 3;
++ for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++)
++ if (buf[buf_offset])
++ break;
++
++ return buf_size > buf_offset ? buf_consumed : buf_size;
++}
++
++static av_cold int aac_decode_close(AVCodecContext *avctx)
++{
++ AACContext *ac = avctx->priv_data;
++ int i, type;
++
++ for (i = 0; i < MAX_ELEM_ID; i++) {
++ for (type = 0; type < 4; type++) {
++ if (ac->che[type][i])
++ ff_aac_sbr_ctx_close(&ac->che[type][i]->sbr);
++ av_freep(&ac->che[type][i]);
++ }
++ }
++
++ ff_mdct_end(&ac->mdct);
++ ff_mdct_end(&ac->mdct_small);
++ return 0;
++}
++
++AVCodec aac_decoder = {
++ "aac",
++ AVMEDIA_TYPE_AUDIO,
++ CODEC_ID_AAC,
++ sizeof(AACContext),
++ aac_decode_init,
++ NULL,
++ aac_decode_close,
++ aac_decode_frame,
++ .long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"),
++ .sample_fmts = (const enum SampleFormat[]) {
++ SAMPLE_FMT_S16,SAMPLE_FMT_NONE
++ },
++ .channel_layouts = aac_channel_layout,
++};
+--- a/libavcodec/aac.h
++++ b/libavcodec/aac.h
+@@ -38,12 +38,6 @@
+
+ #include
+
+-#define AAC_INIT_VLC_STATIC(num, size) \
+- INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \
+- ff_aac_spectral_bits[num], sizeof( ff_aac_spectral_bits[num][0]), sizeof( ff_aac_spectral_bits[num][0]), \
+- ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \
+- size);
+-
+ #define MAX_CHANNELS 64
+ #define MAX_ELEM_ID 16
+
+@@ -241,7 +235,7 @@ typedef struct {
+ * main AAC context
+ */
+ typedef struct {
+- AVCodecContext * avccontext;
++ AVCodecContext *avctx;
+
+ MPEG4AudioConfig m4ac;
+
+@@ -255,8 +249,9 @@ typedef struct {
+ enum ChannelPosition che_pos[4][MAX_ELEM_ID]; /**< channel element channel mapping with the
+ * first index as the first 4 raw data block types
+ */
+- ChannelElement * che[4][MAX_ELEM_ID];
+- ChannelElement * tag_che_map[4][MAX_ELEM_ID];
++ ChannelElement *che[4][MAX_ELEM_ID];
++ ChannelElement *tag_che_map[4][MAX_ELEM_ID];
++ uint8_t tags_seen_this_frame[4][MAX_ELEM_ID];
+ int tags_mapped;
+ /** @} */
+
+--- /dev/null
++++ b/libavcodec/aac_tablegen_decl.h
+@@ -0,0 +1,34 @@
++/*
++ * Header file for hardcoded AAC tables
++ *
++ * Copyright (c) 2010 Alex Converse
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#ifndef AAC_TABLEGEN_INIT_H
++#define AAC_TABLEGEN_INIT_H
++
++#if CONFIG_HARDCODED_TABLES
++#define ff_aac_tableinit()
++extern const float ff_aac_pow2sf_tab[428];
++#else
++void ff_aac_tableinit(void);
++extern float ff_aac_pow2sf_tab[428];
++#endif /* CONFIG_HARDCODED_TABLES */
++
++#endif /* AAC_TABLEGEN_INIT_H */
+--- /dev/null
++++ b/libavcodec/aacps.c
+@@ -0,0 +1,1037 @@
++/*
++ * MPEG-4 Parametric Stereo decoding functions
++ * Copyright (c) 2010 Alex Converse
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#include
++#include "libavutil/common.h"
++#include "libavutil/mathematics.h"
++#include "avcodec.h"
++#include "get_bits.h"
++#include "aacps.h"
++#include "aacps_tablegen.h"
++#include "aacpsdata.c"
++
++#define PS_BASELINE 0 //< Operate in Baseline PS mode
++ //< Baseline implies 10 or 20 stereo bands,
++ //< mixing mode A, and no ipd/opd
++
++#define numQMFSlots 32 //numTimeSlots * RATE
++
++static const int8_t num_env_tab[2][4] = {
++ { 0, 1, 2, 4, },
++ { 1, 2, 3, 4, },
++};
++
++static const int8_t nr_iidicc_par_tab[] = {
++ 10, 20, 34, 10, 20, 34,
++};
++
++static const int8_t nr_iidopd_par_tab[] = {
++ 5, 11, 17, 5, 11, 17,
++};
++
++enum {
++ huff_iid_df1,
++ huff_iid_dt1,
++ huff_iid_df0,
++ huff_iid_dt0,
++ huff_icc_df,
++ huff_icc_dt,
++ huff_ipd_df,
++ huff_ipd_dt,
++ huff_opd_df,
++ huff_opd_dt,
++};
++
++static const int huff_iid[] = {
++ huff_iid_df0,
++ huff_iid_df1,
++ huff_iid_dt0,
++ huff_iid_dt1,
++};
++
++static VLC vlc_ps[10];
++
++/**
++ * Read Inter-channel Intensity Difference/Inter-Channel Coherence/
++ * Inter-channel Phase Difference/Overall Phase Difference parameters from the
++ * bitstream.
++ *
++ * @param avctx contains the current codec context
++ * @param gb pointer to the input bitstream
++ * @param ps pointer to the Parametric Stereo context
++ * @param par pointer to the parameter to be read
++ * @param e envelope to decode
++ * @param dt 1: time delta-coded, 0: frequency delta-coded
++ */
++#define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION) \
++static int read_ ## PAR ## _data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, \
++ int8_t (*PAR)[PS_MAX_NR_IIDICC], int table_idx, int e, int dt) \
++{ \
++ int b, num = ps->nr_ ## PAR ## _par; \
++ VLC_TYPE (*vlc_table)[2] = vlc_ps[table_idx].table; \
++ if (dt) { \
++ int e_prev = e ? e - 1 : ps->num_env_old - 1; \
++ e_prev = FFMAX(e_prev, 0); \
++ for (b = 0; b < num; b++) { \
++ int val = PAR[e_prev][b] + get_vlc2(gb, vlc_table, 9, 3) - OFFSET; \
++ if (MASK) val &= MASK; \
++ PAR[e][b] = val; \
++ if (ERR_CONDITION) \
++ goto err; \
++ } \
++ } else { \
++ int val = 0; \
++ for (b = 0; b < num; b++) { \
++ val += get_vlc2(gb, vlc_table, 9, 3) - OFFSET; \
++ if (MASK) val &= MASK; \
++ PAR[e][b] = val; \
++ if (ERR_CONDITION) \
++ goto err; \
++ } \
++ } \
++ return 0; \
++err: \
++ av_log(avctx, AV_LOG_ERROR, "illegal "#PAR"\n"); \
++ return -1; \
++}
++
++READ_PAR_DATA(iid, huff_offset[table_idx], 0, FFABS(ps->iid_par[e][b]) > 7 + 8 * ps->iid_quant)
++READ_PAR_DATA(icc, huff_offset[table_idx], 0, ps->icc_par[e][b] > 7U)
++READ_PAR_DATA(ipdopd, 0, 0x07, 0)
++
++static int ps_read_extension_data(GetBitContext *gb, PSContext *ps, int ps_extension_id)
++{
++ int e;
++ int count = get_bits_count(gb);
++
++ if (ps_extension_id)
++ return 0;
++
++ ps->enable_ipdopd = get_bits1(gb);
++ if (ps->enable_ipdopd) {
++ for (e = 0; e < ps->num_env; e++) {
++ int dt = get_bits1(gb);
++ read_ipdopd_data(NULL, gb, ps, ps->ipd_par, dt ? huff_ipd_dt : huff_ipd_df, e, dt);
++ dt = get_bits1(gb);
++ read_ipdopd_data(NULL, gb, ps, ps->opd_par, dt ? huff_opd_dt : huff_opd_df, e, dt);
++ }
++ }
++ skip_bits1(gb); //reserved_ps
++ return get_bits_count(gb) - count;
++}
++
++static void ipdopd_reset(int8_t *opd_hist, int8_t *ipd_hist)
++{
++ int i;
++ for (i = 0; i < PS_MAX_NR_IPDOPD; i++) {
++ opd_hist[i] = 0;
++ ipd_hist[i] = 0;
++ }
++}
++
++int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left)
++{
++ int e;
++ int bit_count_start = get_bits_count(gb_host);
++ int header;
++ int bits_consumed;
++ GetBitContext gbc = *gb_host, *gb = &gbc;
++
++ header = get_bits1(gb);
++ if (header) { //enable_ps_header
++ ps->enable_iid = get_bits1(gb);
++ if (ps->enable_iid) {
++ int iid_mode = get_bits(gb, 3);
++ if (iid_mode > 5) {
++ av_log(avctx, AV_LOG_ERROR, "iid_mode %d is reserved.\n",
++ iid_mode);
++ goto err;
++ }
++ ps->nr_iid_par = nr_iidicc_par_tab[iid_mode];
++ ps->iid_quant = iid_mode > 2;
++ ps->nr_ipdopd_par = nr_iidopd_par_tab[iid_mode];
++ }
++ ps->enable_icc = get_bits1(gb);
++ if (ps->enable_icc) {
++ ps->icc_mode = get_bits(gb, 3);
++ if (ps->icc_mode > 5) {
++ av_log(avctx, AV_LOG_ERROR, "icc_mode %d is reserved.\n",
++ ps->icc_mode);
++ goto err;
++ }
++ ps->nr_icc_par = nr_iidicc_par_tab[ps->icc_mode];
++ }
++ ps->enable_ext = get_bits1(gb);
++ }
++
++ ps->frame_class = get_bits1(gb);
++ ps->num_env_old = ps->num_env;
++ ps->num_env = num_env_tab[ps->frame_class][get_bits(gb, 2)];
++
++ ps->border_position[0] = -1;
++ if (ps->frame_class) {
++ for (e = 1; e <= ps->num_env; e++)
++ ps->border_position[e] = get_bits(gb, 5);
++ } else
++ for (e = 1; e <= ps->num_env; e++)
++ ps->border_position[e] = (e * numQMFSlots >> ff_log2_tab[ps->num_env]) - 1;
++
++ if (ps->enable_iid) {
++ for (e = 0; e < ps->num_env; e++) {
++ int dt = get_bits1(gb);
++ if (read_iid_data(avctx, gb, ps, ps->iid_par, huff_iid[2*dt+ps->iid_quant], e, dt))
++ goto err;
++ }
++ } else
++ memset(ps->iid_par, 0, sizeof(ps->iid_par));
++
++ if (ps->enable_icc)
++ for (e = 0; e < ps->num_env; e++) {
++ int dt = get_bits1(gb);
++ if (read_icc_data(avctx, gb, ps, ps->icc_par, dt ? huff_icc_dt : huff_icc_df, e, dt))
++ goto err;
++ }
++ else
++ memset(ps->icc_par, 0, sizeof(ps->icc_par));
++
++ if (ps->enable_ext) {
++ int cnt = get_bits(gb, 4);
++ if (cnt == 15) {
++ cnt += get_bits(gb, 8);
++ }
++ cnt *= 8;
++ while (cnt > 7) {
++ int ps_extension_id = get_bits(gb, 2);
++ cnt -= 2 + ps_read_extension_data(gb, ps, ps_extension_id);
++ }
++ if (cnt < 0) {
++ av_log(avctx, AV_LOG_ERROR, "ps extension overflow %d", cnt);
++ goto err;
++ }
++ skip_bits(gb, cnt);
++ }
++
++ ps->enable_ipdopd &= !PS_BASELINE;
++
++ //Fix up envelopes
++ if (!ps->num_env || ps->border_position[ps->num_env] < numQMFSlots - 1) {
++ //Create a fake envelope
++ int source = ps->num_env ? ps->num_env - 1 : ps->num_env_old - 1;
++ if (source >= 0 && source != ps->num_env) {
++ if (ps->enable_iid) {
++ memcpy(ps->iid_par+ps->num_env, ps->iid_par+source, sizeof(ps->iid_par[0]));
++ }
++ if (ps->enable_icc) {
++ memcpy(ps->icc_par+ps->num_env, ps->icc_par+source, sizeof(ps->icc_par[0]));
++ }
++ if (ps->enable_ipdopd) {
++ memcpy(ps->ipd_par+ps->num_env, ps->ipd_par+source, sizeof(ps->ipd_par[0]));
++ memcpy(ps->opd_par+ps->num_env, ps->opd_par+source, sizeof(ps->opd_par[0]));
++ }
++ }
++ ps->num_env++;
++ ps->border_position[ps->num_env] = numQMFSlots - 1;
++ }
++
++
++ ps->is34bands_old = ps->is34bands;
++ if (!PS_BASELINE && (ps->enable_iid || ps->enable_icc))
++ ps->is34bands = (ps->enable_iid && ps->nr_iid_par == 34) ||
++ (ps->enable_icc && ps->nr_icc_par == 34);
++
++ //Baseline
++ if (!ps->enable_ipdopd) {
++ memset(ps->ipd_par, 0, sizeof(ps->ipd_par));
++ memset(ps->opd_par, 0, sizeof(ps->opd_par));
++ }
++
++ if (header)
++ ps->start = 1;
++
++ bits_consumed = get_bits_count(gb) - bit_count_start;
++ if (bits_consumed <= bits_left) {
++ skip_bits_long(gb_host, bits_consumed);
++ return bits_consumed;
++ }
++ av_log(avctx, AV_LOG_ERROR, "Expected to read %d PS bits actually read %d.\n", bits_left, bits_consumed);
++err:
++ ps->start = 0;
++ skip_bits_long(gb_host, bits_left);
++ return bits_left;
++}
++
++/** Split one subband into 2 subsubbands with a symmetric real filter.
++ * The filter must have its non-center even coefficients equal to zero. */
++static void hybrid2_re(float (*in)[2], float (*out)[32][2], const float filter[7], int len, int reverse)
++{
++ int i, j;
++ for (i = 0; i < len; i++, in++) {
++ float re_in = filter[6] * in[6][0]; //real inphase
++ float re_op = 0.0f; //real out of phase
++ float im_in = filter[6] * in[6][1]; //imag inphase
++ float im_op = 0.0f; //imag out of phase
++ for (j = 0; j < 6; j += 2) {
++ re_op += filter[j+1] * (in[j+1][0] + in[12-j-1][0]);
++ im_op += filter[j+1] * (in[j+1][1] + in[12-j-1][1]);
++ }
++ out[ reverse][i][0] = re_in + re_op;
++ out[ reverse][i][1] = im_in + im_op;
++ out[!reverse][i][0] = re_in - re_op;
++ out[!reverse][i][1] = im_in - im_op;
++ }
++}
++
++/** Split one subband into 6 subsubbands with a complex filter */
++static void hybrid6_cx(float (*in)[2], float (*out)[32][2], const float (*filter)[7][2], int len)
++{
++ int i, j, ssb;
++ int N = 8;
++ float temp[8][2];
++
++ for (i = 0; i < len; i++, in++) {
++ for (ssb = 0; ssb < N; ssb++) {
++ float sum_re = filter[ssb][6][0] * in[6][0], sum_im = filter[ssb][6][0] * in[6][1];
++ for (j = 0; j < 6; j++) {
++ float in0_re = in[j][0];
++ float in0_im = in[j][1];
++ float in1_re = in[12-j][0];
++ float in1_im = in[12-j][1];
++ sum_re += filter[ssb][j][0] * (in0_re + in1_re) - filter[ssb][j][1] * (in0_im - in1_im);
++ sum_im += filter[ssb][j][0] * (in0_im + in1_im) + filter[ssb][j][1] * (in0_re - in1_re);
++ }
++ temp[ssb][0] = sum_re;
++ temp[ssb][1] = sum_im;
++ }
++ out[0][i][0] = temp[6][0];
++ out[0][i][1] = temp[6][1];
++ out[1][i][0] = temp[7][0];
++ out[1][i][1] = temp[7][1];
++ out[2][i][0] = temp[0][0];
++ out[2][i][1] = temp[0][1];
++ out[3][i][0] = temp[1][0];
++ out[3][i][1] = temp[1][1];
++ out[4][i][0] = temp[2][0] + temp[5][0];
++ out[4][i][1] = temp[2][1] + temp[5][1];
++ out[5][i][0] = temp[3][0] + temp[4][0];
++ out[5][i][1] = temp[3][1] + temp[4][1];
++ }
++}
++
++static void hybrid4_8_12_cx(float (*in)[2], float (*out)[32][2], const float (*filter)[7][2], int N, int len)
++{
++ int i, j, ssb;
++
++ for (i = 0; i < len; i++, in++) {
++ for (ssb = 0; ssb < N; ssb++) {
++ float sum_re = filter[ssb][6][0] * in[6][0], sum_im = filter[ssb][6][0] * in[6][1];
++ for (j = 0; j < 6; j++) {
++ float in0_re = in[j][0];
++ float in0_im = in[j][1];
++ float in1_re = in[12-j][0];
++ float in1_im = in[12-j][1];
++ sum_re += filter[ssb][j][0] * (in0_re + in1_re) - filter[ssb][j][1] * (in0_im - in1_im);
++ sum_im += filter[ssb][j][0] * (in0_im + in1_im) + filter[ssb][j][1] * (in0_re - in1_re);
++ }
++ out[ssb][i][0] = sum_re;
++ out[ssb][i][1] = sum_im;
++ }
++ }
++}
++
++static void hybrid_analysis(float out[91][32][2], float in[5][44][2], float L[2][38][64], int is34, int len)
++{
++ int i, j;
++ for (i = 0; i < 5; i++) {
++ for (j = 0; j < 38; j++) {
++ in[i][j+6][0] = L[0][j][i];
++ in[i][j+6][1] = L[1][j][i];
++ }
++ }
++ if (is34) {
++ hybrid4_8_12_cx(in[0], out, f34_0_12, 12, len);
++ hybrid4_8_12_cx(in[1], out+12, f34_1_8, 8, len);
++ hybrid4_8_12_cx(in[2], out+20, f34_2_4, 4, len);
++ hybrid4_8_12_cx(in[3], out+24, f34_2_4, 4, len);
++ hybrid4_8_12_cx(in[4], out+28, f34_2_4, 4, len);
++ for (i = 0; i < 59; i++) {
++ for (j = 0; j < len; j++) {
++ out[i+32][j][0] = L[0][j][i+5];
++ out[i+32][j][1] = L[1][j][i+5];
++ }
++ }
++ } else {
++ hybrid6_cx(in[0], out, f20_0_8, len);
++ hybrid2_re(in[1], out+6, g1_Q2, len, 1);
++ hybrid2_re(in[2], out+8, g1_Q2, len, 0);
++ for (i = 0; i < 61; i++) {
++ for (j = 0; j < len; j++) {
++ out[i+10][j][0] = L[0][j][i+3];
++ out[i+10][j][1] = L[1][j][i+3];
++ }
++ }
++ }
++ //update in_buf
++ for (i = 0; i < 5; i++) {
++ memcpy(in[i], in[i]+32, 6 * sizeof(in[i][0]));
++ }
++}
++
++static void hybrid_synthesis(float out[2][38][64], float in[91][32][2], int is34, int len)
++{
++ int i, n;
++ if (is34) {
++ for (n = 0; n < len; n++) {
++ memset(out[0][n], 0, 5*sizeof(out[0][n][0]));
++ memset(out[1][n], 0, 5*sizeof(out[1][n][0]));
++ for (i = 0; i < 12; i++) {
++ out[0][n][0] += in[ i][n][0];
++ out[1][n][0] += in[ i][n][1];
++ }
++ for (i = 0; i < 8; i++) {
++ out[0][n][1] += in[12+i][n][0];
++ out[1][n][1] += in[12+i][n][1];
++ }
++ for (i = 0; i < 4; i++) {
++ out[0][n][2] += in[20+i][n][0];
++ out[1][n][2] += in[20+i][n][1];
++ out[0][n][3] += in[24+i][n][0];
++ out[1][n][3] += in[24+i][n][1];
++ out[0][n][4] += in[28+i][n][0];
++ out[1][n][4] += in[28+i][n][1];
++ }
++ }
++ for (i = 0; i < 59; i++) {
++ for (n = 0; n < len; n++) {
++ out[0][n][i+5] = in[i+32][n][0];
++ out[1][n][i+5] = in[i+32][n][1];
++ }
++ }
++ } else {
++ for (n = 0; n < len; n++) {
++ out[0][n][0] = in[0][n][0] + in[1][n][0] + in[2][n][0] +
++ in[3][n][0] + in[4][n][0] + in[5][n][0];
++ out[1][n][0] = in[0][n][1] + in[1][n][1] + in[2][n][1] +
++ in[3][n][1] + in[4][n][1] + in[5][n][1];
++ out[0][n][1] = in[6][n][0] + in[7][n][0];
++ out[1][n][1] = in[6][n][1] + in[7][n][1];
++ out[0][n][2] = in[8][n][0] + in[9][n][0];
++ out[1][n][2] = in[8][n][1] + in[9][n][1];
++ }
++ for (i = 0; i < 61; i++) {
++ for (n = 0; n < len; n++) {
++ out[0][n][i+3] = in[i+10][n][0];
++ out[1][n][i+3] = in[i+10][n][1];
++ }
++ }
++ }
++}
++
++/// All-pass filter decay slope
++#define DECAY_SLOPE 0.05f
++/// Number of frequency bands that can be addressed by the parameter index, b(k)
++static const int NR_PAR_BANDS[] = { 20, 34 };
++/// Number of frequency bands that can be addressed by the sub subband index, k
++static const int NR_BANDS[] = { 71, 91 };
++/// Start frequency band for the all-pass filter decay slope
++static const int DECAY_CUTOFF[] = { 10, 32 };
++/// Number of all-pass filer bands
++static const int NR_ALLPASS_BANDS[] = { 30, 50 };
++/// First stereo band using the short one sample delay
++static const int SHORT_DELAY_BAND[] = { 42, 62 };
++
++/** Table 8.46 */
++static void map_idx_10_to_20(int8_t *par_mapped, const int8_t *par, int full)
++{
++ int b;
++ if (full)
++ b = 9;
++ else {
++ b = 4;
++ par_mapped[10] = 0;
++ }
++ for (; b >= 0; b--) {
++ par_mapped[2*b+1] = par_mapped[2*b] = par[b];
++ }
++}
++
++static void map_idx_34_to_20(int8_t *par_mapped, const int8_t *par, int full)
++{
++ par_mapped[ 0] = (2*par[ 0] + par[ 1]) / 3;
++ par_mapped[ 1] = ( par[ 1] + 2*par[ 2]) / 3;
++ par_mapped[ 2] = (2*par[ 3] + par[ 4]) / 3;
++ par_mapped[ 3] = ( par[ 4] + 2*par[ 5]) / 3;
++ par_mapped[ 4] = ( par[ 6] + par[ 7]) / 2;
++ par_mapped[ 5] = ( par[ 8] + par[ 9]) / 2;
++ par_mapped[ 6] = par[10];
++ par_mapped[ 7] = par[11];
++ par_mapped[ 8] = ( par[12] + par[13]) / 2;
++ par_mapped[ 9] = ( par[14] + par[15]) / 2;
++ par_mapped[10] = par[16];
++ if (full) {
++ par_mapped[11] = par[17];
++ par_mapped[12] = par[18];
++ par_mapped[13] = par[19];
++ par_mapped[14] = ( par[20] + par[21]) / 2;
++ par_mapped[15] = ( par[22] + par[23]) / 2;
++ par_mapped[16] = ( par[24] + par[25]) / 2;
++ par_mapped[17] = ( par[26] + par[27]) / 2;
++ par_mapped[18] = ( par[28] + par[29] + par[30] + par[31]) / 4;
++ par_mapped[19] = ( par[32] + par[33]) / 2;
++ }
++}
++
++static void map_val_34_to_20(float par[PS_MAX_NR_IIDICC])
++{
++ par[ 0] = (2*par[ 0] + par[ 1]) * 0.33333333f;
++ par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333f;
++ par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333f;
++ par[ 3] = ( par[ 4] + 2*par[ 5]) * 0.33333333f;
++ par[ 4] = ( par[ 6] + par[ 7]) * 0.5f;
++ par[ 5] = ( par[ 8] + par[ 9]) * 0.5f;
++ par[ 6] = par[10];
++ par[ 7] = par[11];
++ par[ 8] = ( par[12] + par[13]) * 0.5f;
++ par[ 9] = ( par[14] + par[15]) * 0.5f;
++ par[10] = par[16];
++ par[11] = par[17];
++ par[12] = par[18];
++ par[13] = par[19];
++ par[14] = ( par[20] + par[21]) * 0.5f;
++ par[15] = ( par[22] + par[23]) * 0.5f;
++ par[16] = ( par[24] + par[25]) * 0.5f;
++ par[17] = ( par[26] + par[27]) * 0.5f;
++ par[18] = ( par[28] + par[29] + par[30] + par[31]) * 0.25f;
++ par[19] = ( par[32] + par[33]) * 0.5f;
++}
++
++static void map_idx_10_to_34(int8_t *par_mapped, const int8_t *par, int full)
++{
++ if (full) {
++ par_mapped[33] = par[9];
++ par_mapped[32] = par[9];
++ par_mapped[31] = par[9];
++ par_mapped[30] = par[9];
++ par_mapped[29] = par[9];
++ par_mapped[28] = par[9];
++ par_mapped[27] = par[8];
++ par_mapped[26] = par[8];
++ par_mapped[25] = par[8];
++ par_mapped[24] = par[8];
++ par_mapped[23] = par[7];
++ par_mapped[22] = par[7];
++ par_mapped[21] = par[7];
++ par_mapped[20] = par[7];
++ par_mapped[19] = par[6];
++ par_mapped[18] = par[6];
++ par_mapped[17] = par[5];
++ par_mapped[16] = par[5];
++ } else {
++ par_mapped[16] = 0;
++ }
++ par_mapped[15] = par[4];
++ par_mapped[14] = par[4];
++ par_mapped[13] = par[4];
++ par_mapped[12] = par[4];
++ par_mapped[11] = par[3];
++ par_mapped[10] = par[3];
++ par_mapped[ 9] = par[2];
++ par_mapped[ 8] = par[2];
++ par_mapped[ 7] = par[2];
++ par_mapped[ 6] = par[2];
++ par_mapped[ 5] = par[1];
++ par_mapped[ 4] = par[1];
++ par_mapped[ 3] = par[1];
++ par_mapped[ 2] = par[0];
++ par_mapped[ 1] = par[0];
++ par_mapped[ 0] = par[0];
++}
++
++static void map_idx_20_to_34(int8_t *par_mapped, const int8_t *par, int full)
++{
++ if (full) {
++ par_mapped[33] = par[19];
++ par_mapped[32] = par[19];
++ par_mapped[31] = par[18];
++ par_mapped[30] = par[18];
++ par_mapped[29] = par[18];
++ par_mapped[28] = par[18];
++ par_mapped[27] = par[17];
++ par_mapped[26] = par[17];
++ par_mapped[25] = par[16];
++ par_mapped[24] = par[16];
++ par_mapped[23] = par[15];
++ par_mapped[22] = par[15];
++ par_mapped[21] = par[14];
++ par_mapped[20] = par[14];
++ par_mapped[19] = par[13];
++ par_mapped[18] = par[12];
++ par_mapped[17] = par[11];
++ }
++ par_mapped[16] = par[10];
++ par_mapped[15] = par[ 9];
++ par_mapped[14] = par[ 9];
++ par_mapped[13] = par[ 8];
++ par_mapped[12] = par[ 8];
++ par_mapped[11] = par[ 7];
++ par_mapped[10] = par[ 6];
++ par_mapped[ 9] = par[ 5];
++ par_mapped[ 8] = par[ 5];
++ par_mapped[ 7] = par[ 4];
++ par_mapped[ 6] = par[ 4];
++ par_mapped[ 5] = par[ 3];
++ par_mapped[ 4] = (par[ 2] + par[ 3]) / 2;
++ par_mapped[ 3] = par[ 2];
++ par_mapped[ 2] = par[ 1];
++ par_mapped[ 1] = (par[ 0] + par[ 1]) / 2;
++ par_mapped[ 0] = par[ 0];
++}
++
++static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC])
++{
++ par[33] = par[19];
++ par[32] = par[19];
++ par[31] = par[18];
++ par[30] = par[18];
++ par[29] = par[18];
++ par[28] = par[18];
++ par[27] = par[17];
++ par[26] = par[17];
++ par[25] = par[16];
++ par[24] = par[16];
++ par[23] = par[15];
++ par[22] = par[15];
++ par[21] = par[14];
++ par[20] = par[14];
++ par[19] = par[13];
++ par[18] = par[12];
++ par[17] = par[11];
++ par[16] = par[10];
++ par[15] = par[ 9];
++ par[14] = par[ 9];
++ par[13] = par[ 8];
++ par[12] = par[ 8];
++ par[11] = par[ 7];
++ par[10] = par[ 6];
++ par[ 9] = par[ 5];
++ par[ 8] = par[ 5];
++ par[ 7] = par[ 4];
++ par[ 6] = par[ 4];
++ par[ 5] = par[ 3];
++ par[ 4] = (par[ 2] + par[ 3]) * 0.5f;
++ par[ 3] = par[ 2];
++ par[ 2] = par[ 1];
++ par[ 1] = (par[ 0] + par[ 1]) * 0.5f;
++ par[ 0] = par[ 0];
++}
++
++static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[32][2], int is34)
++{
++ float power[34][PS_QMF_TIME_SLOTS] = {{0}};
++ float transient_gain[34][PS_QMF_TIME_SLOTS];
++ float *peak_decay_nrg = ps->peak_decay_nrg;
++ float *power_smooth = ps->power_smooth;
++ float *peak_decay_diff_smooth = ps->peak_decay_diff_smooth;
++ float (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay;
++ float (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay;
++ const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
++ const float peak_decay_factor = 0.76592833836465f;
++ const float transient_impact = 1.5f;
++ const float a_smooth = 0.25f; //< Smoothing coefficient
++ int i, k, m, n;
++ int n0 = 0, nL = 32;
++ static const int link_delay[] = { 3, 4, 5 };
++ static const float a[] = { 0.65143905753106f,
++ 0.56471812200776f,
++ 0.48954165955695f };
++
++ if (is34 != ps->is34bands_old) {
++ memset(ps->peak_decay_nrg, 0, sizeof(ps->peak_decay_nrg));
++ memset(ps->power_smooth, 0, sizeof(ps->power_smooth));
++ memset(ps->peak_decay_diff_smooth, 0, sizeof(ps->peak_decay_diff_smooth));
++ memset(ps->delay, 0, sizeof(ps->delay));
++ memset(ps->ap_delay, 0, sizeof(ps->ap_delay));
++ }
++
++ for (n = n0; n < nL; n++) {
++ for (k = 0; k < NR_BANDS[is34]; k++) {
++ int i = k_to_i[k];
++ power[i][n] += s[k][n][0] * s[k][n][0] + s[k][n][1] * s[k][n][1];
++ }
++ }
++
++ //Transient detection
++ for (i = 0; i < NR_PAR_BANDS[is34]; i++) {
++ for (n = n0; n < nL; n++) {
++ float decayed_peak = peak_decay_factor * peak_decay_nrg[i];
++ float denom;
++ peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]);
++ power_smooth[i] += a_smooth * (power[i][n] - power_smooth[i]);
++ peak_decay_diff_smooth[i] += a_smooth * (peak_decay_nrg[i] - power[i][n] - peak_decay_diff_smooth[i]);
++ denom = transient_impact * peak_decay_diff_smooth[i];
++ transient_gain[i][n] = (denom > power_smooth[i]) ?
++ power_smooth[i] / denom : 1.0f;
++ }
++ }
++
++ //Decorrelation and transient reduction
++ // PS_AP_LINKS - 1
++ // -----
++ // | | Q_fract_allpass[k][m]*z^-link_delay[m] - a[m]*g_decay_slope[k]
++ //H[k][z] = z^-2 * phi_fract[k] * | | ----------------------------------------------------------------
++ // | | 1 - a[m]*g_decay_slope[k]*Q_fract_allpass[k][m]*z^-link_delay[m]
++ // m = 0
++ //d[k][z] (out) = transient_gain_mapped[k][z] * H[k][z] * s[k][z]
++ for (k = 0; k < NR_ALLPASS_BANDS[is34]; k++) {
++ int b = k_to_i[k];
++ float g_decay_slope = 1.f - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]);
++ float ag[PS_AP_LINKS];
++ g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f);
++ memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
++ memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
++ for (m = 0; m < PS_AP_LINKS; m++) {
++ memcpy(ap_delay[k][m], ap_delay[k][m]+numQMFSlots, 5*sizeof(ap_delay[k][m][0]));
++ ag[m] = a[m] * g_decay_slope;
++ }
++ for (n = n0; n < nL; n++) {
++ float in_re = delay[k][n+PS_MAX_DELAY-2][0] * phi_fract[is34][k][0] -
++ delay[k][n+PS_MAX_DELAY-2][1] * phi_fract[is34][k][1];
++ float in_im = delay[k][n+PS_MAX_DELAY-2][0] * phi_fract[is34][k][1] +
++ delay[k][n+PS_MAX_DELAY-2][1] * phi_fract[is34][k][0];
++ for (m = 0; m < PS_AP_LINKS; m++) {
++ float a_re = ag[m] * in_re;
++ float a_im = ag[m] * in_im;
++ float link_delay_re = ap_delay[k][m][n+5-link_delay[m]][0];
++ float link_delay_im = ap_delay[k][m][n+5-link_delay[m]][1];
++ float fractional_delay_re = Q_fract_allpass[is34][k][m][0];
++ float fractional_delay_im = Q_fract_allpass[is34][k][m][1];
++ ap_delay[k][m][n+5][0] = in_re;
++ ap_delay[k][m][n+5][1] = in_im;
++ in_re = link_delay_re * fractional_delay_re - link_delay_im * fractional_delay_im - a_re;
++ in_im = link_delay_re * fractional_delay_im + link_delay_im * fractional_delay_re - a_im;
++ ap_delay[k][m][n+5][0] += ag[m] * in_re;
++ ap_delay[k][m][n+5][1] += ag[m] * in_im;
++ }
++ out[k][n][0] = transient_gain[b][n] * in_re;
++ out[k][n][1] = transient_gain[b][n] * in_im;
++ }
++ }
++ for (; k < SHORT_DELAY_BAND[is34]; k++) {
++ memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
++ memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
++ for (n = n0; n < nL; n++) {
++ //H = delay 14
++ out[k][n][0] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-14][0];
++ out[k][n][1] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-14][1];
++ }
++ }
++ for (; k < NR_BANDS[is34]; k++) {
++ memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
++ memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
++ for (n = n0; n < nL; n++) {
++ //H = delay 1
++ out[k][n][0] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-1][0];
++ out[k][n][1] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-1][1];
++ }
++ }
++}
++
++static void remap34(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC],
++ int8_t (*par)[PS_MAX_NR_IIDICC],
++ int num_par, int num_env, int full)
++{
++ int8_t (*par_mapped)[PS_MAX_NR_IIDICC] = *p_par_mapped;
++ int e;
++ if (num_par == 20 || num_par == 11) {
++ for (e = 0; e < num_env; e++) {
++ map_idx_20_to_34(par_mapped[e], par[e], full);
++ }
++ } else if (num_par == 10 || num_par == 5) {
++ for (e = 0; e < num_env; e++) {
++ map_idx_10_to_34(par_mapped[e], par[e], full);
++ }
++ } else {
++ *p_par_mapped = par;
++ }
++}
++
++static void remap20(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC],
++ int8_t (*par)[PS_MAX_NR_IIDICC],
++ int num_par, int num_env, int full)
++{
++ int8_t (*par_mapped)[PS_MAX_NR_IIDICC] = *p_par_mapped;
++ int e;
++ if (num_par == 34 || num_par == 17) {
++ for (e = 0; e < num_env; e++) {
++ map_idx_34_to_20(par_mapped[e], par[e], full);
++ }
++ } else if (num_par == 10 || num_par == 5) {
++ for (e = 0; e < num_env; e++) {
++ map_idx_10_to_20(par_mapped[e], par[e], full);
++ }
++ } else {
++ *p_par_mapped = par;
++ }
++}
++
++static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2], int is34)
++{
++ int e, b, k, n;
++
++ float (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11;
++ float (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12;
++ float (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21;
++ float (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22;
++ int8_t *opd_hist = ps->opd_hist;
++ int8_t *ipd_hist = ps->ipd_hist;
++ int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
++ int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
++ int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
++ int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
++ int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf;
++ int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf;
++ int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf;
++ int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf;
++ const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
++ const float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB;
++
++ //Remapping
++ memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0]));
++ memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0]));
++ memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0]));
++ memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0]));
++ memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0]));
++ memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0]));
++ memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0]));
++ memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0]));
++ if (is34) {
++ remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
++ remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
++ if (ps->enable_ipdopd) {
++ remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
++ remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
++ }
++ if (!ps->is34bands_old) {
++ map_val_20_to_34(H11[0][0]);
++ map_val_20_to_34(H11[1][0]);
++ map_val_20_to_34(H12[0][0]);
++ map_val_20_to_34(H12[1][0]);
++ map_val_20_to_34(H21[0][0]);
++ map_val_20_to_34(H21[1][0]);
++ map_val_20_to_34(H22[0][0]);
++ map_val_20_to_34(H22[1][0]);
++ ipdopd_reset(ipd_hist, opd_hist);
++ }
++ } else {
++ remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
++ remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
++ if (ps->enable_ipdopd) {
++ remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
++ remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
++ }
++ if (ps->is34bands_old) {
++ map_val_34_to_20(H11[0][0]);
++ map_val_34_to_20(H11[1][0]);
++ map_val_34_to_20(H12[0][0]);
++ map_val_34_to_20(H12[1][0]);
++ map_val_34_to_20(H21[0][0]);
++ map_val_34_to_20(H21[1][0]);
++ map_val_34_to_20(H22[0][0]);
++ map_val_34_to_20(H22[1][0]);
++ ipdopd_reset(ipd_hist, opd_hist);
++ }
++ }
++
++ //Mixing
++ for (e = 0; e < ps->num_env; e++) {
++ for (b = 0; b < NR_PAR_BANDS[is34]; b++) {
++ float h11, h12, h21, h22;
++ h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0];
++ h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1];
++ h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2];
++ h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3];
++ if (!PS_BASELINE && ps->enable_ipdopd && b < ps->nr_ipdopd_par) {
++ //The spec say says to only run this smoother when enable_ipdopd
++ //is set but the reference decoder appears to run it constantly
++ float h11i, h12i, h21i, h22i;
++ float ipd_adj_re, ipd_adj_im;
++ int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b];
++ int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b];
++ float opd_re = pd_re_smooth[opd_idx];
++ float opd_im = pd_im_smooth[opd_idx];
++ float ipd_re = pd_re_smooth[ipd_idx];
++ float ipd_im = pd_im_smooth[ipd_idx];
++ opd_hist[b] = opd_idx & 0x3F;
++ ipd_hist[b] = ipd_idx & 0x3F;
++
++ ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im;
++ ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im;
++ h11i = h11 * opd_im;
++ h11 = h11 * opd_re;
++ h12i = h12 * ipd_adj_im;
++ h12 = h12 * ipd_adj_re;
++ h21i = h21 * opd_im;
++ h21 = h21 * opd_re;
++ h22i = h22 * ipd_adj_im;
++ h22 = h22 * ipd_adj_re;
++ H11[1][e+1][b] = h11i;
++ H12[1][e+1][b] = h12i;
++ H21[1][e+1][b] = h21i;
++ H22[1][e+1][b] = h22i;
++ }
++ H11[0][e+1][b] = h11;
++ H12[0][e+1][b] = h12;
++ H21[0][e+1][b] = h21;
++ H22[0][e+1][b] = h22;
++ }
++ for (k = 0; k < NR_BANDS[is34]; k++) {
++ float h11r, h12r, h21r, h22r;
++ float h11i, h12i, h21i, h22i;
++ float h11r_step, h12r_step, h21r_step, h22r_step;
++ float h11i_step, h12i_step, h21i_step, h22i_step;
++ int start = ps->border_position[e];
++ int stop = ps->border_position[e+1];
++ float width = 1.f / (stop - start);
++ b = k_to_i[k];
++ h11r = H11[0][e][b];
++ h12r = H12[0][e][b];
++ h21r = H21[0][e][b];
++ h22r = H22[0][e][b];
++ if (!PS_BASELINE && ps->enable_ipdopd) {
++ //Is this necessary? ps_04_new seems unchanged
++ if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) {
++ h11i = -H11[1][e][b];
++ h12i = -H12[1][e][b];
++ h21i = -H21[1][e][b];
++ h22i = -H22[1][e][b];
++ } else {
++ h11i = H11[1][e][b];
++ h12i = H12[1][e][b];
++ h21i = H21[1][e][b];
++ h22i = H22[1][e][b];
++ }
++ }
++ //Interpolation
++ h11r_step = (H11[0][e+1][b] - h11r) * width;
++ h12r_step = (H12[0][e+1][b] - h12r) * width;
++ h21r_step = (H21[0][e+1][b] - h21r) * width;
++ h22r_step = (H22[0][e+1][b] - h22r) * width;
++ if (!PS_BASELINE && ps->enable_ipdopd) {
++ h11i_step = (H11[1][e+1][b] - h11i) * width;
++ h12i_step = (H12[1][e+1][b] - h12i) * width;
++ h21i_step = (H21[1][e+1][b] - h21i) * width;
++ h22i_step = (H22[1][e+1][b] - h22i) * width;
++ }
++ for (n = start + 1; n <= stop; n++) {
++ //l is s, r is d
++ float l_re = l[k][n][0];
++ float l_im = l[k][n][1];
++ float r_re = r[k][n][0];
++ float r_im = r[k][n][1];
++ h11r += h11r_step;
++ h12r += h12r_step;
++ h21r += h21r_step;
++ h22r += h22r_step;
++ if (!PS_BASELINE && ps->enable_ipdopd) {
++ h11i += h11i_step;
++ h12i += h12i_step;
++ h21i += h21i_step;
++ h22i += h22i_step;
++
++ l[k][n][0] = h11r*l_re + h21r*r_re - h11i*l_im - h21i*r_im;
++ l[k][n][1] = h11r*l_im + h21r*r_im + h11i*l_re + h21i*r_re;
++ r[k][n][0] = h12r*l_re + h22r*r_re - h12i*l_im - h22i*r_im;
++ r[k][n][1] = h12r*l_im + h22r*r_im + h12i*l_re + h22i*r_re;
++ } else {
++ l[k][n][0] = h11r*l_re + h21r*r_re;
++ l[k][n][1] = h11r*l_im + h21r*r_im;
++ r[k][n][0] = h12r*l_re + h22r*r_re;
++ r[k][n][1] = h12r*l_im + h22r*r_im;
++ }
++ }
++ }
++ }
++}
++
++int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top)
++{
++ float Lbuf[91][32][2];
++ float Rbuf[91][32][2];
++ const int len = 32;
++ int is34 = ps->is34bands;
++
++ top += NR_BANDS[is34] - 64;
++ memset(ps->delay+top, 0, (NR_BANDS[is34] - top)*sizeof(ps->delay[0]));
++ if (top < NR_ALLPASS_BANDS[is34])
++ memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*sizeof(ps->ap_delay[0]));
++
++ hybrid_analysis(Lbuf, ps->in_buf, L, is34, len);
++ decorrelation(ps, Rbuf, Lbuf, is34);
++ stereo_processing(ps, Lbuf, Rbuf, is34);
++ hybrid_synthesis(L, Lbuf, is34, len);
++ hybrid_synthesis(R, Rbuf, is34, len);
++
++ return 0;
++}
++
++#define PS_INIT_VLC_STATIC(num, size) \
++ INIT_VLC_STATIC(&vlc_ps[num], 9, ps_tmp[num].table_size / ps_tmp[num].elem_size, \
++ ps_tmp[num].ps_bits, 1, 1, \
++ ps_tmp[num].ps_codes, ps_tmp[num].elem_size, ps_tmp[num].elem_size, \
++ size);
++
++#define PS_VLC_ROW(name) \
++ { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) }
++
++av_cold void ff_ps_init(void) {
++ // Syntax initialization
++ static const struct {
++ const void *ps_codes, *ps_bits;
++ const unsigned int table_size, elem_size;
++ } ps_tmp[] = {
++ PS_VLC_ROW(huff_iid_df1),
++ PS_VLC_ROW(huff_iid_dt1),
++ PS_VLC_ROW(huff_iid_df0),
++ PS_VLC_ROW(huff_iid_dt0),
++ PS_VLC_ROW(huff_icc_df),
++ PS_VLC_ROW(huff_icc_dt),
++ PS_VLC_ROW(huff_ipd_df),
++ PS_VLC_ROW(huff_ipd_dt),
++ PS_VLC_ROW(huff_opd_df),
++ PS_VLC_ROW(huff_opd_dt),
++ };
++
++ PS_INIT_VLC_STATIC(0, 1544);
++ PS_INIT_VLC_STATIC(1, 832);
++ PS_INIT_VLC_STATIC(2, 1024);
++ PS_INIT_VLC_STATIC(3, 1036);
++ PS_INIT_VLC_STATIC(4, 544);
++ PS_INIT_VLC_STATIC(5, 544);
++ PS_INIT_VLC_STATIC(6, 512);
++ PS_INIT_VLC_STATIC(7, 512);
++ PS_INIT_VLC_STATIC(8, 512);
++ PS_INIT_VLC_STATIC(9, 512);
++
++ ps_tableinit();
++}
++
++av_cold void ff_ps_ctx_init(PSContext *ps)
++{
++}
+--- /dev/null
++++ b/libavcodec/aacps.h
+@@ -0,0 +1,82 @@
++/*
++ * MPEG-4 Parametric Stereo definitions and declarations
++ * Copyright (c) 2010 Alex Converse
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#ifndef AVCODEC_PS_H
++#define AVCODEC_PS_H
++
++#include
++
++#include "avcodec.h"
++#include "get_bits.h"
++
++#define PS_MAX_NUM_ENV 5
++#define PS_MAX_NR_IIDICC 34
++#define PS_MAX_NR_IPDOPD 17
++#define PS_MAX_SSB 91
++#define PS_MAX_AP_BANDS 50
++#define PS_QMF_TIME_SLOTS 32
++#define PS_MAX_DELAY 14
++#define PS_AP_LINKS 3
++#define PS_MAX_AP_DELAY 5
++
++typedef struct {
++ int start;
++ int enable_iid;
++ int iid_quant;
++ int nr_iid_par;
++ int nr_ipdopd_par;
++ int enable_icc;
++ int icc_mode;
++ int nr_icc_par;
++ int enable_ext;
++ int frame_class;
++ int num_env_old;
++ int num_env;
++ int enable_ipdopd;
++ int border_position[PS_MAX_NUM_ENV+1];
++ int8_t iid_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; //
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++static const uint8_t huff_iid_df1_bits[] = {
++ 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 18, 17, 17, 16, 16, 15, 14, 14,
++ 13, 12, 12, 11, 10, 10, 8, 7, 6, 5, 4, 3, 1, 3, 4, 5, 6, 7,
++ 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 16, 17, 17, 18, 17, 18, 18,
++ 18, 18, 18, 18, 18, 18, 18,
++};
++
++static const uint32_t huff_iid_df1_codes[] = {
++ 0x01FEB4, 0x01FEB5, 0x01FD76, 0x01FD77, 0x01FD74, 0x01FD75, 0x01FE8A,
++ 0x01FE8B, 0x01FE88, 0x00FE80, 0x01FEB6, 0x00FE82, 0x00FEB8, 0x007F42,
++ 0x007FAE, 0x003FAF, 0x001FD1, 0x001FE9, 0x000FE9, 0x0007EA, 0x0007FB,
++ 0x0003FB, 0x0001FB, 0x0001FF, 0x00007C, 0x00003C, 0x00001C, 0x00000C,
++ 0x000000, 0x000001, 0x000001, 0x000002, 0x000001, 0x00000D, 0x00001D,
++ 0x00003D, 0x00007D, 0x0000FC, 0x0001FC, 0x0003FC, 0x0003F4, 0x0007EB,
++ 0x000FEA, 0x001FEA, 0x001FD6, 0x003FD0, 0x007FAF, 0x007F43, 0x00FEB9,
++ 0x00FE83, 0x01FEB7, 0x00FE81, 0x01FE89, 0x01FE8E, 0x01FE8F, 0x01FE8C,
++ 0x01FE8D, 0x01FEB2, 0x01FEB3, 0x01FEB0, 0x01FEB1,
++};
++
++static const uint8_t huff_iid_dt1_bits[] = {
++ 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 13,
++ 13, 13, 12, 12, 11, 10, 9, 9, 7, 6, 5, 3, 1, 2, 5, 6, 7, 8,
++ 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16,
++ 16, 16, 16, 16, 16, 16, 16,
++};
++
++static const uint16_t huff_iid_dt1_codes[] = {
++ 0x004ED4, 0x004ED5, 0x004ECE, 0x004ECF, 0x004ECC, 0x004ED6, 0x004ED8,
++ 0x004F46, 0x004F60, 0x002718, 0x002719, 0x002764, 0x002765, 0x00276D,
++ 0x0027B1, 0x0013B7, 0x0013D6, 0x0009C7, 0x0009E9, 0x0009ED, 0x0004EE,
++ 0x0004F7, 0x000278, 0x000139, 0x00009A, 0x00009F, 0x000020, 0x000011,
++ 0x00000A, 0x000003, 0x000001, 0x000000, 0x00000B, 0x000012, 0x000021,
++ 0x00004C, 0x00009B, 0x00013A, 0x000279, 0x000270, 0x0004EF, 0x0004E2,
++ 0x0009EA, 0x0009D8, 0x0013D7, 0x0013D0, 0x0027B2, 0x0027A2, 0x00271A,
++ 0x00271B, 0x004F66, 0x004F67, 0x004F61, 0x004F47, 0x004ED9, 0x004ED7,
++ 0x004ECD, 0x004ED2, 0x004ED3, 0x004ED0, 0x004ED1,
++};
++
++static const uint8_t huff_iid_df0_bits[] = {
++ 17, 17, 17, 17, 16, 15, 13, 10, 9, 7, 6, 5, 4, 3, 1, 3, 4, 5,
++ 6, 6, 8, 11, 13, 14, 14, 15, 17, 18, 18,
++};
++
++static const uint32_t huff_iid_df0_codes[] = {
++ 0x01FFFB, 0x01FFFC, 0x01FFFD, 0x01FFFA, 0x00FFFC, 0x007FFC, 0x001FFD,
++ 0x0003FE, 0x0001FE, 0x00007E, 0x00003C, 0x00001D, 0x00000D, 0x000005,
++ 0x000000, 0x000004, 0x00000C, 0x00001C, 0x00003D, 0x00003E, 0x0000FE,
++ 0x0007FE, 0x001FFC, 0x003FFC, 0x003FFD, 0x007FFD, 0x01FFFE, 0x03FFFE,
++ 0x03FFFF,
++};
++
++static const uint8_t huff_iid_dt0_bits[] = {
++ 19, 19, 19, 20, 20, 20, 17, 15, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7,
++ 9, 11, 13, 14, 17, 19, 20, 20, 20, 20, 20,
++};
++
++static const uint32_t huff_iid_dt0_codes[] = {
++ 0x07FFF9, 0x07FFFA, 0x07FFFB, 0x0FFFF8, 0x0FFFF9, 0x0FFFFA, 0x01FFFD,
++ 0x007FFE, 0x000FFE, 0x0003FE, 0x0000FE, 0x00003E, 0x00000E, 0x000002,
++ 0x000000, 0x000006, 0x00001E, 0x00007E, 0x0001FE, 0x0007FE, 0x001FFE,
++ 0x003FFE, 0x01FFFC, 0x07FFF8, 0x0FFFFB, 0x0FFFFC, 0x0FFFFD, 0x0FFFFE,
++ 0x0FFFFF,
++};
++
++static const uint8_t huff_icc_df_bits[] = {
++ 14, 14, 12, 10, 7, 5, 3, 1, 2, 4, 6, 8, 9, 11, 13,
++};
++
++static const uint16_t huff_icc_df_codes[] = {
++ 0x3FFF, 0x3FFE, 0x0FFE, 0x03FE, 0x007E, 0x001E, 0x0006, 0x0000,
++ 0x0002, 0x000E, 0x003E, 0x00FE, 0x01FE, 0x07FE, 0x1FFE,
++};
++
++static const uint8_t huff_icc_dt_bits[] = {
++ 14, 13, 11, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14,
++};
++
++static const uint16_t huff_icc_dt_codes[] = {
++ 0x3FFE, 0x1FFE, 0x07FE, 0x01FE, 0x007E, 0x001E, 0x0006, 0x0000,
++ 0x0002, 0x000E, 0x003E, 0x00FE, 0x03FE, 0x0FFE, 0x3FFF,
++};
++
++static const uint8_t huff_ipd_df_bits[] = {
++ 1, 3, 4, 4, 4, 4, 4, 4,
++};
++
++static const uint8_t huff_ipd_df_codes[] = {
++ 0x01, 0x00, 0x06, 0x04, 0x02, 0x03, 0x05, 0x07,
++};
++
++static const uint8_t huff_ipd_dt_bits[] = {
++ 1, 3, 4, 5, 5, 4, 4, 3,
++};
++
++static const uint8_t huff_ipd_dt_codes[] = {
++ 0x01, 0x02, 0x02, 0x03, 0x02, 0x00, 0x03, 0x03,
++};
++
++static const uint8_t huff_opd_df_bits[] = {
++ 1, 3, 4, 4, 5, 5, 4, 3,
++};
++
++static const uint8_t huff_opd_df_codes[] = {
++ 0x01, 0x01, 0x06, 0x04, 0x0F, 0x0E, 0x05, 0x00,
++};
++
++static const uint8_t huff_opd_dt_bits[] = {
++ 1, 3, 4, 5, 5, 4, 4, 3,
++};
++
++static const uint8_t huff_opd_dt_codes[] = {
++ 0x01, 0x02, 0x01, 0x07, 0x06, 0x00, 0x02, 0x03,
++};
++
++static const int8_t huff_offset[] = {
++ 30, 30,
++ 14, 14,
++ 7, 7,
++ 0, 0,
++ 0, 0,
++};
++
++///Table 8.48
++static const int8_t k_to_i_20[] = {
++ 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, 15,
++ 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18,
++ 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
++ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19
++};
++///Table 8.49
++static const int8_t k_to_i_34[] = {
++ 0, 1, 2, 3, 4, 5, 6, 6, 7, 2, 1, 0, 10, 10, 4, 5, 6, 7, 8,
++ 9, 10, 11, 12, 9, 14, 11, 12, 13, 14, 15, 16, 13, 16, 17, 18, 19, 20, 21,
++ 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29,
++ 30, 30, 30, 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
++ 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33
++};
++
++static const float g1_Q2[] = {
++ 0.0f, 0.01899487526049f, 0.0f, -0.07293139167538f,
++ 0.0f, 0.30596630545168f, 0.5f
++};
+--- a/libavcodec/sbr.h
++++ b/libavcodec/sbr.h
+@@ -31,6 +31,7 @@
+
+ #include
+ #include "fft.h"
++#include "aacps.h"
+
+ /**
+ * Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the previous header.
+@@ -133,6 +134,7 @@ typedef struct {
+ ///The number of frequency bands in f_master
+ unsigned n_master;
+ SBRData data[2];
++ PSContext ps;
+ ///N_Low and N_High respectively, the number of frequency bands for low and high resolution
+ unsigned n[2];
+ ///Number of noise floor bands
+@@ -157,7 +159,7 @@ typedef struct {
+ ///QMF output of the HF generator
+ float X_high[64][40][2];
+ ///QMF values of the reconstructed signal
+- DECLARE_ALIGNED(16, float, X)[2][2][32][64];
++ DECLARE_ALIGNED(16, float, X)[2][2][38][64];
+ ///Zeroth coefficient used to filter the subband signals
+ float alpha0[64][2];
+ ///First coefficient used to filter the subband signals
+@@ -176,7 +178,7 @@ typedef struct {
+ float s_m[7][48];
+ float gain[7][48];
+ DECLARE_ALIGNED(16, float, qmf_filter_scratch)[5][64];
+- RDFTContext rdft;
++ FFTContext mdct_ana;
+ FFTContext mdct;
+ } SpectralBandReplication;
+
+--- a/libavcodec/Makefile
++++ b/libavcodec/Makefile
+@@ -43,7 +43,7 @@ OBJS-$(CONFIG_VAAPI) +
+ OBJS-$(CONFIG_VDPAU) += vdpau.o
+
+ # decoders/encoders/hardware accelerators
+-OBJS-$(CONFIG_AAC_DECODER) += aac.o aactab.o aacsbr.o
++OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o
+ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \
+ aacpsy.o aactab.o \
+ psymodel.o iirfilter.o \
+--- a/libavcodec/aacsbr.c
++++ b/libavcodec/aacsbr.c
+@@ -31,6 +31,7 @@
+ #include "aacsbr.h"
+ #include "aacsbrdata.h"
+ #include "fft.h"
++#include "aacps.h"
+
+ #include
+ #include
+@@ -71,9 +72,6 @@ enum {
+ static VLC vlc_sbr[10];
+ static const int8_t vlc_sbr_lav[10] =
+ { 60, 60, 24, 24, 31, 31, 12, 12, 31, 12 };
+-static DECLARE_ALIGNED(16, float, analysis_cos_pre)[64];
+-static DECLARE_ALIGNED(16, float, analysis_sin_pre)[64];
+-static DECLARE_ALIGNED(16, float, analysis_cossin_post)[32][2];
+ static const DECLARE_ALIGNED(16, float, zero64)[64];
+
+ #define SBR_INIT_VLC_STATIC(num, size) \
+@@ -87,7 +85,7 @@ static const DECLARE_ALIGNED(16, float,
+
+ av_cold void ff_aac_sbr_init(void)
+ {
+- int n, k;
++ int n;
+ static const struct {
+ const void *sbr_codes, *sbr_bits;
+ const unsigned int table_size, elem_size;
+@@ -116,16 +114,6 @@ av_cold void ff_aac_sbr_init(void)
+ SBR_INIT_VLC_STATIC(8, 592);
+ SBR_INIT_VLC_STATIC(9, 512);
+
+- for (n = 0; n < 64; n++) {
+- float pre = M_PI * n / 64;
+- analysis_cos_pre[n] = cosf(pre);
+- analysis_sin_pre[n] = sinf(pre);
+- }
+- for (k = 0; k < 32; k++) {
+- float post = M_PI * (k + 0.5) / 128;
+- analysis_cossin_post[k][0] = 4.0 * cosf(post);
+- analysis_cossin_post[k][1] = -4.0 * sinf(post);
+- }
+ for (n = 1; n < 320; n++)
+ sbr_qmf_window_us[320 + n] = sbr_qmf_window_us[320 - n];
+ sbr_qmf_window_us[384] = -sbr_qmf_window_us[384];
+@@ -133,6 +121,8 @@ av_cold void ff_aac_sbr_init(void)
+
+ for (n = 0; n < 320; n++)
+ sbr_qmf_window_ds[n] = sbr_qmf_window_us[2*n];
++
++ ff_ps_init();
+ }
+
+ av_cold void ff_aac_sbr_ctx_init(SpectralBandReplication *sbr)
+@@ -142,13 +132,14 @@ av_cold void ff_aac_sbr_ctx_init(Spectra
+ sbr->data[0].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128);
+ sbr->data[1].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128);
+ ff_mdct_init(&sbr->mdct, 7, 1, 1.0/64);
+- ff_rdft_init(&sbr->rdft, 6, IDFT_R2C);
++ ff_mdct_init(&sbr->mdct_ana, 7, 1, -2.0);
++ ff_ps_ctx_init(&sbr->ps);
+ }
+
+ av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr)
+ {
+ ff_mdct_end(&sbr->mdct);
+- ff_rdft_end(&sbr->rdft);
++ ff_mdct_end(&sbr->mdct_ana);
+ }
+
+ static int qsort_comparison_function_int16(const void *a, const void *b)
+@@ -293,15 +284,15 @@ static void make_bands(int16_t* bands, i
+ bands[num_bands-1] = stop - previous;
+ }
+
+-static int check_n_master(AVCodecContext *avccontext, int n_master, int bs_xover_band)
++static int check_n_master(AVCodecContext *avctx, int n_master, int bs_xover_band)
+ {
+ // Requirements (14496-3 sp04 p205)
+ if (n_master <= 0) {
+- av_log(avccontext, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master);
++ av_log(avctx, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master);
+ return -1;
+ }
+ if (bs_xover_band >= n_master) {
+- av_log(avccontext, AV_LOG_ERROR,
++ av_log(avctx, AV_LOG_ERROR,
+ "Invalid bitstream, crossover band index beyond array bounds: %d\n",
+ bs_xover_band);
+ return -1;
+@@ -349,7 +340,7 @@ static int sbr_make_f_master(AACContext
+ sbr_offset_ptr = sbr_offset[5];
+ break;
+ default:
+- av_log(ac->avccontext, AV_LOG_ERROR,
++ av_log(ac->avctx, AV_LOG_ERROR,
+ "Unsupported sample rate for SBR: %d\n", sbr->sample_rate);
+ return -1;
+ }
+@@ -367,7 +358,7 @@ static int sbr_make_f_master(AACContext
+ } else if (spectrum->bs_stop_freq == 15) {
+ sbr->k[2] = 3*sbr->k[0];
+ } else {
+- av_log(ac->avccontext, AV_LOG_ERROR,
++ av_log(ac->avctx, AV_LOG_ERROR,
+ "Invalid bs_stop_freq: %d\n", spectrum->bs_stop_freq);
+ return -1;
+ }
+@@ -382,18 +373,17 @@ static int sbr_make_f_master(AACContext
+ max_qmf_subbands = 32;
+
+ if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) {
+- av_log(ac->avccontext, AV_LOG_ERROR,
++ av_log(ac->avctx, AV_LOG_ERROR,
+ "Invalid bitstream, too many QMF subbands: %d\n", sbr->k[2] - sbr->k[0]);
+ return -1;
+ }
+
+ if (!spectrum->bs_freq_scale) {
+- unsigned int dk;
+- int k2diff;
++ int dk, k2diff;
+
+ dk = spectrum->bs_alter_scale + 1;
+ sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1;
+- if (check_n_master(ac->avccontext, sbr->n_master, sbr->spectrum_params.bs_xover_band))
++ if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
+ return -1;
+
+ for (k = 1; k <= sbr->n_master; k++)
+@@ -428,7 +418,7 @@ static int sbr_make_f_master(AACContext
+ num_bands_0 = lrintf(half_bands * log2f(sbr->k[1] / (float)sbr->k[0])) * 2;
+
+ if (num_bands_0 <= 0) { // Requirements (14496-3 sp04 p205)
+- av_log(ac->avccontext, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0);
++ av_log(ac->avctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0);
+ return -1;
+ }
+
+@@ -442,7 +432,7 @@ static int sbr_make_f_master(AACContext
+ vk0[0] = sbr->k[0];
+ for (k = 1; k <= num_bands_0; k++) {
+ if (vk0[k] <= 0) { // Requirements (14496-3 sp04 p205)
+- av_log(ac->avccontext, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]);
++ av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]);
+ return -1;
+ }
+ vk0[k] += vk0[k-1];
+@@ -472,14 +462,14 @@ static int sbr_make_f_master(AACContext
+ vk1[0] = sbr->k[1];
+ for (k = 1; k <= num_bands_1; k++) {
+ if (vk1[k] <= 0) { // Requirements (14496-3 sp04 p205)
+- av_log(ac->avccontext, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]);
++ av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]);
+ return -1;
+ }
+ vk1[k] += vk1[k-1];
+ }
+
+ sbr->n_master = num_bands_0 + num_bands_1;
+- if (check_n_master(ac->avccontext, sbr->n_master, sbr->spectrum_params.bs_xover_band))
++ if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
+ return -1;
+ memcpy(&sbr->f_master[0], vk0,
+ (num_bands_0 + 1) * sizeof(sbr->f_master[0]));
+@@ -488,7 +478,7 @@ static int sbr_make_f_master(AACContext
+
+ } else {
+ sbr->n_master = num_bands_0;
+- if (check_n_master(ac->avccontext, sbr->n_master, sbr->spectrum_params.bs_xover_band))
++ if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
+ return -1;
+ memcpy(sbr->f_master, vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0]));
+ }
+@@ -524,7 +514,7 @@ static int sbr_hf_calc_npatches(AACConte
+ // illegal however the Coding Technologies decoder check stream has a final
+ // count of 6 patches
+ if (sbr->num_patches > 5) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches);
++ av_log(ac->avctx, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches);
+ return -1;
+ }
+
+@@ -563,12 +553,12 @@ static int sbr_make_f_derived(AACContext
+
+ // Requirements (14496-3 sp04 p205)
+ if (sbr->kx[1] + sbr->m[1] > 64) {
+- av_log(ac->avccontext, AV_LOG_ERROR,
++ av_log(ac->avctx, AV_LOG_ERROR,
+ "Stop frequency border too high: %d\n", sbr->kx[1] + sbr->m[1]);
+ return -1;
+ }
+ if (sbr->kx[1] > 32) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]);
++ av_log(ac->avctx, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]);
+ return -1;
+ }
+
+@@ -580,7 +570,7 @@ static int sbr_make_f_derived(AACContext
+ sbr->n_q = FFMAX(1, lrintf(sbr->spectrum_params.bs_noise_bands *
+ log2f(sbr->k[2] / (float)sbr->kx[1]))); // 0 <= bs_noise_bands <= 3
+ if (sbr->n_q > 5) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q);
++ av_log(ac->avctx, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q);
+ return -1;
+ }
+
+@@ -638,7 +628,7 @@ static int read_sbr_grid(AACContext *ac,
+ ch_data->bs_amp_res = 0;
+
+ if (ch_data->bs_num_env > 4) {
+- av_log(ac->avccontext, AV_LOG_ERROR,
++ av_log(ac->avctx, AV_LOG_ERROR,
+ "Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n",
+ ch_data->bs_num_env);
+ return -1;
+@@ -693,7 +683,7 @@ static int read_sbr_grid(AACContext *ac,
+ ch_data->bs_num_env = num_rel_lead + num_rel_trail + 1;
+
+ if (ch_data->bs_num_env > 5) {
+- av_log(ac->avccontext, AV_LOG_ERROR,
++ av_log(ac->avctx, AV_LOG_ERROR,
+ "Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n",
+ ch_data->bs_num_env);
+ return -1;
+@@ -714,7 +704,7 @@ static int read_sbr_grid(AACContext *ac,
+ }
+
+ if (bs_pointer > ch_data->bs_num_env + 1) {
+- av_log(ac->avccontext, AV_LOG_ERROR,
++ av_log(ac->avctx, AV_LOG_ERROR,
+ "Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n",
+ bs_pointer);
+ return -1;
+@@ -722,7 +712,7 @@ static int read_sbr_grid(AACContext *ac,
+
+ for (i = 1; i <= ch_data->bs_num_env; i++) {
+ if (ch_data->t_env[i-1] > ch_data->t_env[i]) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "Non monotone time borders\n");
++ av_log(ac->avctx, AV_LOG_ERROR, "Non monotone time borders\n");
+ return -1;
+ }
+ }
+@@ -903,25 +893,24 @@ static void read_sbr_extension(AACContex
+ GetBitContext *gb,
+ int bs_extension_id, int *num_bits_left)
+ {
+-//TODO - implement ps_data for parametric stereo parsing
+ switch (bs_extension_id) {
+ case EXTENSION_ID_PS:
+ if (!ac->m4ac.ps) {
+- av_log(ac->avccontext, AV_LOG_ERROR, "Parametric Stereo signaled to be not-present but was found in the bitstream.\n");
++ av_log(ac->avctx, AV_LOG_ERROR, "Parametric Stereo signaled to be not-present but was found in the bitstream.\n");
+ skip_bits_long(gb, *num_bits_left); // bs_fill_bits
+ *num_bits_left = 0;
+ } else {
+-#if 0
+- *num_bits_left -= ff_ps_data(gb, ps);
++#if 1
++ *num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps, *num_bits_left);
+ #else
+- av_log_missing_feature(ac->avccontext, "Parametric Stereo is", 0);
++ av_log_missing_feature(ac->avctx, "Parametric Stereo is", 0);
+ skip_bits_long(gb, *num_bits_left); // bs_fill_bits
+ *num_bits_left = 0;
+ #endif
+ }
+ break;
+ default:
+- av_log_missing_feature(ac->avccontext, "Reserved SBR extensions are", 1);
++ av_log_missing_feature(ac->avctx, "Reserved SBR extensions are", 1);
+ skip_bits_long(gb, *num_bits_left); // bs_fill_bits
+ *num_bits_left = 0;
+ break;
+@@ -1006,7 +995,7 @@ static unsigned int read_sbr_data(AACCon
+ return get_bits_count(gb) - cnt;
+ }
+ } else {
+- av_log(ac->avccontext, AV_LOG_ERROR,
++ av_log(ac->avctx, AV_LOG_ERROR,
+ "Invalid bitstream - cannot apply SBR to element type %d\n", id_aac);
+ sbr->start = 0;
+ return get_bits_count(gb) - cnt;
+@@ -1021,6 +1010,11 @@ static unsigned int read_sbr_data(AACCon
+ num_bits_left -= 2;
+ read_sbr_extension(ac, sbr, gb, get_bits(gb, 2), &num_bits_left); // bs_extension_id
+ }
++ if (num_bits_left < 0) {
++ av_log(ac->avctx, AV_LOG_ERROR, "SBR Extension over read.\n");
++ }
++ if (num_bits_left > 0)
++ skip_bits(gb, num_bits_left);
+ }
+
+ return get_bits_count(gb) - cnt;
+@@ -1033,7 +1027,7 @@ static void sbr_reset(AACContext *ac, Sp
+ if (err >= 0)
+ err = sbr_make_f_derived(ac, sbr);
+ if (err < 0) {
+- av_log(ac->avccontext, AV_LOG_ERROR,
++ av_log(ac->avctx, AV_LOG_ERROR,
+ "SBR reset failed. Switching SBR to pure upsampling mode.\n");
+ sbr->start = 0;
+ }
+@@ -1085,7 +1079,7 @@ int ff_decode_sbr_extension(AACContext *
+ bytes_read = ((num_sbr_bits + num_align_bits + 4) >> 3);
+
+ if (bytes_read > cnt) {
+- av_log(ac->avccontext, AV_LOG_ERROR,
++ av_log(ac->avctx, AV_LOG_ERROR,
+ "Expected to read %d SBR bytes actually read %d.\n", cnt, bytes_read);
+ }
+ return cnt;
+@@ -1139,7 +1133,7 @@ static void sbr_dequant(SpectralBandRepl
+ * @param x pointer to the beginning of the first sample window
+ * @param W array of complex-valued samples split into subbands
+ */
+-static void sbr_qmf_analysis(DSPContext *dsp, RDFTContext *rdft, const float *in, float *x,
++static void sbr_qmf_analysis(DSPContext *dsp, FFTContext *mdct, const float *in, float *x,
+ float z[320], float W[2][32][32][2],
+ float scale)
+ {
+@@ -1152,23 +1146,23 @@ static void sbr_qmf_analysis(DSPContext
+ memcpy(x+288, in, 1024*sizeof(*x));
+ for (i = 0; i < 32; i++) { // numTimeSlots*RATE = 16*2 as 960 sample frames
+ // are not supported
+- float re, im;
+ dsp->vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320);
+ for (k = 0; k < 64; k++) {
+ float f = z[k] + z[k + 64] + z[k + 128] + z[k + 192] + z[k + 256];
+- z[k] = f * analysis_cos_pre[k];
+- z[k+64] = f;
++ z[k] = f;
+ }
+- ff_rdft_calc(rdft, z);
+- re = z[0] * 0.5f;
+- im = 0.5f * dsp->scalarproduct_float(z+64, analysis_sin_pre, 64);
+- W[1][i][0][0] = re * analysis_cossin_post[0][0] - im * analysis_cossin_post[0][1];
+- W[1][i][0][1] = re * analysis_cossin_post[0][1] + im * analysis_cossin_post[0][0];
++ //Shuffle to IMDCT
++ z[64] = z[0];
+ for (k = 1; k < 32; k++) {
+- re = z[2*k ] - re;
+- im = z[2*k+1] - im;
+- W[1][i][k][0] = re * analysis_cossin_post[k][0] - im * analysis_cossin_post[k][1];
+- W[1][i][k][1] = re * analysis_cossin_post[k][1] + im * analysis_cossin_post[k][0];
++ z[64+2*k-1] = z[ k];
++ z[64+2*k ] = -z[64-k];
++ }
++ z[64+63] = z[32];
++
++ ff_imdct_half(mdct, z, z+64);
++ for (k = 0; k < 32; k++) {
++ W[1][i][k][0] = -z[63-k];
++ W[1][i][k][1] = z[k];
+ }
+ x += 32;
+ }
+@@ -1179,7 +1173,7 @@ static void sbr_qmf_analysis(DSPContext
+ * (14496-3 sp04 p206)
+ */
+ static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct,
+- float *out, float X[2][32][64],
++ float *out, float X[2][38][64],
+ float mdct_buf[2][64],
+ float *v0, int *v_off, const unsigned int div,
+ float bias, float scale)
+@@ -1197,21 +1191,22 @@ static void sbr_qmf_synthesis(DSPContext
+ *v_off -= 128 >> div;
+ }
+ v = v0 + *v_off;
+- for (n = 1; n < 64 >> div; n+=2) {
+- X[1][i][n] = -X[1][i][n];
+- }
+- if (div) {
+- memset(X[0][i]+32, 0, 32*sizeof(float));
+- memset(X[1][i]+32, 0, 32*sizeof(float));
+- }
+- ff_imdct_half(mdct, mdct_buf[0], X[0][i]);
+- ff_imdct_half(mdct, mdct_buf[1], X[1][i]);
+ if (div) {
+ for (n = 0; n < 32; n++) {
+- v[ n] = -mdct_buf[0][63 - 2*n] + mdct_buf[1][2*n ];
+- v[ 63 - n] = mdct_buf[0][62 - 2*n] + mdct_buf[1][2*n + 1];
++ X[0][i][ n] = -X[0][i][n];
++ X[0][i][32+n] = X[1][i][31-n];
++ }
++ ff_imdct_half(mdct, mdct_buf[0], X[0][i]);
++ for (n = 0; n < 32; n++) {
++ v[ n] = mdct_buf[0][63 - 2*n];
++ v[63 - n] = -mdct_buf[0][62 - 2*n];
+ }
+ } else {
++ for (n = 1; n < 64; n+=2) {
++ X[1][i][n] = -X[1][i][n];
++ }
++ ff_imdct_half(mdct, mdct_buf[0], X[0][i]);
++ ff_imdct_half(mdct, mdct_buf[1], X[1][i]);
+ for (n = 0; n < 64; n++) {
+ v[ n] = -mdct_buf[0][63 - n] + mdct_buf[1][ n ];
+ v[127 - n] = mdct_buf[0][63 - n] + mdct_buf[1][ n ];
+@@ -1380,7 +1375,7 @@ static int sbr_hf_gen(AACContext *ac, Sp
+ g--;
+
+ if (g < 0) {
+- av_log(ac->avccontext, AV_LOG_ERROR,
++ av_log(ac->avctx, AV_LOG_ERROR,
+ "ERROR : no subband found for frequency %d\n", k);
+ return -1;
+ }
+@@ -1414,7 +1409,7 @@ static int sbr_hf_gen(AACContext *ac, Sp
+ }
+
+ /// Generate the subband filtered lowband
+-static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][32][64],
++static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][38][64],
+ const float X_low[32][40][2], const float Y[2][38][64][2],
+ int ch)
+ {
+@@ -1436,7 +1431,7 @@ static int sbr_x_gen(SpectralBandReplica
+ }
+
+ for (k = 0; k < sbr->kx[1]; k++) {
+- for (i = i_Temp; i < i_f; i++) {
++ for (i = i_Temp; i < 38; i++) {
+ X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0];
+ X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1];
+ }
+@@ -1730,7 +1725,7 @@ void ff_sbr_apply(AACContext *ac, Spectr
+ }
+ for (ch = 0; ch < nch; ch++) {
+ /* decode channel */
+- sbr_qmf_analysis(&ac->dsp, &sbr->rdft, ch ? R : L, sbr->data[ch].analysis_filterbank_samples,
++ sbr_qmf_analysis(&ac->dsp, &sbr->mdct_ana, ch ? R : L, sbr->data[ch].analysis_filterbank_samples,
+ (float*)sbr->qmf_filter_scratch,
+ sbr->data[ch].W, 1/(-1024 * ac->sf_scale));
+ sbr_lf_gen(ac, sbr, sbr->X_low, sbr->data[ch].W);
+@@ -1752,6 +1747,16 @@ void ff_sbr_apply(AACContext *ac, Spectr
+ /* synthesis */
+ sbr_x_gen(sbr, sbr->X[ch], sbr->X_low, sbr->data[ch].Y, ch);
+ }
++
++ if (ac->m4ac.ps == 1) {
++ if (sbr->ps.start) {
++ ff_ps_apply(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]);
++ } else {
++ memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0]));
++ }
++ nch = 2;
++ }
++
+ sbr_qmf_synthesis(&ac->dsp, &sbr->mdct, L, sbr->X[0], sbr->qmf_filter_scratch,
+ sbr->data[0].synthesis_filterbank_samples,
+ &sbr->data[0].synthesis_filterbank_samples_offset,
+--- a/libavcodec/aactab.c
++++ b/libavcodec/aactab.c
+@@ -29,6 +29,7 @@
+
+ #include "libavutil/mem.h"
+ #include "aac.h"
++#include "aac_tablegen.h"
+
+ #include
+
+@@ -1204,129 +1205,3 @@ const uint8_t ff_tns_max_bands_128[] = {
+ 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
+ };
+ // @}
+-
+-
+-#if CONFIG_HARDCODED_TABLES
+-
+-/**
+- * Table of pow(2, (i - 200)/4.) used for different purposes depending on the
+- * range of indices to the table:
+- * [ 0, 255] scale factor decoding when using C dsp.float_to_int16
+- * [60, 315] scale factor decoding when using SIMD dsp.float_to_int16
+- * [45, 300] intensity stereo position decoding mapped in reverse order i.e. 0->300, 1->299, ..., 254->46, 255->45
+- */
+-const float ff_aac_pow2sf_tab[428] = {
+- 8.88178420e-16, 1.05622810e-15, 1.25607397e-15, 1.49373210e-15,
+- 1.77635684e-15, 2.11245619e-15, 2.51214793e-15, 2.98746420e-15,
+- 3.55271368e-15, 4.22491238e-15, 5.02429587e-15, 5.97492839e-15,
+- 7.10542736e-15, 8.44982477e-15, 1.00485917e-14, 1.19498568e-14,
+- 1.42108547e-14, 1.68996495e-14, 2.00971835e-14, 2.38997136e-14,
+- 2.84217094e-14, 3.37992991e-14, 4.01943669e-14, 4.77994272e-14,
+- 5.68434189e-14, 6.75985982e-14, 8.03887339e-14, 9.55988543e-14,
+- 1.13686838e-13, 1.35197196e-13, 1.60777468e-13, 1.91197709e-13,
+- 2.27373675e-13, 2.70394393e-13, 3.21554936e-13, 3.82395417e-13,
+- 4.54747351e-13, 5.40788785e-13, 6.43109871e-13, 7.64790834e-13,
+- 9.09494702e-13, 1.08157757e-12, 1.28621974e-12, 1.52958167e-12,
+- 1.81898940e-12, 2.16315514e-12, 2.57243948e-12, 3.05916334e-12,
+- 3.63797881e-12, 4.32631028e-12, 5.14487897e-12, 6.11832668e-12,
+- 7.27595761e-12, 8.65262056e-12, 1.02897579e-11, 1.22366534e-11,
+- 1.45519152e-11, 1.73052411e-11, 2.05795159e-11, 2.44733067e-11,
+- 2.91038305e-11, 3.46104823e-11, 4.11590317e-11, 4.89466134e-11,
+- 5.82076609e-11, 6.92209645e-11, 8.23180635e-11, 9.78932268e-11,
+- 1.16415322e-10, 1.38441929e-10, 1.64636127e-10, 1.95786454e-10,
+- 2.32830644e-10, 2.76883858e-10, 3.29272254e-10, 3.91572907e-10,
+- 4.65661287e-10, 5.53767716e-10, 6.58544508e-10, 7.83145814e-10,
+- 9.31322575e-10, 1.10753543e-09, 1.31708902e-09, 1.56629163e-09,
+- 1.86264515e-09, 2.21507086e-09, 2.63417803e-09, 3.13258326e-09,
+- 3.72529030e-09, 4.43014173e-09, 5.26835606e-09, 6.26516652e-09,
+- 7.45058060e-09, 8.86028346e-09, 1.05367121e-08, 1.25303330e-08,
+- 1.49011612e-08, 1.77205669e-08, 2.10734243e-08, 2.50606661e-08,
+- 2.98023224e-08, 3.54411338e-08, 4.21468485e-08, 5.01213321e-08,
+- 5.96046448e-08, 7.08822677e-08, 8.42936970e-08, 1.00242664e-07,
+- 1.19209290e-07, 1.41764535e-07, 1.68587394e-07, 2.00485328e-07,
+- 2.38418579e-07, 2.83529071e-07, 3.37174788e-07, 4.00970657e-07,
+- 4.76837158e-07, 5.67058141e-07, 6.74349576e-07, 8.01941314e-07,
+- 9.53674316e-07, 1.13411628e-06, 1.34869915e-06, 1.60388263e-06,
+- 1.90734863e-06, 2.26823256e-06, 2.69739830e-06, 3.20776526e-06,
+- 3.81469727e-06, 4.53646513e-06, 5.39479661e-06, 6.41553051e-06,
+- 7.62939453e-06, 9.07293026e-06, 1.07895932e-05, 1.28310610e-05,
+- 1.52587891e-05, 1.81458605e-05, 2.15791864e-05, 2.56621220e-05,
+- 3.05175781e-05, 3.62917210e-05, 4.31583729e-05, 5.13242441e-05,
+- 6.10351562e-05, 7.25834421e-05, 8.63167458e-05, 1.02648488e-04,
+- 1.22070312e-04, 1.45166884e-04, 1.72633492e-04, 2.05296976e-04,
+- 2.44140625e-04, 2.90333768e-04, 3.45266983e-04, 4.10593953e-04,
+- 4.88281250e-04, 5.80667537e-04, 6.90533966e-04, 8.21187906e-04,
+- 9.76562500e-04, 1.16133507e-03, 1.38106793e-03, 1.64237581e-03,
+- 1.95312500e-03, 2.32267015e-03, 2.76213586e-03, 3.28475162e-03,
+- 3.90625000e-03, 4.64534029e-03, 5.52427173e-03, 6.56950324e-03,
+- 7.81250000e-03, 9.29068059e-03, 1.10485435e-02, 1.31390065e-02,
+- 1.56250000e-02, 1.85813612e-02, 2.20970869e-02, 2.62780130e-02,
+- 3.12500000e-02, 3.71627223e-02, 4.41941738e-02, 5.25560260e-02,
+- 6.25000000e-02, 7.43254447e-02, 8.83883476e-02, 1.05112052e-01,
+- 1.25000000e-01, 1.48650889e-01, 1.76776695e-01, 2.10224104e-01,
+- 2.50000000e-01, 2.97301779e-01, 3.53553391e-01, 4.20448208e-01,
+- 5.00000000e-01, 5.94603558e-01, 7.07106781e-01, 8.40896415e-01,
+- 1.00000000e+00, 1.18920712e+00, 1.41421356e+00, 1.68179283e+00,
+- 2.00000000e+00, 2.37841423e+00, 2.82842712e+00, 3.36358566e+00,
+- 4.00000000e+00, 4.75682846e+00, 5.65685425e+00, 6.72717132e+00,
+- 8.00000000e+00, 9.51365692e+00, 1.13137085e+01, 1.34543426e+01,
+- 1.60000000e+01, 1.90273138e+01, 2.26274170e+01, 2.69086853e+01,
+- 3.20000000e+01, 3.80546277e+01, 4.52548340e+01, 5.38173706e+01,
+- 6.40000000e+01, 7.61092554e+01, 9.05096680e+01, 1.07634741e+02,
+- 1.28000000e+02, 1.52218511e+02, 1.81019336e+02, 2.15269482e+02,
+- 2.56000000e+02, 3.04437021e+02, 3.62038672e+02, 4.30538965e+02,
+- 5.12000000e+02, 6.08874043e+02, 7.24077344e+02, 8.61077929e+02,
+- 1.02400000e+03, 1.21774809e+03, 1.44815469e+03, 1.72215586e+03,
+- 2.04800000e+03, 2.43549617e+03, 2.89630938e+03, 3.44431172e+03,
+- 4.09600000e+03, 4.87099234e+03, 5.79261875e+03, 6.88862343e+03,
+- 8.19200000e+03, 9.74198469e+03, 1.15852375e+04, 1.37772469e+04,
+- 1.63840000e+04, 1.94839694e+04, 2.31704750e+04, 2.75544937e+04,
+- 3.27680000e+04, 3.89679387e+04, 4.63409500e+04, 5.51089875e+04,
+- 6.55360000e+04, 7.79358775e+04, 9.26819000e+04, 1.10217975e+05,
+- 1.31072000e+05, 1.55871755e+05, 1.85363800e+05, 2.20435950e+05,
+- 2.62144000e+05, 3.11743510e+05, 3.70727600e+05, 4.40871900e+05,
+- 5.24288000e+05, 6.23487020e+05, 7.41455200e+05, 8.81743800e+05,
+- 1.04857600e+06, 1.24697404e+06, 1.48291040e+06, 1.76348760e+06,
+- 2.09715200e+06, 2.49394808e+06, 2.96582080e+06, 3.52697520e+06,
+- 4.19430400e+06, 4.98789616e+06, 5.93164160e+06, 7.05395040e+06,
+- 8.38860800e+06, 9.97579232e+06, 1.18632832e+07, 1.41079008e+07,
+- 1.67772160e+07, 1.99515846e+07, 2.37265664e+07, 2.82158016e+07,
+- 3.35544320e+07, 3.99031693e+07, 4.74531328e+07, 5.64316032e+07,
+- 6.71088640e+07, 7.98063385e+07, 9.49062656e+07, 1.12863206e+08,
+- 1.34217728e+08, 1.59612677e+08, 1.89812531e+08, 2.25726413e+08,
+- 2.68435456e+08, 3.19225354e+08, 3.79625062e+08, 4.51452825e+08,
+- 5.36870912e+08, 6.38450708e+08, 7.59250125e+08, 9.02905651e+08,
+- 1.07374182e+09, 1.27690142e+09, 1.51850025e+09, 1.80581130e+09,
+- 2.14748365e+09, 2.55380283e+09, 3.03700050e+09, 3.61162260e+09,
+- 4.29496730e+09, 5.10760567e+09, 6.07400100e+09, 7.22324521e+09,
+- 8.58993459e+09, 1.02152113e+10, 1.21480020e+10, 1.44464904e+10,
+- 1.71798692e+10, 2.04304227e+10, 2.42960040e+10, 2.88929808e+10,
+- 3.43597384e+10, 4.08608453e+10, 4.85920080e+10, 5.77859616e+10,
+- 6.87194767e+10, 8.17216907e+10, 9.71840160e+10, 1.15571923e+11,
+- 1.37438953e+11, 1.63443381e+11, 1.94368032e+11, 2.31143847e+11,
+- 2.74877907e+11, 3.26886763e+11, 3.88736064e+11, 4.62287693e+11,
+- 5.49755814e+11, 6.53773525e+11, 7.77472128e+11, 9.24575386e+11,
+- 1.09951163e+12, 1.30754705e+12, 1.55494426e+12, 1.84915077e+12,
+- 2.19902326e+12, 2.61509410e+12, 3.10988851e+12, 3.69830155e+12,
+- 4.39804651e+12, 5.23018820e+12, 6.21977702e+12, 7.39660309e+12,
+- 8.79609302e+12, 1.04603764e+13, 1.24395540e+13, 1.47932062e+13,
+- 1.75921860e+13, 2.09207528e+13, 2.48791081e+13, 2.95864124e+13,
+- 3.51843721e+13, 4.18415056e+13, 4.97582162e+13, 5.91728247e+13,
+- 7.03687442e+13, 8.36830112e+13, 9.95164324e+13, 1.18345649e+14,
+- 1.40737488e+14, 1.67366022e+14, 1.99032865e+14, 2.36691299e+14,
+- 2.81474977e+14, 3.34732045e+14, 3.98065730e+14, 4.73382598e+14,
+- 5.62949953e+14, 6.69464090e+14, 7.96131459e+14, 9.46765196e+14,
+- 1.12589991e+15, 1.33892818e+15, 1.59226292e+15, 1.89353039e+15,
+- 2.25179981e+15, 2.67785636e+15, 3.18452584e+15, 3.78706078e+15,
+- 4.50359963e+15, 5.35571272e+15, 6.36905167e+15, 7.57412156e+15,
+- 9.00719925e+15, 1.07114254e+16, 1.27381033e+16, 1.51482431e+16,
+- 1.80143985e+16, 2.14228509e+16, 2.54762067e+16, 3.02964863e+16,
+- 3.60287970e+16, 4.28457018e+16, 5.09524134e+16, 6.05929725e+16,
+- 7.20575940e+16, 8.56914035e+16, 1.01904827e+17, 1.21185945e+17,
+-};
+-
+-#else
+-
+-float ff_aac_pow2sf_tab[428];
+-
+-#endif /* CONFIG_HARDCODED_TABLES */
+--- a/libavcodec/aactab.h
++++ b/libavcodec/aactab.h
+@@ -32,6 +32,7 @@
+
+ #include "libavutil/mem.h"
+ #include "aac.h"
++#include "aac_tablegen_decl.h"
+
+ #include
+
+@@ -73,10 +74,4 @@ extern const uint16_t * const ff_swb_off
+ extern const uint8_t ff_tns_max_bands_1024[13];
+ extern const uint8_t ff_tns_max_bands_128 [13];
+
+-#if CONFIG_HARDCODED_TABLES
+-extern const float ff_aac_pow2sf_tab[428];
+-#else
+-extern float ff_aac_pow2sf_tab[428];
+-#endif /* CONFIG_HARDCODED_TABLES */
+-
+ #endif /* AVCODEC_AACTAB_H */
+--- /dev/null
++++ b/libavcodec/aac_tablegen.c
+@@ -0,0 +1,39 @@
++/*
++ * Generate a header file for hardcoded AAC tables
++ *
++ * Copyright (c) 2010 Alex Converse
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#include
++#define CONFIG_HARDCODED_TABLES 0
++#include "aac_tablegen.h"
++#include "tableprint.h"
++
++int main(void)
++{
++ ff_aac_tableinit();
++
++ write_fileheader();
++
++ printf("const float ff_aac_pow2sf_tab[428] = {\n");
++ write_float_array(ff_aac_pow2sf_tab, 428);
++ printf("};\n");
++
++ return 0;
++}
+--- /dev/null
++++ b/libavcodec/aac_tablegen.h
+@@ -0,0 +1,42 @@
++/*
++ * Header file for hardcoded AAC tables
++ *
++ * Copyright (c) 2010 Alex Converse
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#ifndef AAC_TABLEGEN_H
++#define AAC_TABLEGEN_H
++
++#include "aac_tablegen_decl.h"
++
++#if CONFIG_HARDCODED_TABLES
++#include "libavcodec/aac_tables.h"
++#else
++#include "../libavutil/mathematics.h"
++float ff_aac_pow2sf_tab[428];
++
++void ff_aac_tableinit(void)
++{
++ int i;
++ for (i = 0; i < 428; i++)
++ ff_aac_pow2sf_tab[i] = pow(2, (i - 200) / 4.);
++}
++#endif /* CONFIG_HARDCODED_TABLES */
++
++#endif /* AAC_TABLEGEN_H */
+--- /dev/null
++++ b/libavcodec/aacps_tablegen.c
+@@ -0,0 +1,93 @@
++/*
++ * Generate a header file for hardcoded Parametric Stereo tables
++ *
++ * Copyright (c) 2010 Alex Converse
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#include
++#define CONFIG_HARDCODED_TABLES 0
++#include "aacps_tablegen.h"
++#include "tableprint.h"
++
++void write_float_3d_array (const void *p, int b, int c, int d)
++{
++ int i;
++ const float *f = p;
++ for (i = 0; i < b; i++) {
++ printf("{\n");
++ write_float_2d_array(f, c, d);
++ printf("},\n");
++ f += c * d;
++ }
++}
++
++void write_float_4d_array (const void *p, int a, int b, int c, int d)
++{
++ int i;
++ const float *f = p;
++ for (i = 0; i < a; i++) {
++ printf("{\n");
++ write_float_3d_array(f, b, c, d);
++ printf("},\n");
++ f += b * c * d;
++ }
++}
++
++int main(void)
++{
++ ps_tableinit();
++
++ write_fileheader();
++
++ printf("static const float pd_re_smooth[8*8*8] = {\n");
++ write_float_array(pd_re_smooth, 8*8*8);
++ printf("};\n");
++ printf("static const float pd_im_smooth[8*8*8] = {\n");
++ write_float_array(pd_im_smooth, 8*8*8);
++ printf("};\n");
++
++ printf("static const float HA[46][8][4] = {\n");
++ write_float_3d_array(HA, 46, 8, 4);
++ printf("};\n");
++ printf("static const float HB[46][8][4] = {\n");
++ write_float_3d_array(HB, 46, 8, 4);
++ printf("};\n");
++
++ printf("static const float f20_0_8[8][7][2] = {\n");
++ write_float_3d_array(f20_0_8, 8, 7, 2);
++ printf("};\n");
++ printf("static const float f34_0_12[12][7][2] = {\n");
++ write_float_3d_array(f34_0_12, 12, 7, 2);
++ printf("};\n");
++ printf("static const float f34_1_8[8][7][2] = {\n");
++ write_float_3d_array(f34_1_8, 8, 7, 2);
++ printf("};\n");
++ printf("static const float f34_2_4[4][7][2] = {\n");
++ write_float_3d_array(f34_2_4, 4, 7, 2);
++ printf("};\n");
++
++ printf("static const float Q_fract_allpass[2][50][3][2] = {\n");
++ write_float_4d_array(Q_fract_allpass, 2, 50, 3, 2);
++ printf("};\n");
++ printf("static const float phi_fract[2][50][2] = {\n");
++ write_float_3d_array(phi_fract, 2, 50, 2);
++ printf("};\n");
++
++ return 0;
++}
+--- /dev/null
++++ b/libavcodec/aacps_tablegen.h
+@@ -0,0 +1,212 @@
++/*
++ * Header file for hardcoded Parametric Stereo tables
++ *
++ * Copyright (c) 2010 Alex Converse
++ *
++ * This file is part of FFmpeg.
++ *
++ * FFmpeg is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * FFmpeg 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#ifndef AACPS_TABLEGEN_H
++#define AACPS_TABLEGEN_H
++
++#include
++
++#if CONFIG_HARDCODED_TABLES
++#define ps_tableinit()
++#include "libavcodec/aacps_tables.h"
++#else
++#include "../libavutil/common.h"
++#include "../libavutil/mathematics.h"
++#define NR_ALLPASS_BANDS20 30
++#define NR_ALLPASS_BANDS34 50
++#define PS_AP_LINKS 3
++static float pd_re_smooth[8*8*8];
++static float pd_im_smooth[8*8*8];
++static float HA[46][8][4];
++static float HB[46][8][4];
++static float f20_0_8 [ 8][7][2];
++static float f34_0_12[12][7][2];
++static float f34_1_8 [ 8][7][2];
++static float f34_2_4 [ 4][7][2];
++static float Q_fract_allpass[2][50][3][2];
++static float phi_fract[2][50][2];
++
++static const float g0_Q8[] = {
++ 0.00746082949812f, 0.02270420949825f, 0.04546865930473f, 0.07266113929591f,
++ 0.09885108575264f, 0.11793710567217f, 0.125f
++};
++
++static const float g0_Q12[] = {
++ 0.04081179924692f, 0.03812810994926f, 0.05144908135699f, 0.06399831151592f,
++ 0.07428313801106f, 0.08100347892914f, 0.08333333333333f
++};
++
++static const float g1_Q8[] = {
++ 0.01565675600122f, 0.03752716391991f, 0.05417891378782f, 0.08417044116767f,
++ 0.10307344158036f, 0.12222452249753f, 0.125f
++};
++
++static const float g2_Q4[] = {
++ -0.05908211155639f, -0.04871498374946f, 0.0f, 0.07778723915851f,
++ 0.16486303567403f, 0.23279856662996f, 0.25f
++};
++
++static void make_filters_from_proto(float (*filter)[7][2], const float *proto, int bands)
++{
++ int q, n;
++ for (q = 0; q < bands; q++) {
++ for (n = 0; n < 7; n++) {
++ double theta = 2 * M_PI * (q + 0.5) * (n - 6) / bands;
++ filter[q][n][0] = proto[n] * cos(theta);
++ filter[q][n][1] = proto[n] * -sin(theta);
++ }
++ }
++}
++
++static void ps_tableinit(void)
++{
++ static const float ipdopd_sin[] = { 0, M_SQRT1_2, 1, M_SQRT1_2, 0, -M_SQRT1_2, -1, -M_SQRT1_2 };
++ static const float ipdopd_cos[] = { 1, M_SQRT1_2, 0, -M_SQRT1_2, -1, -M_SQRT1_2, 0, M_SQRT1_2 };
++ int pd0, pd1, pd2;
++
++ static const float iid_par_dequant[] = {
++ //iid_par_dequant_default
++ 0.05623413251903, 0.12589254117942, 0.19952623149689, 0.31622776601684,
++ 0.44668359215096, 0.63095734448019, 0.79432823472428, 1,
++ 1.25892541179417, 1.58489319246111, 2.23872113856834, 3.16227766016838,
++ 5.01187233627272, 7.94328234724282, 17.7827941003892,
++ //iid_par_dequant_fine
++ 0.00316227766017, 0.00562341325190, 0.01, 0.01778279410039,
++ 0.03162277660168, 0.05623413251903, 0.07943282347243, 0.11220184543020,
++ 0.15848931924611, 0.22387211385683, 0.31622776601684, 0.39810717055350,
++ 0.50118723362727, 0.63095734448019, 0.79432823472428, 1,
++ 1.25892541179417, 1.58489319246111, 1.99526231496888, 2.51188643150958,
++ 3.16227766016838, 4.46683592150963, 6.30957344480193, 8.91250938133745,
++ 12.5892541179417, 17.7827941003892, 31.6227766016838, 56.2341325190349,
++ 100, 177.827941003892, 316.227766016837,
++ };
++ static const float icc_invq[] = {
++ 1, 0.937, 0.84118, 0.60092, 0.36764, 0, -0.589, -1
++ };
++ static const float acos_icc_invq[] = {
++ 0, 0.35685527, 0.57133466, 0.92614472, 1.1943263, M_PI/2, 2.2006171, M_PI
++ };
++ int iid, icc;
++
++ int k, m;
++ static const int8_t f_center_20[] = {
++ -3, -1, 1, 3, 5, 7, 10, 14, 18, 22,
++ };
++ static const int8_t f_center_34[] = {
++ 2, 6, 10, 14, 18, 22, 26, 30,
++ 34,-10, -6, -2, 51, 57, 15, 21,
++ 27, 33, 39, 45, 54, 66, 78, 42,
++ 102, 66, 78, 90,102,114,126, 90,
++ };
++ static const float fractional_delay_links[] = { 0.43f, 0.75f, 0.347f };
++ const float fractional_delay_gain = 0.39f;
++
++ for (pd0 = 0; pd0 < 8; pd0++) {
++ float pd0_re = ipdopd_cos[pd0];
++ float pd0_im = ipdopd_sin[pd0];
++ for (pd1 = 0; pd1 < 8; pd1++) {
++ float pd1_re = ipdopd_cos[pd1];
++ float pd1_im = ipdopd_sin[pd1];
++ for (pd2 = 0; pd2 < 8; pd2++) {
++ float pd2_re = ipdopd_cos[pd2];
++ float pd2_im = ipdopd_sin[pd2];
++ float re_smooth = 0.25f * pd0_re + 0.5f * pd1_re + pd2_re;
++ float im_smooth = 0.25f * pd0_im + 0.5f * pd1_im + pd2_im;
++ float pd_mag = 1 / sqrt(im_smooth * im_smooth + re_smooth * re_smooth);
++ pd_re_smooth[pd0*64+pd1*8+pd2] = re_smooth * pd_mag;
++ pd_im_smooth[pd0*64+pd1*8+pd2] = im_smooth * pd_mag;
++ }
++ }
++ }
++
++ for (iid = 0; iid < 46; iid++) {
++ float c = iid_par_dequant[iid]; //icc_mode < 3)*/ {
++ float alpha = 0.5f * acos_icc_invq[icc];
++ float beta = alpha * (c1 - c2) * (float)M_SQRT1_2;
++ HA[iid][icc][0] = c2 * cosf(beta + alpha);
++ HA[iid][icc][1] = c1 * cosf(beta - alpha);
++ HA[iid][icc][2] = c2 * sinf(beta + alpha);
++ HA[iid][icc][3] = c1 * sinf(beta - alpha);
++ } /* else */ {
++ float alpha, gamma, mu, rho;
++ float alpha_c, alpha_s, gamma_c, gamma_s;
++ rho = FFMAX(icc_invq[icc], 0.05f);
++ alpha = 0.5f * atan2f(2.0f * c * rho, c*c - 1.0f);
++ mu = c + 1.0f / c;
++ mu = sqrtf(1 + (4 * rho * rho - 4)/(mu * mu));
++ gamma = atanf(sqrtf((1.0f - mu)/(1.0f + mu)));
++ if (alpha < 0) alpha += M_PI/2;
++ alpha_c = cosf(alpha);
++ alpha_s = sinf(alpha);
++ gamma_c = cosf(gamma);
++ gamma_s = sinf(gamma);
++ HB[iid][icc][0] = M_SQRT2 * alpha_c * gamma_c;
++ HB[iid][icc][1] = M_SQRT2 * alpha_s * gamma_c;
++ HB[iid][icc][2] = -M_SQRT2 * alpha_s * gamma_s;
++ HB[iid][icc][3] = M_SQRT2 * alpha_c * gamma_s;
++ }
++ }
++ }
++
++ for (k = 0; k < NR_ALLPASS_BANDS20; k++) {
++ double f_center, theta;
++ if (k < FF_ARRAY_ELEMS(f_center_20))
++ f_center = f_center_20[k] * 0.125;
++ else
++ f_center = k - 6.5f;
++ for (m = 0; m < PS_AP_LINKS; m++) {
++ theta = -M_PI * fractional_delay_links[m] * f_center;
++ Q_fract_allpass[0][k][m][0] = cos(theta);
++ Q_fract_allpass[0][k][m][1] = sin(theta);
++ }
++ theta = -M_PI*fractional_delay_gain*f_center;
++ phi_fract[0][k][0] = cos(theta);
++ phi_fract[0][k][1] = sin(theta);
++ }
++ for (k = 0; k < NR_ALLPASS_BANDS34; k++) {
++ double f_center, theta;
++ if (k < FF_ARRAY_ELEMS(f_center_34))
++ f_center = f_center_34[k] / 24.;
++ else
++ f_center = k - 26.5f;
++ for (m = 0; m < PS_AP_LINKS; m++) {
++ theta = -M_PI * fractional_delay_links[m] * f_center;
++ Q_fract_allpass[1][k][m][0] = cos(theta);
++ Q_fract_allpass[1][k][m][1] = sin(theta);
++ }
++ theta = -M_PI*fractional_delay_gain*f_center;
++ phi_fract[1][k][0] = cos(theta);
++ phi_fract[1][k][1] = sin(theta);
++ }
++
++ make_filters_from_proto(f20_0_8, g0_Q8, 8);
++ make_filters_from_proto(f34_0_12, g0_Q12, 12);
++ make_filters_from_proto(f34_1_8, g1_Q8, 8);
++ make_filters_from_proto(f34_2_4, g2_Q4, 4);
++}
++#endif /* CONFIG_HARDCODED_TABLES */
++
++#endif /* AACPS_TABLEGEN_H */
--- ffmpeg-0.6.orig/debian/source/format
+++ ffmpeg-0.6/debian/source/format
@@ -0,0 +1 @@
+1.0