Radix cross Linux

Radix Linux distribution for embedded systems.

637 Commits   4 Branches   3 Tags
author: Andrey V.Kosteltsev <kx@radix.pro> 2016-10-19 12:17:46 +0000 committer: Andrey V.Kosteltsev <kx@radix.pro> 2016-10-19 12:17:46 +0000 commit: b0b19f02acb2827874fd2ee1b971d3e61faf30fb parent: da3ce28f494dfa162df8d722ec8af8af97db12ed
Commit Summary:
FAAC - MPEG-4 and MPEG-2 AAC Encoder
Diffstat:
32 files changed, 2901 insertions, 5 deletions
diff --git a/app/faac/1.28-x86_32/Makefile b/app/faac/1.28-x86_32/Makefile
new file mode 100644
index 000000000..1468fe06c
--- /dev/null
+++ b/app/faac/1.28-x86_32/Makefile
@@ -0,0 +1,186 @@
+
+COMPONENT_TARGETS  = $(HARDWARE_PC64)
+
+NEED_ABS_PATH      = true
+COMPONENT_IS_3PP   = true
+
+CREATE_X86_32_PACKAGE = true
+
+
+include ../../../build-system/constants.mk
+
+
+SOURCE_REQUIRES    = sources/packages/m/audiocoding/faac
+
+REQUIRES           = app/faac/1.28
+REQUIRES          += libs/mp4v2/2.0.0-x86_32
+
+# ======= __END_OF_REQUIRES__ =======
+
+
+version            = 1.28
+tar_gz_archive     = $(SRC_PACKAGE_PATH)/packages/m/audiocoding/faac/faac-$(version).tar.gz
+SRC_ARCHIVE        = $(tar_gz_archive)
+SRC_DIR            = $(TARGET_BUILD_DIR)/faac-$(version)
+src_dir_name       = faac-$(version)
+src_done           = $(TARGET_BUILD_DIR)/.source_done
+
+PATCHES = PATCHES
+
+build_target       = $(TARGET_BUILD_DIR)/.build_done
+install_target     = $(TARGET_BUILD_DIR)/.install_done
+
+
+####### Targets
+
+PKG_GROUP = app
+
+#
+# *PKG_NAME & *PKG_VERSION shouldn't be a reference to value.
+#
+FAAC_32_PKG_NAME                = faac-x32
+FAAC_32_PKG_VERSION             = 1.28
+FAAC_32_PKG_ARCH                = $(TOOLCHAIN)
+FAAC_32_PKG_DISTRO_NAME         = $(DISTRO_NAME)
+FAAC_32_PKG_DISTRO_VERSION      = $(DISTRO_VERSION)
+FAAC_32_PKG_GROUP               = $(PKG_GROUP)
+###                              |---handy-ruler-------------------------------|
+FAAC_32_PKG_SHORT_DESCRIPTION   = MPEG-4 and MPEG-2 AAC encoder
+FAAC_32_PKG_URL                 = $(BUG_URL)
+FAAC_32_PKG_LICENSE             = LGPLv2
+FAAC_32_PKG_DESCRIPTION_FILE    = $(TARGET_BUILD_DIR)/$(FAAC_32_PKG_NAME)-pkg-description
+FAAC_32_PKG_DESCRIPTION_FILE_IN = $(FAAC_32_PKG_NAME)-pkg-description.in
+FAAC_32_PKG_INSTALL_SCRIPT      = $(FAAC_32_PKG_NAME)-pkg-install.sh
+
+FAAC_32_PKG       = $(CURDIR)/$(TARGET_BUILD_DIR)/$(FAAC_32_PKG_NAME)-package
+
+pkg_basename      = $(FAAC_32_PKG_NAME)-$(FAAC_32_PKG_VERSION)-$(FAAC_32_PKG_ARCH)-$(FAAC_32_PKG_DISTRO_NAME)-$(FAAC_32_PKG_DISTRO_VERSION)
+
+pkg_archive       = $(TARGET_BUILD_DIR)/$(PKG_GROUP)/$(pkg_basename).$(pkg_arch_suffix)
+pkg_signature     = $(call sign-name,$(pkg_archive))
+pkg_description   = $(call desc-name,$(pkg_archive))
+products          = $(call pkg-files,$(pkg_archive))
+
+BUILD_TARGETS     = $(build_target)
+BUILD_TARGETS    += $(install_target)
+
+PRODUCT_TARGETS   = $(products)
+
+ROOTFS_TARGETS    = $(pkg_archive)
+
+
+include ../../../build-system/core.mk
+
+
+env_sysroot  = DESTDIR=$(FAAC_32_PKG)
+
+
+extra_configure_switches  = --libdir=/usr/lib$(MULTILIB_X86_32_SUFFIX)
+extra_configure_switches += --docdir=/usr/share/doc/$(src_dir_name)
+extra_configure_switches += --mandir=/usr/share/man
+extra_configure_switches += --disable-dependency-tracking
+
+extra_configure_switches += --sysconfdir=/etc
+extra_configure_switches += --localstatedir=/var
+
+extra_configure_switches += --bindir=/usr/bin/32
+
+extra_configure_switches += --with-pic
+
+extra_configure_switches += --enable-shared=yes
+extra_configure_switches += --enable-static=yes
+
+
+CXXFLAGS += -Wno-write-strings -Wno-address
+
+
+TARGET_BIN_RPATH = /lib$(MULTILIB_X86_32_SUFFIX):/usr/lib$(MULTILIB_X86_32_SUFFIX)
+TARGET_LIB_RPATH = /lib$(MULTILIB_X86_32_SUFFIX):/usr/lib$(MULTILIB_X86_32_SUFFIX):/usr/lib/../lib$(MULTILIB_X86_32_SUFFIX)
+
+LDFLAGS += -Wl,-rpath,$(TARGET_LIB_RPATH)
+
+
+####### Dependencies
+
+$(src_done): $(SRC_ARCHIVE) $(PATCHES_DEP)
+	$(UNPACK_SRC_ARCHIVE)
+	$(APPLY_PATCHES)
+	@( cd $(SRC_DIR) ; \
+	   ./bootstrap ; \
+	 )
+	@touch $@
+
+$(build_target): $(src_done)
+	@cd $(SRC_DIR) && \
+	  $(BUILD_ENVIRONMENT) ./configure \
+	  --prefix=/usr               \
+	  --build=$(BUILD)            \
+	  --host=$(TARGET32)          \
+	  $(extra_configure_switches)
+	@cd $(SRC_DIR) && $(BUILD_ENVIRONMENT) $(MAKE)
+	@touch $@
+
+$(install_target): $(build_target)
+	@mkdir -p $(FAAC_32_PKG)
+	@cd $(SRC_DIR) && $(BUILD_ENVIRONMENT) $(MAKE) -j1 install $(env_sysroot)
+	@rm -rf $(FAAC_32_PKG)/usr/include
+	@rm -rf $(FAAC_32_PKG)/usr/share
+	# ======= remove toolchain path from target libtool *.la files =======
+	@( cd $(FAAC_32_PKG)/usr/lib$(MULTILIB_X86_32_SUFFIX) ; \
+	   sed -i "s,$(TARGET_DEST_DIR),,g" libfaac.la  \
+	 )
+	# ======= Install the same to $(TARGET_DEST_DIR) =======
+	$(call install-into-devenv, $(FAAC_32_PKG))
+	# ======= tune libtool *.la search path to the target destination for development =======
+	@( cd $(TARGET_DEST_DIR)/usr/lib$(MULTILIB_X86_32_SUFFIX) ; \
+	   sed -i "s,/usr,$(TARGET_DEST_DIR)/usr,g" libfaac.la ; \
+	   sed -i "s,L/lib,L$(TARGET_DEST_DIR)/lib,g" libfaac.la \
+	 )
+	# ======= Strip binaries =======
+	@( cd $(FAAC_32_PKG) ; \
+	   find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs $(STRIP) --strip-unneeded 2> /dev/null ; \
+	   find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs $(STRIP) --strip-unneeded 2> /dev/null ; \
+	   find . | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs $(STRIP) -g 2> /dev/null \
+	 )
+ifneq ($(CHRPATH),)
+	# ======= Set RPATH/RUNPATH for target binaries =======
+	@( cd $(FAAC_32_PKG)/usr/bin/32 ; \
+	   for file in `find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs echo` ; do \
+	     rpath=`$(CHRPATH) -l $$file 2> /dev/null | grep "R*PATH"` ; \
+	     if echo "$$rpath" | grep -q "$(TARGET_DEST_DIR)" ; then \
+	       $(CHRPATH) -r $(TARGET_BIN_RPATH) $$file 1> /dev/null 2> /dev/null ; \
+	     fi ; \
+	   done ; \
+	 )
+	# ======= Set RPATH/RUNPATH for target shared objects =======
+	@( cd $(FAAC_32_PKG)/usr/lib$(MULTILIB_X86_32_SUFFIX) ; \
+	   for file in `find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs echo` ; do \
+	     rpath=`$(CHRPATH) -l $$file 2> /dev/null | grep "R*PATH"` ; \
+	     if echo "$$rpath" | grep -q "$(TARGET_DEST_DIR)" ; then \
+	       $(CHRPATH) -r $(TARGET_LIB_RPATH) $$file 1> /dev/null 2> /dev/null ; \
+	     fi ; \
+	   done ; \
+	 )
+endif
+	@touch $@
+
+$(FAAC_32_PKG_DESCRIPTION_FILE): $(FAAC_32_PKG_DESCRIPTION_FILE_IN)
+	@cat $< | $(SED) -e "s/@VERSION@/$(version)/g" > $@
+
+$(pkg_signature)   : $(pkg_archive) ;
+$(pkg_description) : $(pkg_archive) ;
+
+$(pkg_archive): $(install_target) $(FAAC_32_PKG_DESCRIPTION_FILE) $(FAAC_32_PKG_INSTALL_SCRIPT)
+	@cp $(FAAC_32_PKG_DESCRIPTION_FILE) $(FAAC_32_PKG)/.DESCRIPTION
+	@cp $(FAAC_32_PKG_INSTALL_SCRIPT) $(FAAC_32_PKG)/.INSTALL
+	@$(BUILD_PKG_REQUIRES) $(FAAC_32_PKG)/.REQUIRES
+	@echo "pkgname=$(FAAC_32_PKG_NAME)"                            >  $(FAAC_32_PKG)/.PKGINFO ; \
+	 echo "pkgver=$(FAAC_32_PKG_VERSION)"                          >> $(FAAC_32_PKG)/.PKGINFO ; \
+	 echo "arch=$(FAAC_32_PKG_ARCH)"                               >> $(FAAC_32_PKG)/.PKGINFO ; \
+	 echo "distroname=$(FAAC_32_PKG_DISTRO_NAME)"                  >> $(FAAC_32_PKG)/.PKGINFO ; \
+	 echo "distrover=$(FAAC_32_PKG_DISTRO_VERSION)"                >> $(FAAC_32_PKG)/.PKGINFO ; \
+	 echo "group=$(FAAC_32_PKG_GROUP)"                             >> $(FAAC_32_PKG)/.PKGINFO ; \
+	 echo "short_description=\"$(FAAC_32_PKG_SHORT_DESCRIPTION)\"" >> $(FAAC_32_PKG)/.PKGINFO ; \
+	 echo "url=$(FAAC_32_PKG_URL)"                                 >> $(FAAC_32_PKG)/.PKGINFO ; \
+	 echo "license=$(FAAC_32_PKG_LICENSE)"                         >> $(FAAC_32_PKG)/.PKGINFO
+	@$(FAKEROOT) sh -c "cd $(FAAC_32_PKG) && chown -R root:root . && $(MAKE_PACKAGE) --linkadd yes .."
diff --git a/app/faac/1.28-x86_32/PATCHES b/app/faac/1.28-x86_32/PATCHES
new file mode 100644
index 000000000..ebd8e2d63
--- /dev/null
+++ b/app/faac/1.28-x86_32/PATCHES
@@ -0,0 +1,3 @@
+
+../../../sources/packages/m/audiocoding/faac/patches/faac-1.28-mpeg4ip.patch -p0
+../../../sources/packages/m/audiocoding/faac/patches/faac-1.28-mp4v2.patch   -p0
diff --git a/app/faac/1.28-x86_32/faac-x32-pkg-description.in b/app/faac/1.28-x86_32/faac-x32-pkg-description.in
new file mode 100644
index 000000000..c0fd96316
--- /dev/null
+++ b/app/faac/1.28-x86_32/faac-x32-pkg-description.in
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description.  Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in.  You must
+# make exactly 11 lines for the formatting to be correct.  It's also
+# customary to leave one space after the ':'.
+
+        |-----handy-ruler------------------------------------------------------|
+faac-x32: faac-x32 @VERSION@ (x86_32 MPEG-4 and MPEG-2 AAC encoder)
+faac-x32:
+faac-x32: This package contains the ISO/MPEG 2/4 AAC Encoder and Library.
+faac-x32:
+faac-x32: The ISO/MPEG 2/4 AAC Encoder Library provides a high-level interface
+faac-x32: for encoding MPEG2 and MPEG4 ISO AAC files. The faac.h header file
+faac-x32: is provided for usage in C/C++ programs.
+faac-x32:
+faac-x32: Homepage: http://audiocoding.com/index.html
+faac-x32:
+faac-x32:
diff --git a/app/faac/1.28-x86_32/faac-x32-pkg-install.sh b/app/faac/1.28-x86_32/faac-x32-pkg-install.sh
new file mode 100755
index 000000000..8e8683cd6
--- /dev/null
+++ b/app/faac/1.28-x86_32/faac-x32-pkg-install.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# arg 1:  the new package version
+pre_install() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+post_install() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+# arg 2:  the old package version
+pre_update() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+# arg 2:  the old package version
+post_update() {
+  post_install
+}
+
+# arg 1:  the old package version
+pre_remove() {
+  /bin/true
+}
+
+# arg 1:  the old package version
+post_remove() {
+  /bin/true
+}
+
+
+operation=$1
+shift
+
+$operation $*
diff --git a/app/faac/1.28/Makefile b/app/faac/1.28/Makefile
new file mode 100644
index 000000000..bfbc1bd2f
--- /dev/null
+++ b/app/faac/1.28/Makefile
@@ -0,0 +1,223 @@
+
+COMPONENT_TARGETS  = $(HARDWARE_PC32)
+COMPONENT_TARGETS += $(HARDWARE_PC64)
+COMPONENT_TARGETS += $(HARDWARE_CB1X)
+COMPONENT_TARGETS += $(HARDWARE_CB2X)
+COMPONENT_TARGETS += $(HARDWARE_CB3X)
+COMPONENT_TARGETS += $(HARDWARE_FFRK3288)
+COMPONENT_TARGETS += $(HARDWARE_M201)
+COMPONENT_TARGETS += $(HARDWARE_MXQ)
+COMPONENT_TARGETS += $(HARDWARE_NIT6Q)
+COMPONENT_TARGETS += $(HARDWARE_OMAP5UEVM)
+COMPONENT_TARGETS += $(HARDWARE_DRA7XXEVM)
+COMPONENT_TARGETS += $(HARDWARE_CI20)
+COMPONENT_TARGETS += $(HARDWARE_BT1)
+
+
+NEED_ABS_PATH      = true
+COMPONENT_IS_3PP   = true
+
+
+include ../../../build-system/constants.mk
+
+
+SOURCE_REQUIRES    = sources/packages/m/audiocoding/faac
+
+REQUIRES           = libs/mp4v2/2.0.0
+
+# ======= __END_OF_REQUIRES__ =======
+
+
+version            = 1.28
+tar_gz_archive     = $(SRC_PACKAGE_PATH)/packages/m/audiocoding/faac/faac-$(version).tar.gz
+SRC_ARCHIVE        = $(tar_gz_archive)
+SRC_DIR            = $(TARGET_BUILD_DIR)/faac-$(version)
+src_dir_name       = faac-$(version)
+src_done           = $(TARGET_BUILD_DIR)/.source_done
+
+PATCHES = PATCHES
+
+build_target       = $(TARGET_BUILD_DIR)/.build_done
+install_target     = $(TARGET_BUILD_DIR)/.install_done
+
+
+####### Targets
+
+PKG_GROUP = app
+
+#
+# *PKG_NAME & *PKG_VERSION shouldn't be a reference to value.
+#
+FAAC_PKG_NAME                = faac
+FAAC_PKG_VERSION             = 1.28
+FAAC_PKG_ARCH                = $(TOOLCHAIN)
+FAAC_PKG_DISTRO_NAME         = $(DISTRO_NAME)
+FAAC_PKG_DISTRO_VERSION      = $(DISTRO_VERSION)
+FAAC_PKG_GROUP               = $(PKG_GROUP)
+###                           |---handy-ruler-------------------------------|
+FAAC_PKG_SHORT_DESCRIPTION   = MPEG-4 and MPEG-2 AAC encoder
+FAAC_PKG_URL                 = $(BUG_URL)
+FAAC_PKG_LICENSE             = LGPLv2
+FAAC_PKG_DESCRIPTION_FILE    = $(TARGET_BUILD_DIR)/$(FAAC_PKG_NAME)-pkg-description
+FAAC_PKG_DESCRIPTION_FILE_IN = $(FAAC_PKG_NAME)-pkg-description.in
+FAAC_PKG_INSTALL_SCRIPT      = $(FAAC_PKG_NAME)-pkg-install.sh
+
+FAAC_PKG         = $(CURDIR)/$(TARGET_BUILD_DIR)/$(FAAC_PKG_NAME)-package
+
+pkg_basename     = $(FAAC_PKG_NAME)-$(FAAC_PKG_VERSION)-$(FAAC_PKG_ARCH)-$(FAAC_PKG_DISTRO_NAME)-$(FAAC_PKG_DISTRO_VERSION)
+
+pkg_archive      = $(TARGET_BUILD_DIR)/$(PKG_GROUP)/$(pkg_basename).$(pkg_arch_suffix)
+pkg_signature    = $(call sign-name,$(pkg_archive))
+pkg_description  = $(call desc-name,$(pkg_archive))
+products         = $(call pkg-files,$(pkg_archive))
+
+BUILD_TARGETS    = $(build_target)
+BUILD_TARGETS   += $(install_target)
+
+PRODUCT_TARGETS  = $(products)
+
+ROOTFS_TARGETS   = $(pkg_archive)
+
+
+include ../../../build-system/core.mk
+
+
+env_sysroot = DESTDIR=$(FAAC_PKG)
+
+
+extra_configure_switches  = --libdir=/usr/lib$(LIBSUFFIX)
+extra_configure_switches += --docdir=/usr/share/doc/$(src_dir_name)
+extra_configure_switches += --mandir=/usr/share/man
+extra_configure_switches += --disable-dependency-tracking
+
+extra_configure_switches += --sysconfdir=/etc
+extra_configure_switches += --localstatedir=/var
+
+extra_configure_switches += --with-pic
+
+extra_configure_switches += --enable-shared=yes
+extra_configure_switches += --enable-static=yes
+
+
+CXXFLAGS += -Wno-write-strings -Wno-address
+
+
+TARGET_BIN_RPATH = /lib$(LIBSUFFIX):/usr/lib$(LIBSUFFIX)
+TARGET_LIB_RPATH = /lib$(LIBSUFFIX):/usr/lib$(LIBSUFFIX):/usr/lib/../lib$(LIBSUFFIX)
+
+LDFLAGS += -Wl,-rpath,$(TARGET_LIB_RPATH)
+
+
+####### Dependencies
+
+$(src_done): $(SRC_ARCHIVE) $(PATCHES_DEP)
+	$(UNPACK_SRC_ARCHIVE)
+	$(APPLY_PATCHES)
+	@( cd $(SRC_DIR) ; \
+	   ./bootstrap ; \
+	 )
+	@touch $@
+
+$(build_target): $(src_done)
+	@cd $(SRC_DIR) && \
+	  $(BUILD_ENVIRONMENT) ./configure \
+	  --prefix=/usr               \
+	  --build=$(BUILD)            \
+	  --host=$(TARGET)            \
+	  $(extra_configure_switches)
+	@cd $(SRC_DIR) && $(BUILD_ENVIRONMENT) $(MAKE)
+	@touch $@
+
+$(install_target): $(build_target)
+	@mkdir -p $(FAAC_PKG)
+	@cd $(SRC_DIR) && $(BUILD_ENVIRONMENT) $(MAKE) -j1 install     $(env_sysroot)
+	# ======= Install Documentation =======
+	@if [ -d $(FAAC_PKG)/usr/share/man ]; then \
+	  ( cd $(FAAC_PKG)/usr/share/man ; \
+	    for manpagedir in `find . -type d -name "man*"` ; do \
+	      ( cd $$manpagedir ; \
+	        for eachpage in `find . -type l -maxdepth 1` ; do \
+	          ln -s `readlink $$eachpage`.gz $$eachpage.gz ; \
+	          rm $$eachpage ; \
+	        done ; \
+	        gzip -9 *.? ; \
+	      ) \
+	    done \
+	  ) \
+	 fi
+	@mkdir -p $(FAAC_PKG)/usr/doc/$(src_dir_name)
+	@cp -a $(SRC_DIR)/AUTHORS $(SRC_DIR)/COPYING \
+	       $(FAAC_PKG)/usr/doc/$(src_dir_name)
+	@mkdir -p $(FAAC_PKG)/usr/share/doc/$(src_dir_name)/html
+	@( cd $(SRC_DIR) ; \
+	   cp -a AUTHORS COPYING INSTALL NEWS README TODO docs/*.pdf \
+	         $(FAAC_PKG)/usr/share/doc/$(src_dir_name) ; \
+	   cp -a docs/*.html \
+	         $(FAAC_PKG)/usr/share/doc/$(src_dir_name)/html ; \
+	 )
+	@( cd $(SRC_DIR) ; \
+	   if [ -r ChangeLog ]; then \
+	     DOCSDIR=`echo $(FAAC_PKG)/usr/share/doc/$(src_dir_name)` ; \
+	     cat ChangeLog | head -n 1000 > $$DOCSDIR/ChangeLog ; \
+	     touch -r ChangeLog $$DOCSDIR/ChangeLog ; \
+	   fi \
+	 )
+	# ======= remove toolchain path from target libtool *.la files =======
+	@( cd $(FAAC_PKG)/usr/lib$(LIBSUFFIX) ; \
+	   sed -i "s,$(TARGET_DEST_DIR),,g" libfaac.la  \
+	 )
+	# ======= Install the same to $(TARGET_DEST_DIR) =======
+	$(call install-into-devenv, $(FAAC_PKG))
+	# ======= tune libtool *.la search path to the target destination for development =======
+	@( cd $(TARGET_DEST_DIR)/usr/lib$(LIBSUFFIX) ; \
+	   sed -i "s,/usr,$(TARGET_DEST_DIR)/usr,g" libfaac.la ; \
+	   sed -i "s,L/lib,L$(TARGET_DEST_DIR)/lib,g" libfaac.la \
+	 )
+	# ======= Strip binaries =======
+	@( cd $(FAAC_PKG) ; \
+	   find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs $(STRIP) --strip-unneeded 2> /dev/null ; \
+	   find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs $(STRIP) --strip-unneeded 2> /dev/null ; \
+	   find . | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs $(STRIP) -g 2> /dev/null \
+	 )
+ifneq ($(CHRPATH),)
+	# ======= Set RPATH/RUNPATH for target binaries =======
+	@( cd $(FAAC_PKG)/usr/bin ; \
+	   for file in `find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs echo` ; do \
+	     rpath=`$(CHRPATH) -l $$file 2> /dev/null | grep "R*PATH"` ; \
+	     if echo "$$rpath" | grep -q "$(TARGET_DEST_DIR)" ; then \
+	       $(CHRPATH) -r $(TARGET_BIN_RPATH) $$file 1> /dev/null 2> /dev/null ; \
+	     fi ; \
+	   done ; \
+	 )
+	# ======= Set RPATH/RUNPATH for target shared objects =======
+	@( cd $(FAAC_PKG)/usr/lib$(LIBSUFFIX) ; \
+	   for file in `find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs echo` ; do \
+	     rpath=`$(CHRPATH) -l $$file 2> /dev/null | grep "R*PATH"` ; \
+	     if echo "$$rpath" | grep -q "$(TARGET_DEST_DIR)" ; then \
+	       $(CHRPATH) -r $(TARGET_LIB_RPATH) $$file 1> /dev/null 2> /dev/null ; \
+	     fi ; \
+	   done ; \
+	 )
+endif
+	@touch $@
+
+$(FAAC_PKG_DESCRIPTION_FILE): $(FAAC_PKG_DESCRIPTION_FILE_IN)
+	@cat $< | $(SED) -e "s/@VERSION@/$(version)/g" > $@
+
+$(pkg_signature)   : $(pkg_archive) ;
+$(pkg_description) : $(pkg_archive) ;
+
+$(pkg_archive): $(install_target) $(FAAC_PKG_DESCRIPTION_FILE) $(FAAC_PKG_INSTALL_SCRIPT)
+	@cp $(FAAC_PKG_DESCRIPTION_FILE) $(FAAC_PKG)/.DESCRIPTION
+	@cp $(FAAC_PKG_INSTALL_SCRIPT) $(FAAC_PKG)/.INSTALL
+	@$(BUILD_PKG_REQUIRES) $(FAAC_PKG)/.REQUIRES
+	@echo "pkgname=$(FAAC_PKG_NAME)"                            >  $(FAAC_PKG)/.PKGINFO ; \
+	 echo "pkgver=$(FAAC_PKG_VERSION)"                          >> $(FAAC_PKG)/.PKGINFO ; \
+	 echo "arch=$(FAAC_PKG_ARCH)"                               >> $(FAAC_PKG)/.PKGINFO ; \
+	 echo "distroname=$(FAAC_PKG_DISTRO_NAME)"                  >> $(FAAC_PKG)/.PKGINFO ; \
+	 echo "distrover=$(FAAC_PKG_DISTRO_VERSION)"                >> $(FAAC_PKG)/.PKGINFO ; \
+	 echo "group=$(FAAC_PKG_GROUP)"                             >> $(FAAC_PKG)/.PKGINFO ; \
+	 echo "short_description=\"$(FAAC_PKG_SHORT_DESCRIPTION)\"" >> $(FAAC_PKG)/.PKGINFO ; \
+	 echo "url=$(FAAC_PKG_URL)"                                 >> $(FAAC_PKG)/.PKGINFO ; \
+	 echo "license=$(FAAC_PKG_LICENSE)"                         >> $(FAAC_PKG)/.PKGINFO
+	@$(FAKEROOT) sh -c "cd $(FAAC_PKG) && chown -R root:root . && $(MAKE_PACKAGE) --linkadd yes .."
diff --git a/app/faac/1.28/PATCHES b/app/faac/1.28/PATCHES
new file mode 100644
index 000000000..ebd8e2d63
--- /dev/null
+++ b/app/faac/1.28/PATCHES
@@ -0,0 +1,3 @@
+
+../../../sources/packages/m/audiocoding/faac/patches/faac-1.28-mpeg4ip.patch -p0
+../../../sources/packages/m/audiocoding/faac/patches/faac-1.28-mp4v2.patch   -p0
diff --git a/app/faac/1.28/faac-pkg-description.in b/app/faac/1.28/faac-pkg-description.in
new file mode 100644
index 000000000..8db0ee142
--- /dev/null
+++ b/app/faac/1.28/faac-pkg-description.in
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description.  Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in.  You must
+# make exactly 11 lines for the formatting to be correct.  It's also
+# customary to leave one space after the ':'.
+
+    |-----handy-ruler------------------------------------------------------|
+faac: faac @VERSION@ (MPEG-4 and MPEG-2 AAC encoder)
+faac:
+faac: This package contains the ISO/MPEG 2/4 AAC Encoder and Library.
+faac:
+faac: The ISO/MPEG 2/4 AAC Encoder Library provides a high-level interface
+faac: for encoding MPEG2 and MPEG4 ISO AAC files. The faac.h header file
+faac: is provided for usage in C/C++ programs.
+faac:
+faac: Homepage: http://audiocoding.com/index.html
+faac:
+faac:
diff --git a/app/faac/1.28/faac-pkg-install.sh b/app/faac/1.28/faac-pkg-install.sh
new file mode 100755
index 000000000..8e8683cd6
--- /dev/null
+++ b/app/faac/1.28/faac-pkg-install.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# arg 1:  the new package version
+pre_install() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+post_install() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+# arg 2:  the old package version
+pre_update() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+# arg 2:  the old package version
+post_update() {
+  post_install
+}
+
+# arg 1:  the old package version
+pre_remove() {
+  /bin/true
+}
+
+# arg 1:  the old package version
+post_remove() {
+  /bin/true
+}
+
+
+operation=$1
+shift
+
+$operation $*
diff --git a/libs/mp4v2/2.0.0-x86_32/Makefile b/libs/mp4v2/2.0.0-x86_32/Makefile
new file mode 100644
index 000000000..bbd33fc56
--- /dev/null
+++ b/libs/mp4v2/2.0.0-x86_32/Makefile
@@ -0,0 +1,182 @@
+
+COMPONENT_TARGETS  = $(HARDWARE_PC64)
+
+NEED_ABS_PATH      = true
+COMPONENT_IS_3PP   = true
+
+CREATE_X86_32_PACKAGE = true
+
+
+include ../../../build-system/constants.mk
+
+
+SOURCE_REQUIRES    = sources/packages/m/mp4v2
+
+REQUIRES           = libs/mp4v2/2.0.0
+
+# ======= __END_OF_REQUIRES__ =======
+
+
+version            = 2.0.0
+tar_bz2_archive    = $(SRC_PACKAGE_PATH)/packages/m/mp4v2/mp4v2-$(version).tar.bz2
+SRC_ARCHIVE        = $(tar_bz2_archive)
+SRC_DIR            = $(TARGET_BUILD_DIR)/mp4v2-$(version)
+src_dir_name       = mp4v2-$(version)
+src_done           = $(TARGET_BUILD_DIR)/.source_done
+
+PATCHES = PATCHES
+
+build_dir          = $(TARGET_BUILD_DIR)/build
+build_target       = $(TARGET_BUILD_DIR)/.build_done
+install_target     = $(TARGET_BUILD_DIR)/.install_done
+
+
+####### Targets
+
+PKG_GROUP = libs
+
+#
+# *PKG_NAME & *PKG_VERSION shouldn't be a reference to value.
+#
+MP4V2_32_PKG_NAME                = mp4v2-x32
+MP4V2_32_PKG_VERSION             = 2.0.0
+MP4V2_32_PKG_ARCH                = $(TOOLCHAIN)
+MP4V2_32_PKG_DISTRO_NAME         = $(DISTRO_NAME)
+MP4V2_32_PKG_DISTRO_VERSION      = $(DISTRO_VERSION)
+MP4V2_32_PKG_GROUP               = $(PKG_GROUP)
+###                               |---handy-ruler-------------------------------|
+MP4V2_32_PKG_SHORT_DESCRIPTION   = The MPEG-4 library
+MP4V2_32_PKG_URL                 = $(BUG_URL)
+MP4V2_32_PKG_LICENSE             = MPL
+MP4V2_32_PKG_DESCRIPTION_FILE    = $(TARGET_BUILD_DIR)/$(MP4V2_32_PKG_NAME)-pkg-description
+MP4V2_32_PKG_DESCRIPTION_FILE_IN = $(MP4V2_32_PKG_NAME)-pkg-description.in
+MP4V2_32_PKG_INSTALL_SCRIPT      = $(MP4V2_32_PKG_NAME)-pkg-install.sh
+
+MP4V2_32_PKG      = $(CURDIR)/$(TARGET_BUILD_DIR)/$(MP4V2_32_PKG_NAME)-package
+
+pkg_basename      = $(MP4V2_32_PKG_NAME)-$(MP4V2_32_PKG_VERSION)-$(MP4V2_32_PKG_ARCH)-$(MP4V2_32_PKG_DISTRO_NAME)-$(MP4V2_32_PKG_DISTRO_VERSION)
+
+pkg_archive       = $(TARGET_BUILD_DIR)/$(PKG_GROUP)/$(pkg_basename).$(pkg_arch_suffix)
+pkg_signature     = $(call sign-name,$(pkg_archive))
+pkg_description   = $(call desc-name,$(pkg_archive))
+products          = $(call pkg-files,$(pkg_archive))
+
+BUILD_TARGETS     = $(build_target)
+BUILD_TARGETS    += $(install_target)
+
+PRODUCT_TARGETS   = $(products)
+
+ROOTFS_TARGETS    = $(pkg_archive)
+
+
+include ../../../build-system/core.mk
+
+
+env_sysroot  = DESTDIR=$(MP4V2_32_PKG)
+
+
+extra_configure_switches  = --libdir=/usr/lib$(MULTILIB_X86_32_SUFFIX)
+extra_configure_switches += --docdir=/usr/share/doc/$(src_dir_name)
+extra_configure_switches += --mandir=/usr/share/man
+extra_configure_switches += --disable-dependency-tracking
+
+extra_configure_switches += --sysconfdir=/etc
+extra_configure_switches += --localstatedir=/var
+
+extra_configure_switches += --bindir=/usr/bin/32
+
+extra_configure_switches += --disable-gch
+extra_configure_switches += --with-pic
+
+extra_configure_switches += --enable-shared=yes
+extra_configure_switches += --enable-static=yes
+
+
+TARGET_BIN_RPATH = /lib$(MULTILIB_X86_32_SUFFIX):/usr/lib$(MULTILIB_X86_32_SUFFIX)
+TARGET_LIB_RPATH = /lib$(MULTILIB_X86_32_SUFFIX):/usr/lib$(MULTILIB_X86_32_SUFFIX):/usr/lib/../lib$(MULTILIB_X86_32_SUFFIX)
+
+LDFLAGS += -Wl,-rpath,$(TARGET_BIN_RPATH)
+
+
+####### Dependencies
+
+$(src_done): $(SRC_ARCHIVE) $(PATCHES_DEP)
+	$(UNPACK_SRC_ARCHIVE)
+	$(APPLY_PATCHES)
+	@touch $@
+
+$(build_target): $(src_done)
+	@mkdir -p $(build_dir)
+	@cd $(build_dir) && \
+	  $(BUILD_ENVIRONMENT) ../$(src_dir_name)/configure \
+	  --prefix=/usr               \
+	  --build=$(BUILD)            \
+	  --host=$(TARGET32)          \
+	  $(extra_configure_switches)
+	@cd $(build_dir) && $(BUILD_ENVIRONMENT) $(MAKE)
+	@touch $@
+
+$(install_target): $(build_target)
+	@mkdir -p $(MP4V2_32_PKG)
+	@cd $(build_dir) && $(BUILD_ENVIRONMENT) $(MAKE) -j1 install $(env_sysroot)
+	@rm -rf $(MP4V2_32_PKG)/usr/include
+	@rm -rf $(MP4V2_32_PKG)/usr/share
+	# ======= remove toolchain path from target libtool *.la files =======
+	@( cd $(MP4V2_32_PKG)/usr/lib$(MULTILIB_X86_32_SUFFIX) ; \
+	   sed -i "s,$(TARGET_DEST_DIR),,g" libmp4v2.la  \
+	 )
+	# ======= Install the same to $(TARGET_DEST_DIR) =======
+	$(call install-into-devenv, $(MP4V2_32_PKG))
+	# ======= tune libtool *.la search path to the target destination for development =======
+	@( cd $(TARGET_DEST_DIR)/usr/lib$(MULTILIB_X86_32_SUFFIX) ; \
+	   sed -i "s,/usr,$(TARGET_DEST_DIR)/usr,g" libmp4v2.la ; \
+	   sed -i "s,L/lib,L$(TARGET_DEST_DIR)/lib,g" libmp4v2.la \
+	 )
+	# ======= Strip binaries =======
+	@( cd $(MP4V2_32_PKG) ; \
+	   find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs $(STRIP) --strip-unneeded 2> /dev/null ; \
+	   find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs $(STRIP) --strip-unneeded 2> /dev/null ; \
+	   find . | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs $(STRIP) -g 2> /dev/null \
+	 )
+ifneq ($(CHRPATH),)
+	# ======= Set RPATH/RUNPATH for target binaries =======
+	@( cd $(MP4V2_32_PKG)/usr/bin/32 ; \
+	   for file in `find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs echo` ; do \
+	     rpath=`$(CHRPATH) -l $$file 2> /dev/null | grep "R*PATH"` ; \
+	     if echo "$$rpath" | grep -q "$(TARGET_DEST_DIR)" ; then \
+	       $(CHRPATH) -r $(TARGET_BIN_RPATH) $$file 1> /dev/null 2> /dev/null ; \
+	     fi ; \
+	   done ; \
+	 )
+	# ======= Set RPATH/RUNPATH for target shared objects =======
+	@( cd $(MP4V2_32_PKG)/usr/lib$(MULTILIB_X86_32_SUFFIX) ; \
+	   for file in `find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs echo` ; do \
+	     rpath=`$(CHRPATH) -l $$file 2> /dev/null | grep "R*PATH"` ; \
+	     if echo "$$rpath" | grep -q "$(TARGET_DEST_DIR)" ; then \
+	       $(CHRPATH) -r $(TARGET_LIB_RPATH) $$file 1> /dev/null 2> /dev/null ; \
+	     fi ; \
+	   done ; \
+	 )
+endif
+	@touch $@
+
+$(MP4V2_32_PKG_DESCRIPTION_FILE): $(MP4V2_32_PKG_DESCRIPTION_FILE_IN)
+	@cat $< | $(SED) -e "s/@VERSION@/$(version)/g" > $@
+
+$(pkg_signature)   : $(pkg_archive) ;
+$(pkg_description) : $(pkg_archive) ;
+
+$(pkg_archive): $(install_target) $(MP4V2_32_PKG_DESCRIPTION_FILE) $(MP4V2_32_PKG_INSTALL_SCRIPT)
+	@cp $(MP4V2_32_PKG_DESCRIPTION_FILE) $(MP4V2_32_PKG)/.DESCRIPTION
+	@cp $(MP4V2_32_PKG_INSTALL_SCRIPT) $(MP4V2_32_PKG)/.INSTALL
+	@$(BUILD_PKG_REQUIRES) $(MP4V2_32_PKG)/.REQUIRES
+	@echo "pkgname=$(MP4V2_32_PKG_NAME)"                            >  $(MP4V2_32_PKG)/.PKGINFO ; \
+	 echo "pkgver=$(MP4V2_32_PKG_VERSION)"                          >> $(MP4V2_32_PKG)/.PKGINFO ; \
+	 echo "arch=$(MP4V2_32_PKG_ARCH)"                               >> $(MP4V2_32_PKG)/.PKGINFO ; \
+	 echo "distroname=$(MP4V2_32_PKG_DISTRO_NAME)"                  >> $(MP4V2_32_PKG)/.PKGINFO ; \
+	 echo "distrover=$(MP4V2_32_PKG_DISTRO_VERSION)"                >> $(MP4V2_32_PKG)/.PKGINFO ; \
+	 echo "group=$(MP4V2_32_PKG_GROUP)"                             >> $(MP4V2_32_PKG)/.PKGINFO ; \
+	 echo "short_description=\"$(MP4V2_32_PKG_SHORT_DESCRIPTION)\"" >> $(MP4V2_32_PKG)/.PKGINFO ; \
+	 echo "url=$(MP4V2_32_PKG_URL)"                                 >> $(MP4V2_32_PKG)/.PKGINFO ; \
+	 echo "license=$(MP4V2_32_PKG_LICENSE)"                         >> $(MP4V2_32_PKG)/.PKGINFO
+	@$(FAKEROOT) sh -c "cd $(MP4V2_32_PKG) && chown -R root:root . && $(MAKE_PACKAGE) --linkadd yes .."
diff --git a/libs/mp4v2/2.0.0-x86_32/PATCHES b/libs/mp4v2/2.0.0-x86_32/PATCHES
new file mode 100644
index 000000000..9077ff1b6
--- /dev/null
+++ b/libs/mp4v2/2.0.0-x86_32/PATCHES
@@ -0,0 +1,2 @@
+
+../../../sources/packages/m/mp4v2/patches/mp4v2-2.0.0-help2man.patch -p0
diff --git a/libs/mp4v2/2.0.0-x86_32/mp4v2-x32-pkg-description.in b/libs/mp4v2/2.0.0-x86_32/mp4v2-x32-pkg-description.in
new file mode 100644
index 000000000..7f8eb8dce
--- /dev/null
+++ b/libs/mp4v2/2.0.0-x86_32/mp4v2-x32-pkg-description.in
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description.  Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in.  You must
+# make exactly 11 lines for the formatting to be correct.  It's also
+# customary to leave one space after the ':'.
+
+         |-----handy-ruler------------------------------------------------------|
+mp4v2-x32: mp4v2-x32 @VERSION@ (x86_32 MPEG-4 library)
+mp4v2-x32:
+mp4v2-x32: The MP4v2 library provides an API to create and modify mp4 files as
+mp4v2-x32: defined by ISO-IEC:14496-1:2001 MPEG-4 Systems. This file format is
+mp4v2-x32: derived from Apple's QuickTime file format that has been used as a
+mp4v2-x32: multimedia file format in a variety of platforms and applications.
+mp4v2-x32: It is a very powerful and extensible format that can accommodate
+mp4v2-x32: practically any type of media.
+mp4v2-x32:
+mp4v2-x32:
+mp4v2-x32:
diff --git a/libs/mp4v2/2.0.0-x86_32/mp4v2-x32-pkg-install.sh b/libs/mp4v2/2.0.0-x86_32/mp4v2-x32-pkg-install.sh
new file mode 100755
index 000000000..8e8683cd6
--- /dev/null
+++ b/libs/mp4v2/2.0.0-x86_32/mp4v2-x32-pkg-install.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# arg 1:  the new package version
+pre_install() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+post_install() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+# arg 2:  the old package version
+pre_update() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+# arg 2:  the old package version
+post_update() {
+  post_install
+}
+
+# arg 1:  the old package version
+pre_remove() {
+  /bin/true
+}
+
+# arg 1:  the old package version
+post_remove() {
+  /bin/true
+}
+
+
+operation=$1
+shift
+
+$operation $*
diff --git a/libs/mp4v2/2.0.0/Makefile b/libs/mp4v2/2.0.0/Makefile
new file mode 100644
index 000000000..bb5249db6
--- /dev/null
+++ b/libs/mp4v2/2.0.0/Makefile
@@ -0,0 +1,229 @@
+
+COMPONENT_TARGETS  = $(HARDWARE_PC32)
+COMPONENT_TARGETS += $(HARDWARE_PC64)
+COMPONENT_TARGETS += $(HARDWARE_CB1X)
+COMPONENT_TARGETS += $(HARDWARE_CB2X)
+COMPONENT_TARGETS += $(HARDWARE_CB3X)
+COMPONENT_TARGETS += $(HARDWARE_FFRK3288)
+COMPONENT_TARGETS += $(HARDWARE_M201)
+COMPONENT_TARGETS += $(HARDWARE_MXQ)
+COMPONENT_TARGETS += $(HARDWARE_NIT6Q)
+COMPONENT_TARGETS += $(HARDWARE_OMAP5UEVM)
+COMPONENT_TARGETS += $(HARDWARE_DRA7XXEVM)
+COMPONENT_TARGETS += $(HARDWARE_CI20)
+COMPONENT_TARGETS += $(HARDWARE_BT1)
+
+
+NEED_ABS_PATH      = true
+COMPONENT_IS_3PP   = true
+
+
+include ../../../build-system/constants.mk
+
+
+SOURCE_REQUIRES    = sources/packages/m/mp4v2
+
+ifeq ($(__USE_BUILT_GCC_LIBS__),yes)
+REQUIRES           = dev/gcc/5.3.0
+else
+ifneq ($(HARDWARE),$(HARDWARE_PC64))
+REQUIRES           = libs/glibc/2.23
+else
+REQUIRES           = libs/glibc/2.23-x86_32
+endif
+endif
+
+# ======= __END_OF_REQUIRES__ =======
+
+
+version            = 2.0.0
+tar_bz2_archive    = $(SRC_PACKAGE_PATH)/packages/m/mp4v2/mp4v2-$(version).tar.bz2
+SRC_ARCHIVE        = $(tar_bz2_archive)
+SRC_DIR            = $(TARGET_BUILD_DIR)/mp4v2-$(version)
+src_dir_name       = mp4v2-$(version)
+src_done           = $(TARGET_BUILD_DIR)/.source_done
+
+PATCHES = PATCHES
+
+build_dir          = $(TARGET_BUILD_DIR)/build
+build_target       = $(TARGET_BUILD_DIR)/.build_done
+install_target     = $(TARGET_BUILD_DIR)/.install_done
+
+
+####### Targets
+
+PKG_GROUP = libs
+
+#
+# *PKG_NAME & *PKG_VERSION shouldn't be a reference to value.
+#
+MP4V2_PKG_NAME                = mp4v2
+MP4V2_PKG_VERSION             = 2.0.0
+MP4V2_PKG_ARCH                = $(TOOLCHAIN)
+MP4V2_PKG_DISTRO_NAME         = $(DISTRO_NAME)
+MP4V2_PKG_DISTRO_VERSION      = $(DISTRO_VERSION)
+MP4V2_PKG_GROUP               = $(PKG_GROUP)
+###                            |---handy-ruler-------------------------------|
+MP4V2_PKG_SHORT_DESCRIPTION   = The MPEG-4 library
+MP4V2_PKG_URL                 = $(BUG_URL)
+MP4V2_PKG_LICENSE             = MPL
+MP4V2_PKG_DESCRIPTION_FILE    = $(TARGET_BUILD_DIR)/$(MP4V2_PKG_NAME)-pkg-description
+MP4V2_PKG_DESCRIPTION_FILE_IN = $(MP4V2_PKG_NAME)-pkg-description.in
+MP4V2_PKG_INSTALL_SCRIPT      = $(MP4V2_PKG_NAME)-pkg-install.sh
+
+MP4V2_PKG        = $(CURDIR)/$(TARGET_BUILD_DIR)/$(MP4V2_PKG_NAME)-package
+
+pkg_basename     = $(MP4V2_PKG_NAME)-$(MP4V2_PKG_VERSION)-$(MP4V2_PKG_ARCH)-$(MP4V2_PKG_DISTRO_NAME)-$(MP4V2_PKG_DISTRO_VERSION)
+
+pkg_archive      = $(TARGET_BUILD_DIR)/$(PKG_GROUP)/$(pkg_basename).$(pkg_arch_suffix)
+pkg_signature    = $(call sign-name,$(pkg_archive))
+pkg_description  = $(call desc-name,$(pkg_archive))
+products         = $(call pkg-files,$(pkg_archive))
+
+BUILD_TARGETS    = $(build_target)
+BUILD_TARGETS   += $(install_target)
+
+PRODUCT_TARGETS  = $(products)
+
+ROOTFS_TARGETS   = $(pkg_archive)
+
+
+include ../../../build-system/core.mk
+
+
+env_sysroot = DESTDIR=$(MP4V2_PKG)
+
+
+extra_configure_switches  = --libdir=/usr/lib$(LIBSUFFIX)
+extra_configure_switches += --docdir=/usr/share/doc/$(src_dir_name)
+extra_configure_switches += --mandir=/usr/share/man
+extra_configure_switches += --disable-dependency-tracking
+
+extra_configure_switches += --sysconfdir=/etc
+extra_configure_switches += --localstatedir=/var
+
+extra_configure_switches += --disable-gch
+extra_configure_switches += --with-pic
+
+extra_configure_switches += --enable-shared=yes
+extra_configure_switches += --enable-static=yes
+
+
+TARGET_BIN_RPATH = /lib$(LIBSUFFIX):/usr/lib$(LIBSUFFIX)
+TARGET_LIB_RPATH = /lib$(LIBSUFFIX):/usr/lib$(LIBSUFFIX):/usr/lib/../lib$(LIBSUFFIX)
+
+LDFLAGS += -Wl,-rpath,$(TARGET_BIN_RPATH)
+
+
+####### Dependencies
+
+$(src_done): $(SRC_ARCHIVE) $(PATCHES_DEP)
+	$(UNPACK_SRC_ARCHIVE)
+	$(APPLY_PATCHES)
+	@touch $@
+
+$(build_target): $(src_done)
+	@mkdir -p $(build_dir)
+	@cd $(build_dir) && \
+	  $(BUILD_ENVIRONMENT) ../$(src_dir_name)/configure \
+	  --prefix=/usr               \
+	  --build=$(BUILD)            \
+	  --host=$(TARGET)            \
+	  $(extra_configure_switches)
+	@cd $(build_dir) && $(BUILD_ENVIRONMENT) $(MAKE)
+	@touch $@
+
+$(install_target): $(build_target)
+	@mkdir -p $(MP4V2_PKG)
+	@cd $(build_dir) && $(BUILD_ENVIRONMENT) $(MAKE) -j1 install     $(env_sysroot)
+	@cd $(build_dir) && $(BUILD_ENVIRONMENT) $(MAKE) -j1 install man $(env_sysroot)
+	# ======= Install Documentation =======
+	@if [ -d $(MP4V2_PKG)/usr/share/man ]; then \
+	  ( cd $(MP4V2_PKG)/usr/share/man ; \
+	    for manpagedir in `find . -type d -name "man*"` ; do \
+	      ( cd $$manpagedir ; \
+	        for eachpage in `find . -type l -maxdepth 1` ; do \
+	          ln -s `readlink $$eachpage`.gz $$eachpage.gz ; \
+	          rm $$eachpage ; \
+	        done ; \
+	        gzip -9 *.? ; \
+	      ) \
+	    done \
+	  ) \
+	 fi
+	@mkdir -p $(MP4V2_PKG)/usr/doc/$(src_dir_name)
+	@cp -a $(SRC_DIR)/COPYING \
+	       $(MP4V2_PKG)/usr/doc/$(src_dir_name)
+	@mkdir -p $(MP4V2_PKG)/usr/share/doc/$(src_dir_name)/doc
+	@( cd $(SRC_DIR) ; \
+	   cp -a COPYING INSTALL README \
+	         $(MP4V2_PKG)/usr/share/doc/$(src_dir_name) ; \
+	   cp -a doc/*.txt \
+	         $(MP4V2_PKG)/usr/share/doc/$(src_dir_name)/doc ; \
+	 )
+	@( cd $(SRC_DIR) ; \
+	   if [ -r ChangeLog ]; then \
+	     DOCSDIR=`echo $(MP4V2_PKG)/usr/share/doc/$(src_dir_name)` ; \
+	     cat ChangeLog | head -n 1000 > $$DOCSDIR/ChangeLog ; \
+	     touch -r ChangeLog $$DOCSDIR/ChangeLog ; \
+	   fi \
+	 )
+	# ======= remove toolchain path from target libtool *.la files =======
+	@( cd $(MP4V2_PKG)/usr/lib$(LIBSUFFIX) ; \
+	   sed -i "s,$(TARGET_DEST_DIR),,g" libmp4v2.la  \
+	 )
+	# ======= Install the same to $(TARGET_DEST_DIR) =======
+	$(call install-into-devenv, $(MP4V2_PKG))
+	# ======= tune libtool *.la search path to the target destination for development =======
+	@( cd $(TARGET_DEST_DIR)/usr/lib$(LIBSUFFIX) ; \
+	   sed -i "s,/usr,$(TARGET_DEST_DIR)/usr,g" libmp4v2.la ; \
+	   sed -i "s,L/lib,L$(TARGET_DEST_DIR)/lib,g" libmp4v2.la \
+	 )
+	# ======= Strip binaries =======
+	@( cd $(MP4V2_PKG) ; \
+	   find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs $(STRIP) --strip-unneeded 2> /dev/null ; \
+	   find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs $(STRIP) --strip-unneeded 2> /dev/null ; \
+	   find . | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs $(STRIP) -g 2> /dev/null \
+	 )
+ifneq ($(CHRPATH),)
+	# ======= Set RPATH/RUNPATH for target binaries =======
+	@( cd $(MP4V2_PKG)/usr/bin ; \
+	   for file in `find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs echo` ; do \
+	     rpath=`$(CHRPATH) -l $$file 2> /dev/null | grep "R*PATH"` ; \
+	     if echo "$$rpath" | grep -q "$(TARGET_DEST_DIR)" ; then \
+	       $(CHRPATH) -r $(TARGET_BIN_RPATH) $$file 1> /dev/null 2> /dev/null ; \
+	     fi ; \
+	   done ; \
+	 )
+	# ======= Set RPATH/RUNPATH for target shared objects =======
+	@( cd $(MP4V2_PKG)/usr/lib$(LIBSUFFIX) ; \
+	   for file in `find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs echo` ; do \
+	     rpath=`$(CHRPATH) -l $$file 2> /dev/null | grep "R*PATH"` ; \
+	     if echo "$$rpath" | grep -q "$(TARGET_DEST_DIR)" ; then \
+	       $(CHRPATH) -r $(TARGET_LIB_RPATH) $$file 1> /dev/null 2> /dev/null ; \
+	     fi ; \
+	   done ; \
+	 )
+endif
+	@touch $@
+
+$(MP4V2_PKG_DESCRIPTION_FILE): $(MP4V2_PKG_DESCRIPTION_FILE_IN)
+	@cat $< | $(SED) -e "s/@VERSION@/$(version)/g" > $@
+
+$(pkg_signature)   : $(pkg_archive) ;
+$(pkg_description) : $(pkg_archive) ;
+
+$(pkg_archive): $(install_target) $(MP4V2_PKG_DESCRIPTION_FILE) $(MP4V2_PKG_INSTALL_SCRIPT)
+	@cp $(MP4V2_PKG_DESCRIPTION_FILE) $(MP4V2_PKG)/.DESCRIPTION
+	@cp $(MP4V2_PKG_INSTALL_SCRIPT) $(MP4V2_PKG)/.INSTALL
+	@$(BUILD_PKG_REQUIRES) $(MP4V2_PKG)/.REQUIRES
+	@echo "pkgname=$(MP4V2_PKG_NAME)"                            >  $(MP4V2_PKG)/.PKGINFO ; \
+	 echo "pkgver=$(MP4V2_PKG_VERSION)"                          >> $(MP4V2_PKG)/.PKGINFO ; \
+	 echo "arch=$(MP4V2_PKG_ARCH)"                               >> $(MP4V2_PKG)/.PKGINFO ; \
+	 echo "distroname=$(MP4V2_PKG_DISTRO_NAME)"                  >> $(MP4V2_PKG)/.PKGINFO ; \
+	 echo "distrover=$(MP4V2_PKG_DISTRO_VERSION)"                >> $(MP4V2_PKG)/.PKGINFO ; \
+	 echo "group=$(MP4V2_PKG_GROUP)"                             >> $(MP4V2_PKG)/.PKGINFO ; \
+	 echo "short_description=\"$(MP4V2_PKG_SHORT_DESCRIPTION)\"" >> $(MP4V2_PKG)/.PKGINFO ; \
+	 echo "url=$(MP4V2_PKG_URL)"                                 >> $(MP4V2_PKG)/.PKGINFO ; \
+	 echo "license=$(MP4V2_PKG_LICENSE)"                         >> $(MP4V2_PKG)/.PKGINFO
+	@$(FAKEROOT) sh -c "cd $(MP4V2_PKG) && chown -R root:root . && $(MAKE_PACKAGE) --linkadd yes .."
diff --git a/libs/mp4v2/2.0.0/PATCHES b/libs/mp4v2/2.0.0/PATCHES
new file mode 100644
index 000000000..9077ff1b6
--- /dev/null
+++ b/libs/mp4v2/2.0.0/PATCHES
@@ -0,0 +1,2 @@
+
+../../../sources/packages/m/mp4v2/patches/mp4v2-2.0.0-help2man.patch -p0
diff --git a/libs/mp4v2/2.0.0/mp4v2-pkg-description.in b/libs/mp4v2/2.0.0/mp4v2-pkg-description.in
new file mode 100644
index 000000000..a2debe030
--- /dev/null
+++ b/libs/mp4v2/2.0.0/mp4v2-pkg-description.in
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description.  Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in.  You must
+# make exactly 11 lines for the formatting to be correct.  It's also
+# customary to leave one space after the ':'.
+
+     |-----handy-ruler------------------------------------------------------|
+mp4v2: mp4v2 @VERSION@ (The MPEG-4 library)
+mp4v2:
+mp4v2: The MP4v2 library provides an API to create and modify mp4 files as
+mp4v2: defined by ISO-IEC:14496-1:2001 MPEG-4 Systems. This file format is
+mp4v2: derived from Apple's QuickTime file format that has been used as a
+mp4v2: multimedia file format in a variety of platforms and applications.
+mp4v2: It is a very powerful and extensible format that can accommodate
+mp4v2: practically any type of media.
+mp4v2:
+mp4v2:
+mp4v2:
diff --git a/libs/mp4v2/2.0.0/mp4v2-pkg-install.sh b/libs/mp4v2/2.0.0/mp4v2-pkg-install.sh
new file mode 100755
index 000000000..8e8683cd6
--- /dev/null
+++ b/libs/mp4v2/2.0.0/mp4v2-pkg-install.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# arg 1:  the new package version
+pre_install() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+post_install() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+# arg 2:  the old package version
+pre_update() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+# arg 2:  the old package version
+post_update() {
+  post_install
+}
+
+# arg 1:  the old package version
+pre_remove() {
+  /bin/true
+}
+
+# arg 1:  the old package version
+post_remove() {
+  /bin/true
+}
+
+
+operation=$1
+shift
+
+$operation $*
diff --git a/sources/packages/m/audiocoding/Makefile b/sources/packages/m/audiocoding/Makefile
new file mode 100644
index 000000000..78f51bc23
--- /dev/null
+++ b/sources/packages/m/audiocoding/Makefile
@@ -0,0 +1,13 @@
+
+COMPONENT_TARGETS = $(HARDWARE_NOARCH)
+
+SOURCE_REQUIRES += ALL_DIRS
+
+
+include ../../../../build-system/core.mk
+
+
+download_clean:
+	@true
+
+.PHONY: download_clean
diff --git a/sources/packages/m/audiocoding/faac/Makefile b/sources/packages/m/audiocoding/faac/Makefile
new file mode 100644
index 000000000..c13be4391
--- /dev/null
+++ b/sources/packages/m/audiocoding/faac/Makefile
@@ -0,0 +1,58 @@
+
+COMPONENT_TARGETS = $(HARDWARE_NOARCH)
+
+
+include ../../../../../build-system/constants.mk
+
+
+url         = $(DOWNLOAD_SERVER)/sources/packages/m/audiocoding/faac
+
+versions    = 1.28
+pkgname     = faac
+suffix      = tar.gz
+
+tarballs    = $(addsuffix .$(suffix), $(addprefix $(pkgname)-, $(versions)))
+sha1s       = $(addsuffix .sha1sum, $(tarballs))
+
+patches     = $(CURDIR)/patches/faac-1.28-mpeg4ip.patch
+patches    += $(CURDIR)/patches/faac-1.28-mp4v2.patch
+
+.NOTPARALLEL: $(patches)
+
+
+BUILD_TARGETS = $(tarballs) $(sha1s) $(patches)
+
+
+include ../../../../../build-system/core.mk
+
+
+.PHONY: download_clean
+
+
+$(tarballs):
+	@echo -e "\n======= Downloading source tarballs =======" ; \
+	 for tarball in $(tarballs) ; do \
+	   echo "$(url)/$$tarball" | xargs -n 1 -P 100 wget $(WGET_OPTIONS) -i & \
+	 done ; wait
+
+$(sha1s): $(tarballs)
+	@for sha in $@ ; do \
+	   echo -e "\n======= Downloading '$$sha' signature =======\n" ; \
+	   echo "$(url)/$$sha" | xargs -n 1 -P 100 wget $(WGET_OPTIONS) -i & wait %1 ; \
+	   touch $$sha ; \
+	   echo -e "\n======= Check the '$$sha' sha1sum =======\n" ; \
+	   sha1sum --check $$sha ; ret="$$?" ; \
+	   if [ "$$ret" == "1" ]; then \
+	     echo -e "\n======= ERROR: Bad '$$sha' sha1sum =======\n" ; \
+	     exit 1 ; \
+	   fi ; \
+	 done
+
+$(patches): $(sha1s)
+	@echo -e "\n======= Create Patches =======\n" ; \
+	 ( cd create-1.28-mpeg4ip-patch ; ./create.patch.sh ) ; \
+	 ( cd create-1.28-mp4v2-patch   ; ./create.patch.sh ) ; \
+	 echo -e "\n"
+
+download_clean:
+	@rm -f $(tarballs) $(sha1s) $(patches)
diff --git a/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/create.patch.sh b/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/create.patch.sh
new file mode 100755
index 000000000..c1fd27f5d
--- /dev/null
+++ b/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/create.patch.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=1.28
+
+tar --files-from=file.list -xzvf ../faac-$VERSION.tar.gz
+mv faac-$VERSION faac-$VERSION-orig
+
+cp -rf ./faac-$VERSION-new ./faac-$VERSION
+
+diff -b --unified -Nr  faac-$VERSION-orig  faac-$VERSION > faac-$VERSION-mp4v2.patch
+
+mv faac-$VERSION-mp4v2.patch ../patches
+
+rm -rf ./faac-$VERSION
+rm -rf ./faac-$VERSION-orig
diff --git a/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/faac-1.28-new/configure.in b/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/faac-1.28-new/configure.in
new file mode 100644
index 000000000..3bd0ce38d
--- /dev/null
+++ b/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/faac-1.28-new/configure.in
@@ -0,0 +1,94 @@
+AC_PREREQ(2.50)
+AC_INIT(FAAC, 1.28, faac-dev@lists.sourceforge.net)
+AC_CONFIG_AUX_DIR(.)
+AM_INIT_AUTOMAKE
+
+AM_CONFIG_HEADER(config.h)
+
+AC_ARG_WITH( mp4v2,  [  --with-mp4v2            compile libmp4v2],WITHMP4V2=$withval, WITHMP4V2=yes)
+AC_ARG_ENABLE( drm,  [  --enable-drm            Digital Radio Mondiale support], enable_drm=$enableval, enable_drm=no)
+
+AC_DEFUN([MY_DEFINE], [ AC_DEFINE($1, 1, [define if needed]) ])
+
+CFLAGS=${CFLAGS:-"-O2 -Wall"}
+
+AC_PROG_CC
+AC_PROG_CXX
+AM_PROG_LIBTOOL
+
+AC_CHECK_HEADERS(getopt.h)
+
+AC_CHECK_TYPES(u_int32_t)
+AC_CHECK_TYPES(u_int16_t)
+AC_CHECK_TYPES(int32_t)
+AC_CHECK_TYPES(int16_t)
+
+AC_CHECK_DECL(strcasecmp, MY_DEFINE(HAVE_STRCASECMP))
+
+AC_CHECK_LIB(gnugetopt, getopt_long)
+
+AM_CONDITIONAL(WITH_MP4V2, false)
+AM_CONDITIONAL(WITH_EXTERNAL_MP4V2, false)
+
+AC_CHECK_DECLS([MP4Create],
+               AC_CHECK_LIB(mp4v2, MP4Create, external_mp4v2=yes,
+                            external_mp4v2=no, -lstdc++),
+               external_mp4v2=no, [
+#if defined(__ALTIVEC__)
+#undef bool
+#endif
+#include <mp4v2/mp4v2.h>
+])
+
+if test x$external_mp4v2 = xyes; then
+  AC_MSG_NOTICE([*** Building with external mp4v2 ***])
+  MY_DEFINE(HAVE_LIBMP4V2)
+  AM_CONDITIONAL(WITH_EXTERNAL_MP4V2, true)
+  AC_CHECK_DECLS([MP4TagsAlloc], [], [], [#include <mp4v2/mp4v2.h>])
+else
+  if test x$WITHMP4V2 = xyes; then
+     AC_MSG_NOTICE([*** Building with internal mp4v2 ***])
+     AM_CONDITIONAL(WITH_MP4V2, true)
+     AC_CONFIG_LINKS(common/mp4v2/mpeg4ip_config.h:config.h)
+     MY_DEFINE(HAVE_LIBMP4V2)
+  else
+     AC_MSG_NOTICE([*** Building WITHOUT mp4v2 ***])
+  fi
+fi
+
+dnl Check for DRM mode
+if test "x$enable_drm" = "xyes"; then
+    AC_DEFINE(DRM, 1, [Define if you want to encode for DRM])
+    AM_CONDITIONAL(USE_DRM, true)
+      CFLAGS="$CFLAGS -DDRM"
+else
+    AM_CONDITIONAL(USE_DRM, false)
+fi
+
+AC_C_BIGENDIAN
+
+dnl Checks for header files required for mp4.h
+AC_HEADER_STDC
+AC_SYS_LARGEFILE
+AC_CHECK_HEADERS(stdint.h inttypes.h)
+AC_CHECK_HEADERS(mathf.h)
+AC_CHECK_HEADERS(float.h)
+AC_CHECK_DECL(strchr, MY_DEFINE(HAVE_STRCHR))
+AC_CHECK_DECL(memcpy, MY_DEFINE(HAVE_MEMCPY))
+AC_CHECK_DECL(strsep, MY_DEFINE(HAVE_STRSEP))
+AC_CHECK_HEADERS(sys/time.h)
+AC_HEADER_TIME
+AC_TYPE_OFF_T
+AC_CHECK_TYPES([in_port_t, socklen_t], , , 
+	[#include <sys/types.h>
+	 #include <sys/socket.h>
+	 #include <netinet/in.h>])
+AC_CHECK_MEMBERS(fpos_t.__pos,,, [#include <stdio.h>])
+
+AC_OUTPUT([
+common/Makefile
+common/mp4v2/Makefile
+libfaac/Makefile
+frontend/Makefile
+include/Makefile
+Makefile])
diff --git a/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/faac-1.28-new/frontend/Makefile.am b/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/faac-1.28-new/frontend/Makefile.am
new file mode 100644
index 000000000..2643d51c0
--- /dev/null
+++ b/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/faac-1.28-new/frontend/Makefile.am
@@ -0,0 +1,16 @@
+bin_PROGRAMS = faac
+man_MANS = ../docs/faac.1
+
+faac_SOURCES = main.c input.c
+
+if WITH_MP4V2
+INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/common/mp4v2
+LDADD = $(top_builddir)/libfaac/libfaac.la $(top_srcdir)/common/mp4v2/libmp4v2.a -lm -lstdc++
+else
+INCLUDES = -I$(top_srcdir)/include 
+if WITH_EXTERNAL_MP4V2
+LDADD = $(top_builddir)/libfaac/libfaac.la -lm -lmp4v2
+else
+LDADD = $(top_builddir)/libfaac/libfaac.la -lm
+endif
+endif
diff --git a/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/faac-1.28-new/frontend/main.c b/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/faac-1.28-new/frontend/main.c
new file mode 100644
index 000000000..3455a9842
--- /dev/null
+++ b/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/faac-1.28-new/frontend/main.c
@@ -0,0 +1,1417 @@
+/*
+ * FAAC - Freeware Advanced Audio Coder
+ * Copyright (C) 2001 Menno Bakker
+ * Copyright (C) 2002-2004 Krzysztof Nikiel
+ * Copyright (C) 2004 Dan Villiom P. Christiansen
+ *
+ * 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 Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * $Id: main.c,v 1.82 2009/01/24 01:10:20 menno Exp $
+ */
+
+#ifdef _MSC_VER
+# define HAVE_LIBMP4V2  1
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_LIBMP4V2
+#if defined(__ALTIVEC__)
+# undef bool
+#endif
+# include <mp4v2/mp4v2.h>
+#endif
+
+#define DEFAULT_TNS     0
+
+#ifdef _WIN32
+#include <windows.h>
+#include <fcntl.h>
+#else
+#include <signal.h>
+#endif
+
+/* the BSD derivatives don't define __unix__ */
+#if defined(__APPLE__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
+#define __unix__
+#endif
+
+#ifdef __unix__
+#include <time.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <math.h>
+#include <string.h>
+
+#ifdef HAVE_GETOPT_H
+# include <getopt.h>
+#else
+# include "getopt.h"
+# include "getopt.c"
+#endif
+
+#if !defined(HAVE_STRCASECMP) && !defined(_WIN32)
+# define strcasecmp strcmp
+#endif
+
+#ifdef _WIN32
+# undef stderr
+# define stderr stdout
+#endif
+
+#include "input.h"
+
+#include <faac.h>
+
+const char *usage =
+  "Usage: %s [options] [-o outfile] infiles ...\n"
+  "\n"
+  "\t<infiles> and/or <outfile> can be \"-\", which means stdin/stdout.\n"
+  "\n"
+  "See also:\n"
+  "\t\"%s --help\" for short help on using FAAC\n"
+  "\t\"%s --long-help\" for a description of all options for FAAC.\n"
+  "\t\"%s --license\" for the license terms for FAAC.\n\n";
+
+const char *short_help =
+  "Usage: %s [options] infiles ...\n"
+  "Options:\n"
+  "  -q <quality>\tSet quantizer quality.\n"
+  "  -b <bitrate>\tSet average bitrate to x kbps. (ABR, lower quality mode)\n"
+  "  -c <freq>\tSet the bandwidth in Hz. (default=automatic)\n"
+  "  -o X\t\tSet output file to X (only for one input file)\n"
+  "  -r\t\tUse RAW AAC output file.\n"
+  "  -P\t\tRaw PCM input mode (default 44100Hz 16bit stereo).\n"
+  "  -R\t\tRaw PCM input rate.\n"
+  "  -B\t\tRaw PCM input sample size (8, 16 (default), 24 or 32bits).\n"
+  "  -C\t\tRaw PCM input channels.\n"
+  "  -X\t\tRaw PCM swap input bytes\n"
+  "  -I <C,LF>\tInput channel config, default is 3,4 (Center third, LF fourth)\n"
+  "\n"
+  "MP4 specific options:\n"
+#ifdef HAVE_LIBMP4V2
+  "  -w\t\tWrap AAC data in MP4 container. (default for *.mp4 and *.m4a)\n"
+  "  -s\t\tOptimize MP4 container layout after encoding\n"
+  "  --artist X\tSet artist to X\n"
+  "  --writer X\tSet writer to X\n"
+  "  --title X\tSet title to X\n"
+  "  --genre X\tSet genre to X\n"
+  "  --album X\tSet album to X\n"
+  "  --compilation\tSet compilation\n"
+  "  --track X\tSet track to X (number/total)\n"
+  "  --disc X\tSet disc to X (number/total)\n"
+  "  --year X\tSet year to X\n"
+  "  --cover-art X\tRead cover art from file X\n"
+  "  --comment X\tSet comment to X\n"
+#else
+  "  MP4 support unavailable.\n"
+#endif
+  "\n"
+  "Documentation:\n"
+  "  --license\tShow the FAAC license.\n"
+  "  --help\tShow this abbreviated help.\n"
+  "  --long-help\tShow complete help.\n"
+  "\n"
+  "  More tips can be found in the audiocoding.com Knowledge Base at\n"
+  "  <http://www.audiocoding.com/wiki/>\n"
+  "\n";
+
+const char *long_help =
+  "Usage: %s [options] infiles ...\n"
+  "\n"
+  "Quality-related options:\n"
+  "  -q <quality>\tSet default variable bitrate (VBR) quantizer quality in percent.\n"
+  "\t\t(default: 100, averages at approx. 120 kbps VBR for a normal\n"
+  "\t\tstereo input file with 16 bit and 44.1 kHz sample rate; max.\n"
+  "\t\tvalue 500, min. 10).\n"
+  "  -b <bitrate>\tSet average bitrate (ABR) to approximately <bitrate> kbps.\n"
+"\t\t(max. value 152 kbps/stereo with a 16 kHz cutoff, can be raised\n"
+  "\t\twith a higher -c setting).\n"
+  "  -c <freq>\tSet the bandwidth in Hz (default: automatic, i.e. adapts\n"
+  "\t\tmaximum value to input sample rate).\n"
+  "\n"
+  "Input/output options:\n"
+  "  -\t\t<stdin/stdout>: If you simply use a hyphen/minus sign instead\n"
+  "\t\tof an input file name, FAAC can encode directly from stdin,\n"
+  "\t\tthus enabling piping from other applications and utilities. The\n"
+  "\t\tsame works for stdout as well, so FAAC can pipe its output to\n"
+  "\t\tother apps such as a server.\n"
+  "  -o X\t\tSet output file to X (only for one input file)\n"
+  "\t\tonly for one input file; you can use *.aac, *.mp4, *.m4a or\n"
+  "\t\t*.m4b as file extension, and the file format will be set\n"
+  "\t\tautomatically to ADTS or MP4).\n"
+  "  -P\t\tRaw PCM input mode (default: off, i.e. expecting a WAV header;\n"
+  "\t\tnecessary for input files or bitstreams without a header; using\n"
+  "\t\tonly -P assumes the default values for -R, -B and -C in the\n"
+  "\t\tinput file).\n"
+  "  -R\t\tRaw PCM input sample rate in Hz (default: 44100 Hz, max. 96 kHz)\n"
+  "  -B\t\tRaw PCM input sample size (default: 16, also possible 8, 24, 32\n"
+  "\t\tbit fixed or float input).\n"
+  "  -C\t\tRaw PCM input channels (default: 2, max. 33 + 1 LFE).\n"
+  "  -X\t\tRaw PCM swap input bytes (default: bigendian).\n"
+  "  -I <C[,LFE]>\tInput multichannel configuration (default: 3,4 which means\n"
+  "\t\tCenter is third and LFE is fourth like in 5.1 WAV, so you only\n"
+  "\t\thave to specify a different position of these two mono channels\n"
+  "\t\tin your multichannel input files if they haven't been reordered\n"
+  "\t\talready).\n"
+  "\n"
+  "MP4 specific options:\n"
+#ifdef HAVE_LIBMP4V2
+  "  -w\t\tWrap AAC data in MP4 container. (default for *.mp4, *.m4a and\n"
+  "\t\t*.m4b)\n"
+  "  -s\t\tOptimize MP4 container layout after encoding.\n"
+  "  --artist X\tSet artist to X\n"
+  "  --writer X\tSet writer/composer to X\n"
+  "  --title X\tSet title/track name to X\n"
+  "  --genre X\tSet genre to X\n"
+  "  --album X\tSet album/performer to X\n"
+  "  --compilation\tMark as compilation\n"
+  "  --track X\tSet track to X (number/total)\n"
+  "  --disc X\tSet disc to X (number/total)\n"
+  "  --year X\tSet year to X\n"
+  "  --cover-art X\tRead cover art from file X\n"
+  "\t\tSupported image formats are GIF, JPEG, and PNG.\n"
+  "  --comment X\tSet comment to X\n"
+#else
+  "  MP4 support unavailable.\n"
+#endif
+  "\n"
+  "Expert options, only for testing purposes:\n"
+#if !DEFAULT_TNS
+  "  --tns  \tEnable coding of TNS, temporal noise shaping.\n"
+#else
+  "  --no-tns\tDisable coding of TNS, temporal noise shaping.\n"
+#endif
+  "  --no-midside\tDon\'t use mid/side coding.\n"
+  "  --mpeg-vers X\tForce AAC MPEG version, X can be 2 or 4\n"
+  "  --obj-type X\tAAC object type. (LC (Low Complexity, default), Main or LTP\n"
+  "\t\t(Long Term Prediction)\n"
+  "  --shortctl X\tEnforce block type (0 = both (default); 1 = no short; 2 = no\n"
+  "\t\tlong).\n"
+  "  -r\t\tGenerate raw AAC bitstream (i.e. without any headers).\n"
+  "\t\tNot advised!!!, RAW AAC files are practically useless!!!\n"
+  "\n"
+  "Documentation:\n"
+  "  --license\tShow the FAAC license.\n"
+  "  --help\tShow this abbreviated help.\n"
+  "  --long-help\tShow complete help.\n"
+  "\n"
+  "  More tips can be found in the audiocoding.com Knowledge Base at\n"
+  "  <http://www.audiocoding.com/wiki/>\n"
+  "\n";
+
+char *license =
+  "\nPlease note that the use of this software may require the payment of patent\n"
+  "royalties. You need to consider this issue before you start building derivative\n"
+  "works. We are not warranting or indemnifying you in any way for patent\n"
+  "royalities! YOU ARE SOLELY RESPONSIBLE FOR YOUR OWN ACTIONS!\n"
+  "\n"
+  "FAAC is based on the ISO MPEG-4 reference code. For this code base the\n"
+  "following license applies:\n"
+  "\n"
+  "This software module was originally developed by\n"
+  "\n"
+  "FirstName LastName (CompanyName)\n"
+  "\n"
+  "and edited by\n"
+  "\n"
+  "FirstName LastName (CompanyName)\n"
+  "FirstName LastName (CompanyName)\n"
+  "\n"
+  "in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard\n"
+  "ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an\n"
+  "implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools\n"
+  "as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives\n"
+  "users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this\n"
+  "software module or modifications thereof for use in hardware or\n"
+  "software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio\n"
+  "standards. Those intending to use this software module in hardware or\n"
+  "software products are advised that this use may infringe existing\n"
+  "patents. The original developer of this software module and his/her\n"
+  "company, the subsequent editors and their companies, and ISO/IEC have\n"
+  "no liability for use of this software module or modifications thereof\n"
+  "in an implementation. Copyright is not released for non MPEG-2\n"
+  "NBC/MPEG-4 Audio conforming products. The original developer retains\n"
+  "full right to use the code for his/her own purpose, assign or donate\n"
+  "the code to a third party and to inhibit third party from using the\n"
+  "code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This\n"
+  "copyright notice must be included in all copies or derivative works.\n"
+  "\n"
+  "Copyright (c) 1997.\n"
+  "\n"
+  "For the changes made for the FAAC project the GNU Lesser General Public\n"
+  "License (LGPL), version 2 1991 applies:\n"
+  "\n"
+  "FAAC - Freeware Advanced Audio Coder\n"
+  "Copyright (C) 2001-2004 The individual contributors\n"
+  "\n"
+  "This library is free software; you can redistribute it and/or\n"
+  "modify it under the terms of the GNU Lesser General Public\n"
+  "License as published by the Free Software Foundation; either\n"
+  "version 2.1 of the License, or (at your option) any later version.\n"
+  "\n"
+  "This library is distributed in the hope that it will be useful,\n"
+  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n"
+  "Lesser General Public License for more details.\n"
+  "\n"
+  "You should have received a copy of the GNU Lesser General Public\n"
+  "License along with this library; if not, write to the Free Software\n"
+  "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n"
+  "\n";
+
+#ifndef min
+#define min(a,b) ( (a) < (b) ? (a) : (b) )
+#endif
+
+/* globals */
+char* progName;
+#ifndef _WIN32
+volatile int running = 1;
+#endif
+
+enum stream_format {
+  RAW_STREAM = 0,
+  ADTS_STREAM = 1,
+};
+
+enum container_format {
+  NO_CONTAINER,
+#ifdef HAVE_LIBMP4V2
+  MP4_CONTAINER,
+#endif
+};
+
+enum flags {
+  SHORTCTL_FLAG = 300,
+  TNS_FLAG = 301,
+  NO_TNS_FLAG = 302,
+  MPEGVERS_FLAG = 303,
+  OBJTYPE_FLAG = 304,
+  NO_MIDSIDE_FLAG = 306,
+
+#ifdef HAVE_LIBMP4V2
+  ARTIST_FLAG = 320,
+  TITLE_FLAG = 321,
+  GENRE_FLAG = 322,
+  ALBUM_FLAG = 323,
+  COMPILATION_FLAG = 324,
+  TRACK_FLAG = 325,
+  DISC_FLAG = 326,
+  YEAR_FLAG = 327,
+  COVER_ART_FLAG = 328,
+  COMMENT_FLAG = 329,
+  WRITER_FLAG = 330,
+#endif
+};
+
+#ifndef _WIN32
+void signal_handler(int signal) {
+    running = 0;
+}
+#endif
+
+#ifdef HAVE_LIBMP4V2
+static int check_image_header(const char *buf) {
+  if (!strncmp(buf, "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A", 8))
+    return 1; /* PNG */
+  else if (!strncmp(buf, "\xFF\xD8\xFF\xE0", 4) ||
+       !strncmp(buf, "\xFF\xD8\xFF\xE1", 4))
+    return 1; /* JPEG */
+  else if (!strncmp(buf, "GIF87a", 6) || !strncmp(buf, "GIF89a", 6))
+    return 1; /* GIF */
+  else
+    return 0;
+}
+#endif
+
+static int *mkChanMap(int channels, int center, int lf)
+{
+    int *map;
+    int inpos;
+    int outpos;
+
+    if (!center && !lf)
+        return NULL;
+
+    if (channels < 3)
+        return NULL;
+
+    if (lf > 0)
+        lf--;
+    else
+        lf = channels - 1; // default AAC position
+
+    if (center > 0)
+        center--;
+    else
+        center = 0; // default AAC position
+
+    map = malloc(channels * sizeof(map[0]));
+    memset(map, 0, channels * sizeof(map[0]));
+
+    outpos = 0;
+    if ((center >= 0) && (center < channels))
+        map[outpos++] = center;
+
+    inpos = 0;
+    for (; outpos < (channels - 1); inpos++)
+    {
+        if (inpos == center)
+            continue;
+        if (inpos == lf)
+            continue;
+
+        map[outpos++] = inpos;
+    }
+    if (outpos < channels)
+    {
+        if ((lf >= 0) && (lf < channels))
+            map[outpos] = lf;
+        else
+            map[outpos] = inpos;
+    }
+
+    return map;
+}
+
+int main(int argc, char *argv[])
+{
+    int frames, currentFrame;
+    faacEncHandle hEncoder;
+    pcmfile_t *infile = NULL;
+
+    unsigned long samplesInput, maxBytesOutput, totalBytesWritten=0;
+
+    faacEncConfigurationPtr myFormat;
+    unsigned int mpegVersion = MPEG2;
+    unsigned int objectType = LOW;
+    unsigned int useMidSide = 1;
+    static unsigned int useTns = DEFAULT_TNS;
+    enum container_format container = NO_CONTAINER;
+    int optimizeFlag = 0;
+    enum stream_format stream = ADTS_STREAM;
+    int cutOff = -1;
+    int bitRate = 0;
+    unsigned long quantqual = 0;
+    int chanC = 3;
+    int chanLF = 4;
+
+    char *audioFileName = NULL;
+    char *aacFileName = NULL;
+    char *aacFileExt = NULL;
+    int aacFileNameGiven = 0;
+
+    float *pcmbuf;
+    int *chanmap = NULL;
+
+    unsigned char *bitbuf;
+    int samplesRead = 0;
+    const char *dieMessage = NULL;
+
+    int rawChans = 0; // disabled by default
+    int rawBits = 16;
+    int rawRate = 44100;
+    int rawEndian = 1;
+
+    int shortctl = SHORTCTL_NORMAL;
+
+    FILE *outfile = NULL;
+
+#ifdef HAVE_LIBMP4V2
+    MP4FileHandle MP4hFile = MP4_INVALID_FILE_HANDLE;
+    MP4TrackId MP4track = 0;
+    unsigned int ntracks = 0, trackno = 0;
+    unsigned int ndiscs = 0, discno = 0;
+    u_int8_t compilation = 0;
+    const char *artist = NULL, *title = NULL, *album = NULL, *year = NULL,
+      *genre = NULL, *comment = NULL, *writer = NULL;
+    u_int8_t *art = NULL;
+    u_int64_t artSize = 0;
+    u_int64_t total_samples = 0;
+    u_int64_t encoded_samples = 0;
+    unsigned int delay_samples;
+    unsigned int frameSize;
+#endif
+    char *faac_id_string;
+    char *faac_copyright_string;
+
+#ifndef _WIN32
+    // install signal handler
+    signal(SIGINT, signal_handler);
+    signal(SIGTERM, signal_handler);
+#endif
+
+    // get faac version
+    if (faacEncGetVersion(&faac_id_string, &faac_copyright_string) == FAAC_CFG_VERSION)
+    {
+        fprintf(stderr, "Freeware Advanced Audio Coder\nFAAC %s\n\n", faac_id_string);
+    }
+    else
+    {
+        fprintf(stderr, __FILE__ "(%d): wrong libfaac version\n", __LINE__);
+        return 1;
+    }
+
+    /* begin process command line */
+    progName = argv[0];
+    while (1) {
+        static struct option long_options[] = {
+            { "help", 0, 0, 'h'},
+            { "long-help", 0, 0, 'H'},
+            { "raw", 0, 0, 'r'},
+            { "no-midside", 0, 0, NO_MIDSIDE_FLAG},
+            { "cutoff", 1, 0, 'c'},
+            { "quality", 1, 0, 'q'},
+            { "pcmraw", 0, 0, 'P'},
+            { "pcmsamplerate", 1, 0, 'R'},
+            { "pcmsamplebits", 1, 0, 'B'},
+            { "pcmchannels", 1, 0, 'C'},
+            { "shortctl", 1, 0, SHORTCTL_FLAG},
+            { "tns", 0, 0, TNS_FLAG},
+            { "no-tns", 0, 0, NO_TNS_FLAG},
+            { "mpeg-version", 1, 0, MPEGVERS_FLAG},
+            { "obj-type", 1, 0, OBJTYPE_FLAG},
+            { "license", 0, 0, 'L'},
+#ifdef HAVE_LIBMP4V2
+            { "createmp4", 0, 0, 'w'},
+            { "optimize", 0, 0, 's'},
+            { "artist", 1, 0, ARTIST_FLAG},
+            { "title", 1, 0, TITLE_FLAG},
+            { "album", 1, 0, ALBUM_FLAG},
+            { "track", 1, 0, TRACK_FLAG},
+            { "disc", 1, 0, DISC_FLAG},
+            { "genre", 1, 0, GENRE_FLAG},
+            { "year", 1, 0, YEAR_FLAG},
+            { "cover-art", 1, 0, COVER_ART_FLAG},
+            { "comment", 1, 0, COMMENT_FLAG},
+        { "writer", 1, 0, WRITER_FLAG},
+        { "compilation", 0, 0, COMPILATION_FLAG},
+#endif
+        { "pcmswapbytes", 0, 0, 'X'},
+            { 0, 0, 0, 0}
+        };
+        int c = -1;
+        int option_index = 0;
+
+        c = getopt_long(argc, argv, "Hhb:m:o:rnc:q:PR:B:C:I:X"
+#ifdef HAVE_LIBMP4V2
+                        "ws"
+#endif
+            ,long_options, &option_index);
+
+        if (c == -1)
+            break;
+
+        if (!c)
+        {
+          dieMessage = usage;
+          break;
+        }
+
+        switch (c) {
+    case 'o':
+        {
+            int l = strlen(optarg);
+        aacFileName = malloc(l+1);
+        memcpy(aacFileName, optarg, l);
+        aacFileName[l] = '\0';
+        aacFileNameGiven = 1;
+        }
+        break;
+        case 'r': {
+            stream = RAW_STREAM;
+            break;
+        }
+        case NO_MIDSIDE_FLAG: {
+            useMidSide = 0;
+            break;
+        }
+        case 'c': {
+            unsigned int i;
+            if (sscanf(optarg, "%u", &i) > 0) {
+                cutOff = i;
+            }
+            break;
+        }
+        case 'b': {
+            unsigned int i;
+            if (sscanf(optarg, "%u", &i) > 0)
+            {
+                bitRate = 1000 * i;
+            }
+            break;
+        }
+        case 'q':
+        {
+            unsigned int i;
+            if (sscanf(optarg, "%u", &i) > 0)
+            {
+                if (i > 0 && i < 1000)
+                    quantqual = i;
+            }
+            break;
+        }
+        case 'I':
+            sscanf(optarg, "%d,%d", &chanC, &chanLF);
+            break;
+        case 'P':
+            rawChans = 2; // enable raw input
+            break;
+        case 'R':
+        {
+            unsigned int i;
+            if (sscanf(optarg, "%u", &i) > 0)
+            {
+                rawRate = i;
+                rawChans = (rawChans > 0) ? rawChans : 2;
+            }
+            break;
+        }
+        case 'B':
+        {
+            unsigned int i;
+            if (sscanf(optarg, "%u", &i) > 0)
+            {
+                if (i > 32)
+                    i = 32;
+                if (i < 8)
+                    i = 8;
+                rawBits = i;
+                rawChans = (rawChans > 0) ? rawChans : 2;
+            }
+            break;
+        }
+        case 'C':
+        {
+            unsigned int i;
+            if (sscanf(optarg, "%u", &i) > 0)
+                rawChans = i;
+            break;
+        }
+#ifdef HAVE_LIBMP4V2
+        case 'w':
+        container = MP4_CONTAINER;
+            break;
+        case 's':
+        optimizeFlag = 1;
+            break;
+    case ARTIST_FLAG:
+        artist = optarg;
+        break;
+    case WRITER_FLAG:
+        writer = optarg;
+        break;
+    case TITLE_FLAG:
+        title = optarg;
+        break;
+    case ALBUM_FLAG:
+        album = optarg;
+        break;
+    case TRACK_FLAG:
+        sscanf(optarg, "%d/%d", &trackno, &ntracks);
+        break;
+    case DISC_FLAG:
+        sscanf(optarg, "%d/%d", &discno, &ndiscs);
+        break;
+    case COMPILATION_FLAG:
+        compilation = 0x1;
+        break;
+    case GENRE_FLAG:
+        genre = optarg;
+        break;
+    case YEAR_FLAG:
+        year = optarg;
+        break;
+    case COMMENT_FLAG:
+        comment = optarg;
+        break;
+    case COVER_ART_FLAG: {
+        FILE *artFile = fopen(optarg, "rb");
+
+        if(artFile) {
+            u_int64_t r;
+
+            fseek(artFile, 0, SEEK_END);
+        artSize = ftell(artFile);
+
+        art = malloc(artSize);
+
+            fseek(artFile, 0, SEEK_SET);
+        clearerr(artFile);
+
+        r = fread(art, artSize, 1, artFile);
+
+        if (r != 1) {
+            dieMessage = "Error reading cover art file!\n";
+            free(art);
+            art = NULL;
+        } else if (artSize < 12 || !check_image_header(art)) {
+            /* the above expression checks the image signature */
+            dieMessage = "Unsupported cover image file format!\n";
+            free(art);
+            art = NULL;
+        }
+
+        fclose(artFile);
+        } else {
+            dieMessage = "Error opening cover art file!\n";
+        }
+
+        break;
+    }
+#endif
+        case SHORTCTL_FLAG:
+            shortctl = atoi(optarg);
+            break;
+        case TNS_FLAG:
+            useTns = 1;
+            break;
+        case NO_TNS_FLAG:
+            useTns = 0;
+            break;
+    case MPEGVERS_FLAG:
+            mpegVersion = atoi(optarg);
+            switch(mpegVersion)
+            {
+            case 2:
+                mpegVersion = MPEG2;
+                break;
+            case 4:
+                mpegVersion = MPEG4;
+                break;
+            default:
+            dieMessage = "Unrecognised MPEG version!\n";
+            }
+            break;
+#if 0
+    case OBJTYPE_FLAG:
+        if (!strcasecmp(optarg, "LC"))
+                objectType = LOW;
+        else if (!strcasecmp(optarg, "Main"))
+            objectType = MAIN;
+        else if (!strcasecmp(optarg, "LTP")) {
+            mpegVersion = MPEG4;
+        objectType = LTP;
+        } else
+            dieMessage = "Unrecognised object type!\n";
+        break;
+#endif
+        case 'L':
+        fprintf(stderr, faac_copyright_string);
+        dieMessage = license;
+        break;
+    case 'X':
+      rawEndian = 0;
+      break;
+    case 'H':
+      dieMessage = long_help;
+      break;
+    case 'h':
+          dieMessage = short_help;
+      break;
+    case '?':
+        default:
+      dieMessage = usage;
+          break;
+        }
+    }
+
+    /* check that we have at least one non-option arguments */
+    if (!dieMessage && (argc - optind) > 1 && aacFileNameGiven)
+        dieMessage = "Cannot encode several input files to one output file.\n";
+
+    if (argc - optind < 1 || dieMessage)
+    {
+        fprintf(stderr, dieMessage ? dieMessage : usage,
+           progName, progName, progName, progName);
+        return 1;
+    }
+
+    while (argc - optind > 0) {
+
+    /* get the input file name */
+    audioFileName = argv[optind++];
+
+    /* generate the output file name, if necessary */
+    if (!aacFileNameGiven) {
+        char *t = strrchr(audioFileName, '.');
+    int l = t ? strlen(audioFileName) - strlen(t) : strlen(audioFileName);
+
+#ifdef HAVE_LIBMP4V2
+    aacFileExt = container == MP4_CONTAINER ? ".m4a" : ".aac";
+#else
+    aacFileExt = ".aac";
+#endif
+
+    aacFileName = malloc(l+1+4);
+    memcpy(aacFileName, audioFileName, l);
+    memcpy(aacFileName + l, aacFileExt, 4);
+    aacFileName[l+4] = '\0';
+    } else {
+        aacFileExt = strrchr(aacFileName, '.');
+
+        if (aacFileExt && (!strcmp(".m4a", aacFileExt) || !strcmp(".m4b", aacFileExt) || !strcmp(".mp4", aacFileExt)))
+#ifndef HAVE_LIBMP4V2
+        fprintf(stderr, "WARNING: MP4 support unavailable!\n");
+#else
+        container = MP4_CONTAINER;
+#endif
+    }
+
+    /* open the audio input file */
+    if (rawChans > 0) // use raw input
+    {
+        infile = wav_open_read(audioFileName, 1);
+    if (infile)
+    {
+        infile->bigendian = rawEndian;
+        infile->channels = rawChans;
+        infile->samplebytes = rawBits / 8;
+        infile->samplerate = rawRate;
+        infile->samples /= (infile->channels * infile->samplebytes);
+    }
+    }
+    else // header input
+        infile = wav_open_read(audioFileName, 0);
+
+    if (infile == NULL)
+    {
+        fprintf(stderr, "Couldn't open input file %s\n", audioFileName);
+    return 1;
+    }
+
+
+    /* open the encoder library */
+    hEncoder = faacEncOpen(infile->samplerate, infile->channels,
+        &samplesInput, &maxBytesOutput);
+
+#ifdef HAVE_LIBMP4V2
+    if (container != MP4_CONTAINER && (ntracks || trackno || artist ||
+                       title ||  album || year || art ||
+                       genre || comment || discno || ndiscs ||
+                       writer || compilation))
+    {
+        fprintf(stderr, "Metadata requires MP4 output!\n");
+    return 1;
+    }
+
+    if (container == MP4_CONTAINER)
+    {
+        mpegVersion = MPEG4;
+    stream = RAW_STREAM;
+    }
+
+    frameSize = samplesInput/infile->channels;
+    delay_samples = frameSize; // encoder delay 1024 samples
+#endif
+    pcmbuf = (float *)malloc(samplesInput*sizeof(float));
+    bitbuf = (unsigned char*)malloc(maxBytesOutput*sizeof(unsigned char));
+    chanmap = mkChanMap(infile->channels, chanC, chanLF);
+    if (chanmap)
+    {
+        fprintf(stderr, "Remapping input channels: Center=%d, LFE=%d\n",
+            chanC, chanLF);
+    }
+
+    if (cutOff <= 0)
+    {
+        if (cutOff < 0) // default
+            cutOff = 0;
+        else // disabled
+            cutOff = infile->samplerate / 2;
+    }
+    if (cutOff > (infile->samplerate / 2))
+        cutOff = infile->samplerate / 2;
+
+    /* put the options in the configuration struct */
+    myFormat = faacEncGetCurrentConfiguration(hEncoder);
+    myFormat->aacObjectType = objectType;
+    myFormat->mpegVersion = mpegVersion;
+    myFormat->useTns = useTns;
+    switch (shortctl)
+    {
+    case SHORTCTL_NOSHORT:
+      fprintf(stderr, "disabling short blocks\n");
+      myFormat->shortctl = shortctl;
+      break;
+    case SHORTCTL_NOLONG:
+      fprintf(stderr, "disabling long blocks\n");
+      myFormat->shortctl = shortctl;
+      break;
+    }
+    if (infile->channels >= 6)
+        myFormat->useLfe = 1;
+    myFormat->allowMidside = useMidSide;
+    if (bitRate)
+        myFormat->bitRate = bitRate / infile->channels;
+    myFormat->bandWidth = cutOff;
+    if (quantqual > 0)
+        myFormat->quantqual = quantqual;
+    myFormat->outputFormat = stream;
+    myFormat->inputFormat = FAAC_INPUT_FLOAT;
+    if (!faacEncSetConfiguration(hEncoder, myFormat)) {
+        fprintf(stderr, "Unsupported output format!\n");
+#ifdef HAVE_LIBMP4V2
+#ifdef MP4_CLOSE_DO_NOT_COMPUTE_BITRATE /* r479 fix */
+        if (container == MP4_CONTAINER) MP4Close(MP4hFile, 0);
+#else
+        if (container == MP4_CONTAINER) MP4Close(MP4hFile);
+#endif
+#endif
+        return 1;
+    }
+
+#ifdef HAVE_LIBMP4V2
+    /* initialize MP4 creation */
+    if (container == MP4_CONTAINER) {
+        unsigned char *ASC = 0;
+        unsigned long ASCLength = 0;
+    char *version_string;
+
+#ifdef MP4_DETAILS_ERROR /* r453 fix */
+        MP4hFile = MP4Create(aacFileName, MP4_DETAILS_ERROR, 0);
+#else
+        MP4hFile = MP4Create(aacFileName, 0);
+#endif
+        if (!MP4_IS_VALID_FILE_HANDLE(MP4hFile)) {
+            fprintf(stderr, "Couldn't create output file %s\n", aacFileName);
+            return 1;
+        }
+
+        MP4SetTimeScale(MP4hFile, 90000);
+        MP4track = MP4AddAudioTrack(MP4hFile, infile->samplerate, MP4_INVALID_DURATION, MP4_MPEG4_AUDIO_TYPE);
+        MP4SetAudioProfileLevel(MP4hFile, 0x0F);
+        faacEncGetDecoderSpecificInfo(hEncoder, &ASC, &ASCLength);
+        MP4SetTrackESConfiguration(MP4hFile, MP4track, ASC, ASCLength);
+    free(ASC);
+
+    /* set metadata */
+#if HAVE_DECL_MP4TAGSALLOC
+    const MP4Tags* tags;
+    tags = MP4TagsAlloc();
+    MP4TagsFetch( tags, MP4hFile );
+#endif
+    version_string = malloc(strlen(faac_id_string) + 6);
+    strcpy(version_string, "FAAC ");
+    strcpy(version_string + 5, faac_id_string);
+#if !HAVE_DECL_MP4TAGSALLOC
+    MP4SetMetadataTool(MP4hFile, version_string);
+#else
+    MP4TagsSetEncodingTool(tags, version_string);
+#endif
+    free(version_string);
+
+#if !HAVE_DECL_MP4TAGSALLOC
+    if (artist) MP4SetMetadataArtist(MP4hFile, artist);
+    if (writer) MP4SetMetadataWriter(MP4hFile, writer);
+    if (title) MP4SetMetadataName(MP4hFile, title);
+    if (album) MP4SetMetadataAlbum(MP4hFile, album);
+    if (trackno > 0) MP4SetMetadataTrack(MP4hFile, trackno, ntracks);
+    if (discno > 0) MP4SetMetadataDisk(MP4hFile, discno, ndiscs);
+    if (compilation) MP4SetMetadataCompilation(MP4hFile, compilation);
+    if (year) MP4SetMetadataYear(MP4hFile, year);
+    if (genre) MP4SetMetadataGenre(MP4hFile, genre);
+    if (comment) MP4SetMetadataComment(MP4hFile, comment);
+        if (artSize) {
+        MP4SetMetadataCoverArt(MP4hFile, art, artSize);
+#else
+    if (artist) MP4TagsSetArtist(tags, artist);
+    if (writer) MP4TagsSetComposer(tags, writer);
+    if (title) MP4TagsSetName(tags, title);
+    if (album) MP4TagsSetAlbum(tags, album);
+    if (trackno > 0) {
+        MP4TagTrack tt;
+        tt.index = trackno;
+        tt.total = ntracks;
+        MP4TagsSetTrack(tags, &tt);
+    }
+    if (discno > 0) {
+        MP4TagDisk td;
+        td.index = discno;
+        td.total = ndiscs;
+        MP4TagsSetDisk(tags, &td);
+    }
+    if (compilation) MP4TagsSetCompilation(tags, compilation);
+    if (year) MP4TagsSetReleaseDate(tags, year);
+    if (genre) MP4TagsSetGenre(tags, genre);
+    if (comment) MP4TagsSetComments(tags, comment);
+    if (artSize) {
+        MP4TagArtwork mp4art;
+        mp4art.data = art;
+        mp4art.size = artSize;
+        mp4art.type = MP4_ART_UNDEFINED; // delegate typing to libmp4v2
+        MP4TagsAddArtwork( tags, &mp4art );
+#endif
+        free(art);
+    }
+#if HAVE_DECL_MP4TAGSALLOC
+    MP4TagsStore( tags, MP4hFile );
+    MP4TagsFree( tags );
+#endif
+    }
+    else
+    {
+#endif
+        /* open the aac output file */
+        if (!strcmp(aacFileName, "-"))
+        {
+            outfile = stdout;
+        }
+        else
+        {
+            outfile = fopen(aacFileName, "wb");
+        }
+        if (!outfile)
+        {
+            fprintf(stderr, "Couldn't create output file %s\n", aacFileName);
+            return 1;
+        }
+#ifdef HAVE_LIBMP4V2
+    }
+#endif
+
+    cutOff = myFormat->bandWidth;
+    quantqual = myFormat->quantqual;
+    bitRate = myFormat->bitRate;
+    if (bitRate)
+      fprintf(stderr, "Average bitrate: %d kbps\n",
+          (bitRate + 500)/1000*infile->channels);
+    fprintf(stderr, "Quantization quality: %ld\n", quantqual);
+    fprintf(stderr, "Bandwidth: %d Hz\n", cutOff);
+    fprintf(stderr, "Object type: ");
+    switch(objectType)
+    {
+    case LOW:
+        fprintf(stderr, "Low Complexity");
+        break;
+    case MAIN:
+        fprintf(stderr, "Main");
+        break;
+    case LTP:
+        fprintf(stderr, "LTP");
+        break;
+    }
+    fprintf(stderr, "(MPEG-%d)", (mpegVersion == MPEG4) ? 4 : 2);
+    if (myFormat->useTns)
+        fprintf(stderr, " + TNS");
+    if (myFormat->allowMidside)
+        fprintf(stderr, " + M/S");
+    fprintf(stderr, "\n");
+
+    fprintf(stderr, "Container format: ");
+    switch(container)
+    {
+    case NO_CONTAINER:
+      switch(stream)
+    {
+    case RAW_STREAM:
+      fprintf(stderr, "Headerless AAC (RAW)\n");
+      break;
+    case ADTS_STREAM:
+      fprintf(stderr, "Transport Stream (ADTS)\n");
+      break;
+    }
+        break;
+#ifdef HAVE_LIBMP4V2
+    case MP4_CONTAINER:
+        fprintf(stderr, "MPEG-4 File Format (MP4)\n");
+        break;
+#endif
+    }
+
+    if (outfile
+#ifdef HAVE_LIBMP4V2
+        || MP4hFile != MP4_INVALID_FILE_HANDLE
+#endif
+       )
+    {
+        int showcnt = 0;
+#ifdef _WIN32
+        long begin = GetTickCount();
+#endif
+        if (infile->samples)
+            frames = ((infile->samples + 1023) / 1024) + 1;
+        else
+            frames = 0;
+        currentFrame = 0;
+
+        fprintf(stderr, "Encoding %s to %s\n", audioFileName, aacFileName);
+        if (frames != 0)
+            fprintf(stderr, "   frame          | bitrate | elapsed/estim | "
+            "play/CPU | ETA\n");
+        else
+            fprintf(stderr, " frame | elapsed | play/CPU\n");
+
+        /* encoding loop */
+#ifdef _WIN32
+    for (;;)
+#else
+        while (running)
+#endif
+        {
+            int bytesWritten;
+
+            samplesRead = wav_read_float32(infile, pcmbuf, samplesInput, chanmap);
+
+#ifdef HAVE_LIBMP4V2
+            total_samples += samplesRead / infile->channels;
+#endif
+
+            /* call the actual encoding routine */
+            bytesWritten = faacEncEncode(hEncoder,
+                (int32_t *)pcmbuf,
+                samplesRead,
+                bitbuf,
+                maxBytesOutput);
+
+            if (bytesWritten)
+            {
+                currentFrame++;
+                showcnt--;
+        totalBytesWritten += bytesWritten;
+            }
+
+            if ((showcnt <= 0) || !bytesWritten)
+            {
+                double timeused;
+#ifdef __unix__
+                struct rusage usage;
+#endif
+#ifdef _WIN32
+                char percent[MAX_PATH + 20];
+                timeused = (GetTickCount() - begin) * 1e-3;
+#else
+#ifdef __unix__
+                if (getrusage(RUSAGE_SELF, &usage) == 0) {
+                    timeused = (double)usage.ru_utime.tv_sec +
+                        (double)usage.ru_utime.tv_usec * 1e-6;
+                }
+                else
+                    timeused = 0;
+#else
+                timeused = (double)clock() * (1.0 / CLOCKS_PER_SEC);
+#endif
+#endif
+                if (currentFrame && (timeused > 0.1))
+                {
+                    showcnt += 50;
+
+                    if (frames != 0)
+                        fprintf(stderr,
+                            "\r%5d/%-5d (%3d%%)|  %5.1f  | %6.1f/%-6.1f | %7.2fx | %.1f ",
+                            currentFrame, frames, currentFrame*100/frames,
+                ((double)totalBytesWritten * 8.0 / 1000.0) /
+                ((double)infile->samples / infile->samplerate * currentFrame / frames),
+                            timeused,
+                            timeused * frames / currentFrame,
+                            (1024.0 * currentFrame / infile->samplerate) / timeused,
+                            timeused  * (frames - currentFrame) / currentFrame);
+                    else
+                        fprintf(stderr,
+                            "\r %5d |  %6.1f | %7.2fx ",
+                            currentFrame,
+                            timeused,
+                            (1024.0 * currentFrame / infile->samplerate) / timeused);
+
+                    fflush(stderr);
+#ifdef _WIN32
+                    if (frames != 0)
+                    {
+                        sprintf(percent, "%.2f%% encoding %s",
+                            100.0 * currentFrame / frames, audioFileName);
+                        SetConsoleTitle(percent);
+                    }
+#endif
+                }
+            }
+
+            /* all done, bail out */
+            if (!samplesRead && !bytesWritten)
+                break ;
+
+            if (bytesWritten < 0)
+            {
+                fprintf(stderr, "faacEncEncode() failed\n");
+                break ;
+            }
+
+            if (bytesWritten > 0)
+            {
+#ifdef HAVE_LIBMP4V2
+                u_int64_t samples_left = total_samples - encoded_samples + delay_samples;
+                MP4Duration dur = samples_left > frameSize ? frameSize : samples_left;
+                MP4Duration ofs = encoded_samples > 0 ? 0 : delay_samples;
+
+                if (container == MP4_CONTAINER)
+                {
+                    /* write bitstream to mp4 file */
+                    MP4WriteSample(MP4hFile, MP4track, bitbuf, bytesWritten, dur, ofs, 1);
+                }
+                else
+                {
+#endif
+                    /* write bitstream to aac file */
+                    fwrite(bitbuf, 1, bytesWritten, outfile);
+#ifdef HAVE_LIBMP4V2
+                }
+
+                encoded_samples += dur;
+#endif
+            }
+        }
+
+#ifdef HAVE_LIBMP4V2
+        /* clean up */
+        if (container == MP4_CONTAINER)
+        {
+#ifdef MP4_CLOSE_DO_NOT_COMPUTE_BITRATE /* r479 fix */
+            MP4Close(MP4hFile, 0);
+#else
+            MP4Close(MP4hFile);
+#endif
+            if (optimizeFlag == 1)
+            {
+                fprintf(stderr, "\n\nMP4 format optimization... ");
+#ifdef MP4_DETAILS_ERROR /* r453 fix */
+                MP4Optimize(aacFileName, NULL, 0);
+#else
+                MP4Optimize(aacFileName, NULL);
+#endif
+                fprintf(stderr, "Done!");
+            }
+        } else
+#endif
+            fclose(outfile);
+
+        fprintf(stderr, "\n\n");
+    }
+
+    faacEncClose(hEncoder);
+
+    wav_close(infile);
+
+    if (pcmbuf) free(pcmbuf);
+    if (bitbuf) free(bitbuf);
+    if (aacFileNameGiven) free(aacFileName);
+
+    }
+
+    return 0;
+}
+
+/*
+$Log: main.c,v $
+Revision 1.82  2009/01/24 01:10:20  menno
+Made JPEG detection less restrictive
+
+Revision 1.81  2009/01/24 00:15:12  menno
+Added -s option for output of optimized mp4 layout
+
+Revision 1.80  2007/03/19 19:57:40  menno
+Made faacgui buildable again
+Made stdout as output possible (use - as output filename)
+Disabled MAIN and LTP encoding
+Increase version number
+
+Revision 1.79  2006/09/25 19:53:36  menno
+Fixed track and disk number reading from command line
+
+Revision 1.78  2004/12/08 11:07:17  menno
+Make long help work again
+
+Revision 1.77  2004/08/19 15:33:30  menno
+typo
+it's not bad to have this option, but people should be warned that they can get severe playback problems with RAW AAC files (anything other then 44100 will not be decoded properly unless you know that it has that samplerate). Seeking is also not possible on these files.
+
+Revision 1.76  2004/08/19 13:18:44  menno
+Removed stupid comment in help of FAAC. RAW AAC files are USELESS, it seems that already some people encoded their collection using the -r option.
+
+Revision 1.75  2004/08/06 19:33:19  danchr
+TNS is no longer enabled by default (reported by guruboolez)
+documentation fixes in frontend
+default to mp4 for *.m4b as well
+
+Revision 1.74  2004/08/03 00:08:51  danchr
+fix --shortctl documentation
+
+Revision 1.73  2004/08/02 20:53:23  danchr
+*BSD portability fix
+
+Revision 1.72  2004/08/02 20:41:59  danchr
+NetBSD portability fix + fixing metadata bugs w/ sscanf()
+
+Revision 1.71  2004/07/28 08:18:21  danchr
+Darwin portability fixes, should help on Linux too
+
+Revision 1.70  2004/05/03 11:39:05  danchr
+fix documentation bugs (per Hans-Jrgen's suggestions)
+enable (preliminary) multiple output file support
+
+Revision 1.69  2004/04/22 14:07:14  danchr
+set copyright notice to my full name
+
+Revision 1.68  2004/04/16 14:51:10  danchr
+don't use stderr on Windows
+
+Revision 1.67  2004/04/16 09:49:10  danchr
+change -a <kbps/channel> to -b <kbps>
+Darwin portability fixes
+Make LTP imply MPEG-4 AAC
+silence a few warnings
+
+Revision 1.66  2004/04/13 13:47:05  danchr
+compilation and composer patch by Jordan Breeding
+undocumented single-letter switches removed
+numerous bug-fixes
+
+Revision 1.65  2004/04/03 17:47:40  danchr
+fix typo + add GIF support
+
+Revision 1.64  2004/04/03 15:54:48  danchr
+make TNS default
+
+Revision 1.63  2004/04/03 15:50:05  danchr
+non-backwards compatible revamp of the FAAC command line interface
+cover art metadata support based on patch by Jordan Breeding (jordan breeding (a) mac com)
+
+Revision 1.62  2004/03/29 14:02:04  danchr
+MP4 bug fixes by Jordan Breeding (jordan breeding (a) mac com)
+Document long options for metadata - they are much more intuitive.
+
+Revision 1.61  2004/03/27 13:44:24  danchr
+minor compile-time bugfix for Win32
+
+Revision 1.60  2004/03/24 15:44:08  danchr
+fixing WIN32 -> _WIN32
+
+Revision 1.59  2004/03/24 11:09:06  danchr
+prettify the way stream format is handled - this just *might* fix a bug
+
+Revision 1.58  2004/03/24 11:00:40  danchr
+silence a few warnings and fix a few mem. leaks
+make it possible to disable stripping (needed for profiling and debugging)
+
+Revision 1.57  2004/03/17 13:32:13  danchr
+- New signal handler. Disabled on Windows, although it *should* work.
+- Separated handling of stream format and output format.
+- Bitrate + file format displayed on stderr.
+- knik and myself added to the copyright header.
+
+Revision 1.56  2004/03/15 20:15:48  knik
+improved MP4 support by Dan Christiansen
+
+Revision 1.55  2004/03/03 15:54:50  knik
+libmp4v2 autoconf detection and mp4 metadata support by Dan Christiansen
+
+Revision 1.54  2004/02/14 10:31:23  knik
+Print help and exit when unknown option is specified.
+
+Revision 1.53  2003/12/20 04:32:48  stux
+i've added sms00's OSX patch to faac
+
+Revision 1.52  2003/12/14 12:25:44  ca5e
+Gapless MP4 handling method changed again...
+
+Revision 1.51  2003/12/13 21:58:35  ca5e
+Improved gapless encoding
+
+Revision 1.50  2003/11/24 18:11:14  knik
+using new version info interface
+
+Revision 1.49  2003/11/13 18:30:19  knik
+raw input bugfix
+
+Revision 1.48  2003/10/17 17:11:18  knik
+fixed raw input
+
+Revision 1.47  2003/10/12 14:30:29  knik
+more accurate average bitrate control
+
+Revision 1.46  2003/09/24 16:30:34  knik
+Added option to enforce block type.
+
+Revision 1.45  2003/09/08 16:28:21  knik
+conditional libmp4v2 compilation
+
+Revision 1.44  2003/09/07 17:44:36  ca5e
+length calculations/silence padding changed to match current libfaac behavior
+changed tabs to spaces, fixes to indentation
+
+Revision 1.43  2003/08/17 19:38:15  menno
+fixes to MP4 files by Case
+
+Revision 1.41  2003/08/15 11:43:14  knik
+Option to add a number of silent frames at the end of output.
+Small TNS option fix.
+
+Revision 1.40  2003/08/07 11:28:06  knik
+fixed win32 crash with long filenames
+
+Revision 1.39  2003/07/21 16:33:49  knik
+Fixed LFE channel mapping.
+
+Revision 1.38  2003/07/13 08:34:43  knik
+Fixed -o, -m and -I option.
+Print object type setting.
+
+Revision 1.37  2003/07/10 19:19:32  knik
+Input channel remapping and 24-bit support.
+
+Revision 1.36  2003/06/26 19:40:53  knik
+TNS disabled by default.
+Copyright info moved to library.
+Print help to standard output.
+
+Revision 1.35  2003/06/21 08:59:31  knik
+raw input support moved to input.c
+
+Revision 1.34  2003/05/10 09:40:35  knik
+added approximate ABR option
+
+Revision 1.33  2003/04/13 08:39:28  knik
+removed psymodel setting
+
+Revision 1.32  2003/03/27 17:11:06  knik
+updated library interface
+-b bitrate option replaced with -q quality option
+TNS enabled by default
+
+Revision 1.31  2002/12/23 19:02:43  knik
+added some headers
+
+Revision 1.30  2002/12/15 15:16:55  menno
+Some portability changes
+
+Revision 1.29  2002/11/23 17:34:59  knik
+replaced libsndfile with input.c
+improved bandwidth/bitrate calculation formula
+
+Revision 1.28  2002/08/30 16:20:45  knik
+misplaced #endif
+
+Revision 1.27  2002/08/19 16:33:54  knik
+automatic bitrate setting
+more advanced status line
+
+*/
diff --git a/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/file.list b/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/file.list
new file mode 100644
index 000000000..569f481e3
--- /dev/null
+++ b/sources/packages/m/audiocoding/faac/create-1.28-mp4v2-patch/file.list
@@ -0,0 +1,3 @@
+faac-1.28/configure.in
+faac-1.28/frontend/Makefile.am
+faac-1.28/frontend/main.c
diff --git a/sources/packages/m/audiocoding/faac/create-1.28-mpeg4ip-patch/create.patch.sh b/sources/packages/m/audiocoding/faac/create-1.28-mpeg4ip-patch/create.patch.sh
new file mode 100755
index 000000000..0c70c3e12
--- /dev/null
+++ b/sources/packages/m/audiocoding/faac/create-1.28-mpeg4ip-patch/create.patch.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=1.28
+
+tar --files-from=file.list -xzvf ../faac-$VERSION.tar.gz
+mv faac-$VERSION faac-$VERSION-orig
+
+cp -rf ./faac-$VERSION-new ./faac-$VERSION
+
+diff -b --unified -Nr  faac-$VERSION-orig  faac-$VERSION > faac-$VERSION-mpeg4ip.patch
+
+mv faac-$VERSION-mpeg4ip.patch ../patches
+
+rm -rf ./faac-$VERSION
+rm -rf ./faac-$VERSION-orig
diff --git a/sources/packages/m/audiocoding/faac/create-1.28-mpeg4ip-patch/faac-1.28-new/common/mp4v2/mpeg4ip.h b/sources/packages/m/audiocoding/faac/create-1.28-mpeg4ip-patch/faac-1.28-new/common/mp4v2/mpeg4ip.h
new file mode 100644
index 000000000..c1292c49f
--- /dev/null
+++ b/sources/packages/m/audiocoding/faac/create-1.28-mpeg4ip-patch/faac-1.28-new/common/mp4v2/mpeg4ip.h
@@ -0,0 +1,317 @@
+/*
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ * 
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ * 
+ * The Original Code is MPEG4IP.
+ * 
+ * The Initial Developer of the Original Code is Cisco Systems Inc.
+ * Portions created by Cisco Systems Inc. are
+ * Copyright (C) Cisco Systems Inc. 2000-2005.  All Rights Reserved.
+ * 
+ * Contributor(s): 
+ *		Dave Mackie		dmackie@cisco.com
+ *              Bill May                wmay@cisco.com
+ */
+
+#ifndef __MPEG4IP_INCLUDED__
+#define __MPEG4IP_INCLUDED__
+
+/* project wide applicable stuff here */
+
+
+#ifndef _WIN32
+#ifdef PACKAGE_BUGREPORT
+#define TEMP_PACKAGE_BUGREPORT PACKAGE_BUGREPORT
+#define TEMP_PACKAGE_NAME PACKAGE_NAME
+#define TEMP_PACKAGE_STRING PACKAGE_STRING
+#define TEMP_PACKAGE_TARNAME PACKAGE_TARNAME
+#define TEMP_PACKAGE_VERSION PACKAGE_VERSION
+#undef PACKAGE_BUGREPORT
+#undef PACKAGE_NAME
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+#undef PACKAGE_VERSION
+#include <mpeg4ip_config.h>
+#else
+#include <mpeg4ip_config.h>
+#endif
+#endif
+
+// the mpeg4ip_package and mpeg4ip_version are always in this
+// file 
+#include "mpeg4ip_version.h"
+
+#ifdef _WIN32
+#include "mpeg4ip_win32.h"
+#include "mpeg4ip_version.h"
+#else /* UNIX */
+/*****************************************************************************
+ *   UNIX LIKE DEFINES BELOW THIS POINT
+ *****************************************************************************/
+#ifdef sun
+#include <sys/feature_tests.h>
+#endif
+
+#ifndef _FILE_OFFSET_BITS
+#define _FILE_OFFSET_BITS 64
+#else
+#ifndef sun
+#if _FILE_OFFSET_BITS < 64
+ #error File offset bits is already set to non-64 value
+#endif
+#endif
+#endif
+
+#ifndef _LARGEFILE_SOURCE
+#define _LARGEFILE_SOURCE
+#endif
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#if !defined(HAVE_INTTYPES_H) && !defined(HAVE_STDINT_H)
+#error "Don't have stdint.h or inttypes.h - no way to get uint8_t"
+#endif
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <syslog.h>
+#include <string.h>
+#include <ctype.h>
+#include <netdb.h>
+#include <sys/stat.h>
+#ifdef TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#include <time.h>
+#else
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+#endif
+#include <sys/param.h>
+
+#define OPEN_RDWR O_RDWR
+#define OPEN_CREAT O_CREAT 
+#define OPEN_RDONLY O_RDONLY
+
+#define closesocket close
+#define IOSBINARY ios::bin
+
+#if SIZEOF_LONG == 8
+#define MAX_UINT64 -1LU
+#define D64F "ld"
+#define U64F  "lu"
+#define X64F "lx"
+
+#define TO_D64(a) (a##L)
+#define TO_U64(a) (a##LU)
+#else
+#define MAX_UINT64 -1LLU
+#define D64F "lld"
+#define U64F  "llu"
+#define X64F "llx"
+
+#define TO_D64(a) (a##LL)
+#define TO_U64(a) (a##LLU)
+#endif
+
+#ifdef HAVE_FPOS_T___POS
+#define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)((fpos).__pos)
+#define VAR_TO_FPOS(fpos, var) (fpos).__pos = (var)
+#else
+#define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)(fpos)
+#define VAR_TO_FPOS(fpos, var) (fpos) = (var)
+#endif
+
+#define FOPEN_READ_BINARY "r"
+#define FOPEN_WRITE_BINARY "w"
+#define UINT64_TO_DOUBLE(a) ((double)(a))
+#endif /* define unix */
+
+/*****************************************************************************
+ *             Generic type includes used in the whole package               *
+ *****************************************************************************/
+#define D64  "%"D64F
+#define U64  "%"U64F
+#define X64 "%"X64F
+
+#define M_LLU TO_U64(1000)
+#define M_64 TO_U64(1000)
+#define LLU  U64
+
+#include <stdarg.h>
+typedef void (*error_msg_func_t)(int loglevel,
+				 const char *lib,
+				 const char *fmt,
+				 va_list ap);
+typedef void (*lib_message_func_t)(int loglevel,
+				   const char *lib,
+				   const char *fmt,
+				   ...);
+#ifndef HAVE_IN_PORT_T
+typedef uint16_t in_port_t;
+#endif
+
+#ifndef HAVE_SOCKLEN_T
+typedef unsigned int socklen_t;
+#endif
+
+#ifdef sun
+#include <limits.h>
+#define u_int8_t uint8_t
+#define u_int16_t uint16_t
+#define u_int32_t uint32_t
+#define u_int64_t uint64_t
+#define __STRING(expr) #expr
+#endif
+
+#ifndef HAVE_STRSEP
+#ifdef __cplusplus
+extern "C" {
+#endif
+char *strsep(char **strp, const char *delim); 
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+#ifndef INADDR_NONE
+#define INADDR_NONE (-1)
+#endif
+
+#define MALLOC_STRUCTURE(a) ((a *)malloc(sizeof(a)))
+
+#define CHECK_AND_FREE(a) if ((a) != NULL) { free((void *)(a)); (a) = NULL;}
+
+#define NUM_ELEMENTS_IN_ARRAY(name) ((sizeof((name))) / (sizeof(*(name))))
+
+#define ADV_SPACE(a) {while (isspace(*(a)) && (*(a) != '\0'))(a)++;}
+
+#ifndef HAVE_GTK
+typedef char gchar;
+typedef unsigned char guchar;
+
+typedef int gint;
+typedef unsigned int guint;
+
+typedef long glong;
+typedef unsigned long gulong;
+
+typedef double gdouble;
+
+typedef int gboolean;
+
+typedef int16_t gint16;
+typedef uint16_t guint16;
+
+typedef int32_t gint32;
+typedef uint32_t guint32;
+
+typedef int64_t gint64;
+typedef uint64_t guint64;
+
+typedef uint8_t  guint8;
+typedef int8_t gint8;
+
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef __cplusplus
+
+#ifndef bool
+ #if SIZEOF_BOOL == 8
+  typedef uint64_t bool;
+ #else
+   #if SIZEOF_BOOL == 4
+    typedef uint32_t bool;
+   #else
+     #if SIZEOF_BOOL == 2
+      typedef uint16_t bool;
+     #else
+      typedef unsigned char bool;
+     #endif
+   #endif
+ #endif
+ #ifndef false
+ #define false FALSE
+ #endif
+ #ifndef true
+ #define true TRUE
+ #endif
+#endif
+
+#endif
+
+#ifndef ROUND
+# ifdef HAVE_RINT
+# define ROUND(f) rint(f)
+# else
+# define ROUND(f) (int)(floor((f) + 0.5))
+# endif
+#endif
+
+#ifndef INT16_MAX
+# define INT16_MAX (32767)
+#endif
+#ifndef INT16_MIN 
+# define INT16_MIN (-32767-1)
+#endif 
+
+#ifndef UINT32_MAX
+# define UINT32_MAX             (4294967295U)
+#endif
+
+#ifndef UINT64_MAX
+# define UINT64_MAX TO_U64(0xffffffffffffffff)
+#endif
+
+typedef enum audio_format_t {
+  AUDIO_FMT_U8 = 0,
+  AUDIO_FMT_S8,
+  AUDIO_FMT_U16LSB,
+  AUDIO_FMT_S16LSB,
+  AUDIO_FMT_U16MSB,
+  AUDIO_FMT_S16MSB,
+  AUDIO_FMT_U16,
+  AUDIO_FMT_S16,
+  AUDIO_FMT_FLOAT,
+  AUDIO_FMT_HW_AC3,
+} audio_format_t;
+
+#endif /* __MPEG4IP_INCLUDED__ */
+
diff --git a/sources/packages/m/audiocoding/faac/create-1.28-mpeg4ip-patch/file.list b/sources/packages/m/audiocoding/faac/create-1.28-mpeg4ip-patch/file.list
new file mode 100644
index 000000000..0627537f4
--- /dev/null
+++ b/sources/packages/m/audiocoding/faac/create-1.28-mpeg4ip-patch/file.list
@@ -0,0 +1 @@
+faac-1.28/common/mp4v2/mpeg4ip.h
diff --git a/sources/packages/m/audiocoding/faac/patches/README b/sources/packages/m/audiocoding/faac/patches/README
new file mode 100644
index 000000000..9ae50f72d
--- /dev/null
+++ b/sources/packages/m/audiocoding/faac/patches/README
@@ -0,0 +1,8 @@
+
+/* begin *
+
+   faac-1.28-mp4v2.patch - to use external mp4v2 library this patch should be applied
+                           and also the ./configure script shoild be called without
+                           --with-mp4v2 option.
+
+ * end */
diff --git a/sources/packages/m/audiocoding/faad2/Makefile b/sources/packages/m/audiocoding/faad2/Makefile
new file mode 100644
index 000000000..93ac32c99
--- /dev/null
+++ b/sources/packages/m/audiocoding/faad2/Makefile
@@ -0,0 +1,47 @@
+
+COMPONENT_TARGETS = $(HARDWARE_NOARCH)
+
+
+include ../../../../../build-system/constants.mk
+
+
+url         = $(DOWNLOAD_SERVER)/sources/packages/m/audiocoding/faad2
+
+versions    = 2.7
+pkgname     = faad2
+suffix      = tar.gz
+
+tarballs    = $(addsuffix .$(suffix), $(addprefix $(pkgname)-, $(versions)))
+sha1s       = $(addsuffix .sha1sum, $(tarballs))
+
+
+BUILD_TARGETS = $(tarballs) $(sha1s)
+
+
+include ../../../../../build-system/core.mk
+
+
+.PHONY: download_clean
+
+
+$(tarballs):
+	@echo -e "\n======= Downloading source tarballs =======" ; \
+	 for tarball in $(tarballs) ; do \
+	   echo "$(url)/$$tarball" | xargs -n 1 -P 100 wget $(WGET_OPTIONS) -i & \
+	 done ; wait
+
+$(sha1s): $(tarballs)
+	@for sha in $@ ; do \
+	   echo -e "\n======= Downloading '$$sha' signature =======\n" ; \
+	   echo "$(url)/$$sha" | xargs -n 1 -P 100 wget $(WGET_OPTIONS) -i & wait %1 ; \
+	   touch $$sha ; \
+	   echo -e "\n======= Check the '$$sha' sha1sum =======\n" ; \
+	   sha1sum --check $$sha ; ret="$$?" ; \
+	   if [ "$$ret" == "1" ]; then \
+	     echo -e "\n======= ERROR: Bad '$$sha' sha1sum =======\n" ; \
+	     exit 1 ; \
+	   fi ; \
+	 done
+
+download_clean:
+	@rm -f $(tarballs) $(sha1s)
diff --git a/sources/packages/m/mp4v2/Makefile b/sources/packages/m/mp4v2/Makefile
new file mode 100644
index 000000000..20f02e757
--- /dev/null
+++ b/sources/packages/m/mp4v2/Makefile
@@ -0,0 +1,56 @@
+
+COMPONENT_TARGETS = $(HARDWARE_NOARCH)
+
+
+include ../../../../build-system/constants.mk
+
+
+url         = $(DOWNLOAD_SERVER)/sources/packages/m/mp4v2
+
+versions    = 2.0.0
+pkgname     = mp4v2
+suffix      = tar.bz2
+
+tarballs    = $(addsuffix .$(suffix), $(addprefix $(pkgname)-, $(versions)))
+sha1s       = $(addsuffix .sha1sum, $(tarballs))
+
+patches     = $(CURDIR)/patches/mp4v2-2.0.0-help2man.patch
+
+.NOTPARALLEL: $(patches)
+
+
+BUILD_TARGETS = $(tarballs) $(sha1s) $(patches)
+
+
+include ../../../../build-system/core.mk
+
+
+.PHONY: download_clean
+
+
+$(tarballs):
+	@echo -e "\n======= Downloading source tarballs =======" ; \
+	 for tarball in $(tarballs) ; do \
+	   echo "$(url)/$$tarball" | xargs -n 1 -P 100 wget $(WGET_OPTIONS) -i & \
+	 done ; wait
+
+$(sha1s): $(tarballs)
+	@for sha in $@ ; do \
+	   echo -e "\n======= Downloading '$$sha' signature =======\n" ; \
+	   echo "$(url)/$$sha" | xargs -n 1 -P 100 wget $(WGET_OPTIONS) -i & wait %1 ; \
+	   touch $$sha ; \
+	   echo -e "\n======= Check the '$$sha' sha1sum =======\n" ; \
+	   sha1sum --check $$sha ; ret="$$?" ; \
+	   if [ "$$ret" == "1" ]; then \
+	     echo -e "\n======= ERROR: Bad '$$sha' sha1sum =======\n" ; \
+	     exit 1 ; \
+	   fi ; \
+	 done
+
+$(patches): $(sha1s)
+	@echo -e "\n======= Create Patches =======\n" ; \
+	 ( cd create-2.0.0-help2man-patch ; ./create.patch.sh ) ; \
+	 echo -e "\n"
+
+download_clean:
+	@rm -f $(tarballs) $(sha1s) $(patches)
diff --git a/sources/packages/m/mp4v2/create-2.0.0-help2man-patch/create.patch.sh b/sources/packages/m/mp4v2/create-2.0.0-help2man-patch/create.patch.sh
new file mode 100755
index 000000000..22388b881
--- /dev/null
+++ b/sources/packages/m/mp4v2/create-2.0.0-help2man-patch/create.patch.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=2.0.0
+
+tar --files-from=file.list -xjvf ../mp4v2-$VERSION.tar.bz2
+mv mp4v2-$VERSION mp4v2-$VERSION-orig
+
+cp -rf ./mp4v2-$VERSION-new ./mp4v2-$VERSION
+
+diff -b --unified -Nr  mp4v2-$VERSION-orig  mp4v2-$VERSION > mp4v2-$VERSION-help2man.patch
+
+mv mp4v2-$VERSION-help2man.patch ../patches
+
+rm -rf ./mp4v2-$VERSION
+rm -rf ./mp4v2-$VERSION-orig
diff --git a/sources/packages/m/mp4v2/create-2.0.0-help2man-patch/file.list b/sources/packages/m/mp4v2/create-2.0.0-help2man-patch/file.list
new file mode 100644
index 000000000..4ffe46c96
--- /dev/null
+++ b/sources/packages/m/mp4v2/create-2.0.0-help2man-patch/file.list
@@ -0,0 +1 @@
+mp4v2-2.0.0/doc/GNUmakefile.mk
diff --git a/sources/packages/m/mp4v2/create-2.0.0-help2man-patch/mp4v2-2.0.0-new/doc/GNUmakefile.mk b/sources/packages/m/mp4v2/create-2.0.0-help2man-patch/mp4v2-2.0.0-new/doc/GNUmakefile.mk
new file mode 100644
index 000000000..879ce72b8
--- /dev/null
+++ b/sources/packages/m/mp4v2/create-2.0.0-help2man-patch/mp4v2-2.0.0-new/doc/GNUmakefile.mk
@@ -0,0 +1,387 @@
+###############################################################################
+##
+##  makefile for documentation creation
+##
+##  INTPUT FILES (SOURCE/doc)
+##      doc/
+##          dox/            <-- generated API docs support files
+##          doxygen/        <-- generated API docs support files
+##          texi/           <-- hand-written project articles
+##
+##  OUTPUT FILES (BUILD/doc)
+##      doc/
+##      doc/
+##          api/
+##              html/   <-- API in html format
+##              xml/    <-- API in xml format
+##          articles/
+##              html/   <-- articles in html format
+##              txt/    <-- articles in txt format
+##              wiki/   <-- articles in Google Code Wiki format
+##              xml/    <-- articles in xml-texinfo format
+##          man/
+##              man1/   <-- man-pages for utilities
+##
+###############################################################################
+
+# Conventional VPATH directive breaks too many things so we use vpath and its
+# pattern-spec feature. If new files or extensions are introduced they may need
+# to be added here.
+
+VPATH =
+
+vpath COPYING       $(top_srcdir)
+vpath INSTALL       $(top_srcdir)
+vpath README        $(top_srcdir)
+vpath autoaux/%     $(top_srcdir)
+vpath %.1           $(top_srcdir)
+vpath %.cpp         $(top_srcdir)
+vpath %.h           $(top_srcdir)
+vpath %.m4          $(top_srcdir)
+vpath %.tcc         $(top_srcdir)
+
+###############################################################################
+
+SOURCE/ = $(top_srcdir)/
+BUILD/  = $(top_builddir)/
+
+DOC.in/  = $(SOURCE/)doc/
+DOC.out/ = $(BUILD/)doc/
+
+DOC.out.api/      = $(DOC.out/)api/
+DOC.out.articles/ = $(DOC.out/)articles/
+DOC.out.site/     = $(DOC.out/)site/
+
+###############################################################################
+
+M4       = m4
+M4.flags = -I$(BUILD/)project
+M4.cmd   = $(M4) $(M4.flags) $(1) > $(2)
+M4.deps  = $(BUILD/)project/project.m4
+
+ifeq ($(FOUND_HELP2MAN),yes)
+HELP2MAN       = help2man
+HELP2MAN.flags = --no-discard-stderr -m "$(PROJECT_name) Utilities" -N
+HELP2MAN.cmd   = $(HELP2MAN) $(HELP2MAN.flags) ./$(1) -o $(2)
+else
+HELP2MAN.cmd = touch $(2)
+endif
+
+MAKEINFO.flags      = -I$(DOC.in/)texi -I$(DOC.out/)texi
+MAKEINFO.flags.html = --html --no-headers --no-split
+MAKEINFO.flags.txt  = --plaintext --no-headers
+MAKEINFO.flags.xml  = --xml --output-indent=4
+MAKEINFO.cmd        = makeinfo $(MAKEINFO.flags) $(MAKEINFO.flags.$(1)) $(2) -o $(3)
+
+HTMLCOMBINE = $(SOURCE/)project/htmlcombine.py
+HTMLCOMBINE.cmd   = $(HTMLCOMBINE) --header $(1) --footer $(2) --body $(3) > $(4)
+HTMLCOMBINE.deps  = $(HTMLCOMBINE)
+
+XML2WIKI       = $(SOURCE/)project/xml2wiki.py
+XML2WIKI.flags = --date --toc
+XML2WIKI.cmd   = $(XML2WIKI) $(XML2WIKI.flags) $(1) > $(2)
+XML2WIKI.deps  = $(XML2WIKI)
+
+DOXYGEN     = doxygen
+DOXYGEN.cmd = $(DOXYGEN) $(1)
+
+###############################################################################
+
+DOC.m4.out = \
+    doc/texi/base/project.texi \
+    doc/doxygen/Doxyfile       \
+    doc/doxygen/header.html    \
+    doc/doxygen/footer.html    \
+    doc/html/header.html       \
+    doc/html/footer.html
+
+DOC.man.utils = mp4art mp4file mp4subtitle mp4track
+DOC.man.out   = $(DOC.man.utils:%=$(DOC.out/)man/man1/%.1)
+
+DOC.texi.articles = $(wildcard $(DOC.in/)texi/*.texi $(DOC.out/)texi/*.texi)
+
+DOC.texi.includes = \
+    doc/texi/base/project.texi \
+    $(wildcard $(DOC.in/)texi/*/*.texi $(DOC.out/)texi/*/*.texi)
+
+DOC.texi2html.out = $(DOC.texi.articles:$(DOC.in/)texi/%.texi=$(DOC.out.articles/)html/%.html)
+DOC.texi2txt.out  = $(DOC.texi.articles:$(DOC.in/)texi/%.texi=$(DOC.out.articles/)txt/%.txt)
+DOC.texi2xml.out  = $(DOC.texi.articles:$(DOC.in/)texi/%.texi=$(DOC.out.articles/)xml/%.xml)
+
+DOC.xml2wiki.out  = $(DOC.texi2xml.out:$(DOC.out.articles/)xml/%.xml=$(DOC.out.articles/)wiki/%.wiki)
+
+DOC.api.out = $(DOC.out.api/).stamp
+
+DOC.site.out       = $(DOC.out.site/).stamp
+DOC.site.out.copy  = $(patsubst $(DOC.in/)html/%,$(DOC.out.site/)%, \
+    $(filter-out %.in,$(wildcard $(DOC.in/)html/*)))
+DOC.site.out.index = $(DOC.out.site/)index.html
+DOC.site.out.html  = $(patsubst $(DOC.out.articles/)html/%,$(DOC.out.site/)%, \
+    $(filter-out %/Documentation.html,$(DOC.texi2html.out)))
+
+###############################################################################
+
+MKDIRS += $(dir $(DOC.m4.out))
+MKDIRS += $(DOC.out/)man/man1/
+MKDIRS += $(foreach n,html man texi txt wiki xml,$(DOC.out.articles/)$n)
+MKDIRS += $(DOC.out.api/)
+MKDIRS += $(DOC.out.site/)
+
+###############################################################################
+
+EXTRA_DIST += \
+    $(SOURCE/)vstudio9.0/include/mp4v2/project.h \
+    $(SOURCE/)vstudio9.0/mp4v2.sln \
+    $(wildcard $(SOURCE/)vstudio9.0/*/*.vcproj)
+
+###############################################################################
+
+dist-hook: $(DOC.texi2txt.out) $(DOC.man.out)
+	rm -fr $(distdir)/doc
+	$(mkdir_p) $(distdir)/doc
+	$(INSTALL_DATA) $(DOC.in/)GNUmakefile.mk $(distdir)/doc/.
+ifneq (,$(DOC.texi2txt.out))
+	$(INSTALL_DATA) $(DOC.texi2txt.out) $(distdir)/doc/.
+endif
+ifneq (,$(DOC.man.out))
+	$(mkdir_p) $(distdir)/doc/man/man1
+	$(INSTALL_DATA) $(DOC.man.out) $(distdir)/doc/man/man1
+endif
+
+distclean-local: docclean
+
+###############################################################################
+
+$(DOC.m4.out): %: %.m4 $(M4.deps) | $(dir $(DOC.m4.out))
+	$(call M4.cmd,$<,$@)
+
+###############################################################################
+
+.PHONY: articles doc
+articles: html txt xml wiki
+doc: man articles api site
+
+.PHONY: articlesclean apiclean docclean
+articlesclean: htmlclean txtclean xmlclean wikiclean
+docclean: manclean articlesclean apiclean siteclean
+
+.PHONY: man html txt xml wiki api
+man: $(DOC.man.out)
+html: $(DOC.texi2html.out)
+txt: $(DOC.texi2txt.out)
+xml: $(DOC.texi2xml.out)
+wiki: $(DOC.xml2wiki.out)
+api: $(DOC.api.out)
+site: $(DOC.site.out)
+
+.PHONY: manclean htmlclean txtclean xmlclean wikiclean apiclean
+manclean:
+	rm -f $(DOC.man.out)
+
+htmlclean:
+	rm -f $(DOC.texi2html.out)
+
+txtclean:
+	rm -f $(DOC.texi2txt.out)
+
+xmlclean:
+	rm -f $(DOC.texi2xml.out)
+
+wikiclean:
+	rm -f $(DOC.xml2wiki.out)
+
+apiclean:
+	rm -f $(DOC.api.out)
+	rm -fr $(DOC.out.api/)html/ $(DOC.out.api/)xml/
+
+siteclean:
+	rm -fr $(DOC.out.site/)
+
+###############################################################################
+
+$(DOC.man.out): | $(dir $(DOC.man.out))
+$(DOC.man.out): $(DOC.out/)man/man1/%.1: $(BUILD/)%$(EXEEXT)
+	$(call HELP2MAN.cmd,$<,$@)
+
+$(DOC.texi2html.out): $(DOC.texi.includes) | $(dir $(DOC.texi2html.out))
+$(DOC.texi2html.out): $(DOC.out.articles/)html/%.html: $(DOC.in/)texi/%.texi
+	$(call MAKEINFO.cmd,html,$<,$@)
+
+$(DOC.texi2txt.out): $(DOC.texi.includes) | $(dir $(DOC.texi2txt.out))
+$(DOC.texi2txt.out): $(DOC.out.articles/)txt/%.txt: $(DOC.in/)texi/%.texi
+	$(call MAKEINFO.cmd,txt,$<,$@)
+
+$(DOC.texi2xml.out): $(DOC.texi.includes) | $(dir $(DOC.texi2xml.out))
+$(DOC.texi2xml.out): $(DOC.out.articles/)xml/%.xml: $(DOC.in/)texi/%.texi
+	$(call MAKEINFO.cmd,xml,$<,$@)
+
+$(DOC.xml2wiki.out): $(XML2WIKI.deps) | $(dir $(DOC.xml2wiki.out))
+$(DOC.xml2wiki.out): $(DOC.out.articles/)wiki/%.wiki: $(DOC.out.articles/)xml/%.xml
+	$(call XML2WIKI.cmd,$<,$@)
+
+$(DOC.api.out): | $(dir $(DOC.api.out))
+$(DOC.api.out): $(DOC.in/)doxygen/banner.png
+$(DOC.api.out): $(DOC.in/)doxygen/project.css
+$(DOC.api.out): $(DOC.out/)doxygen/header.html
+$(DOC.api.out): $(DOC.out/)doxygen/footer.html
+$(DOC.api.out): $(DOC.out/)doxygen/Doxyfile
+	$(call DOXYGEN.cmd,$<)
+	$(INSTALL_DATA) $(DOC.in/)doxygen/banner.png $(DOC.out.api/)html/
+	touch $@
+
+###############################################################################
+
+$(DOC.site.out): | $(DOC.out.site/)articles
+$(DOC.site.out): | $(DOC.out.site/)api
+$(DOC.site.out): $(DOC.site.out.copy)
+$(DOC.site.out): $(DOC.site.out.index)
+$(DOC.site.out): $(DOC.site.out.html)
+
+$(DOC.out.site/)articles: | html $(DOC.out.site/)
+	rm -f $@
+	ln -s ../articles/html $@
+
+$(DOC.out.site/)api: | api $(DOC.out.site/)
+	rm -f $@
+	ln -s ../api/html $@
+
+$(DOC.site.out.copy): $(DOC.out.site/)%: $(DOC.in/)html/%
+	$(INSTALL_DATA) $^ $(@D)/.
+
+$(DOC.site.out.index): $(DOC.out/)html/header.html $(DOC.out/)html/footer.html
+$(DOC.site.out.index): $(HTMLCOMBINE.deps)
+$(DOC.site.out.index): $(DOC.out.articles/)html/Documentation.html
+	$(call HTMLCOMBINE.cmd,$(word 2,$^),$(word 3,$^),$<,$@)
+
+$(DOC.site.out.html): $(DOC.out/)html/header.html $(DOC.out/)html/footer.html
+$(DOC.site.out.html): $(HTMLCOMBINE.deps)
+$(DOC.site.out.html): $(DOC.out.site/)%: $(DOC.out.articles/)html/%
+	$(call HTMLCOMBINE.cmd,$(word 2,$^),$(word 3,$^),$<,$@)
+
+###############################################################################
+
+GOOGLE.out/      = $(top_builddir)/google/
+GOOGLE.repo.doc  = $(PROJECT_repo_branch)
+
+google.clean:
+	rm -fr $(GOOGLE.out/)
+
+google.post: site wiki
+google.post: | $(GOOGLE.out/)
+google.post: google.rsync google.rm google.add google.propset
+
+$(GOOGLE.out/):
+	svn co --depth immediates $(PROJECT_repo_root) $(GOOGLE.out/)
+	svn update --set-depth immediates google/wiki
+	svn update --set-depth infinity google/doc/$(GOOGLE.repo.doc)
+
+google.rsync:
+	rsync -vrptPL --delete \
+	    --exclude=".svn/*" --exclude=".svn" \
+	    --exclude="*/.svn/*" --exclude="*/.svn" \
+	    --exclude=".stamp" --exclude="*/.stamp" \
+	    --exclude="*.m4" --exclude="*/*.m4" \
+	    $(DOC.out.site/). $(GOOGLE.out/)doc/$(GOOGLE.repo.doc)/.
+	$(INSTALL_DATA) $(DOC.out.articles/)wiki/BuildRepository.wiki $(GOOGLE.out/)wiki/.
+	$(INSTALL_DATA) $(DOC.out.articles/)wiki/BuildSource.wiki $(GOOGLE.out/)wiki/.
+
+google.rm:
+	@files=`svn status $(GOOGLE.out/) | grep '^!' | awk '{ print $$2 }'`; \
+	if [ -n "$$files" ]; then \
+	    svn rm $$files; \
+	fi
+
+google.add:
+	@files=`svn status $(GOOGLE.out/) | grep '^?' | awk '{ print $$2 }'`; \
+	if [ -n "$$files" ]; then \
+	    svn add $$files; \
+	fi
+
+google.propset:
+	find $(GOOGLE.out/)doc/$(GOOGLE.repo.doc) -type f -a \( -name "*.html" -o -name "*.css" \) -print0 \
+	    | xargs -0 svn propset svn:eol-style native
+	find $(GOOGLE.out/)doc/$(GOOGLE.repo.doc) -type f -a -name "*.html" -print0 \
+	    | xargs -0 svn propset svn:mime-type "text/html"
+
+###############################################################################
+
+dist-hb: distdir=lib$(PACKAGE)
+dist-hb: distdir
+	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >lib$(PACKAGE)-$(VERSION).tar.gz
+	$(am__remove_distdir)
+
+###############################################################################
+
+## Precompiled header support is tricky given libtool's complexity and its
+## historical aversion to supporting it.
+##
+## What we do is add rules to precompile. Unfortunately, we cannot
+## automatically determine what flags libtool adds for compilation variants;
+## ie: PIC or non-PIC compilation. So instead we will hardcode the flags
+## to match. The reason for this is the precompiled-header will not be used if
+## (relevent) compilation flags differ.
+
+CXX.gch.static.flags = $(X_GCH_STATIC_FLAGS)
+CXX.gch.static.in    = libplatform/impl.h src/impl.h libutil/impl.h
+CXX.gch.static.out   = $(CXX.gch.static.in:%=$(BUILD/)%.gch/static)
+
+CXX.gch.shared.flags = $(X_GCH_SHARED_FLAGS)
+CXX.gch.shared.in    = libplatform/impl.h src/impl.h libutil/impl.h
+CXX.gch.shared.out   = $(CXX.gch.shared.in:%=$(BUILD/)%.gch/shared)
+
+CXX.gch.exe.flags = $(X_GCH_FLAGS)
+CXX.gch.exe.in    = util/impl.h
+CXX.gch.exe.out   = $(CXX.gch.exe.in:%=$(BUILD/)%.gch/exe)
+
+CXX.gch.static.dependents = $(libmp4v2_la_OBJECTS)
+CXX.gch.shared.dependents = $(libmp4v2_la_OBJECTS)
+
+CXX.gch.exe.dependents = \
+    $(mp4art_OBJECTS)        \
+    $(mp4chaps_OBJECTS)      \
+    $(mp4extract_OBJECTS)    \
+    $(mp4file_OBJECTS)       \
+    $(mp4info_OBJECTS)       \
+    $(mp4subtitle_OBJECTS)   \
+    $(mp4syncfiles_OBJECTS)  \
+    $(mp4tags_OBJECTS)       \
+    $(mp4track_OBJECTS)      \
+    $(mp4trackdump_OBJECTS)
+
+ifeq ($(X_GCH_STATIC),1)
+$(CXX.gch.static.dependents): $(CXX.gch.static.out)
+endif
+
+ifeq ($(X_GCH_SHARED),1)
+$(CXX.gch.shared.dependents): $(CXX.gch.shared.out)
+endif
+
+ifeq ($(X_GCH),1)
+$(CXX.gch.exe.dependents): $(CXX.gch.exe.out)
+endif
+
+$(CXX.gch.static.out): | $(sort $(dir $(CXX.gch.static.out)))
+$(CXX.gch.static.out): $(BUILD/)%.gch/static: %
+	$(CXXCOMPILE) $(CXX.gch.static.flags) -c $< -o $@
+
+$(CXX.gch.shared.out): | $(sort $(dir $(CXX.gch.shared.out)))
+$(CXX.gch.shared.out): $(BUILD/)%.gch/shared: %
+	$(CXXCOMPILE) $(CXX.gch.shared.flags) -c $< -o $@
+
+$(CXX.gch.exe.out): | $(sort $(dir $(CXX.gch.exe.out)))
+$(CXX.gch.exe.out): $(BUILD/)%.gch/exe: %
+	$(CXXCOMPILE) $(CXX.gch.exe.flags) -c $< -o $@
+
+MKDIRS += $(dir $(CXX.gch.static.out))
+MKDIRS += $(dir $(CXX.gch.shared.out))
+MKDIRS += $(dir $(CXX.gch.exe.out))
+
+clean-local:
+	rm -f $(CXX.gch.static.out)
+	rm -f $(CXX.gch.shared.out)
+	rm -f $(CXX.gch.exe.out)
+
+###############################################################################
+
+$(sort $(MKDIRS)):
+	$(mkdir_p) $@