Imported Upstream version 0.11.90
diff --git a/ext/Makefile.am b/ext/Makefile.am
new file mode 100644
index 0000000..e34480d
--- /dev/null
+++ b/ext/Makefile.am
@@ -0,0 +1,93 @@
+if USE_A52DEC
+A52DEC_DIR = a52dec
+else
+A52DEC_DIR =
+endif
+
+if USE_AMRNB
+ AMRNB_DIR = amrnb
+else
+ AMRNB_DIR =
+endif
+
+if USE_AMRWB
+ AMRWB_DIR = amrwbdec
+else
+ AMRWB_DIR =
+endif
+
+if USE_CDIO
+CDIO_DIR = cdio
+else
+CDIO_DIR = 
+endif
+
+if USE_DVDREAD
+ DVDREAD_DIR = dvdread
+else
+ DVDREAD_DIR =
+endif
+
+if USE_LAME
+LAME_DIR = lame
+else
+LAME_DIR =
+endif
+
+if USE_MAD
+MAD_DIR = mad
+else
+MAD_DIR =
+endif
+
+if USE_MPEG2DEC
+MPEG2DEC_DIR = mpeg2dec
+else
+MPEG2DEC_DIR =
+endif
+
+if USE_SIDPLAY
+SIDPLAY_DIR = sidplay
+else
+SIDPLAY_DIR =
+endif
+
+if USE_TWOLAME
+TWOLAME_DIR = twolame
+else
+TWOLAME_DIR =
+endif
+
+if USE_X264
+X264_DIR=x264
+else
+X264_DIR=
+endif
+
+SUBDIRS = \
+	$(A52DEC_DIR) \
+	$(AMRNB_DIR) \
+	$(AMRWB_DIR) \
+	$(CDIO_DIR) \
+	$(DVDREAD_DIR) \
+	$(LAME_DIR) \
+	$(MAD_DIR) \
+	$(MPEG2DEC_DIR) \
+	$(SIDPLAY_DIR) \
+	$(TWOLAME_DIR) \
+	$(X264_DIR)
+
+DIST_SUBDIRS = \
+	a52dec \
+	amrnb \
+	amrwbdec \
+	cdio \
+	dvdread \
+	lame \
+	mad \
+	mpeg2dec \
+	sidplay \
+	twolame \
+	x264
+
+include $(top_srcdir)/common/parallel-subdirs.mak
diff --git a/ext/Makefile.in b/ext/Makefile.in
new file mode 100644
index 0000000..d3d5a98
--- /dev/null
+++ b/ext/Makefile.in
@@ -0,0 +1,806 @@
+# Makefile.in generated by automake 1.11.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# include this at the end of $MODULE/ext/Makefile.am to force make to
+# build subdirectories in parallel when make -jN is used. We will end up
+# descending into all subdirectories a second time, but only after the first
+# (parallel) run has finished, so it should go right through the second time.
+VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+	$(top_srcdir)/common/parallel-subdirs.mak
+subdir = ext
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \
+	$(top_srcdir)/common/m4/as-auto-alt.m4 \
+	$(top_srcdir)/common/m4/as-compiler-flag.m4 \
+	$(top_srcdir)/common/m4/as-python.m4 \
+	$(top_srcdir)/common/m4/as-scrub-include.m4 \
+	$(top_srcdir)/common/m4/as-version.m4 \
+	$(top_srcdir)/common/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/common/m4/gst-arch.m4 \
+	$(top_srcdir)/common/m4/gst-args.m4 \
+	$(top_srcdir)/common/m4/gst-check.m4 \
+	$(top_srcdir)/common/m4/gst-default.m4 \
+	$(top_srcdir)/common/m4/gst-dowhile.m4 \
+	$(top_srcdir)/common/m4/gst-error.m4 \
+	$(top_srcdir)/common/m4/gst-feature.m4 \
+	$(top_srcdir)/common/m4/gst-function.m4 \
+	$(top_srcdir)/common/m4/gst-gettext.m4 \
+	$(top_srcdir)/common/m4/gst-glib2.m4 \
+	$(top_srcdir)/common/m4/gst-package-release-datetime.m4 \
+	$(top_srcdir)/common/m4/gst-plugin-docs.m4 \
+	$(top_srcdir)/common/m4/gst-plugindir.m4 \
+	$(top_srcdir)/common/m4/gst.m4 \
+	$(top_srcdir)/common/m4/gtk-doc.m4 \
+	$(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \
+	$(top_srcdir)/m4/a52.m4 $(top_srcdir)/m4/gettext.m4 \
+	$(top_srcdir)/m4/gst-sid.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+	$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN   " $@;
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+	html-recursive info-recursive install-data-recursive \
+	install-dvi-recursive install-exec-recursive \
+	install-html-recursive install-info-recursive \
+	install-pdf-recursive install-ps-recursive install-recursive \
+	installcheck-recursive installdirs-recursive pdf-recursive \
+	ps-recursive uninstall-recursive
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+	distdir
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+A52DEC_CFLAGS = @A52DEC_CFLAGS@
+A52DEC_LIBS = @A52DEC_LIBS@
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMRNB_CFLAGS = @AMRNB_CFLAGS@
+AMRNB_LIBS = @AMRNB_LIBS@
+AMRWB_CFLAGS = @AMRWB_CFLAGS@
+AMRWB_LIBS = @AMRWB_LIBS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CDIO_CFLAGS = @CDIO_CFLAGS@
+CDIO_LIBS = @CDIO_LIBS@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@
+DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@
+DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@
+DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@
+DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DVDREAD_LIBS = @DVDREAD_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+ERROR_CXXFLAGS = @ERROR_CXXFLAGS@
+EXEEXT = @EXEEXT@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+GCOV = @GCOV@
+GCOV_CFLAGS = @GCOV_CFLAGS@
+GCOV_LIBS = @GCOV_LIBS@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LDFLAGS = @GIO_LDFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_PREFIX = @GLIB_PREFIX@
+GLIB_REQ = @GLIB_REQ@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@
+GSTPB_PREFIX = @GSTPB_PREFIX@
+GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@
+GST_API_VERSION = @GST_API_VERSION@
+GST_BASE_CFLAGS = @GST_BASE_CFLAGS@
+GST_BASE_LIBS = @GST_BASE_LIBS@
+GST_CFLAGS = @GST_CFLAGS@
+GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@
+GST_CHECK_LIBS = @GST_CHECK_LIBS@
+GST_CXXFLAGS = @GST_CXXFLAGS@
+GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@
+GST_LIBS = @GST_LIBS@
+GST_LICENSE = @GST_LICENSE@
+GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@
+GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@
+GST_PACKAGE_NAME = @GST_PACKAGE_NAME@
+GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@
+GST_PLUGINS_ALL = @GST_PLUGINS_ALL@
+GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@
+GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@
+GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@
+GST_PLUGINS_DIR = @GST_PLUGINS_DIR@
+GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@
+GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GST_PREFIX = @GST_PREFIX@
+GST_TOOLS_DIR = @GST_TOOLS_DIR@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DVDREAD = @HAVE_DVDREAD@
+HAVE_LAME = @HAVE_LAME@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LAME_CFLAGS = @LAME_CFLAGS@
+LAME_LIBS = @LAME_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAD_CFLAGS = @MAD_CFLAGS@
+MAD_LIBS = @MAD_LIBS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MPEG2DEC_CFLAGS = @MPEG2DEC_CFLAGS@
+MPEG2DEC_LIBS = @MPEG2DEC_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ORCC = @ORCC@
+ORCC_FLAGS = @ORCC_FLAGS@
+ORC_CFLAGS = @ORC_CFLAGS@
+ORC_LIBS = @ORC_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@
+PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGINDIR = @PLUGINDIR@
+POSUB = @POSUB@
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIDPLAY_CFLAGS = @SIDPLAY_CFLAGS@
+SIDPLAY_LIBS = @SIDPLAY_LIBS@
+STRIP = @STRIP@
+TWOLAME_CFLAGS = @TWOLAME_CFLAGS@
+TWOLAME_LIBS = @TWOLAME_LIBS@
+USE_NLS = @USE_NLS@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VALGRIND_PATH = @VALGRIND_PATH@
+VERSION = @VERSION@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WIN32_LIBS = @WIN32_LIBS@
+X264_CFLAGS = @X264_CFLAGS@
+X264_LIBS = @X264_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+plugindir = @plugindir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+@USE_A52DEC_FALSE@A52DEC_DIR = 
+@USE_A52DEC_TRUE@A52DEC_DIR = a52dec
+@USE_AMRNB_FALSE@AMRNB_DIR = 
+@USE_AMRNB_TRUE@AMRNB_DIR = amrnb
+@USE_AMRWB_FALSE@AMRWB_DIR = 
+@USE_AMRWB_TRUE@AMRWB_DIR = amrwbdec
+@USE_CDIO_FALSE@CDIO_DIR = 
+@USE_CDIO_TRUE@CDIO_DIR = cdio
+@USE_DVDREAD_FALSE@DVDREAD_DIR = 
+@USE_DVDREAD_TRUE@DVDREAD_DIR = dvdread
+@USE_LAME_FALSE@LAME_DIR = 
+@USE_LAME_TRUE@LAME_DIR = lame
+@USE_MAD_FALSE@MAD_DIR = 
+@USE_MAD_TRUE@MAD_DIR = mad
+@USE_MPEG2DEC_FALSE@MPEG2DEC_DIR = 
+@USE_MPEG2DEC_TRUE@MPEG2DEC_DIR = mpeg2dec
+@USE_SIDPLAY_FALSE@SIDPLAY_DIR = 
+@USE_SIDPLAY_TRUE@SIDPLAY_DIR = sidplay
+@USE_TWOLAME_FALSE@TWOLAME_DIR = 
+@USE_TWOLAME_TRUE@TWOLAME_DIR = twolame
+@USE_X264_FALSE@X264_DIR = 
+@USE_X264_TRUE@X264_DIR = x264
+SUBDIRS = \
+	$(A52DEC_DIR) \
+	$(AMRNB_DIR) \
+	$(AMRWB_DIR) \
+	$(CDIO_DIR) \
+	$(DVDREAD_DIR) \
+	$(LAME_DIR) \
+	$(MAD_DIR) \
+	$(MPEG2DEC_DIR) \
+	$(SIDPLAY_DIR) \
+	$(TWOLAME_DIR) \
+	$(X264_DIR)
+
+DIST_SUBDIRS = \
+	a52dec \
+	amrnb \
+	amrwbdec \
+	cdio \
+	dvdread \
+	lame \
+	mad \
+	mpeg2dec \
+	sidplay \
+	twolame \
+	x264
+
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/common/parallel-subdirs.mak $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu ext/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+$(top_srcdir)/common/parallel-subdirs.mak:
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+	@fail= failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+	@fail= failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
+	done; \
+	rev="$$rev ."; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	  empty_fix=.; \
+	else \
+	  include_option=--include; \
+	  empty_fix=; \
+	fi; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test ! -f $$subdir/TAGS || \
+	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    $(am__make_dryrun) \
+	      || test -d "$(distdir)/$$subdir" \
+	      || $(MKDIR_P) "$(distdir)/$$subdir" \
+	      || exit 1; \
+	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+	    $(am__relativize); \
+	    new_distdir=$$reldir; \
+	    dir1=$$subdir; dir2="$(top_distdir)"; \
+	    $(am__relativize); \
+	    new_top_distdir=$$reldir; \
+	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+	    ($(am__cd) $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$$new_top_distdir" \
+	        distdir="$$new_distdir" \
+		am__remove_distdir=: \
+		am__skip_length_check=: \
+		am__skip_mode_fix=: \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+	install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+	all all-am check check-am clean clean-generic clean-libtool \
+	ctags ctags-recursive distclean distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
+	uninstall uninstall-am
+
+
+.PHONY: independent-subdirs $(SUBDIRS)
+
+independent-subdirs: $(SUBDIRS)
+
+$(SUBDIRS):
+	$(MAKE) -C $@
+
+all-recursive: independent-subdirs
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/ext/a52dec/Makefile.am b/ext/a52dec/Makefile.am
new file mode 100644
index 0000000..65c4d26
--- /dev/null
+++ b/ext/a52dec/Makefile.am
@@ -0,0 +1,20 @@
+plugin_LTLIBRARIES = libgsta52dec.la
+
+libgsta52dec_la_SOURCES = gsta52dec.c
+libgsta52dec_la_CFLAGS = \
+	$(GST_PLUGINS_BASE_CFLAGS) \
+        $(GST_BASE_CFLAGS) \
+        $(GST_CFLAGS) \
+	$(ORC_CFLAGS) \
+	$(A52DEC_CFLAGS)
+libgsta52dec_la_LIBADD = \
+	$(GST_PLUGINS_BASE_LIBS) \
+        $(GST_BASE_LIBS) \
+        $(GST_LIBS) \
+        -lgstaudio-$(GST_API_VERSION) \
+	$(ORC_LIBS) \
+	$(A52DEC_LIBS)
+libgsta52dec_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgsta52dec_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS = gsta52dec.h
diff --git a/ext/a52dec/Makefile.in b/ext/a52dec/Makefile.in
new file mode 100644
index 0000000..9171dc2
--- /dev/null
+++ b/ext/a52dec/Makefile.in
@@ -0,0 +1,760 @@
+# Makefile.in generated by automake 1.11.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = ext/a52dec
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \
+	$(top_srcdir)/common/m4/as-auto-alt.m4 \
+	$(top_srcdir)/common/m4/as-compiler-flag.m4 \
+	$(top_srcdir)/common/m4/as-python.m4 \
+	$(top_srcdir)/common/m4/as-scrub-include.m4 \
+	$(top_srcdir)/common/m4/as-version.m4 \
+	$(top_srcdir)/common/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/common/m4/gst-arch.m4 \
+	$(top_srcdir)/common/m4/gst-args.m4 \
+	$(top_srcdir)/common/m4/gst-check.m4 \
+	$(top_srcdir)/common/m4/gst-default.m4 \
+	$(top_srcdir)/common/m4/gst-dowhile.m4 \
+	$(top_srcdir)/common/m4/gst-error.m4 \
+	$(top_srcdir)/common/m4/gst-feature.m4 \
+	$(top_srcdir)/common/m4/gst-function.m4 \
+	$(top_srcdir)/common/m4/gst-gettext.m4 \
+	$(top_srcdir)/common/m4/gst-glib2.m4 \
+	$(top_srcdir)/common/m4/gst-package-release-datetime.m4 \
+	$(top_srcdir)/common/m4/gst-plugin-docs.m4 \
+	$(top_srcdir)/common/m4/gst-plugindir.m4 \
+	$(top_srcdir)/common/m4/gst.m4 \
+	$(top_srcdir)/common/m4/gtk-doc.m4 \
+	$(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \
+	$(top_srcdir)/m4/a52.m4 $(top_srcdir)/m4/gettext.m4 \
+	$(top_srcdir)/m4/gst-sid.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+	$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(plugindir)"
+LTLIBRARIES = $(plugin_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libgsta52dec_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am_libgsta52dec_la_OBJECTS = libgsta52dec_la-gsta52dec.lo
+libgsta52dec_la_OBJECTS = $(am_libgsta52dec_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+libgsta52dec_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+	$(libgsta52dec_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+	$(CCLD) $(libgsta52dec_la_CFLAGS) $(CFLAGS) \
+	$(libgsta52dec_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libgsta52dec_la_SOURCES)
+DIST_SOURCES = $(libgsta52dec_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+A52DEC_CFLAGS = @A52DEC_CFLAGS@
+A52DEC_LIBS = @A52DEC_LIBS@
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMRNB_CFLAGS = @AMRNB_CFLAGS@
+AMRNB_LIBS = @AMRNB_LIBS@
+AMRWB_CFLAGS = @AMRWB_CFLAGS@
+AMRWB_LIBS = @AMRWB_LIBS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CDIO_CFLAGS = @CDIO_CFLAGS@
+CDIO_LIBS = @CDIO_LIBS@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@
+DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@
+DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@
+DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@
+DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DVDREAD_LIBS = @DVDREAD_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+ERROR_CXXFLAGS = @ERROR_CXXFLAGS@
+EXEEXT = @EXEEXT@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+GCOV = @GCOV@
+GCOV_CFLAGS = @GCOV_CFLAGS@
+GCOV_LIBS = @GCOV_LIBS@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LDFLAGS = @GIO_LDFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_PREFIX = @GLIB_PREFIX@
+GLIB_REQ = @GLIB_REQ@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@
+GSTPB_PREFIX = @GSTPB_PREFIX@
+GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@
+GST_API_VERSION = @GST_API_VERSION@
+GST_BASE_CFLAGS = @GST_BASE_CFLAGS@
+GST_BASE_LIBS = @GST_BASE_LIBS@
+GST_CFLAGS = @GST_CFLAGS@
+GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@
+GST_CHECK_LIBS = @GST_CHECK_LIBS@
+GST_CXXFLAGS = @GST_CXXFLAGS@
+GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@
+GST_LIBS = @GST_LIBS@
+GST_LICENSE = @GST_LICENSE@
+GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@
+GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@
+GST_PACKAGE_NAME = @GST_PACKAGE_NAME@
+GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@
+GST_PLUGINS_ALL = @GST_PLUGINS_ALL@
+GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@
+GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@
+GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@
+GST_PLUGINS_DIR = @GST_PLUGINS_DIR@
+GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@
+GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GST_PREFIX = @GST_PREFIX@
+GST_TOOLS_DIR = @GST_TOOLS_DIR@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DVDREAD = @HAVE_DVDREAD@
+HAVE_LAME = @HAVE_LAME@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LAME_CFLAGS = @LAME_CFLAGS@
+LAME_LIBS = @LAME_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAD_CFLAGS = @MAD_CFLAGS@
+MAD_LIBS = @MAD_LIBS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MPEG2DEC_CFLAGS = @MPEG2DEC_CFLAGS@
+MPEG2DEC_LIBS = @MPEG2DEC_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ORCC = @ORCC@
+ORCC_FLAGS = @ORCC_FLAGS@
+ORC_CFLAGS = @ORC_CFLAGS@
+ORC_LIBS = @ORC_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@
+PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGINDIR = @PLUGINDIR@
+POSUB = @POSUB@
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIDPLAY_CFLAGS = @SIDPLAY_CFLAGS@
+SIDPLAY_LIBS = @SIDPLAY_LIBS@
+STRIP = @STRIP@
+TWOLAME_CFLAGS = @TWOLAME_CFLAGS@
+TWOLAME_LIBS = @TWOLAME_LIBS@
+USE_NLS = @USE_NLS@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VALGRIND_PATH = @VALGRIND_PATH@
+VERSION = @VERSION@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WIN32_LIBS = @WIN32_LIBS@
+X264_CFLAGS = @X264_CFLAGS@
+X264_LIBS = @X264_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+plugindir = @plugindir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+plugin_LTLIBRARIES = libgsta52dec.la
+libgsta52dec_la_SOURCES = gsta52dec.c
+libgsta52dec_la_CFLAGS = \
+	$(GST_PLUGINS_BASE_CFLAGS) \
+        $(GST_BASE_CFLAGS) \
+        $(GST_CFLAGS) \
+	$(ORC_CFLAGS) \
+	$(A52DEC_CFLAGS)
+
+libgsta52dec_la_LIBADD = \
+	$(GST_PLUGINS_BASE_LIBS) \
+        $(GST_BASE_LIBS) \
+        $(GST_LIBS) \
+        -lgstaudio-$(GST_API_VERSION) \
+	$(ORC_LIBS) \
+	$(A52DEC_LIBS)
+
+libgsta52dec_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgsta52dec_la_LIBTOOLFLAGS = --tag=disable-static
+noinst_HEADERS = gsta52dec.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/a52dec/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu ext/a52dec/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \
+	  $(MKDIR_P) '$(DESTDIR)$(plugindir)' || exit 1; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+	}
+
+uninstall-pluginLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+	done
+
+clean-pluginLTLIBRARIES:
+	-test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+	@list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libgsta52dec.la: $(libgsta52dec_la_OBJECTS) $(libgsta52dec_la_DEPENDENCIES) $(EXTRA_libgsta52dec_la_DEPENDENCIES) 
+	$(AM_V_CCLD)$(libgsta52dec_la_LINK) -rpath $(plugindir) $(libgsta52dec_la_OBJECTS) $(libgsta52dec_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsta52dec_la-gsta52dec.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+libgsta52dec_la-gsta52dec.lo: gsta52dec.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgsta52dec_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgsta52dec_la_CFLAGS) $(CFLAGS) -MT libgsta52dec_la-gsta52dec.lo -MD -MP -MF $(DEPDIR)/libgsta52dec_la-gsta52dec.Tpo -c -o libgsta52dec_la-gsta52dec.lo `test -f 'gsta52dec.c' || echo '$(srcdir)/'`gsta52dec.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgsta52dec_la-gsta52dec.Tpo $(DEPDIR)/libgsta52dec_la-gsta52dec.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gsta52dec.c' object='libgsta52dec_la-gsta52dec.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgsta52dec_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgsta52dec_la_CFLAGS) $(CFLAGS) -c -o libgsta52dec_la-gsta52dec.lo `test -f 'gsta52dec.c' || echo '$(srcdir)/'`gsta52dec.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(plugindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pluginLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pluginLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pluginLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/ext/a52dec/gsta52dec.c b/ext/a52dec/gsta52dec.c
new file mode 100644
index 0000000..f684721
--- /dev/null
+++ b/ext/a52dec/gsta52dec.c
@@ -0,0 +1,816 @@
+/* GStreamer
+ * Copyright (C) <2001> David I. Lehn <dlehn@users.sourceforge.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * SECTION:element-a52dec
+ *
+ * Dolby Digital (AC-3) audio decoder.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch dvdreadsrc title=1 ! mpegpsdemux ! a52dec ! audioresample ! audioconvert ! alsasink
+ * ]| Play audio track from a dvd.
+ * |[
+ * gst-launch filesrc location=abc.ac3 ! a52dec ! audioresample ! audioconvert ! alsasink
+ * ]| Decode a stand alone file and play it.
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#include <stdlib.h>
+#include "_stdint.h"
+
+#include <gst/gst.h>
+
+#include <a52dec/a52.h>
+#include <a52dec/mm_accel.h>
+#include "gsta52dec.h"
+
+#if HAVE_ORC
+#include <orc/orc.h>
+#endif
+
+#ifdef LIBA52_DOUBLE
+#define SAMPLE_WIDTH 64
+#define SAMPLE_FORMAT GST_AUDIO_NE(F64)
+#define SAMPLE_TYPE GST_AUDIO_FORMAT_F64
+#else
+#define SAMPLE_WIDTH 32
+#define SAMPLE_FORMAT GST_AUDIO_NE(F32)
+#define SAMPLE_TYPE GST_AUDIO_FORMAT_F32
+#endif
+
+GST_DEBUG_CATEGORY_STATIC (a52dec_debug);
+#define GST_CAT_DEFAULT (a52dec_debug)
+
+/* A52Dec args */
+enum
+{
+  ARG_0,
+  ARG_DRC,
+  ARG_MODE,
+  ARG_LFE,
+};
+
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-ac3; audio/ac3; audio/x-private1-ac3")
+    );
+
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " SAMPLE_FORMAT ", "
+        "layout = (string) interleaved, "
+        "rate = (int) [ 4000, 96000 ], " "channels = (int) [ 1, 6 ]")
+    );
+
+#define gst_a52dec_parent_class parent_class
+G_DEFINE_TYPE (GstA52Dec, gst_a52dec, GST_TYPE_AUDIO_DECODER);
+
+static gboolean gst_a52dec_start (GstAudioDecoder * dec);
+static gboolean gst_a52dec_stop (GstAudioDecoder * dec);
+static gboolean gst_a52dec_set_format (GstAudioDecoder * bdec, GstCaps * caps);
+static gboolean gst_a52dec_parse (GstAudioDecoder * dec, GstAdapter * adapter,
+    gint * offset, gint * length);
+static GstFlowReturn gst_a52dec_handle_frame (GstAudioDecoder * dec,
+    GstBuffer * buffer);
+
+static GstFlowReturn gst_a52dec_chain (GstPad * pad, GstObject * parent,
+    GstBuffer * buffer);
+static void gst_a52dec_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec);
+static void gst_a52dec_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec);
+
+#define GST_TYPE_A52DEC_MODE (gst_a52dec_mode_get_type())
+static GType
+gst_a52dec_mode_get_type (void)
+{
+  static GType a52dec_mode_type = 0;
+  static const GEnumValue a52dec_modes[] = {
+    {A52_MONO, "Mono", "mono"},
+    {A52_STEREO, "Stereo", "stereo"},
+    {A52_3F, "3 Front", "3f"},
+    {A52_2F1R, "2 Front, 1 Rear", "2f1r"},
+    {A52_3F1R, "3 Front, 1 Rear", "3f1r"},
+    {A52_2F2R, "2 Front, 2 Rear", "2f2r"},
+    {A52_3F2R, "3 Front, 2 Rear", "3f2r"},
+    {A52_DOLBY, "Dolby", "dolby"},
+    {0, NULL, NULL},
+  };
+
+  if (!a52dec_mode_type) {
+    a52dec_mode_type = g_enum_register_static ("GstA52DecMode", a52dec_modes);
+  }
+  return a52dec_mode_type;
+}
+
+static void
+gst_a52dec_class_init (GstA52DecClass * klass)
+{
+  GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
+  GstAudioDecoderClass *gstbase_class;
+  guint cpuflags;
+
+  gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
+  gstbase_class = (GstAudioDecoderClass *) klass;
+
+  gobject_class->set_property = gst_a52dec_set_property;
+  gobject_class->get_property = gst_a52dec_get_property;
+
+  gstbase_class->start = GST_DEBUG_FUNCPTR (gst_a52dec_start);
+  gstbase_class->stop = GST_DEBUG_FUNCPTR (gst_a52dec_stop);
+  gstbase_class->set_format = GST_DEBUG_FUNCPTR (gst_a52dec_set_format);
+  gstbase_class->parse = GST_DEBUG_FUNCPTR (gst_a52dec_parse);
+  gstbase_class->handle_frame = GST_DEBUG_FUNCPTR (gst_a52dec_handle_frame);
+
+  /**
+   * GstA52Dec::drc
+   *
+   * Set to true to apply the recommended Dolby Digital dynamic range compression
+   * to the audio stream. Dynamic range compression makes loud sounds
+   * softer and soft sounds louder, so you can more easily listen
+   * to the stream without disturbing other people.
+   */
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DRC,
+      g_param_spec_boolean ("drc", "Dynamic Range Compression",
+          "Use Dynamic Range Compression", FALSE,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /**
+   * GstA52Dec::mode
+   *
+   * Force a particular output channel configuration from the decoder. By default,
+   * the channel downmix (if any) is chosen automatically based on the downstream
+   * capabilities of the pipeline.
+   */
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MODE,
+      g_param_spec_enum ("mode", "Decoder Mode", "Decoding Mode (default 3f2r)",
+          GST_TYPE_A52DEC_MODE, A52_3F2R,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /**
+   * GstA52Dec::lfe
+   *
+   * Whether to output the LFE (Low Frequency Emitter) channel of the audio stream.
+   */
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LFE,
+      g_param_spec_boolean ("lfe", "LFE", "LFE", TRUE,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_factory));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_factory));
+  gst_element_class_set_static_metadata (gstelement_class,
+      "ATSC A/52 audio decoder", "Codec/Decoder/Audio",
+      "Decodes ATSC A/52 encoded audio streams",
+      "David I. Lehn <dlehn@users.sourceforge.net>");
+
+  GST_DEBUG_CATEGORY_INIT (a52dec_debug, "a52dec", 0,
+      "AC3/A52 software decoder");
+
+  /* If no CPU instruction based acceleration is available, end up using the
+   * generic software djbfft based one when available in the used liba52 */
+#ifdef MM_ACCEL_DJBFFT
+  klass->a52_cpuflags = MM_ACCEL_DJBFFT;
+#else
+  klass->a52_cpuflags = 0;
+#endif
+
+#if HAVE_ORC
+  cpuflags = orc_target_get_default_flags (orc_target_get_by_name ("mmx"));
+
+  if (cpuflags & ORC_TARGET_MMX_MMX)
+    klass->a52_cpuflags |= MM_ACCEL_X86_MMX;
+  if (cpuflags & ORC_TARGET_MMX_3DNOW)
+    klass->a52_cpuflags |= MM_ACCEL_X86_3DNOW;
+  if (cpuflags & ORC_TARGET_MMX_MMXEXT)
+    klass->a52_cpuflags |= MM_ACCEL_X86_MMXEXT;
+#else
+  cpuflags = 0;
+#endif
+
+  GST_LOG ("CPU flags: a52=%08x, liboil=%08x", klass->a52_cpuflags, cpuflags);
+}
+
+static void
+gst_a52dec_init (GstA52Dec * a52dec)
+{
+  a52dec->request_channels = A52_CHANNEL;
+  a52dec->dynamic_range_compression = FALSE;
+
+  a52dec->state = NULL;
+  a52dec->samples = NULL;
+
+  /* retrieve and intercept base class chain.
+   * Quite HACKish, but that's dvd specs/caps for you,
+   * since one buffer needs to be split into 2 frames */
+  a52dec->base_chain = GST_PAD_CHAINFUNC (GST_AUDIO_DECODER_SINK_PAD (a52dec));
+  gst_pad_set_chain_function (GST_AUDIO_DECODER_SINK_PAD (a52dec),
+      GST_DEBUG_FUNCPTR (gst_a52dec_chain));
+}
+
+static gboolean
+gst_a52dec_start (GstAudioDecoder * dec)
+{
+  GstA52Dec *a52dec = GST_A52DEC (dec);
+  GstA52DecClass *klass;
+
+  GST_DEBUG_OBJECT (dec, "start");
+
+  klass = GST_A52DEC_CLASS (G_OBJECT_GET_CLASS (a52dec));
+  a52dec->state = a52_init (klass->a52_cpuflags);
+
+  if (!a52dec->state) {
+    GST_ELEMENT_ERROR (GST_ELEMENT (a52dec), LIBRARY, INIT, (NULL),
+        ("failed to initialize a52 state"));
+    return FALSE;
+  }
+
+  a52dec->samples = a52_samples (a52dec->state);
+  a52dec->bit_rate = -1;
+  a52dec->sample_rate = -1;
+  a52dec->stream_channels = A52_CHANNEL;
+  a52dec->using_channels = A52_CHANNEL;
+  a52dec->level = 1;
+  a52dec->bias = 0;
+  a52dec->flag_update = TRUE;
+
+  /* call upon legacy upstream byte support (e.g. seeking) */
+  gst_audio_decoder_set_estimate_rate (dec, TRUE);
+
+  return TRUE;
+}
+
+static gboolean
+gst_a52dec_stop (GstAudioDecoder * dec)
+{
+  GstA52Dec *a52dec = GST_A52DEC (dec);
+
+  GST_DEBUG_OBJECT (dec, "stop");
+
+  a52dec->samples = NULL;
+  if (a52dec->state) {
+    a52_free (a52dec->state);
+    a52dec->state = NULL;
+  }
+
+  return TRUE;
+}
+
+static GstFlowReturn
+gst_a52dec_parse (GstAudioDecoder * bdec, GstAdapter * adapter,
+    gint * _offset, gint * len)
+{
+  GstA52Dec *a52dec;
+  const guint8 *data;
+  gint av, size;
+  gint length = 0, flags, sample_rate, bit_rate;
+  GstFlowReturn result = GST_FLOW_EOS;
+
+  a52dec = GST_A52DEC (bdec);
+
+  size = av = gst_adapter_available (adapter);
+  data = (const guint8 *) gst_adapter_map (adapter, av);
+
+  /* find and read header */
+  bit_rate = a52dec->bit_rate;
+  sample_rate = a52dec->sample_rate;
+  flags = 0;
+  while (size >= 7) {
+    length = a52_syncinfo ((guint8 *) data, &flags, &sample_rate, &bit_rate);
+
+    if (length == 0) {
+      /* shift window to re-find sync */
+      data++;
+      size--;
+    } else if (length <= size) {
+      GST_LOG_OBJECT (a52dec, "Sync: frame size %d", length);
+      result = GST_FLOW_OK;
+      break;
+    } else {
+      GST_LOG_OBJECT (a52dec, "Not enough data available (needed %d had %d)",
+          length, size);
+      break;
+    }
+  }
+  gst_adapter_unmap (adapter);
+
+  *_offset = av - size;
+  *len = length;
+
+  return result;
+}
+
+static gint
+gst_a52dec_channels (int flags, GstAudioChannelPosition * pos)
+{
+  gint chans = 0;
+
+  if (flags & A52_LFE) {
+    chans += 1;
+    if (pos) {
+      pos[0] = GST_AUDIO_CHANNEL_POSITION_LFE1;
+    }
+  }
+  flags &= A52_CHANNEL_MASK;
+  switch (flags) {
+    case A52_3F2R:
+      if (pos) {
+        pos[0 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
+        pos[1 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER;
+        pos[2 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
+        pos[3 + chans] = GST_AUDIO_CHANNEL_POSITION_REAR_LEFT;
+        pos[4 + chans] = GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT;
+      }
+      chans += 5;
+      break;
+    case A52_2F2R:
+      if (pos) {
+        pos[0 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
+        pos[1 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
+        pos[2 + chans] = GST_AUDIO_CHANNEL_POSITION_REAR_LEFT;
+        pos[3 + chans] = GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT;
+      }
+      chans += 4;
+      break;
+    case A52_3F1R:
+      if (pos) {
+        pos[0 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
+        pos[1 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER;
+        pos[2 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
+        pos[3 + chans] = GST_AUDIO_CHANNEL_POSITION_REAR_CENTER;
+      }
+      chans += 4;
+      break;
+    case A52_2F1R:
+      if (pos) {
+        pos[0 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
+        pos[1 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
+        pos[2 + chans] = GST_AUDIO_CHANNEL_POSITION_REAR_CENTER;
+      }
+      chans += 3;
+      break;
+    case A52_3F:
+      if (pos) {
+        pos[0 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
+        pos[1 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER;
+        pos[2 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
+      }
+      chans += 3;
+      break;
+    case A52_CHANNEL:          /* Dual mono. Should really be handled as 2 src pads */
+    case A52_STEREO:
+    case A52_DOLBY:
+      if (pos) {
+        pos[0 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
+        pos[1 + chans] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
+      }
+      chans += 2;
+      break;
+    case A52_MONO:
+      if (pos) {
+        pos[0 + chans] = GST_AUDIO_CHANNEL_POSITION_MONO;
+      }
+      chans += 1;
+      break;
+    default:
+      /* error, caller should post error message */
+      return 0;
+  }
+
+  return chans;
+}
+
+static gboolean
+gst_a52dec_reneg (GstA52Dec * a52dec)
+{
+  gint channels;
+  gboolean result = FALSE;
+  GstAudioChannelPosition from[6], to[6];
+  GstAudioInfo info;
+
+  channels = gst_a52dec_channels (a52dec->using_channels, from);
+
+  if (!channels)
+    goto done;
+
+  GST_INFO_OBJECT (a52dec, "reneg channels:%d rate:%d",
+      channels, a52dec->sample_rate);
+
+  memcpy (to, from, sizeof (GstAudioChannelPosition) * channels);
+  gst_audio_channel_positions_to_valid_order (to, channels);
+  gst_audio_get_channel_reorder_map (channels, from, to,
+      a52dec->channel_reorder_map);
+
+  gst_audio_info_init (&info);
+  gst_audio_info_set_format (&info,
+      SAMPLE_TYPE, a52dec->sample_rate, channels, (channels > 1 ? to : NULL));
+
+  if (!gst_audio_decoder_set_output_format (GST_AUDIO_DECODER (a52dec), &info))
+    goto done;
+
+  result = TRUE;
+
+done:
+  return result;
+}
+
+static void
+gst_a52dec_update_streaminfo (GstA52Dec * a52dec)
+{
+  GstTagList *taglist;
+
+  taglist = gst_tag_list_new_empty ();
+  gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_BITRATE,
+      (guint) a52dec->bit_rate, NULL);
+
+  gst_audio_decoder_merge_tags (GST_AUDIO_DECODER (a52dec), taglist,
+      GST_TAG_MERGE_REPLACE);
+  gst_tag_list_free (taglist);
+}
+
+static GstFlowReturn
+gst_a52dec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
+{
+  GstA52Dec *a52dec;
+  gint channels, i;
+  gboolean need_reneg = FALSE;
+  gint chans;
+  gint length = 0, flags, sample_rate, bit_rate;
+  GstMapInfo map;
+  GstFlowReturn result = GST_FLOW_OK;
+  GstBuffer *outbuf;
+  const gint num_blocks = 6;
+
+  a52dec = GST_A52DEC (bdec);
+
+  /* no fancy draining */
+  if (G_UNLIKELY (!buffer))
+    return GST_FLOW_OK;
+
+  /* parsed stuff already, so this should work out fine */
+  gst_buffer_map (buffer, &map, GST_MAP_READ);
+  g_assert (map.size >= 7);
+
+  /* re-obtain some sync header info,
+   * should be same as during _parse and could also be cached there,
+   * but anyway ... */
+  bit_rate = a52dec->bit_rate;
+  sample_rate = a52dec->sample_rate;
+  flags = 0;
+  length = a52_syncinfo (map.data, &flags, &sample_rate, &bit_rate);
+  g_assert (length == map.size);
+
+  /* update stream information, renegotiate or re-streaminfo if needed */
+  need_reneg = FALSE;
+  if (a52dec->sample_rate != sample_rate) {
+    need_reneg = TRUE;
+    a52dec->sample_rate = sample_rate;
+  }
+
+  if (flags) {
+    a52dec->stream_channels = flags & (A52_CHANNEL_MASK | A52_LFE);
+  }
+
+  if (bit_rate != a52dec->bit_rate) {
+    a52dec->bit_rate = bit_rate;
+    gst_a52dec_update_streaminfo (a52dec);
+  }
+
+  /* If we haven't had an explicit number of channels chosen through properties
+   * at this point, choose what to downmix to now, based on what the peer will
+   * accept - this allows a52dec to do downmixing in preference to a
+   * downstream element such as audioconvert.
+   */
+  if (a52dec->request_channels != A52_CHANNEL) {
+    flags = a52dec->request_channels;
+  } else if (a52dec->flag_update) {
+    GstCaps *caps;
+
+    a52dec->flag_update = FALSE;
+
+    caps = gst_pad_get_allowed_caps (GST_AUDIO_DECODER_SRC_PAD (a52dec));
+    if (caps && gst_caps_get_size (caps) > 0) {
+      GstCaps *copy = gst_caps_copy_nth (caps, 0);
+      GstStructure *structure = gst_caps_get_structure (copy, 0);
+      gint channels;
+      const int a52_channels[6] = {
+        A52_MONO,
+        A52_STEREO,
+        A52_STEREO | A52_LFE,
+        A52_2F2R,
+        A52_2F2R | A52_LFE,
+        A52_3F2R | A52_LFE,
+      };
+
+      /* Prefer the original number of channels, but fixate to something
+       * preferred (first in the caps) downstream if possible.
+       */
+      gst_structure_fixate_field_nearest_int (structure, "channels",
+          flags ? gst_a52dec_channels (flags, NULL) : 6);
+      if (gst_structure_get_int (structure, "channels", &channels)
+          && channels <= 6)
+        flags = a52_channels[channels - 1];
+      else
+        flags = a52_channels[5];
+
+      gst_caps_unref (copy);
+    } else if (flags)
+      flags = a52dec->stream_channels;
+    else
+      flags = A52_3F2R | A52_LFE;
+
+    if (caps)
+      gst_caps_unref (caps);
+  } else {
+    flags = a52dec->using_channels;
+  }
+
+  /* process */
+  flags |= A52_ADJUST_LEVEL;
+  a52dec->level = 1;
+  if (a52_frame (a52dec->state, map.data, &flags, &a52dec->level, a52dec->bias)) {
+    gst_buffer_unmap (buffer, &map);
+    GST_AUDIO_DECODER_ERROR (a52dec, 1, STREAM, DECODE, (NULL),
+        ("a52_frame error"), result);
+    goto exit;
+  }
+  gst_buffer_unmap (buffer, &map);
+
+  channels = flags & (A52_CHANNEL_MASK | A52_LFE);
+  if (a52dec->using_channels != channels) {
+    need_reneg = TRUE;
+    a52dec->using_channels = channels;
+  }
+
+  /* negotiate if required */
+  if (need_reneg) {
+    GST_DEBUG_OBJECT (a52dec,
+        "a52dec reneg: sample_rate:%d stream_chans:%d using_chans:%d",
+        a52dec->sample_rate, a52dec->stream_channels, a52dec->using_channels);
+    if (!gst_a52dec_reneg (a52dec))
+      goto failed_negotiation;
+  }
+
+  if (a52dec->dynamic_range_compression == FALSE) {
+    a52_dynrng (a52dec->state, NULL, NULL);
+  }
+
+  flags &= (A52_CHANNEL_MASK | A52_LFE);
+  chans = gst_a52dec_channels (flags, NULL);
+  if (!chans)
+    goto invalid_flags;
+
+  /* handle decoded data;
+   * each frame has 6 blocks, one block is 256 samples, ea */
+  outbuf =
+      gst_buffer_new_and_alloc (256 * chans * (SAMPLE_WIDTH / 8) * num_blocks);
+
+  gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
+  {
+    guint8 *ptr = map.data;
+    for (i = 0; i < num_blocks; i++) {
+      if (a52_block (a52dec->state)) {
+        /* also marks discont */
+        GST_AUDIO_DECODER_ERROR (a52dec, 1, STREAM, DECODE, (NULL),
+            ("error decoding block %d", i), result);
+        if (result != GST_FLOW_OK) {
+          gst_buffer_unmap (outbuf, &map);
+          goto exit;
+        }
+      } else {
+        gint n, c;
+        gint *reorder_map = a52dec->channel_reorder_map;
+
+        for (n = 0; n < 256; n++) {
+          for (c = 0; c < chans; c++) {
+            ((sample_t *) ptr)[n * chans + reorder_map[c]] =
+                a52dec->samples[c * 256 + n];
+          }
+        }
+      }
+      ptr += 256 * chans * (SAMPLE_WIDTH / 8);
+    }
+  }
+  gst_buffer_unmap (outbuf, &map);
+
+  result = gst_audio_decoder_finish_frame (bdec, outbuf, 1);
+
+exit:
+  return result;
+
+  /* ERRORS */
+failed_negotiation:
+  {
+    GST_ELEMENT_ERROR (a52dec, CORE, NEGOTIATION, (NULL), (NULL));
+    return GST_FLOW_ERROR;
+  }
+invalid_flags:
+  {
+    GST_ELEMENT_ERROR (GST_ELEMENT (a52dec), STREAM, DECODE, (NULL),
+        ("Invalid channel flags: %d", flags));
+    return GST_FLOW_ERROR;
+  }
+}
+
+static gboolean
+gst_a52dec_set_format (GstAudioDecoder * bdec, GstCaps * caps)
+{
+  GstA52Dec *a52dec = GST_A52DEC (bdec);
+  GstStructure *structure;
+
+  structure = gst_caps_get_structure (caps, 0);
+
+  if (structure && gst_structure_has_name (structure, "audio/x-private1-ac3"))
+    a52dec->dvdmode = TRUE;
+  else
+    a52dec->dvdmode = FALSE;
+
+  return TRUE;
+}
+
+static GstFlowReturn
+gst_a52dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
+{
+  GstA52Dec *a52dec = GST_A52DEC (parent);
+  GstFlowReturn ret = GST_FLOW_OK;
+  gint first_access;
+
+  if (a52dec->dvdmode) {
+    gsize size;
+    guint8 data[2];
+    gint offset;
+    gint len;
+    GstBuffer *subbuf;
+
+    size = gst_buffer_extract (buf, 0, data, 2);
+    if (size < 2)
+      goto not_enough_data;
+
+    first_access = (data[0] << 8) | data[1];
+
+    /* Skip the first_access header */
+    offset = 2;
+
+    if (first_access > 1) {
+      /* Length of data before first_access */
+      len = first_access - 1;
+
+      if (len <= 0 || offset + len > size)
+        goto bad_first_access_parameter;
+
+      subbuf = gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, offset, len);
+      GST_BUFFER_TIMESTAMP (subbuf) = GST_CLOCK_TIME_NONE;
+      ret = a52dec->base_chain (pad, parent, subbuf);
+      if (ret != GST_FLOW_OK) {
+        gst_buffer_unref (buf);
+        goto done;
+      }
+
+      offset += len;
+      len = size - offset;
+
+      if (len > 0) {
+        subbuf = gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, offset, len);
+        GST_BUFFER_TIMESTAMP (subbuf) = GST_BUFFER_TIMESTAMP (buf);
+
+        ret = a52dec->base_chain (pad, parent, subbuf);
+      }
+      gst_buffer_unref (buf);
+    } else {
+      /* first_access = 0 or 1, so if there's a timestamp it applies to the first byte */
+      subbuf =
+          gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, offset,
+          size - offset);
+      GST_BUFFER_TIMESTAMP (subbuf) = GST_BUFFER_TIMESTAMP (buf);
+      gst_buffer_unref (buf);
+      ret = a52dec->base_chain (pad, parent, subbuf);
+    }
+  } else {
+    ret = a52dec->base_chain (pad, parent, buf);
+  }
+
+done:
+  return ret;
+
+/* ERRORS */
+not_enough_data:
+  {
+    GST_ELEMENT_ERROR (GST_ELEMENT (a52dec), STREAM, DECODE, (NULL),
+        ("Insufficient data in buffer. Can't determine first_acess"));
+    gst_buffer_unref (buf);
+    return GST_FLOW_ERROR;
+  }
+bad_first_access_parameter:
+  {
+    GST_ELEMENT_ERROR (GST_ELEMENT (a52dec), STREAM, DECODE, (NULL),
+        ("Bad first_access parameter (%d) in buffer", first_access));
+    gst_buffer_unref (buf);
+    return GST_FLOW_ERROR;
+  }
+}
+
+static void
+gst_a52dec_set_property (GObject * object, guint prop_id, const GValue * value,
+    GParamSpec * pspec)
+{
+  GstA52Dec *src = GST_A52DEC (object);
+
+  switch (prop_id) {
+    case ARG_DRC:
+      GST_OBJECT_LOCK (src);
+      src->dynamic_range_compression = g_value_get_boolean (value);
+      GST_OBJECT_UNLOCK (src);
+      break;
+    case ARG_MODE:
+      GST_OBJECT_LOCK (src);
+      src->request_channels &= ~A52_CHANNEL_MASK;
+      src->request_channels |= g_value_get_enum (value);
+      GST_OBJECT_UNLOCK (src);
+      break;
+    case ARG_LFE:
+      GST_OBJECT_LOCK (src);
+      src->request_channels &= ~A52_LFE;
+      src->request_channels |= g_value_get_boolean (value) ? A52_LFE : 0;
+      GST_OBJECT_UNLOCK (src);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+gst_a52dec_get_property (GObject * object, guint prop_id, GValue * value,
+    GParamSpec * pspec)
+{
+  GstA52Dec *src = GST_A52DEC (object);
+
+  switch (prop_id) {
+    case ARG_DRC:
+      GST_OBJECT_LOCK (src);
+      g_value_set_boolean (value, src->dynamic_range_compression);
+      GST_OBJECT_UNLOCK (src);
+      break;
+    case ARG_MODE:
+      GST_OBJECT_LOCK (src);
+      g_value_set_enum (value, src->request_channels & A52_CHANNEL_MASK);
+      GST_OBJECT_UNLOCK (src);
+      break;
+    case ARG_LFE:
+      GST_OBJECT_LOCK (src);
+      g_value_set_boolean (value, src->request_channels & A52_LFE);
+      GST_OBJECT_UNLOCK (src);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+#if HAVE_ORC
+  orc_init ();
+#endif
+
+  if (!gst_element_register (plugin, "a52dec", GST_RANK_SECONDARY,
+          GST_TYPE_A52DEC))
+    return FALSE;
+
+  return TRUE;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    a52dec,
+    "Decodes ATSC A/52 encoded audio streams",
+    plugin_init, VERSION, "GPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
diff --git a/ext/a52dec/gsta52dec.h b/ext/a52dec/gsta52dec.h
new file mode 100644
index 0000000..3bb8131
--- /dev/null
+++ b/ext/a52dec/gsta52dec.h
@@ -0,0 +1,104 @@
+/* GStreamer
+ * Copyright (C) <2001> David I. Lehn <dlehn@users.sourceforge.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#ifndef __GST_A52DEC_H__
+#define __GST_A52DEC_H__
+
+#include <gst/gst.h>
+#include <gst/audio/audio.h>
+#include <gst/audio/gstaudiodecoder.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_A52DEC \
+  (gst_a52dec_get_type())
+#define GST_A52DEC(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_A52DEC,GstA52Dec))
+#define GST_A52DEC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_A52DEC,GstA52DecClass))
+#define GST_IS_A52DEC(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_A52DEC))
+#define GST_IS_A52DEC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_A52DEC))
+
+typedef struct _GstA52Dec GstA52Dec;
+typedef struct _GstA52DecClass GstA52DecClass;
+
+struct _GstA52Dec {
+  GstAudioDecoder element;
+
+  GstPadChainFunction base_chain;
+
+  gboolean       dvdmode;
+  gboolean       flag_update;
+  int            prev_flags;
+
+  /* stream properties */
+  int            bit_rate;
+  int            sample_rate;
+  int            stream_channels;
+  int            request_channels;
+  int            using_channels;
+
+  gint           channel_reorder_map[6];
+
+  sample_t       level;
+  sample_t       bias;
+  gboolean       dynamic_range_compression;
+  sample_t      *samples;
+  a52_state_t   *state;
+};
+
+struct _GstA52DecClass {
+  GstAudioDecoderClass parent_class;
+
+  guint32 a52_cpuflags;
+};
+
+GType gst_a52dec_get_type (void);
+
+#ifndef A52_MONO
+#define A52_MONO 1
+#endif
+#ifndef A52_STEREO
+#define A52_STEREO 2
+#endif
+#ifndef A52_3F
+#define A52_3F 3
+#endif
+#ifndef A52_2F1R
+#define A52_2F1R 4
+#endif
+#ifndef A52_3F1R
+#define A52_3F1R 5
+#endif
+#ifndef A52_2F2R
+#define A52_2F2R 6
+#endif
+#ifndef A52_3F2R
+#define A52_3F2R 7
+#endif
+#ifndef A52_DOLBY
+#define A52_DOLBY 10
+#endif
+
+G_END_DECLS
+
+#endif /* __GST_A52DEC_H__ */
diff --git a/ext/amrnb/GstAmrnbEnc.prs b/ext/amrnb/GstAmrnbEnc.prs
new file mode 100644
index 0000000..69e3719
--- /dev/null
+++ b/ext/amrnb/GstAmrnbEnc.prs
@@ -0,0 +1,11 @@
+[_presets_]
+version=0.10
+element-name=GstAmrnbEnc
+
+[enhance-size]
+_meta/comment=Maximize compression, lowest bitrate
+band-mode=0
+
+[enhance-quality]
+_meta/comment=Maximize quality, highest bitrate
+band-mode=7
diff --git a/ext/amrnb/Makefile.am b/ext/amrnb/Makefile.am
new file mode 100644
index 0000000..9379396
--- /dev/null
+++ b/ext/amrnb/Makefile.am
@@ -0,0 +1,23 @@
+plugin_LTLIBRARIES = libgstamrnb.la
+
+libgstamrnb_la_SOURCES = \
+	amrnb.c \
+	amrnbdec.c \
+	amrnbenc.c
+
+libgstamrnb_la_CFLAGS = -DGST_USE_UNSTABLE_API $(GST_PLUGINS_BASE_CFLAGS) \
+	$(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AMRNB_CFLAGS)
+libgstamrnb_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
+        -lgstaudio-@GST_API_VERSION@ \
+        $(GST_BASE_LIBS) $(GST_LIBS) $(AMRNB_LIBS)
+libgstamrnb_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstamrnb_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS = \
+	amrnbdec.h \
+	amrnbenc.h
+
+presetdir = $(datadir)/gstreamer-$(GST_API_VERSION)/presets
+preset_DATA = GstAmrnbEnc.prs
+
+EXTRA_DIST = $(preset_DATA)
diff --git a/ext/amrnb/Makefile.in b/ext/amrnb/Makefile.in
new file mode 100644
index 0000000..3ab7ff0
--- /dev/null
+++ b/ext/amrnb/Makefile.in
@@ -0,0 +1,803 @@
+# Makefile.in generated by automake 1.11.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+
+VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = ext/amrnb
+DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \
+	$(top_srcdir)/common/m4/as-auto-alt.m4 \
+	$(top_srcdir)/common/m4/as-compiler-flag.m4 \
+	$(top_srcdir)/common/m4/as-python.m4 \
+	$(top_srcdir)/common/m4/as-scrub-include.m4 \
+	$(top_srcdir)/common/m4/as-version.m4 \
+	$(top_srcdir)/common/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/common/m4/gst-arch.m4 \
+	$(top_srcdir)/common/m4/gst-args.m4 \
+	$(top_srcdir)/common/m4/gst-check.m4 \
+	$(top_srcdir)/common/m4/gst-default.m4 \
+	$(top_srcdir)/common/m4/gst-dowhile.m4 \
+	$(top_srcdir)/common/m4/gst-error.m4 \
+	$(top_srcdir)/common/m4/gst-feature.m4 \
+	$(top_srcdir)/common/m4/gst-function.m4 \
+	$(top_srcdir)/common/m4/gst-gettext.m4 \
+	$(top_srcdir)/common/m4/gst-glib2.m4 \
+	$(top_srcdir)/common/m4/gst-package-release-datetime.m4 \
+	$(top_srcdir)/common/m4/gst-plugin-docs.m4 \
+	$(top_srcdir)/common/m4/gst-plugindir.m4 \
+	$(top_srcdir)/common/m4/gst.m4 \
+	$(top_srcdir)/common/m4/gtk-doc.m4 \
+	$(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \
+	$(top_srcdir)/m4/a52.m4 $(top_srcdir)/m4/gettext.m4 \
+	$(top_srcdir)/m4/gst-sid.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+	$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(presetdir)"
+LTLIBRARIES = $(plugin_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libgstamrnb_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1)
+am_libgstamrnb_la_OBJECTS = libgstamrnb_la-amrnb.lo \
+	libgstamrnb_la-amrnbdec.lo libgstamrnb_la-amrnbenc.lo
+libgstamrnb_la_OBJECTS = $(am_libgstamrnb_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+libgstamrnb_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+	$(libgstamrnb_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+	$(CCLD) $(libgstamrnb_la_CFLAGS) $(CFLAGS) \
+	$(libgstamrnb_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libgstamrnb_la_SOURCES)
+DIST_SOURCES = $(libgstamrnb_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+DATA = $(preset_DATA)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+A52DEC_CFLAGS = @A52DEC_CFLAGS@
+A52DEC_LIBS = @A52DEC_LIBS@
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMRNB_CFLAGS = @AMRNB_CFLAGS@
+AMRNB_LIBS = @AMRNB_LIBS@
+AMRWB_CFLAGS = @AMRWB_CFLAGS@
+AMRWB_LIBS = @AMRWB_LIBS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CDIO_CFLAGS = @CDIO_CFLAGS@
+CDIO_LIBS = @CDIO_LIBS@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@
+DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@
+DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@
+DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@
+DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DVDREAD_LIBS = @DVDREAD_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+ERROR_CXXFLAGS = @ERROR_CXXFLAGS@
+EXEEXT = @EXEEXT@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+GCOV = @GCOV@
+GCOV_CFLAGS = @GCOV_CFLAGS@
+GCOV_LIBS = @GCOV_LIBS@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LDFLAGS = @GIO_LDFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_PREFIX = @GLIB_PREFIX@
+GLIB_REQ = @GLIB_REQ@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@
+GSTPB_PREFIX = @GSTPB_PREFIX@
+GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@
+GST_API_VERSION = @GST_API_VERSION@
+GST_BASE_CFLAGS = @GST_BASE_CFLAGS@
+GST_BASE_LIBS = @GST_BASE_LIBS@
+GST_CFLAGS = @GST_CFLAGS@
+GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@
+GST_CHECK_LIBS = @GST_CHECK_LIBS@
+GST_CXXFLAGS = @GST_CXXFLAGS@
+GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@
+GST_LIBS = @GST_LIBS@
+GST_LICENSE = @GST_LICENSE@
+GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@
+GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@
+GST_PACKAGE_NAME = @GST_PACKAGE_NAME@
+GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@
+GST_PLUGINS_ALL = @GST_PLUGINS_ALL@
+GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@
+GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@
+GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@
+GST_PLUGINS_DIR = @GST_PLUGINS_DIR@
+GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@
+GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GST_PREFIX = @GST_PREFIX@
+GST_TOOLS_DIR = @GST_TOOLS_DIR@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DVDREAD = @HAVE_DVDREAD@
+HAVE_LAME = @HAVE_LAME@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LAME_CFLAGS = @LAME_CFLAGS@
+LAME_LIBS = @LAME_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAD_CFLAGS = @MAD_CFLAGS@
+MAD_LIBS = @MAD_LIBS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MPEG2DEC_CFLAGS = @MPEG2DEC_CFLAGS@
+MPEG2DEC_LIBS = @MPEG2DEC_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ORCC = @ORCC@
+ORCC_FLAGS = @ORCC_FLAGS@
+ORC_CFLAGS = @ORC_CFLAGS@
+ORC_LIBS = @ORC_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@
+PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGINDIR = @PLUGINDIR@
+POSUB = @POSUB@
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIDPLAY_CFLAGS = @SIDPLAY_CFLAGS@
+SIDPLAY_LIBS = @SIDPLAY_LIBS@
+STRIP = @STRIP@
+TWOLAME_CFLAGS = @TWOLAME_CFLAGS@
+TWOLAME_LIBS = @TWOLAME_LIBS@
+USE_NLS = @USE_NLS@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VALGRIND_PATH = @VALGRIND_PATH@
+VERSION = @VERSION@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WIN32_LIBS = @WIN32_LIBS@
+X264_CFLAGS = @X264_CFLAGS@
+X264_LIBS = @X264_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+plugindir = @plugindir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+plugin_LTLIBRARIES = libgstamrnb.la
+libgstamrnb_la_SOURCES = \
+	amrnb.c \
+	amrnbdec.c \
+	amrnbenc.c
+
+libgstamrnb_la_CFLAGS = -DGST_USE_UNSTABLE_API $(GST_PLUGINS_BASE_CFLAGS) \
+	$(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AMRNB_CFLAGS)
+
+libgstamrnb_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
+        -lgstaudio-@GST_API_VERSION@ \
+        $(GST_BASE_LIBS) $(GST_LIBS) $(AMRNB_LIBS)
+
+libgstamrnb_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstamrnb_la_LIBTOOLFLAGS = --tag=disable-static
+noinst_HEADERS = \
+	amrnbdec.h \
+	amrnbenc.h
+
+presetdir = $(datadir)/gstreamer-$(GST_API_VERSION)/presets
+preset_DATA = GstAmrnbEnc.prs
+EXTRA_DIST = $(preset_DATA)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/amrnb/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu ext/amrnb/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \
+	  $(MKDIR_P) '$(DESTDIR)$(plugindir)' || exit 1; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+	}
+
+uninstall-pluginLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+	done
+
+clean-pluginLTLIBRARIES:
+	-test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+	@list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libgstamrnb.la: $(libgstamrnb_la_OBJECTS) $(libgstamrnb_la_DEPENDENCIES) $(EXTRA_libgstamrnb_la_DEPENDENCIES) 
+	$(AM_V_CCLD)$(libgstamrnb_la_LINK) -rpath $(plugindir) $(libgstamrnb_la_OBJECTS) $(libgstamrnb_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstamrnb_la-amrnb.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstamrnb_la-amrnbdec.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstamrnb_la-amrnbenc.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+libgstamrnb_la-amrnb.lo: amrnb.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstamrnb_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstamrnb_la_CFLAGS) $(CFLAGS) -MT libgstamrnb_la-amrnb.lo -MD -MP -MF $(DEPDIR)/libgstamrnb_la-amrnb.Tpo -c -o libgstamrnb_la-amrnb.lo `test -f 'amrnb.c' || echo '$(srcdir)/'`amrnb.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgstamrnb_la-amrnb.Tpo $(DEPDIR)/libgstamrnb_la-amrnb.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='amrnb.c' object='libgstamrnb_la-amrnb.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstamrnb_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstamrnb_la_CFLAGS) $(CFLAGS) -c -o libgstamrnb_la-amrnb.lo `test -f 'amrnb.c' || echo '$(srcdir)/'`amrnb.c
+
+libgstamrnb_la-amrnbdec.lo: amrnbdec.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstamrnb_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstamrnb_la_CFLAGS) $(CFLAGS) -MT libgstamrnb_la-amrnbdec.lo -MD -MP -MF $(DEPDIR)/libgstamrnb_la-amrnbdec.Tpo -c -o libgstamrnb_la-amrnbdec.lo `test -f 'amrnbdec.c' || echo '$(srcdir)/'`amrnbdec.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgstamrnb_la-amrnbdec.Tpo $(DEPDIR)/libgstamrnb_la-amrnbdec.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='amrnbdec.c' object='libgstamrnb_la-amrnbdec.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstamrnb_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstamrnb_la_CFLAGS) $(CFLAGS) -c -o libgstamrnb_la-amrnbdec.lo `test -f 'amrnbdec.c' || echo '$(srcdir)/'`amrnbdec.c
+
+libgstamrnb_la-amrnbenc.lo: amrnbenc.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstamrnb_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstamrnb_la_CFLAGS) $(CFLAGS) -MT libgstamrnb_la-amrnbenc.lo -MD -MP -MF $(DEPDIR)/libgstamrnb_la-amrnbenc.Tpo -c -o libgstamrnb_la-amrnbenc.lo `test -f 'amrnbenc.c' || echo '$(srcdir)/'`amrnbenc.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgstamrnb_la-amrnbenc.Tpo $(DEPDIR)/libgstamrnb_la-amrnbenc.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='amrnbenc.c' object='libgstamrnb_la-amrnbenc.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstamrnb_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstamrnb_la_CFLAGS) $(CFLAGS) -c -o libgstamrnb_la-amrnbenc.lo `test -f 'amrnbenc.c' || echo '$(srcdir)/'`amrnbenc.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-presetDATA: $(preset_DATA)
+	@$(NORMAL_INSTALL)
+	@list='$(preset_DATA)'; test -n "$(presetdir)" || list=; \
+	if test -n "$$list"; then \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(presetdir)'"; \
+	  $(MKDIR_P) '$(DESTDIR)$(presetdir)' || exit 1; \
+	fi; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(presetdir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(presetdir)" || exit $$?; \
+	done
+
+uninstall-presetDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(preset_DATA)'; test -n "$(presetdir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	dir='$(DESTDIR)$(presetdir)'; $(am__uninstall_files_from_dir)
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(presetdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES install-presetDATA
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES uninstall-presetDATA
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pluginLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pluginLTLIBRARIES \
+	install-presetDATA install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pluginLTLIBRARIES \
+	uninstall-presetDATA
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/ext/amrnb/README b/ext/amrnb/README
new file mode 100644
index 0000000..879dbe7
--- /dev/null
+++ b/ext/amrnb/README
@@ -0,0 +1,6 @@
+Compiling AMRNB:
+================
+
+To compile the amrnb plugin, you need the opencore-amrnb development package.
+If your distribution does not provide this package, you can download the 
+source code from "http://sourceforge.net/projects/opencore-amr".
diff --git a/ext/amrnb/amrnb.c b/ext/amrnb/amrnb.c
new file mode 100644
index 0000000..e7e8b4a
--- /dev/null
+++ b/ext/amrnb/amrnb.c
@@ -0,0 +1,42 @@
+/* GStreamer Adaptive Multi-Rate Narrow-Band (AMR-NB) plugin
+ * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "amrnbdec.h"
+#include "amrnbenc.h"
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  return gst_element_register (plugin, "amrnbdec",
+      GST_RANK_PRIMARY, GST_TYPE_AMRNBDEC) &&
+      gst_element_register (plugin, "amrnbenc",
+      GST_RANK_SECONDARY, GST_TYPE_AMRNBENC);
+}
+
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    amrnb,
+    "Adaptive Multi-Rate Narrow-Band",
+    plugin_init, VERSION, GST_LICENSE_UNKNOWN, GST_PACKAGE_NAME,
+    GST_PACKAGE_ORIGIN);
diff --git a/ext/amrnb/amrnbdec.c b/ext/amrnb/amrnbdec.c
new file mode 100644
index 0000000..d70ab47
--- /dev/null
+++ b/ext/amrnb/amrnbdec.c
@@ -0,0 +1,316 @@
+/* GStreamer Adaptive Multi-Rate Narrow-Band (AMR-NB) plugin
+ * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * SECTION:element-amrnbdec
+ * @see_also: #GstAmrnbEnc, #GstAmrParse
+ *
+ * AMR narrowband decoder based on the 
+ * <ulink url="http://sourceforge.net/projects/opencore-amr">opencore codec implementation</ulink>.
+ * 
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch filesrc location=abc.amr ! amrparse ! amrnbdec ! audioresample ! audioconvert ! alsasink
+ * ]|
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "amrnbdec.h"
+
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/AMR, " "rate = (int) 8000, " "channels = (int) 1")
+    );
+
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw, format = (string) " GST_AUDIO_NE (S16) ", "
+        "layout = (string) interleaved, "
+        "rate = (int) 8000," "channels = (int) 1")
+    );
+
+GST_DEBUG_CATEGORY_STATIC (gst_amrnbdec_debug);
+#define GST_CAT_DEFAULT gst_amrnbdec_debug
+
+static const gint block_size_if1[16] = { 12, 13, 15, 17, 19, 20, 26, 31, 5,
+  0, 0, 0, 0, 0, 0, 0
+};
+
+static const gint block_size_if2[16] = { 12, 13, 15, 17, 18, 20, 25, 30, 5,
+  0, 0, 0, 0, 0, 0, 0
+};
+
+static GType
+gst_amrnb_variant_get_type (void)
+{
+  static GType gst_amrnb_variant_type = 0;
+  static const GEnumValue gst_amrnb_variant[] = {
+    {GST_AMRNB_VARIANT_IF1, "IF1", "IF1"},
+    {GST_AMRNB_VARIANT_IF2, "IF2", "IF2"},
+    {0, NULL, NULL},
+  };
+  if (!gst_amrnb_variant_type) {
+    gst_amrnb_variant_type =
+        g_enum_register_static ("GstAmrnbVariant", gst_amrnb_variant);
+  }
+  return gst_amrnb_variant_type;
+}
+
+#define GST_AMRNB_VARIANT_TYPE (gst_amrnb_variant_get_type())
+
+#define VARIANT_DEFAULT GST_AMRNB_VARIANT_IF1
+enum
+{
+  PROP_0,
+  PROP_VARIANT
+};
+
+static void gst_amrnbdec_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec);
+static void gst_amrnbdec_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec);
+
+static gboolean gst_amrnbdec_start (GstAudioDecoder * dec);
+static gboolean gst_amrnbdec_stop (GstAudioDecoder * dec);
+static gboolean gst_amrnbdec_set_format (GstAudioDecoder * dec, GstCaps * caps);
+static gboolean gst_amrnbdec_parse (GstAudioDecoder * dec, GstAdapter * adapter,
+    gint * offset, gint * length);
+static GstFlowReturn gst_amrnbdec_handle_frame (GstAudioDecoder * dec,
+    GstBuffer * buffer);
+
+#define gst_amrnbdec_parent_class parent_class
+G_DEFINE_TYPE (GstAmrnbDec, gst_amrnbdec, GST_TYPE_AUDIO_DECODER);
+
+static void
+gst_amrnbdec_class_init (GstAmrnbDecClass * klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstAudioDecoderClass *base_class = GST_AUDIO_DECODER_CLASS (klass);
+
+  object_class->set_property = gst_amrnbdec_set_property;
+  object_class->get_property = gst_amrnbdec_get_property;
+
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&sink_template));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&src_template));
+
+  gst_element_class_set_static_metadata (element_class, "AMR-NB audio decoder",
+      "Codec/Decoder/Audio",
+      "Adaptive Multi-Rate Narrow-Band audio decoder",
+      "GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
+
+  base_class->start = GST_DEBUG_FUNCPTR (gst_amrnbdec_start);
+  base_class->stop = GST_DEBUG_FUNCPTR (gst_amrnbdec_stop);
+  base_class->set_format = GST_DEBUG_FUNCPTR (gst_amrnbdec_set_format);
+  base_class->parse = GST_DEBUG_FUNCPTR (gst_amrnbdec_parse);
+  base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_amrnbdec_handle_frame);
+
+  g_object_class_install_property (object_class, PROP_VARIANT,
+      g_param_spec_enum ("variant", "Variant",
+          "The decoder variant", GST_AMRNB_VARIANT_TYPE,
+          VARIANT_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+  GST_DEBUG_CATEGORY_INIT (gst_amrnbdec_debug, "amrnbdec", 0,
+      "AMR-NB audio decoder");
+}
+
+static void
+gst_amrnbdec_init (GstAmrnbDec * amrnbdec)
+{
+}
+
+static gboolean
+gst_amrnbdec_start (GstAudioDecoder * dec)
+{
+  GstAmrnbDec *amrnbdec = GST_AMRNBDEC (dec);
+
+  GST_DEBUG_OBJECT (dec, "start");
+  if (!(amrnbdec->handle = Decoder_Interface_init ()))
+    return FALSE;
+
+  amrnbdec->rate = 0;
+  amrnbdec->channels = 0;
+
+  return TRUE;
+}
+
+static gboolean
+gst_amrnbdec_stop (GstAudioDecoder * dec)
+{
+  GstAmrnbDec *amrnbdec = GST_AMRNBDEC (dec);
+
+  GST_DEBUG_OBJECT (dec, "stop");
+  Decoder_Interface_exit (amrnbdec->handle);
+
+  return TRUE;
+}
+
+static void
+gst_amrnbdec_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec)
+{
+  GstAmrnbDec *self = GST_AMRNBDEC (object);
+
+  switch (prop_id) {
+    case PROP_VARIANT:
+      self->variant = g_value_get_enum (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+  return;
+}
+
+static void
+gst_amrnbdec_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec)
+{
+  GstAmrnbDec *self = GST_AMRNBDEC (object);
+
+  switch (prop_id) {
+    case PROP_VARIANT:
+      g_value_set_enum (value, self->variant);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+  return;
+}
+
+static gboolean
+gst_amrnbdec_set_format (GstAudioDecoder * dec, GstCaps * caps)
+{
+  GstStructure *structure;
+  GstAmrnbDec *amrnbdec;
+  GstAudioInfo info;
+
+  amrnbdec = GST_AMRNBDEC (dec);
+
+  structure = gst_caps_get_structure (caps, 0);
+
+  /* get channel count */
+  gst_structure_get_int (structure, "channels", &amrnbdec->channels);
+  gst_structure_get_int (structure, "rate", &amrnbdec->rate);
+
+  /* create reverse caps */
+  gst_audio_info_init (&info);
+  gst_audio_info_set_format (&info,
+      GST_AUDIO_FORMAT_S16, amrnbdec->rate, amrnbdec->channels, NULL);
+
+  return gst_audio_decoder_set_output_format (dec, &info);
+}
+
+static GstFlowReturn
+gst_amrnbdec_parse (GstAudioDecoder * dec, GstAdapter * adapter,
+    gint * offset, gint * length)
+{
+  GstAmrnbDec *amrnbdec = GST_AMRNBDEC (dec);
+  guint8 head[1];
+  guint size;
+  gboolean sync, eos;
+  gint block, mode;
+
+  size = gst_adapter_available (adapter);
+  g_return_val_if_fail (size > 0, GST_FLOW_ERROR);
+
+  gst_audio_decoder_get_parse_state (dec, &sync, &eos);
+
+  /* need to peek data to get the size */
+  if (size < 1)
+    return GST_FLOW_ERROR;
+
+  gst_adapter_copy (adapter, head, 0, 1);
+
+  /* get size */
+  switch (amrnbdec->variant) {
+    case GST_AMRNB_VARIANT_IF1:
+      mode = (head[0] >> 3) & 0x0F;
+      block = block_size_if1[mode] + 1;
+      break;
+    case GST_AMRNB_VARIANT_IF2:
+      mode = head[0] & 0x0F;
+      block = block_size_if2[mode] + 1;
+      break;
+    default:
+      g_assert_not_reached ();
+      return GST_FLOW_ERROR;
+      break;
+  }
+
+  GST_DEBUG_OBJECT (amrnbdec, "mode %d, block %d", mode, block);
+
+  if (block > size)
+    return GST_FLOW_EOS;
+
+  *offset = 0;
+  *length = block;
+
+  return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_amrnbdec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
+{
+  GstAmrnbDec *amrnbdec;
+  GstMapInfo inmap, outmap;
+  GstBuffer *out;
+
+  amrnbdec = GST_AMRNBDEC (dec);
+
+  /* no fancy flushing */
+  if (!buffer || !gst_buffer_get_size (buffer))
+    return GST_FLOW_OK;
+
+  if (amrnbdec->rate == 0 || amrnbdec->channels == 0)
+    goto not_negotiated;
+
+  gst_buffer_map (buffer, &inmap, GST_MAP_READ);
+
+  /* get output */
+  out = gst_buffer_new_and_alloc (160 * 2);
+  /* decode */
+  gst_buffer_map (out, &outmap, GST_MAP_WRITE);
+  Decoder_Interface_Decode (amrnbdec->handle, inmap.data,
+      (gint16 *) outmap.data, 0);
+  gst_buffer_unmap (out, &outmap);
+
+  gst_buffer_unmap (buffer, &inmap);
+
+  return gst_audio_decoder_finish_frame (dec, out, 1);
+
+  /* ERRORS */
+not_negotiated:
+  {
+    GST_ELEMENT_ERROR (amrnbdec, STREAM, TYPE_NOT_FOUND, (NULL),
+        ("Decoder is not initialized"));
+    return GST_FLOW_NOT_NEGOTIATED;
+  }
+}
diff --git a/ext/amrnb/amrnbdec.h b/ext/amrnb/amrnbdec.h
new file mode 100644
index 0000000..5fe6982
--- /dev/null
+++ b/ext/amrnb/amrnbdec.h
@@ -0,0 +1,74 @@
+/* GStreamer Adaptive Multi-Rate Narrow-Band (AMR-NB) plugin
+ * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_AMRNBDEC_H__
+#define __GST_AMRNBDEC_H__
+
+#include <gst/gst.h>
+#include <gst/audio/gstaudiodecoder.h>
+
+#ifdef HAVE_OPENCORE_AMRNB_0_1_3_OR_LATER
+#include <opencore-amrnb/interf_dec.h>
+#else
+#include <interf_dec.h>
+#endif
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_AMRNBDEC \
+  (gst_amrnbdec_get_type())
+#define GST_AMRNBDEC(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_AMRNBDEC, GstAmrnbDec))
+#define GST_AMRNBDEC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_AMRNBDEC, GstAmrnbDecClass))
+#define GST_IS_AMRNBDEC(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_AMRNBDEC))
+#define GST_IS_AMRNBDEC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_AMRNBDEC))
+
+typedef struct _GstAmrnbDec GstAmrnbDec;
+typedef struct _GstAmrnbDecClass GstAmrnbDecClass;
+
+typedef enum
+{
+  GST_AMRNB_VARIANT_IF1,
+  GST_AMRNB_VARIANT_IF2
+} GstAmrnbVariant;
+
+struct _GstAmrnbDec {
+  GstAudioDecoder element;
+
+  GstAmrnbVariant variant;
+
+  /* library handle */
+  void *handle;
+
+  /* output settings */
+  gint channels, rate;
+};
+
+struct _GstAmrnbDecClass {
+  GstAudioDecoderClass parent_class;
+};
+
+GType gst_amrnbdec_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_AMRNBDEC_H__ */
diff --git a/ext/amrnb/amrnbenc.c b/ext/amrnb/amrnbenc.c
new file mode 100644
index 0000000..a0390b5
--- /dev/null
+++ b/ext/amrnb/amrnbenc.c
@@ -0,0 +1,292 @@
+/* GStreamer Adaptive Multi-Rate Narrow-Band (AMR-NB) plugin
+ * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * SECTION:element-amrnbenc
+ * @see_also: #GstAmrnbDec, #GstAmrnbParse
+ *
+ * AMR narrowband encoder based on the 
+ * <ulink url="http://sourceforge.net/projects/opencore-amr">opencore codec implementation</ulink>.
+ * 
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch filesrc location=abc.wav ! wavparse ! audioresample ! audioconvert ! amrnbenc ! filesink location=abc.amr
+ * ]|
+ * Please note that the above stream misses the header, that is needed to play
+ * the stream.
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "amrnbenc.h"
+
+static GType
+gst_amrnbenc_bandmode_get_type (void)
+{
+  static GType gst_amrnbenc_bandmode_type = 0;
+  static const GEnumValue gst_amrnbenc_bandmode[] = {
+    {MR475, "MR475", "MR475"},
+    {MR515, "MR515", "MR515"},
+    {MR59, "MR59", "MR59"},
+    {MR67, "MR67", "MR67"},
+    {MR74, "MR74", "MR74"},
+    {MR795, "MR795", "MR795"},
+    {MR102, "MR102", "MR102"},
+    {MR122, "MR122", "MR122"},
+    {MRDTX, "MRDTX", "MRDTX"},
+    {0, NULL, NULL},
+  };
+  if (!gst_amrnbenc_bandmode_type) {
+    gst_amrnbenc_bandmode_type =
+        g_enum_register_static ("GstAmrnbEncBandMode", gst_amrnbenc_bandmode);
+  }
+  return gst_amrnbenc_bandmode_type;
+}
+
+#define GST_AMRNBENC_BANDMODE_TYPE (gst_amrnbenc_bandmode_get_type())
+
+#define BANDMODE_DEFAULT MR122
+enum
+{
+  PROP_0,
+  PROP_BANDMODE
+};
+
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw, format = (string) " GST_AUDIO_NE (S16) ", "
+        "layout = (string) interleaved, "
+        "rate = (int) 8000," "channels = (int) 1")
+    );
+
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/AMR, " "rate = (int) 8000, " "channels = (int) 1")
+    );
+
+GST_DEBUG_CATEGORY_STATIC (gst_amrnbenc_debug);
+#define GST_CAT_DEFAULT gst_amrnbenc_debug
+
+static gboolean gst_amrnbenc_start (GstAudioEncoder * enc);
+static gboolean gst_amrnbenc_stop (GstAudioEncoder * enc);
+static gboolean gst_amrnbenc_set_format (GstAudioEncoder * enc,
+    GstAudioInfo * info);
+static GstFlowReturn gst_amrnbenc_handle_frame (GstAudioEncoder * enc,
+    GstBuffer * in_buf);
+
+#define gst_amrnbenc_parent_class parent_class
+G_DEFINE_TYPE (GstAmrnbEnc, gst_amrnbenc, GST_TYPE_AUDIO_ENCODER);
+
+static void
+gst_amrnbenc_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec)
+{
+  GstAmrnbEnc *self = GST_AMRNBENC (object);
+
+  switch (prop_id) {
+    case PROP_BANDMODE:
+      self->bandmode = g_value_get_enum (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+  return;
+}
+
+static void
+gst_amrnbenc_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec)
+{
+  GstAmrnbEnc *self = GST_AMRNBENC (object);
+
+  switch (prop_id) {
+    case PROP_BANDMODE:
+      g_value_set_enum (value, self->bandmode);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+  return;
+}
+
+static void
+gst_amrnbenc_class_init (GstAmrnbEncClass * klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstAudioEncoderClass *base_class = GST_AUDIO_ENCODER_CLASS (klass);
+
+  object_class->set_property = gst_amrnbenc_set_property;
+  object_class->get_property = gst_amrnbenc_get_property;
+
+  base_class->start = GST_DEBUG_FUNCPTR (gst_amrnbenc_start);
+  base_class->stop = GST_DEBUG_FUNCPTR (gst_amrnbenc_stop);
+  base_class->set_format = GST_DEBUG_FUNCPTR (gst_amrnbenc_set_format);
+  base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_amrnbenc_handle_frame);
+
+  g_object_class_install_property (object_class, PROP_BANDMODE,
+      g_param_spec_enum ("band-mode", "Band Mode",
+          "Encoding Band Mode (Kbps)", GST_AMRNBENC_BANDMODE_TYPE,
+          BANDMODE_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&sink_template));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&src_template));
+
+  gst_element_class_set_static_metadata (element_class, "AMR-NB audio encoder",
+      "Codec/Encoder/Audio",
+      "Adaptive Multi-Rate Narrow-Band audio encoder",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
+  GST_DEBUG_CATEGORY_INIT (gst_amrnbenc_debug, "amrnbenc", 0,
+      "AMR-NB audio encoder");
+}
+
+static void
+gst_amrnbenc_init (GstAmrnbEnc * amrnbenc)
+{
+}
+
+static gboolean
+gst_amrnbenc_start (GstAudioEncoder * enc)
+{
+  GstAmrnbEnc *amrnbenc = GST_AMRNBENC (enc);
+
+  GST_DEBUG_OBJECT (amrnbenc, "start");
+
+  if (!(amrnbenc->handle = Encoder_Interface_init (0)))
+    return FALSE;
+
+  return TRUE;
+}
+
+static gboolean
+gst_amrnbenc_stop (GstAudioEncoder * enc)
+{
+  GstAmrnbEnc *amrnbenc = GST_AMRNBENC (enc);
+
+  GST_DEBUG_OBJECT (amrnbenc, "stop");
+
+  Encoder_Interface_exit (amrnbenc->handle);
+
+  return TRUE;
+}
+
+static gboolean
+gst_amrnbenc_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
+{
+  GstAmrnbEnc *amrnbenc;
+  GstCaps *copy;
+
+  amrnbenc = GST_AMRNBENC (enc);
+
+  /* parameters already parsed for us */
+  amrnbenc->rate = GST_AUDIO_INFO_RATE (info);
+  amrnbenc->channels = GST_AUDIO_INFO_CHANNELS (info);
+
+  /* we do not really accept other input, but anyway ... */
+  /* this is not wrong but will sound bad */
+  if (amrnbenc->channels != 1) {
+    g_warning ("amrnbdec is only optimized for mono channels");
+  }
+  if (amrnbenc->rate != 8000) {
+    g_warning ("amrnbdec is only optimized for 8000 Hz samplerate");
+  }
+
+  /* create reverse caps */
+  copy = gst_caps_new_simple ("audio/AMR",
+      "channels", G_TYPE_INT, amrnbenc->channels,
+      "rate", G_TYPE_INT, amrnbenc->rate, NULL);
+
+  gst_audio_encoder_set_output_format (GST_AUDIO_ENCODER (amrnbenc), copy);
+  gst_caps_unref (copy);
+
+  /* report needs to base class: hand one frame at a time */
+  gst_audio_encoder_set_frame_samples_min (enc, 160);
+  gst_audio_encoder_set_frame_samples_max (enc, 160);
+  gst_audio_encoder_set_frame_max (enc, 1);
+
+  return TRUE;
+}
+
+static GstFlowReturn
+gst_amrnbenc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
+{
+  GstAmrnbEnc *amrnbenc;
+  GstFlowReturn ret;
+  GstBuffer *out;
+  GstMapInfo in_map, out_map;
+  gsize out_size;
+
+  amrnbenc = GST_AMRNBENC (enc);
+
+  g_return_val_if_fail (amrnbenc->handle, GST_FLOW_FLUSHING);
+
+  /* we don't deal with squeezing remnants, so simply discard those */
+  if (G_UNLIKELY (buffer == NULL)) {
+    GST_DEBUG_OBJECT (amrnbenc, "no data");
+    return GST_FLOW_OK;
+  }
+
+  gst_buffer_map (buffer, &in_map, GST_MAP_READ);
+
+  if (G_UNLIKELY (in_map.size < 320)) {
+    gst_buffer_unmap (buffer, &in_map);
+    GST_DEBUG_OBJECT (amrnbenc, "discarding trailing data of %" G_GSIZE_FORMAT
+        " bytes", in_map.size);
+    return gst_audio_encoder_finish_frame (enc, NULL, -1);
+  }
+
+  /* get output, max size is 32 */
+  out = gst_buffer_new_and_alloc (32);
+  /* AMR encoder actually writes into the source data buffers it gets */
+  /* should be able to handle that with what we are given */
+
+  gst_buffer_map (out, &out_map, GST_MAP_WRITE);
+  /* encode */
+  out_size =
+      Encoder_Interface_Encode (amrnbenc->handle, amrnbenc->bandmode,
+      (short *) in_map.data, out_map.data, 0);
+  gst_buffer_unmap (out, &out_map);
+  gst_buffer_resize (out, 0, out_size);
+  gst_buffer_unmap (buffer, &in_map);
+
+  GST_LOG_OBJECT (amrnbenc, "output data size %" G_GSIZE_FORMAT, out_size);
+
+  if (out_size) {
+    ret = gst_audio_encoder_finish_frame (enc, out, 160);
+  } else {
+    /* should not happen (without dtx or so at least) */
+    GST_WARNING_OBJECT (amrnbenc, "no encoded data; discarding input");
+    gst_buffer_unref (out);
+    ret = gst_audio_encoder_finish_frame (enc, NULL, -1);
+  }
+
+  return ret;
+}
diff --git a/ext/amrnb/amrnbenc.h b/ext/amrnb/amrnbenc.h
new file mode 100644
index 0000000..48a8fe8
--- /dev/null
+++ b/ext/amrnb/amrnbenc.h
@@ -0,0 +1,70 @@
+/* GStreamer Adaptive Multi-Rate Narrow-Band (AMR-NB) plugin
+ * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_AMRNBENC_H__
+#define __GST_AMRNBENC_H__
+
+#include <gst/gst.h>
+#include <gst/audio/gstaudioencoder.h>
+
+#ifdef HAVE_OPENCORE_AMRNB_0_1_3_OR_LATER
+#include <opencore-amrnb/interf_enc.h>
+#else
+#include <interf_enc.h>
+#endif
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_AMRNBENC \
+  (gst_amrnbenc_get_type())
+#define GST_AMRNBENC(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_AMRNBENC, GstAmrnbEnc))
+#define GST_AMRNBENC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_AMRNBENC, GstAmrnbEncClass))
+#define GST_IS_AMRNBENC(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_AMRNBENC))
+#define GST_IS_AMRNBENC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_AMRNBENC))
+
+typedef struct _GstAmrnbEnc GstAmrnbEnc;
+typedef struct _GstAmrnbEncClass GstAmrnbEncClass;
+
+struct _GstAmrnbEnc {
+  GstAudioEncoder element;
+
+  /* library handle */
+  void *handle;
+
+  /* input settings */
+  gint channels, rate;
+  gint duration;
+
+  /* property */
+  enum Mode bandmode;
+};
+
+struct _GstAmrnbEncClass {
+  GstAudioEncoderClass parent_class;
+};
+
+GType gst_amrnbenc_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_AMRNBENC_H__ */
diff --git a/ext/amrwbdec/Makefile.am b/ext/amrwbdec/Makefile.am
new file mode 100644
index 0000000..64b6e6a
--- /dev/null
+++ b/ext/amrwbdec/Makefile.am
@@ -0,0 +1,17 @@
+plugin_LTLIBRARIES = libgstamrwbdec.la
+
+libgstamrwbdec_la_SOURCES = \
+	amrwb.c \
+	amrwbdec.c
+
+libgstamrwbdec_la_CFLAGS = -DGST_USE_UNSTABLE_API $(GST_PLUGINS_BASE_CFLAGS) \
+	$(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AMRWB_CFLAGS)
+libgstamrwbdec_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
+	$(GST_BASE_LIBS) \
+	-lgstaudio-@GST_API_VERSION@ \
+	$(GST_LIBS) $(AMRWB_LIBS)
+libgstamrwbdec_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstamrwbdec_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS = \
+	amrwbdec.h
diff --git a/ext/amrwbdec/Makefile.in b/ext/amrwbdec/Makefile.in
new file mode 100644
index 0000000..7d94aa9
--- /dev/null
+++ b/ext/amrwbdec/Makefile.in
@@ -0,0 +1,767 @@
+# Makefile.in generated by automake 1.11.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = ext/amrwbdec
+DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \
+	$(top_srcdir)/common/m4/as-auto-alt.m4 \
+	$(top_srcdir)/common/m4/as-compiler-flag.m4 \
+	$(top_srcdir)/common/m4/as-python.m4 \
+	$(top_srcdir)/common/m4/as-scrub-include.m4 \
+	$(top_srcdir)/common/m4/as-version.m4 \
+	$(top_srcdir)/common/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/common/m4/gst-arch.m4 \
+	$(top_srcdir)/common/m4/gst-args.m4 \
+	$(top_srcdir)/common/m4/gst-check.m4 \
+	$(top_srcdir)/common/m4/gst-default.m4 \
+	$(top_srcdir)/common/m4/gst-dowhile.m4 \
+	$(top_srcdir)/common/m4/gst-error.m4 \
+	$(top_srcdir)/common/m4/gst-feature.m4 \
+	$(top_srcdir)/common/m4/gst-function.m4 \
+	$(top_srcdir)/common/m4/gst-gettext.m4 \
+	$(top_srcdir)/common/m4/gst-glib2.m4 \
+	$(top_srcdir)/common/m4/gst-package-release-datetime.m4 \
+	$(top_srcdir)/common/m4/gst-plugin-docs.m4 \
+	$(top_srcdir)/common/m4/gst-plugindir.m4 \
+	$(top_srcdir)/common/m4/gst.m4 \
+	$(top_srcdir)/common/m4/gtk-doc.m4 \
+	$(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \
+	$(top_srcdir)/m4/a52.m4 $(top_srcdir)/m4/gettext.m4 \
+	$(top_srcdir)/m4/gst-sid.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+	$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(plugindir)"
+LTLIBRARIES = $(plugin_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libgstamrwbdec_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1)
+am_libgstamrwbdec_la_OBJECTS = libgstamrwbdec_la-amrwb.lo \
+	libgstamrwbdec_la-amrwbdec.lo
+libgstamrwbdec_la_OBJECTS = $(am_libgstamrwbdec_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+libgstamrwbdec_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+	$(libgstamrwbdec_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+	$(CCLD) $(libgstamrwbdec_la_CFLAGS) $(CFLAGS) \
+	$(libgstamrwbdec_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libgstamrwbdec_la_SOURCES)
+DIST_SOURCES = $(libgstamrwbdec_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+A52DEC_CFLAGS = @A52DEC_CFLAGS@
+A52DEC_LIBS = @A52DEC_LIBS@
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMRNB_CFLAGS = @AMRNB_CFLAGS@
+AMRNB_LIBS = @AMRNB_LIBS@
+AMRWB_CFLAGS = @AMRWB_CFLAGS@
+AMRWB_LIBS = @AMRWB_LIBS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CDIO_CFLAGS = @CDIO_CFLAGS@
+CDIO_LIBS = @CDIO_LIBS@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@
+DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@
+DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@
+DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@
+DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DVDREAD_LIBS = @DVDREAD_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+ERROR_CXXFLAGS = @ERROR_CXXFLAGS@
+EXEEXT = @EXEEXT@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+GCOV = @GCOV@
+GCOV_CFLAGS = @GCOV_CFLAGS@
+GCOV_LIBS = @GCOV_LIBS@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LDFLAGS = @GIO_LDFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_PREFIX = @GLIB_PREFIX@
+GLIB_REQ = @GLIB_REQ@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@
+GSTPB_PREFIX = @GSTPB_PREFIX@
+GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@
+GST_API_VERSION = @GST_API_VERSION@
+GST_BASE_CFLAGS = @GST_BASE_CFLAGS@
+GST_BASE_LIBS = @GST_BASE_LIBS@
+GST_CFLAGS = @GST_CFLAGS@
+GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@
+GST_CHECK_LIBS = @GST_CHECK_LIBS@
+GST_CXXFLAGS = @GST_CXXFLAGS@
+GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@
+GST_LIBS = @GST_LIBS@
+GST_LICENSE = @GST_LICENSE@
+GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@
+GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@
+GST_PACKAGE_NAME = @GST_PACKAGE_NAME@
+GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@
+GST_PLUGINS_ALL = @GST_PLUGINS_ALL@
+GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@
+GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@
+GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@
+GST_PLUGINS_DIR = @GST_PLUGINS_DIR@
+GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@
+GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GST_PREFIX = @GST_PREFIX@
+GST_TOOLS_DIR = @GST_TOOLS_DIR@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DVDREAD = @HAVE_DVDREAD@
+HAVE_LAME = @HAVE_LAME@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LAME_CFLAGS = @LAME_CFLAGS@
+LAME_LIBS = @LAME_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAD_CFLAGS = @MAD_CFLAGS@
+MAD_LIBS = @MAD_LIBS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MPEG2DEC_CFLAGS = @MPEG2DEC_CFLAGS@
+MPEG2DEC_LIBS = @MPEG2DEC_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ORCC = @ORCC@
+ORCC_FLAGS = @ORCC_FLAGS@
+ORC_CFLAGS = @ORC_CFLAGS@
+ORC_LIBS = @ORC_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@
+PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGINDIR = @PLUGINDIR@
+POSUB = @POSUB@
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIDPLAY_CFLAGS = @SIDPLAY_CFLAGS@
+SIDPLAY_LIBS = @SIDPLAY_LIBS@
+STRIP = @STRIP@
+TWOLAME_CFLAGS = @TWOLAME_CFLAGS@
+TWOLAME_LIBS = @TWOLAME_LIBS@
+USE_NLS = @USE_NLS@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VALGRIND_PATH = @VALGRIND_PATH@
+VERSION = @VERSION@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WIN32_LIBS = @WIN32_LIBS@
+X264_CFLAGS = @X264_CFLAGS@
+X264_LIBS = @X264_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+plugindir = @plugindir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+plugin_LTLIBRARIES = libgstamrwbdec.la
+libgstamrwbdec_la_SOURCES = \
+	amrwb.c \
+	amrwbdec.c
+
+libgstamrwbdec_la_CFLAGS = -DGST_USE_UNSTABLE_API $(GST_PLUGINS_BASE_CFLAGS) \
+	$(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AMRWB_CFLAGS)
+
+libgstamrwbdec_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
+	$(GST_BASE_LIBS) \
+	-lgstaudio-@GST_API_VERSION@ \
+	$(GST_LIBS) $(AMRWB_LIBS)
+
+libgstamrwbdec_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstamrwbdec_la_LIBTOOLFLAGS = --tag=disable-static
+noinst_HEADERS = \
+	amrwbdec.h
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/amrwbdec/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu ext/amrwbdec/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \
+	  $(MKDIR_P) '$(DESTDIR)$(plugindir)' || exit 1; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+	}
+
+uninstall-pluginLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+	done
+
+clean-pluginLTLIBRARIES:
+	-test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+	@list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libgstamrwbdec.la: $(libgstamrwbdec_la_OBJECTS) $(libgstamrwbdec_la_DEPENDENCIES) $(EXTRA_libgstamrwbdec_la_DEPENDENCIES) 
+	$(AM_V_CCLD)$(libgstamrwbdec_la_LINK) -rpath $(plugindir) $(libgstamrwbdec_la_OBJECTS) $(libgstamrwbdec_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstamrwbdec_la-amrwb.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstamrwbdec_la-amrwbdec.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+libgstamrwbdec_la-amrwb.lo: amrwb.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstamrwbdec_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstamrwbdec_la_CFLAGS) $(CFLAGS) -MT libgstamrwbdec_la-amrwb.lo -MD -MP -MF $(DEPDIR)/libgstamrwbdec_la-amrwb.Tpo -c -o libgstamrwbdec_la-amrwb.lo `test -f 'amrwb.c' || echo '$(srcdir)/'`amrwb.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgstamrwbdec_la-amrwb.Tpo $(DEPDIR)/libgstamrwbdec_la-amrwb.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='amrwb.c' object='libgstamrwbdec_la-amrwb.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstamrwbdec_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstamrwbdec_la_CFLAGS) $(CFLAGS) -c -o libgstamrwbdec_la-amrwb.lo `test -f 'amrwb.c' || echo '$(srcdir)/'`amrwb.c
+
+libgstamrwbdec_la-amrwbdec.lo: amrwbdec.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstamrwbdec_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstamrwbdec_la_CFLAGS) $(CFLAGS) -MT libgstamrwbdec_la-amrwbdec.lo -MD -MP -MF $(DEPDIR)/libgstamrwbdec_la-amrwbdec.Tpo -c -o libgstamrwbdec_la-amrwbdec.lo `test -f 'amrwbdec.c' || echo '$(srcdir)/'`amrwbdec.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgstamrwbdec_la-amrwbdec.Tpo $(DEPDIR)/libgstamrwbdec_la-amrwbdec.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='amrwbdec.c' object='libgstamrwbdec_la-amrwbdec.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstamrwbdec_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstamrwbdec_la_CFLAGS) $(CFLAGS) -c -o libgstamrwbdec_la-amrwbdec.lo `test -f 'amrwbdec.c' || echo '$(srcdir)/'`amrwbdec.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(plugindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pluginLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pluginLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pluginLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/ext/amrwbdec/README b/ext/amrwbdec/README
new file mode 100644
index 0000000..835adef
--- /dev/null
+++ b/ext/amrwbdec/README
@@ -0,0 +1,6 @@
+Compiling AMRWB decoder:
+========================
+
+To compile the amrwbdec plugin, you need the opencore-amrwb development
+package. If your distribution does not provide this package, you can
+download the source code from "http://sourceforge.net/projects/opencore-amr".
diff --git a/ext/amrwbdec/amrwb.c b/ext/amrwbdec/amrwb.c
new file mode 100644
index 0000000..362b306
--- /dev/null
+++ b/ext/amrwbdec/amrwb.c
@@ -0,0 +1,39 @@
+/* GStreamer Adaptive Multi-Rate Wide-Band (AMR-WB) Decoder plugin
+ * Copyright (C) 2006 Edgard Lima <edgard.lima@indt.org.br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "amrwbdec.h"
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  return gst_element_register (plugin, "amrwbdec",
+      GST_RANK_PRIMARY, GST_TYPE_AMRWBDEC);
+}
+
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    amrwbdec,
+    "Adaptive Multi-Rate Wide-Band Decoder",
+    plugin_init, VERSION, GST_LICENSE_UNKNOWN, GST_PACKAGE_NAME,
+    GST_PACKAGE_ORIGIN);
diff --git a/ext/amrwbdec/amrwbdec.c b/ext/amrwbdec/amrwbdec.c
new file mode 100644
index 0000000..67bd070
--- /dev/null
+++ b/ext/amrwbdec/amrwbdec.c
@@ -0,0 +1,243 @@
+/* GStreamer Adaptive Multi-Rate Narrow-Band (AMR-NB) plugin
+ * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * SECTION:element-amrwbdec
+ * @see_also: #GstAmrwbEnc
+ *
+ * AMR wideband decoder based on the 
+ * <ulink url="http://sourceforge.net/projects/opencore-amr">opencore codec implementation</ulink>.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch filesrc location=abc.amr ! amrparse ! amrwbdec ! audioresample ! audioconvert ! alsasink
+ * ]|
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/audio/audio.h>
+
+#include "amrwbdec.h"
+
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/AMR-WB, "
+        "rate = (int) 16000, " "channels = (int) 1")
+    );
+
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " GST_AUDIO_NE (S16) ", "
+        "layout = (string) interleaved, "
+        "rate = (int) 16000, " "channels = (int) 1")
+    );
+
+GST_DEBUG_CATEGORY_STATIC (gst_amrwbdec_debug);
+#define GST_CAT_DEFAULT gst_amrwbdec_debug
+
+#define L_FRAME16k      320     /* Frame size at 16kHz  */
+
+static const unsigned char block_size[16] =
+    { 18, 24, 33, 37, 41, 47, 51, 59, 61,
+  6, 0, 0, 0, 0, 1, 1
+};
+
+static gboolean gst_amrwbdec_start (GstAudioDecoder * dec);
+static gboolean gst_amrwbdec_stop (GstAudioDecoder * dec);
+static gboolean gst_amrwbdec_set_format (GstAudioDecoder * dec, GstCaps * caps);
+static gboolean gst_amrwbdec_parse (GstAudioDecoder * dec, GstAdapter * adapter,
+    gint * offset, gint * length);
+static GstFlowReturn gst_amrwbdec_handle_frame (GstAudioDecoder * dec,
+    GstBuffer * buffer);
+
+#define gst_amrwbdec_parent_class parent_class
+G_DEFINE_TYPE (GstAmrwbDec, gst_amrwbdec, GST_TYPE_AUDIO_DECODER);
+
+static void
+gst_amrwbdec_class_init (GstAmrwbDecClass * klass)
+{
+  GstAudioDecoderClass *base_class = GST_AUDIO_DECODER_CLASS (klass);
+  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&sink_template));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&src_template));
+
+  gst_element_class_set_static_metadata (element_class, "AMR-WB audio decoder",
+      "Codec/Decoder/Audio",
+      "Adaptive Multi-Rate Wideband audio decoder",
+      "Renato Araujo <renato.filho@indt.org.br>");
+
+  base_class->start = GST_DEBUG_FUNCPTR (gst_amrwbdec_start);
+  base_class->stop = GST_DEBUG_FUNCPTR (gst_amrwbdec_stop);
+  base_class->set_format = GST_DEBUG_FUNCPTR (gst_amrwbdec_set_format);
+  base_class->parse = GST_DEBUG_FUNCPTR (gst_amrwbdec_parse);
+  base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_amrwbdec_handle_frame);
+
+  GST_DEBUG_CATEGORY_INIT (gst_amrwbdec_debug, "amrwbdec", 0,
+      "AMR-WB audio decoder");
+}
+
+static void
+gst_amrwbdec_init (GstAmrwbDec * amrwbdec)
+{
+}
+
+static gboolean
+gst_amrwbdec_start (GstAudioDecoder * dec)
+{
+  GstAmrwbDec *amrwbdec = GST_AMRWBDEC (dec);
+
+  GST_DEBUG_OBJECT (dec, "start");
+  if (!(amrwbdec->handle = D_IF_init ()))
+    return FALSE;
+
+  amrwbdec->rate = 0;
+  amrwbdec->channels = 0;
+
+  return TRUE;
+}
+
+static gboolean
+gst_amrwbdec_stop (GstAudioDecoder * dec)
+{
+  GstAmrwbDec *amrwbdec = GST_AMRWBDEC (dec);
+
+  GST_DEBUG_OBJECT (dec, "stop");
+  D_IF_exit (amrwbdec->handle);
+
+  return TRUE;
+}
+
+static gboolean
+gst_amrwbdec_set_format (GstAudioDecoder * dec, GstCaps * caps)
+{
+  GstStructure *structure;
+  GstAmrwbDec *amrwbdec;
+  GstAudioInfo info;
+
+  amrwbdec = GST_AMRWBDEC (dec);
+
+  structure = gst_caps_get_structure (caps, 0);
+
+  /* get channel count */
+  gst_structure_get_int (structure, "channels", &amrwbdec->channels);
+  gst_structure_get_int (structure, "rate", &amrwbdec->rate);
+
+  /* create reverse caps */
+  gst_audio_info_init (&info);
+  gst_audio_info_set_format (&info,
+      GST_AUDIO_FORMAT_S16, amrwbdec->rate, amrwbdec->channels, NULL);
+
+  gst_audio_decoder_set_output_format (dec, &info);
+
+  return TRUE;
+}
+
+static GstFlowReturn
+gst_amrwbdec_parse (GstAudioDecoder * dec, GstAdapter * adapter,
+    gint * offset, gint * length)
+{
+  GstAmrwbDec *amrwbdec = GST_AMRWBDEC (dec);
+  guint8 header[1];
+  guint size;
+  gboolean sync, eos;
+  gint block, mode;
+
+  size = gst_adapter_available (adapter);
+  g_return_val_if_fail (size > 0, GST_FLOW_ERROR);
+
+  gst_audio_decoder_get_parse_state (dec, &sync, &eos);
+
+  /* need to peek data to get the size */
+  if (size < 1)
+    return GST_FLOW_ERROR;
+
+  gst_adapter_copy (adapter, header, 0, 1);
+  mode = (header[0] >> 3) & 0x0F;
+  block = block_size[mode];
+
+  GST_DEBUG_OBJECT (amrwbdec, "mode %d, block %d", mode, block);
+
+  if (block) {
+    if (block > size)
+      return GST_FLOW_EOS;
+    *offset = 0;
+    *length = block;
+  } else {
+    /* no frame yet, skip one byte */
+    GST_LOG_OBJECT (amrwbdec, "skipping byte");
+    *offset = 1;
+    return GST_FLOW_EOS;
+  }
+
+  return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_amrwbdec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
+{
+  GstAmrwbDec *amrwbdec;
+  GstBuffer *out;
+  GstMapInfo inmap, outmap;
+
+  amrwbdec = GST_AMRWBDEC (dec);
+
+  /* no fancy flushing */
+  if (!buffer || !gst_buffer_get_size (buffer))
+    return GST_FLOW_OK;
+
+  if (amrwbdec->rate == 0 || amrwbdec->channels == 0)
+    goto not_negotiated;
+
+  /* the library seems to write into the source data, hence the copy. */
+  /* should be no problem */
+  gst_buffer_map (buffer, &inmap, GST_MAP_READ);
+
+  /* get output */
+  out = gst_buffer_new_and_alloc (sizeof (gint16) * L_FRAME16k);
+  gst_buffer_map (out, &outmap, GST_MAP_WRITE);
+
+  /* decode */
+  D_IF_decode (amrwbdec->handle, (unsigned char *) inmap.data,
+      (short int *) outmap.data, _good_frame);
+
+  gst_buffer_unmap (out, &outmap);
+  gst_buffer_unmap (buffer, &inmap);
+
+  /* send out */
+  return gst_audio_decoder_finish_frame (dec, out, 1);
+
+  /* ERRORS */
+not_negotiated:
+  {
+    GST_ELEMENT_ERROR (amrwbdec, STREAM, TYPE_NOT_FOUND, (NULL),
+        ("Decoder is not initialized"));
+    return GST_FLOW_NOT_NEGOTIATED;
+  }
+}
diff --git a/ext/amrwbdec/amrwbdec.h b/ext/amrwbdec/amrwbdec.h
new file mode 100644
index 0000000..6b82ae9
--- /dev/null
+++ b/ext/amrwbdec/amrwbdec.h
@@ -0,0 +1,73 @@
+/* GStreamer Adaptive Multi-Rate Wide-Band (AMR-WB) plugin
+ * Copyright (C) 2006 Edgard Lima <edgard.lima@indt.org.br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_AMRWBDEC_H__
+#define __GST_AMRWBDEC_H__
+
+#include <gst/gst.h>
+#include <gst/audio/gstaudiodecoder.h>
+
+#ifdef HAVE_OPENCORE_AMRWB_0_1_3_OR_LATER
+#include <opencore-amrwb/dec_if.h>
+#include <opencore-amrwb/if_rom.h>
+#else
+#include <dec_if.h>
+#include <if_rom.h>
+#endif
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_AMRWBDEC			\
+  (gst_amrwbdec_get_type())
+#define GST_AMRWBDEC(obj)						\
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_AMRWBDEC, GstAmrwbDec))
+#define GST_AMRWBDEC_CLASS(klass)					\
+  (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_AMRWBDEC, GstAmrwbDecClass))
+#define GST_IS_AMRWBDEC(obj)					\
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_AMRWBDEC))
+#define GST_IS_AMRWBDEC_CLASS(klass)			\
+  (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_AMRWBDEC))
+
+typedef struct _GstAmrwbDec GstAmrwbDec;
+typedef struct _GstAmrwbDecClass GstAmrwbDecClass;
+
+/**
+ * GstAmrwbDec:
+ *
+ * Opaque data structure.
+ */
+struct _GstAmrwbDec {
+  GstAudioDecoder element;
+
+  /* library handle */
+  void *handle;
+
+  /* output settings */
+  gint channels, rate;
+};
+
+struct _GstAmrwbDecClass {
+  GstAudioDecoderClass parent_class;
+};
+
+GType gst_amrwbdec_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_AMRWBDEC_H__ */
diff --git a/ext/cdio/Makefile.am b/ext/cdio/Makefile.am
new file mode 100644
index 0000000..8ad13c3
--- /dev/null
+++ b/ext/cdio/Makefile.am
@@ -0,0 +1,23 @@
+plugin_LTLIBRARIES = libgstcdio.la
+
+libgstcdio_la_SOURCES = \
+	gstcdio.c \
+	gstcdiocddasrc.c
+
+libgstcdio_la_CFLAGS = \
+	$(GST_PLUGINS_BASE_CFLAGS) \
+	$(GST_BASE_CFLAGS) \
+	$(GST_CFLAGS) \
+	$(CDIO_CFLAGS)
+
+libgstcdio_la_LIBADD = \
+	$(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_API_VERSION) \
+	$(GST_BASE_LIBS) \
+	$(CDIO_LIBS)
+
+libgstcdio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) 
+libgstcdio_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS = \
+	gstcdio.h \
+	gstcdiocddasrc.h
diff --git a/ext/cdio/Makefile.in b/ext/cdio/Makefile.in
new file mode 100644
index 0000000..1437e71
--- /dev/null
+++ b/ext/cdio/Makefile.in
@@ -0,0 +1,770 @@
+# Makefile.in generated by automake 1.11.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = ext/cdio
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \
+	$(top_srcdir)/common/m4/as-auto-alt.m4 \
+	$(top_srcdir)/common/m4/as-compiler-flag.m4 \
+	$(top_srcdir)/common/m4/as-python.m4 \
+	$(top_srcdir)/common/m4/as-scrub-include.m4 \
+	$(top_srcdir)/common/m4/as-version.m4 \
+	$(top_srcdir)/common/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/common/m4/gst-arch.m4 \
+	$(top_srcdir)/common/m4/gst-args.m4 \
+	$(top_srcdir)/common/m4/gst-check.m4 \
+	$(top_srcdir)/common/m4/gst-default.m4 \
+	$(top_srcdir)/common/m4/gst-dowhile.m4 \
+	$(top_srcdir)/common/m4/gst-error.m4 \
+	$(top_srcdir)/common/m4/gst-feature.m4 \
+	$(top_srcdir)/common/m4/gst-function.m4 \
+	$(top_srcdir)/common/m4/gst-gettext.m4 \
+	$(top_srcdir)/common/m4/gst-glib2.m4 \
+	$(top_srcdir)/common/m4/gst-package-release-datetime.m4 \
+	$(top_srcdir)/common/m4/gst-plugin-docs.m4 \
+	$(top_srcdir)/common/m4/gst-plugindir.m4 \
+	$(top_srcdir)/common/m4/gst.m4 \
+	$(top_srcdir)/common/m4/gtk-doc.m4 \
+	$(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \
+	$(top_srcdir)/m4/a52.m4 $(top_srcdir)/m4/gettext.m4 \
+	$(top_srcdir)/m4/gst-sid.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+	$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(plugindir)"
+LTLIBRARIES = $(plugin_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libgstcdio_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am_libgstcdio_la_OBJECTS = libgstcdio_la-gstcdio.lo \
+	libgstcdio_la-gstcdiocddasrc.lo
+libgstcdio_la_OBJECTS = $(am_libgstcdio_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+libgstcdio_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+	$(libgstcdio_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+	$(CCLD) $(libgstcdio_la_CFLAGS) $(CFLAGS) \
+	$(libgstcdio_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libgstcdio_la_SOURCES)
+DIST_SOURCES = $(libgstcdio_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+A52DEC_CFLAGS = @A52DEC_CFLAGS@
+A52DEC_LIBS = @A52DEC_LIBS@
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMRNB_CFLAGS = @AMRNB_CFLAGS@
+AMRNB_LIBS = @AMRNB_LIBS@
+AMRWB_CFLAGS = @AMRWB_CFLAGS@
+AMRWB_LIBS = @AMRWB_LIBS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CDIO_CFLAGS = @CDIO_CFLAGS@
+CDIO_LIBS = @CDIO_LIBS@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@
+DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@
+DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@
+DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@
+DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DVDREAD_LIBS = @DVDREAD_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+ERROR_CXXFLAGS = @ERROR_CXXFLAGS@
+EXEEXT = @EXEEXT@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+GCOV = @GCOV@
+GCOV_CFLAGS = @GCOV_CFLAGS@
+GCOV_LIBS = @GCOV_LIBS@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LDFLAGS = @GIO_LDFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_PREFIX = @GLIB_PREFIX@
+GLIB_REQ = @GLIB_REQ@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@
+GSTPB_PREFIX = @GSTPB_PREFIX@
+GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@
+GST_API_VERSION = @GST_API_VERSION@
+GST_BASE_CFLAGS = @GST_BASE_CFLAGS@
+GST_BASE_LIBS = @GST_BASE_LIBS@
+GST_CFLAGS = @GST_CFLAGS@
+GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@
+GST_CHECK_LIBS = @GST_CHECK_LIBS@
+GST_CXXFLAGS = @GST_CXXFLAGS@
+GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@
+GST_LIBS = @GST_LIBS@
+GST_LICENSE = @GST_LICENSE@
+GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@
+GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@
+GST_PACKAGE_NAME = @GST_PACKAGE_NAME@
+GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@
+GST_PLUGINS_ALL = @GST_PLUGINS_ALL@
+GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@
+GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@
+GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@
+GST_PLUGINS_DIR = @GST_PLUGINS_DIR@
+GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@
+GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GST_PREFIX = @GST_PREFIX@
+GST_TOOLS_DIR = @GST_TOOLS_DIR@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DVDREAD = @HAVE_DVDREAD@
+HAVE_LAME = @HAVE_LAME@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LAME_CFLAGS = @LAME_CFLAGS@
+LAME_LIBS = @LAME_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAD_CFLAGS = @MAD_CFLAGS@
+MAD_LIBS = @MAD_LIBS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MPEG2DEC_CFLAGS = @MPEG2DEC_CFLAGS@
+MPEG2DEC_LIBS = @MPEG2DEC_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ORCC = @ORCC@
+ORCC_FLAGS = @ORCC_FLAGS@
+ORC_CFLAGS = @ORC_CFLAGS@
+ORC_LIBS = @ORC_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@
+PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGINDIR = @PLUGINDIR@
+POSUB = @POSUB@
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIDPLAY_CFLAGS = @SIDPLAY_CFLAGS@
+SIDPLAY_LIBS = @SIDPLAY_LIBS@
+STRIP = @STRIP@
+TWOLAME_CFLAGS = @TWOLAME_CFLAGS@
+TWOLAME_LIBS = @TWOLAME_LIBS@
+USE_NLS = @USE_NLS@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VALGRIND_PATH = @VALGRIND_PATH@
+VERSION = @VERSION@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WIN32_LIBS = @WIN32_LIBS@
+X264_CFLAGS = @X264_CFLAGS@
+X264_LIBS = @X264_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+plugindir = @plugindir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+plugin_LTLIBRARIES = libgstcdio.la
+libgstcdio_la_SOURCES = \
+	gstcdio.c \
+	gstcdiocddasrc.c
+
+libgstcdio_la_CFLAGS = \
+	$(GST_PLUGINS_BASE_CFLAGS) \
+	$(GST_BASE_CFLAGS) \
+	$(GST_CFLAGS) \
+	$(CDIO_CFLAGS)
+
+libgstcdio_la_LIBADD = \
+	$(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_API_VERSION) \
+	$(GST_BASE_LIBS) \
+	$(CDIO_LIBS)
+
+libgstcdio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) 
+libgstcdio_la_LIBTOOLFLAGS = --tag=disable-static
+noinst_HEADERS = \
+	gstcdio.h \
+	gstcdiocddasrc.h
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/cdio/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu ext/cdio/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \
+	  $(MKDIR_P) '$(DESTDIR)$(plugindir)' || exit 1; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+	}
+
+uninstall-pluginLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+	done
+
+clean-pluginLTLIBRARIES:
+	-test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+	@list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libgstcdio.la: $(libgstcdio_la_OBJECTS) $(libgstcdio_la_DEPENDENCIES) $(EXTRA_libgstcdio_la_DEPENDENCIES) 
+	$(AM_V_CCLD)$(libgstcdio_la_LINK) -rpath $(plugindir) $(libgstcdio_la_OBJECTS) $(libgstcdio_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstcdio_la-gstcdio.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstcdio_la-gstcdiocddasrc.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+libgstcdio_la-gstcdio.lo: gstcdio.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstcdio_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstcdio_la_CFLAGS) $(CFLAGS) -MT libgstcdio_la-gstcdio.lo -MD -MP -MF $(DEPDIR)/libgstcdio_la-gstcdio.Tpo -c -o libgstcdio_la-gstcdio.lo `test -f 'gstcdio.c' || echo '$(srcdir)/'`gstcdio.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgstcdio_la-gstcdio.Tpo $(DEPDIR)/libgstcdio_la-gstcdio.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gstcdio.c' object='libgstcdio_la-gstcdio.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstcdio_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstcdio_la_CFLAGS) $(CFLAGS) -c -o libgstcdio_la-gstcdio.lo `test -f 'gstcdio.c' || echo '$(srcdir)/'`gstcdio.c
+
+libgstcdio_la-gstcdiocddasrc.lo: gstcdiocddasrc.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstcdio_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstcdio_la_CFLAGS) $(CFLAGS) -MT libgstcdio_la-gstcdiocddasrc.lo -MD -MP -MF $(DEPDIR)/libgstcdio_la-gstcdiocddasrc.Tpo -c -o libgstcdio_la-gstcdiocddasrc.lo `test -f 'gstcdiocddasrc.c' || echo '$(srcdir)/'`gstcdiocddasrc.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgstcdio_la-gstcdiocddasrc.Tpo $(DEPDIR)/libgstcdio_la-gstcdiocddasrc.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gstcdiocddasrc.c' object='libgstcdio_la-gstcdiocddasrc.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstcdio_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstcdio_la_CFLAGS) $(CFLAGS) -c -o libgstcdio_la-gstcdiocddasrc.lo `test -f 'gstcdiocddasrc.c' || echo '$(srcdir)/'`gstcdiocddasrc.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(plugindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pluginLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pluginLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pluginLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/ext/cdio/gstcdio.c b/ext/cdio/gstcdio.c
new file mode 100644
index 0000000..2f58d18
--- /dev/null
+++ b/ext/cdio/gstcdio.c
@@ -0,0 +1,124 @@
+/* GStreamer
+ * Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstcdio.h"
+#include "gstcdiocddasrc.h"
+
+#include <cdio/logging.h>
+
+GST_DEBUG_CATEGORY (gst_cdio_debug);
+
+void
+gst_cdio_add_cdtext_field (GstObject * src, cdtext_t * cdtext,
+    cdtext_field_t field, const gchar * gst_tag, GstTagList ** p_tags)
+{
+  const gchar *txt;
+
+  txt = cdtext_get_const (field, cdtext);
+  if (txt == NULL || *txt == '\0') {
+    GST_DEBUG_OBJECT (src, "empty CD-TEXT field %u (%s)", field, gst_tag);
+    return;
+  }
+
+  /* FIXME: beautify strings (they might be all uppercase for example)? */
+  /* FIXME: what encoding are these strings in? Let's hope ASCII or UTF-8 */
+  if (!g_utf8_validate (txt, -1, NULL)) {
+    GST_WARNING_OBJECT (src, "CD-TEXT string is not UTF-8! (%s)", gst_tag);
+    return;
+  }
+
+  if (*p_tags == NULL)
+    *p_tags = gst_tag_list_new_empty ();
+
+  gst_tag_list_add (*p_tags, GST_TAG_MERGE_REPLACE, gst_tag, txt, NULL);
+
+  GST_DEBUG_OBJECT (src, "CD-TEXT: %s = %s", gst_tag, txt);
+}
+
+GstTagList *
+gst_cdio_get_cdtext (GstObject * src, CdIo * cdio, track_t track)
+{
+  GstTagList *tags = NULL;
+  cdtext_t *t;
+
+  t = cdio_get_cdtext (cdio, track);
+  if (t == NULL) {
+    GST_DEBUG_OBJECT (src, "no CD-TEXT for track %u", track);
+    return NULL;
+  }
+
+  gst_cdio_add_cdtext_field (src, t, CDTEXT_PERFORMER, GST_TAG_ARTIST, &tags);
+  gst_cdio_add_cdtext_field (src, t, CDTEXT_TITLE, GST_TAG_TITLE, &tags);
+
+  return tags;
+}
+
+void
+gst_cdio_add_cdtext_album_tags (GstObject * src, CdIo * cdio, GstTagList * tags)
+{
+  cdtext_t *t;
+
+  t = cdio_get_cdtext (cdio, 0);
+  if (t == NULL) {
+    GST_DEBUG_OBJECT (src, "no CD-TEXT for album");
+    return;
+  }
+
+  /* FIXME: map CDTEXT_PERFORMER to GST_TAG_ALBUM_ARTIST once we have that */
+  gst_cdio_add_cdtext_field (src, t, CDTEXT_TITLE, GST_TAG_ALBUM, &tags);
+  gst_cdio_add_cdtext_field (src, t, CDTEXT_GENRE, GST_TAG_GENRE, &tags);
+
+  GST_DEBUG ("CD-TEXT album tags: %" GST_PTR_FORMAT, tags);
+}
+
+static void
+gst_cdio_log_handler (cdio_log_level_t level, const char *msg)
+{
+  const gchar *level_str[] = { "DEBUG", "INFO", "WARN", "ERROR", "ASSERT" };
+  const gchar *s;
+
+  s = level_str[CLAMP (level, 1, G_N_ELEMENTS (level_str)) - 1];
+  GST_DEBUG ("CDIO-%s: %s", s, GST_STR_NULL (msg));
+}
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  if (!gst_element_register (plugin, "cdiocddasrc", GST_RANK_SECONDARY - 1,
+          GST_TYPE_CDIO_CDDA_SRC))
+    return FALSE;
+
+  cdio_log_set_handler (gst_cdio_log_handler);
+
+  GST_DEBUG_CATEGORY_INIT (gst_cdio_debug, "cdio", 0, "libcdio elements");
+
+  return TRUE;
+}
+
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    cdio,
+    "Read audio from audio CDs",
+    plugin_init, VERSION, "GPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/ext/cdio/gstcdio.h b/ext/cdio/gstcdio.h
new file mode 100644
index 0000000..ef31ed0
--- /dev/null
+++ b/ext/cdio/gstcdio.h
@@ -0,0 +1,46 @@
+/* GStreamer
+ * Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_CDIO_H__
+#define __GST_CDIO_H__
+
+#include <gst/gst.h>
+#include <cdio/cdio.h>
+#include <cdio/cdtext.h>
+
+GST_DEBUG_CATEGORY_EXTERN (gst_cdio_debug);
+#define GST_CAT_DEFAULT gst_cdio_debug
+
+void     gst_cdio_add_cdtext_field (GstObject      * src,
+                                    cdtext_t       * cdtext,
+                                    cdtext_field_t   field,
+                                    const gchar    * gst_tag,
+                                    GstTagList    ** p_tags);
+
+GstTagList  * gst_cdio_get_cdtext  (GstObject      * src,
+                                    CdIo           * cdio,
+                                    track_t          track);
+
+void      gst_cdio_add_cdtext_album_tags (GstObject  * src,
+                                          CdIo       * cdio,
+                                          GstTagList * tags);
+
+#endif /* __GST_CDIO_H__ */
+
diff --git a/ext/cdio/gstcdiocddasrc.c b/ext/cdio/gstcdiocddasrc.c
new file mode 100644
index 0000000..615a0c8
--- /dev/null
+++ b/ext/cdio/gstcdiocddasrc.c
@@ -0,0 +1,378 @@
+/* GStreamer
+ * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * SECTION:element-cdiocddasrc
+ * @see_also: GstCdParanoiaSrc, GstAudioCdSrc
+ *
+ * <refsect2>
+ * <para>
+ * cdiocddasrc reads and extracts raw audio from Audio CDs. It can operate
+ * in one of two modes:
+ * <itemizedlist>
+ *  <listitem><para>
+ *    treat each track as a separate stream, counting time from the start
+ *    of the track to the end of the track and posting EOS at the end of
+ *    a track, or
+ *  </para></listitem>
+ *  <listitem><para>
+ *    treat the entire disc as one stream, counting time from the start of
+ *    the first track to the end of the last track, posting EOS only at
+ *    the end of the last track.
+ *  </para></listitem>
+ * </itemizedlist>
+ * </para>
+ * <para>
+ * With a recent-enough version of libcdio, the element will extract
+ * CD-TEXT if this is supported by the CD-drive and CD-TEXT information
+ * is available on the CD. The information will be posted on the bus in
+ * form of a tag message.
+ * </para>
+ * <para>
+ * When opened, the element will also calculate a CDDB disc ID and a
+ * MusicBrainz disc ID, which applications can use to query online
+ * databases for artist/title information. These disc IDs will also be
+ * posted on the bus as part of the tag messages.
+ * </para>
+ * <para>
+ * cdiocddasrc supports the GstUriHandler interface, so applications can use
+ * playbin with cdda://&lt;track-number&gt; URIs for playback (they will have
+ * to connect to playbin's notify::source signal and set the device on the
+ * cd source in the notify callback if they want to set the device property).
+ * Applications should use seeks in "track" format to switch between different
+ * tracks of the same CD (passing a new cdda:// URI to playbin involves opening
+ * and closing the CD device, which is much slower).
+ * </para>
+ * <title>Example launch line</title>
+ * <para>
+ * <programlisting>
+ * gst-launch cdiocddasrc track=5 device=/dev/cdrom ! audioconvert ! vorbisenc ! oggmux ! filesink location=track5.ogg
+ * </programlisting>
+ * This pipeline extracts track 5 of the audio CD and encodes it into an
+ * Ogg/Vorbis file.
+ * </para>
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstcdio.h"
+#include "gstcdiocddasrc.h"
+
+#include <gst/gst.h>
+#include "gst/gst-i18n-plugin.h"
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#define DEFAULT_READ_SPEED   -1
+
+enum
+{
+  PROP_0 = 0,
+  PROP_READ_SPEED
+};
+
+G_DEFINE_TYPE (GstCdioCddaSrc, gst_cdio_cdda_src, GST_TYPE_AUDIO_CD_SRC);
+
+static void gst_cdio_cdda_src_finalize (GObject * obj);
+static void gst_cdio_cdda_src_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec);
+static void gst_cdio_cdda_src_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec);
+static GstBuffer *gst_cdio_cdda_src_read_sector (GstAudioCdSrc * src,
+    gint sector);
+static gboolean gst_cdio_cdda_src_open (GstAudioCdSrc * src,
+    const gchar * device);
+static void gst_cdio_cdda_src_close (GstAudioCdSrc * src);
+
+#if 0
+static gchar *
+gst_cdio_cdda_src_get_default_device (GstAudioCdSrc * audiocdsrc)
+{
+  GstCdioCddaSrc *src;
+  gchar *default_device, *ret;
+
+  src = GST_CDIO_CDDA_SRC (audiocdsrc);
+
+  /* src->cdio may be NULL here */
+  default_device = cdio_get_default_device (src->cdio);
+
+  ret = g_strdup (default_device);
+  free (default_device);
+
+  GST_LOG_OBJECT (src, "returning default device: %s", GST_STR_NULL (ret));
+
+  return ret;
+}
+
+static gchar **
+gst_cdio_cdda_src_probe_devices (GstAudioCdSrc * audiocdsrc)
+{
+  char **devices, **ret, **d;
+
+  /* FIXME: might return the same hardware device twice, e.g.
+   * as /dev/cdrom and /dev/dvd - gotta do something more sophisticated */
+  devices = cdio_get_devices (DRIVER_DEVICE);
+
+  if (devices == NULL)
+    goto no_devices;
+
+  if (*devices == NULL)
+    goto empty_devices;
+
+  ret = g_strdupv (devices);
+  for (d = devices; *d != NULL; ++d) {
+    GST_DEBUG_OBJECT (audiocdsrc, "device: %s", GST_STR_NULL (*d));
+    free (*d);
+  }
+  free (devices);
+
+  return ret;
+
+  /* ERRORS */
+no_devices:
+  {
+    GST_DEBUG_OBJECT (audiocdsrc, "no devices found");
+    return NULL;
+  }
+empty_devices:
+  {
+    GST_DEBUG_OBJECT (audiocdsrc, "empty device list found");
+    free (devices);
+    return NULL;
+  }
+}
+#endif
+
+static GstBuffer *
+gst_cdio_cdda_src_read_sector (GstAudioCdSrc * audiocdsrc, gint sector)
+{
+  GstCdioCddaSrc *src;
+  guint8 *data;
+
+  src = GST_CDIO_CDDA_SRC (audiocdsrc);
+
+  data = g_malloc (CDIO_CD_FRAMESIZE_RAW);
+
+  /* can't use pad_alloc because we can't return the GstFlowReturn (FIXME 0.11) */
+  if (cdio_read_audio_sector (src->cdio, data, sector) != 0)
+    goto read_failed;
+
+  return gst_buffer_new_wrapped (data, CDIO_CD_FRAMESIZE_RAW);
+
+  /* ERRORS */
+read_failed:
+  {
+    GST_WARNING_OBJECT (src, "read at sector %d failed!", sector);
+    GST_ELEMENT_ERROR (src, RESOURCE, READ,
+        (_("Could not read from CD.")),
+        ("cdio_read_audio_sector at %d failed: %s", sector,
+            g_strerror (errno)));
+    g_free (data);
+    return NULL;
+  }
+}
+
+static gboolean
+notcdio_track_is_audio_track (const CdIo * p_cdio, track_t i_track)
+{
+  return (cdio_get_track_format (p_cdio, i_track) == TRACK_FORMAT_AUDIO);
+}
+
+static gboolean
+gst_cdio_cdda_src_open (GstAudioCdSrc * audiocdsrc, const gchar * device)
+{
+  GstCdioCddaSrc *src;
+  discmode_t discmode;
+  gint first_track, num_tracks, i;
+
+  src = GST_CDIO_CDDA_SRC (audiocdsrc);
+
+  g_assert (device != NULL);
+  g_assert (src->cdio == NULL);
+
+  GST_LOG_OBJECT (src, "trying to open device %s", device);
+
+  if (!(src->cdio = cdio_open (device, DRIVER_UNKNOWN)))
+    goto open_failed;
+
+  discmode = cdio_get_discmode (src->cdio);
+  GST_LOG_OBJECT (src, "discmode: %d", (gint) discmode);
+
+  if (discmode != CDIO_DISC_MODE_CD_DA && discmode != CDIO_DISC_MODE_CD_MIXED)
+    goto not_audio;
+
+  first_track = cdio_get_first_track_num (src->cdio);
+  num_tracks = cdio_get_num_tracks (src->cdio);
+
+  if (num_tracks <= 0 || first_track < 0)
+    return TRUE;                /* base class will generate 'has no tracks' error */
+
+  if (src->read_speed != -1)
+    cdio_set_speed (src->cdio, src->read_speed);
+
+  gst_cdio_add_cdtext_album_tags (GST_OBJECT_CAST (src), src->cdio,
+      audiocdsrc->tags);
+
+  GST_LOG_OBJECT (src, "%u tracks, first track: %d", num_tracks, first_track);
+
+  for (i = 0; i < num_tracks; ++i) {
+    GstAudioCdSrcTrack track = { 0, };
+    gint len_sectors;
+
+    len_sectors = cdio_get_track_sec_count (src->cdio, i + first_track);
+
+    track.num = i + first_track;
+    track.is_audio = notcdio_track_is_audio_track (src->cdio, i + first_track);
+
+    /* Note: LSN/LBA confusion all around us; in any case, this does
+     * the right thing here (for cddb id calculations etc. as well) */
+    track.start = cdio_get_track_lsn (src->cdio, i + first_track);
+    track.end = track.start + len_sectors - 1;  /* -1? */
+    track.tags = gst_cdio_get_cdtext (GST_OBJECT (src), src->cdio,
+        i + first_track);
+
+    gst_audio_cd_src_add_track (GST_AUDIO_CD_SRC (src), &track);
+  }
+  return TRUE;
+
+  /* ERRORS */
+open_failed:
+  {
+    GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+        (_("Could not open CD device for reading.")),
+        ("cdio_open() failed: %s", g_strerror (errno)));
+    return FALSE;
+  }
+not_audio:
+  {
+    GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+        (_("Disc is not an Audio CD.")), ("discmode: %d", (gint) discmode));
+
+    cdio_destroy (src->cdio);
+    src->cdio = NULL;
+    return FALSE;
+  }
+}
+
+static void
+gst_cdio_cdda_src_close (GstAudioCdSrc * audiocdsrc)
+{
+  GstCdioCddaSrc *src = GST_CDIO_CDDA_SRC (audiocdsrc);
+
+  if (src->cdio) {
+    cdio_destroy (src->cdio);
+    src->cdio = NULL;
+  }
+}
+
+static void
+gst_cdio_cdda_src_init (GstCdioCddaSrc * src)
+{
+  src->read_speed = DEFAULT_READ_SPEED; /* don't need atomic access here */
+  src->cdio = NULL;
+}
+
+static void
+gst_cdio_cdda_src_finalize (GObject * obj)
+{
+  GstCdioCddaSrc *src = GST_CDIO_CDDA_SRC (obj);
+
+  if (src->cdio) {
+    cdio_destroy (src->cdio);
+    src->cdio = NULL;
+  }
+
+  G_OBJECT_CLASS (gst_cdio_cdda_src_parent_class)->finalize (obj);
+}
+
+static void
+gst_cdio_cdda_src_class_init (GstCdioCddaSrcClass * klass)
+{
+  GstAudioCdSrcClass *audiocdsrc_class = GST_AUDIO_CD_SRC_CLASS (klass);
+  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->set_property = gst_cdio_cdda_src_set_property;
+  gobject_class->get_property = gst_cdio_cdda_src_get_property;
+  gobject_class->finalize = gst_cdio_cdda_src_finalize;
+
+  audiocdsrc_class->open = gst_cdio_cdda_src_open;
+  audiocdsrc_class->close = gst_cdio_cdda_src_close;
+  audiocdsrc_class->read_sector = gst_cdio_cdda_src_read_sector;
+#if 0
+  audiocdsrc_class->probe_devices = gst_cdio_cdda_src_probe_devices;
+  audiocdsrc_class->get_default_device = gst_cdio_cdda_src_get_default_device;
+#endif
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_READ_SPEED,
+      g_param_spec_int ("read-speed", "Read speed",
+          "Read from device at the specified speed (-1 = default)", -1, 100,
+          DEFAULT_READ_SPEED, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  gst_element_class_set_static_metadata (element_class,
+      "CD audio source (CDDA)", "Source/File",
+      "Read audio from CD using libcdio",
+      "Tim-Philipp Müller <tim centricular net>");
+}
+
+static void
+gst_cdio_cdda_src_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec)
+{
+  GstCdioCddaSrc *src = GST_CDIO_CDDA_SRC (object);
+
+  switch (prop_id) {
+    case PROP_READ_SPEED:{
+      gint speed;
+
+      speed = g_value_get_int (value);
+      g_atomic_int_set (&src->read_speed, speed);
+      break;
+    }
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+gst_cdio_cdda_src_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec)
+{
+  GstCdioCddaSrc *src = GST_CDIO_CDDA_SRC (object);
+
+  switch (prop_id) {
+    case PROP_READ_SPEED:{
+      gint speed;
+
+      speed = g_atomic_int_get (&src->read_speed);
+      g_value_set_int (value, speed);
+      break;
+    }
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
diff --git a/ext/cdio/gstcdiocddasrc.h b/ext/cdio/gstcdiocddasrc.h
new file mode 100644
index 0000000..63cade0
--- /dev/null
+++ b/ext/cdio/gstcdiocddasrc.h
@@ -0,0 +1,52 @@
+/* GStreamer
+ * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_CDIO_CDDA_SRC_H__
+#define __GST_CDIO_CDDA_SRC_H__
+
+#include <gst/audio/gstaudiocdsrc.h>
+#include <cdio/cdio.h>
+
+#define GST_TYPE_CDIO_CDDA_SRC            (gst_cdio_cdda_src_get_type ())
+#define GST_CDIO_CDDA_SRC(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_CDIO_CDDA_SRC, GstCdioCddaSrc))
+#define GST_CDIO_CDDA_SRC_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  GST_TYPE_CDIO_CDDA_SRC, GstCdioCddaSrcClass))
+#define GST_IS_CDIO_CDDA_SRC(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_CDIO_CDDA_SRC))
+#define GST_IS_CDIO_CDDA_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  GST_TYPE_CDIO_CDDA_SRC))
+
+typedef struct _GstCdioCddaSrc GstCdioCddaSrc;
+typedef struct _GstCdioCddaSrcClass GstCdioCddaSrcClass;
+
+struct _GstCdioCddaSrc
+{
+  GstAudioCdSrc  audiocdsrc;
+
+  gint           read_speed;    /* ATOMIC */
+
+  CdIo          *cdio;          /* NULL if not open */
+};
+
+struct _GstCdioCddaSrcClass
+{
+  GstAudioCdSrcClass  audiocdsrc_class;
+};
+
+GType   gst_cdio_cdda_src_get_type (void);
+
+#endif /* __GST_CDIO_CDDA_SRC_H__ */
+
diff --git a/ext/dvdread/Makefile.am b/ext/dvdread/Makefile.am
new file mode 100644
index 0000000..e3bfa82
--- /dev/null
+++ b/ext/dvdread/Makefile.am
@@ -0,0 +1,11 @@
+plugin_LTLIBRARIES = libgstdvdread.la
+
+libgstdvdread_la_SOURCES = dvdreadsrc.c
+libgstdvdread_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(DVDREAD_CFLAGS)
+libgstdvdread_la_LIBADD = $(GST_BASE_LIBS) $(DVDREAD_LIBS)
+libgstdvdread_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstdvdread_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS = dvdreadsrc.h
+
+EXTRA_DIST = README demo-play
diff --git a/ext/dvdread/Makefile.in b/ext/dvdread/Makefile.in
new file mode 100644
index 0000000..7ed4bad
--- /dev/null
+++ b/ext/dvdread/Makefile.in
@@ -0,0 +1,747 @@
+# Makefile.in generated by automake 1.11.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = ext/dvdread
+DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \
+	$(top_srcdir)/common/m4/as-auto-alt.m4 \
+	$(top_srcdir)/common/m4/as-compiler-flag.m4 \
+	$(top_srcdir)/common/m4/as-python.m4 \
+	$(top_srcdir)/common/m4/as-scrub-include.m4 \
+	$(top_srcdir)/common/m4/as-version.m4 \
+	$(top_srcdir)/common/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/common/m4/gst-arch.m4 \
+	$(top_srcdir)/common/m4/gst-args.m4 \
+	$(top_srcdir)/common/m4/gst-check.m4 \
+	$(top_srcdir)/common/m4/gst-default.m4 \
+	$(top_srcdir)/common/m4/gst-dowhile.m4 \
+	$(top_srcdir)/common/m4/gst-error.m4 \
+	$(top_srcdir)/common/m4/gst-feature.m4 \
+	$(top_srcdir)/common/m4/gst-function.m4 \
+	$(top_srcdir)/common/m4/gst-gettext.m4 \
+	$(top_srcdir)/common/m4/gst-glib2.m4 \
+	$(top_srcdir)/common/m4/gst-package-release-datetime.m4 \
+	$(top_srcdir)/common/m4/gst-plugin-docs.m4 \
+	$(top_srcdir)/common/m4/gst-plugindir.m4 \
+	$(top_srcdir)/common/m4/gst.m4 \
+	$(top_srcdir)/common/m4/gtk-doc.m4 \
+	$(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \
+	$(top_srcdir)/m4/a52.m4 $(top_srcdir)/m4/gettext.m4 \
+	$(top_srcdir)/m4/gst-sid.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+	$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(plugindir)"
+LTLIBRARIES = $(plugin_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libgstdvdread_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1)
+am_libgstdvdread_la_OBJECTS = libgstdvdread_la-dvdreadsrc.lo
+libgstdvdread_la_OBJECTS = $(am_libgstdvdread_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+libgstdvdread_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+	$(libgstdvdread_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+	$(CCLD) $(libgstdvdread_la_CFLAGS) $(CFLAGS) \
+	$(libgstdvdread_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libgstdvdread_la_SOURCES)
+DIST_SOURCES = $(libgstdvdread_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+A52DEC_CFLAGS = @A52DEC_CFLAGS@
+A52DEC_LIBS = @A52DEC_LIBS@
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMRNB_CFLAGS = @AMRNB_CFLAGS@
+AMRNB_LIBS = @AMRNB_LIBS@
+AMRWB_CFLAGS = @AMRWB_CFLAGS@
+AMRWB_LIBS = @AMRWB_LIBS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CDIO_CFLAGS = @CDIO_CFLAGS@
+CDIO_LIBS = @CDIO_LIBS@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@
+DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@
+DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@
+DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@
+DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DVDREAD_LIBS = @DVDREAD_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+ERROR_CXXFLAGS = @ERROR_CXXFLAGS@
+EXEEXT = @EXEEXT@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+GCOV = @GCOV@
+GCOV_CFLAGS = @GCOV_CFLAGS@
+GCOV_LIBS = @GCOV_LIBS@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LDFLAGS = @GIO_LDFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_PREFIX = @GLIB_PREFIX@
+GLIB_REQ = @GLIB_REQ@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@
+GSTPB_PREFIX = @GSTPB_PREFIX@
+GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@
+GST_API_VERSION = @GST_API_VERSION@
+GST_BASE_CFLAGS = @GST_BASE_CFLAGS@
+GST_BASE_LIBS = @GST_BASE_LIBS@
+GST_CFLAGS = @GST_CFLAGS@
+GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@
+GST_CHECK_LIBS = @GST_CHECK_LIBS@
+GST_CXXFLAGS = @GST_CXXFLAGS@
+GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@
+GST_LIBS = @GST_LIBS@
+GST_LICENSE = @GST_LICENSE@
+GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@
+GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@
+GST_PACKAGE_NAME = @GST_PACKAGE_NAME@
+GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@
+GST_PLUGINS_ALL = @GST_PLUGINS_ALL@
+GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@
+GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@
+GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@
+GST_PLUGINS_DIR = @GST_PLUGINS_DIR@
+GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@
+GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GST_PREFIX = @GST_PREFIX@
+GST_TOOLS_DIR = @GST_TOOLS_DIR@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DVDREAD = @HAVE_DVDREAD@
+HAVE_LAME = @HAVE_LAME@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LAME_CFLAGS = @LAME_CFLAGS@
+LAME_LIBS = @LAME_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAD_CFLAGS = @MAD_CFLAGS@
+MAD_LIBS = @MAD_LIBS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MPEG2DEC_CFLAGS = @MPEG2DEC_CFLAGS@
+MPEG2DEC_LIBS = @MPEG2DEC_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ORCC = @ORCC@
+ORCC_FLAGS = @ORCC_FLAGS@
+ORC_CFLAGS = @ORC_CFLAGS@
+ORC_LIBS = @ORC_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@
+PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGINDIR = @PLUGINDIR@
+POSUB = @POSUB@
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIDPLAY_CFLAGS = @SIDPLAY_CFLAGS@
+SIDPLAY_LIBS = @SIDPLAY_LIBS@
+STRIP = @STRIP@
+TWOLAME_CFLAGS = @TWOLAME_CFLAGS@
+TWOLAME_LIBS = @TWOLAME_LIBS@
+USE_NLS = @USE_NLS@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VALGRIND_PATH = @VALGRIND_PATH@
+VERSION = @VERSION@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WIN32_LIBS = @WIN32_LIBS@
+X264_CFLAGS = @X264_CFLAGS@
+X264_LIBS = @X264_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+plugindir = @plugindir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+plugin_LTLIBRARIES = libgstdvdread.la
+libgstdvdread_la_SOURCES = dvdreadsrc.c
+libgstdvdread_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(DVDREAD_CFLAGS)
+libgstdvdread_la_LIBADD = $(GST_BASE_LIBS) $(DVDREAD_LIBS)
+libgstdvdread_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstdvdread_la_LIBTOOLFLAGS = --tag=disable-static
+noinst_HEADERS = dvdreadsrc.h
+EXTRA_DIST = README demo-play
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/dvdread/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu ext/dvdread/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \
+	  $(MKDIR_P) '$(DESTDIR)$(plugindir)' || exit 1; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+	}
+
+uninstall-pluginLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+	done
+
+clean-pluginLTLIBRARIES:
+	-test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+	@list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libgstdvdread.la: $(libgstdvdread_la_OBJECTS) $(libgstdvdread_la_DEPENDENCIES) $(EXTRA_libgstdvdread_la_DEPENDENCIES) 
+	$(AM_V_CCLD)$(libgstdvdread_la_LINK) -rpath $(plugindir) $(libgstdvdread_la_OBJECTS) $(libgstdvdread_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstdvdread_la-dvdreadsrc.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+libgstdvdread_la-dvdreadsrc.lo: dvdreadsrc.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstdvdread_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstdvdread_la_CFLAGS) $(CFLAGS) -MT libgstdvdread_la-dvdreadsrc.lo -MD -MP -MF $(DEPDIR)/libgstdvdread_la-dvdreadsrc.Tpo -c -o libgstdvdread_la-dvdreadsrc.lo `test -f 'dvdreadsrc.c' || echo '$(srcdir)/'`dvdreadsrc.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgstdvdread_la-dvdreadsrc.Tpo $(DEPDIR)/libgstdvdread_la-dvdreadsrc.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='dvdreadsrc.c' object='libgstdvdread_la-dvdreadsrc.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstdvdread_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstdvdread_la_CFLAGS) $(CFLAGS) -c -o libgstdvdread_la-dvdreadsrc.lo `test -f 'dvdreadsrc.c' || echo '$(srcdir)/'`dvdreadsrc.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(plugindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pluginLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pluginLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pluginLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/ext/dvdread/README b/ext/dvdread/README
new file mode 100644
index 0000000..acf8d08
--- /dev/null
+++ b/ext/dvdread/README
@@ -0,0 +1,5 @@
+Various Info
+============
+
+http://members.aol.com/mpucoder/DVD/index.html
+http://dvd.sourceforge.net/
diff --git a/ext/dvdread/demo-play b/ext/dvdread/demo-play
new file mode 100755
index 0000000..1def730
--- /dev/null
+++ b/ext/dvdread/demo-play
@@ -0,0 +1,6 @@
+#!/bin/sh
+AUDIOSINK=`gconftool-2 -g /system/gstreamer/0.8/default/audiosink`
+VIDEOSINK=`gconftool-2 -g /system/gstreamer/0.8/default/videosink`
+gst-launch dvdreadsrc ! dvddemux name=demux .video_00 ! \
+	{ queue ! mpeg2dec ! ffmpegcolorspace ! videoscale ! $VIDEOSINK } \
+	{ demux.audio_00 ! queue ! a52dec ! audioconvert ! audioscale ! $AUDIOSINK }
diff --git a/ext/dvdread/dvdreadsrc.c b/ext/dvdread/dvdreadsrc.c
new file mode 100644
index 0000000..3c2e631
--- /dev/null
+++ b/ext/dvdread/dvdreadsrc.c
@@ -0,0 +1,1783 @@
+/* GStreamer DVD title source
+ * Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) 2001 Billy Biggs <vektor@dumbterm.net>.
+ * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "_stdint.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include "dvdreadsrc.h"
+
+#include <gst/gst-i18n-plugin.h>
+
+GST_DEBUG_CATEGORY_STATIC (gstgst_dvd_read_src_debug);
+#define GST_CAT_DEFAULT (gstgst_dvd_read_src_debug)
+
+enum
+{
+  ARG_0,
+  ARG_DEVICE,
+  ARG_TITLE,
+  ARG_CHAPTER,
+  ARG_ANGLE
+};
+
+static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("video/mpeg, mpegversion=2, systemstream=(boolean)true"));
+
+static GstFormat title_format;
+static GstFormat angle_format;
+static GstFormat sector_format;
+static GstFormat chapter_format;
+
+static gboolean gst_dvd_read_src_start (GstBaseSrc * basesrc);
+static gboolean gst_dvd_read_src_stop (GstBaseSrc * basesrc);
+static GstFlowReturn gst_dvd_read_src_create (GstPushSrc * pushsrc,
+    GstBuffer ** buf);
+static gboolean gst_dvd_read_src_src_query (GstBaseSrc * basesrc,
+    GstQuery * query);
+static gboolean gst_dvd_read_src_src_event (GstBaseSrc * basesrc,
+    GstEvent * event);
+static gboolean gst_dvd_read_src_goto_title (GstDvdReadSrc * src, gint title,
+    gint angle);
+static gboolean gst_dvd_read_src_goto_chapter (GstDvdReadSrc * src,
+    gint chapter);
+static gboolean gst_dvd_read_src_goto_sector (GstDvdReadSrc * src, gint angle);
+static void gst_dvd_read_src_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec);
+static void gst_dvd_read_src_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec);
+static GstEvent *gst_dvd_read_src_make_clut_change_event (GstDvdReadSrc * src,
+    const guint * clut);
+static gboolean gst_dvd_read_src_get_size (GstDvdReadSrc * src, gint64 * size);
+static gboolean gst_dvd_read_src_do_seek (GstBaseSrc * src, GstSegment * s);
+static gint64 gst_dvd_read_src_convert_timecode (dvd_time_t * time);
+static gint gst_dvd_read_src_get_next_cell (GstDvdReadSrc * src,
+    pgc_t * pgc, gint cell);
+static GstClockTime gst_dvd_read_src_get_time_for_sector (GstDvdReadSrc * src,
+    guint sector);
+static gint gst_dvd_read_src_get_sector_from_time (GstDvdReadSrc * src,
+    GstClockTime ts);
+
+static void gst_dvd_read_src_uri_handler_init (gpointer g_iface,
+    gpointer iface_data);
+
+#define gst_dvd_read_src_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstDvdReadSrc, gst_dvd_read_src, GST_TYPE_PUSH_SRC,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
+        gst_dvd_read_src_uri_handler_init));
+
+static void
+gst_dvd_read_src_finalize (GObject * object)
+{
+  GstDvdReadSrc *src = GST_DVD_READ_SRC (object);
+
+  g_free (src->location);
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gst_dvd_read_src_init (GstDvdReadSrc * src)
+{
+  src->dvd = NULL;
+  src->vts_file = NULL;
+  src->vmg_file = NULL;
+  src->dvd_title = NULL;
+
+  src->location = g_strdup ("/dev/dvd");
+  src->new_seek = TRUE;
+  src->new_cell = TRUE;
+  src->change_cell = FALSE;
+  src->uri_title = 1;
+  src->uri_chapter = 1;
+  src->uri_angle = 1;
+
+  src->title_lang_event_pending = NULL;
+  src->pending_clut_event = NULL;
+
+  gst_pad_use_fixed_caps (GST_BASE_SRC_PAD (src));
+  gst_pad_set_caps (GST_BASE_SRC_PAD (src),
+      gst_static_pad_template_get_caps (&srctemplate));
+}
+
+static gboolean
+gst_dvd_read_src_is_seekable (GstBaseSrc * src)
+{
+  return TRUE;
+}
+
+static void
+gst_dvd_read_src_class_init (GstDvdReadSrcClass * klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
+  GstPushSrcClass *gstpushsrc_class = GST_PUSH_SRC_CLASS (klass);
+  GstBaseSrcClass *gstbasesrc_class = GST_BASE_SRC_CLASS (klass);
+
+  gobject_class->finalize = gst_dvd_read_src_finalize;
+  gobject_class->set_property = gst_dvd_read_src_set_property;
+  gobject_class->get_property = gst_dvd_read_src_get_property;
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DEVICE,
+      g_param_spec_string ("device", "Device",
+          "DVD device location", NULL,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TITLE,
+      g_param_spec_int ("title", "title", "title",
+          1, 999, 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CHAPTER,
+      g_param_spec_int ("chapter", "chapter", "chapter",
+          1, 999, 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ANGLE,
+      g_param_spec_int ("angle", "angle", "angle",
+          1, 999, 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&srctemplate));
+
+  gst_element_class_set_static_metadata (gstelement_class, "DVD Source",
+      "Source/File/DVD",
+      "Access a DVD title/chapter/angle using libdvdread",
+      "Erik Walthinsen <omega@cse.ogi.edu>");
+
+  gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_dvd_read_src_start);
+  gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_dvd_read_src_stop);
+  gstbasesrc_class->query = GST_DEBUG_FUNCPTR (gst_dvd_read_src_src_query);
+  gstbasesrc_class->event = GST_DEBUG_FUNCPTR (gst_dvd_read_src_src_event);
+  gstbasesrc_class->do_seek = GST_DEBUG_FUNCPTR (gst_dvd_read_src_do_seek);
+  gstbasesrc_class->is_seekable =
+      GST_DEBUG_FUNCPTR (gst_dvd_read_src_is_seekable);
+
+  gstpushsrc_class->create = GST_DEBUG_FUNCPTR (gst_dvd_read_src_create);
+
+  title_format = gst_format_register ("title", "DVD title");
+  angle_format = gst_format_register ("angle", "DVD angle");
+  sector_format = gst_format_register ("sector", "DVD sector");
+  chapter_format = gst_format_register ("chapter", "DVD chapter");
+}
+
+static gboolean
+gst_dvd_read_src_start (GstBaseSrc * basesrc)
+{
+  GstDvdReadSrc *src = GST_DVD_READ_SRC (basesrc);
+
+  g_return_val_if_fail (src->location != NULL, FALSE);
+
+  GST_DEBUG_OBJECT (src, "Opening DVD '%s'", src->location);
+
+  if ((src->dvd = DVDOpen (src->location)) == NULL)
+    goto open_failed;
+
+  /* Load the video manager to find out the information about the titles */
+  GST_DEBUG_OBJECT (src, "Loading VMG info");
+
+  if (!(src->vmg_file = ifoOpen (src->dvd, 0)))
+    goto ifo_open_failed;
+
+  src->tt_srpt = src->vmg_file->tt_srpt;
+
+  src->title = src->uri_title - 1;
+  src->chapter = src->uri_chapter - 1;
+  src->angle = src->uri_angle - 1;
+
+  if (!gst_dvd_read_src_goto_title (src, src->title, src->angle))
+    goto title_open_failed;
+
+  if (!gst_dvd_read_src_goto_chapter (src, src->chapter))
+    goto chapter_open_failed;
+
+  src->new_seek = FALSE;
+  src->change_cell = TRUE;
+
+  return TRUE;
+
+  /* ERRORS */
+open_failed:
+  {
+    GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+        (_("Could not open DVD")),
+        ("DVDOpen(%s) failed: %s", src->location, g_strerror (errno)));
+    return FALSE;
+  }
+ifo_open_failed:
+  {
+    GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+        (_("Could not open DVD")),
+        ("ifoOpen() failed: %s", g_strerror (errno)));
+    return FALSE;
+  }
+title_open_failed:
+  {
+    GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+        (_("Could not open DVD title %d"), src->uri_title), (NULL));
+    return FALSE;
+  }
+chapter_open_failed:
+  {
+    GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+        (_("Failed to go to chapter %d of DVD title %d"),
+            src->uri_chapter, src->uri_title), (NULL));
+    return FALSE;
+  }
+}
+
+static gboolean
+gst_dvd_read_src_stop (GstBaseSrc * basesrc)
+{
+  GstDvdReadSrc *src = GST_DVD_READ_SRC (basesrc);
+
+  if (src->vts_file) {
+    ifoClose (src->vts_file);
+    src->vts_file = NULL;
+  }
+  if (src->vmg_file) {
+    ifoClose (src->vmg_file);
+    src->vmg_file = NULL;
+  }
+  if (src->dvd_title) {
+    DVDCloseFile (src->dvd_title);
+    src->dvd_title = NULL;
+  }
+  if (src->dvd) {
+    DVDClose (src->dvd);
+    src->dvd = NULL;
+  }
+  src->new_cell = TRUE;
+  src->new_seek = TRUE;
+  src->change_cell = FALSE;
+  src->chapter = 0;
+  src->title = 0;
+  src->need_newsegment = TRUE;
+  src->vts_tmapt = NULL;
+  if (src->title_lang_event_pending) {
+    gst_event_unref (src->title_lang_event_pending);
+    src->title_lang_event_pending = NULL;
+  }
+  if (src->pending_clut_event) {
+    gst_event_unref (src->pending_clut_event);
+    src->pending_clut_event = NULL;
+  }
+  if (src->chapter_starts) {
+    g_free (src->chapter_starts);
+    src->chapter_starts = NULL;
+  }
+
+  GST_LOG_OBJECT (src, "closed DVD");
+
+  return TRUE;
+}
+
+static void
+cur_title_get_chapter_pgc (GstDvdReadSrc * src, gint chapter, gint * p_pgn,
+    gint * p_pgc_id, pgc_t ** p_pgc)
+{
+  pgc_t *pgc;
+  gint pgn, pgc_id;
+
+  g_assert (chapter >= 0 && chapter < src->num_chapters);
+
+  pgc_id = src->vts_ptt_srpt->title[src->ttn - 1].ptt[chapter].pgcn;
+  pgn = src->vts_ptt_srpt->title[src->ttn - 1].ptt[chapter].pgn;
+  pgc = src->vts_file->vts_pgcit->pgci_srp[pgc_id - 1].pgc;
+
+  *p_pgn = pgn;
+  *p_pgc_id = pgc_id;
+  *p_pgc = pgc;
+}
+
+static void
+cur_title_get_chapter_bounds (GstDvdReadSrc * src, gint chapter,
+    gint * p_first_cell, gint * p_last_cell)
+{
+  pgc_t *pgc;
+  gint pgn, pgc_id, pgn_next_ch;
+
+  g_assert (chapter >= 0 && chapter < src->num_chapters);
+
+  cur_title_get_chapter_pgc (src, chapter, &pgn, &pgc_id, &pgc);
+
+  *p_first_cell = pgc->program_map[pgn - 1] - 1;
+
+  if (chapter == (src->num_chapters - 1)) {
+    *p_last_cell = pgc->nr_of_cells - 1;
+  } else {
+    pgn_next_ch = src->vts_ptt_srpt->title[src->ttn - 1].ptt[chapter + 1].pgn;
+    *p_last_cell = pgc->program_map[pgn_next_ch - 1] - 1;
+  }
+
+  GST_DEBUG_OBJECT (src, "Chapter %d bounds: %d %d (within %d cells)",
+      chapter, *p_first_cell, *p_last_cell, pgc->nr_of_cells);
+}
+
+static gboolean
+gst_dvd_read_src_goto_chapter (GstDvdReadSrc * src, gint chapter)
+{
+  gint i;
+
+  /* make sure the chapter number is valid for this title */
+  if (chapter < 0 || chapter >= src->num_chapters) {
+    GST_WARNING_OBJECT (src, "invalid chapter %d (only %d available)",
+        chapter, src->num_chapters);
+    chapter = CLAMP (chapter, 0, src->num_chapters - 1);
+  }
+
+  /* determine which program chain we want to watch. This is
+   * based on the chapter number */
+  cur_title_get_chapter_pgc (src, chapter, &src->pgn, &src->pgc_id,
+      &src->cur_pgc);
+  cur_title_get_chapter_bounds (src, chapter, &src->start_cell,
+      &src->last_cell);
+
+  GST_LOG_OBJECT (src, "Opened chapter %d - cell %d-%d", chapter + 1,
+      src->start_cell, src->last_cell);
+
+  /* retrieve position */
+  src->cur_pack = 0;
+  for (i = 0; i < chapter; i++) {
+    gint c1, c2;
+
+    cur_title_get_chapter_bounds (src, i, &c1, &c2);
+
+    while (c1 < c2) {
+      src->cur_pack +=
+          src->cur_pgc->cell_playback[c1].last_sector -
+          src->cur_pgc->cell_playback[c1].first_sector;
+      ++c1;
+    }
+  }
+
+  /* prepare reading for new cell */
+  src->new_cell = TRUE;
+  src->next_cell = src->start_cell;
+
+  src->chapter = chapter;
+
+  if (src->pending_clut_event)
+    gst_event_unref (src->pending_clut_event);
+
+  src->pending_clut_event =
+      gst_dvd_read_src_make_clut_change_event (src, src->cur_pgc->palette);
+
+  return TRUE;
+}
+
+static void
+gst_dvd_read_src_get_chapter_starts (GstDvdReadSrc * src)
+{
+  GstClockTime uptohere;
+  guint c;
+
+  g_free (src->chapter_starts);
+  src->chapter_starts = g_new (GstClockTime, src->num_chapters);
+
+  uptohere = (GstClockTime) 0;
+  for (c = 0; c < src->num_chapters; ++c) {
+    GstClockTime chapter_duration = 0;
+    gint cell_start, cell_end, cell;
+    gint pgn, pgc_id;
+    pgc_t *pgc;
+
+    cur_title_get_chapter_pgc (src, c, &pgn, &pgc_id, &pgc);
+    cur_title_get_chapter_bounds (src, c, &cell_start, &cell_end);
+
+    cell = cell_start;
+    while (cell < cell_end) {
+      dvd_time_t *cell_duration;
+
+      cell_duration = &pgc->cell_playback[cell].playback_time;
+      chapter_duration += gst_dvd_read_src_convert_timecode (cell_duration);
+      cell = gst_dvd_read_src_get_next_cell (src, pgc, cell);
+    }
+
+    src->chapter_starts[c] = uptohere;
+
+    GST_INFO_OBJECT (src, "[%02u] Chapter %02u starts at %" GST_TIME_FORMAT
+        ", dur = %" GST_TIME_FORMAT ", cells %d-%d", src->title + 1, c + 1,
+        GST_TIME_ARGS (uptohere), GST_TIME_ARGS (chapter_duration),
+        cell_start, cell_end);
+
+    uptohere += chapter_duration;
+  }
+}
+
+static gboolean
+gst_dvd_read_src_goto_title (GstDvdReadSrc * src, gint title, gint angle)
+{
+  GstStructure *s;
+  gchar lang_code[3] = { '\0', '\0', '\0' }, *t;
+  pgc_t *pgc0;
+  gint title_set_nr;
+  gint num_titles;
+  gint pgn0, pgc0_id;
+  gint i;
+
+  /* make sure our title number is valid */
+  num_titles = src->tt_srpt->nr_of_srpts;
+  GST_INFO_OBJECT (src, "There are %d titles on this DVD", num_titles);
+  if (title < 0 || title >= num_titles)
+    goto invalid_title;
+
+  src->num_chapters = src->tt_srpt->title[title].nr_of_ptts;
+  GST_INFO_OBJECT (src, "Title %d has %d chapters", title + 1,
+      src->num_chapters);
+
+  /* make sure the angle number is valid for this title */
+  src->num_angles = src->tt_srpt->title[title].nr_of_angles;
+  GST_LOG_OBJECT (src, "Title %d has %d angles", title + 1, src->num_angles);
+  if (angle < 0 || angle >= src->num_angles) {
+    GST_WARNING_OBJECT (src, "Invalid angle %d (only %d available)",
+        angle, src->num_angles);
+    angle = CLAMP (angle, 0, src->num_angles - 1);
+  }
+
+  /* load the VTS information for the title set our title is in */
+  title_set_nr = src->tt_srpt->title[title].title_set_nr;
+  src->vts_file = ifoOpen (src->dvd, title_set_nr);
+  if (src->vts_file == NULL)
+    goto ifo_open_failed;
+
+  src->ttn = src->tt_srpt->title[title].vts_ttn;
+  src->vts_ptt_srpt = src->vts_file->vts_ptt_srpt;
+
+  /* interactive title? */
+  if (src->num_chapters > 0 &&
+      src->vts_ptt_srpt->title[src->ttn - 1].ptt[0].pgn == 0) {
+    goto commands_only_pgc;
+  }
+
+  /* we've got enough info, time to open the title set data */
+  src->dvd_title = DVDOpenFile (src->dvd, title_set_nr, DVD_READ_TITLE_VOBS);
+  if (src->dvd_title == NULL)
+    goto title_open_failed;
+
+  GST_INFO_OBJECT (src, "Opened title %d, angle %d", title + 1, angle);
+  src->title = title;
+  src->angle = angle;
+
+  /* build event */
+
+  if (src->title_lang_event_pending) {
+    gst_event_unref (src->title_lang_event_pending);
+    src->title_lang_event_pending = NULL;
+  }
+
+  s = gst_structure_new ("application/x-gst-dvd",
+      "event", G_TYPE_STRING, "dvd-lang-codes", NULL);
+
+  /* so we can filter out invalid/unused streams (same for all chapters) */
+  cur_title_get_chapter_pgc (src, 0, &pgn0, &pgc0_id, &pgc0);
+
+  /* audio */
+  for (i = 0; i < src->vts_file->vtsi_mat->nr_of_vts_audio_streams; i++) {
+    const audio_attr_t *a;
+
+    /* audio stream present? */
+    if (pgc0 != NULL && (pgc0->audio_control[i] & 0x8000) == 0)
+      continue;
+
+    a = &src->vts_file->vtsi_mat->vts_audio_attr[i];
+
+    t = g_strdup_printf ("audio-%d-format", i);
+    gst_structure_set (s, t, G_TYPE_INT, (int) a->audio_format, NULL);
+    g_free (t);
+
+    if (a->lang_type) {
+      t = g_strdup_printf ("audio-%d-language", i);
+      lang_code[0] = (a->lang_code >> 8) & 0xff;
+      lang_code[1] = a->lang_code & 0xff;
+      gst_structure_set (s, t, G_TYPE_STRING, lang_code, NULL);
+      g_free (t);
+    } else {
+      lang_code[0] = '\0';
+    }
+
+    GST_INFO_OBJECT (src, "[%02d] Audio    %02d: lang='%s', format=%d",
+        src->title + 1, i, lang_code, (gint) a->audio_format);
+  }
+
+  /* subtitle */
+  for (i = 0; i < src->vts_file->vtsi_mat->nr_of_vts_subp_streams; i++) {
+    const subp_attr_t *u;
+    const video_attr_t *v;
+    gint sid;
+
+    /* subpicture stream present? */
+    if (pgc0 != NULL && (pgc0->subp_control[i] & 0x80000000) == 0)
+      continue;
+
+    u = &src->vts_file->vtsi_mat->vts_subp_attr[i];
+    v = &src->vts_file->vtsi_mat->vts_video_attr;
+
+    sid = i;
+    if (pgc0 != NULL) {
+      if (v->display_aspect_ratio == 0) /* 4:3 */
+        sid = (pgc0->subp_control[i] >> 24) & 0x1f;
+      else if (v->display_aspect_ratio == 3)    /* 16:9 */
+        sid = (pgc0->subp_control[i] >> 8) & 0x1f;
+    }
+
+    if (u->type) {
+      t = g_strdup_printf ("subtitle-%d-language", sid);
+      lang_code[0] = (u->lang_code >> 8) & 0xff;
+      lang_code[1] = u->lang_code & 0xff;
+      gst_structure_set (s, t, G_TYPE_STRING, lang_code, NULL);
+      g_free (t);
+    } else {
+      lang_code[0] = '\0';
+    }
+
+    GST_INFO_OBJECT (src, "[%02d] Subtitle %02d: lang='%s', type=%d",
+        src->title + 1, sid, lang_code, u->type);
+  }
+
+  src->title_lang_event_pending =
+      gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, s);
+
+  /* dump seek tables */
+  src->vts_tmapt = src->vts_file->vts_tmapt;
+  if (src->vts_tmapt) {
+    gint i, j;
+
+    GST_LOG_OBJECT (src, "nr_of_tmaps = %d", src->vts_tmapt->nr_of_tmaps);
+    for (i = 0; i < src->vts_tmapt->nr_of_tmaps; ++i) {
+      GST_LOG_OBJECT (src, "======= Table %d ===================", i);
+      GST_LOG_OBJECT (src, "Offset relative to VTS_TMAPTI: %d",
+          src->vts_tmapt->tmap_offset[i]);
+      GST_LOG_OBJECT (src, "Time unit (seconds)          : %d",
+          src->vts_tmapt->tmap[i].tmu);
+      GST_LOG_OBJECT (src, "Number of entries            : %d",
+          src->vts_tmapt->tmap[i].nr_of_entries);
+      for (j = 0; j < src->vts_tmapt->tmap[i].nr_of_entries; j++) {
+        guint64 time;
+
+        time = src->vts_tmapt->tmap[i].tmu * (j + 1) * GST_SECOND;
+        GST_LOG_OBJECT (src, "Time: %" GST_TIME_FORMAT " VOBU "
+            "Sector: 0x%08x %s", GST_TIME_ARGS (time),
+            src->vts_tmapt->tmap[i].map_ent[j] & 0x7fffffff,
+            (src->vts_tmapt->tmap[i].map_ent[j] >> 31) ? "discontinuity" : "");
+      }
+    }
+  } else {
+    GST_WARNING_OBJECT (src, "no vts_tmapt - seeking will suck");
+  }
+
+  gst_dvd_read_src_get_chapter_starts (src);
+
+  return TRUE;
+
+  /* ERRORS */
+invalid_title:
+  {
+    GST_WARNING_OBJECT (src, "Invalid title %d (only %d available)",
+        title, num_titles);
+    return FALSE;
+  }
+ifo_open_failed:
+  {
+    GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+        (_("Could not open DVD title %d"), title_set_nr),
+        ("ifoOpen(%d) failed: %s", title_set_nr, g_strerror (errno)));
+    return FALSE;
+  }
+title_open_failed:
+  {
+    GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+        (_("Could not open DVD title %d"), title_set_nr),
+        ("Can't open title VOBS (VTS_%02d_1.VOB)", title_set_nr));
+    return FALSE;
+  }
+commands_only_pgc:
+  {
+    GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+        (_("Could not open DVD title %d. Interactive titles are not supported "
+                "by this element"), title_set_nr),
+        ("Commands-only PGC, not supported, use rsndvdbin"));
+    return FALSE;
+  }
+}
+
+/* FIXME: double-check this function, compare against original */
+static gint
+gst_dvd_read_src_get_next_cell (GstDvdReadSrc * src, pgc_t * pgc, gint cell)
+{
+  /* Check if we're entering an angle block. */
+  if (pgc->cell_playback[cell].block_type != BLOCK_TYPE_ANGLE_BLOCK)
+    return (cell + 1);
+
+  while (pgc->cell_playback[cell].block_mode != BLOCK_MODE_LAST_CELL)
+    ++cell;
+
+  return cell + 1;
+}
+
+/* Returns true if the pack is a NAV pack */
+static gboolean
+gst_dvd_read_src_is_nav_pack (const guint8 * data, gint lbn, dsi_t * dsi_pack)
+{
+  if (GST_READ_UINT32_BE (data + 0x26) != 0x000001BF)
+    return FALSE;
+
+  /* Check that this is substream 0 (PCI) */
+  if (data[0x2c] != 0)
+    return FALSE;
+
+  if (GST_READ_UINT32_BE (data + 0x400) != 0x000001BF)
+    return FALSE;
+
+  /* Check that this is substream 1 (DSI) */
+  if (data[0x406] != 1)
+    return FALSE;
+
+  /* Check sizes of PCI and DSI packets */
+  if (GST_READ_UINT16_BE (data + 0x2a) != 0x03d4)
+    return FALSE;
+
+  if (GST_READ_UINT16_BE (data + 0x404) != 0x03fa)
+    return FALSE;
+
+  /* Read the DSI packet into the provided struct and check it */
+  navRead_DSI (dsi_pack, (unsigned char *) data + DSI_START_BYTE);
+  if (lbn != dsi_pack->dsi_gi.nv_pck_lbn)
+    return FALSE;
+
+  return TRUE;
+}
+
+/* find time for sector from index, returns NONE if there is no exact match */
+static GstClockTime
+gst_dvd_read_src_get_time_for_sector (GstDvdReadSrc * src, guint sector)
+{
+  gint i, j;
+
+  if (src->vts_tmapt == NULL || src->vts_tmapt->nr_of_tmaps == 0)
+    return GST_CLOCK_TIME_NONE;
+
+  for (i = 0; i < src->vts_tmapt->nr_of_tmaps; ++i) {
+    for (j = 0; j < src->vts_tmapt->tmap[i].nr_of_entries; ++j) {
+      if ((src->vts_tmapt->tmap[i].map_ent[j] & 0x7fffffff) == sector)
+        return src->vts_tmapt->tmap[i].tmu * (j + 1) * GST_SECOND;
+    }
+  }
+
+  if (sector == 0)
+    return (GstClockTime) 0;
+
+  return GST_CLOCK_TIME_NONE;
+}
+
+/* returns the sector in the index at (or before) the given time, or -1 */
+static gint
+gst_dvd_read_src_get_sector_from_time (GstDvdReadSrc * src, GstClockTime ts)
+{
+  gint sector, j;
+
+  if (src->vts_tmapt == NULL || src->vts_tmapt->nr_of_tmaps < src->ttn)
+    return -1;
+
+  sector = 0;
+  for (j = 0; j < src->vts_tmapt->tmap[src->ttn - 1].nr_of_entries; ++j) {
+    GstClockTime entry_time;
+
+    entry_time = src->vts_tmapt->tmap[src->ttn - 1].tmu * (j + 1) * GST_SECOND;
+    if (entry_time <= ts) {
+      sector = src->vts_tmapt->tmap[src->ttn - 1].map_ent[j] & 0x7fffffff;
+    }
+    if (entry_time >= ts) {
+      return sector;
+    }
+  }
+
+  if (ts == 0)
+    return 0;
+
+  return -1;
+}
+
+typedef enum
+{
+  GST_DVD_READ_OK = 0,
+  GST_DVD_READ_ERROR = -1,
+  GST_DVD_READ_EOS = -2,
+  GST_DVD_READ_AGAIN = -3
+} GstDvdReadReturn;
+
+static GstDvdReadReturn
+gst_dvd_read_src_read (GstDvdReadSrc * src, gint angle, gint new_seek,
+    GstBuffer ** p_buf)
+{
+  GstBuffer *buf;
+  GstSegment *seg;
+  guint8 oneblock[DVD_VIDEO_LB_LEN];
+  dsi_t dsi_pack;
+  guint next_vobu, cur_output_size;
+  gint len;
+  gint retries;
+  gint64 next_time;
+  GstMapInfo map;
+
+  seg = &(GST_BASE_SRC (src)->segment);
+
+  /* playback by cell in this pgc, starting at the cell for our chapter */
+  if (new_seek)
+    src->cur_cell = src->start_cell;
+
+again:
+
+  if (src->cur_cell >= src->last_cell) {
+    /* advance to next chapter */
+    if (src->chapter == (src->num_chapters - 1) ||
+        (seg->format == chapter_format && seg->stop != -1 &&
+            src->chapter == (seg->stop - 1))) {
+      GST_DEBUG_OBJECT (src, "end of chapter segment");
+      goto eos;
+    }
+
+    GST_INFO_OBJECT (src, "end of chapter %d, switch to next",
+        src->chapter + 1);
+
+    ++src->chapter;
+    gst_dvd_read_src_goto_chapter (src, src->chapter);
+
+    return GST_DVD_READ_AGAIN;
+  }
+
+  if (src->new_cell || new_seek) {
+    if (!new_seek) {
+      src->cur_cell = src->next_cell;
+      if (src->cur_cell >= src->last_cell) {
+        GST_LOG_OBJECT (src, "last cell in chapter");
+        goto again;
+      }
+    }
+
+    /* take angle into account */
+    if (src->cur_pgc->cell_playback[src->cur_cell].block_type
+        == BLOCK_TYPE_ANGLE_BLOCK)
+      src->cur_cell += angle;
+
+    /* calculate next cell */
+    src->next_cell =
+        gst_dvd_read_src_get_next_cell (src, src->cur_pgc, src->cur_cell);
+
+    /* we loop until we're out of this cell */
+    src->cur_pack = src->cur_pgc->cell_playback[src->cur_cell].first_sector;
+    src->new_cell = FALSE;
+    GST_DEBUG_OBJECT (src, "Starting new cell %d @ pack %d", src->cur_cell,
+        src->cur_pack);
+  }
+
+  if (src->cur_pack >= src->cur_pgc->cell_playback[src->cur_cell].last_sector) {
+    src->new_cell = TRUE;
+    GST_LOG_OBJECT (src, "Beyond last sector for cell %d, going to next cell",
+        src->cur_cell);
+    return GST_DVD_READ_AGAIN;
+  }
+
+  /* read NAV packet */
+  retries = 0;
+nav_retry:
+  retries++;
+
+  len = DVDReadBlocks (src->dvd_title, src->cur_pack, 1, oneblock);
+  if (len != 1)
+    goto read_error;
+
+  if (!gst_dvd_read_src_is_nav_pack (oneblock, src->cur_pack, &dsi_pack)) {
+    GST_LOG_OBJECT (src, "Skipping nav packet @ pack %d", src->cur_pack);
+    src->cur_pack++;
+
+    if (retries < 2000) {
+      goto nav_retry;
+    } else {
+      GST_LOG_OBJECT (src, "No nav packet @ pack %d after 2000 blocks",
+          src->cur_pack);
+      goto read_error;
+    }
+  }
+
+  /* determine where we go next. These values are the ones we
+   * mostly care about */
+  cur_output_size = dsi_pack.dsi_gi.vobu_ea + 1;
+
+  /* If we're not at the end of this cell, we can determine the next
+   * VOBU to display using the VOBU_SRI information section of the
+   * DSI.  Using this value correctly follows the current angle,
+   * avoiding the doubled scenes in The Matrix, and makes our life
+   * really happy.
+   *
+   * Otherwise, we set our next address past the end of this cell to
+   * force the code above to go to the next cell in the program. */
+  if (dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL) {
+    next_vobu = src->cur_pack + (dsi_pack.vobu_sri.next_vobu & 0x7fffffff);
+  } else {
+    next_vobu = src->cur_pgc->cell_playback[src->cur_cell].last_sector + 1;
+  }
+
+  g_assert (cur_output_size < 1024);
+
+  /* create the buffer (TODO: use buffer pool?) */
+  buf =
+      gst_buffer_new_allocate (NULL, cur_output_size * DVD_VIDEO_LB_LEN, NULL);
+
+  GST_LOG_OBJECT (src, "Going to read %u sectors @ pack %d", cur_output_size,
+      src->cur_pack);
+
+  gst_buffer_map (buf, &map, GST_MAP_WRITE);
+  /* read in and output cursize packs */
+  len =
+      DVDReadBlocks (src->dvd_title, src->cur_pack, cur_output_size, map.data);
+
+  if (len != cur_output_size)
+    goto block_read_error;
+
+  gst_buffer_unmap (buf, &map);
+  gst_buffer_resize (buf, 0, cur_output_size * DVD_VIDEO_LB_LEN);
+  /* GST_BUFFER_OFFSET (buf) = priv->cur_pack * DVD_VIDEO_LB_LEN; */
+  GST_BUFFER_TIMESTAMP (buf) =
+      gst_dvd_read_src_get_time_for_sector (src, src->cur_pack);
+
+  *p_buf = buf;
+
+  GST_LOG_OBJECT (src, "Read %u sectors", cur_output_size);
+
+  src->cur_pack = next_vobu;
+
+  next_time = GST_BUFFER_TIMESTAMP (buf);
+  if (GST_CLOCK_TIME_IS_VALID (next_time) && seg->format == GST_FORMAT_TIME &&
+      GST_CLOCK_TIME_IS_VALID (seg->stop) &&
+      next_time > seg->stop + 5 * GST_SECOND) {
+    GST_DEBUG_OBJECT (src, "end of TIME segment");
+    goto eos;
+  }
+
+  return GST_DVD_READ_OK;
+
+  /* ERRORS */
+eos:
+  {
+    GST_INFO_OBJECT (src, "Reached end-of-segment/stream - EOS");
+    return GST_DVD_READ_EOS;
+  }
+read_error:
+  {
+    GST_ERROR_OBJECT (src, "Read failed for block %d", src->cur_pack);
+    return GST_DVD_READ_ERROR;
+  }
+block_read_error:
+  {
+    GST_ERROR_OBJECT (src, "Read failed for %d blocks at %d",
+        cur_output_size, src->cur_pack);
+    gst_buffer_unmap (buf, &map);
+    gst_buffer_unref (buf);
+    return GST_DVD_READ_ERROR;
+  }
+}
+
+/* we don't cache the result on purpose */
+static gboolean
+gst_dvd_read_descrambler_available (void)
+{
+  GModule *module;
+  gpointer sym;
+  gsize res;
+
+  module = g_module_open ("libdvdcss", 0);
+  if (module != NULL) {
+    res = g_module_symbol (module, "dvdcss_open", &sym);
+    g_module_close (module);
+  } else {
+    res = FALSE;
+  }
+
+  return res;
+}
+
+static GstFlowReturn
+gst_dvd_read_src_create (GstPushSrc * pushsrc, GstBuffer ** p_buf)
+{
+  GstDvdReadSrc *src = GST_DVD_READ_SRC (pushsrc);
+  GstPad *srcpad;
+  gint res;
+
+  g_return_val_if_fail (src->dvd != NULL, GST_FLOW_ERROR);
+
+  srcpad = GST_BASE_SRC (src)->srcpad;
+
+  if (src->need_newsegment) {
+    GstSegment seg;
+
+    gst_segment_init (&seg, GST_FORMAT_BYTES);
+    seg.start = src->cur_pack * DVD_VIDEO_LB_LEN;
+    seg.stop = -1;
+    seg.time = 0;
+    gst_pad_push_event (srcpad, gst_event_new_segment (&seg));
+    src->need_newsegment = FALSE;
+  }
+
+  if (src->new_seek) {
+    gst_dvd_read_src_goto_title (src, src->title, src->angle);
+    gst_dvd_read_src_goto_chapter (src, src->chapter);
+
+    src->new_seek = FALSE;
+    src->change_cell = TRUE;
+  }
+
+  if (src->title_lang_event_pending) {
+    gst_pad_push_event (srcpad, src->title_lang_event_pending);
+    src->title_lang_event_pending = NULL;
+  }
+
+  if (src->pending_clut_event) {
+    gst_pad_push_event (srcpad, src->pending_clut_event);
+    src->pending_clut_event = NULL;
+  }
+
+  /* read it in */
+  do {
+    res = gst_dvd_read_src_read (src, src->angle, src->change_cell, p_buf);
+  } while (res == GST_DVD_READ_AGAIN);
+
+  switch (res) {
+    case GST_DVD_READ_ERROR:{
+      /* FIXME: figure out a way to detect if scrambling is the problem */
+      if (!gst_dvd_read_descrambler_available ()) {
+        GST_ELEMENT_ERROR (src, RESOURCE, READ,
+            (_("Could not read DVD. This may be because the DVD is encrypted "
+                    "and a DVD decryption library is not installed.")), (NULL));
+      } else {
+        GST_ELEMENT_ERROR (src, RESOURCE, READ, (_("Could not read DVD.")),
+            (NULL));
+      }
+      return GST_FLOW_ERROR;
+    }
+    case GST_DVD_READ_EOS:{
+      return GST_FLOW_EOS;
+    }
+    case GST_DVD_READ_OK:{
+      src->change_cell = FALSE;
+      return GST_FLOW_OK;
+    }
+    default:
+      break;
+  }
+
+  g_return_val_if_reached (GST_FLOW_EOS);
+}
+
+static void
+gst_dvd_read_src_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec)
+{
+  GstDvdReadSrc *src = GST_DVD_READ_SRC (object);
+  gboolean started;
+
+  GST_OBJECT_LOCK (src);
+  started = GST_OBJECT_FLAG_IS_SET (src, GST_BASE_SRC_FLAG_STARTED);
+
+  switch (prop_id) {
+    case ARG_DEVICE:{
+      if (started) {
+        g_warning ("%s: property '%s' needs to be set before the device is "
+            "opened", GST_ELEMENT_NAME (src), pspec->name);
+        break;;
+      }
+
+      g_free (src->location);
+      /* clear the filename if we get a NULL (is that possible?) */
+      if (g_value_get_string (value) == NULL) {
+        src->location = g_strdup ("/dev/dvd");
+      } else {
+        src->location = g_strdup (g_value_get_string (value));
+      }
+      break;
+    }
+    case ARG_TITLE:
+      src->uri_title = g_value_get_int (value);
+      if (started) {
+        src->title = src->uri_title - 1;
+        src->new_seek = TRUE;
+      }
+      break;
+    case ARG_CHAPTER:
+      src->uri_chapter = g_value_get_int (value);
+      if (started) {
+        src->chapter = src->uri_chapter - 1;
+        src->new_seek = TRUE;
+      }
+      break;
+    case ARG_ANGLE:
+      src->uri_angle = g_value_get_int (value);
+      if (started) {
+        src->angle = src->uri_angle - 1;
+      }
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+
+  GST_OBJECT_UNLOCK (src);
+}
+
+static void
+gst_dvd_read_src_get_property (GObject * object, guint prop_id, GValue * value,
+    GParamSpec * pspec)
+{
+  GstDvdReadSrc *src = GST_DVD_READ_SRC (object);
+
+  GST_OBJECT_LOCK (src);
+
+  switch (prop_id) {
+    case ARG_DEVICE:
+      g_value_set_string (value, src->location);
+      break;
+    case ARG_TITLE:
+      g_value_set_int (value, src->uri_title);
+      break;
+    case ARG_CHAPTER:
+      g_value_set_int (value, src->uri_chapter);
+      break;
+    case ARG_ANGLE:
+      g_value_set_int (value, src->uri_angle);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+
+  GST_OBJECT_UNLOCK (src);
+}
+
+static gboolean
+gst_dvd_read_src_get_size (GstDvdReadSrc * src, gint64 * size)
+{
+  gboolean ret = FALSE;
+
+  if (src->dvd_title) {
+    gssize blocks;
+
+    blocks = DVDFileSize (src->dvd_title);
+    if (blocks >= 0) {
+      *size = (gint64) blocks *DVD_VIDEO_LB_LEN;
+
+      ret = TRUE;
+    } else {
+      GST_WARNING_OBJECT (src, "DVDFileSize(%p) failed!", src->dvd_title);
+    }
+  }
+
+  return ret;
+}
+
+/*** Querying and seeking ***/
+
+static gboolean
+gst_dvd_read_src_handle_seek_event (GstDvdReadSrc * src, GstEvent * event)
+{
+  GstSeekFlags flags;
+  GstSeekType cur_type, end_type;
+  gint64 new_off, total;
+  GstFormat format;
+  GstPad *srcpad;
+  gboolean query_ok;
+  gdouble rate;
+
+  gst_event_parse_seek (event, &rate, &format, &flags, &cur_type, &new_off,
+      &end_type, NULL);
+
+  if (rate <= 0.0) {
+    GST_DEBUG_OBJECT (src, "cannot do backwards playback yet");
+    return FALSE;
+  }
+
+  if (end_type != GST_SEEK_TYPE_NONE) {
+    if ((format != chapter_format && format != GST_FORMAT_TIME) ||
+        end_type != GST_SEEK_TYPE_SET) {
+      GST_DEBUG_OBJECT (src, "end seek type not supported");
+      return FALSE;
+    }
+  }
+
+  if (cur_type != GST_SEEK_TYPE_SET) {
+    GST_DEBUG_OBJECT (src, "only SEEK_TYPE_SET is supported");
+    return FALSE;
+  }
+
+  if (format == angle_format) {
+    GST_OBJECT_LOCK (src);
+    if (new_off < 0 || new_off >= src->num_angles) {
+      GST_OBJECT_UNLOCK (src);
+      GST_DEBUG_OBJECT (src, "invalid angle %d, only %d available",
+          src->num_angles, src->num_angles);
+      return FALSE;
+    }
+    src->angle = (gint) new_off;
+    GST_OBJECT_UNLOCK (src);
+    GST_DEBUG_OBJECT (src, "switched to angle %d", (gint) new_off + 1);
+    return TRUE;
+  }
+
+  if (format != chapter_format && format != title_format &&
+      format != GST_FORMAT_BYTES && format != GST_FORMAT_TIME) {
+    GST_DEBUG_OBJECT (src, "unsupported seek format %d (%s)", format,
+        gst_format_get_name (format));
+    return FALSE;
+  }
+
+  if (format == GST_FORMAT_BYTES) {
+    GST_DEBUG_OBJECT (src, "Requested seek to byte %" G_GUINT64_FORMAT,
+        new_off);
+  } else if (format == GST_FORMAT_TIME) {
+    GST_DEBUG_OBJECT (src, "Requested seek to time %" GST_TIME_FORMAT,
+        GST_TIME_ARGS (new_off));
+    if (gst_dvd_read_src_get_sector_from_time (src, new_off) < 0) {
+      GST_DEBUG_OBJECT (src, "Can't find sector for requested time");
+      return FALSE;
+    }
+  }
+
+  srcpad = GST_BASE_SRC_PAD (src);
+
+  /* check whether the seek looks reasonable (ie within possible range) */
+  if (format == GST_FORMAT_BYTES) {
+    GST_OBJECT_LOCK (src);
+    query_ok = gst_dvd_read_src_get_size (src, &total);
+    GST_OBJECT_UNLOCK (src);
+  } else {
+    query_ok = gst_pad_query_duration (srcpad, format, &total);
+  }
+
+  if (!query_ok) {
+    GST_DEBUG_OBJECT (src, "Failed to query duration in format %s",
+        gst_format_get_name (format));
+    return FALSE;
+  }
+
+  GST_DEBUG_OBJECT (src, "Total      %s: %12" G_GINT64_FORMAT,
+      gst_format_get_name (format), total);
+  GST_DEBUG_OBJECT (src, "Seek to    %s: %12" G_GINT64_FORMAT,
+      gst_format_get_name (format), new_off);
+
+  if (new_off >= total) {
+    GST_DEBUG_OBJECT (src, "Seek position out of range");
+    return FALSE;
+  }
+
+  /* set segment to seek format; this allows us to use the do_seek
+   * virtual function and let the base source handle all the tricky
+   * stuff for us. We don't use the segment internally anyway */
+  /* FIXME: can't take the stream lock here - what to do? */
+  GST_OBJECT_LOCK (src);
+  GST_BASE_SRC (src)->segment.format = format;
+  GST_BASE_SRC (src)->segment.start = 0;
+  GST_BASE_SRC (src)->segment.stop = total;
+  GST_BASE_SRC (src)->segment.duration = total;
+  GST_OBJECT_UNLOCK (src);
+
+  return GST_BASE_SRC_CLASS (parent_class)->event (GST_BASE_SRC (src), event);
+}
+
+static void
+gst_dvd_read_src_get_sector_bounds (GstDvdReadSrc * src, gint * first,
+    gint * last)
+{
+  gint c1, c2, tmp;
+  cur_title_get_chapter_bounds (src, 0, &c1, &tmp);
+  cur_title_get_chapter_bounds (src, src->num_chapters - 1, &tmp, &c2);
+  *first = src->cur_pgc->cell_playback[c1].first_sector;
+  *last = src->cur_pgc->cell_playback[c2].last_sector;
+}
+
+static gboolean
+gst_dvd_read_src_do_seek (GstBaseSrc * basesrc, GstSegment * s)
+{
+  GstDvdReadSrc *src;
+
+  src = GST_DVD_READ_SRC (basesrc);
+
+  GST_DEBUG_OBJECT (src, "Seeking to %s: %12" G_GINT64_FORMAT,
+      gst_format_get_name (s->format), s->position);
+
+  if (s->format == sector_format || s->format == GST_FORMAT_BYTES
+      || s->format == GST_FORMAT_TIME) {
+    guint old;
+
+    old = src->cur_pack;
+
+    if (s->format == sector_format) {
+      gint first, last;
+      gst_dvd_read_src_get_sector_bounds (src, &first, &last);
+      GST_DEBUG_OBJECT (src, "Format is sector, seeking to %" G_GINT64_FORMAT,
+          s->position);
+      src->cur_pack = s->position;
+      if (src->cur_pack < first)
+        src->cur_pack = first;
+      if (src->cur_pack > last)
+        src->cur_pack = last;
+    } else if (s->format == GST_FORMAT_TIME) {
+      gint sector;
+      GST_DEBUG_OBJECT (src, "Format is time");
+
+      sector = gst_dvd_read_src_get_sector_from_time (src, s->position);
+
+      GST_DEBUG_OBJECT (src, "Time %" GST_TIME_FORMAT " => sector %d",
+          GST_TIME_ARGS (s->position), sector);
+
+      /* really shouldn't happen, we've checked this earlier ... */
+      g_return_val_if_fail (sector >= 0, FALSE);
+
+      src->cur_pack = sector;
+    } else {
+      /* byte format */
+      gint first, last;
+      gst_dvd_read_src_get_sector_bounds (src, &first, &last);
+      GST_DEBUG_OBJECT (src, "Format is byte");
+      src->cur_pack = s->position / DVD_VIDEO_LB_LEN;
+      if (((gint64) src->cur_pack * DVD_VIDEO_LB_LEN) != s->position) {
+        GST_LOG_OBJECT (src, "rounded down offset %" G_GINT64_FORMAT " => %"
+            G_GINT64_FORMAT, s->position,
+            (gint64) src->cur_pack * DVD_VIDEO_LB_LEN);
+      }
+      src->cur_pack += first;
+    }
+
+    if (!gst_dvd_read_src_goto_sector (src, src->angle)) {
+      GST_DEBUG_OBJECT (src, "seek to sector 0x%08x failed", src->cur_pack);
+      src->cur_pack = old;
+      return FALSE;
+    }
+
+    GST_LOG_OBJECT (src, "seek to sector 0x%08x ok", src->cur_pack);
+  } else if (s->format == chapter_format) {
+    if (!gst_dvd_read_src_goto_chapter (src, (gint) s->position)) {
+      GST_DEBUG_OBJECT (src, "seek to chapter %d failed",
+          (gint) s->position + 1);
+      return FALSE;
+    }
+    GST_INFO_OBJECT (src, "seek to chapter %d ok", (gint) s->position + 1);
+    src->chapter = s->position;
+  } else if (s->format == title_format) {
+    if (!gst_dvd_read_src_goto_title (src, (gint) s->position, src->angle) ||
+        !gst_dvd_read_src_goto_chapter (src, 0)) {
+      GST_DEBUG_OBJECT (src, "seek to title %d failed", (gint) s->position);
+      return FALSE;
+    }
+    src->title = (gint) s->position;
+    src->chapter = 0;
+    GST_INFO_OBJECT (src, "seek to title %d ok", src->title + 1);
+  } else {
+    g_return_val_if_reached (FALSE);
+  }
+
+  src->need_newsegment = TRUE;
+  return TRUE;
+}
+
+static gboolean
+gst_dvd_read_src_src_event (GstBaseSrc * basesrc, GstEvent * event)
+{
+  GstDvdReadSrc *src = GST_DVD_READ_SRC (basesrc);
+  gboolean res;
+
+  GST_LOG_OBJECT (src, "handling %s event", GST_EVENT_TYPE_NAME (event));
+
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_SEEK:
+      res = gst_dvd_read_src_handle_seek_event (src, event);
+      break;
+    default:
+      res = GST_BASE_SRC_CLASS (parent_class)->event (basesrc, event);
+      break;
+  }
+
+  return res;
+}
+
+static GstEvent *
+gst_dvd_read_src_make_clut_change_event (GstDvdReadSrc * src,
+    const guint * clut)
+{
+  GstStructure *structure;
+  gchar name[16];
+  gint i;
+
+  structure = gst_structure_new ("application/x-gst-dvd",
+      "event", G_TYPE_STRING, "dvd-spu-clut-change", NULL);
+
+  /* Create a separate field for each value in the table. */
+  for (i = 0; i < 16; i++) {
+    g_snprintf (name, sizeof (name), "clut%02d", i);
+    gst_structure_set (structure, name, G_TYPE_INT, (int) clut[i], NULL);
+  }
+
+  /* Create the DVD event and put the structure into it. */
+  return gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, structure);
+}
+
+static gint64
+gst_dvd_read_src_convert_timecode (dvd_time_t * time)
+{
+  gint64 ret_time;
+  const gint64 one_hour = 3600 * GST_SECOND;
+  const gint64 one_min = 60 * GST_SECOND;
+
+  g_return_val_if_fail ((time->hour >> 4) < 0xa
+      && (time->hour & 0xf) < 0xa, -1);
+  g_return_val_if_fail ((time->minute >> 4) < 0x7
+      && (time->minute & 0xf) < 0xa, -1);
+  g_return_val_if_fail ((time->second >> 4) < 0x7
+      && (time->second & 0xf) < 0xa, -1);
+
+  ret_time = ((time->hour >> 4) * 10 + (time->hour & 0xf)) * one_hour;
+  ret_time += ((time->minute >> 4) * 10 + (time->minute & 0xf)) * one_min;
+  ret_time += ((time->second >> 4) * 10 + (time->second & 0xf)) * GST_SECOND;
+
+  return ret_time;
+}
+
+static gboolean
+gst_dvd_read_src_do_duration_query (GstDvdReadSrc * src, GstQuery * query)
+{
+  GstFormat format;
+  gint64 val;
+
+  gst_query_parse_duration (query, &format, NULL);
+
+  switch (format) {
+    case GST_FORMAT_TIME:{
+      if (src->cur_pgc == NULL)
+        return FALSE;
+      val = gst_dvd_read_src_convert_timecode (&src->cur_pgc->playback_time);
+      if (val < 0)
+        return FALSE;
+      break;
+    }
+    case GST_FORMAT_BYTES:{
+      if (!gst_dvd_read_src_get_size (src, &val))
+        return FALSE;
+      break;
+    }
+    default:{
+      if (format == sector_format) {
+        val = DVDFileSize (src->dvd_title);
+      } else if (format == title_format) {
+        val = src->tt_srpt->nr_of_srpts;
+      } else if (format == chapter_format) {
+        val = src->num_chapters;
+      } else if (format == angle_format) {
+        val = src->tt_srpt->title[src->title].nr_of_angles;
+      } else {
+        GST_DEBUG_OBJECT (src, "Don't know how to handle format %d (%s)",
+            format, gst_format_get_name (format));
+        return FALSE;
+      }
+      break;
+    }
+  }
+
+  GST_LOG_OBJECT (src, "duration = %" G_GINT64_FORMAT " %s", val,
+      gst_format_get_name (format));
+
+  gst_query_set_duration (query, format, val);
+  return TRUE;
+}
+
+static gboolean
+gst_dvd_read_src_do_position_query (GstDvdReadSrc * src, GstQuery * query)
+{
+  GstFormat format;
+  gint64 val;
+
+  gst_query_parse_position (query, &format, NULL);
+
+  switch (format) {
+    case GST_FORMAT_BYTES:{
+      val = (gint64) src->cur_pack * DVD_VIDEO_LB_LEN;
+      break;
+    }
+    default:{
+      if (format == sector_format) {
+        val = src->cur_pack;
+      } else if (format == title_format) {
+        val = src->title;
+      } else if (format == chapter_format) {
+        val = src->chapter;
+      } else if (format == angle_format) {
+        val = src->angle;
+      } else {
+        GST_DEBUG_OBJECT (src, "Don't know how to handle format %d (%s)",
+            format, gst_format_get_name (format));
+        return FALSE;
+      }
+      break;
+    }
+  }
+
+  GST_LOG_OBJECT (src, "position = %" G_GINT64_FORMAT " %s", val,
+      gst_format_get_name (format));
+
+  gst_query_set_position (query, format, val);
+  return TRUE;
+}
+
+static gboolean
+gst_dvd_read_src_do_convert_query (GstDvdReadSrc * src, GstQuery * query)
+{
+  GstFormat src_format, dest_format;
+  gboolean ret = FALSE;
+  gint64 src_val, dest_val = -1;
+
+  gst_query_parse_convert (query, &src_format, &src_val, &dest_format, NULL);
+
+  if (src_format == dest_format) {
+    dest_val = src_val;
+    ret = TRUE;
+    goto done;
+  }
+
+  /* Formats to consider: TIME, DEFAULT, BYTES, title, chapter, sector.
+   * Note: title and chapter are counted as starting from 0 here, just like
+   * in the context of seek events. Another note: DEFAULT format is undefined */
+
+  if (src_format == GST_FORMAT_BYTES) {
+    src_format = sector_format;
+    src_val /= DVD_VIDEO_LB_LEN;
+  }
+
+  if (src_format == sector_format) {
+    /* SECTOR => xyz */
+    if (dest_format == GST_FORMAT_TIME && src_val < G_MAXUINT) {
+      dest_val = gst_dvd_read_src_get_time_for_sector (src, (guint) src_val);
+      ret = (dest_val >= 0);
+    } else if (dest_format == GST_FORMAT_BYTES) {
+      dest_val = src_val * DVD_VIDEO_LB_LEN;
+      ret = TRUE;
+    } else {
+      ret = FALSE;
+    }
+  } else if (src_format == title_format) {
+    /* TITLE => xyz */
+    if (dest_format == GST_FORMAT_TIME) {
+      /* not really true, but we use this to trick the base source into
+       * handling seeks in title-format for us (the source won't know that
+       * we changed the title in this case) (changing titles should really
+       * be done with an interface rather than a seek, but for now we're
+       * stuck with this mechanism. Fix in 0.11) */
+      dest_val = (GstClockTime) 0;
+      ret = TRUE;
+    } else {
+      ret = FALSE;
+    }
+  } else if (src_format == chapter_format) {
+    /* CHAPTER => xyz */
+    if (dest_format == GST_FORMAT_TIME) {
+      if (src->num_chapters >= 0 && src_val < src->num_chapters) {
+        dest_val = src->chapter_starts[src_val];
+        ret = TRUE;
+      }
+    } else if (dest_format == sector_format) {
+    } else {
+      ret = FALSE;
+    }
+  } else if (src_format == GST_FORMAT_TIME) {
+    /* TIME => xyz */
+    if (dest_format == sector_format || dest_format == GST_FORMAT_BYTES) {
+      dest_val = gst_dvd_read_src_get_sector_from_time (src, src_val);
+      ret = (dest_val >= 0);
+      if (dest_format == GST_FORMAT_BYTES)
+        dest_val *= DVD_VIDEO_LB_LEN;
+    } else if (dest_format == chapter_format) {
+      if (src->chapter_starts != NULL) {
+        gint i;
+
+        for (i = src->num_chapters - 1; i >= 0; --i) {
+          if (src->chapter_starts && src->chapter_starts[i] >= src_val) {
+            dest_val = i;
+            ret = TRUE;
+            break;
+          }
+        }
+      } else {
+        ret = FALSE;
+      }
+    } else {
+      ret = FALSE;
+    }
+  } else {
+    ret = FALSE;
+  }
+
+done:
+
+  if (ret) {
+    gst_query_set_convert (query, src_format, src_val, dest_format, dest_val);
+  }
+
+  return ret;
+}
+
+static gboolean
+gst_dvd_read_src_src_query (GstBaseSrc * basesrc, GstQuery * query)
+{
+  GstDvdReadSrc *src = GST_DVD_READ_SRC (basesrc);
+  gboolean started;
+  gboolean res = TRUE;
+
+  GST_LOG_OBJECT (src, "handling %s query",
+      gst_query_type_get_name (GST_QUERY_TYPE (query)));
+
+  GST_OBJECT_LOCK (src);
+  started = (GST_OBJECT_FLAG_IS_SET (src, GST_BASE_SRC_FLAG_STARTED));
+  GST_OBJECT_UNLOCK (src);
+
+  if (!started) {
+    GST_DEBUG_OBJECT (src, "query failed: not started");
+    return FALSE;
+  }
+
+  switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_DURATION:
+      GST_OBJECT_LOCK (src);
+      res = gst_dvd_read_src_do_duration_query (src, query);
+      GST_OBJECT_UNLOCK (src);
+      break;
+    case GST_QUERY_POSITION:
+      GST_OBJECT_LOCK (src);
+      res = gst_dvd_read_src_do_position_query (src, query);
+      GST_OBJECT_UNLOCK (src);
+      break;
+    case GST_QUERY_CONVERT:
+      GST_OBJECT_LOCK (src);
+      res = gst_dvd_read_src_do_convert_query (src, query);
+      GST_OBJECT_UNLOCK (src);
+      break;
+    default:
+      res = GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query);
+      break;
+  }
+
+  return res;
+}
+
+static gboolean
+gst_dvd_read_src_goto_sector (GstDvdReadSrc * src, int angle)
+{
+  gint seek_to = src->cur_pack;
+  gint chapter, next, cur, i;
+
+  /* retrieve position */
+  src->cur_pack = 0;
+  GST_DEBUG_OBJECT (src, "Goto sector %d, angle %d, within %d chapters",
+      seek_to, angle, src->num_chapters);
+
+  for (i = 0; i < src->num_chapters; i++) {
+    gint c1, c2;
+
+    cur_title_get_chapter_bounds (src, i, &c1, &c2);
+    GST_DEBUG_OBJECT (src, " Looking in chapter %d, bounds: %d %d", i, c1, c2);
+
+    for (next = cur = c1; cur < c2;) {
+      gint first = src->cur_pgc->cell_playback[cur].first_sector;
+      gint last = src->cur_pgc->cell_playback[cur].last_sector;
+      GST_DEBUG_OBJECT (src, "Cell %d sector bounds: %d %d", cur, first, last);
+      /* seeking to 0 should end up at first chapter in any case */
+      if ((seek_to >= first && seek_to <= last) || (seek_to == 0 && i == 0)) {
+        GST_DEBUG_OBJECT (src, "Seek target found in chapter %d", i);
+        chapter = i;
+        goto done;
+      }
+      cur = next;
+      if (src->cur_pgc->cell_playback[cur].block_type == BLOCK_TYPE_ANGLE_BLOCK)
+        cur += angle;
+      next = gst_dvd_read_src_get_next_cell (src, src->cur_pgc, cur);
+    }
+  }
+
+  GST_DEBUG_OBJECT (src, "Seek to sector %u failed", seek_to);
+
+  return FALSE;
+
+done:
+  {
+    /* so chapter $chapter and cell $cur contain our sector
+     * of interest. Let's go there! */
+    GST_INFO_OBJECT (src, "Seek succeeded, going to chapter %u, cell %u",
+        chapter + 1, cur);
+
+    gst_dvd_read_src_goto_chapter (src, chapter);
+    src->cur_cell = cur;
+    src->next_cell = next;
+    src->new_cell = FALSE;
+    src->cur_pack = seek_to;
+
+    return TRUE;
+  }
+}
+
+
+/*** URI interface ***/
+
+static GstURIType
+gst_dvd_read_src_uri_get_type (GType type)
+{
+  return GST_URI_SRC;
+}
+
+static const gchar *const *
+gst_dvd_read_src_uri_get_protocols (GType type)
+{
+  static const gchar *protocols[] = { "dvd", NULL };
+
+  return protocols;
+}
+
+static gchar *
+gst_dvd_read_src_uri_get_uri (GstURIHandler * handler)
+{
+  GstDvdReadSrc *src = GST_DVD_READ_SRC (handler);
+  gchar *uri;
+
+  GST_OBJECT_LOCK (src);
+  uri = g_strdup_printf ("dvd://%d,%d,%d", src->uri_title, src->uri_chapter,
+      src->uri_angle);
+  GST_OBJECT_UNLOCK (src);
+
+  return uri;
+}
+
+static gboolean
+gst_dvd_read_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
+    GError ** error)
+{
+  GstDvdReadSrc *src = GST_DVD_READ_SRC (handler);
+
+  /* parse out the new t/c/a and seek to them */
+  {
+    gchar *location = NULL;
+    gchar **strs;
+    gchar **strcur;
+    gint pos = 0;
+
+    location = gst_uri_get_location (uri);
+
+    GST_OBJECT_LOCK (src);
+
+    src->uri_title = 1;
+    src->uri_chapter = 1;
+    src->uri_angle = 1;
+
+    if (!location)
+      goto empty_location;
+
+    strcur = strs = g_strsplit (location, ",", 0);
+    while (strcur && *strcur) {
+      gint val;
+
+      if (!sscanf (*strcur, "%d", &val))
+        break;
+
+      if (val <= 0) {
+        g_warning ("Invalid value %d in URI '%s'. Must be 1 or greater",
+            val, location);
+        break;
+      }
+
+      switch (pos) {
+        case 0:
+          src->uri_title = val;
+          break;
+        case 1:
+          src->uri_chapter = val;
+          break;
+        case 2:
+          src->uri_angle = val;
+          break;
+      }
+
+      strcur++;
+      pos++;
+    }
+
+    if (pos > 0 && GST_OBJECT_FLAG_IS_SET (src, GST_BASE_SRC_FLAG_STARTED)) {
+      src->title = src->uri_title - 1;
+      src->chapter = src->uri_chapter - 1;
+      src->angle = src->uri_angle - 1;
+      src->new_seek = TRUE;
+    }
+
+    g_strfreev (strs);
+    g_free (location);
+
+  empty_location:
+
+    GST_OBJECT_UNLOCK (src);
+  }
+
+  return TRUE;
+}
+
+static void
+gst_dvd_read_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
+{
+  GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
+
+  iface->get_type = gst_dvd_read_src_uri_get_type;
+  iface->get_protocols = gst_dvd_read_src_uri_get_protocols;
+  iface->get_uri = gst_dvd_read_src_uri_get_uri;
+  iface->set_uri = gst_dvd_read_src_uri_set_uri;
+}
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  GST_DEBUG_CATEGORY_INIT (gstgst_dvd_read_src_debug, "dvdreadsrc", 0,
+      "DVD reader element based on dvdreadsrc");
+
+#ifdef ENABLE_NLS
+  GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
+      LOCALEDIR);
+  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif /* ENABLE_NLS */
+
+  if (!gst_element_register (plugin, "dvdreadsrc", GST_RANK_SECONDARY,
+          GST_TYPE_DVD_READ_SRC)) {
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    dvdread,
+    "Access a DVD with dvdread",
+    plugin_init, VERSION, "GPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
diff --git a/ext/dvdread/dvdreadsrc.h b/ext/dvdread/dvdreadsrc.h
new file mode 100644
index 0000000..9224379
--- /dev/null
+++ b/ext/dvdread/dvdreadsrc.h
@@ -0,0 +1,101 @@
+/* GStreamer DVD title source
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) <2001> Billy Biggs <vektor@dumbterm.net>.
+ * Copyright (C) <2006> Tim-Philipp Müller <tim centricular net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_DVD_READ_SRC_H__
+#define __GST_DVD_READ_SRC_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstpushsrc.h>
+
+#include <dvdread/dvd_reader.h>
+#include <dvdread/ifo_types.h>
+#include <dvdread/ifo_read.h>
+#include <dvdread/nav_read.h>
+#include <dvdread/nav_print.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_DVD_READ_SRC            (gst_dvd_read_src_get_type())
+#define GST_DVD_READ_SRC(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DVD_READ_SRC,GstDvdReadSrc))
+#define GST_DVD_READ_SRC_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DVD_READ_SRC,GstDvdReadSrcClass))
+#define GST_IS_DVD_READ_SRC(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DVD_READ_SRC))
+#define GST_IS_DVD_READ_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DVD_READ_SRC))
+
+typedef struct _GstDvdReadSrc GstDvdReadSrc;
+typedef struct _GstDvdReadSrcClass GstDvdReadSrcClass;
+
+struct _GstDvdReadSrc {
+  GstPushSrc       pushsrc;
+
+  /* location */
+  gchar           *location;
+
+  gboolean         new_seek;
+  gboolean         change_cell;
+
+  gboolean         new_cell;
+
+  gint             uri_title;     /* set via the URI handler or properties,  */
+  gint             uri_chapter;   /* otherwise not touched; these values     */
+  gint             uri_angle;     /* start from 1                            */
+
+  gint             title;         /* current position while open, set to the */
+  gint             chapter;       /* URI-set values in ::start(). these      */
+  gint             angle;         /* values start from 0                     */
+
+  gint             start_cell, last_cell, cur_cell;
+  gint             cur_pack;
+  gint             next_cell;
+  dvd_reader_t    *dvd;
+  ifo_handle_t    *vmg_file;
+
+  /* title stuff */
+  gint             ttn;
+  tt_srpt_t       *tt_srpt;
+  ifo_handle_t    *vts_file;
+  vts_ptt_srpt_t  *vts_ptt_srpt;
+  vts_tmapt_t     *vts_tmapt;
+  dvd_file_t      *dvd_title;
+  gint             num_chapters;
+  gint             num_angles;
+
+  GstClockTime    *chapter_starts;  /* start time of chapters within title   */
+
+  /* which program chain to watch (based on title and chapter number) */
+  pgc_t           *cur_pgc;
+  gint             pgc_id;
+  gint             pgn;
+
+  gboolean         need_newsegment;
+  GstEvent        *title_lang_event_pending;
+  GstEvent        *pending_clut_event;
+};
+
+struct _GstDvdReadSrcClass {
+  GstPushSrcClass parent_class;
+};
+
+GType gst_dvd_read_src_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_DVD_READ_SRC_H__ */
+
diff --git a/ext/lame/Makefile.am b/ext/lame/Makefile.am
new file mode 100644
index 0000000..d3a70c3
--- /dev/null
+++ b/ext/lame/Makefile.am
@@ -0,0 +1,11 @@
+plugin_LTLIBRARIES = libgstlame.la
+
+libgstlame_la_SOURCES = gstlamemp3enc.c plugin.c
+libgstlame_la_CFLAGS = -DGST_USE_UNSTABLE_API \
+        $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(LAME_CFLAGS)
+libgstlame_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) -lgstaudio-$(GST_API_VERSION) \
+	$(GST_BASE_LIBS) $(GST_LIBS) $(LAME_LIBS)
+libgstlame_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstlame_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS = gstlamemp3enc.h
diff --git a/ext/lame/Makefile.in b/ext/lame/Makefile.in
new file mode 100644
index 0000000..5daecc7
--- /dev/null
+++ b/ext/lame/Makefile.in
@@ -0,0 +1,760 @@
+# Makefile.in generated by automake 1.11.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = ext/lame
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \
+	$(top_srcdir)/common/m4/as-auto-alt.m4 \
+	$(top_srcdir)/common/m4/as-compiler-flag.m4 \
+	$(top_srcdir)/common/m4/as-python.m4 \
+	$(top_srcdir)/common/m4/as-scrub-include.m4 \
+	$(top_srcdir)/common/m4/as-version.m4 \
+	$(top_srcdir)/common/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/common/m4/gst-arch.m4 \
+	$(top_srcdir)/common/m4/gst-args.m4 \
+	$(top_srcdir)/common/m4/gst-check.m4 \
+	$(top_srcdir)/common/m4/gst-default.m4 \
+	$(top_srcdir)/common/m4/gst-dowhile.m4 \
+	$(top_srcdir)/common/m4/gst-error.m4 \
+	$(top_srcdir)/common/m4/gst-feature.m4 \
+	$(top_srcdir)/common/m4/gst-function.m4 \
+	$(top_srcdir)/common/m4/gst-gettext.m4 \
+	$(top_srcdir)/common/m4/gst-glib2.m4 \
+	$(top_srcdir)/common/m4/gst-package-release-datetime.m4 \
+	$(top_srcdir)/common/m4/gst-plugin-docs.m4 \
+	$(top_srcdir)/common/m4/gst-plugindir.m4 \
+	$(top_srcdir)/common/m4/gst.m4 \
+	$(top_srcdir)/common/m4/gtk-doc.m4 \
+	$(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \
+	$(top_srcdir)/m4/a52.m4 $(top_srcdir)/m4/gettext.m4 \
+	$(top_srcdir)/m4/gst-sid.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+	$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(plugindir)"
+LTLIBRARIES = $(plugin_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libgstlame_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am_libgstlame_la_OBJECTS = libgstlame_la-gstlamemp3enc.lo \
+	libgstlame_la-plugin.lo
+libgstlame_la_OBJECTS = $(am_libgstlame_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+libgstlame_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+	$(libgstlame_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+	$(CCLD) $(libgstlame_la_CFLAGS) $(CFLAGS) \
+	$(libgstlame_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libgstlame_la_SOURCES)
+DIST_SOURCES = $(libgstlame_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+A52DEC_CFLAGS = @A52DEC_CFLAGS@
+A52DEC_LIBS = @A52DEC_LIBS@
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMRNB_CFLAGS = @AMRNB_CFLAGS@
+AMRNB_LIBS = @AMRNB_LIBS@
+AMRWB_CFLAGS = @AMRWB_CFLAGS@
+AMRWB_LIBS = @AMRWB_LIBS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CDIO_CFLAGS = @CDIO_CFLAGS@
+CDIO_LIBS = @CDIO_LIBS@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@
+DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@
+DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@
+DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@
+DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DVDREAD_LIBS = @DVDREAD_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+ERROR_CXXFLAGS = @ERROR_CXXFLAGS@
+EXEEXT = @EXEEXT@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+GCOV = @GCOV@
+GCOV_CFLAGS = @GCOV_CFLAGS@
+GCOV_LIBS = @GCOV_LIBS@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LDFLAGS = @GIO_LDFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_PREFIX = @GLIB_PREFIX@
+GLIB_REQ = @GLIB_REQ@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@
+GSTPB_PREFIX = @GSTPB_PREFIX@
+GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@
+GST_API_VERSION = @GST_API_VERSION@
+GST_BASE_CFLAGS = @GST_BASE_CFLAGS@
+GST_BASE_LIBS = @GST_BASE_LIBS@
+GST_CFLAGS = @GST_CFLAGS@
+GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@
+GST_CHECK_LIBS = @GST_CHECK_LIBS@
+GST_CXXFLAGS = @GST_CXXFLAGS@
+GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@
+GST_LIBS = @GST_LIBS@
+GST_LICENSE = @GST_LICENSE@
+GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@
+GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@
+GST_PACKAGE_NAME = @GST_PACKAGE_NAME@
+GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@
+GST_PLUGINS_ALL = @GST_PLUGINS_ALL@
+GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@
+GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@
+GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@
+GST_PLUGINS_DIR = @GST_PLUGINS_DIR@
+GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@
+GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GST_PREFIX = @GST_PREFIX@
+GST_TOOLS_DIR = @GST_TOOLS_DIR@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DVDREAD = @HAVE_DVDREAD@
+HAVE_LAME = @HAVE_LAME@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LAME_CFLAGS = @LAME_CFLAGS@
+LAME_LIBS = @LAME_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAD_CFLAGS = @MAD_CFLAGS@
+MAD_LIBS = @MAD_LIBS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MPEG2DEC_CFLAGS = @MPEG2DEC_CFLAGS@
+MPEG2DEC_LIBS = @MPEG2DEC_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ORCC = @ORCC@
+ORCC_FLAGS = @ORCC_FLAGS@
+ORC_CFLAGS = @ORC_CFLAGS@
+ORC_LIBS = @ORC_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@
+PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGINDIR = @PLUGINDIR@
+POSUB = @POSUB@
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIDPLAY_CFLAGS = @SIDPLAY_CFLAGS@
+SIDPLAY_LIBS = @SIDPLAY_LIBS@
+STRIP = @STRIP@
+TWOLAME_CFLAGS = @TWOLAME_CFLAGS@
+TWOLAME_LIBS = @TWOLAME_LIBS@
+USE_NLS = @USE_NLS@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VALGRIND_PATH = @VALGRIND_PATH@
+VERSION = @VERSION@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WIN32_LIBS = @WIN32_LIBS@
+X264_CFLAGS = @X264_CFLAGS@
+X264_LIBS = @X264_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+plugindir = @plugindir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+plugin_LTLIBRARIES = libgstlame.la
+libgstlame_la_SOURCES = gstlamemp3enc.c plugin.c
+libgstlame_la_CFLAGS = -DGST_USE_UNSTABLE_API \
+        $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(LAME_CFLAGS)
+
+libgstlame_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) -lgstaudio-$(GST_API_VERSION) \
+	$(GST_BASE_LIBS) $(GST_LIBS) $(LAME_LIBS)
+
+libgstlame_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstlame_la_LIBTOOLFLAGS = --tag=disable-static
+noinst_HEADERS = gstlamemp3enc.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/lame/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu ext/lame/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \
+	  $(MKDIR_P) '$(DESTDIR)$(plugindir)' || exit 1; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+	}
+
+uninstall-pluginLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+	done
+
+clean-pluginLTLIBRARIES:
+	-test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+	@list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libgstlame.la: $(libgstlame_la_OBJECTS) $(libgstlame_la_DEPENDENCIES) $(EXTRA_libgstlame_la_DEPENDENCIES) 
+	$(AM_V_CCLD)$(libgstlame_la_LINK) -rpath $(plugindir) $(libgstlame_la_OBJECTS) $(libgstlame_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstlame_la-gstlamemp3enc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstlame_la-plugin.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+libgstlame_la-gstlamemp3enc.lo: gstlamemp3enc.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstlame_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstlame_la_CFLAGS) $(CFLAGS) -MT libgstlame_la-gstlamemp3enc.lo -MD -MP -MF $(DEPDIR)/libgstlame_la-gstlamemp3enc.Tpo -c -o libgstlame_la-gstlamemp3enc.lo `test -f 'gstlamemp3enc.c' || echo '$(srcdir)/'`gstlamemp3enc.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgstlame_la-gstlamemp3enc.Tpo $(DEPDIR)/libgstlame_la-gstlamemp3enc.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gstlamemp3enc.c' object='libgstlame_la-gstlamemp3enc.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstlame_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstlame_la_CFLAGS) $(CFLAGS) -c -o libgstlame_la-gstlamemp3enc.lo `test -f 'gstlamemp3enc.c' || echo '$(srcdir)/'`gstlamemp3enc.c
+
+libgstlame_la-plugin.lo: plugin.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstlame_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstlame_la_CFLAGS) $(CFLAGS) -MT libgstlame_la-plugin.lo -MD -MP -MF $(DEPDIR)/libgstlame_la-plugin.Tpo -c -o libgstlame_la-plugin.lo `test -f 'plugin.c' || echo '$(srcdir)/'`plugin.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgstlame_la-plugin.Tpo $(DEPDIR)/libgstlame_la-plugin.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='plugin.c' object='libgstlame_la-plugin.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstlame_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstlame_la_CFLAGS) $(CFLAGS) -c -o libgstlame_la-plugin.lo `test -f 'plugin.c' || echo '$(srcdir)/'`plugin.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(plugindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pluginLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pluginLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pluginLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/ext/lame/gstlamemp3enc.c b/ext/lame/gstlamemp3enc.c
new file mode 100644
index 0000000..c2b0871
--- /dev/null
+++ b/ext/lame/gstlamemp3enc.c
@@ -0,0 +1,925 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) <2004> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
+ * Copyright (C) <2009> Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * SECTION:element-lamemp3enc
+ * @see_also: lame, mad, vorbisenc
+ *
+ * This element encodes raw integer audio into an MPEG-1 layer 3 (MP3) stream.
+ * Note that <ulink url="http://en.wikipedia.org/wiki/MP3">MP3</ulink> is not
+ * a free format, there are licensing and patent issues to take into
+ * consideration. See <ulink url="http://www.vorbis.com/">Ogg/Vorbis</ulink>
+ * for a royalty free (and often higher quality) alternative.
+ *
+ * <refsect2>
+ * <title>Output sample rate</title>
+ * If no fixed output sample rate is negotiated on the element's src pad,
+ * the element will choose an optimal sample rate to resample to internally.
+ * For example, a 16-bit 44.1 KHz mono audio stream encoded at 48 kbit will
+ * get resampled to 32 KHz.  Use filter caps on the src pad to force a
+ * particular sample rate.
+ * </refsect2>
+ * <refsect2>
+ * <title>Example pipelines</title>
+ * |[
+ * gst-launch -v audiotestsrc wave=sine num-buffers=100 ! audioconvert ! lamemp3enc ! filesink location=sine.mp3
+ * ]| Encode a test sine signal to MP3.
+ * |[
+ * gst-launch -v alsasrc ! audioconvert ! lamemp3enc target=bitrate bitrate=192 ! filesink location=alsasrc.mp3
+ * ]| Record from a sound card using ALSA and encode to MP3 with an average bitrate of 192kbps
+ * |[
+ * gst-launch -v filesrc location=music.wav ! decodebin ! audioconvert ! audioresample ! lamemp3enc target=quality quality=0 ! id3v2mux ! filesink location=music.mp3
+ * ]| Transcode from a .wav file to MP3 (the id3v2mux element is optional) with best VBR quality
+ * |[
+ * gst-launch -v cdda://5 ! audioconvert ! lamemp3enc target=bitrate cbr=true bitrate=192 ! filesink location=track5.mp3
+ * ]| Encode Audio CD track 5 to MP3 with a constant bitrate of 192kbps
+ * |[
+ * gst-launch -v audiotestsrc num-buffers=10 ! audio/x-raw,rate=44100,channels=1 ! lamemp3enc target=bitrate cbr=true bitrate=48 ! filesink location=test.mp3
+ * ]| Encode to a fixed sample rate
+ * </refsect2>
+ *
+ * Since: 0.10.12
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "gstlamemp3enc.h"
+#include <gst/gst-i18n-plugin.h>
+
+/* lame < 3.98 */
+#ifndef HAVE_LAME_SET_VBR_QUALITY
+#define lame_set_VBR_quality(flags,q) lame_set_VBR_q((flags),(int)(q))
+#endif
+
+GST_DEBUG_CATEGORY_STATIC (debug);
+#define GST_CAT_DEFAULT debug
+
+/* elementfactory information */
+
+/* LAMEMP3ENC can do MPEG-1, MPEG-2, and MPEG-2.5, so it has 9 possible
+ * sample rates it supports */
+static GstStaticPadTemplate gst_lamemp3enc_sink_template =
+    GST_STATIC_PAD_TEMPLATE ("sink",
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " GST_AUDIO_NE (S16) ", "
+        "layout = (string) interleaved, "
+        "rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
+        "channels = (int) 1; "
+        "audio/x-raw, "
+        "format = (string) " GST_AUDIO_NE (S16) ", "
+        "layout = (string) interleaved, "
+        "rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
+        "channels = (int) 2, " "channel-mask = (bitmask) 0x3")
+    );
+
+static GstStaticPadTemplate gst_lamemp3enc_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/mpeg, "
+        "mpegversion = (int) 1, "
+        "layer = (int) 3, "
+        "rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
+        "channels = (int) [ 1, 2 ]")
+    );
+
+/********** Define useful types for non-programmatic interfaces **********/
+enum
+{
+  LAMEMP3ENC_TARGET_QUALITY = 0,
+  LAMEMP3ENC_TARGET_BITRATE
+};
+
+#define GST_TYPE_LAMEMP3ENC_TARGET (gst_lamemp3enc_target_get_type())
+static GType
+gst_lamemp3enc_target_get_type (void)
+{
+  static GType lame_target_type = 0;
+  static GEnumValue lame_targets[] = {
+    {LAMEMP3ENC_TARGET_QUALITY, "Quality", "quality"},
+    {LAMEMP3ENC_TARGET_BITRATE, "Bitrate", "bitrate"},
+    {0, NULL, NULL}
+  };
+
+  if (!lame_target_type) {
+    lame_target_type =
+        g_enum_register_static ("GstLameMP3EncTarget", lame_targets);
+  }
+  return lame_target_type;
+}
+
+enum
+{
+  LAMEMP3ENC_ENCODING_ENGINE_QUALITY_FAST = 0,
+  LAMEMP3ENC_ENCODING_ENGINE_QUALITY_STANDARD,
+  LAMEMP3ENC_ENCODING_ENGINE_QUALITY_HIGH
+};
+
+#define GST_TYPE_LAMEMP3ENC_ENCODING_ENGINE_QUALITY (gst_lamemp3enc_encoding_engine_quality_get_type())
+static GType
+gst_lamemp3enc_encoding_engine_quality_get_type (void)
+{
+  static GType lame_encoding_engine_quality_type = 0;
+  static GEnumValue lame_encoding_engine_quality[] = {
+    {0, "Fast", "fast"},
+    {1, "Standard", "standard"},
+    {2, "High", "high"},
+    {0, NULL, NULL}
+  };
+
+  if (!lame_encoding_engine_quality_type) {
+    lame_encoding_engine_quality_type =
+        g_enum_register_static ("GstLameMP3EncEncodingEngineQuality",
+        lame_encoding_engine_quality);
+  }
+  return lame_encoding_engine_quality_type;
+}
+
+/********** Standard stuff for signals and arguments **********/
+
+enum
+{
+  ARG_0,
+  ARG_TARGET,
+  ARG_BITRATE,
+  ARG_CBR,
+  ARG_QUALITY,
+  ARG_ENCODING_ENGINE_QUALITY,
+  ARG_MONO
+};
+
+#define DEFAULT_TARGET LAMEMP3ENC_TARGET_QUALITY
+#define DEFAULT_BITRATE 128
+#define DEFAULT_CBR FALSE
+#define DEFAULT_QUALITY 4
+#define DEFAULT_ENCODING_ENGINE_QUALITY LAMEMP3ENC_ENCODING_ENGINE_QUALITY_STANDARD
+#define DEFAULT_MONO FALSE
+
+static gboolean gst_lamemp3enc_start (GstAudioEncoder * enc);
+static gboolean gst_lamemp3enc_stop (GstAudioEncoder * enc);
+static gboolean gst_lamemp3enc_set_format (GstAudioEncoder * enc,
+    GstAudioInfo * info);
+static GstFlowReturn gst_lamemp3enc_handle_frame (GstAudioEncoder * enc,
+    GstBuffer * in_buf);
+static void gst_lamemp3enc_flush (GstAudioEncoder * enc);
+
+static void gst_lamemp3enc_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec);
+static void gst_lamemp3enc_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec);
+static gboolean gst_lamemp3enc_setup (GstLameMP3Enc * lame, GstTagList ** tags);
+
+#define gst_lamemp3enc_parent_class parent_class
+G_DEFINE_TYPE (GstLameMP3Enc, gst_lamemp3enc, GST_TYPE_AUDIO_ENCODER);
+
+static void
+gst_lamemp3enc_release_memory (GstLameMP3Enc * lame)
+{
+  if (lame->lgf) {
+    lame_close (lame->lgf);
+    lame->lgf = NULL;
+  }
+}
+
+static void
+gst_lamemp3enc_finalize (GObject * obj)
+{
+  gst_lamemp3enc_release_memory (GST_LAMEMP3ENC (obj));
+
+  G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+static void
+gst_lamemp3enc_class_init (GstLameMP3EncClass * klass)
+{
+  GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
+  GstAudioEncoderClass *base_class;
+
+  gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
+  base_class = (GstAudioEncoderClass *) klass;
+
+  gobject_class->set_property = gst_lamemp3enc_set_property;
+  gobject_class->get_property = gst_lamemp3enc_get_property;
+  gobject_class->finalize = gst_lamemp3enc_finalize;
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_lamemp3enc_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_lamemp3enc_sink_template));
+
+  gst_element_class_set_static_metadata (gstelement_class,
+      "L.A.M.E. mp3 encoder", "Codec/Encoder/Audio",
+      "High-quality free MP3 encoder",
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
+  base_class->start = GST_DEBUG_FUNCPTR (gst_lamemp3enc_start);
+  base_class->stop = GST_DEBUG_FUNCPTR (gst_lamemp3enc_stop);
+  base_class->set_format = GST_DEBUG_FUNCPTR (gst_lamemp3enc_set_format);
+  base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_lamemp3enc_handle_frame);
+  base_class->flush = GST_DEBUG_FUNCPTR (gst_lamemp3enc_flush);
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TARGET,
+      g_param_spec_enum ("target", "Target",
+          "Optimize for quality or bitrate", GST_TYPE_LAMEMP3ENC_TARGET,
+          DEFAULT_TARGET,
+          G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
+      g_param_spec_int ("bitrate", "Bitrate (kb/s)",
+          "Bitrate in kbit/sec (Only valid if target is bitrate, for CBR one "
+          "of 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, "
+          "256 or 320)", 8, 320, DEFAULT_BITRATE,
+          G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CBR,
+      g_param_spec_boolean ("cbr", "CBR", "Enforce constant bitrate encoding "
+          "(Only valid if target is bitrate)", DEFAULT_CBR,
+          G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUALITY,
+      g_param_spec_float ("quality", "Quality",
+          "VBR Quality from 0 to 10, 0 being the best "
+          "(Only valid if target is quality)", 0.0, 9.999,
+          DEFAULT_QUALITY,
+          G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (G_OBJECT_CLASS (klass),
+      ARG_ENCODING_ENGINE_QUALITY, g_param_spec_enum ("encoding-engine-quality",
+          "Encoding Engine Quality", "Quality/speed of the encoding engine, "
+          "this does not affect the bitrate!",
+          GST_TYPE_LAMEMP3ENC_ENCODING_ENGINE_QUALITY,
+          DEFAULT_ENCODING_ENGINE_QUALITY,
+          G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MONO,
+      g_param_spec_boolean ("mono", "Mono", "Enforce mono encoding",
+          DEFAULT_MONO,
+          G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
+
+static void
+gst_lamemp3enc_init (GstLameMP3Enc * lame)
+{
+}
+
+static gboolean
+gst_lamemp3enc_start (GstAudioEncoder * enc)
+{
+  GstLameMP3Enc *lame = GST_LAMEMP3ENC (enc);
+
+  GST_DEBUG_OBJECT (lame, "start");
+
+  if (!lame->adapter)
+    lame->adapter = gst_adapter_new ();
+  gst_adapter_clear (lame->adapter);
+
+  return TRUE;
+}
+
+static gboolean
+gst_lamemp3enc_stop (GstAudioEncoder * enc)
+{
+  GstLameMP3Enc *lame = GST_LAMEMP3ENC (enc);
+
+  GST_DEBUG_OBJECT (lame, "stop");
+
+  if (lame->adapter) {
+    g_object_unref (lame->adapter);
+    lame->adapter = NULL;
+  }
+
+  gst_lamemp3enc_release_memory (lame);
+  return TRUE;
+}
+
+static gboolean
+gst_lamemp3enc_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
+{
+  GstLameMP3Enc *lame;
+  gint out_samplerate;
+  gint version;
+  GstCaps *othercaps;
+  GstClockTime latency;
+  GstTagList *tags = NULL;
+
+  lame = GST_LAMEMP3ENC (enc);
+
+  /* parameters already parsed for us */
+  lame->samplerate = GST_AUDIO_INFO_RATE (info);
+  lame->num_channels = GST_AUDIO_INFO_CHANNELS (info);
+
+  /* but we might be asked to reconfigure, so reset */
+  gst_lamemp3enc_release_memory (lame);
+
+  GST_DEBUG_OBJECT (lame, "setting up lame");
+  if (!gst_lamemp3enc_setup (lame, &tags))
+    goto setup_failed;
+
+  out_samplerate = lame_get_out_samplerate (lame->lgf);
+  if (out_samplerate == 0)
+    goto zero_output_rate;
+  if (out_samplerate != lame->samplerate) {
+    GST_WARNING_OBJECT (lame,
+        "output samplerate %d is different from incoming samplerate %d",
+        out_samplerate, lame->samplerate);
+  }
+  lame->out_samplerate = out_samplerate;
+
+  version = lame_get_version (lame->lgf);
+  if (version == 0)
+    version = 2;
+  else if (version == 1)
+    version = 1;
+  else if (version == 2)
+    version = 3;
+
+  othercaps =
+      gst_caps_new_simple ("audio/mpeg",
+      "mpegversion", G_TYPE_INT, 1,
+      "mpegaudioversion", G_TYPE_INT, version,
+      "layer", G_TYPE_INT, 3,
+      "channels", G_TYPE_INT, lame->mono ? 1 : lame->num_channels,
+      "rate", G_TYPE_INT, out_samplerate, NULL);
+
+  /* and use these caps */
+  gst_audio_encoder_set_output_format (GST_AUDIO_ENCODER (enc), othercaps);
+  gst_caps_unref (othercaps);
+
+  /* base class feedback:
+   * - we will handle buffers, just hand us all available
+   * - report latency */
+  latency = gst_util_uint64_scale_int (lame_get_framesize (lame->lgf),
+      GST_SECOND, lame->samplerate);
+  gst_audio_encoder_set_latency (enc, latency, latency);
+
+  if (tags) {
+    gst_audio_encoder_merge_tags (enc, tags, GST_TAG_MERGE_REPLACE);
+    gst_tag_list_free (tags);
+  }
+
+  return TRUE;
+
+zero_output_rate:
+  {
+    if (tags)
+      gst_tag_list_free (tags);
+    GST_ELEMENT_ERROR (lame, LIBRARY, SETTINGS, (NULL),
+        ("LAME mp3 audio decided on a zero sample rate"));
+    return FALSE;
+  }
+setup_failed:
+  {
+    GST_ELEMENT_ERROR (lame, LIBRARY, SETTINGS,
+        (_("Failed to configure LAME mp3 audio encoder. Check your encoding parameters.")), (NULL));
+    return FALSE;
+  }
+}
+
+/* <php-emulation-mode>three underscores for ___rate is really really really
+ * private as opposed to one underscore<php-emulation-mode> */
+/* call this MACRO outside of the NULL state so that we have a higher chance
+ * of actually having a pipeline and bus to get the message through */
+
+#define CHECK_AND_FIXUP_BITRATE(obj,param,rate)		 		  \
+G_STMT_START {                                                            \
+  gint ___rate = rate;                                                    \
+  gint maxrate = 320;							  \
+  gint multiplier = 64;							  \
+  if (rate == 0) {                                                        \
+    ___rate = rate;                                                       \
+  } else if (rate <= 64) {				                  \
+    maxrate = 64; multiplier = 8;                                         \
+    if ((rate % 8) != 0) ___rate = GST_ROUND_UP_8 (rate); 		  \
+  } else if (rate <= 128) {						  \
+    maxrate = 128; multiplier = 16;                                       \
+    if ((rate % 16) != 0) ___rate = GST_ROUND_UP_16 (rate);               \
+  } else if (rate <= 256) {						  \
+    maxrate = 256; multiplier = 32;                                       \
+    if ((rate % 32) != 0) ___rate = GST_ROUND_UP_32 (rate);               \
+  } else if (rate <= 320) { 						  \
+    maxrate = 320; multiplier = 64;                                       \
+    if ((rate % 64) != 0) ___rate = GST_ROUND_UP_64 (rate);               \
+  }                                                                       \
+  if (___rate != rate) {                                                  \
+    GST_ELEMENT_WARNING (obj, LIBRARY, SETTINGS,			  \
+      (_("The requested bitrate %d kbit/s for property '%s' "             \
+       "is not allowed. "  					          \
+       "The bitrate was changed to %d kbit/s."), rate,		          \
+         param,  ___rate), 					          \
+       ("A bitrate below %d should be a multiple of %d.", 		  \
+          maxrate, multiplier));		  			  \
+    rate = ___rate;                                                       \
+  }                                                                       \
+} G_STMT_END
+
+static void
+gst_lamemp3enc_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec)
+{
+  GstLameMP3Enc *lame;
+
+  lame = GST_LAMEMP3ENC (object);
+
+  switch (prop_id) {
+    case ARG_TARGET:
+      lame->target = g_value_get_enum (value);
+      break;
+    case ARG_BITRATE:
+      lame->bitrate = g_value_get_int (value);
+      break;
+    case ARG_CBR:
+      lame->cbr = g_value_get_boolean (value);
+      break;
+    case ARG_QUALITY:
+      lame->quality = g_value_get_float (value);
+      break;
+    case ARG_ENCODING_ENGINE_QUALITY:
+      lame->encoding_engine_quality = g_value_get_enum (value);
+      break;
+    case ARG_MONO:
+      lame->mono = g_value_get_boolean (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+gst_lamemp3enc_get_property (GObject * object, guint prop_id, GValue * value,
+    GParamSpec * pspec)
+{
+  GstLameMP3Enc *lame;
+
+  lame = GST_LAMEMP3ENC (object);
+
+  switch (prop_id) {
+    case ARG_TARGET:
+      g_value_set_enum (value, lame->target);
+      break;
+    case ARG_BITRATE:
+      g_value_set_int (value, lame->bitrate);
+      break;
+    case ARG_CBR:
+      g_value_set_boolean (value, lame->cbr);
+      break;
+    case ARG_QUALITY:
+      g_value_set_float (value, lame->quality);
+      break;
+    case ARG_ENCODING_ENGINE_QUALITY:
+      g_value_set_enum (value, lame->encoding_engine_quality);
+      break;
+    case ARG_MONO:
+      g_value_set_boolean (value, lame->mono);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+/* **** credits go to mpegaudioparse **** */
+
+static const guint mp3types_bitrates[2][3][16] = {
+  {
+        {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,},
+        {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,},
+        {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,}
+      },
+  {
+        {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,},
+        {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,},
+        {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}
+      },
+};
+
+static const guint mp3types_freqs[3][3] = { {44100, 48000, 32000},
+{22050, 24000, 16000},
+{11025, 12000, 8000}
+};
+
+static inline guint
+mp3_type_frame_length_from_header (GstLameMP3Enc * lame, guint32 header,
+    guint * put_version, guint * put_layer, guint * put_channels,
+    guint * put_bitrate, guint * put_samplerate, guint * put_mode,
+    guint * put_crc)
+{
+  guint length;
+  gulong mode, samplerate, bitrate, layer, channels, padding, crc;
+  gulong version;
+  gint lsf, mpg25;
+
+  if (header & (1 << 20)) {
+    lsf = (header & (1 << 19)) ? 0 : 1;
+    mpg25 = 0;
+  } else {
+    lsf = 1;
+    mpg25 = 1;
+  }
+
+  version = 1 + lsf + mpg25;
+
+  layer = 4 - ((header >> 17) & 0x3);
+
+  crc = (header >> 16) & 0x1;
+
+  bitrate = (header >> 12) & 0xF;
+  bitrate = mp3types_bitrates[lsf][layer - 1][bitrate] * 1000;
+  /* The caller has ensured we have a valid header, so bitrate can't be
+     zero here. */
+  g_assert (bitrate != 0);
+
+  samplerate = (header >> 10) & 0x3;
+  samplerate = mp3types_freqs[lsf + mpg25][samplerate];
+
+  padding = (header >> 9) & 0x1;
+
+  mode = (header >> 6) & 0x3;
+  channels = (mode == 3) ? 1 : 2;
+
+  switch (layer) {
+    case 1:
+      length = 4 * ((bitrate * 12) / samplerate + padding);
+      break;
+    case 2:
+      length = (bitrate * 144) / samplerate + padding;
+      break;
+    default:
+    case 3:
+      length = (bitrate * 144) / (samplerate << lsf) + padding;
+      break;
+  }
+
+  GST_DEBUG_OBJECT (lame, "Calculated mp3 frame length of %u bytes", length);
+  GST_DEBUG_OBJECT (lame, "samplerate = %lu, bitrate = %lu, version = %lu, "
+      "layer = %lu, channels = %lu", samplerate, bitrate, version,
+      layer, channels);
+
+  if (put_version)
+    *put_version = version;
+  if (put_layer)
+    *put_layer = layer;
+  if (put_channels)
+    *put_channels = channels;
+  if (put_bitrate)
+    *put_bitrate = bitrate;
+  if (put_samplerate)
+    *put_samplerate = samplerate;
+  if (put_mode)
+    *put_mode = mode;
+  if (put_crc)
+    *put_crc = crc;
+
+  return length;
+}
+
+static gboolean
+mp3_sync_check (GstLameMP3Enc * lame, unsigned long head)
+{
+  GST_DEBUG_OBJECT (lame, "checking mp3 header 0x%08lx", head);
+  /* if it's not a valid sync */
+  if ((head & 0xffe00000) != 0xffe00000) {
+    GST_WARNING_OBJECT (lame, "invalid sync");
+    return FALSE;
+  }
+  /* if it's an invalid MPEG version */
+  if (((head >> 19) & 3) == 0x1) {
+    GST_WARNING_OBJECT (lame, "invalid MPEG version: 0x%lx", (head >> 19) & 3);
+    return FALSE;
+  }
+  /* if it's an invalid layer */
+  if (!((head >> 17) & 3)) {
+    GST_WARNING_OBJECT (lame, "invalid layer: 0x%lx", (head >> 17) & 3);
+    return FALSE;
+  }
+  /* if it's an invalid bitrate */
+  if (((head >> 12) & 0xf) == 0x0) {
+    GST_WARNING_OBJECT (lame, "invalid bitrate: 0x%lx."
+        "Free format files are not supported yet", (head >> 12) & 0xf);
+    return FALSE;
+  }
+  if (((head >> 12) & 0xf) == 0xf) {
+    GST_WARNING_OBJECT (lame, "invalid bitrate: 0x%lx", (head >> 12) & 0xf);
+    return FALSE;
+  }
+  /* if it's an invalid samplerate */
+  if (((head >> 10) & 0x3) == 0x3) {
+    GST_WARNING_OBJECT (lame, "invalid samplerate: 0x%lx", (head >> 10) & 0x3);
+    return FALSE;
+  }
+
+  if ((head & 0x3) == 0x2) {
+    /* Ignore this as there are some files with emphasis 0x2 that can
+     * be played fine. See BGO #537235 */
+    GST_WARNING_OBJECT (lame, "invalid emphasis: 0x%lx", head & 0x3);
+  }
+
+  return TRUE;
+}
+
+/* **** end mpegaudioparse **** */
+
+static GstFlowReturn
+gst_lamemp3enc_finish_frames (GstLameMP3Enc * lame)
+{
+  gint av;
+  guint header;
+  GstFlowReturn result = GST_FLOW_OK;
+
+  /* limited parsing, we don't expect to lose sync here */
+  while ((result == GST_FLOW_OK) &&
+      ((av = gst_adapter_available (lame->adapter)) > 4)) {
+    guint rate, version, layer, size;
+    GstBuffer *mp3_buf;
+    const guint8 *data;
+
+    data = gst_adapter_map (lame->adapter, 4);
+    header = GST_READ_UINT32_BE (data);
+    gst_adapter_unmap (lame->adapter);
+
+    if (!mp3_sync_check (lame, header))
+      goto invalid_header;
+
+    size = mp3_type_frame_length_from_header (lame, header, &version, &layer,
+        NULL, NULL, &rate, NULL, NULL);
+
+    if (G_UNLIKELY (layer != 3 || rate != lame->out_samplerate)) {
+      GST_DEBUG_OBJECT (lame,
+          "unexpected mp3 header with rate %u, version %u, layer %u",
+          rate, version, layer);
+      goto invalid_header;
+    }
+
+    if (size > av) {
+      /* pretty likely to occur when lame is holding back on us */
+      GST_LOG_OBJECT (lame, "frame size %u (> %d)", size, av);
+      break;
+    }
+
+    /* should be ok now */
+    mp3_buf = gst_adapter_take_buffer (lame->adapter, size);
+    /* number of samples for MPEG-1, layer 3 */
+    result = gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER (lame),
+        mp3_buf, version == 1 ? 1152 : 576);
+  }
+
+exit:
+  return result;
+
+  /* ERRORS */
+invalid_header:
+  {
+    GST_ELEMENT_ERROR (lame, STREAM, ENCODE,
+        ("invalid lame mp3 sync header %08X", header), (NULL));
+    result = GST_FLOW_ERROR;
+    goto exit;
+  }
+}
+
+static GstFlowReturn
+gst_lamemp3enc_flush_full (GstLameMP3Enc * lame, gboolean push)
+{
+  GstBuffer *buf;
+  GstMapInfo map;
+  gint size;
+  GstFlowReturn result = GST_FLOW_OK;
+  gint av;
+
+  if (!lame->lgf)
+    return GST_FLOW_OK;
+
+  buf = gst_buffer_new_and_alloc (7200);
+  gst_buffer_map (buf, &map, GST_MAP_WRITE);
+  size = lame_encode_flush (lame->lgf, map.data, 7200);
+
+  if (size > 0) {
+    gst_buffer_unmap (buf, &map);
+    gst_buffer_resize (buf, 0, size);
+    GST_DEBUG_OBJECT (lame, "collecting final %d bytes", size);
+    gst_adapter_push (lame->adapter, buf);
+  } else {
+    gst_buffer_unmap (buf, &map);
+    GST_DEBUG_OBJECT (lame, "no final packet (size=%d, push=%d)", size, push);
+    gst_buffer_unref (buf);
+    result = GST_FLOW_OK;
+  }
+
+  if (push) {
+    result = gst_lamemp3enc_finish_frames (lame);
+  } else {
+    /* never mind */
+    gst_adapter_clear (lame->adapter);
+  }
+
+  /* either way, we expect nothing left */
+  if ((av = gst_adapter_available (lame->adapter))) {
+    /* should this be more fatal ?? */
+    GST_WARNING_OBJECT (lame, "unparsed %d bytes left after flushing", av);
+    /* clean up anyway */
+    gst_adapter_clear (lame->adapter);
+  }
+
+  return result;
+}
+
+static void
+gst_lamemp3enc_flush (GstAudioEncoder * enc)
+{
+  gst_lamemp3enc_flush_full (GST_LAMEMP3ENC (enc), FALSE);
+}
+
+static GstFlowReturn
+gst_lamemp3enc_handle_frame (GstAudioEncoder * enc, GstBuffer * in_buf)
+{
+  GstLameMP3Enc *lame;
+  gint mp3_buffer_size, mp3_size;
+  GstBuffer *mp3_buf;
+  GstFlowReturn result;
+  gint num_samples;
+  GstMapInfo in_map, mp3_map;
+
+  lame = GST_LAMEMP3ENC (enc);
+
+  /* squeeze remaining and push */
+  if (G_UNLIKELY (in_buf == NULL))
+    return gst_lamemp3enc_flush_full (lame, TRUE);
+
+  gst_buffer_map (in_buf, &in_map, GST_MAP_READ);
+
+  num_samples = in_map.size / 2;
+
+  /* allocate space for output */
+  mp3_buffer_size = 1.25 * num_samples + 7200;
+  mp3_buf = gst_buffer_new_allocate (NULL, mp3_buffer_size, NULL);
+  gst_buffer_map (mp3_buf, &mp3_map, GST_MAP_WRITE);
+
+  /* lame seems to be too stupid to get mono interleaved going */
+  if (lame->num_channels == 1) {
+    mp3_size = lame_encode_buffer (lame->lgf,
+        (short int *) in_map.data,
+        (short int *) in_map.data, num_samples, mp3_map.data, mp3_buffer_size);
+  } else {
+    mp3_size = lame_encode_buffer_interleaved (lame->lgf,
+        (short int *) in_map.data,
+        num_samples / lame->num_channels, mp3_map.data, mp3_buffer_size);
+  }
+  gst_buffer_unmap (in_buf, &in_map);
+
+  GST_LOG_OBJECT (lame, "encoded %" G_GSIZE_FORMAT " bytes of audio "
+      "to %d bytes of mp3", in_map.size, mp3_size);
+
+  if (G_LIKELY (mp3_size > 0)) {
+    /* unfortunately lame does not provide frame delineated output,
+     * so collect output and parse into frames ... */
+    gst_buffer_unmap (mp3_buf, &mp3_map);
+    gst_buffer_resize (mp3_buf, 0, mp3_size);
+    gst_adapter_push (lame->adapter, mp3_buf);
+    result = gst_lamemp3enc_finish_frames (lame);
+  } else {
+    gst_buffer_unmap (mp3_buf, &mp3_map);
+    if (mp3_size < 0) {
+      /* eat error ? */
+      g_warning ("error %d", mp3_size);
+    }
+    gst_buffer_unref (mp3_buf);
+    result = GST_FLOW_OK;
+  }
+
+  return result;
+}
+
+/* set up the encoder state */
+static gboolean
+gst_lamemp3enc_setup (GstLameMP3Enc * lame, GstTagList ** tags)
+{
+  gboolean res;
+
+#define CHECK_ERROR(command) G_STMT_START {\
+  if ((command) < 0) { \
+    GST_ERROR_OBJECT (lame, "setup failed: " G_STRINGIFY (command)); \
+    if (*tags) { \
+      gst_tag_list_free (*tags); \
+      *tags = NULL; \
+    } \
+    return FALSE; \
+  } \
+}G_STMT_END
+
+  int retval;
+  GstCaps *allowed_caps;
+
+  GST_DEBUG_OBJECT (lame, "starting setup");
+
+  lame->lgf = lame_init ();
+
+  if (lame->lgf == NULL)
+    return FALSE;
+
+  *tags = gst_tag_list_new_empty ();
+
+  /* copy the parameters over */
+  lame_set_in_samplerate (lame->lgf, lame->samplerate);
+
+  /* let lame choose default samplerate unless outgoing sample rate is fixed */
+  allowed_caps = gst_pad_get_allowed_caps (GST_AUDIO_ENCODER_SRC_PAD (lame));
+
+  if (allowed_caps != NULL) {
+    GstStructure *structure;
+    gint samplerate;
+
+    structure = gst_caps_get_structure (allowed_caps, 0);
+
+    if (gst_structure_get_int (structure, "rate", &samplerate)) {
+      GST_DEBUG_OBJECT (lame, "Setting sample rate to %d as fixed in src caps",
+          samplerate);
+      lame_set_out_samplerate (lame->lgf, samplerate);
+    } else {
+      GST_DEBUG_OBJECT (lame, "Letting lame choose sample rate");
+      lame_set_out_samplerate (lame->lgf, 0);
+    }
+    gst_caps_unref (allowed_caps);
+    allowed_caps = NULL;
+  } else {
+    GST_DEBUG_OBJECT (lame, "No peer yet, letting lame choose sample rate");
+    lame_set_out_samplerate (lame->lgf, 0);
+  }
+
+  CHECK_ERROR (lame_set_num_channels (lame->lgf, lame->num_channels));
+  CHECK_ERROR (lame_set_bWriteVbrTag (lame->lgf, 0));
+
+  if (lame->target == LAMEMP3ENC_TARGET_QUALITY) {
+    CHECK_ERROR (lame_set_VBR (lame->lgf, vbr_default));
+    CHECK_ERROR (lame_set_VBR_quality (lame->lgf, lame->quality));
+  } else {
+    if (lame->cbr) {
+      CHECK_AND_FIXUP_BITRATE (lame, "bitrate", lame->bitrate);
+      CHECK_ERROR (lame_set_VBR (lame->lgf, vbr_off));
+      CHECK_ERROR (lame_set_brate (lame->lgf, lame->bitrate));
+    } else {
+      CHECK_ERROR (lame_set_VBR (lame->lgf, vbr_abr));
+      CHECK_ERROR (lame_set_VBR_mean_bitrate_kbps (lame->lgf, lame->bitrate));
+    }
+    gst_tag_list_add (*tags, GST_TAG_MERGE_REPLACE, GST_TAG_BITRATE,
+        lame->bitrate * 1000, NULL);
+  }
+
+  if (lame->encoding_engine_quality == LAMEMP3ENC_ENCODING_ENGINE_QUALITY_FAST)
+    CHECK_ERROR (lame_set_quality (lame->lgf, 7));
+  else if (lame->encoding_engine_quality ==
+      LAMEMP3ENC_ENCODING_ENGINE_QUALITY_HIGH)
+    CHECK_ERROR (lame_set_quality (lame->lgf, 2));
+  /* else default */
+
+  if (lame->mono)
+    CHECK_ERROR (lame_set_mode (lame->lgf, MONO));
+
+  /* initialize the lame encoder */
+  if ((retval = lame_init_params (lame->lgf)) >= 0) {
+    /* FIXME: it would be nice to print out the mode here */
+    GST_INFO
+        ("lame encoder setup (target %s, quality %f, bitrate %d, %d Hz, %d channels)",
+        (lame->target == LAMEMP3ENC_TARGET_QUALITY) ? "quality" : "bitrate",
+        lame->quality, lame->bitrate, lame->samplerate, lame->num_channels);
+    res = TRUE;
+  } else {
+    GST_ERROR_OBJECT (lame, "lame_init_params returned %d", retval);
+    res = FALSE;
+  }
+
+  GST_DEBUG_OBJECT (lame, "done with setup");
+  return res;
+#undef CHECK_ERROR
+}
+
+gboolean
+gst_lamemp3enc_register (GstPlugin * plugin)
+{
+  GST_DEBUG_CATEGORY_INIT (debug, "lamemp3enc", 0, "lame mp3 encoder");
+
+  if (!gst_element_register (plugin, "lamemp3enc", GST_RANK_PRIMARY,
+          GST_TYPE_LAMEMP3ENC))
+    return FALSE;
+
+  return TRUE;
+}
diff --git a/ext/lame/gstlamemp3enc.h b/ext/lame/gstlamemp3enc.h
new file mode 100644
index 0000000..d51263e
--- /dev/null
+++ b/ext/lame/gstlamemp3enc.h
@@ -0,0 +1,83 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) <2009> Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#ifndef __GST_LAMEMP3ENC_H__
+#define __GST_LAMEMP3ENC_H__
+
+
+#include <gst/gst.h>
+#include <gst/audio/gstaudioencoder.h>
+#include <gst/base/gstadapter.h>
+
+G_BEGIN_DECLS
+
+#include <lame/lame.h>
+
+#define GST_TYPE_LAMEMP3ENC \
+  (gst_lamemp3enc_get_type())
+#define GST_LAMEMP3ENC(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_LAMEMP3ENC,GstLameMP3Enc))
+#define GST_LAMEMP3ENC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_LAMEMP3ENC,GstLameMP3EncClass))
+#define GST_IS_LAMEMP3ENC(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_LAMEMP3ENC))
+#define GST_IS_LAMEMP3ENC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_LAMEMP3ENC))
+
+typedef struct _GstLameMP3Enc GstLameMP3Enc;
+typedef struct _GstLameMP3EncClass GstLameMP3EncClass;
+
+/**
+ * GstLameMP3Enc:
+ *
+ * Opaque data structure.
+ */
+struct _GstLameMP3Enc {
+  GstAudioEncoder element;
+
+  /*< private >*/
+  gint samplerate;
+  gint out_samplerate;
+  gint num_channels;
+
+  /* properties */
+  gint target;
+  gint bitrate;
+  gboolean cbr;
+  gfloat quality;
+  gint encoding_engine_quality;
+  gboolean mono;
+
+  lame_global_flags *lgf;
+
+  GstAdapter *adapter;
+};
+
+struct _GstLameMP3EncClass {
+  GstAudioEncoderClass parent_class;
+};
+
+GType gst_lamemp3enc_get_type(void);
+gboolean gst_lamemp3enc_register (GstPlugin * plugin);
+
+G_END_DECLS
+
+#endif /* __GST_LAMEMP3ENC_H__ */
diff --git a/ext/lame/plugin.c b/ext/lame/plugin.c
new file mode 100644
index 0000000..5aab8e8
--- /dev/null
+++ b/ext/lame/plugin.c
@@ -0,0 +1,44 @@
+/* GStreamer
+ * Copyright (C) <2009> Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+#include <gst/gst-i18n-plugin.h>
+
+#include "gstlamemp3enc.h"
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+#ifdef ENABLE_NLS
+  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif /* ENABLE_NLS */
+
+  return gst_lamemp3enc_register (plugin);
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    lame,
+    "Encode MP3s with LAME",
+    plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
diff --git a/ext/mad/Makefile.am b/ext/mad/Makefile.am
new file mode 100644
index 0000000..097b864
--- /dev/null
+++ b/ext/mad/Makefile.am
@@ -0,0 +1,29 @@
+plugin_LTLIBRARIES = libgstmad.la 
+
+libgstmad_la_SOURCES = gstmad.c
+
+libgstmad_la_CFLAGS = \
+        $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) \
+	$(MAD_CFLAGS)
+libgstmad_la_LIBADD = \
+        $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) -lgstaudio-$(GST_API_VERSION) \
+	$(GST_BASE_LIBS) $(GST_LIBS) $(MAD_LIBS)
+libgstmad_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstmad_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS = gstmad.h
+
+Android.mk: Makefile.am $(BUILT_SOURCES)
+	androgenizer \
+	-:PROJECT libgstmad -:SHARED libgstmad \
+	 -:TAGS eng debug \
+         -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
+	 -:SOURCES $(libgstmad_la_SOURCES) \
+	 -:CPPFLAGS $(CPPFLAGS) \
+	 -:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(libgstmad_la_CFLAGS) \
+	 -:LDFLAGS $(libgstmad_la_LDFLAGS) \
+	           $(libgstmad_la_LIBADD) \
+	           -ldl \
+	 -:PASSTHROUGH LOCAL_ARM_MODE:=arm \
+		       LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-0.10' \
+	> $@
diff --git a/ext/mad/Makefile.in b/ext/mad/Makefile.in
new file mode 100644
index 0000000..56cf53b
--- /dev/null
+++ b/ext/mad/Makefile.in
@@ -0,0 +1,768 @@
+# Makefile.in generated by automake 1.11.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = ext/mad
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \
+	$(top_srcdir)/common/m4/as-auto-alt.m4 \
+	$(top_srcdir)/common/m4/as-compiler-flag.m4 \
+	$(top_srcdir)/common/m4/as-python.m4 \
+	$(top_srcdir)/common/m4/as-scrub-include.m4 \
+	$(top_srcdir)/common/m4/as-version.m4 \
+	$(top_srcdir)/common/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/common/m4/gst-arch.m4 \
+	$(top_srcdir)/common/m4/gst-args.m4 \
+	$(top_srcdir)/common/m4/gst-check.m4 \
+	$(top_srcdir)/common/m4/gst-default.m4 \
+	$(top_srcdir)/common/m4/gst-dowhile.m4 \
+	$(top_srcdir)/common/m4/gst-error.m4 \
+	$(top_srcdir)/common/m4/gst-feature.m4 \
+	$(top_srcdir)/common/m4/gst-function.m4 \
+	$(top_srcdir)/common/m4/gst-gettext.m4 \
+	$(top_srcdir)/common/m4/gst-glib2.m4 \
+	$(top_srcdir)/common/m4/gst-package-release-datetime.m4 \
+	$(top_srcdir)/common/m4/gst-plugin-docs.m4 \
+	$(top_srcdir)/common/m4/gst-plugindir.m4 \
+	$(top_srcdir)/common/m4/gst.m4 \
+	$(top_srcdir)/common/m4/gtk-doc.m4 \
+	$(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \
+	$(top_srcdir)/m4/a52.m4 $(top_srcdir)/m4/gettext.m4 \
+	$(top_srcdir)/m4/gst-sid.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+	$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(plugindir)"
+LTLIBRARIES = $(plugin_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libgstmad_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am_libgstmad_la_OBJECTS = libgstmad_la-gstmad.lo
+libgstmad_la_OBJECTS = $(am_libgstmad_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+libgstmad_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+	$(libgstmad_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+	$(CCLD) $(libgstmad_la_CFLAGS) $(CFLAGS) \
+	$(libgstmad_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libgstmad_la_SOURCES)
+DIST_SOURCES = $(libgstmad_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+A52DEC_CFLAGS = @A52DEC_CFLAGS@
+A52DEC_LIBS = @A52DEC_LIBS@
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMRNB_CFLAGS = @AMRNB_CFLAGS@
+AMRNB_LIBS = @AMRNB_LIBS@
+AMRWB_CFLAGS = @AMRWB_CFLAGS@
+AMRWB_LIBS = @AMRWB_LIBS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CDIO_CFLAGS = @CDIO_CFLAGS@
+CDIO_LIBS = @CDIO_LIBS@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@
+DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@
+DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@
+DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@
+DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DVDREAD_LIBS = @DVDREAD_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+ERROR_CXXFLAGS = @ERROR_CXXFLAGS@
+EXEEXT = @EXEEXT@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+GCOV = @GCOV@
+GCOV_CFLAGS = @GCOV_CFLAGS@
+GCOV_LIBS = @GCOV_LIBS@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LDFLAGS = @GIO_LDFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_PREFIX = @GLIB_PREFIX@
+GLIB_REQ = @GLIB_REQ@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@
+GSTPB_PREFIX = @GSTPB_PREFIX@
+GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@
+GST_API_VERSION = @GST_API_VERSION@
+GST_BASE_CFLAGS = @GST_BASE_CFLAGS@
+GST_BASE_LIBS = @GST_BASE_LIBS@
+GST_CFLAGS = @GST_CFLAGS@
+GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@
+GST_CHECK_LIBS = @GST_CHECK_LIBS@
+GST_CXXFLAGS = @GST_CXXFLAGS@
+GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@
+GST_LIBS = @GST_LIBS@
+GST_LICENSE = @GST_LICENSE@
+GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@
+GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@
+GST_PACKAGE_NAME = @GST_PACKAGE_NAME@
+GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@
+GST_PLUGINS_ALL = @GST_PLUGINS_ALL@
+GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@
+GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@
+GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@
+GST_PLUGINS_DIR = @GST_PLUGINS_DIR@
+GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@
+GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GST_PREFIX = @GST_PREFIX@
+GST_TOOLS_DIR = @GST_TOOLS_DIR@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DVDREAD = @HAVE_DVDREAD@
+HAVE_LAME = @HAVE_LAME@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LAME_CFLAGS = @LAME_CFLAGS@
+LAME_LIBS = @LAME_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAD_CFLAGS = @MAD_CFLAGS@
+MAD_LIBS = @MAD_LIBS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MPEG2DEC_CFLAGS = @MPEG2DEC_CFLAGS@
+MPEG2DEC_LIBS = @MPEG2DEC_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ORCC = @ORCC@
+ORCC_FLAGS = @ORCC_FLAGS@
+ORC_CFLAGS = @ORC_CFLAGS@
+ORC_LIBS = @ORC_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@
+PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGINDIR = @PLUGINDIR@
+POSUB = @POSUB@
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIDPLAY_CFLAGS = @SIDPLAY_CFLAGS@
+SIDPLAY_LIBS = @SIDPLAY_LIBS@
+STRIP = @STRIP@
+TWOLAME_CFLAGS = @TWOLAME_CFLAGS@
+TWOLAME_LIBS = @TWOLAME_LIBS@
+USE_NLS = @USE_NLS@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VALGRIND_PATH = @VALGRIND_PATH@
+VERSION = @VERSION@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WIN32_LIBS = @WIN32_LIBS@
+X264_CFLAGS = @X264_CFLAGS@
+X264_LIBS = @X264_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+plugindir = @plugindir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+plugin_LTLIBRARIES = libgstmad.la 
+libgstmad_la_SOURCES = gstmad.c
+libgstmad_la_CFLAGS = \
+        $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) \
+	$(MAD_CFLAGS)
+
+libgstmad_la_LIBADD = \
+        $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) -lgstaudio-$(GST_API_VERSION) \
+	$(GST_BASE_LIBS) $(GST_LIBS) $(MAD_LIBS)
+
+libgstmad_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstmad_la_LIBTOOLFLAGS = --tag=disable-static
+noinst_HEADERS = gstmad.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/mad/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu ext/mad/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \
+	  $(MKDIR_P) '$(DESTDIR)$(plugindir)' || exit 1; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+	}
+
+uninstall-pluginLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+	done
+
+clean-pluginLTLIBRARIES:
+	-test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+	@list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libgstmad.la: $(libgstmad_la_OBJECTS) $(libgstmad_la_DEPENDENCIES) $(EXTRA_libgstmad_la_DEPENDENCIES) 
+	$(AM_V_CCLD)$(libgstmad_la_LINK) -rpath $(plugindir) $(libgstmad_la_OBJECTS) $(libgstmad_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstmad_la-gstmad.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+libgstmad_la-gstmad.lo: gstmad.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstmad_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstmad_la_CFLAGS) $(CFLAGS) -MT libgstmad_la-gstmad.lo -MD -MP -MF $(DEPDIR)/libgstmad_la-gstmad.Tpo -c -o libgstmad_la-gstmad.lo `test -f 'gstmad.c' || echo '$(srcdir)/'`gstmad.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgstmad_la-gstmad.Tpo $(DEPDIR)/libgstmad_la-gstmad.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gstmad.c' object='libgstmad_la-gstmad.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstmad_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstmad_la_CFLAGS) $(CFLAGS) -c -o libgstmad_la-gstmad.lo `test -f 'gstmad.c' || echo '$(srcdir)/'`gstmad.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(plugindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pluginLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pluginLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pluginLTLIBRARIES
+
+
+Android.mk: Makefile.am $(BUILT_SOURCES)
+	androgenizer \
+	-:PROJECT libgstmad -:SHARED libgstmad \
+	 -:TAGS eng debug \
+         -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
+	 -:SOURCES $(libgstmad_la_SOURCES) \
+	 -:CPPFLAGS $(CPPFLAGS) \
+	 -:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(libgstmad_la_CFLAGS) \
+	 -:LDFLAGS $(libgstmad_la_LDFLAGS) \
+	           $(libgstmad_la_LIBADD) \
+	           -ldl \
+	 -:PASSTHROUGH LOCAL_ARM_MODE:=arm \
+		       LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-0.10' \
+	> $@
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/ext/mad/gstmad.c b/ext/mad/gstmad.c
new file mode 100644
index 0000000..2326e85
--- /dev/null
+++ b/ext/mad/gstmad.c
@@ -0,0 +1,559 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * SECTION:element-mad
+ * @see_also: lame
+ *
+ * MP3 audio decoder.
+ *
+ * <refsect2>
+ * <title>Example pipelines</title>
+ * |[
+ * gst-launch filesrc location=music.mp3 ! mpegaudioparse ! mad ! audioconvert ! audioresample ! autoaudiosink
+ * ]| Decode and play the mp3 file
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include "gstmad.h"
+#include <gst/audio/audio.h>
+
+enum
+{
+  ARG_0,
+  ARG_HALF,
+  ARG_IGNORE_CRC
+};
+
+GST_DEBUG_CATEGORY_STATIC (mad_debug);
+#define GST_CAT_DEFAULT mad_debug
+
+static GstStaticPadTemplate mad_src_template_factory =
+GST_STATIC_PAD_TEMPLATE ("src",
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " GST_AUDIO_NE (S32) ", "
+        "layout = (string) interleaved, "
+        "rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
+        "channels = (int) [ 1, 2 ]")
+    );
+
+/* FIXME: make three caps, for mpegversion 1, 2 and 2.5 */
+static GstStaticPadTemplate mad_sink_template_factory =
+GST_STATIC_PAD_TEMPLATE ("sink",
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/mpeg, "
+        "mpegversion = (int) 1, "
+        "layer = (int) [ 1, 3 ], "
+        "rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
+        "channels = (int) [ 1, 2 ]")
+    );
+
+
+static gboolean gst_mad_start (GstAudioDecoder * dec);
+static gboolean gst_mad_stop (GstAudioDecoder * dec);
+static gboolean gst_mad_parse (GstAudioDecoder * dec, GstAdapter * adapter,
+    gint * offset, gint * length);
+static GstFlowReturn gst_mad_handle_frame (GstAudioDecoder * dec,
+    GstBuffer * buffer);
+static void gst_mad_flush (GstAudioDecoder * dec, gboolean hard);
+
+static void gst_mad_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec);
+static void gst_mad_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec);
+
+#define parent_class gst_mad_parent_class
+G_DEFINE_TYPE (GstMad, gst_mad, GST_TYPE_AUDIO_DECODER);
+
+static void
+gst_mad_class_init (GstMadClass * klass)
+{
+  GObjectClass *gobject_class = (GObjectClass *) klass;
+  GstElementClass *element_class = (GstElementClass *) klass;
+  GstAudioDecoderClass *base_class = (GstAudioDecoderClass *) klass;
+
+  base_class->start = GST_DEBUG_FUNCPTR (gst_mad_start);
+  base_class->stop = GST_DEBUG_FUNCPTR (gst_mad_stop);
+  base_class->parse = GST_DEBUG_FUNCPTR (gst_mad_parse);
+  base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_mad_handle_frame);
+  base_class->flush = GST_DEBUG_FUNCPTR (gst_mad_flush);
+
+  base_class->start = GST_DEBUG_FUNCPTR (gst_mad_start);
+  base_class->stop = GST_DEBUG_FUNCPTR (gst_mad_stop);
+  base_class->parse = GST_DEBUG_FUNCPTR (gst_mad_parse);
+  base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_mad_handle_frame);
+  base_class->flush = GST_DEBUG_FUNCPTR (gst_mad_flush);
+
+  gobject_class->set_property = gst_mad_set_property;
+  gobject_class->get_property = gst_mad_get_property;
+
+  /* init properties */
+  /* currently, string representations are used, we might want to change that */
+  /* FIXME: descriptions need to be more technical,
+   * default values and ranges need to be selected right */
+  g_object_class_install_property (gobject_class, ARG_HALF,
+      g_param_spec_boolean ("half", "Half", "Generate PCM at 1/2 sample rate",
+          FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (gobject_class, ARG_IGNORE_CRC,
+      g_param_spec_boolean ("ignore-crc", "Ignore CRC", "Ignore CRC errors",
+          TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&mad_sink_template_factory));
+  gst_element_class_add_pad_template (element_class,
+      gst_static_pad_template_get (&mad_src_template_factory));
+
+  gst_element_class_set_static_metadata (element_class, "mad mp3 decoder",
+      "Codec/Decoder/Audio",
+      "Uses mad code to decode mp3 streams", "Wim Taymans <wim@fluendo.com>");
+}
+
+static void
+gst_mad_init (GstMad * mad)
+{
+  GstAudioDecoder *dec;
+
+  dec = GST_AUDIO_DECODER (mad);
+  gst_audio_decoder_set_tolerance (dec, 20 * GST_MSECOND);
+
+  mad->half = FALSE;
+  mad->ignore_crc = TRUE;
+}
+
+static gboolean
+gst_mad_start (GstAudioDecoder * dec)
+{
+  GstMad *mad = GST_MAD (dec);
+  guint options = 0;
+
+  GST_DEBUG_OBJECT (dec, "start");
+  mad_stream_init (&mad->stream);
+  mad_frame_init (&mad->frame);
+  mad_synth_init (&mad->synth);
+  mad->rate = 0;
+  mad->channels = 0;
+  mad->caps_set = FALSE;
+  mad->frame.header.samplerate = 0;
+  if (mad->ignore_crc)
+    options |= MAD_OPTION_IGNORECRC;
+  if (mad->half)
+    options |= MAD_OPTION_HALFSAMPLERATE;
+  mad_stream_options (&mad->stream, options);
+  mad->header.mode = -1;
+  mad->header.emphasis = -1;
+  mad->eos = FALSE;
+
+  /* call upon legacy upstream byte support (e.g. seeking) */
+  gst_audio_decoder_set_estimate_rate (dec, TRUE);
+
+  return TRUE;
+}
+
+static gboolean
+gst_mad_stop (GstAudioDecoder * dec)
+{
+  GstMad *mad = GST_MAD (dec);
+
+  GST_DEBUG_OBJECT (dec, "stop");
+  mad_synth_finish (&mad->synth);
+  mad_frame_finish (&mad->frame);
+  mad_stream_finish (&mad->stream);
+
+  return TRUE;
+}
+
+static inline gint32
+scale (mad_fixed_t sample)
+{
+#if MAD_F_FRACBITS < 28
+  /* round */
+  sample += (1L << (28 - MAD_F_FRACBITS - 1));
+#endif
+
+  /* clip */
+  if (sample >= MAD_F_ONE)
+    sample = MAD_F_ONE - 1;
+  else if (sample < -MAD_F_ONE)
+    sample = -MAD_F_ONE;
+
+#if MAD_F_FRACBITS < 28
+  /* quantize */
+  sample >>= (28 - MAD_F_FRACBITS);
+#endif
+
+  /* convert from 29 bits to 32 bits */
+  return (gint32) (sample << 3);
+}
+
+/* internal function to check if the header has changed and thus the
+ * caps need to be reset.  Only call during normal mode, not resyncing */
+static void
+gst_mad_check_caps_reset (GstMad * mad)
+{
+  guint nchannels;
+  guint rate;
+
+  nchannels = MAD_NCHANNELS (&mad->frame.header);
+
+#if MAD_VERSION_MINOR <= 12
+  rate = mad->header.sfreq;
+#else
+  rate = mad->frame.header.samplerate;
+#endif
+
+  /* rate and channels are not supposed to change in a continuous stream,
+   * so check this first before doing anything */
+
+  /* only set caps if they weren't already set for this continuous stream */
+  if (!gst_pad_has_current_caps (GST_AUDIO_DECODER_SRC_PAD (mad))
+      || mad->channels != nchannels || mad->rate != rate) {
+    GstAudioInfo info;
+    static const GstAudioChannelPosition chan_pos[2][2] = {
+      {GST_AUDIO_CHANNEL_POSITION_MONO},
+      {GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
+          GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
+    };
+
+    if (mad->caps_set) {
+      GST_DEBUG_OBJECT (mad, "Header changed from %d Hz/%d ch to %d Hz/%d ch, "
+          "failed sync after seek ?", mad->rate, mad->channels, rate,
+          nchannels);
+      /* we're conservative on stream changes. However, our *initial* caps
+       * might have been wrong as well - mad ain't perfect in syncing. So,
+       * we count caps changes and change if we pass a limit treshold (3). */
+      if (nchannels != mad->pending_channels || rate != mad->pending_rate) {
+        mad->times_pending = 0;
+        mad->pending_channels = nchannels;
+        mad->pending_rate = rate;
+      }
+      if (++mad->times_pending < 3)
+        return;
+    }
+
+    if (mad->stream.options & MAD_OPTION_HALFSAMPLERATE)
+      rate >>= 1;
+
+    /* we set the caps even when the pad is not connected so they
+     * can be gotten for streaminfo */
+    gst_audio_info_init (&info);
+    gst_audio_info_set_format (&info,
+        GST_AUDIO_FORMAT_S32, rate, nchannels, chan_pos[nchannels - 1]);
+
+    gst_audio_decoder_set_output_format (GST_AUDIO_DECODER (mad), &info);
+
+    mad->caps_set = TRUE;
+    mad->channels = nchannels;
+    mad->rate = rate;
+  }
+}
+
+static GstFlowReturn
+gst_mad_parse (GstAudioDecoder * dec, GstAdapter * adapter,
+    gint * _offset, gint * len)
+{
+  GstMad *mad;
+  GstFlowReturn ret = GST_FLOW_EOS;
+  gint av, size, offset;
+  const guint8 *data;
+  gboolean eos, sync;
+  guint8 *guard = NULL;
+
+  mad = GST_MAD (dec);
+
+  av = gst_adapter_available (adapter);
+  data = gst_adapter_map (adapter, av);
+
+  gst_audio_decoder_get_parse_state (dec, &sync, &eos);
+  GST_LOG_OBJECT (mad, "parse state sync %d, eos %d", sync, eos);
+
+  if (eos) {
+    /* This is one streaming hack right there.
+     * mad will not decode the last frame if it is not followed by
+     * a number of 0 bytes, due to some buffer overflow, which can
+     * not be fixed for reasons I did not inquire into, see
+     * http://www.mars.org/mailman/public/mad-dev/2001-May/000262.html
+     */
+    guard = g_malloc (av + MAD_BUFFER_GUARD);
+    /* let's be nice and not mess with baseclass state and keep hacks local */
+    memcpy (guard, data, av);
+    memset (guard + av, 0, MAD_BUFFER_GUARD);
+    GST_DEBUG_OBJECT (mad, "Added %u zero guard bytes in the adapter; "
+        "using fallback buffer of size %u",
+        MAD_BUFFER_GUARD, av + MAD_BUFFER_GUARD);
+    data = guard;
+    av = av + MAD_BUFFER_GUARD;
+  }
+
+  /* we basically let mad library do parsing,
+   * and translate that back to baseclass.
+   * if a frame is found (and also decoded), subsequent handle_frame
+   * only needs to synthesize it */
+
+  offset = 0;
+  size = 0;
+
+resume:
+  if (G_UNLIKELY (offset + MAD_BUFFER_GUARD > av))
+    goto exit;
+
+  GST_LOG_OBJECT (mad, "setup mad stream at offset %d (of av %d)", offset, av);
+  mad_stream_buffer (&mad->stream, data + offset, av - offset);
+  /* convey sync idea to mad */
+  mad->stream.sync = sync;
+  /* if we get back here, lost sync anyway */
+  sync = FALSE;
+
+  while (TRUE) {
+    GST_LOG_OBJECT (mad, "decoding the header now");
+    if (mad_header_decode (&mad->frame.header, &mad->stream) == -1) {
+      /* HACK it seems mad reports wrong error when it is trying to determine
+       * free bitrate and scanning for next header */
+      if (mad->stream.error == MAD_ERROR_LOSTSYNC) {
+        const guint8 *ptr = mad->stream.this_frame;
+        guint32 header;
+
+        if (ptr >= data && ptr < data + av) {
+          header = GST_READ_UINT32_BE (ptr);
+          /* looks like possible freeform header with not much data */
+          if (((header & 0xFFE00000) == 0xFFE00000) &&
+              (((header >> 12) & 0xF) == 0x0) && (av < 4096)) {
+            GST_DEBUG_OBJECT (mad, "overriding freeform LOST_SYNC to BUFLEN");
+            mad->stream.error = MAD_ERROR_BUFLEN;
+          }
+        }
+      }
+      if (mad->stream.error == MAD_ERROR_BUFLEN) {
+        GST_LOG_OBJECT (mad, "not enough data, getting more");
+        offset = mad->stream.next_frame - data;
+        break;
+      } else if (mad->stream.error == MAD_ERROR_LOSTSYNC) {
+        GST_LOG_OBJECT (mad, "lost sync");
+        continue;
+      } else {
+        /* probably some bogus header, basically also lost sync */
+        GST_DEBUG_OBJECT (mad, "mad_header_decode had an error: %s",
+            mad_stream_errorstr (&mad->stream));
+        continue;
+      }
+    }
+
+    /* could have a frame now, subsequent will confirm */
+    offset = mad->stream.this_frame - data;
+    size = mad->stream.next_frame - mad->stream.this_frame;
+    g_assert (size);
+
+    GST_LOG_OBJECT (mad, "parsing and decoding one frame now "
+        "(offset %d, size %d)", offset, size);
+    if (mad_frame_decode (&mad->frame, &mad->stream) == -1) {
+      GST_LOG_OBJECT (mad, "got error %d", mad->stream.error);
+
+      /* not enough data, need to wait for next buffer? */
+      if (mad->stream.error == MAD_ERROR_BUFLEN) {
+        /* not really expect this error at this stage anymore
+         * assume bogus frame and bad sync and move along a bit */
+        GST_WARNING_OBJECT (mad, "not enough data (unexpected), moving along");
+        offset++;
+        goto resume;
+      } else if (mad->stream.error == MAD_ERROR_BADDATAPTR) {
+        GST_DEBUG_OBJECT (mad, "bad data ptr, skipping presumed frame");
+        /* flush past presumed frame */
+        offset += size;
+        goto resume;
+      } else {
+        GST_WARNING_OBJECT (mad, "mad_frame_decode had an error: %s",
+            mad_stream_errorstr (&mad->stream));
+        if (!MAD_RECOVERABLE (mad->stream.error)) {
+          /* well, all may be well enough bytes later on ... */
+          GST_AUDIO_DECODER_ERROR (mad, 1, STREAM, DECODE, (NULL),
+              ("mad error: %s", mad_stream_errorstr (&mad->stream)), ret);
+        }
+        /* move along and try again */
+        offset++;
+        goto resume;
+      }
+      g_assert_not_reached ();
+    }
+
+    /* so decoded ok, got a frame now */
+    ret = GST_FLOW_OK;
+    break;
+  }
+
+exit:
+
+  gst_adapter_unmap (adapter);
+
+  *_offset = offset;
+  *len = size;
+
+  /* ensure that if we added some dummy guard bytes above, we don't claim
+     to have used them as they're unknown to the caller. */
+  if (eos) {
+    g_assert (av >= MAD_BUFFER_GUARD);
+    av -= MAD_BUFFER_GUARD;
+    if (*_offset > av)
+      *_offset = av;
+    if (*len > av)
+      *len = av;
+    g_assert (guard);
+    g_free (guard);
+  }
+
+  return ret;
+}
+
+static GstFlowReturn
+gst_mad_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
+{
+  GstMad *mad;
+  GstFlowReturn ret = GST_FLOW_EOS;
+  GstBuffer *outbuffer;
+  guint nsamples;
+  GstMapInfo outmap;
+  gint32 *outdata;
+  mad_fixed_t const *left_ch, *right_ch;
+
+  mad = GST_MAD (dec);
+
+  /* no fancy draining */
+  if (G_UNLIKELY (!buffer))
+    return GST_FLOW_OK;
+
+  /* _parse prepared a frame */
+  nsamples = MAD_NSBSAMPLES (&mad->frame.header) *
+      (mad->stream.options & MAD_OPTION_HALFSAMPLERATE ? 16 : 32);
+  GST_LOG_OBJECT (mad, "mad frame with %d samples", nsamples);
+
+  /* arrange for initial caps before pushing data,
+   * and update later on if needed */
+  gst_mad_check_caps_reset (mad);
+
+  mad_synth_frame (&mad->synth, &mad->frame);
+  left_ch = mad->synth.pcm.samples[0];
+  right_ch = mad->synth.pcm.samples[1];
+
+  outbuffer = gst_buffer_new_and_alloc (nsamples * mad->channels * 4);
+
+  gst_buffer_map (outbuffer, &outmap, GST_MAP_WRITE);
+  outdata = (gint32 *) outmap.data;
+
+  /* output sample(s) in 16-bit signed native-endian PCM */
+  if (mad->channels == 1) {
+    gint count = nsamples;
+
+    while (count--) {
+      *outdata++ = scale (*left_ch++) & 0xffffffff;
+    }
+  } else {
+    gint count = nsamples;
+
+    while (count--) {
+      *outdata++ = scale (*left_ch++) & 0xffffffff;
+      *outdata++ = scale (*right_ch++) & 0xffffffff;
+    }
+  }
+
+  gst_buffer_unmap (outbuffer, &outmap);
+
+  ret = gst_audio_decoder_finish_frame (dec, outbuffer, 1);
+
+  return ret;
+}
+
+static void
+gst_mad_flush (GstAudioDecoder * dec, gboolean hard)
+{
+  GstMad *mad;
+
+  mad = GST_MAD (dec);
+  if (hard) {
+    mad_frame_mute (&mad->frame);
+    mad_synth_mute (&mad->synth);
+  }
+}
+
+static void
+gst_mad_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec)
+{
+  GstMad *mad;
+
+  mad = GST_MAD (object);
+
+  switch (prop_id) {
+    case ARG_HALF:
+      mad->half = g_value_get_boolean (value);
+      break;
+    case ARG_IGNORE_CRC:
+      mad->ignore_crc = g_value_get_boolean (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+gst_mad_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec)
+{
+  GstMad *mad;
+
+  mad = GST_MAD (object);
+
+  switch (prop_id) {
+    case ARG_HALF:
+      g_value_set_boolean (value, mad->half);
+      break;
+    case ARG_IGNORE_CRC:
+      g_value_set_boolean (value, mad->ignore_crc);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+/* plugin initialisation */
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  GST_DEBUG_CATEGORY_INIT (mad_debug, "mad", 0, "mad mp3 decoding");
+
+  /* FIXME 0.11: rename to something better like madmp3dec or madmpegaudiodec
+   * or so? */
+  return gst_element_register (plugin, "mad", GST_RANK_SECONDARY,
+      gst_mad_get_type ());
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    mad,
+    "mp3 decoding based on the mad library",
+    plugin_init, VERSION, "GPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
diff --git a/ext/mad/gstmad.h b/ext/mad/gstmad.h
new file mode 100644
index 0000000..889ea9a
--- /dev/null
+++ b/ext/mad/gstmad.h
@@ -0,0 +1,82 @@
+/* GStreamer
+ * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#ifndef __GST_MAD_H__
+#define __GST_MAD_H__
+
+#include <gst/gst.h>
+#include <gst/tag/tag.h>
+#include <gst/audio/gstaudiodecoder.h>
+
+#include <mad.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_MAD \
+  (gst_mad_get_type())
+#define GST_MAD(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MAD,GstMad))
+#define GST_MAD_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MAD,GstMadClass))
+#define GST_IS_MAD(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MAD))
+#define GST_IS_MAD_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MAD))
+
+
+typedef struct _GstMad GstMad;
+typedef struct _GstMadClass GstMadClass;
+
+struct _GstMad
+{
+  GstAudioDecoder element;
+
+  /* state */
+  struct mad_stream stream;
+  struct mad_frame frame;
+  struct mad_synth synth;
+
+  /* info */
+  struct mad_header header;
+
+  /* negotiated format */
+  gint rate, pending_rate;
+  gint channels, pending_channels;
+  gint times_pending;
+  gboolean caps_set;            /* used to keep track of whether to change/update caps */
+
+  gboolean eos;
+
+  /* properties */
+  gboolean half;
+  gboolean ignore_crc;
+};
+
+struct _GstMadClass
+{
+  GstAudioDecoderClass parent_class;
+};
+
+GType                   gst_mad_get_type (void);
+gboolean                gst_mad_register (GstPlugin * plugin);
+
+G_END_DECLS
+
+#endif /* __GST_MAD_H__ */
diff --git a/ext/mpeg2dec/Makefile.am b/ext/mpeg2dec/Makefile.am
new file mode 100644
index 0000000..bf0a4ea
--- /dev/null
+++ b/ext/mpeg2dec/Makefile.am
@@ -0,0 +1,11 @@
+plugin_LTLIBRARIES = libgstmpeg2dec.la
+
+libgstmpeg2dec_la_SOURCES = gstmpeg2dec.c
+libgstmpeg2dec_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \
+	$(GST_CFLAGS) $(MPEG2DEC_CFLAGS)
+libgstmpeg2dec_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_API_VERSION) \
+	$(GST_LIBS) $(MPEG2DEC_LIBS)
+libgstmpeg2dec_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstmpeg2dec_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS = gstmpeg2dec.h
diff --git a/ext/mpeg2dec/Makefile.in b/ext/mpeg2dec/Makefile.in
new file mode 100644
index 0000000..4bc37fd
--- /dev/null
+++ b/ext/mpeg2dec/Makefile.in
@@ -0,0 +1,750 @@
+# Makefile.in generated by automake 1.11.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = ext/mpeg2dec
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \
+	$(top_srcdir)/common/m4/as-auto-alt.m4 \
+	$(top_srcdir)/common/m4/as-compiler-flag.m4 \
+	$(top_srcdir)/common/m4/as-python.m4 \
+	$(top_srcdir)/common/m4/as-scrub-include.m4 \
+	$(top_srcdir)/common/m4/as-version.m4 \
+	$(top_srcdir)/common/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/common/m4/gst-arch.m4 \
+	$(top_srcdir)/common/m4/gst-args.m4 \
+	$(top_srcdir)/common/m4/gst-check.m4 \
+	$(top_srcdir)/common/m4/gst-default.m4 \
+	$(top_srcdir)/common/m4/gst-dowhile.m4 \
+	$(top_srcdir)/common/m4/gst-error.m4 \
+	$(top_srcdir)/common/m4/gst-feature.m4 \
+	$(top_srcdir)/common/m4/gst-function.m4 \
+	$(top_srcdir)/common/m4/gst-gettext.m4 \
+	$(top_srcdir)/common/m4/gst-glib2.m4 \
+	$(top_srcdir)/common/m4/gst-package-release-datetime.m4 \
+	$(top_srcdir)/common/m4/gst-plugin-docs.m4 \
+	$(top_srcdir)/common/m4/gst-plugindir.m4 \
+	$(top_srcdir)/common/m4/gst.m4 \
+	$(top_srcdir)/common/m4/gtk-doc.m4 \
+	$(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \
+	$(top_srcdir)/m4/a52.m4 $(top_srcdir)/m4/gettext.m4 \
+	$(top_srcdir)/m4/gst-sid.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+	$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(plugindir)"
+LTLIBRARIES = $(plugin_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libgstmpeg2dec_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am_libgstmpeg2dec_la_OBJECTS = libgstmpeg2dec_la-gstmpeg2dec.lo
+libgstmpeg2dec_la_OBJECTS = $(am_libgstmpeg2dec_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+libgstmpeg2dec_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+	$(libgstmpeg2dec_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+	$(CCLD) $(libgstmpeg2dec_la_CFLAGS) $(CFLAGS) \
+	$(libgstmpeg2dec_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libgstmpeg2dec_la_SOURCES)
+DIST_SOURCES = $(libgstmpeg2dec_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+A52DEC_CFLAGS = @A52DEC_CFLAGS@
+A52DEC_LIBS = @A52DEC_LIBS@
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMRNB_CFLAGS = @AMRNB_CFLAGS@
+AMRNB_LIBS = @AMRNB_LIBS@
+AMRWB_CFLAGS = @AMRWB_CFLAGS@
+AMRWB_LIBS = @AMRWB_LIBS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CDIO_CFLAGS = @CDIO_CFLAGS@
+CDIO_LIBS = @CDIO_LIBS@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@
+DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@
+DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@
+DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@
+DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DVDREAD_LIBS = @DVDREAD_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+ERROR_CXXFLAGS = @ERROR_CXXFLAGS@
+EXEEXT = @EXEEXT@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+GCOV = @GCOV@
+GCOV_CFLAGS = @GCOV_CFLAGS@
+GCOV_LIBS = @GCOV_LIBS@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LDFLAGS = @GIO_LDFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_PREFIX = @GLIB_PREFIX@
+GLIB_REQ = @GLIB_REQ@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@
+GSTPB_PREFIX = @GSTPB_PREFIX@
+GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@
+GST_API_VERSION = @GST_API_VERSION@
+GST_BASE_CFLAGS = @GST_BASE_CFLAGS@
+GST_BASE_LIBS = @GST_BASE_LIBS@
+GST_CFLAGS = @GST_CFLAGS@
+GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@
+GST_CHECK_LIBS = @GST_CHECK_LIBS@
+GST_CXXFLAGS = @GST_CXXFLAGS@
+GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@
+GST_LIBS = @GST_LIBS@
+GST_LICENSE = @GST_LICENSE@
+GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@
+GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@
+GST_PACKAGE_NAME = @GST_PACKAGE_NAME@
+GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@
+GST_PLUGINS_ALL = @GST_PLUGINS_ALL@
+GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@
+GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@
+GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@
+GST_PLUGINS_DIR = @GST_PLUGINS_DIR@
+GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@
+GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GST_PREFIX = @GST_PREFIX@
+GST_TOOLS_DIR = @GST_TOOLS_DIR@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DVDREAD = @HAVE_DVDREAD@
+HAVE_LAME = @HAVE_LAME@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LAME_CFLAGS = @LAME_CFLAGS@
+LAME_LIBS = @LAME_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAD_CFLAGS = @MAD_CFLAGS@
+MAD_LIBS = @MAD_LIBS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MPEG2DEC_CFLAGS = @MPEG2DEC_CFLAGS@
+MPEG2DEC_LIBS = @MPEG2DEC_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ORCC = @ORCC@
+ORCC_FLAGS = @ORCC_FLAGS@
+ORC_CFLAGS = @ORC_CFLAGS@
+ORC_LIBS = @ORC_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@
+PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGINDIR = @PLUGINDIR@
+POSUB = @POSUB@
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIDPLAY_CFLAGS = @SIDPLAY_CFLAGS@
+SIDPLAY_LIBS = @SIDPLAY_LIBS@
+STRIP = @STRIP@
+TWOLAME_CFLAGS = @TWOLAME_CFLAGS@
+TWOLAME_LIBS = @TWOLAME_LIBS@
+USE_NLS = @USE_NLS@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VALGRIND_PATH = @VALGRIND_PATH@
+VERSION = @VERSION@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WIN32_LIBS = @WIN32_LIBS@
+X264_CFLAGS = @X264_CFLAGS@
+X264_LIBS = @X264_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+plugindir = @plugindir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+plugin_LTLIBRARIES = libgstmpeg2dec.la
+libgstmpeg2dec_la_SOURCES = gstmpeg2dec.c
+libgstmpeg2dec_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \
+	$(GST_CFLAGS) $(MPEG2DEC_CFLAGS)
+
+libgstmpeg2dec_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_API_VERSION) \
+	$(GST_LIBS) $(MPEG2DEC_LIBS)
+
+libgstmpeg2dec_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstmpeg2dec_la_LIBTOOLFLAGS = --tag=disable-static
+noinst_HEADERS = gstmpeg2dec.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/mpeg2dec/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu ext/mpeg2dec/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \
+	  $(MKDIR_P) '$(DESTDIR)$(plugindir)' || exit 1; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+	}
+
+uninstall-pluginLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+	done
+
+clean-pluginLTLIBRARIES:
+	-test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+	@list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libgstmpeg2dec.la: $(libgstmpeg2dec_la_OBJECTS) $(libgstmpeg2dec_la_DEPENDENCIES) $(EXTRA_libgstmpeg2dec_la_DEPENDENCIES) 
+	$(AM_V_CCLD)$(libgstmpeg2dec_la_LINK) -rpath $(plugindir) $(libgstmpeg2dec_la_OBJECTS) $(libgstmpeg2dec_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstmpeg2dec_la-gstmpeg2dec.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+libgstmpeg2dec_la-gstmpeg2dec.lo: gstmpeg2dec.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstmpeg2dec_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstmpeg2dec_la_CFLAGS) $(CFLAGS) -MT libgstmpeg2dec_la-gstmpeg2dec.lo -MD -MP -MF $(DEPDIR)/libgstmpeg2dec_la-gstmpeg2dec.Tpo -c -o libgstmpeg2dec_la-gstmpeg2dec.lo `test -f 'gstmpeg2dec.c' || echo '$(srcdir)/'`gstmpeg2dec.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgstmpeg2dec_la-gstmpeg2dec.Tpo $(DEPDIR)/libgstmpeg2dec_la-gstmpeg2dec.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gstmpeg2dec.c' object='libgstmpeg2dec_la-gstmpeg2dec.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstmpeg2dec_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstmpeg2dec_la_CFLAGS) $(CFLAGS) -c -o libgstmpeg2dec_la-gstmpeg2dec.lo `test -f 'gstmpeg2dec.c' || echo '$(srcdir)/'`gstmpeg2dec.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(plugindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pluginLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pluginLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pluginLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/ext/mpeg2dec/gstmpeg2dec.c b/ext/mpeg2dec/gstmpeg2dec.c
new file mode 100644
index 0000000..90eea28
--- /dev/null
+++ b/ext/mpeg2dec/gstmpeg2dec.c
@@ -0,0 +1,1418 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <string.h>
+
+#include <inttypes.h>
+
+#include "gstmpeg2dec.h"
+
+/* 16byte-aligns a buffer for libmpeg2 */
+#define ALIGN_16(p) ((void *)(((uintptr_t)(p) + 15) & ~((uintptr_t)15)))
+
+/* mpeg2dec changed a struct name after 0.3.1, here's a workaround */
+/* mpeg2dec also only defined MPEG2_RELEASE after 0.3.1
+   #if MPEG2_RELEASE < MPEG2_VERSION(0,3,2)
+*/
+#ifndef MPEG2_RELEASE
+#define MPEG2_VERSION(a,b,c) ((((a)&0xff)<<16)|(((b)&0xff)<<8)|((c)&0xff))
+#define MPEG2_RELEASE MPEG2_VERSION(0,3,1)
+typedef picture_t mpeg2_picture_t;
+typedef gint mpeg2_state_t;
+
+#define STATE_BUFFER 0
+#endif
+
+GST_DEBUG_CATEGORY_EXTERN (GST_CAT_PERFORMANCE);
+GST_DEBUG_CATEGORY_STATIC (mpeg2dec_debug);
+#define GST_CAT_DEFAULT (mpeg2dec_debug)
+
+/* Send a warning message about decoding errors after receiving this many
+ * STATE_INVALID return values from mpeg2_parse. -1 means never.
+ */
+#define WARN_THRESHOLD (5)
+
+//#define enable_user_data
+#ifdef enable_user_data
+static GstStaticPadTemplate user_data_template_factory =
+GST_STATIC_PAD_TEMPLATE ("user_data",
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS_ANY);
+#endif
+
+static GstStaticPadTemplate sink_template_factory =
+GST_STATIC_PAD_TEMPLATE ("sink",
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("video/mpeg, "
+        "mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) false")
+    );
+
+static GstStaticPadTemplate src_template_factory =
+GST_STATIC_PAD_TEMPLATE ("src",
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("video/x-raw, "
+        "format = (string) { I420, Y42B, Y444 }, "
+        "width = (int) [ 16, 4096 ], "
+        "height = (int) [ 16, 4096 ], "
+        "framerate = (fraction) [ 0/1, 2147483647/1 ]")
+    );
+
+static void gst_mpeg2dec_finalize (GObject * object);
+static void gst_mpeg2dec_reset (GstMpeg2dec * mpeg2dec);
+
+static gboolean gst_mpeg2dec_src_event (GstPad * pad, GstObject * parent,
+    GstEvent * event);
+static GstStateChangeReturn gst_mpeg2dec_change_state (GstElement * element,
+    GstStateChange transition);
+
+static gboolean gst_mpeg2dec_sink_event (GstPad * pad, GstObject * parent,
+    GstEvent * event);
+static gboolean gst_mpeg2dec_setcaps (GstPad * pad, GstCaps * caps);
+static GstFlowReturn gst_mpeg2dec_chain (GstPad * pad, GstObject * parent,
+    GstBuffer * buf);
+
+static void clear_buffers (GstMpeg2dec * mpeg2dec);
+
+//static gboolean gst_mpeg2dec_sink_query (GstPad * pad, GstObject * parent, GstQuery * query);
+
+#if 0
+static const GstFormat *gst_mpeg2dec_get_formats (GstPad * pad);
+#endif
+
+#if 0
+static const GstEventMask *gst_mpeg2dec_get_event_masks (GstPad * pad);
+#endif
+
+static gboolean gst_mpeg2dec_crop_buffer (GstMpeg2dec * dec, GstBuffer ** buf,
+    GstVideoFrame * frame);
+
+/*static guint gst_mpeg2dec_signals[LAST_SIGNAL] = { 0 };*/
+
+#define gst_mpeg2dec_parent_class parent_class
+G_DEFINE_TYPE (GstMpeg2dec, gst_mpeg2dec, GST_TYPE_ELEMENT);
+
+static void
+gst_mpeg2dec_class_init (GstMpeg2decClass * klass)
+{
+  GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
+
+  gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
+
+  gobject_class->finalize = gst_mpeg2dec_finalize;
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_template_factory));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_template_factory));
+#ifdef enable_user_data
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&user_data_template_factory));
+#endif
+  gst_element_class_set_static_metadata (gstelement_class,
+      "mpeg1 and mpeg2 video decoder", "Codec/Decoder/Video",
+      "Uses libmpeg2 to decode MPEG video streams",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
+  gstelement_class->change_state = gst_mpeg2dec_change_state;
+
+  GST_DEBUG_CATEGORY_INIT (mpeg2dec_debug, "mpeg2dec", 0,
+      "MPEG2 decoder element");
+}
+
+static void
+gst_mpeg2dec_init (GstMpeg2dec * mpeg2dec)
+{
+  /* create the sink and src pads */
+  mpeg2dec->sinkpad =
+      gst_pad_new_from_static_template (&sink_template_factory, "sink");
+  gst_pad_set_chain_function (mpeg2dec->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_mpeg2dec_chain));
+#if 0
+  gst_pad_set_query_function (mpeg2dec->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_mpeg2dec_get_sink_query));
+#endif
+  gst_pad_set_event_function (mpeg2dec->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_mpeg2dec_sink_event));
+  gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->sinkpad);
+
+  mpeg2dec->srcpad =
+      gst_pad_new_from_static_template (&src_template_factory, "src");
+  gst_pad_set_event_function (mpeg2dec->srcpad,
+      GST_DEBUG_FUNCPTR (gst_mpeg2dec_src_event));
+#if 0
+  gst_pad_set_query_function (mpeg2dec->srcpad,
+      GST_DEBUG_FUNCPTR (gst_mpeg2dec_src_query));
+#endif
+  gst_pad_use_fixed_caps (mpeg2dec->srcpad);
+  gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->srcpad);
+
+#ifdef enable_user_data
+  mpeg2dec->userdatapad =
+      gst_pad_new_from_static_template (&user_data_template_factory,
+      "user_data");
+  gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->userdatapad);
+#endif
+
+  mpeg2dec->error_count = 0;
+  mpeg2dec->can_allocate_aligned = TRUE;
+
+  /* initialize the mpeg2dec acceleration */
+}
+
+static void
+gst_mpeg2dec_finalize (GObject * object)
+{
+  GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (object);
+
+  if (mpeg2dec->decoder) {
+    GST_DEBUG_OBJECT (mpeg2dec, "closing decoder");
+    mpeg2_close (mpeg2dec->decoder);
+    mpeg2dec->decoder = NULL;
+  }
+  clear_buffers (mpeg2dec);
+  g_free (mpeg2dec->dummybuf[3]);
+  mpeg2dec->dummybuf[3] = NULL;
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gst_mpeg2dec_reset (GstMpeg2dec * mpeg2dec)
+{
+  /* reset the initial video state */
+  gst_video_info_init (&mpeg2dec->vinfo);
+  gst_segment_init (&mpeg2dec->segment, GST_FORMAT_UNDEFINED);
+  mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
+  mpeg2dec->frame_period = 0;
+  mpeg2dec->need_sequence = TRUE;
+  mpeg2dec->next_time = -1;
+  mpeg2dec->offset = 0;
+  mpeg2dec->error_count = 0;
+  mpeg2dec->can_allocate_aligned = TRUE;
+  mpeg2_reset (mpeg2dec->decoder, 1);
+}
+
+static void
+gst_mpeg2dec_qos_reset (GstMpeg2dec * mpeg2dec)
+{
+  GST_OBJECT_LOCK (mpeg2dec);
+  mpeg2dec->proportion = 1.0;
+  mpeg2dec->earliest_time = -1;
+  mpeg2dec->dropped = 0;
+  mpeg2dec->processed = 0;
+  GST_OBJECT_UNLOCK (mpeg2dec);
+}
+
+static GstFlowReturn
+gst_mpeg2dec_crop_buffer (GstMpeg2dec * dec, GstBuffer ** buf,
+    GstVideoFrame * frame)
+{
+  GstFlowReturn ret;
+  GstBuffer *outbuf;
+  GstVideoFrame outframe;
+  guint i, n_planes;
+
+  ret = gst_buffer_pool_acquire_buffer (dec->pool, &outbuf, NULL);
+  if (G_UNLIKELY (ret != GST_FLOW_OK))
+    return ret;;
+
+  GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, dec,
+      "cropping input buffer to output buffer");
+
+  gst_video_frame_map (&outframe, &dec->cinfo, outbuf, GST_MAP_WRITE);
+
+  n_planes = GST_VIDEO_FRAME_N_PLANES (&outframe);
+
+  for (i = 0; i < n_planes; i++) {
+    guint w, h, j;
+    guint8 *sp, *dp;
+    gint ss, ds;
+
+    sp = GST_VIDEO_FRAME_PLANE_DATA (frame, i);
+    dp = GST_VIDEO_FRAME_PLANE_DATA (&outframe, i);
+
+    ss = GST_VIDEO_FRAME_PLANE_STRIDE (frame, i);
+    ds = GST_VIDEO_FRAME_PLANE_STRIDE (&outframe, i);
+
+    w = MIN (ABS (ss), ABS (ds));
+    h = GST_VIDEO_FRAME_COMP_HEIGHT (&outframe, i);
+
+    GST_CAT_DEBUG (GST_CAT_PERFORMANCE, "copy plane %u, w:%u h:%u ", i, w, h);
+
+    for (j = 0; j < h; j++) {
+      memcpy (dp, sp, w);
+      dp += ds;
+      sp += ss;
+    }
+  }
+  gst_video_frame_unmap (&outframe);
+
+  gst_buffer_copy_into (outbuf, *buf,
+      GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS, 0, -1);
+
+  gst_buffer_unref (*buf);
+  *buf = outbuf;
+
+  return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_mpeg2dec_negotiate_pool (GstMpeg2dec * dec, GstCaps * caps,
+    GstVideoInfo * vinfo, GstVideoInfo * cinfo)
+{
+  GstQuery *query;
+  GstBufferPool *pool;
+  guint size, min, max;
+  GstStructure *config;
+  GstCaps *pcaps;
+
+  /* find a pool for the negotiated caps now */
+  query = gst_query_new_allocation (caps, TRUE);
+
+  if (gst_pad_peer_query (dec->srcpad, query)) {
+    /* check if downstream supports cropping */
+    dec->has_cropping =
+        gst_query_has_allocation_meta (query, GST_VIDEO_CROP_META_API_TYPE);
+  } else {
+    /* use the query default then */
+    GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints");
+    dec->has_cropping = FALSE;
+  }
+
+  if (gst_query_get_n_allocation_pools (query) > 0) {
+    /* we got configuration from our peer, parse them */
+    gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
+  } else {
+    pool = NULL;
+    size = 0;
+    min = max = 0;
+  }
+
+  GST_DEBUG_OBJECT (dec,
+      "size:%d, min:%d, max:%d,pool:%p", size, min, max, pool);
+  GST_DEBUG_OBJECT (dec, "downstream cropping %d", dec->has_cropping);
+
+  if (pool == NULL) {
+    /* we did not get a pool, make one ourselves then */
+    pool = gst_video_buffer_pool_new ();
+  }
+
+  if (dec->pool) {
+    gst_buffer_pool_set_active (dec->pool, FALSE);
+    gst_object_unref (dec->pool);
+  }
+  dec->pool = pool;
+
+  if (dec->need_cropping && dec->has_cropping) {
+    /* we can crop, configure the pool with buffers of caps and size of the
+     * decoded picture size and then crop them with metadata */
+    pcaps = gst_video_info_to_caps (vinfo);
+    size = MAX (size, GST_VIDEO_INFO_SIZE (vinfo));
+  } else {
+    /* no cropping, use cropped videoinfo */
+    pcaps = gst_caps_ref (caps);
+    size = MAX (size, GST_VIDEO_INFO_SIZE (cinfo));
+  }
+
+  config = gst_buffer_pool_get_config (pool);
+  gst_buffer_pool_config_set_params (config, pcaps, size, min, max);
+  gst_caps_unref (pcaps);
+
+  if (gst_query_has_allocation_meta (query, GST_VIDEO_META_API_TYPE)) {
+    /* just set the option, if the pool can support it we will transparently use
+     * it through the video info API. We could also see if the pool support this
+     * option and only activate it then. */
+    gst_buffer_pool_config_add_option (config,
+        GST_BUFFER_POOL_OPTION_VIDEO_META);
+  }
+
+  gst_buffer_pool_set_config (pool, config);
+  /* and activate */
+  gst_buffer_pool_set_active (pool, TRUE);
+
+  gst_query_unref (query);
+
+  return GST_FLOW_OK;
+}
+
+static void
+init_dummybuf (GstMpeg2dec * mpeg2dec)
+{
+  g_free (mpeg2dec->dummybuf[3]);
+
+  /* libmpeg2 needs 16 byte aligned buffers... care for this here */
+  mpeg2dec->dummybuf[3] = g_malloc0 (mpeg2dec->size + 15);
+  mpeg2dec->dummybuf[0] = ALIGN_16 (mpeg2dec->dummybuf[3]);
+  mpeg2dec->dummybuf[1] = mpeg2dec->dummybuf[0] + mpeg2dec->u_offs;
+  mpeg2dec->dummybuf[2] = mpeg2dec->dummybuf[0] + mpeg2dec->v_offs;
+}
+
+static GstFlowReturn
+handle_sequence (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
+{
+  GstFlowReturn ret = GST_FLOW_OK;
+  const mpeg2_sequence_t *sequence;
+  gint par_n, par_d;
+  GstVideoInfo vinfo, cinfo;
+  GstVideoFormat format;
+  GstCaps *caps;
+  gint y_size, uv_size;
+
+  sequence = info->sequence;
+
+  if (sequence->frame_period == 0)
+    goto invalid_frame_period;
+
+  /* mpeg2 video can only be from 16x16 to 4096x4096. Everything
+   * else is a corrupted file */
+  if (sequence->width > 4096 || sequence->width < 16 ||
+      sequence->height > 4096 || sequence->height < 16)
+    goto invalid_size;
+
+  GST_DEBUG_OBJECT (mpeg2dec,
+      "widthxheight: %dx%d , decoded_widthxheight: %dx%d",
+      sequence->picture_width, sequence->picture_height, sequence->width,
+      sequence->height);
+
+  if (sequence->picture_width != sequence->width ||
+      sequence->picture_height != sequence->height) {
+    GST_DEBUG_OBJECT (mpeg2dec, "we need to crop");
+    mpeg2dec->need_cropping = TRUE;
+  } else {
+    GST_DEBUG_OBJECT (mpeg2dec, "no cropping needed");
+    mpeg2dec->need_cropping = FALSE;
+  }
+
+  y_size = sequence->width * sequence->height;
+  /* get subsampling */
+  if (sequence->chroma_width < sequence->width) {
+    /* horizontally subsampled */
+    if (sequence->chroma_height < sequence->height) {
+      /* and vertically subsamples */
+      format = GST_VIDEO_FORMAT_I420;
+      uv_size = y_size >> 2;
+    } else {
+      format = GST_VIDEO_FORMAT_Y42B;
+      uv_size = y_size >> 1;
+    }
+  } else {
+    /* not subsampled */
+    format = GST_VIDEO_FORMAT_Y444;
+    uv_size = y_size;
+  }
+
+  /* calculate size and offsets of the decoded frames */
+  mpeg2dec->size = y_size + 2 * (uv_size);
+  mpeg2dec->u_offs = y_size;
+  mpeg2dec->v_offs = y_size + uv_size;
+
+  /* we store the codec size before cropping */
+  gst_video_info_init (&vinfo);
+  gst_video_info_set_format (&vinfo, format, sequence->width, sequence->height);
+
+  /* sink caps par overrides sequence PAR */
+  if (mpeg2dec->have_par) {
+    par_n = mpeg2dec->in_par_n;
+    par_d = mpeg2dec->in_par_d;
+    GST_DEBUG_OBJECT (mpeg2dec, "using sink par %d:%d", par_n, par_d);
+  } else {
+    par_n = sequence->pixel_width;
+    par_d = sequence->pixel_height;
+    GST_DEBUG_OBJECT (mpeg2dec, "using encoded par %d:%d", par_n, par_d);
+  }
+
+  if (par_n == 0 || par_d == 0) {
+    if (!gst_util_fraction_multiply (4, 3, sequence->picture_height,
+            sequence->picture_width, &par_n, &par_d))
+      par_n = par_d = 1;
+
+    GST_WARNING_OBJECT (mpeg2dec, "Unknown par, assuming %d:%d", par_n, par_d);
+  }
+  vinfo.par_n = par_n;
+  vinfo.par_d = par_d;
+
+  /* set framerate */
+  vinfo.fps_n = 27000000;
+  vinfo.fps_d = sequence->frame_period;
+  mpeg2dec->frame_period = sequence->frame_period * GST_USECOND / 27;
+
+  if (!(sequence->flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE))
+    vinfo.interlace_mode = GST_VIDEO_INTERLACE_MODE_MIXED;
+  else
+    vinfo.interlace_mode = GST_VIDEO_INTERLACE_MODE_PROGRESSIVE;
+
+  vinfo.chroma_site = GST_VIDEO_CHROMA_SITE_MPEG2;
+  vinfo.colorimetry.range = GST_VIDEO_COLOR_RANGE_16_235;
+
+  if (sequence->flags & SEQ_FLAG_COLOUR_DESCRIPTION) {
+    /* do color description */
+    switch (sequence->colour_primaries) {
+      case 1:
+        vinfo.colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
+        break;
+      case 4:
+        vinfo.colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_BT470M;
+        break;
+      case 5:
+        vinfo.colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_BT470BG;
+        break;
+      case 6:
+        vinfo.colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTE170M;
+        break;
+      case 7:
+        vinfo.colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTE240M;
+        break;
+        /* 0 forbidden */
+        /* 2 unspecified */
+        /* 3 reserved */
+        /* 8-255 reseved */
+      default:
+        vinfo.colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_UNKNOWN;
+        break;
+    }
+    /* matrix coefficients */
+    switch (sequence->matrix_coefficients) {
+      case 1:
+        vinfo.colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_BT709;
+        break;
+      case 4:
+        vinfo.colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_FCC;
+        break;
+      case 5:
+      case 6:
+        vinfo.colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_BT601;
+        break;
+      case 7:
+        vinfo.colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_SMPTE240M;
+        break;
+        /* 0 forbidden */
+        /* 2 unspecified */
+        /* 3 reserved */
+        /* 8-255 reseved */
+      default:
+        vinfo.colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_UNKNOWN;
+        break;
+    }
+    /* transfer characteristics */
+    switch (sequence->transfer_characteristics) {
+      case 1:
+        vinfo.colorimetry.transfer = GST_VIDEO_TRANSFER_BT709;
+        break;
+      case 4:
+        vinfo.colorimetry.transfer = GST_VIDEO_TRANSFER_GAMMA22;
+        break;
+      case 5:
+        vinfo.colorimetry.transfer = GST_VIDEO_TRANSFER_GAMMA28;
+        break;
+      case 6:
+        vinfo.colorimetry.transfer = GST_VIDEO_TRANSFER_BT709;
+        break;
+      case 7:
+        vinfo.colorimetry.transfer = GST_VIDEO_TRANSFER_SMPTE240M;
+        break;
+      case 8:
+        vinfo.colorimetry.transfer = GST_VIDEO_TRANSFER_GAMMA10;
+        break;
+        /* 0 forbidden */
+        /* 2 unspecified */
+        /* 3 reserved */
+        /* 9-255 reseved */
+      default:
+        vinfo.colorimetry.transfer = GST_VIDEO_TRANSFER_UNKNOWN;
+        break;
+    }
+  }
+
+  GST_DEBUG_OBJECT (mpeg2dec,
+      "sequence flags: %d, frame period: %d (%g), frame rate: %d/%d",
+      sequence->flags, sequence->frame_period,
+      (double) (mpeg2dec->frame_period) / GST_SECOND, vinfo.fps_n, vinfo.fps_d);
+  GST_DEBUG_OBJECT (mpeg2dec, "profile: %02x, colour_primaries: %d",
+      sequence->profile_level_id, sequence->colour_primaries);
+  GST_DEBUG_OBJECT (mpeg2dec, "transfer chars: %d, matrix coef: %d",
+      sequence->transfer_characteristics, sequence->matrix_coefficients);
+  GST_DEBUG_OBJECT (mpeg2dec,
+      "FLAGS: CONSTRAINED_PARAMETERS:%d, PROGRESSIVE_SEQUENCE:%d",
+      sequence->flags & SEQ_FLAG_CONSTRAINED_PARAMETERS,
+      sequence->flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE);
+  GST_DEBUG_OBJECT (mpeg2dec, "FLAGS: LOW_DELAY:%d, COLOUR_DESCRIPTION:%d",
+      sequence->flags & SEQ_FLAG_LOW_DELAY,
+      sequence->flags & SEQ_FLAG_COLOUR_DESCRIPTION);
+
+  /* for the output caps we always take the cropped dimensions */
+  cinfo = vinfo;
+  gst_video_info_set_format (&cinfo, GST_VIDEO_INFO_FORMAT (&vinfo),
+      sequence->picture_width, sequence->picture_height);
+  caps = gst_video_info_to_caps (&cinfo);
+  gst_pad_set_caps (mpeg2dec->srcpad, caps);
+
+  gst_mpeg2dec_negotiate_pool (mpeg2dec, caps, &vinfo, &cinfo);
+  gst_caps_unref (caps);
+
+  mpeg2dec->vinfo = vinfo;
+  mpeg2dec->cinfo = cinfo;
+
+  mpeg2_custom_fbuf (mpeg2dec->decoder, 1);
+  init_dummybuf (mpeg2dec);
+
+  /* Pump in some null buffers, because otherwise libmpeg2 doesn't
+   * initialise the discard_fbuf->id */
+  mpeg2_set_buf (mpeg2dec->decoder, mpeg2dec->dummybuf, NULL);
+  mpeg2_set_buf (mpeg2dec->decoder, mpeg2dec->dummybuf, NULL);
+  mpeg2_set_buf (mpeg2dec->decoder, mpeg2dec->dummybuf, NULL);
+
+  mpeg2dec->need_sequence = FALSE;
+
+done:
+  return ret;
+
+invalid_frame_period:
+  {
+    GST_WARNING_OBJECT (mpeg2dec, "Frame period is 0!");
+    ret = GST_FLOW_ERROR;
+    goto done;
+  }
+invalid_size:
+  {
+    GST_ERROR_OBJECT (mpeg2dec, "Invalid frame dimensions: %d x %d",
+        sequence->width, sequence->height);
+    return GST_FLOW_ERROR;
+  }
+}
+
+static void
+clear_buffers (GstMpeg2dec * mpeg2dec)
+{
+  gint i;
+  GstVideoFrame *frame;
+
+  for (i = 0; i < 4; i++) {
+    frame = &mpeg2dec->ip_frame[i];
+    if (frame->buffer) {
+      gst_video_frame_unmap (frame);
+      gst_buffer_unref (frame->buffer);
+      frame->buffer = NULL;
+    }
+  }
+  frame = &mpeg2dec->b_frame;
+  if (frame->buffer) {
+    gst_video_frame_unmap (frame);
+    gst_buffer_unref (frame->buffer);
+    frame->buffer = NULL;
+  }
+}
+
+static void
+clear_queued (GstMpeg2dec * mpeg2dec)
+{
+  g_list_foreach (mpeg2dec->queued, (GFunc) gst_mini_object_unref, NULL);
+  g_list_free (mpeg2dec->queued);
+  mpeg2dec->queued = NULL;
+}
+
+static GstFlowReturn
+flush_queued (GstMpeg2dec * mpeg2dec)
+{
+  GstFlowReturn res = GST_FLOW_OK;
+
+  while (mpeg2dec->queued) {
+    GstBuffer *buf = GST_BUFFER_CAST (mpeg2dec->queued->data);
+
+    GST_LOG_OBJECT (mpeg2dec, "pushing buffer %p, timestamp %"
+        GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT, buf,
+        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
+        GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
+
+    /* iterate ouput queue an push downstream */
+    res = gst_pad_push (mpeg2dec->srcpad, buf);
+
+    mpeg2dec->queued = g_list_delete_link (mpeg2dec->queued, mpeg2dec->queued);
+  }
+  return res;
+}
+
+static GstFlowReturn
+handle_picture (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
+{
+  gboolean key_frame = FALSE;
+  GstBuffer *outbuf;
+  GstVideoFrame *frame;
+  GstFlowReturn ret;
+  gint type;
+  guint8 *buf[3];
+
+  if (mpeg2dec->need_cropping && !mpeg2dec->has_cropping) {
+    GstAllocationParams params = { 0, };
+
+    /* we need to crop manually */
+    params.align = 15;
+    outbuf =
+        gst_buffer_new_allocate (NULL, GST_VIDEO_INFO_SIZE (&mpeg2dec->vinfo),
+        &params);
+    ret = GST_FLOW_OK;
+  } else {
+    ret = gst_buffer_pool_acquire_buffer (mpeg2dec->pool, &outbuf, NULL);
+    if (G_UNLIKELY (ret != GST_FLOW_OK))
+      goto no_buffer;
+  }
+
+  /* we store the original byteoffset of this picture in the stream here
+   * because we need it for indexing */
+  GST_BUFFER_OFFSET (outbuf) = mpeg2dec->offset;
+
+  if (info->current_picture) {
+    type = info->current_picture->flags & PIC_MASK_CODING_TYPE;
+  } else {
+    type = 0;
+  }
+
+  GST_DEBUG_OBJECT (mpeg2dec, "handle picture type %d", type);
+
+  key_frame = type == PIC_FLAG_CODING_TYPE_I;
+
+  switch (type) {
+    case PIC_FLAG_CODING_TYPE_I:
+      mpeg2_skip (mpeg2dec->decoder, 0);
+      if (mpeg2dec->segment.rate < 0.0) {
+        /* negative rate, flush the queued pictures in reverse */
+        GST_DEBUG_OBJECT (mpeg2dec, "flushing queued buffers");
+        flush_queued (mpeg2dec);
+      }
+      /* fallthrough */
+    case PIC_FLAG_CODING_TYPE_P:
+      frame = &mpeg2dec->ip_frame[mpeg2dec->ip_framepos];
+      GST_DEBUG_OBJECT (mpeg2dec, "I/P unref %p, ref %p", frame, outbuf);
+      mpeg2dec->ip_framepos = (mpeg2dec->ip_framepos + 1) & 3;
+      break;
+    case PIC_FLAG_CODING_TYPE_B:
+      frame = &mpeg2dec->b_frame;
+      GST_DEBUG_OBJECT (mpeg2dec, "B unref %p, ref %p", frame, outbuf);
+      break;
+    default:
+      goto unknown_frame;
+  }
+
+  if (frame->buffer) {
+    gst_video_frame_unmap (frame);
+    gst_buffer_unref (frame->buffer);
+    frame->buffer = NULL;
+  }
+
+  if (mpeg2dec->need_cropping && mpeg2dec->has_cropping) {
+    GstVideoCropMeta *crop;
+
+    crop = gst_buffer_add_video_crop_meta (outbuf);
+    /* we can do things slightly more efficient when we know that
+     * downstream understands clipping */
+    crop->x = 0;
+    crop->y = 0;
+    crop->width = info->sequence->picture_width;
+    crop->height = info->sequence->picture_height;
+  }
+
+  gst_video_frame_map (frame, &mpeg2dec->vinfo, outbuf, GST_MAP_WRITE);
+
+  buf[0] = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
+  buf[1] = GST_VIDEO_FRAME_PLANE_DATA (frame, 1);
+  buf[2] = GST_VIDEO_FRAME_PLANE_DATA (frame, 2);
+
+  GST_DEBUG_OBJECT (mpeg2dec, "set_buf: %p %p %p, outbuf %p",
+      buf[0], buf[1], buf[2], outbuf);
+
+  mpeg2_set_buf (mpeg2dec->decoder, buf, frame);
+
+  GST_DEBUG_OBJECT (mpeg2dec, "picture %s, outbuf %p, offset %"
+      G_GINT64_FORMAT,
+      key_frame ? ", kf," : "    ", outbuf, GST_BUFFER_OFFSET (outbuf)
+      );
+
+  if (mpeg2dec->discont_state == MPEG2DEC_DISC_NEW_PICTURE && key_frame)
+    mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_KEYFRAME;
+
+  return ret;
+
+no_buffer:
+  {
+    return ret;
+  }
+unknown_frame:
+  {
+    return ret;
+  }
+}
+
+/* try to clip the buffer to the segment boundaries */
+static gboolean
+clip_buffer (GstMpeg2dec * dec, GstBuffer * buf)
+{
+  gboolean res = TRUE;
+  GstClockTime in_ts, in_dur, stop;
+  guint64 cstart, cstop;
+
+  in_ts = GST_BUFFER_TIMESTAMP (buf);
+  in_dur = GST_BUFFER_DURATION (buf);
+
+  GST_LOG_OBJECT (dec,
+      "timestamp:%" GST_TIME_FORMAT " , duration:%" GST_TIME_FORMAT,
+      GST_TIME_ARGS (in_ts), GST_TIME_ARGS (in_dur));
+
+  /* can't clip without TIME segment */
+  if (dec->segment.format != GST_FORMAT_TIME)
+    goto beach;
+
+  /* we need a start time */
+  if (!GST_CLOCK_TIME_IS_VALID (in_ts))
+    goto beach;
+
+  /* generate valid stop, if duration unknown, we have unknown stop */
+  stop =
+      GST_CLOCK_TIME_IS_VALID (in_dur) ? (in_ts + in_dur) : GST_CLOCK_TIME_NONE;
+
+  /* now clip */
+  if (!(res = gst_segment_clip (&dec->segment, GST_FORMAT_TIME,
+              in_ts, stop, &cstart, &cstop)))
+    goto beach;
+
+  /* update timestamp and possibly duration if the clipped stop time is
+   * valid */
+  GST_BUFFER_TIMESTAMP (buf) = cstart;
+  if (GST_CLOCK_TIME_IS_VALID (cstop))
+    GST_BUFFER_DURATION (buf) = cstop - cstart;
+
+beach:
+  GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
+  return res;
+}
+
+static GstFlowReturn
+handle_slice (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
+{
+  GstBuffer *outbuf = NULL;
+  GstFlowReturn ret = GST_FLOW_OK;
+  const mpeg2_picture_t *picture;
+  gboolean key_frame = FALSE;
+  GstClockTime time;
+  GstVideoFrame *frame;
+
+  GST_DEBUG_OBJECT (mpeg2dec, "picture slice/end %p %p %p %p",
+      info->display_fbuf,
+      info->display_picture, info->current_picture,
+      (info->display_fbuf ? info->display_fbuf->id : NULL));
+
+  if (!info->display_fbuf || !info->display_fbuf->id)
+    goto no_display;
+
+  frame = (GstVideoFrame *) (info->display_fbuf->id);
+  outbuf = frame->buffer;
+
+  picture = info->display_picture;
+
+  key_frame = (picture->flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I;
+
+  GST_DEBUG_OBJECT (mpeg2dec, "picture flags: %d, type: %d, keyframe: %d",
+      picture->flags, picture->flags & PIC_MASK_CODING_TYPE, key_frame);
+
+  if (key_frame) {
+    GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
+    mpeg2_skip (mpeg2dec->decoder, 0);
+  } else {
+    GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
+  }
+
+  if (mpeg2dec->discont_state == MPEG2DEC_DISC_NEW_KEYFRAME && key_frame)
+    mpeg2dec->discont_state = MPEG2DEC_DISC_NONE;
+
+  time = GST_CLOCK_TIME_NONE;
+
+#if MPEG2_RELEASE < MPEG2_VERSION(0,4,0)
+  if (picture->flags & PIC_FLAG_PTS) {
+    time = MPEG_TIME_TO_GST_TIME (picture->pts);
+    GST_DEBUG_OBJECT (mpeg2dec, "picture pts %" G_GUINT64_FORMAT
+        ", time %" GST_TIME_FORMAT, picture->pts, GST_TIME_ARGS (time));
+  }
+#else
+  if (picture->flags & PIC_FLAG_TAGS) {
+    guint64 pts = (((guint64) picture->tag2) << 32) | picture->tag;
+
+    time = MPEG_TIME_TO_GST_TIME (pts);
+    GST_DEBUG_OBJECT (mpeg2dec, "picture tags %" G_GUINT64_FORMAT
+        ", time %" GST_TIME_FORMAT, pts, GST_TIME_ARGS (time));
+  }
+#endif
+
+  if (time == GST_CLOCK_TIME_NONE) {
+    time = mpeg2dec->next_time;
+    GST_DEBUG_OBJECT (mpeg2dec, "picture didn't have pts");
+  } else {
+    GST_DEBUG_OBJECT (mpeg2dec,
+        "picture had pts %" GST_TIME_FORMAT ", we had %"
+        GST_TIME_FORMAT, GST_TIME_ARGS (time),
+        GST_TIME_ARGS (mpeg2dec->next_time));
+    mpeg2dec->next_time = time;
+  }
+  GST_BUFFER_TIMESTAMP (outbuf) = time;
+
+  /* TODO set correct offset here based on frame number */
+  if (info->display_picture_2nd) {
+    GST_BUFFER_DURATION (outbuf) = (picture->nb_fields +
+        info->display_picture_2nd->nb_fields) * mpeg2dec->frame_period / 2;
+  } else {
+    GST_BUFFER_DURATION (outbuf) =
+        picture->nb_fields * mpeg2dec->frame_period / 2;
+  }
+  mpeg2dec->next_time += GST_BUFFER_DURATION (outbuf);
+
+  if (!(picture->flags & PIC_FLAG_PROGRESSIVE_FRAME))
+    GST_BUFFER_FLAG_SET (outbuf, GST_VIDEO_BUFFER_FLAG_INTERLACED);
+
+  if (picture->flags & PIC_FLAG_TOP_FIELD_FIRST)
+    GST_BUFFER_FLAG_SET (outbuf, GST_VIDEO_BUFFER_FLAG_TFF);
+
+#if MPEG2_RELEASE >= MPEG2_VERSION(0,5,0)
+  /* repeat field introduced in 0.5.0 */
+  if (picture->flags & PIC_FLAG_REPEAT_FIRST_FIELD)
+    GST_BUFFER_FLAG_SET (outbuf, GST_VIDEO_BUFFER_FLAG_RFF);
+#endif
+
+  GST_DEBUG_OBJECT (mpeg2dec,
+      "picture: %s %s %s %s %s fields:%d off:%" G_GINT64_FORMAT " ts:%"
+      GST_TIME_FORMAT,
+      (picture->flags & PIC_FLAG_PROGRESSIVE_FRAME ? "prog" : "    "),
+      (picture->flags & PIC_FLAG_TOP_FIELD_FIRST ? "tff" : "   "),
+#if MPEG2_RELEASE >= MPEG2_VERSION(0,5,0)
+      (picture->flags & PIC_FLAG_REPEAT_FIRST_FIELD ? "rff" : "   "),
+#else
+      "unknown rff",
+#endif
+      (picture->flags & PIC_FLAG_SKIP ? "skip" : "    "),
+      (picture->flags & PIC_FLAG_COMPOSITE_DISPLAY ? "composite" : "         "),
+      picture->nb_fields, GST_BUFFER_OFFSET (outbuf),
+      GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)));
+
+  if (picture->flags & PIC_FLAG_SKIP)
+    goto skip;
+
+  if (mpeg2dec->discont_state != MPEG2DEC_DISC_NONE)
+    goto drop;
+
+  /* check for clipping */
+  if (!clip_buffer (mpeg2dec, outbuf))
+    goto clipped;
+
+  if (GST_CLOCK_TIME_IS_VALID (time)) {
+    gboolean need_skip;
+    GstClockTime qostime;
+
+    /* qos needs to be done on running time */
+    qostime = gst_segment_to_running_time (&mpeg2dec->segment, GST_FORMAT_TIME,
+        time);
+
+    GST_OBJECT_LOCK (mpeg2dec);
+    /* check for QoS, don't perform the last steps of getting and
+     * pushing the buffers that are known to be late. */
+    /* FIXME, we can also entirely skip decoding if the next valid buffer is
+     * known to be after a keyframe (using the granule_shift) */
+    need_skip = mpeg2dec->earliest_time != -1
+        && qostime <= mpeg2dec->earliest_time;
+    GST_OBJECT_UNLOCK (mpeg2dec);
+
+    if (need_skip) {
+      GstMessage *qos_msg;
+      guint64 stream_time;
+      gint64 jitter;
+
+      mpeg2dec->dropped++;
+
+      stream_time =
+          gst_segment_to_stream_time (&mpeg2dec->segment, GST_FORMAT_TIME,
+          time);
+      jitter = GST_CLOCK_DIFF (qostime, mpeg2dec->earliest_time);
+
+      qos_msg =
+          gst_message_new_qos (GST_OBJECT_CAST (mpeg2dec), FALSE, qostime,
+          stream_time, time, GST_BUFFER_DURATION (outbuf));
+      gst_message_set_qos_values (qos_msg, jitter, mpeg2dec->proportion,
+          1000000);
+      gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
+          mpeg2dec->processed, mpeg2dec->dropped);
+      gst_element_post_message (GST_ELEMENT_CAST (mpeg2dec), qos_msg);
+
+      goto dropping_qos;
+    }
+  }
+
+  mpeg2dec->processed++;
+
+  /* ref before pushing it out, so we still have the ref in our
+   * array of buffers */
+  gst_buffer_ref (outbuf);
+
+  /* do cropping if the target region is smaller than the input one */
+  if (mpeg2dec->need_cropping && !mpeg2dec->has_cropping) {
+    GST_DEBUG_OBJECT (mpeg2dec, "cropping buffer");
+    ret = gst_mpeg2dec_crop_buffer (mpeg2dec, &outbuf, frame);
+    if (ret != GST_FLOW_OK)
+      goto done;
+  }
+
+  if (mpeg2dec->segment.rate >= 0.0) {
+    /* forward: push right away */
+    GST_LOG_OBJECT (mpeg2dec, "pushing buffer %p, timestamp %"
+        GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT,
+        outbuf,
+        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
+        GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)));
+    GST_LOG_OBJECT (mpeg2dec, "... with flags %x", GST_BUFFER_FLAGS (outbuf));
+
+    ret = gst_pad_push (mpeg2dec->srcpad, outbuf);
+    GST_DEBUG_OBJECT (mpeg2dec, "pushed with result %s",
+        gst_flow_get_name (ret));
+  } else {
+    /* reverse: queue, we'll push in reverse when we receive the next (previous)
+     * keyframe. */
+    GST_DEBUG_OBJECT (mpeg2dec, "queued frame");
+    mpeg2dec->queued = g_list_prepend (mpeg2dec->queued, outbuf);
+    ret = GST_FLOW_OK;
+  }
+done:
+  return ret;
+
+  /* special cases */
+no_display:
+  {
+    GST_DEBUG_OBJECT (mpeg2dec, "no picture to display");
+    return GST_FLOW_OK;
+  }
+skip:
+  {
+    GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer because of skip flag");
+    return GST_FLOW_OK;
+  }
+drop:
+  {
+    GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer, discont state %d",
+        mpeg2dec->discont_state);
+    return GST_FLOW_OK;
+  }
+clipped:
+  {
+    GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer, clipped");
+    return GST_FLOW_OK;
+  }
+dropping_qos:
+  {
+    GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer because of QoS");
+    return GST_FLOW_OK;
+  }
+}
+
+static GstFlowReturn
+gst_mpeg2dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
+{
+  GstMpeg2dec *mpeg2dec;
+  GstMapInfo map;
+  GstClockTime pts;
+  const mpeg2_info_t *info;
+  mpeg2_state_t state;
+  gboolean done = FALSE;
+  GstFlowReturn ret = GST_FLOW_OK;
+
+  mpeg2dec = GST_MPEG2DEC (parent);
+
+  gst_buffer_map (buf, &map, GST_MAP_READ);
+  pts = GST_BUFFER_TIMESTAMP (buf);
+
+  if (GST_BUFFER_IS_DISCONT (buf)) {
+    GST_LOG_OBJECT (mpeg2dec, "DISCONT, reset decoder");
+    /* when we receive a discont, reset our state as to not create too much
+     * distortion in the picture due to missing packets */
+    mpeg2_reset (mpeg2dec->decoder, 0);
+    mpeg2_skip (mpeg2dec->decoder, 1);
+    mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
+  }
+
+  GST_LOG_OBJECT (mpeg2dec, "received buffer, timestamp %"
+      GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT,
+      GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
+      GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
+
+  info = mpeg2dec->info;
+
+  mpeg2dec->offset = GST_BUFFER_OFFSET (buf);
+
+  if (pts != GST_CLOCK_TIME_NONE) {
+    gint64 mpeg_pts = GST_TIME_TO_MPEG_TIME (pts);
+
+    GST_DEBUG_OBJECT (mpeg2dec,
+        "have pts: %" G_GINT64_FORMAT " (%" GST_TIME_FORMAT ")",
+        mpeg_pts, GST_TIME_ARGS (MPEG_TIME_TO_GST_TIME (mpeg_pts)));
+
+#if MPEG2_RELEASE >= MPEG2_VERSION(0,4,0)
+    mpeg2_tag_picture (mpeg2dec->decoder, mpeg_pts & 0xffffffff,
+        mpeg_pts >> 32);
+#else
+    mpeg2_pts (mpeg2dec->decoder, mpeg_pts);
+#endif
+  } else {
+    GST_LOG ("no pts");
+  }
+
+  GST_LOG_OBJECT (mpeg2dec, "calling mpeg2_buffer");
+  mpeg2_buffer (mpeg2dec->decoder, map.data, map.data + map.size);
+  GST_LOG_OBJECT (mpeg2dec, "calling mpeg2_buffer done");
+
+  while (!done) {
+    GST_LOG_OBJECT (mpeg2dec, "calling parse");
+    state = mpeg2_parse (mpeg2dec->decoder);
+    GST_DEBUG_OBJECT (mpeg2dec, "parse state %d", state);
+
+    switch (state) {
+#if MPEG2_RELEASE >= MPEG2_VERSION (0, 5, 0)
+      case STATE_SEQUENCE_MODIFIED:
+        GST_DEBUG_OBJECT (mpeg2dec, "sequence modified");
+        /* fall through */
+#endif
+      case STATE_SEQUENCE:
+        ret = handle_sequence (mpeg2dec, info);
+        /* if there is an error handling the sequence
+         * reset the decoder, maybe something more elegant
+         * could be done.
+         */
+        if (ret == GST_FLOW_ERROR) {
+          mpeg2dec->error_count++;
+          GST_WARNING_OBJECT (mpeg2dec, "Decoding error #%d",
+              mpeg2dec->error_count);
+          if (mpeg2dec->error_count >= WARN_THRESHOLD && WARN_THRESHOLD > 0) {
+            GST_ELEMENT_WARNING (mpeg2dec, STREAM, DECODE,
+                ("%d consecutive decoding errors", mpeg2dec->error_count),
+                (NULL));
+          }
+          mpeg2_reset (mpeg2dec->decoder, 0);
+          mpeg2_skip (mpeg2dec->decoder, 1);
+          mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
+
+          goto exit;
+        }
+        break;
+      case STATE_SEQUENCE_REPEATED:
+        GST_DEBUG_OBJECT (mpeg2dec, "sequence repeated");
+        break;
+      case STATE_GOP:
+        GST_DEBUG_OBJECT (mpeg2dec, "gop");
+        break;
+      case STATE_PICTURE:
+        ret = handle_picture (mpeg2dec, info);
+        break;
+      case STATE_SLICE_1ST:
+        GST_LOG_OBJECT (mpeg2dec, "1st slice of frame encountered");
+        break;
+      case STATE_PICTURE_2ND:
+        GST_LOG_OBJECT (mpeg2dec,
+            "Second picture header encountered. Decoding 2nd field");
+        break;
+#if MPEG2_RELEASE >= MPEG2_VERSION (0, 4, 0)
+      case STATE_INVALID_END:
+        GST_DEBUG_OBJECT (mpeg2dec, "invalid end");
+#endif
+      case STATE_END:
+        GST_DEBUG_OBJECT (mpeg2dec, "end");
+        mpeg2dec->need_sequence = TRUE;
+      case STATE_SLICE:
+        ret = handle_slice (mpeg2dec, info);
+        break;
+      case STATE_BUFFER:
+        done = TRUE;
+        break;
+        /* error */
+      case STATE_INVALID:
+        /* FIXME: at some point we should probably send newsegment events to
+         * let downstream know that parts of the stream are missing */
+        mpeg2dec->error_count++;
+        GST_WARNING_OBJECT (mpeg2dec, "Decoding error #%d",
+            mpeg2dec->error_count);
+        if (mpeg2dec->error_count >= WARN_THRESHOLD && WARN_THRESHOLD > 0) {
+          GST_ELEMENT_WARNING (mpeg2dec, STREAM, DECODE,
+              ("%d consecutive decoding errors", mpeg2dec->error_count),
+              (NULL));
+        }
+        continue;
+      default:
+        GST_ERROR_OBJECT (mpeg2dec, "Unknown libmpeg2 state %d, FIXME", state);
+        goto exit;
+    }
+
+    mpeg2dec->error_count = 0;
+
+    /*
+     * FIXME: should pass more information such as state the user data is from
+     */
+#ifdef enable_user_data
+    if (info->user_data_len > 0) {
+      GstBuffer *udbuf =
+          gst_buffer_new_allocate (NULL, info->user_data_len, NULL);
+
+      gst_buffer_fill (udbuf, 0, info->user_data, info->user_data_len);
+
+      gst_pad_push (mpeg2dec->userdatapad, udbuf);
+    }
+#endif
+
+    if (ret != GST_FLOW_OK) {
+      GST_DEBUG_OBJECT (mpeg2dec, "exit loop, reason %s",
+          gst_flow_get_name (ret));
+      break;
+    }
+  }
+done:
+  gst_buffer_unmap (buf, &map);
+  gst_buffer_unref (buf);
+  return ret;
+
+  /* errors */
+exit:
+  {
+    ret = GST_FLOW_OK;
+    goto done;
+  }
+}
+
+static gboolean
+gst_mpeg2dec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
+{
+  GstMpeg2dec *mpeg2dec;
+  gboolean ret = TRUE;
+
+  mpeg2dec = GST_MPEG2DEC (parent);
+
+  GST_DEBUG_OBJECT (mpeg2dec, "Got %s event on sink pad",
+      GST_EVENT_TYPE_NAME (event));
+
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
+
+      gst_event_parse_caps (event, &caps);
+      ret = gst_mpeg2dec_setcaps (pad, caps);
+      gst_event_unref (event);
+      break;
+    }
+    case GST_EVENT_SEGMENT:
+    {
+      GstSegment seg;
+
+      gst_event_copy_segment (event, &seg);
+
+      /* we need TIME */
+      if (seg.format != GST_FORMAT_TIME)
+        goto newseg_wrong_format;
+
+      /* now configure the values */
+      mpeg2dec->segment = seg;
+
+      GST_DEBUG_OBJECT (mpeg2dec, "Pushing seg %" GST_SEGMENT_FORMAT, &seg);
+
+      ret = gst_pad_push_event (mpeg2dec->srcpad, event);
+      break;
+    }
+    case GST_EVENT_FLUSH_START:
+      ret = gst_pad_push_event (mpeg2dec->srcpad, event);
+      break;
+    case GST_EVENT_FLUSH_STOP:
+    {
+      mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
+      mpeg2dec->next_time = -1;;
+      gst_mpeg2dec_qos_reset (mpeg2dec);
+      mpeg2_reset (mpeg2dec->decoder, 0);
+      mpeg2_skip (mpeg2dec->decoder, 1);
+      clear_queued (mpeg2dec);
+      ret = gst_pad_push_event (mpeg2dec->srcpad, event);
+      break;
+    }
+    case GST_EVENT_EOS:
+      ret = gst_pad_push_event (mpeg2dec->srcpad, event);
+      break;
+    default:
+      ret = gst_pad_push_event (mpeg2dec->srcpad, event);
+      break;
+  }
+
+done:
+
+  return ret;
+
+  /* ERRORS */
+newseg_wrong_format:
+  {
+    GST_DEBUG_OBJECT (mpeg2dec, "received non TIME newsegment");
+    gst_event_unref (event);
+    goto done;
+  }
+}
+
+static gboolean
+gst_mpeg2dec_setcaps (GstPad * pad, GstCaps * caps)
+{
+  GstMpeg2dec *mpeg2dec;
+  GstStructure *s;
+
+  mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
+
+  s = gst_caps_get_structure (caps, 0);
+
+  /* parse the par, this overrides the encoded par */
+  mpeg2dec->have_par = gst_structure_get_fraction (s, "pixel-aspect-ratio",
+      &mpeg2dec->in_par_n, &mpeg2dec->in_par_d);
+
+  gst_object_unref (mpeg2dec);
+
+  return TRUE;
+}
+
+static gboolean
+gst_mpeg2dec_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
+{
+  gboolean res;
+  GstMpeg2dec *mpeg2dec;
+
+  mpeg2dec = GST_MPEG2DEC (parent);
+
+  if (mpeg2dec->decoder == NULL)
+    goto no_decoder;
+
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_QOS:
+    {
+      GstQOSType type;
+      gdouble proportion;
+      GstClockTimeDiff diff;
+      GstClockTime timestamp;
+
+      gst_event_parse_qos (event, &type, &proportion, &diff, &timestamp);
+
+      GST_OBJECT_LOCK (mpeg2dec);
+      mpeg2dec->proportion = proportion;
+      mpeg2dec->earliest_time = timestamp + diff;
+      GST_OBJECT_UNLOCK (mpeg2dec);
+
+      GST_DEBUG_OBJECT (mpeg2dec,
+          "got QoS %" GST_TIME_FORMAT ", %" G_GINT64_FORMAT,
+          GST_TIME_ARGS (timestamp), diff);
+
+      res = gst_pad_push_event (mpeg2dec->sinkpad, event);
+      break;
+    }
+    case GST_EVENT_SEEK:
+    case GST_EVENT_NAVIGATION:
+      /* Forward unchanged */
+    default:
+      res = gst_pad_push_event (mpeg2dec->sinkpad, event);
+      break;
+  }
+  return res;
+
+no_decoder:
+  {
+    GST_DEBUG_OBJECT (mpeg2dec, "no decoder, cannot handle event");
+    gst_event_unref (event);
+    return FALSE;
+  }
+}
+
+static GstStateChangeReturn
+gst_mpeg2dec_change_state (GstElement * element, GstStateChange transition)
+{
+  GstStateChangeReturn ret;
+  GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (element);
+
+  switch (transition) {
+    case GST_STATE_CHANGE_NULL_TO_READY:
+      mpeg2_accel (MPEG2_ACCEL_DETECT);
+      if ((mpeg2dec->decoder = mpeg2_init ()) == NULL)
+        goto init_failed;
+      mpeg2dec->info = mpeg2_info (mpeg2dec->decoder);
+      break;
+    case GST_STATE_CHANGE_READY_TO_PAUSED:
+      gst_mpeg2dec_reset (mpeg2dec);
+      gst_mpeg2dec_qos_reset (mpeg2dec);
+      break;
+    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
+    default:
+      break;
+  }
+
+  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+
+  switch (transition) {
+    case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
+      break;
+    case GST_STATE_CHANGE_PAUSED_TO_READY:
+      gst_mpeg2dec_qos_reset (mpeg2dec);
+      clear_queued (mpeg2dec);
+      if (mpeg2dec->pool) {
+        gst_buffer_pool_set_active (mpeg2dec->pool, FALSE);
+        gst_object_unref (mpeg2dec->pool);
+        mpeg2dec->pool = NULL;
+      }
+      break;
+    case GST_STATE_CHANGE_READY_TO_NULL:
+      if (mpeg2dec->decoder) {
+        mpeg2_close (mpeg2dec->decoder);
+        mpeg2dec->decoder = NULL;
+        mpeg2dec->info = NULL;
+      }
+      clear_buffers (mpeg2dec);
+      break;
+    default:
+      break;
+  }
+  return ret;
+
+  /* ERRORS */
+init_failed:
+  {
+    GST_ELEMENT_ERROR (mpeg2dec, LIBRARY, INIT,
+        (NULL), ("Failed to initialize libmpeg2 library"));
+    return GST_STATE_CHANGE_FAILURE;
+  }
+}
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  if (!gst_element_register (plugin, "mpeg2dec", GST_RANK_PRIMARY,
+          GST_TYPE_MPEG2DEC))
+    return FALSE;
+
+  return TRUE;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    mpeg2dec,
+    "LibMpeg2 decoder", plugin_init, VERSION, "GPL", GST_PACKAGE_NAME,
+    GST_PACKAGE_ORIGIN);
diff --git a/ext/mpeg2dec/gstmpeg2dec.h b/ext/mpeg2dec/gstmpeg2dec.h
new file mode 100644
index 0000000..eaf6fa4
--- /dev/null
+++ b/ext/mpeg2dec/gstmpeg2dec.h
@@ -0,0 +1,127 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#ifndef __GST_MPEG2DEC_H__
+#define __GST_MPEG2DEC_H__
+
+
+#include <gst/gst.h>
+#include <gst/video/video.h>
+#include <gst/video/gstvideopool.h>
+#include <gst/video/gstvideometa.h>
+#include <mpeg2.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_MPEG2DEC \
+  (gst_mpeg2dec_get_type())
+#define GST_MPEG2DEC(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MPEG2DEC,GstMpeg2dec))
+#define GST_MPEG2DEC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MPEG2DEC,GstMpeg2decClass))
+#define GST_IS_MPEG2DEC(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MPEG2DEC))
+#define GST_IS_MPEG2DEC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MPEG2DEC))
+
+#define MPEG_TIME_TO_GST_TIME(time) ((time) == -1 ? -1 : ((time) * (GST_MSECOND/10)) / G_GINT64_CONSTANT(9))
+#define GST_TIME_TO_MPEG_TIME(time) ((time) == -1 ? -1 : ((time) * G_GINT64_CONSTANT(9)) / (GST_MSECOND/10))
+
+typedef struct _GstMpeg2dec GstMpeg2dec;
+typedef struct _GstMpeg2decClass GstMpeg2decClass;
+
+typedef enum
+{
+  MPEG2DEC_DISC_NONE            = 0,
+  MPEG2DEC_DISC_NEW_PICTURE,
+  MPEG2DEC_DISC_NEW_KEYFRAME
+} DiscontState;
+
+struct _GstMpeg2dec {
+  GstElement     element;
+
+  /* pads */
+  GstPad        *sinkpad,
+                *srcpad,
+                *userdatapad;
+
+  mpeg2dec_t    *decoder;
+  const mpeg2_info_t *info;
+
+  gboolean       closed;
+  gboolean       have_fbuf;
+
+  /* buffer management */
+  guint          ip_framepos;
+  GstVideoFrame  ip_frame[4];
+  GstVideoFrame  b_frame;
+
+  DiscontState   discont_state;
+
+  /* the timestamp of the next frame */
+  GstClockTime   next_time;
+  GstSegment     segment;
+
+  /* whether we have a pixel aspect ratio from the sink caps */
+  gboolean       have_par;
+  gint           in_par_n;
+  gint           in_par_d;
+
+  /* video state */
+  GstVideoInfo   vinfo;
+  GstVideoInfo   cinfo;
+  gboolean       need_cropping;
+  gboolean       has_cropping;
+  gint64         frame_period;
+  gboolean       interlaced;
+  GstBufferPool *pool;
+
+  gint           size;
+  gint           u_offs;
+  gint           v_offs;
+  guint8        *dummybuf[4];
+
+  guint64        offset;
+  gboolean       need_sequence;
+
+  gint           error_count;
+  gboolean       can_allocate_aligned;
+
+  /* QoS stuff */ /* with LOCK*/
+  gdouble        proportion;
+  GstClockTime   earliest_time;
+  guint64        processed;
+  guint64        dropped;
+
+  /* gather/decode queues for reverse playback */
+  GList *gather;
+  GList *decode;
+  GList *queued;
+};
+
+struct _GstMpeg2decClass {
+  GstElementClass parent_class;
+};
+
+GType gst_mpeg2dec_get_type(void);
+
+G_END_DECLS
+
+#endif /* __GST_MPEG2DEC_H__ */
diff --git a/ext/sidplay/Makefile.am b/ext/sidplay/Makefile.am
new file mode 100644
index 0000000..47e51ee
--- /dev/null
+++ b/ext/sidplay/Makefile.am
@@ -0,0 +1,11 @@
+plugin_LTLIBRARIES = libgstsid.la
+
+libgstsid_la_SOURCES = gstsiddec.cc
+libgstsid_la_CXXFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) \
+	$(GST_CXXFLAGS) $(SIDPLAY_CFLAGS)
+libgstsid_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) $(SIDPLAY_LIBS) \
+		      -lgstaudio-$(GST_API_VERSION)
+libgstsid_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstsid_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS = gstsiddec.h
diff --git a/ext/sidplay/Makefile.in b/ext/sidplay/Makefile.in
new file mode 100644
index 0000000..86e6ae7
--- /dev/null
+++ b/ext/sidplay/Makefile.in
@@ -0,0 +1,751 @@
+# Makefile.in generated by automake 1.11.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = ext/sidplay
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \
+	$(top_srcdir)/common/m4/as-auto-alt.m4 \
+	$(top_srcdir)/common/m4/as-compiler-flag.m4 \
+	$(top_srcdir)/common/m4/as-python.m4 \
+	$(top_srcdir)/common/m4/as-scrub-include.m4 \
+	$(top_srcdir)/common/m4/as-version.m4 \
+	$(top_srcdir)/common/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/common/m4/gst-arch.m4 \
+	$(top_srcdir)/common/m4/gst-args.m4 \
+	$(top_srcdir)/common/m4/gst-check.m4 \
+	$(top_srcdir)/common/m4/gst-default.m4 \
+	$(top_srcdir)/common/m4/gst-dowhile.m4 \
+	$(top_srcdir)/common/m4/gst-error.m4 \
+	$(top_srcdir)/common/m4/gst-feature.m4 \
+	$(top_srcdir)/common/m4/gst-function.m4 \
+	$(top_srcdir)/common/m4/gst-gettext.m4 \
+	$(top_srcdir)/common/m4/gst-glib2.m4 \
+	$(top_srcdir)/common/m4/gst-package-release-datetime.m4 \
+	$(top_srcdir)/common/m4/gst-plugin-docs.m4 \
+	$(top_srcdir)/common/m4/gst-plugindir.m4 \
+	$(top_srcdir)/common/m4/gst.m4 \
+	$(top_srcdir)/common/m4/gtk-doc.m4 \
+	$(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \
+	$(top_srcdir)/m4/a52.m4 $(top_srcdir)/m4/gettext.m4 \
+	$(top_srcdir)/m4/gst-sid.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+	$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(plugindir)"
+LTLIBRARIES = $(plugin_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libgstsid_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1)
+am_libgstsid_la_OBJECTS = libgstsid_la-gstsiddec.lo
+libgstsid_la_OBJECTS = $(am_libgstsid_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+libgstsid_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(libgstsid_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+	$(CXXLD) $(libgstsid_la_CXXFLAGS) $(CXXFLAGS) \
+	$(libgstsid_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_@AM_V@)
+am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
+am__v_CXX_0 = @echo "  CXX   " $@;
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libgstsid_la_SOURCES)
+DIST_SOURCES = $(libgstsid_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+A52DEC_CFLAGS = @A52DEC_CFLAGS@
+A52DEC_LIBS = @A52DEC_LIBS@
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMRNB_CFLAGS = @AMRNB_CFLAGS@
+AMRNB_LIBS = @AMRNB_LIBS@
+AMRWB_CFLAGS = @AMRWB_CFLAGS@
+AMRWB_LIBS = @AMRWB_LIBS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CDIO_CFLAGS = @CDIO_CFLAGS@
+CDIO_LIBS = @CDIO_LIBS@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@
+DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@
+DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@
+DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@
+DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DVDREAD_LIBS = @DVDREAD_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+ERROR_CXXFLAGS = @ERROR_CXXFLAGS@
+EXEEXT = @EXEEXT@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+GCOV = @GCOV@
+GCOV_CFLAGS = @GCOV_CFLAGS@
+GCOV_LIBS = @GCOV_LIBS@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LDFLAGS = @GIO_LDFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_PREFIX = @GLIB_PREFIX@
+GLIB_REQ = @GLIB_REQ@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@
+GSTPB_PREFIX = @GSTPB_PREFIX@
+GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@
+GST_API_VERSION = @GST_API_VERSION@
+GST_BASE_CFLAGS = @GST_BASE_CFLAGS@
+GST_BASE_LIBS = @GST_BASE_LIBS@
+GST_CFLAGS = @GST_CFLAGS@
+GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@
+GST_CHECK_LIBS = @GST_CHECK_LIBS@
+GST_CXXFLAGS = @GST_CXXFLAGS@
+GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@
+GST_LIBS = @GST_LIBS@
+GST_LICENSE = @GST_LICENSE@
+GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@
+GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@
+GST_PACKAGE_NAME = @GST_PACKAGE_NAME@
+GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@
+GST_PLUGINS_ALL = @GST_PLUGINS_ALL@
+GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@
+GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@
+GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@
+GST_PLUGINS_DIR = @GST_PLUGINS_DIR@
+GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@
+GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GST_PREFIX = @GST_PREFIX@
+GST_TOOLS_DIR = @GST_TOOLS_DIR@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DVDREAD = @HAVE_DVDREAD@
+HAVE_LAME = @HAVE_LAME@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LAME_CFLAGS = @LAME_CFLAGS@
+LAME_LIBS = @LAME_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAD_CFLAGS = @MAD_CFLAGS@
+MAD_LIBS = @MAD_LIBS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MPEG2DEC_CFLAGS = @MPEG2DEC_CFLAGS@
+MPEG2DEC_LIBS = @MPEG2DEC_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ORCC = @ORCC@
+ORCC_FLAGS = @ORCC_FLAGS@
+ORC_CFLAGS = @ORC_CFLAGS@
+ORC_LIBS = @ORC_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@
+PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGINDIR = @PLUGINDIR@
+POSUB = @POSUB@
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIDPLAY_CFLAGS = @SIDPLAY_CFLAGS@
+SIDPLAY_LIBS = @SIDPLAY_LIBS@
+STRIP = @STRIP@
+TWOLAME_CFLAGS = @TWOLAME_CFLAGS@
+TWOLAME_LIBS = @TWOLAME_LIBS@
+USE_NLS = @USE_NLS@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VALGRIND_PATH = @VALGRIND_PATH@
+VERSION = @VERSION@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WIN32_LIBS = @WIN32_LIBS@
+X264_CFLAGS = @X264_CFLAGS@
+X264_LIBS = @X264_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+plugindir = @plugindir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+plugin_LTLIBRARIES = libgstsid.la
+libgstsid_la_SOURCES = gstsiddec.cc
+libgstsid_la_CXXFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) \
+	$(GST_CXXFLAGS) $(SIDPLAY_CFLAGS)
+
+libgstsid_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) $(SIDPLAY_LIBS) \
+		      -lgstaudio-$(GST_API_VERSION)
+
+libgstsid_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstsid_la_LIBTOOLFLAGS = --tag=disable-static
+noinst_HEADERS = gstsiddec.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cc .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/sidplay/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu ext/sidplay/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \
+	  $(MKDIR_P) '$(DESTDIR)$(plugindir)' || exit 1; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+	}
+
+uninstall-pluginLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+	done
+
+clean-pluginLTLIBRARIES:
+	-test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+	@list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libgstsid.la: $(libgstsid_la_OBJECTS) $(libgstsid_la_DEPENDENCIES) $(EXTRA_libgstsid_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libgstsid_la_LINK) -rpath $(plugindir) $(libgstsid_la_OBJECTS) $(libgstsid_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstsid_la-gstsiddec.Plo@am__quote@
+
+.cc.o:
+@am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+@am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+@am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
+
+libgstsid_la-gstsiddec.lo: gstsiddec.cc
+@am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(libgstsid_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstsid_la_CXXFLAGS) $(CXXFLAGS) -MT libgstsid_la-gstsiddec.lo -MD -MP -MF $(DEPDIR)/libgstsid_la-gstsiddec.Tpo -c -o libgstsid_la-gstsiddec.lo `test -f 'gstsiddec.cc' || echo '$(srcdir)/'`gstsiddec.cc
+@am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgstsid_la-gstsiddec.Tpo $(DEPDIR)/libgstsid_la-gstsiddec.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='gstsiddec.cc' object='libgstsid_la-gstsiddec.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(libgstsid_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstsid_la_CXXFLAGS) $(CXXFLAGS) -c -o libgstsid_la-gstsiddec.lo `test -f 'gstsiddec.cc' || echo '$(srcdir)/'`gstsiddec.cc
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(plugindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pluginLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pluginLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pluginLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/ext/sidplay/gstsiddec.cc b/ext/sidplay/gstsiddec.cc
new file mode 100644
index 0000000..3c47565
--- /dev/null
+++ b/ext/sidplay/gstsiddec.cc
@@ -0,0 +1,746 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *           (C) <2006> Wim Taymans <wim@fluendo.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * SECTION:element-siddec
+ *
+ * This element decodes .sid files to raw audio. .sid files are in fact 
+ * small Commodore 64 programs that are executed on an emulated 6502 CPU and a 
+ * MOS 6581 sound chip.
+ * 
+ * This plugin will first load the complete program into memory before starting
+ * the emulator and producing output.
+ * 
+ * Seeking is not (and cannot be) implemented.
+ * 
+ * <refsect2>
+ * <title>Example pipelines</title>
+ * |[
+ * gst-launch -v filesrc location=Hawkeye.sid ! siddec ! audioconvert ! alsasink
+ * ]| Decode a sid file and play back the audio using alsasink.
+ * </refsect2>
+ *
+ * Last reviewed on 2006-12-30 (0.10.5)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <gst/audio/audio.h>
+#include "gstsiddec.h"
+
+#define DEFAULT_TUNE		0
+#define DEFAULT_CLOCK		SIDTUNE_CLOCK_PAL
+#define DEFAULT_MEMORY		MPU_BANK_SWITCHING
+#define DEFAULT_FILTER		TRUE
+#define DEFAULT_MEASURED_VOLUME	TRUE
+#define DEFAULT_MOS8580		FALSE
+#define DEFAULT_FORCE_SPEED	FALSE
+#define DEFAULT_BLOCKSIZE	4096
+
+enum
+{
+  PROP_0,
+  PROP_TUNE,
+  PROP_CLOCK,
+  PROP_MEMORY,
+  PROP_FILTER,
+  PROP_MEASURED_VOLUME,
+  PROP_MOS8580,
+  PROP_FORCE_SPEED,
+  PROP_BLOCKSIZE,
+  PROP_METADATA
+};
+
+static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-sid")
+    );
+
+#define FORMATS "{ "GST_AUDIO_NE(S16)","GST_AUDIO_NE(U16)", S8, U8 }"
+
+static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) " FORMATS ", "
+        "layout = (string) interleaved, "
+        "rate = (int) [ 8000, 48000 ], " "channels = (int) [ 1, 2 ]")
+    );
+
+GST_DEBUG_CATEGORY_STATIC (gst_siddec_debug);
+#define GST_CAT_DEFAULT gst_siddec_debug
+
+#define GST_TYPE_SID_CLOCK (gst_sid_clock_get_type())
+static GType
+gst_sid_clock_get_type (void)
+{
+  static GType sid_clock_type = 0;
+  static const GEnumValue sid_clock[] = {
+    {SIDTUNE_CLOCK_PAL, "PAL", "pal"},
+    {SIDTUNE_CLOCK_NTSC, "NTSC", "ntsc"},
+    {0, NULL, NULL},
+  };
+
+  if (!sid_clock_type) {
+    sid_clock_type = g_enum_register_static ("GstSidClock", sid_clock);
+  }
+  return sid_clock_type;
+}
+
+#define GST_TYPE_SID_MEMORY (gst_sid_memory_get_type())
+static GType
+gst_sid_memory_get_type (void)
+{
+  static GType sid_memory_type = 0;
+  static const GEnumValue sid_memory[] = {
+    {MPU_BANK_SWITCHING, "Bank Switching", "bank-switching"},
+    {MPU_TRANSPARENT_ROM, "Transparent ROM", "transparent-rom"},
+    {MPU_PLAYSID_ENVIRONMENT, "Playsid Environment", "playsid-environment"},
+    {0, NULL, NULL},
+  };
+
+  if (!sid_memory_type) {
+    sid_memory_type = g_enum_register_static ("GstSidMemory", sid_memory);
+  }
+  return sid_memory_type;
+}
+
+static void gst_siddec_finalize (GObject * object);
+
+static GstFlowReturn gst_siddec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer);
+static gboolean gst_siddec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event);
+
+static gboolean gst_siddec_src_convert (GstPad * pad, GstFormat src_format,
+    gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static gboolean gst_siddec_src_event (GstPad * pad, GstObject * parent, GstEvent * event);
+static gboolean gst_siddec_src_query (GstPad * pad, GstObject * parent, GstQuery * query);
+
+static void gst_siddec_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec);
+static void gst_siddec_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec);
+
+#define gst_siddec_parent_class parent_class
+G_DEFINE_TYPE (GstSidDec, gst_siddec, GST_TYPE_ELEMENT);
+
+static void
+gst_siddec_class_init (GstSidDecClass * klass)
+{
+  GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
+
+  gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
+
+  gobject_class->finalize = gst_siddec_finalize;
+  gobject_class->set_property = gst_siddec_set_property;
+  gobject_class->get_property = gst_siddec_get_property;
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TUNE,
+      g_param_spec_int ("tune", "tune", "tune",
+          0, 100, DEFAULT_TUNE,
+          (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_CLOCK,
+      g_param_spec_enum ("clock", "clock", "clock",
+          GST_TYPE_SID_CLOCK, DEFAULT_CLOCK,
+          (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MEMORY,
+      g_param_spec_enum ("memory", "memory", "memory", GST_TYPE_SID_MEMORY,
+          DEFAULT_MEMORY,
+          (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FILTER,
+      g_param_spec_boolean ("filter", "filter", "filter", DEFAULT_FILTER,
+          (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MEASURED_VOLUME,
+      g_param_spec_boolean ("measured-volume", "measured_volume",
+          "measured_volume", DEFAULT_MEASURED_VOLUME,
+          (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MOS8580,
+      g_param_spec_boolean ("mos8580", "mos8580", "mos8580", DEFAULT_MOS8580,
+          (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FORCE_SPEED,
+      g_param_spec_boolean ("force-speed", "force_speed", "force_speed",
+          DEFAULT_FORCE_SPEED,
+          (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BLOCKSIZE,
+      g_param_spec_uint ("blocksize", "Block size",
+          "Size in bytes to output per buffer", 1, G_MAXUINT,
+          DEFAULT_BLOCKSIZE,
+          (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+  g_object_class_install_property (gobject_class, PROP_METADATA,
+      g_param_spec_boxed ("metadata", "Metadata", "Metadata", GST_TYPE_CAPS,
+          (GParamFlags)(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
+
+  gst_element_class_set_static_metadata (gstelement_class, "Sid decoder",
+      "Codec/Decoder/Audio", "Use libsidplay to decode SID audio tunes",
+      "Wim Taymans <wim.taymans@gmail.com>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_templ));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_templ));
+}
+
+static void
+gst_siddec_init (GstSidDec * siddec)
+{
+  siddec->sinkpad = gst_pad_new_from_static_template (&sink_templ, "sink");
+  gst_pad_set_event_function (siddec->sinkpad, gst_siddec_sink_event);
+  gst_pad_set_chain_function (siddec->sinkpad, gst_siddec_chain);
+  gst_element_add_pad (GST_ELEMENT (siddec), siddec->sinkpad);
+
+  siddec->srcpad = gst_pad_new_from_static_template (&src_templ, "src");
+  gst_pad_set_event_function (siddec->srcpad, gst_siddec_src_event);
+  gst_pad_set_query_function (siddec->srcpad, gst_siddec_src_query);
+  gst_pad_use_fixed_caps (siddec->srcpad);
+  gst_element_add_pad (GST_ELEMENT (siddec), siddec->srcpad);
+
+  siddec->engine = new emuEngine ();
+  siddec->tune = new sidTune (0);
+  siddec->config = (emuConfig *) g_malloc (sizeof (emuConfig));
+
+  /* get default config parameters */
+  siddec->engine->getConfig (*siddec->config);
+
+  siddec->config->mos8580 = DEFAULT_MOS8580;    // mos8580
+  siddec->config->memoryMode = DEFAULT_MEMORY;  // memory mode
+  siddec->config->clockSpeed = DEFAULT_CLOCK;   // clock speed
+  siddec->config->forceSongSpeed = DEFAULT_FORCE_SPEED; // force song speed
+
+  siddec->engine->setConfig (*siddec->config);
+
+  siddec->tune_buffer = (guchar *) g_malloc (maxSidtuneFileLen);
+  siddec->tune_len = 0;
+  siddec->tune_number = 0;
+  siddec->total_bytes = 0;
+  siddec->blocksize = DEFAULT_BLOCKSIZE;
+}
+
+static void
+gst_siddec_finalize (GObject * object)
+{
+  GstSidDec *siddec = GST_SIDDEC (object);
+
+  g_free (siddec->config);
+  g_free (siddec->tune_buffer);
+
+  delete (siddec->tune);
+  delete (siddec->engine);
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+update_tags (GstSidDec * siddec)
+{
+  sidTuneInfo info;
+  GstTagList *list;
+
+  if (siddec->tune->getInfo (info)) {
+    list = gst_tag_list_new_empty ();
+
+    if (info.nameString) {
+      gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
+          GST_TAG_TITLE, info.nameString, (void *) NULL);
+    }
+    if (info.authorString) {
+      gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
+          GST_TAG_ARTIST, info.authorString, (void *) NULL);
+    }
+    if (info.copyrightString) {
+      gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
+          GST_TAG_COPYRIGHT, info.copyrightString, (void *) NULL);
+    }
+    gst_pad_push_event (siddec->srcpad, gst_event_new_tag (list));
+  }
+}
+
+static gboolean
+siddec_negotiate (GstSidDec * siddec)
+{
+  GstCaps *allowed;
+  GstStructure *structure;
+  int rate = 44100;
+  int channels = 1;
+  GstCaps *caps;
+  const gchar *str;
+  GstAudioFormat format;
+
+  allowed = gst_pad_get_allowed_caps (siddec->srcpad);
+  if (!allowed)
+    goto nothing_allowed;
+
+  GST_DEBUG_OBJECT (siddec, "allowed caps: %" GST_PTR_FORMAT, allowed);
+
+  allowed = gst_caps_normalize (allowed);
+
+  structure = gst_caps_get_structure (allowed, 0);
+
+  str = gst_structure_get_string (structure, "format");
+  if (str == NULL)
+    goto invalid_format;
+
+  format = gst_audio_format_from_string (str);
+  switch (format) {
+    case GST_AUDIO_FORMAT_S8:
+      siddec->config->bitsPerSample = 8;
+      siddec->config->sampleFormat = SIDEMU_SIGNED_PCM;
+      break;
+    case GST_AUDIO_FORMAT_U8:
+      siddec->config->bitsPerSample = 8;
+      siddec->config->sampleFormat = SIDEMU_UNSIGNED_PCM;
+      break;
+    case GST_AUDIO_FORMAT_S16:
+      siddec->config->bitsPerSample = 16;
+      siddec->config->sampleFormat = SIDEMU_SIGNED_PCM;
+      break;
+    case GST_AUDIO_FORMAT_U16:
+      siddec->config->bitsPerSample = 16;
+      siddec->config->sampleFormat = SIDEMU_UNSIGNED_PCM;
+      break;
+    default:
+      goto invalid_format;
+  }
+
+  gst_structure_get_int (structure, "rate", &rate);
+  siddec->config->frequency = rate;
+  gst_structure_get_int (structure, "channels", &channels);
+  siddec->config->channels = channels;
+
+  caps = gst_caps_new_simple ("audio/x-raw",
+      "format", G_TYPE_STRING, gst_audio_format_to_string (format),
+      "layout", G_TYPE_STRING, "interleaved",
+      "rate", G_TYPE_INT, siddec->config->frequency,
+      "channels", G_TYPE_INT, siddec->config->channels, NULL);
+  gst_pad_set_caps (siddec->srcpad, caps);
+  gst_caps_unref (caps);
+
+  gst_caps_unref (allowed);
+
+  siddec->engine->setConfig (*siddec->config);
+
+  return TRUE;
+
+  /* ERRORS */
+nothing_allowed:
+  {
+    GST_DEBUG_OBJECT (siddec, "could not get allowed caps");
+    return FALSE;
+  }
+invalid_format:
+  {
+    GST_DEBUG_OBJECT (siddec, "invalid audio caps");
+    gst_caps_unref (allowed);
+    return FALSE;
+  }
+}
+
+static void
+play_loop (GstPad * pad)
+{
+  GstFlowReturn ret;
+  GstSidDec *siddec;
+  GstBuffer *out;
+  GstMapInfo outmap;
+  gint64 value, offset, time;
+  GstFormat format;
+
+  siddec = GST_SIDDEC (gst_pad_get_parent (pad));
+
+  out = gst_buffer_new_and_alloc (siddec->blocksize);
+
+  gst_buffer_map (out, &outmap, GST_MAP_WRITE);
+  sidEmuFillBuffer (*siddec->engine, *siddec->tune,
+      outmap.data, siddec->blocksize);
+  gst_buffer_unmap (out, &outmap);
+
+  /* get offset in samples */
+  format = GST_FORMAT_DEFAULT;
+  gst_siddec_src_convert (siddec->srcpad,
+      GST_FORMAT_BYTES, siddec->total_bytes, &format, &offset);
+  GST_BUFFER_OFFSET (out) = offset;
+
+  /* get current timestamp */
+  format = GST_FORMAT_TIME;
+  gst_siddec_src_convert (siddec->srcpad,
+      GST_FORMAT_BYTES, siddec->total_bytes, &format, &time);
+  GST_BUFFER_TIMESTAMP (out) = time;
+
+  /* update position and get new timestamp to calculate duration */
+  siddec->total_bytes += siddec->blocksize;
+
+  /* get offset in samples */
+  format = GST_FORMAT_DEFAULT;
+  gst_siddec_src_convert (siddec->srcpad,
+      GST_FORMAT_BYTES, siddec->total_bytes, &format, &value);
+  GST_BUFFER_OFFSET_END (out) = value;
+
+  format = GST_FORMAT_TIME;
+  gst_siddec_src_convert (siddec->srcpad,
+      GST_FORMAT_BYTES, siddec->total_bytes, &format, &value);
+  GST_BUFFER_DURATION (out) = value - time;
+
+  if ((ret = gst_pad_push (siddec->srcpad, out)) != GST_FLOW_OK)
+    goto pause;
+
+done:
+  gst_object_unref (siddec);
+
+  return;
+
+  /* ERRORS */
+pause:
+  {
+    const gchar *reason = gst_flow_get_name (ret);
+
+    if (ret == GST_FLOW_EOS) {
+      /* perform EOS logic, FIXME, segment seek? */
+      gst_pad_push_event (pad, gst_event_new_eos ());
+    } else  if (ret < GST_FLOW_EOS || ret == GST_FLOW_NOT_LINKED) {
+      /* for fatal errors we post an error message */
+      GST_ELEMENT_ERROR (siddec, STREAM, FAILED,
+          (NULL), ("streaming task paused, reason %s", reason));
+      gst_pad_push_event (pad, gst_event_new_eos ());
+    }
+
+    GST_INFO_OBJECT (siddec, "pausing task, reason: %s", reason);
+    gst_pad_pause_task (pad);
+    goto done;
+  }
+}
+
+static gboolean
+start_play_tune (GstSidDec * siddec)
+{
+  gboolean res;
+  GstSegment segment;
+
+  if (!siddec->tune->load (siddec->tune_buffer, siddec->tune_len))
+    goto could_not_load;
+
+  update_tags (siddec);
+
+  if (!siddec_negotiate (siddec))
+    goto could_not_negotiate;
+
+  if (!sidEmuInitializeSong (*siddec->engine, *siddec->tune,
+          siddec->tune_number))
+    goto could_not_init;
+
+  gst_segment_init (&segment, GST_FORMAT_TIME);
+  gst_pad_push_event (siddec->srcpad,
+      gst_event_new_segment (&segment));
+
+  res = gst_pad_start_task (siddec->srcpad,
+      (GstTaskFunction) play_loop, siddec->srcpad);
+  return res;
+
+  /* ERRORS */
+could_not_load:
+  {
+    GST_ELEMENT_ERROR (siddec, LIBRARY, INIT,
+        ("Could not load tune"), ("Could not load tune"));
+    return FALSE;
+  }
+could_not_negotiate:
+  {
+    GST_ELEMENT_ERROR (siddec, CORE, NEGOTIATION,
+        ("Could not negotiate format"), ("Could not negotiate format"));
+    return FALSE;
+  }
+could_not_init:
+  {
+    GST_ELEMENT_ERROR (siddec, LIBRARY, INIT,
+        ("Could not initialize song"), ("Could not initialize song"));
+    return FALSE;
+  }
+}
+
+static gboolean
+gst_siddec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
+{
+  GstSidDec *siddec;
+  gboolean res;
+
+  siddec = GST_SIDDEC (parent);
+
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_EOS:
+      res = start_play_tune (siddec);
+      break;
+    case GST_EVENT_SEGMENT:
+      res = TRUE;
+      break;
+    default:
+      res = TRUE;
+      break;
+  }
+  gst_event_unref (event);
+
+  return res;
+}
+
+static GstFlowReturn
+gst_siddec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
+{
+  GstSidDec *siddec;
+  guint64 size;
+
+  siddec = GST_SIDDEC (parent);
+
+  size = gst_buffer_get_size (buffer);
+  if (siddec->tune_len + size > maxSidtuneFileLen)
+    goto overflow;
+
+  gst_buffer_extract (buffer, 0, siddec->tune_buffer + siddec->tune_len, size);
+
+  siddec->tune_len += size;
+
+  gst_buffer_unref (buffer);
+
+  return GST_FLOW_OK;
+
+  /* ERRORS */
+overflow:
+  {
+    GST_ELEMENT_ERROR (siddec, STREAM, DECODE,
+        (NULL), ("Input data bigger than allowed buffer size"));
+    return GST_FLOW_ERROR;
+  }
+}
+
+static gboolean
+gst_siddec_src_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
+    GstFormat * dest_format, gint64 * dest_value)
+{
+  gboolean res = TRUE;
+  guint scale = 1;
+  GstSidDec *siddec;
+  gint bytes_per_sample;
+
+  siddec = GST_SIDDEC (gst_pad_get_parent (pad));
+
+  if (src_format == *dest_format) {
+    *dest_value = src_value;
+    return TRUE;
+  }
+
+  bytes_per_sample =
+      (siddec->config->bitsPerSample >> 3) * siddec->config->channels;
+
+  switch (src_format) {
+    case GST_FORMAT_BYTES:
+      switch (*dest_format) {
+        case GST_FORMAT_DEFAULT:
+          if (bytes_per_sample == 0)
+            return FALSE;
+          *dest_value = src_value / bytes_per_sample;
+          break;
+        case GST_FORMAT_TIME:
+        {
+          gint byterate = bytes_per_sample * siddec->config->frequency;
+
+          if (byterate == 0)
+            return FALSE;
+          *dest_value =
+              gst_util_uint64_scale_int (src_value, GST_SECOND, byterate);
+          break;
+        }
+        default:
+          res = FALSE;
+      }
+      break;
+    case GST_FORMAT_DEFAULT:
+      switch (*dest_format) {
+        case GST_FORMAT_BYTES:
+          *dest_value = src_value * bytes_per_sample;
+          break;
+        case GST_FORMAT_TIME:
+          if (siddec->config->frequency == 0)
+            return FALSE;
+          *dest_value =
+              gst_util_uint64_scale_int (src_value, GST_SECOND,
+              siddec->config->frequency);
+          break;
+        default:
+          res = FALSE;
+      }
+      break;
+    case GST_FORMAT_TIME:
+      switch (*dest_format) {
+        case GST_FORMAT_BYTES:
+          scale = bytes_per_sample;
+          /* fallthrough */
+        case GST_FORMAT_DEFAULT:
+          *dest_value =
+              gst_util_uint64_scale_int (src_value,
+              scale * siddec->config->frequency, GST_SECOND);
+          break;
+        default:
+          res = FALSE;
+      }
+      break;
+    default:
+      res = FALSE;
+  }
+
+  return res;
+}
+
+static gboolean
+gst_siddec_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
+{
+  gboolean res = FALSE;
+
+  switch (GST_EVENT_TYPE (event)) {
+    default:
+      break;
+  }
+  gst_event_unref (event);
+
+  return res;
+}
+
+static gboolean
+gst_siddec_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
+{
+  gboolean res = TRUE;
+  GstSidDec *siddec;
+
+  siddec = GST_SIDDEC (parent);
+
+  switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_POSITION:
+    {
+      GstFormat format;
+      gint64 current;
+
+      gst_query_parse_position (query, &format, NULL);
+
+      /* we only know about our bytes, convert to requested format */
+      res &= gst_siddec_src_convert (pad,
+          GST_FORMAT_BYTES, siddec->total_bytes, &format, &current);
+      if (res) {
+        gst_query_set_position (query, format, current);
+      }
+      break;
+    }
+    default:
+      res = gst_pad_query_default (pad, parent, query);
+      break;
+  }
+
+  return res;
+}
+
+static void
+gst_siddec_set_property (GObject * object, guint prop_id, const GValue * value,
+    GParamSpec * pspec)
+{
+  GstSidDec *siddec = GST_SIDDEC (object);
+
+  switch (prop_id) {
+    case PROP_TUNE:
+      siddec->tune_number = g_value_get_int (value);
+      break;
+    case PROP_CLOCK:
+      siddec->config->clockSpeed = g_value_get_enum (value);
+      break;
+    case PROP_MEMORY:
+      siddec->config->memoryMode = g_value_get_enum (value);
+      break;
+    case PROP_FILTER:
+      siddec->config->emulateFilter = g_value_get_boolean (value);
+      break;
+    case PROP_MEASURED_VOLUME:
+      siddec->config->measuredVolume = g_value_get_boolean (value);
+      break;
+    case PROP_MOS8580:
+      siddec->config->mos8580 = g_value_get_boolean (value);
+      break;
+    case PROP_BLOCKSIZE:
+      siddec->blocksize = g_value_get_uint (value);
+      break;
+    case PROP_FORCE_SPEED:
+      siddec->config->forceSongSpeed = g_value_get_boolean (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      return;
+  }
+  siddec->engine->setConfig (*siddec->config);
+}
+
+static void
+gst_siddec_get_property (GObject * object, guint prop_id, GValue * value,
+    GParamSpec * pspec)
+{
+  GstSidDec *siddec = GST_SIDDEC (object);
+
+  switch (prop_id) {
+    case PROP_TUNE:
+      g_value_set_int (value, siddec->tune_number);
+      break;
+    case PROP_CLOCK:
+      g_value_set_enum (value, siddec->config->clockSpeed);
+      break;
+    case PROP_MEMORY:
+      g_value_set_enum (value, siddec->config->memoryMode);
+      break;
+    case PROP_FILTER:
+      g_value_set_boolean (value, siddec->config->emulateFilter);
+      break;
+    case PROP_MEASURED_VOLUME:
+      g_value_set_boolean (value, siddec->config->measuredVolume);
+      break;
+    case PROP_MOS8580:
+      g_value_set_boolean (value, siddec->config->mos8580);
+      break;
+    case PROP_FORCE_SPEED:
+      g_value_set_boolean (value, siddec->config->forceSongSpeed);
+      break;
+    case PROP_BLOCKSIZE:
+      g_value_set_uint (value, siddec->blocksize);
+      break;
+    case PROP_METADATA:
+      g_value_set_boxed (value, NULL);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  return gst_element_register (plugin, "siddec", GST_RANK_PRIMARY,
+      GST_TYPE_SIDDEC);
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    siddec,
+    "Uses libsidplay to decode .sid files",
+    plugin_init, VERSION, "GPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
diff --git a/ext/sidplay/gstsiddec.h b/ext/sidplay/gstsiddec.h
new file mode 100644
index 0000000..c405ae1
--- /dev/null
+++ b/ext/sidplay/gstsiddec.h
@@ -0,0 +1,72 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#ifndef __GST_SIDDEC_H__
+#define __GST_SIDDEC_H__
+
+#include <stdlib.h>
+#include <sidplay/player.h>
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_SIDDEC \
+  (gst_siddec_get_type())
+#define GST_SIDDEC(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SIDDEC,GstSidDec))
+#define GST_SIDDEC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SIDDEC,GstSidDecClass))
+#define GST_IS_SIDDEC(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SIDDEC))
+#define GST_IS_SIDDEC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SIDDEC))
+
+typedef struct _GstSidDec GstSidDec;
+typedef struct _GstSidDecClass GstSidDecClass;
+
+struct _GstSidDec {
+  GstElement     element;
+
+  /* pads */
+  GstPad        *sinkpad, 
+                *srcpad;
+
+  guchar        *tune_buffer;
+  gint           tune_len;
+  gint           tune_number;
+  guint64        total_bytes;
+
+  emuEngine     *engine;
+  sidTune       *tune;
+  emuConfig     *config;
+
+  guint         blocksize;
+};
+
+struct _GstSidDecClass {
+  GstElementClass parent_class;
+};
+
+GType gst_siddec_get_type (void);
+        
+G_END_DECLS
+
+#endif /* __GST_SIDDEC_H__ */
diff --git a/ext/twolame/Makefile.am b/ext/twolame/Makefile.am
new file mode 100644
index 0000000..785fd8f
--- /dev/null
+++ b/ext/twolame/Makefile.am
@@ -0,0 +1,12 @@
+plugin_LTLIBRARIES = libgsttwolame.la
+
+libgsttwolame_la_SOURCES = gsttwolamemp2enc.c
+libgsttwolame_la_CFLAGS = -DGST_USE_UNSTABLE_API \
+	$(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(TWOLAME_CFLAGS)
+libgsttwolame_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
+	-lgstaudio-@GST_API_VERSION@ -lgstpbutils-@GST_API_VERSION@ \
+	$(GST_LIBS) $(TWOLAME_LIBS)
+libgsttwolame_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgsttwolame_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS = gsttwolamemp2enc.h
diff --git a/ext/twolame/Makefile.in b/ext/twolame/Makefile.in
new file mode 100644
index 0000000..0f97560
--- /dev/null
+++ b/ext/twolame/Makefile.in
@@ -0,0 +1,751 @@
+# Makefile.in generated by automake 1.11.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = ext/twolame
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \
+	$(top_srcdir)/common/m4/as-auto-alt.m4 \
+	$(top_srcdir)/common/m4/as-compiler-flag.m4 \
+	$(top_srcdir)/common/m4/as-python.m4 \
+	$(top_srcdir)/common/m4/as-scrub-include.m4 \
+	$(top_srcdir)/common/m4/as-version.m4 \
+	$(top_srcdir)/common/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/common/m4/gst-arch.m4 \
+	$(top_srcdir)/common/m4/gst-args.m4 \
+	$(top_srcdir)/common/m4/gst-check.m4 \
+	$(top_srcdir)/common/m4/gst-default.m4 \
+	$(top_srcdir)/common/m4/gst-dowhile.m4 \
+	$(top_srcdir)/common/m4/gst-error.m4 \
+	$(top_srcdir)/common/m4/gst-feature.m4 \
+	$(top_srcdir)/common/m4/gst-function.m4 \
+	$(top_srcdir)/common/m4/gst-gettext.m4 \
+	$(top_srcdir)/common/m4/gst-glib2.m4 \
+	$(top_srcdir)/common/m4/gst-package-release-datetime.m4 \
+	$(top_srcdir)/common/m4/gst-plugin-docs.m4 \
+	$(top_srcdir)/common/m4/gst-plugindir.m4 \
+	$(top_srcdir)/common/m4/gst.m4 \
+	$(top_srcdir)/common/m4/gtk-doc.m4 \
+	$(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \
+	$(top_srcdir)/m4/a52.m4 $(top_srcdir)/m4/gettext.m4 \
+	$(top_srcdir)/m4/gst-sid.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+	$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(plugindir)"
+LTLIBRARIES = $(plugin_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libgsttwolame_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am_libgsttwolame_la_OBJECTS = libgsttwolame_la-gsttwolamemp2enc.lo
+libgsttwolame_la_OBJECTS = $(am_libgsttwolame_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+libgsttwolame_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+	$(libgsttwolame_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+	$(CCLD) $(libgsttwolame_la_CFLAGS) $(CFLAGS) \
+	$(libgsttwolame_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libgsttwolame_la_SOURCES)
+DIST_SOURCES = $(libgsttwolame_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+A52DEC_CFLAGS = @A52DEC_CFLAGS@
+A52DEC_LIBS = @A52DEC_LIBS@
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMRNB_CFLAGS = @AMRNB_CFLAGS@
+AMRNB_LIBS = @AMRNB_LIBS@
+AMRWB_CFLAGS = @AMRWB_CFLAGS@
+AMRWB_LIBS = @AMRWB_LIBS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CDIO_CFLAGS = @CDIO_CFLAGS@
+CDIO_LIBS = @CDIO_LIBS@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@
+DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@
+DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@
+DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@
+DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DVDREAD_LIBS = @DVDREAD_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+ERROR_CXXFLAGS = @ERROR_CXXFLAGS@
+EXEEXT = @EXEEXT@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+GCOV = @GCOV@
+GCOV_CFLAGS = @GCOV_CFLAGS@
+GCOV_LIBS = @GCOV_LIBS@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LDFLAGS = @GIO_LDFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_PREFIX = @GLIB_PREFIX@
+GLIB_REQ = @GLIB_REQ@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@
+GSTPB_PREFIX = @GSTPB_PREFIX@
+GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@
+GST_API_VERSION = @GST_API_VERSION@
+GST_BASE_CFLAGS = @GST_BASE_CFLAGS@
+GST_BASE_LIBS = @GST_BASE_LIBS@
+GST_CFLAGS = @GST_CFLAGS@
+GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@
+GST_CHECK_LIBS = @GST_CHECK_LIBS@
+GST_CXXFLAGS = @GST_CXXFLAGS@
+GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@
+GST_LIBS = @GST_LIBS@
+GST_LICENSE = @GST_LICENSE@
+GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@
+GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@
+GST_PACKAGE_NAME = @GST_PACKAGE_NAME@
+GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@
+GST_PLUGINS_ALL = @GST_PLUGINS_ALL@
+GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@
+GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@
+GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@
+GST_PLUGINS_DIR = @GST_PLUGINS_DIR@
+GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@
+GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GST_PREFIX = @GST_PREFIX@
+GST_TOOLS_DIR = @GST_TOOLS_DIR@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DVDREAD = @HAVE_DVDREAD@
+HAVE_LAME = @HAVE_LAME@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LAME_CFLAGS = @LAME_CFLAGS@
+LAME_LIBS = @LAME_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAD_CFLAGS = @MAD_CFLAGS@
+MAD_LIBS = @MAD_LIBS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MPEG2DEC_CFLAGS = @MPEG2DEC_CFLAGS@
+MPEG2DEC_LIBS = @MPEG2DEC_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ORCC = @ORCC@
+ORCC_FLAGS = @ORCC_FLAGS@
+ORC_CFLAGS = @ORC_CFLAGS@
+ORC_LIBS = @ORC_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@
+PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGINDIR = @PLUGINDIR@
+POSUB = @POSUB@
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIDPLAY_CFLAGS = @SIDPLAY_CFLAGS@
+SIDPLAY_LIBS = @SIDPLAY_LIBS@
+STRIP = @STRIP@
+TWOLAME_CFLAGS = @TWOLAME_CFLAGS@
+TWOLAME_LIBS = @TWOLAME_LIBS@
+USE_NLS = @USE_NLS@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VALGRIND_PATH = @VALGRIND_PATH@
+VERSION = @VERSION@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WIN32_LIBS = @WIN32_LIBS@
+X264_CFLAGS = @X264_CFLAGS@
+X264_LIBS = @X264_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+plugindir = @plugindir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+plugin_LTLIBRARIES = libgsttwolame.la
+libgsttwolame_la_SOURCES = gsttwolamemp2enc.c
+libgsttwolame_la_CFLAGS = -DGST_USE_UNSTABLE_API \
+	$(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(TWOLAME_CFLAGS)
+
+libgsttwolame_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
+	-lgstaudio-@GST_API_VERSION@ -lgstpbutils-@GST_API_VERSION@ \
+	$(GST_LIBS) $(TWOLAME_LIBS)
+
+libgsttwolame_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgsttwolame_la_LIBTOOLFLAGS = --tag=disable-static
+noinst_HEADERS = gsttwolamemp2enc.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/twolame/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu ext/twolame/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \
+	  $(MKDIR_P) '$(DESTDIR)$(plugindir)' || exit 1; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+	}
+
+uninstall-pluginLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+	done
+
+clean-pluginLTLIBRARIES:
+	-test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+	@list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libgsttwolame.la: $(libgsttwolame_la_OBJECTS) $(libgsttwolame_la_DEPENDENCIES) $(EXTRA_libgsttwolame_la_DEPENDENCIES) 
+	$(AM_V_CCLD)$(libgsttwolame_la_LINK) -rpath $(plugindir) $(libgsttwolame_la_OBJECTS) $(libgsttwolame_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgsttwolame_la-gsttwolamemp2enc.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+libgsttwolame_la-gsttwolamemp2enc.lo: gsttwolamemp2enc.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgsttwolame_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgsttwolame_la_CFLAGS) $(CFLAGS) -MT libgsttwolame_la-gsttwolamemp2enc.lo -MD -MP -MF $(DEPDIR)/libgsttwolame_la-gsttwolamemp2enc.Tpo -c -o libgsttwolame_la-gsttwolamemp2enc.lo `test -f 'gsttwolamemp2enc.c' || echo '$(srcdir)/'`gsttwolamemp2enc.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgsttwolame_la-gsttwolamemp2enc.Tpo $(DEPDIR)/libgsttwolame_la-gsttwolamemp2enc.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gsttwolamemp2enc.c' object='libgsttwolame_la-gsttwolamemp2enc.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgsttwolame_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgsttwolame_la_CFLAGS) $(CFLAGS) -c -o libgsttwolame_la-gsttwolamemp2enc.lo `test -f 'gsttwolamemp2enc.c' || echo '$(srcdir)/'`gsttwolamemp2enc.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(plugindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pluginLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pluginLTLIBRARIES \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pluginLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/ext/twolame/gsttwolamemp2enc.c b/ext/twolame/gsttwolamemp2enc.c
new file mode 100644
index 0000000..0b8b4c2
--- /dev/null
+++ b/ext/twolame/gsttwolamemp2enc.c
@@ -0,0 +1,891 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) <2004> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
+ * Copyright (C) <2008> Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Based on the lame element.
+ */
+
+/**
+ * SECTION:element-twolame
+ * @see_also: mad, lame
+ *
+ * This element encodes raw integer audio into an MPEG-1 layer 2 (MP2) stream.
+ *
+ * <refsect2>
+ * <title>Example pipelines</title>
+ * |[
+ * gst-launch -v audiotestsrc wave=sine num-buffers=100 ! audioconvert ! twolame ! filesink location=sine.mp2
+ * ]| Encode a test sine signal to MP2.
+ * |[
+ * gst-launch -v alsasrc ! audioconvert ! twolame bitrate=192 ! filesink location=alsasrc.mp2
+ * ]| Record from a sound card using ALSA and encode to MP2
+ * |[
+ * gst-launch -v filesrc location=music.wav ! decodebin ! audioconvert ! audioresample ! twolame bitrate=192 ! id3v2mux ! filesink location=music.mp2
+ * ]| Transcode from a .wav file to MP2 (the id3v2mux element is optional)
+ * |[
+ * gst-launch -v cdda://5 ! audioconvert ! twolame bitrate=192 ! filesink location=track5.mp2
+ * ]| Encode Audio CD track 5 to MP2
+ * </refsect2>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "string.h"
+#include "gsttwolamemp2enc.h"
+#include "gst/gst-i18n-plugin.h"
+
+GST_DEBUG_CATEGORY_STATIC (debug);
+#define GST_CAT_DEFAULT debug
+
+/* TwoLAME can do MPEG-1, MPEG-2 so it has 6 possible
+ * sample rates it supports */
+static GstStaticPadTemplate gst_two_lame_sink_template =
+    GST_STATIC_PAD_TEMPLATE ("sink",
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) { " GST_AUDIO_NE (F32) ", " GST_AUDIO_NE (S16) " }, "
+        "layout = (string) interleaved, "
+        "rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, "
+        "channels = (int) 1; "
+        "audio/x-raw, "
+        "format = (string) { " GST_AUDIO_NE (F32) ", " GST_AUDIO_NE (S16) " }, "
+        "layout = (string) interleaved, "
+        "rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, "
+        "channels = (int) 2," "channel-mask = (bitmask) 0x3")
+    );
+
+static GstStaticPadTemplate gst_two_lame_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/mpeg, "
+        "mpegversion = (int) 1, "
+        "layer = (int) 2, "
+        "rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, "
+        "channels = (int) [ 1, 2 ]")
+    );
+
+static struct
+{
+  gint mode;
+  gint psymodel;
+  gint bitrate;
+  gint padding;
+  gboolean energy_level_extension;
+  gint emphasis;
+  gboolean error_protection;
+  gboolean copyright;
+  gboolean original;
+  gboolean vbr;
+  gfloat vbr_level;
+  gfloat ath_level;
+  gint vbr_max_bitrate;
+  gboolean quick_mode;
+  gint quick_mode_count;
+} gst_two_lame_default_settings;
+
+/********** Define useful types for non-programmatic interfaces **********/
+#define GST_TYPE_TWO_LAME_MODE (gst_two_lame_mode_get_type())
+static GType
+gst_two_lame_mode_get_type (void)
+{
+  static GType two_lame_mode_type = 0;
+  static GEnumValue two_lame_modes[] = {
+    {TWOLAME_AUTO_MODE, "Auto", "auto"},
+    {TWOLAME_STEREO, "Stereo", "stereo"},
+    {TWOLAME_JOINT_STEREO, "Joint Stereo", "joint"},
+    {TWOLAME_DUAL_CHANNEL, "Dual Channel", "dual"},
+    {TWOLAME_MONO, "Mono", "mono"},
+    {0, NULL, NULL}
+  };
+
+  if (!two_lame_mode_type) {
+    two_lame_mode_type =
+        g_enum_register_static ("GstTwoLameMode", two_lame_modes);
+  }
+  return two_lame_mode_type;
+}
+
+#define GST_TYPE_TWO_LAME_PADDING (gst_two_lame_padding_get_type())
+static GType
+gst_two_lame_padding_get_type (void)
+{
+  static GType two_lame_padding_type = 0;
+  static GEnumValue two_lame_padding[] = {
+    {TWOLAME_PAD_NO, "No Padding", "never"},
+    {TWOLAME_PAD_ALL, "Always Pad", "always"},
+    {0, NULL, NULL}
+  };
+
+  if (!two_lame_padding_type) {
+    two_lame_padding_type =
+        g_enum_register_static ("GstTwoLamePadding", two_lame_padding);
+  }
+  return two_lame_padding_type;
+}
+
+#define GST_TYPE_TWO_LAME_EMPHASIS (gst_two_lame_emphasis_get_type())
+static GType
+gst_two_lame_emphasis_get_type (void)
+{
+  static GType two_lame_emphasis_type = 0;
+  static GEnumValue two_lame_emphasis[] = {
+    {TWOLAME_EMPHASIS_N, "No emphasis", "none"},
+    {TWOLAME_EMPHASIS_5, "50/15 ms", "5"},
+    {TWOLAME_EMPHASIS_C, "CCIT J.17", "ccit"},
+    {0, NULL, NULL}
+  };
+
+  if (!two_lame_emphasis_type) {
+    two_lame_emphasis_type =
+        g_enum_register_static ("GstTwoLameEmphasis", two_lame_emphasis);
+  }
+
+  return two_lame_emphasis_type;
+}
+
+/********** Standard stuff for signals and arguments **********/
+
+enum
+{
+  ARG_0,
+  ARG_MODE,
+  ARG_PSYMODEL,
+  ARG_BITRATE,
+  ARG_PADDING,
+  ARG_ENERGY_LEVEL_EXTENSION,
+  ARG_EMPHASIS,
+  ARG_ERROR_PROTECTION,
+  ARG_COPYRIGHT,
+  ARG_ORIGINAL,
+  ARG_VBR,
+  ARG_VBR_LEVEL,
+  ARG_ATH_LEVEL,
+  ARG_VBR_MAX_BITRATE,
+  ARG_QUICK_MODE,
+  ARG_QUICK_MODE_COUNT
+};
+
+static gboolean gst_two_lame_start (GstAudioEncoder * enc);
+static gboolean gst_two_lame_stop (GstAudioEncoder * enc);
+static gboolean gst_two_lame_set_format (GstAudioEncoder * enc,
+    GstAudioInfo * info);
+static GstFlowReturn gst_two_lame_handle_frame (GstAudioEncoder * enc,
+    GstBuffer * in_buf);
+static void gst_two_lame_flush (GstAudioEncoder * enc);
+
+static void gst_two_lame_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec);
+static void gst_two_lame_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec);
+static gboolean gst_two_lame_setup (GstTwoLame * twolame);
+
+G_DEFINE_TYPE (GstTwoLame, gst_two_lame, GST_TYPE_AUDIO_ENCODER);
+
+static void
+gst_two_lame_release_memory (GstTwoLame * twolame)
+{
+  if (twolame->glopts) {
+    twolame_close (&twolame->glopts);
+    twolame->glopts = NULL;
+  }
+}
+
+static void
+gst_two_lame_finalize (GObject * obj)
+{
+  gst_two_lame_release_memory (GST_TWO_LAME (obj));
+
+  G_OBJECT_CLASS (gst_two_lame_parent_class)->finalize (obj);
+}
+
+static void
+gst_two_lame_class_init (GstTwoLameClass * klass)
+{
+  GObjectClass *gobject_class;
+  GstAudioEncoderClass *gstbase_class;
+
+  gobject_class = (GObjectClass *) klass;
+  gstbase_class = (GstAudioEncoderClass *) klass;
+
+  gobject_class->set_property = gst_two_lame_set_property;
+  gobject_class->get_property = gst_two_lame_get_property;
+  gobject_class->finalize = gst_two_lame_finalize;
+
+  gstbase_class->start = GST_DEBUG_FUNCPTR (gst_two_lame_start);
+  gstbase_class->stop = GST_DEBUG_FUNCPTR (gst_two_lame_stop);
+  gstbase_class->set_format = GST_DEBUG_FUNCPTR (gst_two_lame_set_format);
+  gstbase_class->handle_frame = GST_DEBUG_FUNCPTR (gst_two_lame_handle_frame);
+  gstbase_class->flush = GST_DEBUG_FUNCPTR (gst_two_lame_flush);
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MODE,
+      g_param_spec_enum ("mode", "Mode", "Encoding mode",
+          GST_TYPE_TWO_LAME_MODE, gst_two_lame_default_settings.mode,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PSYMODEL,
+      g_param_spec_int ("psymodel", "Psychoacoustic Model",
+          "Psychoacoustic model used to encode the audio",
+          -1, 4, gst_two_lame_default_settings.psymodel,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
+      g_param_spec_int ("bitrate", "Bitrate (kb/s)",
+          "Bitrate in kbit/sec (8, 16, 24, 32, 40, 48, 56, 64, 80, 96, "
+          "112, 128, 144, 160, 192, 224, 256, 320, 384)",
+          8, 384, gst_two_lame_default_settings.bitrate,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PADDING,
+      g_param_spec_enum ("padding", "Padding", "Padding type",
+          GST_TYPE_TWO_LAME_PADDING, gst_two_lame_default_settings.padding,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass),
+      ARG_ENERGY_LEVEL_EXTENSION,
+      g_param_spec_boolean ("energy-level-extension", "Energy Level Extension",
+          "Write peak PCM level to each frame",
+          gst_two_lame_default_settings.energy_level_extension,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EMPHASIS,
+      g_param_spec_enum ("emphasis", "Emphasis",
+          "Pre-emphasis to apply to the decoded audio",
+          GST_TYPE_TWO_LAME_EMPHASIS, gst_two_lame_default_settings.emphasis,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_PROTECTION,
+      g_param_spec_boolean ("error-protection", "Error protection",
+          "Adds checksum to every frame",
+          gst_two_lame_default_settings.error_protection,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COPYRIGHT,
+      g_param_spec_boolean ("copyright", "Copyright", "Mark as copyright",
+          gst_two_lame_default_settings.copyright,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ORIGINAL,
+      g_param_spec_boolean ("original", "Original", "Mark as original",
+          gst_two_lame_default_settings.original,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR,
+      g_param_spec_boolean ("vbr", "VBR", "Enable variable bitrate mode",
+          gst_two_lame_default_settings.vbr,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_LEVEL,
+      g_param_spec_float ("vbr-level", "VBR Level", "VBR Level",
+          -10.0, 10.0, gst_two_lame_default_settings.vbr_level,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ATH_LEVEL,
+      g_param_spec_float ("ath-level", "ATH Level", "ATH Level in dB",
+          -G_MAXFLOAT, G_MAXFLOAT, gst_two_lame_default_settings.ath_level,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_MAX_BITRATE,
+      g_param_spec_int ("vbr-max-bitrate", "VBR max bitrate",
+          "Specify maximum VBR bitrate (0=off, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, "
+          "112, 128, 144, 160, 192, 224, 256, 320, 384)",
+          0, 384, gst_two_lame_default_settings.vbr_max_bitrate,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUICK_MODE,
+      g_param_spec_boolean ("quick-mode", "Quick mode",
+          "Calculate Psymodel every frames",
+          gst_two_lame_default_settings.quick_mode,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUICK_MODE_COUNT,
+      g_param_spec_int ("quick-mode-count", "Quick mode count",
+          "Calculate Psymodel every n frames",
+          0, G_MAXINT, gst_two_lame_default_settings.quick_mode_count,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  gst_element_class_add_pad_template (GST_ELEMENT_CLASS (klass),
+      gst_static_pad_template_get (&gst_two_lame_src_template));
+  gst_element_class_add_pad_template (GST_ELEMENT_CLASS (klass),
+      gst_static_pad_template_get (&gst_two_lame_sink_template));
+
+  gst_element_class_set_static_metadata (GST_ELEMENT_CLASS (klass),
+      "TwoLAME mp2 encoder", "Codec/Encoder/Audio",
+      "High-quality free MP2 encoder",
+      "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+}
+
+static gboolean
+gst_two_lame_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
+{
+  GstTwoLame *twolame;
+  gint out_samplerate;
+  gint version;
+  GstCaps *othercaps;
+
+  twolame = GST_TWO_LAME (enc);
+
+  /* parameters already parsed for us */
+  twolame->samplerate = GST_AUDIO_INFO_RATE (info);
+  twolame->num_channels = GST_AUDIO_INFO_CHANNELS (info);
+  twolame->float_input = !GST_AUDIO_INFO_IS_INTEGER (info);
+
+  /* but we might be asked to reconfigure, so reset */
+  gst_two_lame_release_memory (twolame);
+
+  GST_DEBUG_OBJECT (twolame, "setting up twolame");
+  if (!gst_two_lame_setup (twolame))
+    goto setup_failed;
+
+  out_samplerate = twolame_get_out_samplerate (twolame->glopts);
+  if (out_samplerate == 0)
+    goto zero_output_rate;
+
+  if (out_samplerate != twolame->samplerate) {
+    GST_WARNING_OBJECT (twolame,
+        "output samplerate %d is different from incoming samplerate %d",
+        out_samplerate, twolame->samplerate);
+  }
+
+  version = twolame_get_version (twolame->glopts);
+  if (version == TWOLAME_MPEG2)
+    version = 2;
+  else
+    version = 1;
+
+  othercaps =
+      gst_caps_new_simple ("audio/mpeg",
+      "mpegversion", G_TYPE_INT, 1,
+      "mpegaudioversion", G_TYPE_INT, version,
+      "layer", G_TYPE_INT, 2,
+      "channels", G_TYPE_INT,
+      twolame->mode == TWOLAME_MONO ? 1 : twolame->num_channels, "rate",
+      G_TYPE_INT, out_samplerate, NULL);
+
+  /* and use these caps */
+  gst_audio_encoder_set_output_format (GST_AUDIO_ENCODER (twolame), othercaps);
+  gst_caps_unref (othercaps);
+
+  /* report needs to base class:
+   * hand one frame at a time, if we are pretty sure what a frame is */
+  if (out_samplerate == twolame->samplerate) {
+    gst_audio_encoder_set_frame_samples_min (enc, 1152);
+    gst_audio_encoder_set_frame_samples_max (enc, 1152);
+    gst_audio_encoder_set_frame_max (enc, 1);
+  }
+
+  return TRUE;
+
+zero_output_rate:
+  {
+    GST_ELEMENT_ERROR (twolame, LIBRARY, SETTINGS, (NULL),
+        ("TwoLAME decided on a zero sample rate"));
+    return FALSE;
+  }
+setup_failed:
+  {
+    GST_ELEMENT_ERROR (twolame, LIBRARY, SETTINGS,
+        (_("Failed to configure TwoLAME encoder. Check your encoding parameters.")), (NULL));
+    return FALSE;
+  }
+}
+
+static void
+gst_two_lame_init (GstTwoLame * twolame)
+{
+  GST_DEBUG_OBJECT (twolame, "starting initialization");
+
+  twolame->mode = gst_two_lame_default_settings.mode;
+  twolame->psymodel = gst_two_lame_default_settings.psymodel;
+  twolame->bitrate = gst_two_lame_default_settings.bitrate;
+  twolame->padding = gst_two_lame_default_settings.padding;
+  twolame->energy_level_extension =
+      gst_two_lame_default_settings.energy_level_extension;
+  twolame->emphasis = gst_two_lame_default_settings.emphasis;
+  twolame->error_protection = gst_two_lame_default_settings.error_protection;
+  twolame->copyright = gst_two_lame_default_settings.copyright;
+  twolame->original = gst_two_lame_default_settings.original;
+  twolame->vbr = gst_two_lame_default_settings.vbr;
+  twolame->vbr_level = gst_two_lame_default_settings.vbr_level;
+  twolame->ath_level = gst_two_lame_default_settings.ath_level;
+  twolame->vbr_max_bitrate = gst_two_lame_default_settings.vbr_max_bitrate;
+  twolame->quick_mode = gst_two_lame_default_settings.quick_mode;
+  twolame->quick_mode_count = gst_two_lame_default_settings.quick_mode_count;
+
+  GST_DEBUG_OBJECT (twolame, "done initializing");
+}
+
+static gboolean
+gst_two_lame_start (GstAudioEncoder * enc)
+{
+  GstTwoLame *twolame = GST_TWO_LAME (enc);
+
+  GST_DEBUG_OBJECT (twolame, "start");
+  return TRUE;
+}
+
+static gboolean
+gst_two_lame_stop (GstAudioEncoder * enc)
+{
+  GstTwoLame *twolame = GST_TWO_LAME (enc);
+
+  GST_DEBUG_OBJECT (twolame, "stop");
+
+  gst_two_lame_release_memory (twolame);
+  return TRUE;
+}
+
+/* <php-emulation-mode>three underscores for ___rate is really really really
+ * private as opposed to one underscore<php-emulation-mode> */
+/* call this MACRO outside of the NULL state so that we have a higher chance
+ * of actually having a pipeline and bus to get the message through */
+
+#define CHECK_AND_FIXUP_BITRATE(obj,param,rate)         		  \
+G_STMT_START {                                                            \
+  gint ___rate = rate;                                                    \
+  gint maxrate = 320;							  \
+  gint multiplier = 64;							  \
+  if (rate <= 64) {							  \
+    maxrate = 64; multiplier = 8;                                         \
+    if ((rate % 8) != 0) ___rate = GST_ROUND_UP_8 (rate); 		  \
+  } else if (rate <= 144) {						  \
+    maxrate = 144; multiplier = 16;                                       \
+    if ((rate % 16) != 0) ___rate = GST_ROUND_UP_16 (rate);               \
+  } else if (rate <= 256) {						  \
+    maxrate = 256; multiplier = 32;                                       \
+    if ((rate % 32) != 0) ___rate = GST_ROUND_UP_32 (rate);               \
+  } else if (rate <= 384) { 						  \
+    maxrate = 384; multiplier = 64;                                       \
+    if ((rate % 64) != 0) ___rate = GST_ROUND_UP_64 (rate);               \
+  }                                                                       \
+  if (___rate != rate) {                                                  \
+    GST_ELEMENT_WARNING (obj, LIBRARY, SETTINGS,			  \
+        (_("The requested bitrate %d kbit/s for property '%s' "           \
+           "is not allowed. "  					          \
+           "The bitrate was changed to %d kbit/s."), rate,		  \
+         param,  ___rate), 					          \
+        ("A bitrate below %d should be a multiple of %d.", 		  \
+            maxrate, multiplier));		  			  \
+    rate = ___rate;                                                       \
+  }                                                                       \
+} G_STMT_END
+
+static void
+gst_two_lame_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec)
+{
+  GstTwoLame *twolame = GST_TWO_LAME (object);
+
+  switch (prop_id) {
+    case ARG_MODE:
+      twolame->mode = g_value_get_enum (value);
+      break;
+    case ARG_PSYMODEL:
+      twolame->psymodel = g_value_get_int (value);
+      break;
+    case ARG_BITRATE:
+      twolame->bitrate = g_value_get_int (value);
+      break;
+    case ARG_PADDING:
+      twolame->padding = g_value_get_enum (value);
+      break;
+    case ARG_ENERGY_LEVEL_EXTENSION:
+      twolame->energy_level_extension = g_value_get_boolean (value);
+      break;
+    case ARG_EMPHASIS:
+      twolame->emphasis = g_value_get_enum (value);
+      break;
+    case ARG_ERROR_PROTECTION:
+      twolame->error_protection = g_value_get_boolean (value);
+      break;
+    case ARG_COPYRIGHT:
+      twolame->copyright = g_value_get_boolean (value);
+      break;
+    case ARG_ORIGINAL:
+      twolame->original = g_value_get_boolean (value);
+      break;
+    case ARG_VBR:
+      twolame->vbr = g_value_get_boolean (value);
+      break;
+    case ARG_VBR_LEVEL:
+      twolame->vbr_level = g_value_get_float (value);
+      break;
+    case ARG_ATH_LEVEL:
+      twolame->ath_level = g_value_get_float (value);
+      break;
+    case ARG_VBR_MAX_BITRATE:
+      twolame->vbr_max_bitrate = g_value_get_int (value);
+      break;
+    case ARG_QUICK_MODE:
+      twolame->quick_mode = g_value_get_boolean (value);
+      break;
+    case ARG_QUICK_MODE_COUNT:
+      twolame->quick_mode_count = g_value_get_int (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+gst_two_lame_get_property (GObject * object, guint prop_id, GValue * value,
+    GParamSpec * pspec)
+{
+  GstTwoLame *twolame = GST_TWO_LAME (object);
+
+  switch (prop_id) {
+    case ARG_MODE:
+      g_value_set_enum (value, twolame->mode);
+      break;
+    case ARG_PSYMODEL:
+      g_value_set_int (value, twolame->psymodel);
+      break;
+    case ARG_BITRATE:
+      g_value_set_int (value, twolame->bitrate);
+      break;
+    case ARG_PADDING:
+      g_value_set_enum (value, twolame->padding);
+      break;
+    case ARG_ENERGY_LEVEL_EXTENSION:
+      g_value_set_boolean (value, twolame->energy_level_extension);
+      break;
+    case ARG_EMPHASIS:
+      g_value_set_enum (value, twolame->emphasis);
+      break;
+    case ARG_ERROR_PROTECTION:
+      g_value_set_boolean (value, twolame->error_protection);
+      break;
+    case ARG_COPYRIGHT:
+      g_value_set_boolean (value, twolame->copyright);
+      break;
+    case ARG_ORIGINAL:
+      g_value_set_boolean (value, twolame->original);
+      break;
+    case ARG_VBR:
+      g_value_set_boolean (value, twolame->vbr);
+      break;
+    case ARG_VBR_LEVEL:
+      g_value_set_float (value, twolame->vbr_level);
+      break;
+    case ARG_ATH_LEVEL:
+      g_value_set_float (value, twolame->ath_level);
+      break;
+    case ARG_VBR_MAX_BITRATE:
+      g_value_set_int (value, twolame->vbr_max_bitrate);
+      break;
+    case ARG_QUICK_MODE:
+      g_value_set_boolean (value, twolame->quick_mode);
+      break;
+    case ARG_QUICK_MODE_COUNT:
+      g_value_set_int (value, twolame->quick_mode_count);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static GstFlowReturn
+gst_two_lame_flush_full (GstTwoLame * lame, gboolean push)
+{
+  GstBuffer *buf;
+  GstMapInfo map;
+  gint size;
+  GstFlowReturn result = GST_FLOW_OK;
+
+  if (!lame->glopts)
+    return GST_FLOW_OK;
+
+  buf = gst_buffer_new_and_alloc (16384);
+  gst_buffer_map (buf, &map, GST_MAP_WRITE);
+  size = twolame_encode_flush (lame->glopts, map.data, 16384);
+  gst_buffer_unmap (buf, &map);
+
+  if (size > 0 && push) {
+    gst_buffer_set_size (buf, size);
+    GST_DEBUG_OBJECT (lame, "pushing final packet of %u bytes", size);
+    result = gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER (lame), buf, -1);
+  } else {
+    GST_DEBUG_OBJECT (lame, "no final packet (size=%d, push=%d)", size, push);
+    gst_buffer_unref (buf);
+    result = GST_FLOW_OK;
+  }
+  return result;
+}
+
+static void
+gst_two_lame_flush (GstAudioEncoder * enc)
+{
+  gst_two_lame_flush_full (GST_TWO_LAME (enc), FALSE);
+}
+
+static GstFlowReturn
+gst_two_lame_handle_frame (GstAudioEncoder * enc, GstBuffer * buf)
+{
+  GstTwoLame *twolame;
+  gint mp3_buffer_size, mp3_size;
+  GstBuffer *mp3_buf;
+  GstFlowReturn result;
+  gint num_samples;
+  GstMapInfo map, mp3_map;
+
+  twolame = GST_TWO_LAME (enc);
+
+  /* squeeze remaining and push */
+  if (G_UNLIKELY (buf == NULL))
+    return gst_two_lame_flush_full (twolame, TRUE);
+
+  gst_buffer_map (buf, &map, GST_MAP_READ);
+
+  if (twolame->float_input)
+    num_samples = map.size / 4;
+  else
+    num_samples = map.size / 2;
+
+  /* allocate space for output */
+  mp3_buffer_size = 1.25 * num_samples + 16384;
+  mp3_buf = gst_buffer_new_and_alloc (mp3_buffer_size);
+  gst_buffer_map (mp3_buf, &mp3_map, GST_MAP_WRITE);
+
+  if (twolame->num_channels == 1) {
+    if (twolame->float_input)
+      mp3_size = twolame_encode_buffer_float32 (twolame->glopts,
+          (float *) map.data,
+          (float *) map.data, num_samples, mp3_map.data, mp3_buffer_size);
+    else
+      mp3_size = twolame_encode_buffer (twolame->glopts,
+          (short int *) map.data,
+          (short int *) map.data, num_samples, mp3_map.data, mp3_buffer_size);
+  } else {
+    if (twolame->float_input)
+      mp3_size = twolame_encode_buffer_float32_interleaved (twolame->glopts,
+          (float *) map.data,
+          num_samples / twolame->num_channels, mp3_map.data, mp3_buffer_size);
+    else
+      mp3_size = twolame_encode_buffer_interleaved (twolame->glopts,
+          (short int *) map.data,
+          num_samples / twolame->num_channels, mp3_map.data, mp3_buffer_size);
+  }
+
+  GST_LOG_OBJECT (twolame, "encoded %" G_GSIZE_FORMAT " bytes of audio "
+      "to %d bytes of mp3", map.size, mp3_size);
+
+  gst_buffer_unmap (buf, &map);
+  gst_buffer_unmap (mp3_buf, &mp3_map);
+
+  if (mp3_size > 0) {
+    gst_buffer_set_size (mp3_buf, mp3_size);
+    result = gst_audio_encoder_finish_frame (enc, mp3_buf, -1);
+  } else {
+    if (mp3_size < 0) {
+      /* eat error ? */
+      g_warning ("error %d", mp3_size);
+    }
+    gst_buffer_unref (mp3_buf);
+    result = GST_FLOW_OK;
+  }
+
+  return result;
+}
+
+/* set up the encoder state */
+static gboolean
+gst_two_lame_setup (GstTwoLame * twolame)
+{
+
+#define CHECK_ERROR(command) G_STMT_START {\
+  if ((command) < 0) { \
+    GST_ERROR_OBJECT (twolame, "setup failed: " G_STRINGIFY (command)); \
+    return FALSE; \
+  } \
+}G_STMT_END
+
+  int retval;
+  GstCaps *allowed_caps;
+
+  GST_DEBUG_OBJECT (twolame, "starting setup");
+
+  /* check if we're already setup; if we are, we might want to check
+   * if this initialization is compatible with the previous one */
+  /* FIXME: do this */
+  if (twolame->setup) {
+    GST_WARNING_OBJECT (twolame, "already setup");
+    twolame->setup = FALSE;
+  }
+
+  twolame->glopts = twolame_init ();
+
+  if (twolame->glopts == NULL)
+    return FALSE;
+
+  /* copy the parameters over */
+  twolame_set_in_samplerate (twolame->glopts, twolame->samplerate);
+
+  /* let twolame choose default samplerate unless outgoing sample rate is fixed */
+  allowed_caps = gst_pad_get_allowed_caps (GST_AUDIO_ENCODER_SRC_PAD (twolame));
+
+  if (allowed_caps != NULL) {
+    GstStructure *structure;
+    gint samplerate;
+
+    structure = gst_caps_get_structure (allowed_caps, 0);
+
+    if (gst_structure_get_int (structure, "rate", &samplerate)) {
+      GST_DEBUG_OBJECT (twolame,
+          "Setting sample rate to %d as fixed in src caps", samplerate);
+      twolame_set_out_samplerate (twolame->glopts, samplerate);
+    } else {
+      GST_DEBUG_OBJECT (twolame, "Letting twolame choose sample rate");
+      twolame_set_out_samplerate (twolame->glopts, 0);
+    }
+    gst_caps_unref (allowed_caps);
+    allowed_caps = NULL;
+  } else {
+    GST_DEBUG_OBJECT (twolame,
+        "No peer yet, letting twolame choose sample rate");
+    twolame_set_out_samplerate (twolame->glopts, 0);
+  }
+
+  /* force mono encoding if we only have one channel */
+  if (twolame->num_channels == 1)
+    twolame->mode = 3;
+
+  /* Fix bitrates and MPEG version */
+
+  CHECK_ERROR (twolame_set_num_channels (twolame->glopts,
+          twolame->num_channels));
+
+  CHECK_ERROR (twolame_set_mode (twolame->glopts, twolame->mode));
+  CHECK_ERROR (twolame_set_psymodel (twolame->glopts, twolame->psymodel));
+  CHECK_AND_FIXUP_BITRATE (twolame, "bitrate", twolame->bitrate);
+  CHECK_ERROR (twolame_set_bitrate (twolame->glopts, twolame->bitrate));
+  CHECK_ERROR (twolame_set_padding (twolame->glopts, twolame->padding));
+  CHECK_ERROR (twolame_set_energy_levels (twolame->glopts,
+          twolame->energy_level_extension));
+  CHECK_ERROR (twolame_set_emphasis (twolame->glopts, twolame->emphasis));
+  CHECK_ERROR (twolame_set_error_protection (twolame->glopts,
+          twolame->error_protection));
+  CHECK_ERROR (twolame_set_copyright (twolame->glopts, twolame->copyright));
+  CHECK_ERROR (twolame_set_original (twolame->glopts, twolame->original));
+  CHECK_ERROR (twolame_set_VBR (twolame->glopts, twolame->vbr));
+  CHECK_ERROR (twolame_set_VBR_level (twolame->glopts, twolame->vbr_level));
+  CHECK_ERROR (twolame_set_ATH_level (twolame->glopts, twolame->ath_level));
+  CHECK_AND_FIXUP_BITRATE (twolame, "vbr-max-bitrate",
+      twolame->vbr_max_bitrate);
+  CHECK_ERROR (twolame_set_VBR_max_bitrate_kbps (twolame->glopts,
+          twolame->vbr_max_bitrate));
+  CHECK_ERROR (twolame_set_quick_mode (twolame->glopts, twolame->quick_mode));
+  CHECK_ERROR (twolame_set_quick_count (twolame->glopts,
+          twolame->quick_mode_count));
+
+  /* initialize the twolame encoder */
+  if ((retval = twolame_init_params (twolame->glopts)) >= 0) {
+    twolame->setup = TRUE;
+    /* FIXME: it would be nice to print out the mode here */
+    GST_INFO ("twolame encoder setup (%d kbit/s, %d Hz, %d channels)",
+        twolame->bitrate, twolame->samplerate, twolame->num_channels);
+  } else {
+    GST_ERROR_OBJECT (twolame, "twolame_init_params returned %d", retval);
+  }
+
+  GST_DEBUG_OBJECT (twolame, "done with setup");
+
+  return twolame->setup;
+#undef CHECK_ERROR
+}
+
+static gboolean
+gst_two_lame_get_default_settings (void)
+{
+  twolame_options *glopts = NULL;
+
+  glopts = twolame_init ();
+  if (glopts == NULL) {
+    GST_ERROR ("Couldn't initialize TwoLAME");
+    return FALSE;
+  }
+
+  twolame_set_num_channels (glopts, 2);
+  twolame_set_in_samplerate (glopts, 44100);
+
+  if (twolame_init_params (glopts) != 0) {
+    GST_ERROR ("Couldn't set default parameters");
+    return FALSE;
+  }
+
+  gst_two_lame_default_settings.mode = TWOLAME_JOINT_STEREO;    /* twolame_get_mode (glopts); */
+  gst_two_lame_default_settings.psymodel = twolame_get_psymodel (glopts);
+  gst_two_lame_default_settings.bitrate = twolame_get_bitrate (glopts);
+  gst_two_lame_default_settings.padding = twolame_get_padding (glopts);
+  gst_two_lame_default_settings.energy_level_extension =
+      twolame_get_energy_levels (glopts);
+  gst_two_lame_default_settings.emphasis = twolame_get_emphasis (glopts);
+  gst_two_lame_default_settings.error_protection =
+      twolame_get_error_protection (glopts);
+  gst_two_lame_default_settings.copyright = twolame_get_copyright (glopts);
+  gst_two_lame_default_settings.original = twolame_get_original (glopts);
+  gst_two_lame_default_settings.vbr = twolame_get_VBR (glopts);
+  gst_two_lame_default_settings.vbr_level = twolame_get_VBR_level (glopts);
+  gst_two_lame_default_settings.ath_level = twolame_get_ATH_level (glopts);
+  gst_two_lame_default_settings.vbr_max_bitrate =
+      twolame_get_VBR_max_bitrate_kbps (glopts);
+  gst_two_lame_default_settings.quick_mode = twolame_get_quick_mode (glopts);
+  gst_two_lame_default_settings.quick_mode_count =
+      twolame_get_quick_count (glopts);
+
+  twolame_close (&glopts);
+
+  return TRUE;
+}
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  GST_DEBUG_CATEGORY_INIT (debug, "twolame", 0, "twolame mp2 encoder");
+
+  if (!gst_two_lame_get_default_settings ())
+    return FALSE;
+
+#ifdef ENABLE_NLS
+  GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
+      LOCALEDIR);
+  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif /* ENABLE_NLS */
+
+  if (!gst_element_register (plugin, "twolamemp2enc", GST_RANK_PRIMARY,
+          GST_TYPE_TWO_LAME))
+    return FALSE;
+
+  return TRUE;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    twolame,
+    "Encode MP2s with TwoLAME",
+    plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
diff --git a/ext/twolame/gsttwolamemp2enc.h b/ext/twolame/gsttwolamemp2enc.h
new file mode 100644
index 0000000..deb3cf4
--- /dev/null
+++ b/ext/twolame/gsttwolamemp2enc.h
@@ -0,0 +1,88 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) <2008> Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#ifndef __GST_TWO_LAME_H__
+#define __GST_TWO_LAME_H__
+
+
+#include <gst/gst.h>
+#include <gst/audio/gstaudioencoder.h>
+
+G_BEGIN_DECLS
+
+#include <twolame.h>
+
+#define GST_TYPE_TWO_LAME \
+  (gst_two_lame_get_type())
+#define GST_TWO_LAME(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TWO_LAME,GstTwoLame))
+#define GST_TWO_LAME_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TWO_LAME,GstTwoLameClass))
+#define GST_IS_TWO_LAME(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TWO_LAME))
+#define GST_IS_TWO_LAME_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TWO_LAME))
+
+typedef struct _GstTwoLame GstTwoLame;
+typedef struct _GstTwoLameClass GstTwoLameClass;
+
+/**
+ * GstTwoLame:
+ *
+ * Opaque data structure.
+ */
+struct _GstTwoLame {
+  GstAudioEncoder element;
+
+  gint samplerate;
+  gint num_channels;
+  gboolean float_input;
+  gboolean setup;
+
+  gint mode;
+  gint psymodel;
+  gint bitrate;
+  gint padding;
+  gboolean energy_level_extension;
+  gint emphasis;
+  gboolean error_protection;
+  gboolean copyright;
+  gboolean original;
+  gboolean vbr;
+  gfloat vbr_level;
+  gfloat ath_level;
+  gint vbr_max_bitrate;
+  gboolean quick_mode;
+  gint quick_mode_count;
+
+  twolame_options *glopts;
+};
+
+struct _GstTwoLameClass {
+  GstAudioEncoderClass parent_class;
+};
+
+GType gst_two_lame_get_type(void);
+
+G_END_DECLS
+
+
+#endif /* __GST_TWO_LAME_H__ */
diff --git a/ext/x264/GstX264Enc.prs b/ext/x264/GstX264Enc.prs
new file mode 100644
index 0000000..84c76a9
--- /dev/null
+++ b/ext/x264/GstX264Enc.prs
@@ -0,0 +1,44 @@
+[_presets_]
+version=0.10
+element-name=GstX264Enc
+
+[Profile Baseline]
+_meta/comment=Baseline Profile
+bframes=0
+cabac=false
+dct8x8=false
+
+[Profile Main]
+_meta/comment=Main Profile
+cabac=true
+dct8x8=false
+
+[Profile High]
+_meta/comment=High Profile
+cabac=true
+dct8x8=true
+
+[Quality Low]
+_meta/comment=Low quality
+pass=qual
+quantizer=27
+subme=4
+threads=0
+
+[Quality Normal]
+_meta/comment=Normal quality
+pass=qual
+quantizer=21
+me=umh
+subme=6
+ref=3
+threads=0
+
+[Quality High]
+_meta/comment=High quality
+pass=qual
+quantizer=18
+me=umh
+subme=6
+ref=3
+threads=0
diff --git a/ext/x264/Makefile.am b/ext/x264/Makefile.am
new file mode 100644
index 0000000..f69c9b1
--- /dev/null
+++ b/ext/x264/Makefile.am
@@ -0,0 +1,37 @@
+plugin_LTLIBRARIES = libgstx264.la
+
+libgstx264_la_SOURCES = gstx264enc.c
+libgstx264_la_CFLAGS = \
+	$(GST_PLUGINS_BASE_CFLAGS) \
+	$(GST_CFLAGS) \
+	$(X264_CFLAGS)
+libgstx264_la_LIBADD = \
+	$(GST_PLUGINS_BASE_LIBS) \
+	-lgstvideo-$(GST_API_VERSION) \
+	-lgstpbutils-$(GST_API_VERSION) \
+	$(GST_LIBS) \
+	$(X264_LIBS)
+libgstx264_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstx264_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS = gstx264enc.h
+
+presetdir = $(datadir)/gstreamer-$(GST_API_VERSION)/presets
+preset_DATA = GstX264Enc.prs
+
+EXTRA_DIST = $(preset_DATA)
+
+Android.mk: Makefile.am $(BUILT_SOURCES)
+	androgenizer \
+	-:PROJECT libgstx264 -:SHARED libgstx264 \
+	 -:TAGS eng debug \
+         -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
+	 -:SOURCES $(libgstx264_la_SOURCES) \
+	 -:CPPFLAGS $(CPPFLAGS) \
+	 -:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(libgstx264_la_CFLAGS) -I'$$(GSTREAMER_AGGREGATE_TOP)/x264' \
+	 -:LDFLAGS $(libgstx264_la_LDFLAGS) \
+	           $(libgstx264_la_LIBADD) \
+	           -ldl \
+	 -:PASSTHROUGH LOCAL_ARM_MODE:=arm \
+		       LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-0.10' \
+	> $@
diff --git a/ext/x264/Makefile.in b/ext/x264/Makefile.in
new file mode 100644
index 0000000..0e410ce
--- /dev/null
+++ b/ext/x264/Makefile.in
@@ -0,0 +1,798 @@
+# Makefile.in generated by automake 1.11.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+
+VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = ext/x264
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \
+	$(top_srcdir)/common/m4/as-auto-alt.m4 \
+	$(top_srcdir)/common/m4/as-compiler-flag.m4 \
+	$(top_srcdir)/common/m4/as-python.m4 \
+	$(top_srcdir)/common/m4/as-scrub-include.m4 \
+	$(top_srcdir)/common/m4/as-version.m4 \
+	$(top_srcdir)/common/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/common/m4/gst-arch.m4 \
+	$(top_srcdir)/common/m4/gst-args.m4 \
+	$(top_srcdir)/common/m4/gst-check.m4 \
+	$(top_srcdir)/common/m4/gst-default.m4 \
+	$(top_srcdir)/common/m4/gst-dowhile.m4 \
+	$(top_srcdir)/common/m4/gst-error.m4 \
+	$(top_srcdir)/common/m4/gst-feature.m4 \
+	$(top_srcdir)/common/m4/gst-function.m4 \
+	$(top_srcdir)/common/m4/gst-gettext.m4 \
+	$(top_srcdir)/common/m4/gst-glib2.m4 \
+	$(top_srcdir)/common/m4/gst-package-release-datetime.m4 \
+	$(top_srcdir)/common/m4/gst-plugin-docs.m4 \
+	$(top_srcdir)/common/m4/gst-plugindir.m4 \
+	$(top_srcdir)/common/m4/gst.m4 \
+	$(top_srcdir)/common/m4/gtk-doc.m4 \
+	$(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \
+	$(top_srcdir)/m4/a52.m4 $(top_srcdir)/m4/gettext.m4 \
+	$(top_srcdir)/m4/gst-sid.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+	$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+am__installdirs = "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(presetdir)"
+LTLIBRARIES = $(plugin_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libgstx264_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am_libgstx264_la_OBJECTS = libgstx264_la-gstx264enc.lo
+libgstx264_la_OBJECTS = $(am_libgstx264_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+libgstx264_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+	$(libgstx264_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+	$(CCLD) $(libgstx264_la_CFLAGS) $(CFLAGS) \
+	$(libgstx264_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libgstx264_la_SOURCES)
+DIST_SOURCES = $(libgstx264_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+DATA = $(preset_DATA)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+A52DEC_CFLAGS = @A52DEC_CFLAGS@
+A52DEC_LIBS = @A52DEC_LIBS@
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMRNB_CFLAGS = @AMRNB_CFLAGS@
+AMRNB_LIBS = @AMRNB_LIBS@
+AMRWB_CFLAGS = @AMRWB_CFLAGS@
+AMRWB_LIBS = @AMRWB_LIBS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CDIO_CFLAGS = @CDIO_CFLAGS@
+CDIO_LIBS = @CDIO_LIBS@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@
+DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@
+DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@
+DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@
+DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DVDREAD_LIBS = @DVDREAD_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+ERROR_CXXFLAGS = @ERROR_CXXFLAGS@
+EXEEXT = @EXEEXT@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+GCOV = @GCOV@
+GCOV_CFLAGS = @GCOV_CFLAGS@
+GCOV_LIBS = @GCOV_LIBS@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LDFLAGS = @GIO_LDFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_PREFIX = @GLIB_PREFIX@
+GLIB_REQ = @GLIB_REQ@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@
+GSTPB_PREFIX = @GSTPB_PREFIX@
+GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@
+GST_API_VERSION = @GST_API_VERSION@
+GST_BASE_CFLAGS = @GST_BASE_CFLAGS@
+GST_BASE_LIBS = @GST_BASE_LIBS@
+GST_CFLAGS = @GST_CFLAGS@
+GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@
+GST_CHECK_LIBS = @GST_CHECK_LIBS@
+GST_CXXFLAGS = @GST_CXXFLAGS@
+GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@
+GST_LIBS = @GST_LIBS@
+GST_LICENSE = @GST_LICENSE@
+GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@
+GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@
+GST_PACKAGE_NAME = @GST_PACKAGE_NAME@
+GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@
+GST_PLUGINS_ALL = @GST_PLUGINS_ALL@
+GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@
+GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@
+GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@
+GST_PLUGINS_DIR = @GST_PLUGINS_DIR@
+GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@
+GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GST_PREFIX = @GST_PREFIX@
+GST_TOOLS_DIR = @GST_TOOLS_DIR@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DVDREAD = @HAVE_DVDREAD@
+HAVE_LAME = @HAVE_LAME@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LAME_CFLAGS = @LAME_CFLAGS@
+LAME_LIBS = @LAME_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAD_CFLAGS = @MAD_CFLAGS@
+MAD_LIBS = @MAD_LIBS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MPEG2DEC_CFLAGS = @MPEG2DEC_CFLAGS@
+MPEG2DEC_LIBS = @MPEG2DEC_LIBS@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ORCC = @ORCC@
+ORCC_FLAGS = @ORCC_FLAGS@
+ORC_CFLAGS = @ORC_CFLAGS@
+ORC_LIBS = @ORC_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@
+PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGINDIR = @PLUGINDIR@
+POSUB = @POSUB@
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIDPLAY_CFLAGS = @SIDPLAY_CFLAGS@
+SIDPLAY_LIBS = @SIDPLAY_LIBS@
+STRIP = @STRIP@
+TWOLAME_CFLAGS = @TWOLAME_CFLAGS@
+TWOLAME_LIBS = @TWOLAME_LIBS@
+USE_NLS = @USE_NLS@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VALGRIND_PATH = @VALGRIND_PATH@
+VERSION = @VERSION@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WIN32_LIBS = @WIN32_LIBS@
+X264_CFLAGS = @X264_CFLAGS@
+X264_LIBS = @X264_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+plugindir = @plugindir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+plugin_LTLIBRARIES = libgstx264.la
+libgstx264_la_SOURCES = gstx264enc.c
+libgstx264_la_CFLAGS = \
+	$(GST_PLUGINS_BASE_CFLAGS) \
+	$(GST_CFLAGS) \
+	$(X264_CFLAGS)
+
+libgstx264_la_LIBADD = \
+	$(GST_PLUGINS_BASE_LIBS) \
+	-lgstvideo-$(GST_API_VERSION) \
+	-lgstpbutils-$(GST_API_VERSION) \
+	$(GST_LIBS) \
+	$(X264_LIBS)
+
+libgstx264_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstx264_la_LIBTOOLFLAGS = --tag=disable-static
+noinst_HEADERS = gstx264enc.h
+presetdir = $(datadir)/gstreamer-$(GST_API_VERSION)/presets
+preset_DATA = GstX264Enc.prs
+EXTRA_DIST = $(preset_DATA)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/x264/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu ext/x264/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \
+	  $(MKDIR_P) '$(DESTDIR)$(plugindir)' || exit 1; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+	}
+
+uninstall-pluginLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+	done
+
+clean-pluginLTLIBRARIES:
+	-test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+	@list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libgstx264.la: $(libgstx264_la_OBJECTS) $(libgstx264_la_DEPENDENCIES) $(EXTRA_libgstx264_la_DEPENDENCIES) 
+	$(AM_V_CCLD)$(libgstx264_la_LINK) -rpath $(plugindir) $(libgstx264_la_OBJECTS) $(libgstx264_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstx264_la-gstx264enc.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+libgstx264_la-gstx264enc.lo: gstx264enc.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstx264_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstx264_la_CFLAGS) $(CFLAGS) -MT libgstx264_la-gstx264enc.lo -MD -MP -MF $(DEPDIR)/libgstx264_la-gstx264enc.Tpo -c -o libgstx264_la-gstx264enc.lo `test -f 'gstx264enc.c' || echo '$(srcdir)/'`gstx264enc.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libgstx264_la-gstx264enc.Tpo $(DEPDIR)/libgstx264_la-gstx264enc.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gstx264enc.c' object='libgstx264_la-gstx264enc.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstx264_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstx264_la_CFLAGS) $(CFLAGS) -c -o libgstx264_la-gstx264enc.lo `test -f 'gstx264enc.c' || echo '$(srcdir)/'`gstx264enc.c
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-presetDATA: $(preset_DATA)
+	@$(NORMAL_INSTALL)
+	@list='$(preset_DATA)'; test -n "$(presetdir)" || list=; \
+	if test -n "$$list"; then \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(presetdir)'"; \
+	  $(MKDIR_P) '$(DESTDIR)$(presetdir)' || exit 1; \
+	fi; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(presetdir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(presetdir)" || exit $$?; \
+	done
+
+uninstall-presetDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(preset_DATA)'; test -n "$(presetdir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	dir='$(DESTDIR)$(presetdir)'; $(am__uninstall_files_from_dir)
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(presetdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES install-presetDATA
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES uninstall-presetDATA
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-pluginLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-pluginLTLIBRARIES \
+	install-presetDATA install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-pluginLTLIBRARIES \
+	uninstall-presetDATA
+
+
+Android.mk: Makefile.am $(BUILT_SOURCES)
+	androgenizer \
+	-:PROJECT libgstx264 -:SHARED libgstx264 \
+	 -:TAGS eng debug \
+         -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
+	 -:SOURCES $(libgstx264_la_SOURCES) \
+	 -:CPPFLAGS $(CPPFLAGS) \
+	 -:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(libgstx264_la_CFLAGS) -I'$$(GSTREAMER_AGGREGATE_TOP)/x264' \
+	 -:LDFLAGS $(libgstx264_la_LDFLAGS) \
+	           $(libgstx264_la_LIBADD) \
+	           -ldl \
+	 -:PASSTHROUGH LOCAL_ARM_MODE:=arm \
+		       LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-0.10' \
+	> $@
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/ext/x264/gstx264enc.c b/ext/x264/gstx264enc.c
new file mode 100644
index 0000000..194b4a0
--- /dev/null
+++ b/ext/x264/gstx264enc.c
@@ -0,0 +1,2510 @@
+/* GStreamer H264 encoder plugin
+ * Copyright (C) 2005 Michal Benes <michal.benes@itonis.tv>
+ * Copyright (C) 2005 Josef Zlomek <josef.zlomek@itonis.tv>
+ * Copyright (C) 2008 Mark Nauwelaerts <mnauw@users.sf.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * SECTION:element-x264enc
+ * @see_also: faac
+ *
+ * This element encodes raw video into H264 compressed data,
+ * also otherwise known as MPEG-4 AVC (Advanced Video Codec).
+ *
+ * The #GstX264Enc:pass property controls the type of encoding.  In case of Constant
+ * Bitrate Encoding (actually ABR), the #GstX264Enc:bitrate will determine the quality
+ * of the encoding.  This will similarly be the case if this target bitrate
+ * is to obtained in multiple (2 or 3) pass encoding.
+ * Alternatively, one may choose to perform Constant Quantizer or Quality encoding,
+ * in which case the #GstX264Enc:quantizer property controls much of the outcome, in that case #GstX264Enc:bitrate is the maximum bitrate.
+ *
+ * The H264 profile that is eventually used depends on a few settings.
+ * If #GstX264Enc:dct8x8 is enabled, then High profile is used.
+ * Otherwise, if #GstX264Enc:cabac entropy coding is enabled or #GstX264Enc:bframes
+ * are allowed, then Main Profile is in effect, and otherwise Baseline profile
+ * applies.  The main profile is imposed by default,
+ * which is fine for most software players and settings,
+ * but in some cases (e.g. hardware platforms) a more restricted profile/level
+ * may be necessary. The recommended way to set a profile is to set it in the
+ * downstream caps.
+ *
+ * If a preset/tuning are specified then these will define the default values and
+ * the property defaults will be ignored. After this the option-string property is
+ * applied, followed by the user-set properties, fast first pass restrictions and
+ * finally the profile restrictions.
+ *
+ * <note>Some settings, including the default settings, may lead to quite
+ * some latency (i.e. frame buffering) in the encoder. This may cause problems
+ * with pipeline stalling in non-trivial pipelines, because the encoder latency
+ * is often considerably higher than the default size of a simple queue
+ * element. Such problems are caused by one of the queues in the other
+ * non-x264enc streams/branches filling up and blocking upstream. They can
+ * be fixed by relaxing the default time/size/buffer limits on the queue
+ * elements in the non-x264 branches, or using a (single) multiqueue element
+ * for all branches. Also see the last example below.
+ * </note>
+ *
+ * <refsect2>
+ * <title>Example pipeline</title>
+ * |[
+ * gst-launch -v videotestsrc num-buffers=1000 ! x264enc qp-min=18 ! \
+ *   avimux ! filesink location=videotestsrc.avi
+ * ]| This example pipeline will encode a test video source to H264 muxed in an
+ * AVI container, while ensuring a sane minimum quantization factor to avoid
+ * some (excessive) waste.
+ * |[
+ * gst-launch -v videotestsrc num-buffers=1000 ! x264enc pass=quant ! \
+ *   matroskamux ! filesink location=videotestsrc.avi
+ * ]| This example pipeline will encode a test video source to H264 using fixed
+ * quantization, and muxes it in a Matroska container.
+ * |[
+ * gst-launch -v videotestsrc num-buffers=1000 ! x264enc pass=5 quantizer=25 speed-preset=6 ! video/x-h264, profile=baseline ! \
+ *   qtmux ! filesink location=videotestsrc.mov
+ * ]| This example pipeline will encode a test video source to H264 using
+ * constant quality at around Q25 using the 'medium' speed/quality preset and
+ * restricting the options used so that the output is H.264 Baseline Profile
+ * compliant and finally multiplexing the output in Quicktime mov format.
+ * |[
+ * gst-launch -v videotestsrc num-buffers=1000 ! tee name=t ! queue ! xvimagesink \
+ *   t. ! queue ! x264enc rc-lookahead=5 ! fakesink
+ * ]| This example pipeline will encode a test video source to H264 while
+ * displaying the input material at the same time.  As mentioned above,
+ * specific settings are needed in this case to avoid pipeline stalling.
+ * Depending on goals and context, other approaches are possible, e.g.
+ * tune=zerolatency might be configured, or queue sizes increased.
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "gstx264enc.h"
+
+#include <gst/pbutils/pbutils.h>
+#include <gst/video/video.h>
+
+#if X264_BUILD >= 71
+#define X264_DELAYED_FRAMES_API
+#endif
+
+#if X264_BUILD >= 76
+#define X264_ENC_NALS 1
+#endif
+
+#if X264_BUILD >= 69
+#define X264_MB_RC
+#endif
+
+#if X264_BUILD >= 78
+/* b-pyramid was available before but was changed from boolean here */
+#define X264_B_PYRAMID
+#endif
+
+#if X264_BUILD >= 80
+#define X264_ENH_THREADING
+#endif
+
+#if X264_BUILD >= 82
+#define X264_INTRA_REFRESH
+#endif
+
+#if X264_BUILD >= 86
+#define X264_PRESETS
+#endif
+
+#if X264_BUILD >= 95
+#define FORCE_INTRA_API
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+
+GST_DEBUG_CATEGORY_STATIC (x264_enc_debug);
+#define GST_CAT_DEFAULT x264_enc_debug
+
+enum
+{
+  ARG_0,
+  ARG_THREADS,
+  ARG_SLICED_THREADS,
+  ARG_SYNC_LOOKAHEAD,
+  ARG_PASS,
+  ARG_QUANTIZER,
+  ARG_MULTIPASS_CACHE_FILE,
+  ARG_BYTE_STREAM,
+  ARG_BITRATE,
+  ARG_INTRA_REFRESH,
+  ARG_VBV_BUF_CAPACITY,
+  ARG_ME,
+  ARG_SUBME,
+  ARG_ANALYSE,
+  ARG_DCT8x8,
+  ARG_REF,
+  ARG_BFRAMES,
+  ARG_B_ADAPT,
+  ARG_B_PYRAMID,
+  ARG_WEIGHTB,
+  ARG_SPS_ID,
+  ARG_AU_NALU,
+  ARG_TRELLIS,
+  ARG_KEYINT_MAX,
+  ARG_CABAC,
+  ARG_QP_MIN,
+  ARG_QP_MAX,
+  ARG_QP_STEP,
+  ARG_IP_FACTOR,
+  ARG_PB_FACTOR,
+  ARG_RC_MB_TREE,
+  ARG_RC_LOOKAHEAD,
+  ARG_NR,
+  ARG_INTERLACED,
+  ARG_OPTION_STRING,
+  ARG_SPEED_PRESET,
+  ARG_PSY_TUNE,
+  ARG_TUNE,
+};
+
+#define ARG_THREADS_DEFAULT            0        /* 0 means 'auto' which is 1.5x number of CPU cores */
+#define ARG_PASS_DEFAULT               0
+#define ARG_QUANTIZER_DEFAULT          21
+#define ARG_MULTIPASS_CACHE_FILE_DEFAULT "x264.log"
+#define ARG_BYTE_STREAM_DEFAULT        FALSE
+#define ARG_BITRATE_DEFAULT            (2 * 1024)
+#define ARG_VBV_BUF_CAPACITY_DEFAULT   600
+#define ARG_ME_DEFAULT                 X264_ME_HEX
+#define ARG_SUBME_DEFAULT              1
+#define ARG_ANALYSE_DEFAULT            0
+#define ARG_DCT8x8_DEFAULT             FALSE
+#define ARG_REF_DEFAULT                1
+#define ARG_BFRAMES_DEFAULT            0
+#define ARG_B_ADAPT_DEFAULT            TRUE
+#define ARG_B_PYRAMID_DEFAULT          FALSE
+#define ARG_WEIGHTB_DEFAULT            FALSE
+#define ARG_SPS_ID_DEFAULT             0
+#define ARG_AU_NALU_DEFAULT            TRUE
+#define ARG_TRELLIS_DEFAULT            TRUE
+#define ARG_KEYINT_MAX_DEFAULT         0
+#define ARG_CABAC_DEFAULT              TRUE
+#define ARG_QP_MIN_DEFAULT             10
+#define ARG_QP_MAX_DEFAULT             51
+#define ARG_QP_STEP_DEFAULT            4
+#define ARG_IP_FACTOR_DEFAULT          1.4
+#define ARG_PB_FACTOR_DEFAULT          1.3
+#define ARG_NR_DEFAULT                 0
+#define ARG_INTERLACED_DEFAULT         FALSE
+#define ARG_SLICED_THREADS_DEFAULT     FALSE
+#define ARG_SYNC_LOOKAHEAD_DEFAULT     -1
+#define ARG_RC_MB_TREE_DEFAULT         TRUE
+#define ARG_RC_LOOKAHEAD_DEFAULT       40
+#define ARG_INTRA_REFRESH_DEFAULT      FALSE
+#define ARG_OPTION_STRING_DEFAULT      ""
+static GString *x264enc_defaults;
+#define ARG_SPEED_PRESET_DEFAULT       6        /* 'medium' preset - matches x264 CLI default */
+#define ARG_PSY_TUNE_DEFAULT           0        /* no psy tuning */
+#define ARG_TUNE_DEFAULT               0        /* no tuning */
+
+enum
+{
+  GST_X264_ENC_STREAM_FORMAT_FROM_PROPERTY,
+  GST_X264_ENC_STREAM_FORMAT_AVC,
+  GST_X264_ENC_STREAM_FORMAT_BYTE_STREAM
+};
+
+enum
+{
+  GST_X264_ENC_PASS_CBR = 0,
+  GST_X264_ENC_PASS_QUANT = 0x04,
+  GST_X264_ENC_PASS_QUAL,
+  GST_X264_ENC_PASS_PASS1 = 0x11,
+  GST_X264_ENC_PASS_PASS2,
+  GST_X264_ENC_PASS_PASS3
+};
+
+#define GST_X264_ENC_PASS_TYPE (gst_x264_enc_pass_get_type())
+static GType
+gst_x264_enc_pass_get_type (void)
+{
+  static GType pass_type = 0;
+
+  static const GEnumValue pass_types[] = {
+    {GST_X264_ENC_PASS_CBR, "Constant Bitrate Encoding", "cbr"},
+    {GST_X264_ENC_PASS_QUANT, "Constant Quantizer (debugging only)", "quant"},
+    {GST_X264_ENC_PASS_QUAL, "Constant Quality", "qual"},
+    {GST_X264_ENC_PASS_PASS1, "VBR Encoding - Pass 1", "pass1"},
+    {GST_X264_ENC_PASS_PASS2, "VBR Encoding - Pass 2", "pass2"},
+    {GST_X264_ENC_PASS_PASS3, "VBR Encoding - Pass 3", "pass3"},
+    {0, NULL, NULL}
+  };
+
+  if (!pass_type) {
+    pass_type = g_enum_register_static ("GstX264EncPass", pass_types);
+  }
+  return pass_type;
+}
+
+#define GST_X264_ENC_ME_TYPE (gst_x264_enc_me_get_type())
+static GType
+gst_x264_enc_me_get_type (void)
+{
+  static GType me_type = 0;
+  static GEnumValue *me_types;
+  int n, i;
+
+  if (me_type != 0)
+    return me_type;
+
+  n = 0;
+  while (x264_motion_est_names[n] != NULL)
+    n++;
+
+  me_types = g_new0 (GEnumValue, n + 1);
+
+  for (i = 0; i < n; i++) {
+    me_types[i].value = i;
+    me_types[i].value_name = x264_motion_est_names[i];
+    me_types[i].value_nick = x264_motion_est_names[i];
+  }
+
+  me_type = g_enum_register_static ("GstX264EncMe", me_types);
+
+  return me_type;
+}
+
+#define GST_X264_ENC_ANALYSE_TYPE (gst_x264_enc_analyse_get_type())
+static GType
+gst_x264_enc_analyse_get_type (void)
+{
+  static GType analyse_type = 0;
+  static const GFlagsValue analyse_types[] = {
+    {X264_ANALYSE_I4x4, "i4x4", "i4x4"},
+    {X264_ANALYSE_I8x8, "i8x8", "i8x8"},
+    {X264_ANALYSE_PSUB16x16, "p8x8", "p8x8"},
+    {X264_ANALYSE_PSUB8x8, "p4x4", "p4x4"},
+    {X264_ANALYSE_BSUB16x16, "b8x8", "b8x8"},
+    {0, NULL, NULL},
+  };
+
+  if (!analyse_type) {
+    analyse_type = g_flags_register_static ("GstX264EncAnalyse", analyse_types);
+  }
+  return analyse_type;
+}
+
+#ifdef X264_PRESETS
+
+#define GST_X264_ENC_SPEED_PRESET_TYPE (gst_x264_enc_speed_preset_get_type())
+static GType
+gst_x264_enc_speed_preset_get_type (void)
+{
+  static GType speed_preset_type = 0;
+  static GEnumValue *speed_preset_types;
+  int n, i;
+
+  if (speed_preset_type != 0)
+    return speed_preset_type;
+
+  n = 0;
+  while (x264_preset_names[n] != NULL)
+    n++;
+
+  speed_preset_types = g_new0 (GEnumValue, n + 2);
+
+  speed_preset_types[0].value = 0;
+  speed_preset_types[0].value_name = "No preset";
+  speed_preset_types[0].value_nick = "None";
+
+  for (i = 1; i <= n; i++) {
+    speed_preset_types[i].value = i;
+    speed_preset_types[i].value_name = x264_preset_names[i - 1];
+    speed_preset_types[i].value_nick = x264_preset_names[i - 1];
+  }
+
+  speed_preset_type =
+      g_enum_register_static ("GstX264EncPreset", speed_preset_types);
+
+  return speed_preset_type;
+}
+
+static const GFlagsValue tune_types[] = {
+  {0x0, "No tuning", "none"},
+  {0x1, "Still image", "stillimage"},
+  {0x2, "Fast decode", "fastdecode"},
+  {0x4, "Zero latency (requires constant framerate)", "zerolatency"},
+  {0, NULL, NULL},
+};
+
+#define GST_X264_ENC_TUNE_TYPE (gst_x264_enc_tune_get_type())
+static GType
+gst_x264_enc_tune_get_type (void)
+{
+  static GType tune_type = 0;
+
+  if (!tune_type) {
+    tune_type = g_flags_register_static ("GstX264EncTune", tune_types + 1);
+  }
+  return tune_type;
+}
+
+enum
+{
+  GST_X264_ENC_TUNE_NONE,
+  GST_X264_ENC_TUNE_FILM,
+  GST_X264_ENC_TUNE_ANIMATION,
+  GST_X264_ENC_TUNE_GRAIN,
+  GST_X264_ENC_TUNE_PSNR,
+  GST_X264_ENC_TUNE_SSIM,
+  GST_X264_ENC_TUNE_LAST
+};
+
+static const GEnumValue psy_tune_types[] = {
+  {GST_X264_ENC_TUNE_NONE, "No tuning", "none"},
+  {GST_X264_ENC_TUNE_FILM, "Film", "film"},
+  {GST_X264_ENC_TUNE_ANIMATION, "Animation", "animation"},
+  {GST_X264_ENC_TUNE_GRAIN, "Grain", "grain"},
+  {GST_X264_ENC_TUNE_PSNR, "PSNR", "psnr"},
+  {GST_X264_ENC_TUNE_SSIM, "SSIM", "ssim"},
+  {0, NULL, NULL},
+};
+
+#define GST_X264_ENC_PSY_TUNE_TYPE (gst_x264_enc_psy_tune_get_type())
+static GType
+gst_x264_enc_psy_tune_get_type (void)
+{
+  static GType psy_tune_type = 0;
+
+  if (!psy_tune_type) {
+    psy_tune_type =
+        g_enum_register_static ("GstX264EncPsyTune", psy_tune_types);
+  }
+  return psy_tune_type;
+}
+
+static void
+gst_x264_enc_build_tunings_string (GstX264Enc * x264enc)
+{
+  int i = 1;
+
+  if (x264enc->tunings)
+    g_string_free (x264enc->tunings, TRUE);
+
+  if (x264enc->psy_tune) {
+    x264enc->tunings =
+        g_string_new (psy_tune_types[x264enc->psy_tune].value_nick);
+  } else {
+    x264enc->tunings = g_string_new (NULL);
+  }
+
+  while (tune_types[i].value_name) {
+    if (x264enc->tune & (1 << (i - 1)))
+      g_string_append_printf (x264enc->tunings, "%s%s",
+          x264enc->tunings->len ? "," : "", tune_types[i].value_nick);
+    i++;
+  }
+
+  if (x264enc->tunings->len)
+    GST_DEBUG_OBJECT (x264enc, "Constructed tunings string: %s",
+        x264enc->tunings->str);
+}
+
+#endif
+
+
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("video/x-raw, "
+        "format = (string) { I420, YV12 }, "
+        "framerate = (fraction) [0, MAX], "
+        "width = (int) [ 16, MAX ], " "height = (int) [ 16, MAX ]")
+    );
+
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("video/x-h264, "
+        "framerate = (fraction) [0/1, MAX], "
+        "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ], "
+        "stream-format = (string) { byte-stream, avc }, "
+        "alignment = (string) { au }, "
+        "profile = (string) { high-10, high, main, baseline, "
+        "constrained-baseline, high-10-intra }")
+    );
+
+static void gst_x264_enc_finalize (GObject * object);
+static void gst_x264_enc_reset (GstX264Enc * encoder);
+
+static gboolean gst_x264_enc_init_encoder (GstX264Enc * encoder);
+static void gst_x264_enc_close_encoder (GstX264Enc * encoder);
+
+static gboolean gst_x264_enc_sink_set_caps (GstPad * pad, GstCaps * caps);
+static GstCaps *gst_x264_enc_sink_get_caps (GstPad * pad, GstCaps * filter);
+static gboolean gst_x264_enc_sink_event (GstPad * pad, GstObject * parent,
+    GstEvent * event);
+static gboolean gst_x264_enc_sink_query (GstPad * pad, GstObject * parent,
+    GstQuery * query);
+static gboolean gst_x264_enc_src_event (GstPad * pad, GstObject * parent,
+    GstEvent * event);
+static GstFlowReturn gst_x264_enc_chain (GstPad * pad, GstObject * parent,
+    GstBuffer * buf);
+static void gst_x264_enc_flush_frames (GstX264Enc * encoder, gboolean send);
+static GstFlowReturn gst_x264_enc_encode_frame (GstX264Enc * encoder,
+    x264_picture_t * pic_in, int *i_nal, gboolean send);
+static GstStateChangeReturn gst_x264_enc_change_state (GstElement * element,
+    GstStateChange transition);
+
+static void gst_x264_enc_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec);
+static void gst_x264_enc_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec);
+
+#define gst_x264_enc_parent_class parent_class
+G_DEFINE_TYPE_WITH_CODE (GstX264Enc, gst_x264_enc, GST_TYPE_ELEMENT,
+    G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL));
+
+/* don't forget to free the string after use */
+static const gchar *
+gst_x264_enc_build_partitions (gint analyse)
+{
+  GString *string;
+
+  if (!analyse)
+    return NULL;
+
+  string = g_string_new (NULL);
+  if (analyse & X264_ANALYSE_I4x4)
+    g_string_append (string, "i4x4");
+  if (analyse & X264_ANALYSE_I8x8)
+    g_string_append (string, ",i8x8");
+  if (analyse & X264_ANALYSE_PSUB16x16)
+    g_string_append (string, ",p8x8");
+  if (analyse & X264_ANALYSE_PSUB8x8)
+    g_string_append (string, ",p4x4");
+  if (analyse & X264_ANALYSE_BSUB16x16)
+    g_string_append (string, ",b8x8");
+
+  return (const gchar *) g_string_free (string, FALSE);
+}
+
+static void
+gst_x264_enc_class_init (GstX264EncClass * klass)
+{
+  GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
+
+  const gchar *partitions = NULL;
+
+  x264enc_defaults = g_string_new ("");
+
+  gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
+
+  gobject_class->set_property = gst_x264_enc_set_property;
+  gobject_class->get_property = gst_x264_enc_get_property;
+  gobject_class->finalize = gst_x264_enc_finalize;
+
+  /* options for which we don't use string equivalents */
+  g_object_class_install_property (gobject_class, ARG_PASS,
+      g_param_spec_enum ("pass", "Encoding pass/type",
+          "Encoding pass/type", GST_X264_ENC_PASS_TYPE,
+          ARG_PASS_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (gobject_class, ARG_QUANTIZER,
+      g_param_spec_uint ("quantizer", "Constant Quantizer",
+          "Constant quantizer or quality to apply",
+          1, 50, ARG_QUANTIZER_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (gobject_class, ARG_BITRATE,
+      g_param_spec_uint ("bitrate", "Bitrate", "Bitrate in kbit/sec", 1,
+          100 * 1024, ARG_BITRATE_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+          GST_PARAM_MUTABLE_PLAYING));
+  g_object_class_install_property (gobject_class, ARG_VBV_BUF_CAPACITY,
+      g_param_spec_uint ("vbv-buf-capacity", "VBV buffer capacity",
+          "Size of the VBV buffer in milliseconds",
+          0, 10000, ARG_VBV_BUF_CAPACITY_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+          GST_PARAM_MUTABLE_PLAYING));
+
+#ifdef X264_PRESETS
+  g_object_class_install_property (gobject_class, ARG_SPEED_PRESET,
+      g_param_spec_enum ("speed-preset", "Speed/quality preset",
+          "Preset name for speed/quality tradeoff options (can affect decode "
+          "compatibility - impose restrictions separately for your target decoder)",
+          GST_X264_ENC_SPEED_PRESET_TYPE, ARG_SPEED_PRESET_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (gobject_class, ARG_PSY_TUNE,
+      g_param_spec_enum ("psy-tune", "Psychovisual tuning preset",
+          "Preset name for psychovisual tuning options",
+          GST_X264_ENC_PSY_TUNE_TYPE, ARG_PSY_TUNE_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (gobject_class, ARG_TUNE,
+      g_param_spec_flags ("tune", "Content tuning preset",
+          "Preset name for non-psychovisual tuning options",
+          GST_X264_ENC_TUNE_TYPE, ARG_TUNE_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+#endif /* X264_PRESETS */
+  g_object_class_install_property (gobject_class, ARG_OPTION_STRING,
+      g_param_spec_string ("option-string", "Option string",
+          "String of x264 options (overridden by element properties)",
+          ARG_OPTION_STRING_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  /* options for which we _do_ use string equivalents */
+  g_object_class_install_property (gobject_class, ARG_THREADS,
+      g_param_spec_uint ("threads", "Threads",
+          "Number of threads used by the codec (0 for automatic)",
+          0, 4, ARG_THREADS_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /* NOTE: this first string append doesn't require the ':' delimiter but the
+   * rest do */
+  g_string_append_printf (x264enc_defaults, "threads=%d", ARG_THREADS_DEFAULT);
+#ifdef X264_ENH_THREADING
+  g_object_class_install_property (gobject_class, ARG_SLICED_THREADS,
+      g_param_spec_boolean ("sliced-threads", "Sliced Threads",
+          "Low latency but lower efficiency threading",
+          ARG_SLICED_THREADS_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":sliced-threads=%d",
+      ARG_SLICED_THREADS_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_SYNC_LOOKAHEAD,
+      g_param_spec_int ("sync-lookahead", "Sync Lookahead",
+          "Number of buffer frames for threaded lookahead (-1 for automatic)",
+          -1, 250, ARG_SYNC_LOOKAHEAD_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":sync-lookahead=%d",
+      ARG_SYNC_LOOKAHEAD_DEFAULT);
+#endif
+  g_object_class_install_property (gobject_class, ARG_MULTIPASS_CACHE_FILE,
+      g_param_spec_string ("multipass-cache-file", "Multipass Cache File",
+          "Filename for multipass cache file",
+          ARG_MULTIPASS_CACHE_FILE_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":stats=%s",
+      ARG_MULTIPASS_CACHE_FILE_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_BYTE_STREAM,
+      g_param_spec_boolean ("byte-stream", "Byte Stream",
+          "Generate byte stream format of NALU", ARG_BYTE_STREAM_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":annexb=%d",
+      ARG_BYTE_STREAM_DEFAULT);
+#ifdef X264_INTRA_REFRESH
+  g_object_class_install_property (gobject_class, ARG_INTRA_REFRESH,
+      g_param_spec_boolean ("intra-refresh", "Intra Refresh",
+          "Use Periodic Intra Refresh instead of IDR frames",
+          ARG_INTRA_REFRESH_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":intra-refresh=%d",
+      ARG_INTRA_REFRESH_DEFAULT);
+#endif
+  g_object_class_install_property (gobject_class, ARG_ME,
+      g_param_spec_enum ("me", "Motion Estimation",
+          "Integer pixel motion estimation method", GST_X264_ENC_ME_TYPE,
+          ARG_ME_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":me=%s",
+      x264_motion_est_names[ARG_ME_DEFAULT]);
+  g_object_class_install_property (gobject_class, ARG_SUBME,
+      g_param_spec_uint ("subme", "Subpixel Motion Estimation",
+          "Subpixel motion estimation and partition decision quality: 1=fast, 10=best",
+          1, 10, ARG_SUBME_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":subme=%d", ARG_SUBME_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_ANALYSE,
+      g_param_spec_flags ("analyse", "Analyse", "Partitions to consider",
+          GST_X264_ENC_ANALYSE_TYPE, ARG_ANALYSE_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  partitions = gst_x264_enc_build_partitions (ARG_ANALYSE_DEFAULT);
+  if (partitions) {
+    g_string_append_printf (x264enc_defaults, ":partitions=%s", partitions);
+    g_free ((gpointer) partitions);
+  }
+  g_object_class_install_property (gobject_class, ARG_DCT8x8,
+      g_param_spec_boolean ("dct8x8", "DCT8x8",
+          "Adaptive spatial transform size", ARG_DCT8x8_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":8x8dct=%d", ARG_DCT8x8_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_REF,
+      g_param_spec_uint ("ref", "Reference Frames",
+          "Number of reference frames",
+          1, 12, ARG_REF_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":ref=%d", ARG_REF_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_BFRAMES,
+      g_param_spec_uint ("bframes", "B-Frames",
+          "Number of B-frames between I and P",
+          0, 4, ARG_BFRAMES_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":bframes=%d", ARG_BFRAMES_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_B_ADAPT,
+      g_param_spec_boolean ("b-adapt", "B-Adapt",
+          "Automatically decide how many B-frames to use",
+          ARG_B_ADAPT_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":b-adapt=%d", ARG_B_ADAPT_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_B_PYRAMID,
+      g_param_spec_boolean ("b-pyramid", "B-Pyramid",
+          "Keep some B-frames as references", ARG_B_PYRAMID_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+#ifdef X264_B_PYRAMID
+  g_string_append_printf (x264enc_defaults, ":b-pyramid=%s",
+      x264_b_pyramid_names[ARG_B_PYRAMID_DEFAULT]);
+#else
+  g_string_append_printf (x264enc_defaults, ":b-pyramid=%d",
+      ARG_B_PYRAMID_DEFAULT);
+#endif /* X264_B_PYRAMID */
+  g_object_class_install_property (gobject_class, ARG_WEIGHTB,
+      g_param_spec_boolean ("weightb", "Weighted B-Frames",
+          "Weighted prediction for B-frames", ARG_WEIGHTB_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":weightb=%d", ARG_WEIGHTB_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_SPS_ID,
+      g_param_spec_uint ("sps-id", "SPS ID",
+          "SPS and PPS ID number",
+          0, 31, ARG_SPS_ID_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":sps-id=%d", ARG_SPS_ID_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_AU_NALU,
+      g_param_spec_boolean ("aud", "AUD",
+          "Use AU (Access Unit) delimiter", ARG_AU_NALU_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":aud=%d", ARG_AU_NALU_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_TRELLIS,
+      g_param_spec_boolean ("trellis", "Trellis quantization",
+          "Enable trellis searched quantization", ARG_TRELLIS_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":trellis=%d", ARG_TRELLIS_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_KEYINT_MAX,
+      g_param_spec_uint ("key-int-max", "Key-frame maximal interval",
+          "Maximal distance between two key-frames (0 for automatic)",
+          0, G_MAXINT, ARG_KEYINT_MAX_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":keyint=%d",
+      ARG_KEYINT_MAX_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_CABAC,
+      g_param_spec_boolean ("cabac", "Use CABAC", "Enable CABAC entropy coding",
+          ARG_CABAC_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":cabac=%d", ARG_CABAC_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_QP_MIN,
+      g_param_spec_uint ("qp-min", "Minimum Quantizer",
+          "Minimum quantizer", 1, 51, ARG_QP_MIN_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":qpmin=%d", ARG_QP_MIN_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_QP_MAX,
+      g_param_spec_uint ("qp-max", "Maximum Quantizer",
+          "Maximum quantizer", 1, 51, ARG_QP_MAX_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":qpmax=%d", ARG_QP_MAX_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_QP_STEP,
+      g_param_spec_uint ("qp-step", "Maximum Quantizer Difference",
+          "Maximum quantizer difference between frames",
+          1, 50, ARG_QP_STEP_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":qpstep=%d", ARG_QP_STEP_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_IP_FACTOR,
+      g_param_spec_float ("ip-factor", "IP-Factor",
+          "Quantizer factor between I- and P-frames",
+          0, 2, ARG_IP_FACTOR_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":ip-factor=%f",
+      ARG_IP_FACTOR_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_PB_FACTOR,
+      g_param_spec_float ("pb-factor", "PB-Factor",
+          "Quantizer factor between P- and B-frames", 0, 2,
+          ARG_PB_FACTOR_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":pb-factor=%f",
+      ARG_PB_FACTOR_DEFAULT);
+#ifdef X264_MB_RC
+  g_object_class_install_property (gobject_class, ARG_RC_MB_TREE,
+      g_param_spec_boolean ("mb-tree", "Macroblock Tree",
+          "Macroblock-Tree ratecontrol",
+          ARG_RC_MB_TREE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":mbtree=%d",
+      ARG_RC_MB_TREE_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_RC_LOOKAHEAD,
+      g_param_spec_int ("rc-lookahead", "Rate Control Lookahead",
+          "Number of frames for frametype lookahead", 0, 250,
+          ARG_RC_LOOKAHEAD_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":rc-lookahead=%d",
+      ARG_RC_LOOKAHEAD_DEFAULT);
+#endif
+  g_object_class_install_property (gobject_class, ARG_NR,
+      g_param_spec_uint ("noise-reduction", "Noise Reduction",
+          "Noise reduction strength",
+          0, 100000, ARG_NR_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":nr=%d", ARG_NR_DEFAULT);
+  g_object_class_install_property (gobject_class, ARG_INTERLACED,
+      g_param_spec_boolean ("interlaced", "Interlaced",
+          "Interlaced material", ARG_INTERLACED_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  g_string_append_printf (x264enc_defaults, ":interlaced=%d",
+      ARG_INTERLACED_DEFAULT);
+
+  /* append deblock parameters */
+  g_string_append_printf (x264enc_defaults, ":deblock=0,0");
+  /* append weighted prediction parameter */
+  g_string_append_printf (x264enc_defaults, ":weightp=0");
+
+  gst_element_class_set_static_metadata (gstelement_class,
+      "x264enc", "Codec/Encoder/Video", "H264 Encoder",
+      "Josef Zlomek <josef.zlomek@itonis.tv>, "
+      "Mark Nauwelaerts <mnauw@users.sf.net>");
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&src_factory));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sink_factory));
+
+  gstelement_class->change_state =
+      GST_DEBUG_FUNCPTR (gst_x264_enc_change_state);
+}
+
+static void
+gst_x264_enc_log_callback (gpointer private, gint level, const char *format,
+    va_list args)
+{
+#ifndef GST_DISABLE_GST_DEBUG
+  GstDebugLevel gst_level;
+  GObject *object = (GObject *) private;
+
+  switch (level) {
+    case X264_LOG_NONE:
+      gst_level = GST_LEVEL_NONE;
+      break;
+    case X264_LOG_ERROR:
+      gst_level = GST_LEVEL_ERROR;
+      break;
+    case X264_LOG_WARNING:
+      gst_level = GST_LEVEL_WARNING;
+      break;
+    case X264_LOG_INFO:
+      gst_level = GST_LEVEL_INFO;
+      break;
+    default:
+      /* push x264enc debug down to our lower levels to avoid some clutter */
+      gst_level = GST_LEVEL_LOG;
+      break;
+  }
+
+  gst_debug_log_valist (x264_enc_debug, gst_level, "", "", 0, object, format,
+      args);
+#endif /* GST_DISABLE_GST_DEBUG */
+}
+
+/* initialize the new element
+ * instantiate pads and add them to element
+ * set functions
+ * initialize structure
+ */
+static void
+gst_x264_enc_init (GstX264Enc * encoder)
+{
+  encoder->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
+  gst_pad_set_event_function (encoder->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_x264_enc_sink_event));
+  gst_pad_set_chain_function (encoder->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_x264_enc_chain));
+  gst_pad_set_query_function (encoder->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_x264_enc_sink_query));
+  gst_element_add_pad (GST_ELEMENT (encoder), encoder->sinkpad);
+
+  encoder->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
+  gst_pad_use_fixed_caps (encoder->srcpad);
+  gst_element_add_pad (GST_ELEMENT (encoder), encoder->srcpad);
+
+  gst_pad_set_event_function (encoder->srcpad,
+      GST_DEBUG_FUNCPTR (gst_x264_enc_src_event));
+
+  /* properties */
+  encoder->threads = ARG_THREADS_DEFAULT;
+  encoder->sliced_threads = ARG_SLICED_THREADS_DEFAULT;
+  encoder->sync_lookahead = ARG_SYNC_LOOKAHEAD_DEFAULT;
+  encoder->pass = ARG_PASS_DEFAULT;
+  encoder->quantizer = ARG_QUANTIZER_DEFAULT;
+  encoder->mp_cache_file = g_strdup (ARG_MULTIPASS_CACHE_FILE_DEFAULT);
+  encoder->byte_stream = ARG_BYTE_STREAM_DEFAULT;
+  encoder->bitrate = ARG_BITRATE_DEFAULT;
+  encoder->intra_refresh = ARG_INTRA_REFRESH_DEFAULT;
+  encoder->vbv_buf_capacity = ARG_VBV_BUF_CAPACITY_DEFAULT;
+  encoder->me = ARG_ME_DEFAULT;
+  encoder->subme = ARG_SUBME_DEFAULT;
+  encoder->analyse = ARG_ANALYSE_DEFAULT;
+  encoder->dct8x8 = ARG_DCT8x8_DEFAULT;
+  encoder->ref = ARG_REF_DEFAULT;
+  encoder->bframes = ARG_BFRAMES_DEFAULT;
+  encoder->b_adapt = ARG_B_ADAPT_DEFAULT;
+  encoder->b_pyramid = ARG_B_PYRAMID_DEFAULT;
+  encoder->weightb = ARG_WEIGHTB_DEFAULT;
+  encoder->sps_id = ARG_SPS_ID_DEFAULT;
+  encoder->au_nalu = ARG_AU_NALU_DEFAULT;
+  encoder->trellis = ARG_TRELLIS_DEFAULT;
+  encoder->keyint_max = ARG_KEYINT_MAX_DEFAULT;
+  encoder->cabac = ARG_CABAC_DEFAULT;
+  encoder->qp_min = ARG_QP_MIN_DEFAULT;
+  encoder->qp_max = ARG_QP_MAX_DEFAULT;
+  encoder->qp_step = ARG_QP_STEP_DEFAULT;
+  encoder->ip_factor = ARG_IP_FACTOR_DEFAULT;
+  encoder->pb_factor = ARG_PB_FACTOR_DEFAULT;
+  encoder->mb_tree = ARG_RC_MB_TREE_DEFAULT;
+  encoder->rc_lookahead = ARG_RC_LOOKAHEAD_DEFAULT;
+  encoder->noise_reduction = ARG_NR_DEFAULT;
+  encoder->interlaced = ARG_INTERLACED_DEFAULT;
+  encoder->option_string = g_string_new (NULL);
+  encoder->option_string_prop = g_string_new (ARG_OPTION_STRING_DEFAULT);
+  encoder->speed_preset = ARG_SPEED_PRESET_DEFAULT;
+  encoder->psy_tune = ARG_PSY_TUNE_DEFAULT;
+  encoder->tune = ARG_TUNE_DEFAULT;
+
+  /* resources */
+  encoder->delay = g_queue_new ();
+  encoder->buffer_size = 100000;
+  encoder->buffer = g_malloc (encoder->buffer_size);
+
+  x264_param_default (&encoder->x264param);
+
+  /* log callback setup; part of parameters */
+  encoder->x264param.pf_log = gst_x264_enc_log_callback;
+  encoder->x264param.p_log_private = encoder;
+  encoder->x264param.i_log_level = X264_LOG_DEBUG;
+
+  gst_segment_init (&encoder->segment, GST_FORMAT_TIME);
+  encoder->force_key_unit_event = NULL;
+  gst_x264_enc_reset (encoder);
+}
+
+static void
+gst_x264_enc_reset (GstX264Enc * encoder)
+{
+  encoder->x264enc = NULL;
+  gst_video_info_init (&encoder->info);
+  encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_FROM_PROPERTY;
+  gst_segment_init (&encoder->segment, GST_FORMAT_UNDEFINED);
+
+  GST_OBJECT_LOCK (encoder);
+  gst_event_replace (&encoder->force_key_unit_event, NULL);
+  encoder->pending_key_unit_ts = GST_CLOCK_TIME_NONE;
+  GST_OBJECT_UNLOCK (encoder);
+}
+
+static void
+gst_x264_enc_finalize (GObject * object)
+{
+  GstX264Enc *encoder = GST_X264_ENC (object);
+
+#define FREE_STRING(ptr) \
+  if (ptr) \
+    g_string_free (ptr, TRUE);
+
+  FREE_STRING (encoder->tunings);
+  FREE_STRING (encoder->option_string);
+  FREE_STRING (encoder->option_string_prop);
+
+#undef FREE_STRING
+
+  g_free (encoder->mp_cache_file);
+  encoder->mp_cache_file = NULL;
+  g_free (encoder->buffer);
+  encoder->buffer = NULL;
+  g_queue_free (encoder->delay);
+  encoder->delay = NULL;
+
+  gst_x264_enc_close_encoder (encoder);
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/*
+ * gst_x264_enc_parse_options
+ * @encoder: Encoder to which options are assigned
+ * @str: Option string
+ *
+ * Parse option string and assign to x264 parameters
+ *
+ */
+static gboolean
+gst_x264_enc_parse_options (GstX264Enc * encoder, const gchar * str)
+{
+  GStrv kvpairs;
+  guint npairs, i;
+  gint parse_result = 0, ret = 0;
+  gchar *options = (gchar *) str;
+
+  while (*options == ':')
+    options++;
+
+  kvpairs = g_strsplit (options, ":", 0);
+  npairs = g_strv_length (kvpairs);
+
+  for (i = 0; i < npairs; i++) {
+    GStrv key_val = g_strsplit (kvpairs[i], "=", 2);
+
+    parse_result =
+        x264_param_parse (&encoder->x264param, key_val[0], key_val[1]);
+
+    if (parse_result == X264_PARAM_BAD_NAME) {
+      GST_ERROR_OBJECT (encoder, "Bad name for option %s=%s",
+          key_val[0] ? key_val[0] : "", key_val[1] ? key_val[1] : "");
+    }
+    if (parse_result == X264_PARAM_BAD_VALUE) {
+      GST_ERROR_OBJECT (encoder,
+          "Bad value for option %s=%s (Note: a NULL value for a non-boolean triggers this)",
+          key_val[0] ? key_val[0] : "", key_val[1] ? key_val[1] : "");
+    }
+
+    g_strfreev (key_val);
+
+    if (parse_result)
+      ret++;
+  }
+
+  g_strfreev (kvpairs);
+  return !ret;
+}
+
+/*
+ * gst_x264_enc_init_encoder
+ * @encoder:  Encoder which should be initialized.
+ *
+ * Initialize x264 encoder.
+ *
+ */
+static gboolean
+gst_x264_enc_init_encoder (GstX264Enc * encoder)
+{
+  guint pass = 0;
+  gint width, height, fps_n, fps_d;
+
+  /* make sure that the encoder is closed */
+  gst_x264_enc_close_encoder (encoder);
+
+  GST_OBJECT_LOCK (encoder);
+
+#ifdef X264_PRESETS
+  gst_x264_enc_build_tunings_string (encoder);
+
+  /* set x264 parameters and use preset/tuning if present */
+  GST_DEBUG_OBJECT (encoder, "Applying defaults with preset %s, tunings %s",
+      encoder->speed_preset ? x264_preset_names[encoder->speed_preset - 1] : "",
+      encoder->tunings && encoder->tunings->len ? encoder->tunings->str : "");
+  x264_param_default_preset (&encoder->x264param,
+      encoder->speed_preset ? x264_preset_names[encoder->speed_preset -
+          1] : NULL, encoder->tunings
+      && encoder->tunings->len ? encoder->tunings->str : NULL);
+
+  /* log callback setup; part of parameters
+   * this needs to be done again after every *param_default* () call */
+  encoder->x264param.pf_log = gst_x264_enc_log_callback;
+  encoder->x264param.p_log_private = encoder;
+  encoder->x264param.i_log_level = X264_LOG_DEBUG;
+
+  /* if no preset nor tuning, use property defaults */
+  if (!encoder->speed_preset && !encoder->tunings->len) {
+#endif /* X264_PRESETS */
+    GST_DEBUG_OBJECT (encoder, "Applying x264enc_defaults");
+    if (x264enc_defaults->len
+        && gst_x264_enc_parse_options (encoder,
+            x264enc_defaults->str) == FALSE) {
+      GST_DEBUG_OBJECT (encoder,
+          "x264enc_defaults string contains errors. This is a bug.");
+      goto unlock_and_return;
+    }
+#ifdef X264_PRESETS
+  } else {
+    /* When using presets we need to respect the default output format */
+    encoder->x264param.b_aud = encoder->au_nalu;
+    encoder->x264param.b_annexb = encoder->byte_stream;
+  }
+#endif /* X264_PRESETS */
+
+#if X264_BUILD >= 81
+  /* setup appropriate timebase for gstreamer */
+  encoder->x264param.i_timebase_num = 1;
+  encoder->x264param.i_timebase_den = 1000000000;
+#endif
+
+  /* apply option-string property */
+  if (encoder->option_string_prop && encoder->option_string_prop->len) {
+    GST_DEBUG_OBJECT (encoder, "Applying option-string: %s",
+        encoder->option_string_prop->str);
+    if (gst_x264_enc_parse_options (encoder,
+            encoder->option_string_prop->str) == FALSE) {
+      GST_DEBUG_OBJECT (encoder, "Your option-string contains errors.");
+      goto unlock_and_return;
+    }
+  }
+  /* apply user-set options */
+  if (encoder->option_string && encoder->option_string->len) {
+    GST_DEBUG_OBJECT (encoder, "Applying user-set options: %s",
+        encoder->option_string->str);
+    if (gst_x264_enc_parse_options (encoder,
+            encoder->option_string->str) == FALSE) {
+      GST_DEBUG_OBJECT (encoder, "Failed to parse internal option string. "
+          "This could be due to use of an old libx264 version. Option string "
+          "was: %s", encoder->option_string->str);
+    }
+  }
+
+  width = GST_VIDEO_INFO_WIDTH (&encoder->info);
+  height = GST_VIDEO_INFO_HEIGHT (&encoder->info);
+  fps_n = GST_VIDEO_INFO_FPS_N (&encoder->info);
+  fps_d = GST_VIDEO_INFO_FPS_D (&encoder->info);
+  /* set up encoder parameters */
+
+
+  encoder->x264param.i_fps_num = fps_n;
+  encoder->x264param.i_fps_den = fps_d;
+  encoder->x264param.i_width = width;
+  encoder->x264param.i_height = height;
+  if (GST_VIDEO_INFO_PAR_D (&encoder->info) > 0) {
+    encoder->x264param.vui.i_sar_width = GST_VIDEO_INFO_PAR_N (&encoder->info);
+    encoder->x264param.vui.i_sar_height = GST_VIDEO_INFO_PAR_D (&encoder->info);
+  }
+  /* FIXME 0.11 : 2s default keyframe interval seems excessive
+   * (10s is x264 default) */
+  encoder->x264param.i_keyint_max = encoder->keyint_max ? encoder->keyint_max :
+      (2 * fps_n / fps_d);
+
+  if ((((height == 576) && ((width == 720)
+                  || (width == 704) || (width == 352)))
+          || ((height == 288) && (width == 352)))
+      && (fps_d == 1) && (fps_n == 25)) {
+    encoder->x264param.vui.i_vidformat = 1;     /* PAL */
+  } else if ((((height == 480) && ((width == 720)
+                  || (width == 704) || (width == 352)))
+          || ((height == 240) && (width == 352)))
+      && (fps_d == 1001) && ((fps_n == 30000)
+          || (fps_n == 24000))) {
+    encoder->x264param.vui.i_vidformat = 2;     /* NTSC */
+  } else
+    encoder->x264param.vui.i_vidformat = 5;     /* unspecified */
+
+  encoder->x264param.analyse.b_psnr = 0;
+
+  switch (encoder->pass) {
+    case GST_X264_ENC_PASS_QUANT:
+      encoder->x264param.rc.i_rc_method = X264_RC_CQP;
+      encoder->x264param.rc.i_qp_constant = encoder->quantizer;
+      break;
+    case GST_X264_ENC_PASS_QUAL:
+      encoder->x264param.rc.i_rc_method = X264_RC_CRF;
+      encoder->x264param.rc.f_rf_constant = encoder->quantizer;
+      encoder->x264param.rc.i_vbv_max_bitrate = encoder->bitrate;
+      encoder->x264param.rc.i_vbv_buffer_size
+          = encoder->x264param.rc.i_vbv_max_bitrate
+          * encoder->vbv_buf_capacity / 1000;
+      break;
+    case GST_X264_ENC_PASS_CBR:
+    case GST_X264_ENC_PASS_PASS1:
+    case GST_X264_ENC_PASS_PASS2:
+    case GST_X264_ENC_PASS_PASS3:
+    default:
+      encoder->x264param.rc.i_rc_method = X264_RC_ABR;
+      encoder->x264param.rc.i_bitrate = encoder->bitrate;
+      encoder->x264param.rc.i_vbv_max_bitrate = encoder->bitrate;
+      encoder->x264param.rc.i_vbv_buffer_size =
+          encoder->x264param.rc.i_vbv_max_bitrate
+          * encoder->vbv_buf_capacity / 1000;
+      pass = encoder->pass & 0xF;
+      break;
+  }
+
+  switch (pass) {
+    case 0:
+      encoder->x264param.rc.b_stat_read = 0;
+      encoder->x264param.rc.b_stat_write = 0;
+      break;
+    case 1:
+      encoder->x264param.rc.b_stat_read = 0;
+      encoder->x264param.rc.b_stat_write = 1;
+#ifdef X264_PRESETS
+      x264_param_apply_fastfirstpass (&encoder->x264param);
+#else
+      encoder->x264param.i_frame_reference = 1;
+      encoder->x264param.analyse.b_transform_8x8 = 0;
+      encoder->x264param.analyse.inter = 0;
+      encoder->x264param.analyse.i_me_method = X264_ME_DIA;
+      encoder->x264param.analyse.i_subpel_refine =
+          MIN (2, encoder->x264param.analyse.i_subpel_refine);
+      encoder->x264param.analyse.i_trellis = 0;
+      encoder->x264param.analyse.b_fast_pskip = 1;
+#endif /* X264_PRESETS */
+      break;
+    case 2:
+      encoder->x264param.rc.b_stat_read = 1;
+      encoder->x264param.rc.b_stat_write = 0;
+      break;
+    case 3:
+      encoder->x264param.rc.b_stat_read = 1;
+      encoder->x264param.rc.b_stat_write = 1;
+      break;
+  }
+
+#if X264_BUILD >= 81 && X264_BUILD < 106
+  /* When vfr is disabled, libx264 ignores buffer timestamps. This causes
+   * issues with rate control in libx264 with our nanosecond timebase. This
+   * has been fixed upstream in libx264 but this workaround is required for
+   * pre-fix versions. */
+  if (!encoder->x264param.b_vfr_input) {
+    if (encoder->x264param.i_fps_num == 0) {
+      GST_ELEMENT_ERROR (encoder, STREAM, ENCODE,
+          ("Constant framerate is required."),
+          ("The framerate caps (%d/%d) indicate VFR but VFR is disabled in libx264. (Is the zerolatency tuning in use?)",
+              encoder->x264param.i_fps_num, encoder->x264param.i_fps_den));
+      return FALSE;
+    }
+    encoder->x264param.i_timebase_num = encoder->x264param.i_fps_den;
+    encoder->x264param.i_timebase_den = encoder->x264param.i_fps_num;
+  }
+#endif
+
+#ifdef X264_PRESETS
+  if (encoder->peer_profile) {
+    if (x264_param_apply_profile (&encoder->x264param, encoder->peer_profile))
+      GST_WARNING_OBJECT (encoder, "Bad downstream profile name: %s",
+          encoder->peer_profile);
+  }
+#endif /* X264_PRESETS */
+
+  /* If using an intra profile, all frames are intra frames */
+  if (encoder->peer_intra_profile)
+    encoder->x264param.i_keyint_max = encoder->x264param.i_keyint_min = 1;
+
+  /* Enforce level limits if they were in the caps */
+  if (encoder->peer_level) {
+    encoder->x264param.i_level_idc = encoder->peer_level->level_idc;
+
+    encoder->x264param.rc.i_bitrate = MIN (encoder->x264param.rc.i_bitrate,
+        encoder->peer_level->bitrate);
+    encoder->x264param.rc.i_vbv_max_bitrate =
+        MIN (encoder->x264param.rc.i_vbv_max_bitrate,
+        encoder->peer_level->bitrate);
+    encoder->x264param.rc.i_vbv_buffer_size =
+        MIN (encoder->x264param.rc.i_vbv_buffer_size, encoder->peer_level->cpb);
+    encoder->x264param.analyse.i_mv_range =
+        MIN (encoder->x264param.analyse.i_mv_range,
+        encoder->peer_level->mv_range);
+
+    if (encoder->peer_level->frame_only) {
+      encoder->x264param.b_interlaced = FALSE;
+#if X264_BUILD >= 95
+      encoder->x264param.b_fake_interlaced = FALSE;
+#endif
+    }
+  }
+
+  encoder->reconfig = FALSE;
+
+  GST_OBJECT_UNLOCK (encoder);
+
+  encoder->x264enc = x264_encoder_open (&encoder->x264param);
+  if (!encoder->x264enc) {
+    GST_ELEMENT_ERROR (encoder, STREAM, ENCODE,
+        ("Can not initialize x264 encoder."), (NULL));
+    return FALSE;
+  }
+
+  return TRUE;
+
+unlock_and_return:
+  GST_OBJECT_UNLOCK (encoder);
+  return FALSE;
+}
+
+/* gst_x264_enc_close_encoder
+ * @encoder:  Encoder which should close.
+ *
+ * Close x264 encoder.
+ */
+static void
+gst_x264_enc_close_encoder (GstX264Enc * encoder)
+{
+  if (encoder->x264enc != NULL) {
+    x264_encoder_close (encoder->x264enc);
+    encoder->x264enc = NULL;
+  }
+}
+
+static gboolean
+gst_x264_enc_set_profile_and_level (GstX264Enc * encoder, GstCaps * caps)
+{
+  x264_nal_t *nal;
+  int i_nal;
+  int header_return;
+  gint sps_ni = 0;
+  guint8 *sps;
+
+
+  header_return = x264_encoder_headers (encoder->x264enc, &nal, &i_nal);
+  if (header_return < 0) {
+    GST_ELEMENT_ERROR (encoder, STREAM, ENCODE, ("Encode x264 header failed."),
+        ("x264_encoder_headers return code=%d", header_return));
+    return FALSE;
+  }
+
+  /* old x264 returns SEI, SPS and PPS, newer one has SEI last */
+  if (i_nal == 3 && nal[sps_ni].i_type != 7)
+    sps_ni = 1;
+
+  /* old style API: nal's are not encapsulated, and have no sync/size prefix,
+   * new style API: nal's are encapsulated, and have 4-byte size prefix */
+#ifndef X264_ENC_NALS
+  sps = nal[sps_ni].p_payload;
+#else
+  sps = nal[sps_ni].p_payload + 4;
+  /* skip NAL unit type */
+  sps++;
+#endif
+
+  gst_codec_utils_h264_caps_set_level_and_profile (caps, sps, 3);
+
+  return TRUE;
+}
+
+/*
+ * Returns: Buffer with the stream headers.
+ */
+static GstBuffer *
+gst_x264_enc_header_buf (GstX264Enc * encoder)
+{
+  GstBuffer *buf;
+  x264_nal_t *nal;
+  int i_nal;
+  int header_return;
+  int i_size;
+  int nal_size;
+#ifndef X264_ENC_NALS
+  int i_data;
+#endif
+  guint8 *buffer, *sps;
+  gulong buffer_size;
+  gint sei_ni = 2, sps_ni = 0, pps_ni = 1;
+
+  if (G_UNLIKELY (encoder->x264enc == NULL))
+    return NULL;
+
+  /* Create avcC header. */
+
+  header_return = x264_encoder_headers (encoder->x264enc, &nal, &i_nal);
+  if (header_return < 0) {
+    GST_ELEMENT_ERROR (encoder, STREAM, ENCODE, ("Encode x264 header failed."),
+        ("x264_encoder_headers return code=%d", header_return));
+    return NULL;
+  }
+
+  /* old x264 returns SEI, SPS and PPS, newer one has SEI last */
+  if (i_nal == 3 && nal[sps_ni].i_type != 7) {
+    sei_ni = 0;
+    sps_ni = 1;
+    pps_ni = 2;
+  }
+
+  /* x264 is expected to return an SEI (some identification info),
+   * and SPS and PPS */
+  if (i_nal != 3 || nal[sps_ni].i_type != 7 || nal[pps_ni].i_type != 8 ||
+      nal[sps_ni].i_payload < 4 || nal[pps_ni].i_payload < 1) {
+    GST_ELEMENT_ERROR (encoder, STREAM, ENCODE, (NULL),
+        ("Unexpected x264 header."));
+    return NULL;
+  }
+
+  GST_MEMDUMP ("SEI", nal[sei_ni].p_payload, nal[sei_ni].i_payload);
+  GST_MEMDUMP ("SPS", nal[sps_ni].p_payload, nal[sps_ni].i_payload);
+  GST_MEMDUMP ("PPS", nal[pps_ni].p_payload, nal[pps_ni].i_payload);
+
+  /* nal payloads with emulation_prevention_three_byte, and some header data */
+  buffer_size = (nal[sps_ni].i_payload + nal[pps_ni].i_payload) * 4 + 100;
+  buffer = g_malloc (buffer_size);
+
+  /* old style API: nal's are not encapsulated, and have no sync/size prefix,
+   * new style API: nal's are encapsulated, and have 4-byte size prefix */
+#ifndef X264_ENC_NALS
+  sps = nal[sps_ni].p_payload;
+#else
+  sps = nal[sps_ni].p_payload + 4;
+  /* skip NAL unit type */
+  sps++;
+#endif
+
+  buffer[0] = 1;                /* AVC Decoder Configuration Record ver. 1 */
+  buffer[1] = sps[0];           /* profile_idc                             */
+  buffer[2] = sps[1];           /* profile_compability                     */
+  buffer[3] = sps[2];           /* level_idc                               */
+  buffer[4] = 0xfc | (4 - 1);   /* nal_length_size_minus1                  */
+
+  i_size = 5;
+
+  buffer[i_size++] = 0xe0 | 1;  /* number of SPSs */
+
+#ifndef X264_ENC_NALS
+  i_data = buffer_size - i_size - 2;
+  nal_size = x264_nal_encode (buffer + i_size + 2, &i_data, 0, &nal[sps_ni]);
+#else
+  nal_size = nal[sps_ni].i_payload - 4;
+  memcpy (buffer + i_size + 2, nal[sps_ni].p_payload + 4, nal_size);
+#endif
+  GST_WRITE_UINT16_BE (buffer + i_size, nal_size);
+  i_size += nal_size + 2;
+
+  buffer[i_size++] = 1;         /* number of PPSs */
+
+#ifndef X264_ENC_NALS
+  i_data = buffer_size - i_size - 2;
+  nal_size = x264_nal_encode (buffer + i_size + 2, &i_data, 0, &nal[pps_ni]);
+#else
+  nal_size = nal[pps_ni].i_payload - 4;
+  memcpy (buffer + i_size + 2, nal[pps_ni].p_payload + 4, nal_size);
+#endif
+  GST_WRITE_UINT16_BE (buffer + i_size, nal_size);
+  i_size += nal_size + 2;
+
+  buf = gst_buffer_new_and_alloc (i_size);
+  gst_buffer_fill (buf, 0, buffer, i_size);
+
+  GST_MEMDUMP ("header", buffer, i_size);
+  g_free (buffer);
+
+  return buf;
+}
+
+/* gst_x264_enc_set_src_caps
+ * Returns: TRUE on success.
+ */
+static gboolean
+gst_x264_enc_set_src_caps (GstX264Enc * encoder, GstPad * pad, GstCaps * caps)
+{
+  GstBuffer *buf;
+  GstCaps *outcaps;
+  GstStructure *structure;
+  gboolean res;
+
+  outcaps = gst_caps_new_simple ("video/x-h264",
+      "width", G_TYPE_INT, GST_VIDEO_INFO_WIDTH (&encoder->info),
+      "height", G_TYPE_INT, GST_VIDEO_INFO_HEIGHT (&encoder->info),
+      "framerate", GST_TYPE_FRACTION, GST_VIDEO_INFO_FPS_N (&encoder->info),
+      GST_VIDEO_INFO_FPS_D (&encoder->info),
+      "pixel-aspect-ratio", GST_TYPE_FRACTION,
+      GST_VIDEO_INFO_PAR_N (&encoder->info),
+      GST_VIDEO_INFO_PAR_D (&encoder->info), NULL);
+
+  structure = gst_caps_get_structure (outcaps, 0);
+
+  if (encoder->current_byte_stream == GST_X264_ENC_STREAM_FORMAT_FROM_PROPERTY) {
+    if (encoder->byte_stream) {
+      encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_BYTE_STREAM;
+    } else {
+      encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_AVC;
+    }
+  }
+  if (encoder->current_byte_stream == GST_X264_ENC_STREAM_FORMAT_AVC) {
+    buf = gst_x264_enc_header_buf (encoder);
+    if (buf != NULL) {
+      gst_caps_set_simple (outcaps, "codec_data", GST_TYPE_BUFFER, buf, NULL);
+      gst_buffer_unref (buf);
+    }
+    gst_structure_set (structure, "stream-format", G_TYPE_STRING, "avc", NULL);
+  } else {
+    gst_structure_set (structure, "stream-format", G_TYPE_STRING, "byte-stream",
+        NULL);
+  }
+  gst_structure_set (structure, "alignment", G_TYPE_STRING, "au", NULL);
+
+  if (!gst_x264_enc_set_profile_and_level (encoder, outcaps)) {
+    gst_caps_unref (outcaps);
+    return FALSE;
+  }
+
+  res = gst_pad_set_caps (pad, outcaps);
+  gst_caps_unref (outcaps);
+
+  return res;
+}
+
+static gboolean
+gst_x264_enc_sink_set_caps (GstPad * pad, GstCaps * caps)
+{
+  GstX264Enc *encoder = GST_X264_ENC (GST_OBJECT_PARENT (pad));
+  GstVideoInfo info;
+  gint width, height;
+  gint fps_n, fps_d;
+  gint par_n, par_d;
+  GstCaps *peer_caps;
+  GstCaps *allowed_caps = NULL;
+  gboolean level_ok = TRUE;
+
+  /* get info from caps */
+  if (!gst_video_info_from_caps (&info, caps))
+    goto invalid_caps;
+
+  width = GST_VIDEO_INFO_WIDTH (&info);
+  height = GST_VIDEO_INFO_HEIGHT (&info);
+  fps_n = GST_VIDEO_INFO_FPS_N (&info);
+  fps_d = GST_VIDEO_INFO_FPS_D (&info);
+  par_n = GST_VIDEO_INFO_PAR_N (&info);
+  par_d = GST_VIDEO_INFO_PAR_D (&info);
+
+  /* If the encoder is initialized, do not reinitialize it again if not
+   * necessary */
+  if (encoder->x264enc) {
+    if (width == GST_VIDEO_INFO_WIDTH (&encoder->info) &&
+        height == GST_VIDEO_INFO_HEIGHT (&encoder->info) &&
+        fps_n == GST_VIDEO_INFO_FPS_N (&encoder->info) &&
+        fps_d == GST_VIDEO_INFO_FPS_D (&encoder->info) &&
+        par_n == GST_VIDEO_INFO_PAR_N (&encoder->info) &&
+        par_d == GST_VIDEO_INFO_PAR_D (&encoder->info))
+      return TRUE;
+
+    /* clear out pending frames */
+    gst_x264_enc_flush_frames (encoder, TRUE);
+
+    encoder->sps_id++;
+  }
+
+  /* store input description */
+  encoder->info = info;
+
+  encoder->peer_profile = NULL;
+  encoder->peer_intra_profile = FALSE;
+  encoder->peer_level = NULL;
+
+  /* FIXME: Remove THIS bit in 0.11 when the profile property is removed */
+  peer_caps = gst_pad_peer_query_caps (encoder->srcpad, NULL);
+  if (peer_caps) {
+    gint i;
+    gboolean has_profile_or_level_or_format = FALSE;
+
+    for (i = 0; i < gst_caps_get_size (peer_caps); i++) {
+      GstStructure *s = gst_caps_get_structure (peer_caps, i);
+
+      if (gst_structure_has_name (s, "video/x-h264") &&
+          (gst_structure_has_field (s, "profile") ||
+              gst_structure_has_field (s, "level") ||
+              gst_structure_has_field (s, "stream-format"))) {
+        has_profile_or_level_or_format = TRUE;
+        break;
+      }
+    }
+
+    if (has_profile_or_level_or_format) {
+      GstCaps *template_caps;
+
+      template_caps = gst_pad_get_pad_template_caps (encoder->srcpad);
+
+      allowed_caps = gst_caps_intersect (peer_caps, template_caps);
+      gst_caps_unref (template_caps);
+    }
+
+    gst_caps_unref (peer_caps);
+  }
+
+  /* Replace the bit since FIXME with this
+   * allowed_caps = gst_pad_get_allowed_caps (encoder->srcpad);
+   */
+
+  if (allowed_caps) {
+    GstStructure *s;
+    const gchar *profile;
+    const gchar *level;
+    const gchar *stream_format;
+
+    if (gst_caps_is_empty (allowed_caps)) {
+      gst_caps_unref (allowed_caps);
+      return FALSE;
+    }
+
+    allowed_caps = gst_caps_fixate (allowed_caps);
+
+    allowed_caps = gst_caps_make_writable (allowed_caps);
+    s = gst_caps_get_structure (allowed_caps, 0);
+
+    profile = gst_structure_get_string (s, "profile");
+    if (profile) {
+      /* FIXME - if libx264 ever adds support for FMO, ASO or redundant slices
+       * make sure constrained profile has a separate case which disables
+       * those */
+      if (!strcmp (profile, "constrained-baseline") ||
+          !strcmp (profile, "baseline")) {
+        encoder->peer_profile = "baseline";
+      } else if (!strcmp (profile, "high-10-intra")) {
+        encoder->peer_intra_profile = TRUE;
+        encoder->peer_profile = "high10";
+      } else if (!strcmp (profile, "high-10")) {
+        encoder->peer_profile = "high10";
+      } else if (!strcmp (profile, "high")) {
+        encoder->peer_profile = "high";
+      } else if (!strcmp (profile, "main")) {
+        encoder->peer_profile = "main";
+      } else {
+        g_assert_not_reached ();
+      }
+    }
+
+    level = gst_structure_get_string (s, "level");
+    if (level) {
+      int level_idc = gst_codec_utils_h264_get_level_idc (level);
+
+      if (level_idc) {
+        gint i;
+
+        for (i = 0; x264_levels[i].level_idc; i++) {
+          if (level_idc == x264_levels[i].level_idc) {
+            int mb_width = (width + 15) / 16;
+            int mb_height = (height + 15) / 16;
+            int mbs = mb_width * mb_height;
+
+            if (x264_levels[i].frame_size < mbs ||
+                x264_levels[i].frame_size * 8 < mb_width * mb_width ||
+                x264_levels[i].frame_size * 8 < mb_height * mb_height) {
+              GST_WARNING_OBJECT (encoder,
+                  "Frame size larger than level %s allows", level);
+              level_ok = FALSE;
+              break;
+            }
+
+            if (fps_d && x264_levels[i].mbps < (gint64) mbs * fps_n / fps_d) {
+              GST_WARNING_OBJECT (encoder,
+                  "Macroblock rate higher than level %s allows", level);
+              level_ok = FALSE;
+              break;
+            }
+
+            encoder->peer_level = &x264_levels[i];
+            break;
+          }
+        }
+      }
+    }
+
+    stream_format = gst_structure_get_string (s, "stream-format");
+    encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_FROM_PROPERTY;
+    if (stream_format) {
+      if (!strcmp (stream_format, "avc")) {
+        encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_AVC;
+        g_string_append_printf (encoder->option_string, ":annexb=0");
+      } else if (!strcmp (stream_format, "byte-stream")) {
+        encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_BYTE_STREAM;
+        g_string_append_printf (encoder->option_string, ":annexb=1");
+      } else {
+        /* means we have both in caps and _FROM_PROPERTY should be the option */
+      }
+    }
+
+    gst_caps_unref (allowed_caps);
+  }
+
+  if (!level_ok)
+    return FALSE;
+
+  if (!gst_x264_enc_init_encoder (encoder))
+    return FALSE;
+
+  if (!gst_x264_enc_set_src_caps (encoder, encoder->srcpad, caps)) {
+    gst_x264_enc_close_encoder (encoder);
+    return FALSE;
+  }
+
+  return TRUE;
+
+  /* ERRORS */
+invalid_caps:
+  {
+    GST_ERROR_OBJECT (encoder, "invalid caps");
+    return FALSE;
+  }
+}
+
+static GstCaps *
+gst_x264_enc_sink_get_caps (GstPad * pad, GstCaps * filter)
+{
+  GstX264Enc *encoder;
+  GstPad *peer;
+  GstCaps *caps, *current;
+  GstCaps *templcaps;
+
+  encoder = GST_X264_ENC (gst_pad_get_parent (pad));
+  if (!encoder)
+    return gst_caps_new_empty ();
+
+  templcaps = gst_pad_get_pad_template_caps (pad);
+
+  peer = gst_pad_get_peer (encoder->srcpad);
+  if (peer) {
+    GstCaps *peercaps;
+    guint i, n;
+
+    peercaps = gst_pad_query_caps (peer, NULL);
+
+    /* Translate peercaps to YUV */
+    peercaps = gst_caps_make_writable (peercaps);
+    n = gst_caps_get_size (peercaps);
+    for (i = 0; i < n; i++) {
+      GstStructure *s = gst_caps_get_structure (peercaps, i);
+
+      gst_structure_set_name (s, "video/x-raw");
+      gst_structure_remove_field (s, "stream-format");
+      gst_structure_remove_field (s, "alignment");
+    }
+
+    caps = gst_caps_intersect (peercaps, templcaps);
+    gst_caps_unref (peercaps);
+    gst_caps_unref (templcaps);
+    gst_object_unref (peer);
+    peer = NULL;
+  } else {
+    caps = templcaps;
+  }
+
+  /* If we already have caps return them */
+  current = gst_pad_get_current_caps (pad);
+  if (current) {
+    if (gst_caps_can_intersect (current, caps)) {
+      caps = gst_caps_merge (current, caps);
+    } else {
+      gst_caps_unref (current);
+    }
+  }
+
+  gst_object_unref (encoder);
+
+  return caps;
+}
+
+static gboolean
+gst_x264_enc_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
+{
+  gboolean ret = TRUE;
+  GstX264Enc *encoder;
+  gboolean forward = TRUE;
+
+  encoder = GST_X264_ENC (parent);
+
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_CUSTOM_UPSTREAM:{
+      guint count;
+      gboolean all_headers;
+
+      if (!gst_video_event_is_force_key_unit (event))
+        goto out;
+
+      GST_OBJECT_LOCK (encoder);
+      gst_video_event_parse_upstream_force_key_unit (event,
+          &encoder->pending_key_unit_ts, &all_headers, &count);
+      GST_INFO_OBJECT (encoder, "received upstream force-key-unit event, "
+          "seqnum %d running_time %" GST_TIME_FORMAT " all_headers %d count %d",
+          gst_event_get_seqnum (event),
+          GST_TIME_ARGS (encoder->pending_key_unit_ts), all_headers, count);
+
+      gst_event_replace (&encoder->force_key_unit_event, event);
+      gst_event_unref (event);
+      GST_OBJECT_UNLOCK (encoder);
+      forward = FALSE;
+      break;
+    }
+    default:
+      break;
+  }
+
+out:
+  if (forward)
+    ret = gst_pad_push_event (encoder->sinkpad, event);
+
+  return ret;
+}
+
+static gboolean
+gst_x264_enc_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
+{
+  gboolean ret = FALSE, forward = TRUE;
+  GstX264Enc *encoder;
+
+  encoder = GST_X264_ENC (parent);
+
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_CAPS:
+    {
+      GstCaps *caps;
+
+      gst_event_parse_caps (event, &caps);
+      ret = gst_x264_enc_sink_set_caps (pad, caps);
+      forward = FALSE;
+      break;
+    }
+    case GST_EVENT_SEGMENT:
+      gst_event_copy_segment (event, &encoder->segment);
+      break;
+    case GST_EVENT_FLUSH_STOP:
+      gst_segment_init (&encoder->segment, GST_FORMAT_UNDEFINED);
+      break;
+    case GST_EVENT_EOS:
+      gst_x264_enc_flush_frames (encoder, TRUE);
+      break;
+    case GST_EVENT_TAG:{
+      GstTagList *tags = NULL;
+
+      event =
+          GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
+
+      gst_event_parse_tag (event, &tags);
+      /* drop codec/video-codec and replace encoder/encoder-version */
+      gst_tag_list_remove_tag (tags, GST_TAG_VIDEO_CODEC);
+      gst_tag_list_remove_tag (tags, GST_TAG_CODEC);
+      gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_ENCODER, "x264",
+          GST_TAG_ENCODER_VERSION, X264_BUILD, NULL);
+      /* push is done below */
+      break;
+      /* no flushing if flush received,
+       * buffers in encoder are considered (in the) past */
+    }
+    case GST_EVENT_CUSTOM_DOWNSTREAM:{
+      guint count;
+      gboolean all_headers;
+
+      if (!gst_video_event_is_force_key_unit (event))
+        break;
+
+      GST_OBJECT_LOCK (encoder);
+
+      gst_video_event_parse_downstream_force_key_unit (event, NULL, NULL,
+          &encoder->pending_key_unit_ts, &all_headers, &count);
+      GST_INFO_OBJECT (encoder, "received downstream force-key-unit event, "
+          "seqnum %d running_time %" GST_TIME_FORMAT " all_headers %d count %d",
+          gst_event_get_seqnum (event),
+          GST_TIME_ARGS (encoder->pending_key_unit_ts), all_headers, count);
+
+      gst_event_replace (&encoder->force_key_unit_event, event);
+      gst_event_unref (event);
+      GST_OBJECT_UNLOCK (encoder);
+      break;
+    }
+    default:
+      break;
+  }
+
+  if (forward)
+    ret = gst_pad_push_event (encoder->srcpad, event);
+  else
+    gst_event_unref (event);
+
+  return ret;
+}
+
+static gboolean
+gst_x264_enc_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
+{
+  gboolean ret = FALSE;
+
+  switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_CAPS:
+    {
+      GstCaps *filter, *caps;
+
+      gst_query_parse_caps (query, &filter);
+      caps = gst_x264_enc_sink_get_caps (pad, filter);
+      gst_query_set_caps_result (query, caps);
+      gst_caps_unref (caps);
+      ret = TRUE;
+      break;
+    }
+    default:
+      ret = gst_pad_query_default (pad, parent, query);
+      break;
+  }
+
+  return ret;
+}
+
+/* chain function
+ * this function does the actual processing
+ */
+static GstFlowReturn
+gst_x264_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
+{
+  GstX264Enc *encoder = GST_X264_ENC (parent);
+  GstFlowReturn ret;
+  x264_picture_t pic_in;
+  gint i_nal, i;
+  GstVideoFrame frame;
+
+  if (G_UNLIKELY (encoder->x264enc == NULL))
+    goto not_inited;
+
+  /* create x264_picture_t from the buffer */
+  /* mostly taken from mplayer (file ve_x264.c) */
+  if (!gst_video_frame_map (&frame, &encoder->info, buf, GST_MAP_READ))
+    goto wrong_video_frame;
+
+  /* remember the timestamp and duration */
+  g_queue_push_tail (encoder->delay, buf);
+
+  /* set up input picture */
+  memset (&pic_in, 0, sizeof (pic_in));
+
+  pic_in.img.i_csp = X264_CSP_I420;
+  pic_in.img.i_plane = 3;
+  for (i = 0; i < 3; i++) {
+    pic_in.img.plane[i] = GST_VIDEO_FRAME_COMP_DATA (&frame, i);
+    pic_in.img.i_stride[i] = GST_VIDEO_FRAME_COMP_STRIDE (&frame, i);
+  }
+
+  pic_in.i_type = X264_TYPE_AUTO;
+  pic_in.i_dts = GST_BUFFER_DTS (buf);
+  pic_in.i_pts = GST_BUFFER_PTS (buf);
+
+  ret = gst_x264_enc_encode_frame (encoder, &pic_in, &i_nal, TRUE);
+
+  gst_video_frame_unmap (&frame);
+
+  /* input buffer is released later on */
+  return ret;
+
+/* ERRORS */
+not_inited:
+  {
+    GST_WARNING_OBJECT (encoder, "Got buffer before set_caps was called");
+    gst_buffer_unref (buf);
+    return GST_FLOW_NOT_NEGOTIATED;
+  }
+wrong_video_frame:
+  {
+    GST_ELEMENT_ERROR (encoder, STREAM, ENCODE,
+        ("Encode x264 frame failed."), ("Could not map video frame"));
+    gst_buffer_unref (buf);
+    return GST_FLOW_ERROR;
+  }
+}
+
+static GstEvent *
+check_pending_key_unit_event (GstEvent * pending_event, GstSegment * segment,
+    GstClockTime timestamp, GstClockTime pending_key_unit_ts)
+{
+  GstClockTime running_time, stream_time;
+  gboolean all_headers;
+  guint count;
+  GstEvent *event = NULL;
+
+  g_return_val_if_fail (pending_event != NULL, NULL);
+  g_return_val_if_fail (segment != NULL, NULL);
+
+  if (pending_event == NULL || timestamp == GST_CLOCK_TIME_NONE)
+    goto out;
+
+  running_time = gst_segment_to_running_time (segment,
+      GST_FORMAT_TIME, timestamp);
+
+  GST_INFO ("now %" GST_TIME_FORMAT " wanted %" GST_TIME_FORMAT,
+      GST_TIME_ARGS (running_time), GST_TIME_ARGS (pending_key_unit_ts));
+
+  if (running_time < pending_key_unit_ts)
+    goto out;
+
+  stream_time = gst_segment_to_stream_time (segment,
+      GST_FORMAT_TIME, timestamp);
+
+  gst_video_event_parse_upstream_force_key_unit (pending_event,
+      NULL, &all_headers, &count);
+
+  event =
+      gst_video_event_new_downstream_force_key_unit (timestamp, stream_time,
+      running_time, all_headers, count);
+  gst_event_set_seqnum (event, gst_event_get_seqnum (pending_event));
+
+out:
+  return event;
+}
+
+static GstFlowReturn
+gst_x264_enc_encode_frame (GstX264Enc * encoder, x264_picture_t * pic_in,
+    int *i_nal, gboolean send)
+{
+  GstFlowReturn ret;
+  GstBuffer *out_buf = NULL, *in_buf = NULL;
+  x264_picture_t pic_out;
+  x264_nal_t *nal;
+  int i_size;
+#ifndef X264_ENC_NALS
+  int nal_size;
+  gint i;
+#endif
+  int encoder_return;
+  GstClockTime duration;
+  guint8 *data;
+  GstEvent *event = NULL;
+
+  if (G_UNLIKELY (encoder->x264enc == NULL))
+    return GST_FLOW_NOT_NEGOTIATED;
+
+  GST_OBJECT_LOCK (encoder);
+  if (encoder->reconfig) {
+    encoder->reconfig = FALSE;
+    if (x264_encoder_reconfig (encoder->x264enc, &encoder->x264param) < 0)
+      GST_WARNING_OBJECT (encoder, "Could not reconfigure");
+  }
+
+  if (encoder->pending_key_unit_ts != GST_CLOCK_TIME_NONE && pic_in != NULL) {
+    event = check_pending_key_unit_event (encoder->force_key_unit_event,
+        &encoder->segment, pic_in->i_pts, encoder->pending_key_unit_ts);
+    if (event) {
+      encoder->pending_key_unit_ts = GST_CLOCK_TIME_NONE;
+      gst_event_replace (&encoder->force_key_unit_event, NULL);
+
+#ifdef FORCE_INTRA_API
+      if (encoder->intra_refresh)
+        x264_encoder_intra_refresh (encoder->x264enc);
+      else
+        pic_in->i_type = X264_TYPE_IDR;
+#else
+      pic_in->i_type = X264_TYPE_IDR;
+#endif
+    }
+  }
+  GST_OBJECT_UNLOCK (encoder);
+
+  encoder_return = x264_encoder_encode (encoder->x264enc,
+      &nal, i_nal, pic_in, &pic_out);
+
+  if (encoder_return < 0)
+    goto encode_failed;
+
+  if (!*i_nal) {
+    ret = GST_FLOW_OK;
+    goto out;
+  }
+#ifndef X264_ENC_NALS
+  i_size = 0;
+  for (i = 0; i < *i_nal; i++) {
+    gint i_data = encoder->buffer_size - i_size - 4;
+
+    if (i_data < nal[i].i_payload * 2) {
+      encoder->buffer_size += 2 * nal[i].i_payload;
+      encoder->buffer = g_realloc (encoder->buffer, encoder->buffer_size);
+      i_data = encoder->buffer_size - i_size - 4;
+    }
+
+    nal_size =
+        x264_nal_encode (encoder->buffer + i_size + 4, &i_data, 0, &nal[i]);
+    g_assert (encoder->current_byte_stream !=
+        GST_X264_ENC_STREAM_FORMAT_FROM_PROPERTY);
+    if (encoder->current_byte_stream == GST_X264_ENC_STREAM_FORMAT_BYTE_STREAM)
+      GST_WRITE_UINT32_BE (encoder->buffer + i_size, 1);
+    else
+      GST_WRITE_UINT32_BE (encoder->buffer + i_size, nal_size);
+
+    i_size += nal_size + 4;
+  }
+  data = encoder->buffer;
+#else
+  i_size = encoder_return;
+  data = nal[0].p_payload;
+#endif
+
+  in_buf = g_queue_pop_head (encoder->delay);
+  if (in_buf) {
+    duration = GST_BUFFER_DURATION (in_buf);
+    gst_buffer_unref (in_buf);
+  } else {
+    GST_ELEMENT_ERROR (encoder, STREAM, ENCODE, (NULL),
+        ("Timestamp queue empty."));
+    ret = GST_FLOW_ERROR;
+    goto out;
+  }
+
+  if (!send) {
+    ret = GST_FLOW_OK;
+    goto out;
+  }
+
+  out_buf = gst_buffer_new_allocate (NULL, i_size, NULL);
+  gst_buffer_fill (out_buf, 0, data, i_size);
+
+  GST_LOG_OBJECT (encoder,
+      "output: dts %" G_GINT64_FORMAT " pts %" G_GINT64_FORMAT,
+      (gint64) pic_out.i_dts, (gint64) pic_out.i_pts);
+
+  if (pic_out.i_dts < 0)
+    GST_BUFFER_DTS (out_buf) = GST_CLOCK_TIME_NONE;
+  else
+    GST_BUFFER_DTS (out_buf) = pic_out.i_dts;
+
+  GST_BUFFER_PTS (out_buf) = pic_out.i_pts;
+  GST_BUFFER_DURATION (out_buf) = duration;
+
+#ifdef X264_INTRA_REFRESH
+  if (pic_out.b_keyframe) {
+#else
+  if (pic_out.i_type == X264_TYPE_IDR) {
+#endif
+    GST_BUFFER_FLAG_UNSET (out_buf, GST_BUFFER_FLAG_DELTA_UNIT);
+  } else {
+    GST_BUFFER_FLAG_SET (out_buf, GST_BUFFER_FLAG_DELTA_UNIT);
+  }
+
+  if (event)
+    gst_pad_push_event (encoder->srcpad, gst_event_ref (event));
+
+  ret = gst_pad_push (encoder->srcpad, out_buf);
+
+out:
+  if (event)
+    gst_event_unref (event);
+
+  return ret;
+
+  /* ERRORS */
+encode_failed:
+  {
+    GST_ELEMENT_ERROR (encoder, STREAM, ENCODE, ("Encode x264 frame failed."),
+        ("x264_encoder_encode return code=%d", encoder_return));
+    ret = GST_FLOW_ERROR;
+    goto out;
+  }
+}
+
+static void
+gst_x264_enc_flush_frames (GstX264Enc * encoder, gboolean send)
+{
+  GstFlowReturn flow_ret;
+  gint i_nal;
+
+  /* first send the remaining frames */
+  if (encoder->x264enc)
+    do {
+      flow_ret = gst_x264_enc_encode_frame (encoder, NULL, &i_nal, send);
+#ifdef X264_DELAYED_FRAMES_API
+    } while (flow_ret == GST_FLOW_OK
+        && x264_encoder_delayed_frames (encoder->x264enc) > 0);
+#else
+      /* note that this doesn't flush all frames for > 1 delayed frame */
+    } while (flow_ret == GST_FLOW_OK && i_nal > 0);
+#endif
+
+  /* in any case, make sure the delay queue is emptied */
+  while (!g_queue_is_empty (encoder->delay))
+    gst_buffer_unref (g_queue_pop_head (encoder->delay));
+}
+
+static GstStateChangeReturn
+gst_x264_enc_change_state (GstElement * element, GstStateChange transition)
+{
+  GstX264Enc *encoder = GST_X264_ENC (element);
+  GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+
+  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+  if (ret == GST_STATE_CHANGE_FAILURE)
+    goto out;
+
+  switch (transition) {
+    case GST_STATE_CHANGE_PAUSED_TO_READY:
+      gst_x264_enc_flush_frames (encoder, FALSE);
+      gst_x264_enc_close_encoder (encoder);
+      gst_x264_enc_reset (encoder);
+      break;
+    default:
+      break;
+  }
+
+out:
+  return ret;
+}
+
+
+
+static void
+gst_x264_enc_reconfig (GstX264Enc * encoder)
+{
+  switch (encoder->pass) {
+    case GST_X264_ENC_PASS_QUAL:
+      encoder->x264param.rc.f_rf_constant = encoder->quantizer;
+      encoder->x264param.rc.i_vbv_max_bitrate = encoder->bitrate;
+      encoder->x264param.rc.i_vbv_buffer_size
+          = encoder->x264param.rc.i_vbv_max_bitrate
+          * encoder->vbv_buf_capacity / 1000;
+      break;
+    case GST_X264_ENC_PASS_CBR:
+    case GST_X264_ENC_PASS_PASS1:
+    case GST_X264_ENC_PASS_PASS2:
+    case GST_X264_ENC_PASS_PASS3:
+    default:
+      encoder->x264param.rc.i_bitrate = encoder->bitrate;
+      encoder->x264param.rc.i_vbv_max_bitrate = encoder->bitrate;
+      encoder->x264param.rc.i_vbv_buffer_size
+          = encoder->x264param.rc.i_vbv_max_bitrate
+          * encoder->vbv_buf_capacity / 1000;
+      break;
+  }
+
+  encoder->reconfig = TRUE;
+}
+
+static void
+gst_x264_enc_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec)
+{
+  GstX264Enc *encoder;
+  GstState state;
+
+  const gchar *partitions = NULL;
+
+  encoder = GST_X264_ENC (object);
+
+  GST_OBJECT_LOCK (encoder);
+  /* state at least matters for sps, bytestream, pass,
+   * and so by extension ... */
+
+  state = GST_STATE (encoder);
+  if ((state != GST_STATE_READY && state != GST_STATE_NULL) &&
+      !(pspec->flags & GST_PARAM_MUTABLE_PLAYING))
+    goto wrong_state;
+
+  switch (prop_id) {
+    case ARG_PASS:
+      encoder->pass = g_value_get_enum (value);
+      break;
+    case ARG_QUANTIZER:
+      encoder->quantizer = g_value_get_uint (value);
+      gst_x264_enc_reconfig (encoder);
+      break;
+    case ARG_BITRATE:
+      encoder->bitrate = g_value_get_uint (value);
+      gst_x264_enc_reconfig (encoder);
+      break;
+    case ARG_VBV_BUF_CAPACITY:
+      encoder->vbv_buf_capacity = g_value_get_uint (value);
+      gst_x264_enc_reconfig (encoder);
+      break;
+    case ARG_SPEED_PRESET:
+      encoder->speed_preset = g_value_get_enum (value);
+      break;
+    case ARG_PSY_TUNE:
+      encoder->psy_tune = g_value_get_enum (value);
+      break;
+    case ARG_TUNE:
+      encoder->tune = g_value_get_flags (value);
+      break;
+    case ARG_OPTION_STRING:
+      g_string_assign (encoder->option_string_prop, g_value_get_string (value));
+      break;
+    case ARG_THREADS:
+      encoder->threads = g_value_get_uint (value);
+      g_string_append_printf (encoder->option_string, ":threads=%d",
+          encoder->threads);
+      break;
+    case ARG_SLICED_THREADS:
+      encoder->sliced_threads = g_value_get_boolean (value);
+      g_string_append_printf (encoder->option_string, ":sliced-threads=%d",
+          encoder->sliced_threads);
+      break;
+    case ARG_SYNC_LOOKAHEAD:
+      encoder->sync_lookahead = g_value_get_int (value);
+      g_string_append_printf (encoder->option_string, ":sync-lookahead=%d",
+          encoder->sync_lookahead);
+      break;
+    case ARG_MULTIPASS_CACHE_FILE:
+      if (encoder->mp_cache_file)
+        g_free (encoder->mp_cache_file);
+      encoder->mp_cache_file = g_value_dup_string (value);
+      g_string_append_printf (encoder->option_string, ":stats=%s",
+          encoder->mp_cache_file);
+      break;
+    case ARG_BYTE_STREAM:
+      encoder->byte_stream = g_value_get_boolean (value);
+      g_string_append_printf (encoder->option_string, ":annexb=%d",
+          encoder->byte_stream);
+      break;
+    case ARG_INTRA_REFRESH:
+      encoder->intra_refresh = g_value_get_boolean (value);
+      g_string_append_printf (encoder->option_string, ":intra-refresh=%d",
+          encoder->intra_refresh);
+      break;
+    case ARG_ME:
+      encoder->me = g_value_get_enum (value);
+      g_string_append_printf (encoder->option_string, ":me=%s",
+          x264_motion_est_names[encoder->me]);
+      break;
+    case ARG_SUBME:
+      encoder->subme = g_value_get_uint (value);
+      g_string_append_printf (encoder->option_string, ":subme=%d",
+          encoder->subme);
+      break;
+    case ARG_ANALYSE:
+      encoder->analyse = g_value_get_flags (value);
+      partitions = gst_x264_enc_build_partitions (encoder->analyse);
+      if (partitions) {
+        g_string_append_printf (encoder->option_string, ":partitions=%s",
+            partitions);
+        g_free ((gpointer) partitions);
+      }
+      break;
+    case ARG_DCT8x8:
+      encoder->dct8x8 = g_value_get_boolean (value);
+      g_string_append_printf (encoder->option_string, ":8x8dct=%d",
+          encoder->dct8x8);
+      break;
+    case ARG_REF:
+      encoder->ref = g_value_get_uint (value);
+      g_string_append_printf (encoder->option_string, ":ref=%d", encoder->ref);
+      break;
+    case ARG_BFRAMES:
+      encoder->bframes = g_value_get_uint (value);
+      g_string_append_printf (encoder->option_string, ":bframes=%d",
+          encoder->bframes);
+      break;
+    case ARG_B_ADAPT:
+      encoder->b_adapt = g_value_get_boolean (value);
+      g_string_append_printf (encoder->option_string, ":b-adapt=%d",
+          encoder->b_adapt);
+      break;
+    case ARG_B_PYRAMID:
+      encoder->b_pyramid = g_value_get_boolean (value);
+#ifdef X264_B_PYRAMID
+      g_string_append_printf (encoder->option_string, ":b-pyramid=%s",
+          x264_b_pyramid_names[encoder->b_pyramid]);
+#else
+      g_string_append_printf (encoder->option_string, ":b-pyramid=%d",
+          encoder->b_pyramid);
+#endif /* X264_B_PYRAMID */
+      break;
+    case ARG_WEIGHTB:
+      encoder->weightb = g_value_get_boolean (value);
+      g_string_append_printf (encoder->option_string, ":weightb=%d",
+          encoder->weightb);
+      break;
+    case ARG_SPS_ID:
+      encoder->sps_id = g_value_get_uint (value);
+      g_string_append_printf (encoder->option_string, ":sps-id=%d",
+          encoder->sps_id);
+      break;
+    case ARG_AU_NALU:
+      encoder->au_nalu = g_value_get_boolean (value);
+      g_string_append_printf (encoder->option_string, ":aud=%d",
+          encoder->au_nalu);
+      break;
+    case ARG_TRELLIS:
+      encoder->trellis = g_value_get_boolean (value);
+      g_string_append_printf (encoder->option_string, ":trellis=%d",
+          encoder->trellis);
+      break;
+    case ARG_KEYINT_MAX:
+      encoder->keyint_max = g_value_get_uint (value);
+      g_string_append_printf (encoder->option_string, ":keyint=%d",
+          encoder->keyint_max);
+      break;
+    case ARG_CABAC:
+      encoder->cabac = g_value_get_boolean (value);
+      g_string_append_printf (encoder->option_string, ":cabac=%d",
+          encoder->cabac);
+      break;
+    case ARG_QP_MIN:
+      encoder->qp_min = g_value_get_uint (value);
+      g_string_append_printf (encoder->option_string, ":qpmin=%d",
+          encoder->qp_min);
+      break;
+    case ARG_QP_MAX:
+      encoder->qp_max = g_value_get_uint (value);
+      g_string_append_printf (encoder->option_string, ":qpmax=%d",
+          encoder->qp_max);
+      break;
+    case ARG_QP_STEP:
+      encoder->qp_step = g_value_get_uint (value);
+      g_string_append_printf (encoder->option_string, ":qpstep=%d",
+          encoder->qp_step);
+      break;
+    case ARG_IP_FACTOR:
+      encoder->ip_factor = g_value_get_float (value);
+      g_string_append_printf (encoder->option_string, ":ip-factor=%f",
+          encoder->ip_factor);
+      break;
+    case ARG_PB_FACTOR:
+      encoder->pb_factor = g_value_get_float (value);
+      g_string_append_printf (encoder->option_string, ":pb-factor=%f",
+          encoder->pb_factor);
+      break;
+    case ARG_RC_MB_TREE:
+      encoder->mb_tree = g_value_get_boolean (value);
+      g_string_append_printf (encoder->option_string, ":mbtree=%d",
+          encoder->mb_tree);
+      break;
+    case ARG_RC_LOOKAHEAD:
+      encoder->rc_lookahead = g_value_get_int (value);
+      g_string_append_printf (encoder->option_string, ":rc-lookahead=%d",
+          encoder->rc_lookahead);
+      break;
+    case ARG_NR:
+      encoder->noise_reduction = g_value_get_uint (value);
+      g_string_append_printf (encoder->option_string, ":nr=%d",
+          encoder->noise_reduction);
+      break;
+    case ARG_INTERLACED:
+      encoder->interlaced = g_value_get_boolean (value);
+      g_string_append_printf (encoder->option_string, ":interlaced=%d",
+          encoder->interlaced);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+  GST_OBJECT_UNLOCK (encoder);
+  return;
+
+  /* ERROR */
+wrong_state:
+  {
+    GST_WARNING_OBJECT (encoder, "setting property in wrong state");
+    GST_OBJECT_UNLOCK (encoder);
+  }
+}
+
+static void
+gst_x264_enc_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec)
+{
+  GstX264Enc *encoder;
+
+  encoder = GST_X264_ENC (object);
+
+  GST_OBJECT_LOCK (encoder);
+  switch (prop_id) {
+    case ARG_THREADS:
+      g_value_set_uint (value, encoder->threads);
+      break;
+    case ARG_SLICED_THREADS:
+      g_value_set_boolean (value, encoder->sliced_threads);
+      break;
+    case ARG_SYNC_LOOKAHEAD:
+      g_value_set_int (value, encoder->sync_lookahead);
+      break;
+    case ARG_PASS:
+      g_value_set_enum (value, encoder->pass);
+      break;
+    case ARG_QUANTIZER:
+      g_value_set_uint (value, encoder->quantizer);
+      break;
+    case ARG_MULTIPASS_CACHE_FILE:
+      g_value_set_string (value, encoder->mp_cache_file);
+      break;
+    case ARG_BYTE_STREAM:
+      g_value_set_boolean (value, encoder->byte_stream);
+      break;
+    case ARG_BITRATE:
+      g_value_set_uint (value, encoder->bitrate);
+      break;
+    case ARG_INTRA_REFRESH:
+      g_value_set_boolean (value, encoder->intra_refresh);
+      break;
+    case ARG_VBV_BUF_CAPACITY:
+      g_value_set_uint (value, encoder->vbv_buf_capacity);
+      break;
+    case ARG_ME:
+      g_value_set_enum (value, encoder->me);
+      break;
+    case ARG_SUBME:
+      g_value_set_uint (value, encoder->subme);
+      break;
+    case ARG_ANALYSE:
+      g_value_set_flags (value, encoder->analyse);
+      break;
+    case ARG_DCT8x8:
+      g_value_set_boolean (value, encoder->dct8x8);
+      break;
+    case ARG_REF:
+      g_value_set_uint (value, encoder->ref);
+      break;
+    case ARG_BFRAMES:
+      g_value_set_uint (value, encoder->bframes);
+      break;
+    case ARG_B_ADAPT:
+      g_value_set_boolean (value, encoder->b_adapt);
+      break;
+    case ARG_B_PYRAMID:
+      g_value_set_boolean (value, encoder->b_pyramid);
+      break;
+    case ARG_WEIGHTB:
+      g_value_set_boolean (value, encoder->weightb);
+      break;
+    case ARG_SPS_ID:
+      g_value_set_uint (value, encoder->sps_id);
+      break;
+    case ARG_AU_NALU:
+      g_value_set_boolean (value, encoder->au_nalu);
+      break;
+    case ARG_TRELLIS:
+      g_value_set_boolean (value, encoder->trellis);
+      break;
+    case ARG_KEYINT_MAX:
+      g_value_set_uint (value, encoder->keyint_max);
+      break;
+    case ARG_QP_MIN:
+      g_value_set_uint (value, encoder->qp_min);
+      break;
+    case ARG_QP_MAX:
+      g_value_set_uint (value, encoder->qp_max);
+      break;
+    case ARG_QP_STEP:
+      g_value_set_uint (value, encoder->qp_step);
+      break;
+    case ARG_CABAC:
+      g_value_set_boolean (value, encoder->cabac);
+      break;
+    case ARG_IP_FACTOR:
+      g_value_set_float (value, encoder->ip_factor);
+      break;
+    case ARG_PB_FACTOR:
+      g_value_set_float (value, encoder->pb_factor);
+      break;
+    case ARG_RC_MB_TREE:
+      g_value_set_boolean (value, encoder->mb_tree);
+      break;
+    case ARG_RC_LOOKAHEAD:
+      g_value_set_int (value, encoder->rc_lookahead);
+      break;
+    case ARG_NR:
+      g_value_set_uint (value, encoder->noise_reduction);
+      break;
+    case ARG_INTERLACED:
+      g_value_set_boolean (value, encoder->interlaced);
+      break;
+    case ARG_SPEED_PRESET:
+      g_value_set_enum (value, encoder->speed_preset);
+      break;
+    case ARG_PSY_TUNE:
+      g_value_set_enum (value, encoder->psy_tune);
+      break;
+    case ARG_TUNE:
+      g_value_set_flags (value, encoder->tune);
+      break;
+    case ARG_OPTION_STRING:
+      g_value_set_string (value, encoder->option_string_prop->str);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+  GST_OBJECT_UNLOCK (encoder);
+}
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  GST_DEBUG_CATEGORY_INIT (x264_enc_debug, "x264enc", 0,
+      "h264 encoding element");
+
+  return gst_element_register (plugin, "x264enc",
+      GST_RANK_PRIMARY, GST_TYPE_X264_ENC);
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    x264,
+    "libx264-based H264 plugins",
+    plugin_init, VERSION, "GPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/ext/x264/gstx264enc.h b/ext/x264/gstx264enc.h
new file mode 100644
index 0000000..fc32304
--- /dev/null
+++ b/ext/x264/gstx264enc.h
@@ -0,0 +1,129 @@
+/* GStreamer H264 encoder plugin
+ * Copyright (C) 2005 Michal Benes <michal.benes@itonis.tv>
+ * Copyright (C) 2005 Josef Zlomek <josef.zlomek@itonis.tv>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_X264_ENC_H__
+#define __GST_X264_ENC_H__
+
+#include <gst/gst.h>
+#include <gst/video/video.h>
+#include "_stdint.h"
+#include <x264.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_X264_ENC \
+  (gst_x264_enc_get_type())
+#define GST_X264_ENC(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_X264_ENC,GstX264Enc))
+#define GST_X264_ENC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_X264_ENC,GstX264EncClass))
+#define GST_IS_X264_ENC(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_X264_ENC))
+#define GST_IS_X264_ENC_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_X264_ENC))
+
+typedef struct _GstX264Enc GstX264Enc;
+typedef struct _GstX264EncClass GstX264EncClass;
+
+struct _GstX264Enc
+{
+  GstElement element;
+
+  /*< private >*/
+  GstPad *sinkpad;
+  GstPad *srcpad;
+  GstSegment segment;
+
+  x264_t *x264enc;
+  x264_param_t x264param;
+  gint current_byte_stream;
+
+  /* properties */
+  guint threads;
+  gboolean sliced_threads;
+  gint sync_lookahead;
+  gint pass;
+  guint quantizer;
+  gchar *mp_cache_file;
+  gboolean byte_stream;
+  guint bitrate;
+  gboolean intra_refresh;
+  gint me;
+  guint subme;
+  guint analyse;
+  gboolean dct8x8;
+  guint ref;
+  guint bframes;
+  gboolean b_adapt;
+  gboolean b_pyramid;
+  gboolean weightb;
+  guint sps_id;
+  gboolean au_nalu;
+  gboolean trellis;
+  guint vbv_buf_capacity;
+  guint keyint_max;
+  gboolean cabac;
+  gfloat ip_factor;
+  gfloat pb_factor;
+  guint qp_min;
+  guint qp_max;
+  guint qp_step;
+  gboolean mb_tree;
+  gint rc_lookahead;
+  guint noise_reduction;
+  gboolean interlaced;
+  gint speed_preset;
+  gint psy_tune;
+  guint tune;
+  GString *tunings;
+  GString *option_string_prop; /* option-string property */
+  GString *option_string; /* used by set prop */
+
+  /* input description */
+  GstVideoInfo info;
+
+  /* for b-frame delay handling */
+  GQueue *delay;
+
+  guint8 *buffer;
+  gulong buffer_size;
+
+  /* configuration changed  while playing */
+  gboolean reconfig;
+
+  /* from the downstream caps */
+  const gchar *peer_profile;
+  gboolean peer_intra_profile;
+  const x264_level_t *peer_level;
+
+  GstClockTime pending_key_unit_ts;
+  GstEvent *force_key_unit_event;
+};
+
+struct _GstX264EncClass
+{
+  GstElementClass parent_class;
+};
+
+GType gst_x264_enc_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_X264_ENC_H__ */