All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core
@ 2015-05-18 14:12 Alexander Kanavin
  2015-05-18 14:12 ` [PATCH 1/4] python-gst: move it from oe-core to meta-multimedia Alexander Kanavin
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Alexander Kanavin @ 2015-05-18 14:12 UTC (permalink / raw)
  To: openembedded-devel

These patches add GStreamer 0.10, and things that depend on it from oe-core

GStreamer 0.10 is now being removed from oe-core, but we would still like to
provide it through meta-openembedded.

See: https://bugzilla.yoctoproject.org/show_bug.cgi?id=6294

Alexander Kanavin (4):
  python-gst: move it from oe-core to meta-multimedia
  recipes-qt: move qt-mobility from oe-core to meta-oe
  recipes-multimedia: add gstreamer-0.10 recipes
  Rename gstreamer directory to gstreamer-0.10

 .../0001-aacdec-check-channel-count.patch          |   34 +
 .../0001-alac-fix-nb_samples-order-case.patch      |   30 +
 .../0001-alsdec-check-block-length.patch           |   61 +
 ...ac3dec-Check-coding-mode-against-channels.patch |   37 +
 ...util-fix-signedness-in-sizeof-comparissio.patch |   40 +
 ...le-use-av_image_get_linesize-to-calculate.patch |   50 +
 ...c-parser-reset-indexes-on-realloc-failure.patch |   50 +
 ...a-Perform-pointer-advance-and-checks-befo.patch |   81 +
 .../0001-avcodec-smc-fix-off-by-1-error.patch      |   32 +
 ...egtsenc-Check-data-array-size-in-mpegts_w.patch |   69 +
 .../0001-eamad-fix-out-of-array-accesses.patch     |   29 +
 ...-error-concealment-initialize-block-index.patch |   29 +
 ...alment-Check-that-the-picture-is-not-in-a.patch |   37 +
 .../0001-ffserver-set-oformat.patch                |   36 +
 ...t-ref-count-check-and-limit-fix-out-of-ar.patch |   29 +
 ...t-parameters-from-SPS-whenever-it-changes.patch |  145 +
 ...rror-concealment-when-SPS-and-slices-are-.patch |   33 +
 .../0001-h264_sei-Fix-infinite-loop.patch          |   39 +
 ...01-huffyuvdec-Check-init_vlc-return-codes.patch |   87 +
 .../0001-huffyuvdec-Skip-len-0-cases.patch         |   61 +
 ...f-compute-probe-buffer-size-more-reliably.patch |   45 +
 .../0001-mjpegdec-check-SE.patch                   |   32 +
 ...heck-RLE-size-before-copying.-Fix-out-of-.patch |   34 +
 ...er-dont-access-out-of-array-elements-at-t.patch |   44 +
 ...array-index-before-use-fix-out-of-array-a.patch |   30 +
 .../0001-qdm2dec-fix-buffer-overflow.patch         |   58 +
 ...001-roqvideodec-check-dimensions-validity.patch |   36 +
 ...Check-that-the-last-indexes-are-within-th.patch |   32 +
 ...-vp3-Copy-all-3-frames-for-thread-updates.patch |   32 +
 ...-read-for-negative-tokens-and-memleaks-on.patch |  183 +
 ...o-check-chunk-sizes-before-reading-chunks.patch |   51 +
 ...egdec-check-bits-per-pixel-for-changes-si.patch |   68 +
 .../gst-ffmpeg-0.10.13/configure-fix.patch         |   22 +
 .../gst-ffmpeg-CVE-2013-0855.patch                 |  100 +
 .../gst-ffmpeg-CVE-2013-3674.patch                 |   26 +
 .../gst-ffmpeg-0.10.13/h264_qpel_mmx.patch         |   57 +
 .../gst-ffmpeg-0.10.13/libav-9.patch               | 9304 ++++++++++++++++++++
 .../gst-ffmpeg-0.10.13/libav_e500mc.patch          |   21 +
 .../gst-ffmpeg-0.10.13/libav_e5500.patch           |   19 +
 .../gst-ffmpeg-0.10.13/lower-rank.diff             |   16 +
 .../gstreamer-0.10/gst-ffmpeg_0.10.13.bb           |   90 +
 .../gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb      |   14 +
 .../gst-fluendo-mpegdemux_0.10.85.bb               |   12 +
 .../gstreamer-0.10/gst-fluendo.inc                 |   14 +
 .../gstreamer-0.10/gst-meta-base_0.10.bb           |   73 +
 .../gstreamer-0.10/gst-openmax/gcc_4.6.patch       |   18 +
 .../gstreamer-0.10/gst-openmax/ptr-array.patch     |   46 +
 .../gstreamer-0.10/gst-openmax_0.10.1.bb           |   35 +
 .../gstreamer-0.10/gst-plugins-bad_0.10.23.bb      |   50 +
 ...le-Fix-build-on-x86-if-emmintrin.h-is-ava.patch |   37 +
 .../configure.ac-fix-subparse-plugin.patch         |   27 +
 .../gst-plugins-base-tremor.patch                  |   20 +
 .../gstreamer-0.10/gst-plugins-base_0.10.36.bb     |   39 +
 ...-conditional-gl-framebuffer-undefined-use.patch |   35 +
 .../gstreamer-0.10/gst-plugins-gl_0.10.3.bb        |   25 +
 ...ild-with-recent-kernels-the-v4l2_buffer-i.patch |   33 +
 ...define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch |   45 +
 .../0407-mulawdec-fix-integer-overrun.patch        |   47 +
 .../gstreamer-0.10/gst-plugins-good_0.10.31.bb     |   47 +
 .../gstreamer-0.10/gst-plugins-ugly_0.10.19.bb     |   29 +
 .../gstreamer-0.10/gst-plugins.inc                 |   28 +
 ...ecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch |   34 +
 .../gstreamer-0.10/gst-rtsp_0.10.8.bb              |   16 +
 ...ix-self-comparison-always-evaluates-to-tr.patch |   32 +
 .../gstreamer-0.10.36/check_fix.patch              |   19 +
 .../gst-inspect-check-error.patch                  |   16 +
 ...mer-change-priv_gst_parse_yylex-arguments.patch |   33 +
 .../gstreamer-0.10.36/gstregistrybinary.c          |  487 +
 .../gstreamer-0.10.36/gstregistrybinary.h          |  194 +
 .../gstreamer-0.10/gstreamer_0.10.36.bb            |   51 +
 .../gstreamer-0.10/python-gst/python-path.patch    |   28 +
 .../gstreamer-0.10/python-gst_0.10.22.bb           |   29 +
 ...ecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch |   34 -
 .../gstreamer/gst-rtsp_0.10.8.bb                   |   16 -
 ...embedded-usage-doesn-t-work-outside-of-Qt.patch |   73 +
 ...stvideoconnector-fixed-buffers-allocation.patch |   34 +
 ...nnecessary-rpaths-from-qml_device-example.patch |   28 +
 .../fix-compile-error-no-bluez.patch               |  338 +
 .../fix_metaobjectbuilder_build_err.patch          | 4707 ++++++++++
 .../qt-mobility/qt-mobility-1.2.0/gcc-scope.patch  |   48 +
 .../qt-mobility-1.2.0/qt-mobility-configure.patch  |   17 +
 .../qt-mobility-1.2.0/qt-mobility-no-opengl.patch  |   38 +
 .../qt-mobility-1.2.0/qt-mobility-no-xvideo.patch  |   26 +
 .../qt-mobility/qt-mobility-embedded_1.2.0.bb      |   11 +
 .../qt-mobility/qt-mobility-x11_1.2.0.bb           |   10 +
 .../recipes-qt/qt-mobility/qt-mobility_1.2.0.inc   |  112 +
 86 files changed, 18364 insertions(+), 50 deletions(-)
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/configure-fix.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav-9.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e500mc.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e5500.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/lower-rank.diff
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg_0.10.13.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mpegdemux_0.10.85.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo.inc
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-meta-base_0.10.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/gcc_4.6.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/ptr-array.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax_0.10.1.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-bad_0.10.23.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base_0.10.36.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl_0.10.3.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good_0.10.31.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-ugly_0.10.19.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins.inc
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp_0.10.8.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/check_fix.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gst-inspect-check-error.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.c
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.h
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer_0.10.36.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst/python-path.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst_0.10.22.bb
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp_0.10.8.bb
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0001-fix-embedded-usage-doesn-t-work-outside-of-Qt.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0001-gstvideoconnector-fixed-buffers-allocation.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0002-Remove-unnecessary-rpaths-from-qml_device-example.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/fix-compile-error-no-bluez.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/fix_metaobjectbuilder_build_err.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/gcc-scope.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-configure.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-no-opengl.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-no-xvideo.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-embedded_1.2.0.bb
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-x11_1.2.0.bb
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility_1.2.0.inc

-- 
2.1.4



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/4] python-gst: move it from oe-core to meta-multimedia
  2015-05-18 14:12 [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core Alexander Kanavin
@ 2015-05-18 14:12 ` Alexander Kanavin
  2015-05-18 14:12 ` [PATCH 2/4] recipes-qt: move qt-mobility from oe-core to meta-oe Alexander Kanavin
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Alexander Kanavin @ 2015-05-18 14:12 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Alexander Kanavin

From: Alexander Kanavin <alex.kanavin@gmail.com>

This will allow removal of unsupported gstreamer 0.10 from oe-core

Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com>
---
 .../gstreamer/python-gst/python-path.patch         | 28 +++++++++++++++++++++
 .../gstreamer/python-gst_0.10.22.bb                | 29 ++++++++++++++++++++++
 2 files changed, 57 insertions(+)
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/python-gst/python-path.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/python-gst_0.10.22.bb

diff --git a/meta-multimedia/recipes-multimedia/gstreamer/python-gst/python-path.patch b/meta-multimedia/recipes-multimedia/gstreamer/python-gst/python-path.patch
new file mode 100644
index 0000000..21b5bbf
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/python-gst/python-path.patch
@@ -0,0 +1,28 @@
+Upstream-Status:Pending
+
+Index: gst-python-0.10.19/acinclude.m4
+===================================================================
+--- gst-python-0.10.19.orig/acinclude.m4	2010-04-21 15:23:44.000000000 -0700
++++ gst-python-0.10.19/acinclude.m4	2010-11-15 14:43:00.642994001 -0800
+@@ -43,6 +43,13 @@
+ [AC_REQUIRE([AM_PATH_PYTHON])
+ AC_MSG_CHECKING(for headers required to compile python extensions)
+ dnl deduce PYTHON_INCLUDES
++
++AC_ARG_WITH(python-includes,
++	[  --with-python-includes=DIR  path to Python includes], py_exec_prefix=$withval)
++if test x$py_exec_prefix != x; then
++PYTHON_INCLUDES="-I${py_exec_prefix}/include/python${PYTHON_VERSION}"
++py_prefix="${py_exec_prefix}"
++else
+ py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
+ py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
+ if $PYTHON-config --help 2>/dev/null; then
+@@ -53,6 +60,7 @@
+     PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
+   fi
+ fi
++fi
+ AC_SUBST(PYTHON_INCLUDES)
+ dnl check if the headers exist:
+ save_CPPFLAGS="$CPPFLAGS"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/python-gst_0.10.22.bb b/meta-multimedia/recipes-multimedia/gstreamer/python-gst_0.10.22.bb
new file mode 100644
index 0000000..2a5f2b3
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/python-gst_0.10.22.bb
@@ -0,0 +1,29 @@
+SUMMARY = "Python bindings for the GStreamer multimedia framework"
+SECTION = "devel/python"
+LICENSE = "LGPLv2.1"
+DEPENDS = "gstreamer gst-plugins-base python-pygobject"
+RDEPENDS_${PN} += "python-pygtk"
+PR = "r2"
+
+SRC_URI = "http://gstreamer.freedesktop.org/src/gst-python/gst-python-${PV}.tar.bz2 \
+           file://python-path.patch"
+
+SRC_URI[md5sum] = "937152fe896241f827689f4b53e79b22"
+SRC_URI[sha256sum] = "8f26f519a5bccd770864317e098e5e307fc5ad1201eb96329634b6508b253178"
+S = "${WORKDIR}/gst-python-${PV}"
+
+LIC_FILES_CHKSUM = "file://COPYING;md5=39ff67e932b7bdfa9b78bad67151690b"
+
+inherit autotools distutils-base pkgconfig
+
+EXTRA_OECONF += "--with-python-includes=${STAGING_INCDIR}/../"
+
+FILES_${PN} += "${datadir}/gst-python"
+FILES_${PN}-dev += "${datadir}/gst-python/0.10/defs"
+FILES_${PN}-dbg += "${libdir}/${PYTHON_DIR}/site-packages/gst-0.10/gst/.debug/ ${libdir}/gstreamer-0.10/.debug/"
+
+do_configure_prepend() {
+	if [ `find ${STAGING_LIBDIR} -name libpython*.so` ]; then
+		ln -sf ${STAGING_LIBDIR}/libpython*.so `find ${STAGING_LIBDIR} -name libpython*.a -exec dirname {} \;`
+	fi
+}
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/4] recipes-qt: move qt-mobility from oe-core to meta-oe
  2015-05-18 14:12 [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core Alexander Kanavin
  2015-05-18 14:12 ` [PATCH 1/4] python-gst: move it from oe-core to meta-multimedia Alexander Kanavin
@ 2015-05-18 14:12 ` Alexander Kanavin
  2015-05-18 14:12 ` [PATCH 3/4] recipes-multimedia: add gstreamer-0.10 recipes Alexander Kanavin
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Alexander Kanavin @ 2015-05-18 14:12 UTC (permalink / raw)
  To: openembedded-devel

This will allow removal of gstreamer 0.10 from oe-core

Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com>
---
 ...embedded-usage-doesn-t-work-outside-of-Qt.patch |   73 +
 ...stvideoconnector-fixed-buffers-allocation.patch |   34 +
 ...nnecessary-rpaths-from-qml_device-example.patch |   28 +
 .../fix-compile-error-no-bluez.patch               |  338 ++
 .../fix_metaobjectbuilder_build_err.patch          | 4707 ++++++++++++++++++++
 .../qt-mobility/qt-mobility-1.2.0/gcc-scope.patch  |   48 +
 .../qt-mobility-1.2.0/qt-mobility-configure.patch  |   17 +
 .../qt-mobility-1.2.0/qt-mobility-no-opengl.patch  |   38 +
 .../qt-mobility-1.2.0/qt-mobility-no-xvideo.patch  |   26 +
 .../qt-mobility/qt-mobility-embedded_1.2.0.bb      |   11 +
 .../qt-mobility/qt-mobility-x11_1.2.0.bb           |   10 +
 .../recipes-qt/qt-mobility/qt-mobility_1.2.0.inc   |  112 +
 12 files changed, 5442 insertions(+)
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0001-fix-embedded-usage-doesn-t-work-outside-of-Qt.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0001-gstvideoconnector-fixed-buffers-allocation.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0002-Remove-unnecessary-rpaths-from-qml_device-example.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/fix-compile-error-no-bluez.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/fix_metaobjectbuilder_build_err.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/gcc-scope.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-configure.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-no-opengl.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-no-xvideo.patch
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-embedded_1.2.0.bb
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-x11_1.2.0.bb
 create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility_1.2.0.inc

diff --git a/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0001-fix-embedded-usage-doesn-t-work-outside-of-Qt.patch b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0001-fix-embedded-usage-doesn-t-work-outside-of-Qt.patch
new file mode 100644
index 0000000..d8d88c2
--- /dev/null
+++ b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0001-fix-embedded-usage-doesn-t-work-outside-of-Qt.patch
@@ -0,0 +1,73 @@
+From de2b568a4f14f38ae26960f543277bd2ac57c9d6 Mon Sep 17 00:00:00 2001
+From: Alex <qt-info@nokia.com>
+Date: Tue, 10 May 2011 14:54:49 +1000
+Subject: [PATCH] fix !embedded usage (doesn't work outside of Qt)
+
+embedded is part of QT_CONFIG and not CONFIG
+
+Task-number: QTMOBILITY-1586
+---
+Upstream-Status: Backport
+https://qt.gitorious.org/qt-mobility/qt-mobility/commit/de2b568a4f14f38ae26960f543277bd2ac57c9d6
+EB: refreshed the patch for it to apply properly
+
+ plugins/multimedia/gstreamer/gstreamer.pro | 2 +-
+ src/systeminfo/systeminfo.pro              | 6 +++---
+ tests/auto/auto.pro                        | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+Index: qt-mobility-opensource-src-1.2.0/plugins/multimedia/gstreamer/gstreamer.pro
+===================================================================
+--- qt-mobility-opensource-src-1.2.0.orig/plugins/multimedia/gstreamer/gstreamer.pro	2013-09-19 10:34:40.880862884 +0200
++++ qt-mobility-opensource-src-1.2.0/plugins/multimedia/gstreamer/gstreamer.pro	2013-09-19 10:35:22.844862550 +0200
+@@ -85,7 +85,7 @@
+     qgstutils.cpp
+ 
+ 
+-!win32:!embedded:!mac:!symbian:!simulator:!contains(QT_CONFIG, qpa) {
++!win32:!contains(QT_CONFIG,embedded):!mac:!symbian:!simulator:!contains(QT_CONFIG, qpa) {
+     LIBS += -lXv -lX11 -lXext
+ 
+     HEADERS += \
+Index: qt-mobility-opensource-src-1.2.0/src/systeminfo/systeminfo.pro
+===================================================================
+--- qt-mobility-opensource-src-1.2.0.orig/src/systeminfo/systeminfo.pro	2013-09-19 10:34:40.884862884 +0200
++++ qt-mobility-opensource-src-1.2.0/src/systeminfo/systeminfo.pro	2013-09-19 10:36:05.480862210 +0200
+@@ -101,7 +101,7 @@
+             LIBS += -lblkid
+         }
+ 
+-        !embedded:!contains(QT_CONFIG,qpa): {
++        !contains(QT_CONFIG,embedded):!contains(QT_CONFIG,qpa): {
+             LIBS += -lX11 -lXrandr
+         }
+ 
+@@ -154,7 +154,7 @@
+                 #for now... udisks
+             } else {
+                 DEFINES += QT_NO_UDISKS
+-                !embedded:!contains(QT_CONFIG,qpa): LIBS += -lX11 -lXrandr
++                !contains(QT_CONFIG,embedded):!contains(QT_CONFIG,qpa): LIBS += -lX11 -lXrandr
+             }
+ 
+             contains(connman_enabled, yes): {
+@@ -165,7 +165,7 @@
+             }
+         } else {
+             DEFINES += QT_NO_NETWORKMANAGER QT_NO_UDISKS QT_NO_CONNMAN
+-            !embedded:!contains(QT_CONFIG,qpa): LIBS += -lX11 -lXrandr
++            !contains(QT_CONFIG,embedded):!contains(QT_CONFIG,qpa): LIBS += -lX11 -lXrandr
+         }
+      }
+ 
+Index: qt-mobility-opensource-src-1.2.0/tests/auto/auto.pro
+===================================================================
+--- qt-mobility-opensource-src-1.2.0.orig/tests/auto/auto.pro	2013-09-19 10:34:40.884862884 +0200
++++ qt-mobility-opensource-src-1.2.0/tests/auto/auto.pro	2013-09-19 10:35:22.844862550 +0200
+@@ -21,5 +21,5 @@
+ # which require that the autotest is run on the same machine
+ # doing the build - i.e. cross-compilation is not allowed.
+ win32|mac|linux-g++* {
+-    !embedded:!maemo5:!maemo6:SUBDIRS+=host.pro
++    !contains(QT_CONFIG,embedded):!maemo5:!maemo6:SUBDIRS+=host.pro
+ }
diff --git a/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0001-gstvideoconnector-fixed-buffers-allocation.patch b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0001-gstvideoconnector-fixed-buffers-allocation.patch
new file mode 100644
index 0000000..2df76fc
--- /dev/null
+++ b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0001-gstvideoconnector-fixed-buffers-allocation.patch
@@ -0,0 +1,34 @@
+Upstream-Status: Submitted [QTMOBILITY-1611]
+
+From b308508b49afa9a129b4e4589c57cd107d1320b8 Mon Sep 17 00:00:00 2001
+From: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
+Date: Fri, 6 May 2011 10:35:11 +1000
+Subject: [PATCH] gstvideoconnector: fixed buffers allocation
+
+It should not be necessary, but at least theora video decoder doesn't
+iniatilize *buf, while gst_pad_alloc_buffer relies on buf being NULL.
+
+Task-number: QTMOBILITY-1611
+Reviewed-by: Michael Goddard
+---
+ plugins/multimedia/gstreamer/gstvideoconnector.c |    4 ++++
+ 1 files changed, 4 insertions(+), 0 deletions(-)
+
+diff --git a/plugins/multimedia/gstreamer/gstvideoconnector.c b/plugins/multimedia/gstreamer/gstvideoconnector.c
+index ddf68e0..9f8ceae 100644
+--- a/plugins/multimedia/gstreamer/gstvideoconnector.c
++++ b/plugins/multimedia/gstreamer/gstvideoconnector.c
+@@ -186,6 +186,10 @@ gst_video_connector_buffer_alloc (GstPad * pad, guint64 offset, guint size,
+     GstFlowReturn res = GST_FLOW_OK;
+     element = GST_VIDEO_CONNECTOR (GST_PAD_PARENT (pad));
+ 
++    if (!buf)
++        return GST_FLOW_ERROR;
++    *buf = NULL;
++
+     GST_OBJECT_LOCK (element);
+     gst_object_ref(element->srcpad);
+     GST_OBJECT_UNLOCK (element);
+-- 
+1.7.4.1
+
diff --git a/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0002-Remove-unnecessary-rpaths-from-qml_device-example.patch b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0002-Remove-unnecessary-rpaths-from-qml_device-example.patch
new file mode 100644
index 0000000..a411640
--- /dev/null
+++ b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0002-Remove-unnecessary-rpaths-from-qml_device-example.patch
@@ -0,0 +1,28 @@
+From 92e0c611f4969c716616d64df64831387e5b1632 Mon Sep 17 00:00:00 2001
+From: Paul Eggleton <paul.eggleton@linux.intel.com>
+Date: Fri, 16 Mar 2012 10:24:00 +0000
+Subject: [PATCH] Remove unnecessary rpaths from qml_device example
+
+These can't be valid in any case.
+
+Upstream-Status: Pending
+
+Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
+---
+ examples/declarative-systeminfo/device/device.pro |    3 ---
+ 1 files changed, 0 insertions(+), 3 deletions(-)
+
+diff --git a/examples/declarative-systeminfo/device/device.pro b/examples/declarative-systeminfo/device/device.pro
+index 698e5fb..05be9b7 100644
+--- a/examples/declarative-systeminfo/device/device.pro
++++ b/examples/declarative-systeminfo/device/device.pro
+@@ -17,6 +17,3 @@ symbian {
+ }
+ RESOURCES += device.qrc
+ 
+-QMAKE_LFLAGS_DEBUG += "-Wl,-rpath,/home/user/qt/lib"
+-QMAKE_LFLAGS_RPATH += "-Wl,-rpath,/home/user/qt/lib"
+-QMAKE_LFLAGS_RELEASE += "-Wl,-rpath,/home/user/qt/lib"
+-- 
+1.7.5.4
+
diff --git a/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/fix-compile-error-no-bluez.patch b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/fix-compile-error-no-bluez.patch
new file mode 100644
index 0000000..3f03cf7
--- /dev/null
+++ b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/fix-compile-error-no-bluez.patch
@@ -0,0 +1,338 @@
+From bb05733bd5a685b00f80ddc73a1b7a9a2ba0eb11 Mon Sep 17 00:00:00 2001
+From: Andrew Stanley-Jones <andrew.stanley-jones@nokia.com>
+Date: Thu, 12 May 2011 13:07:13 +1000
+Subject: [PATCH] Fix compile error if bluez is not installed
+
+Upstream-Status: Backport
+
+Task-number: QTMOBILITY-1576
+---
+ src/connectivity/bluetooth/bluetooth.pri           |    1 +
+ .../bluetooth/qbluetoothdevicediscoveryagent.h     |    2 +-
+ .../bluetooth/qbluetoothdevicediscoveryagent_p.cpp |    2 +-
+ .../bluetooth/qbluetoothdevicediscoveryagent_p.h   |    6 +++---
+ .../bluetooth/qbluetoothlocaldevice_p.h            |    4 ++--
+ .../bluetooth/qbluetoothservicediscoveryagent.h    |    2 +-
+ .../bluetooth/qbluetoothservicediscoveryagent_p.h  |    8 ++++----
+ .../bluetooth/qbluetoothserviceinfo_p.cpp          |    2 +-
+ .../bluetooth/qbluetoothserviceinfo_p.h            |    4 ++--
+ src/connectivity/bluetooth/ql2capserver.h          |    2 +-
+ src/connectivity/bluetooth/ql2capserver_p.cpp      |    2 +-
+ src/connectivity/bluetooth/ql2capserver_p.h        |    6 +++---
+ src/connectivity/bluetooth/qrfcommserver.h         |    2 +-
+ src/connectivity/bluetooth/qrfcommserver_p.cpp     |    2 +-
+ src/connectivity/bluetooth/qrfcommserver_p.h       |    6 +++---
+ tests/tests.pro                                    |    4 +++-
+ 16 files changed, 29 insertions(+), 26 deletions(-)
+
+diff --git a/src/connectivity/bluetooth/bluetooth.pri b/src/connectivity/bluetooth/bluetooth.pri
+index 717a1ad..4fa2c15 100644
+--- a/src/connectivity/bluetooth/bluetooth.pri
++++ b/src/connectivity/bluetooth/bluetooth.pri
+@@ -103,6 +103,7 @@ symbian {
+     }
+ } else:contains(bluez_enabled, yes):contains(QT_CONFIG, dbus) {
+     QT *= dbus
++    DEFINES += QTM_BLUEZ_BLUETOOTH
+ 
+     include(bluez/bluez.pri)
+ 
+diff --git a/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent.h b/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent.h
+index a95c467..00cfd14 100644
+--- a/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent.h
++++ b/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent.h
+@@ -101,7 +101,7 @@ private:
+     Q_DECLARE_PRIVATE(QBluetoothDeviceDiscoveryAgent)
+     QBluetoothDeviceDiscoveryAgentPrivate *d_ptr;
+ 
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+     Q_PRIVATE_SLOT(d_func(), void _q_deviceFound(const QString &address, const QVariantMap &dict));
+     Q_PRIVATE_SLOT(d_func(), void _q_propertyChanged(const QString &name, const QDBusVariant &value));
+ #endif
+diff --git a/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.cpp b/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.cpp
+index 6edbd16..512002d 100644
+--- a/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.cpp
++++ b/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.cpp
+@@ -69,7 +69,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start()
+ void QBluetoothDeviceDiscoveryAgentPrivate::stop()
+ {
+ }
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+ void QBluetoothDeviceDiscoveryAgentPrivate::_q_deviceFound(const QString &address,
+                                                            const QVariantMap &dict)
+ {
+diff --git a/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.h b/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.h
+index 0e34e05..700e78d 100644
+--- a/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.h
++++ b/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.h
+@@ -46,7 +46,7 @@
+ 
+ #include <QVariantMap>
+ 
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+ class OrgBluezManagerInterface;
+ class OrgBluezAdapterInterface;
+ class QDBusVariant;
+@@ -80,7 +80,7 @@ public:
+             QString errorDescription);
+ #endif
+ 
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+     void _q_deviceFound(const QString &address, const QVariantMap &dict);
+     void _q_propertyChanged(const QString &name, const QDBusVariant &value);
+ #endif
+@@ -100,7 +100,7 @@ private:
+     bool pendingCancel;
+     bool pendingStart;
+ 
+-#if !defined(QT_NO_DBUS)
++#ifdef QTM_BLUEZ_BLUETOOTH
+     OrgBluezManagerInterface *manager;
+     OrgBluezAdapterInterface *adapter;
+ #endif
+diff --git a/src/connectivity/bluetooth/qbluetoothlocaldevice_p.h b/src/connectivity/bluetooth/qbluetoothlocaldevice_p.h
+index 750c286..381d6b5 100644
+--- a/src/connectivity/bluetooth/qbluetoothlocaldevice_p.h
++++ b/src/connectivity/bluetooth/qbluetoothlocaldevice_p.h
+@@ -51,7 +51,7 @@
+ #include <btengsettings.h>
+ #endif
+ 
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+ #include <QObject>
+ #include <QDBusContext>
+ #include <QDBusObjectPath>
+@@ -68,7 +68,7 @@ QTM_BEGIN_NAMESPACE
+ 
+ class QBluetoothAddress;
+ 
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+ class QBluetoothLocalDevicePrivate : public QObject,
+                                      protected QDBusContext
+ {
+diff --git a/src/connectivity/bluetooth/qbluetoothservicediscoveryagent.h b/src/connectivity/bluetooth/qbluetoothservicediscoveryagent.h
+index 6279432..7eeccfc 100644
+--- a/src/connectivity/bluetooth/qbluetoothservicediscoveryagent.h
++++ b/src/connectivity/bluetooth/qbluetoothservicediscoveryagent.h
+@@ -105,7 +105,7 @@ private:
+     Q_PRIVATE_SLOT(d_func(), void _q_deviceDiscovered(const QBluetoothDeviceInfo &info))
+     Q_PRIVATE_SLOT(d_func(), void _q_deviceDiscoveryFinished())
+     Q_PRIVATE_SLOT(d_func(), void _q_serviceDiscoveryFinished())
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+     Q_PRIVATE_SLOT(d_func(), void _q_discoveredServices(QDBusPendingCallWatcher*))
+     Q_PRIVATE_SLOT(d_func(), void _q_createdDevice(QDBusPendingCallWatcher*))
+ #endif
+diff --git a/src/connectivity/bluetooth/qbluetoothservicediscoveryagent_p.h b/src/connectivity/bluetooth/qbluetoothservicediscoveryagent_p.h
+index 5e7da43..f25c293 100644
+--- a/src/connectivity/bluetooth/qbluetoothservicediscoveryagent_p.h
++++ b/src/connectivity/bluetooth/qbluetoothservicediscoveryagent_p.h
+@@ -53,7 +53,7 @@
+ #include <btsdp.h>
+ #endif
+ 
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+ class OrgBluezManagerInterface;
+ class OrgBluezAdapterInterface;
+ class OrgBluezDeviceInterface;
+@@ -99,7 +99,7 @@ public:
+     void _q_deviceDiscoveryFinished();
+     void _q_deviceDiscovered(const QBluetoothDeviceInfo &info);
+     void _q_serviceDiscoveryFinished();
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+     void _q_discoveredServices(QDBusPendingCallWatcher *watcher);
+     void _q_createdDevice(QDBusPendingCallWatcher *watcher);
+ #endif
+@@ -123,7 +123,7 @@ private:
+ #ifdef QTM_SYMBIAN_BLUETOOTH
+     void startL(const QBluetoothAddress &address);
+     void initL(const QBluetoothAddress &address);
+-#elif !defined(QT_NO_DBUS)
++#elif defined(QTM_BLUEZ_BLUETOOTH)
+     QVariant readAttributeValue(QXmlStreamReader &xml);
+ #endif
+ 
+@@ -153,7 +153,7 @@ private:
+     TSdpAttributeID m_currentAttributeId;
+ 
+     QStack<QVariant> m_stack;
+-#elif !defined(QT_NO_DBUS)
++#elif defined(QTM_BLUEZ_BLUETOOTH)
+     OrgBluezManagerInterface *manager;
+     OrgBluezAdapterInterface *adapter;
+     OrgBluezDeviceInterface *device;
+diff --git a/src/connectivity/bluetooth/qbluetoothserviceinfo_p.cpp b/src/connectivity/bluetooth/qbluetoothserviceinfo_p.cpp
+index 814458c..dd96dcc 100644
+--- a/src/connectivity/bluetooth/qbluetoothserviceinfo_p.cpp
++++ b/src/connectivity/bluetooth/qbluetoothserviceinfo_p.cpp
+@@ -79,7 +79,7 @@ void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId
+     Q_UNUSED(attributeId);
+ }
+ 
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+ bool QBluetoothServiceInfoPrivate::registerService() const
+ {
+     return false;
+diff --git a/src/connectivity/bluetooth/qbluetoothserviceinfo_p.h b/src/connectivity/bluetooth/qbluetoothserviceinfo_p.h
+index 5be7341..8e4254c 100644
+--- a/src/connectivity/bluetooth/qbluetoothserviceinfo_p.h
++++ b/src/connectivity/bluetooth/qbluetoothserviceinfo_p.h
+@@ -72,7 +72,7 @@ public:
+ 
+     bool ensureSdpConnection() const;
+ 
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+     bool registerService() const;
+ #endif
+ 
+@@ -89,7 +89,7 @@ public:
+     mutable TSdpServRecordHandle serviceRecord;
+ #endif
+ 
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+     mutable OrgBluezServiceInterface *service;
+     mutable quint32 serviceRecord;
+     mutable bool registered;
+diff --git a/src/connectivity/bluetooth/ql2capserver.h b/src/connectivity/bluetooth/ql2capserver.h
+index 99c20a5..bed65a3 100644
+--- a/src/connectivity/bluetooth/ql2capserver.h
++++ b/src/connectivity/bluetooth/ql2capserver.h
+@@ -97,7 +97,7 @@ private:
+     Q_PRIVATE_SLOT(d_func(), void _q_disconnected())
+ #endif //QTM_SYMBIAN_BLUETOOTH
+     
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+     Q_PRIVATE_SLOT(d_func(), void _q_newConnection())
+ #endif
+ 
+diff --git a/src/connectivity/bluetooth/ql2capserver_p.cpp b/src/connectivity/bluetooth/ql2capserver_p.cpp
+index 3a2199f..f19977e 100644
+--- a/src/connectivity/bluetooth/ql2capserver_p.cpp
++++ b/src/connectivity/bluetooth/ql2capserver_p.cpp
+@@ -101,7 +101,7 @@ QBluetooth::SecurityFlags QL2capServer::securityFlags() const
+ 
+ 
+ 
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+ void QL2capServerPrivate::_q_newConnection()
+ {
+ }
+diff --git a/src/connectivity/bluetooth/ql2capserver_p.h b/src/connectivity/bluetooth/ql2capserver_p.h
+index b5e76d9..2823106 100644
+--- a/src/connectivity/bluetooth/ql2capserver_p.h
++++ b/src/connectivity/bluetooth/ql2capserver_p.h
+@@ -50,7 +50,7 @@
+ #include <bt_sock.h>
+ #endif //QTM_SYMBIAN_BLUETOOTH
+ 
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+ QT_FORWARD_DECLARE_CLASS(QSocketNotifier)
+ #endif
+ 
+@@ -82,7 +82,7 @@ public:
+     void _q_disconnected();
+ #endif //QTM_SYMBIAN_BLUETOOTH
+     
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+     void _q_newConnection();
+ #endif
+ 
+@@ -103,7 +103,7 @@ protected:
+     QL2capServer *q_ptr;
+ 
+ private:
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+     QSocketNotifier *socketNotifier;
+ #endif
+ };
+diff --git a/src/connectivity/bluetooth/qrfcommserver.h b/src/connectivity/bluetooth/qrfcommserver.h
+index 3f348dd..7974ba6 100644
+--- a/src/connectivity/bluetooth/qrfcommserver.h
++++ b/src/connectivity/bluetooth/qrfcommserver.h
+@@ -97,7 +97,7 @@ private:
+     Q_PRIVATE_SLOT(d_func(), void _q_disconnected())
+ #endif //QTM_SYMBIAN_BLUETOOTH  
+     
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+     Q_PRIVATE_SLOT(d_func(), void _q_newConnection())
+ #endif
+ };
+diff --git a/src/connectivity/bluetooth/qrfcommserver_p.cpp b/src/connectivity/bluetooth/qrfcommserver_p.cpp
+index f8145d9..eb14d64 100644
+--- a/src/connectivity/bluetooth/qrfcommserver_p.cpp
++++ b/src/connectivity/bluetooth/qrfcommserver_p.cpp
+@@ -90,7 +90,7 @@ quint16 QRfcommServer::serverPort() const
+ }
+ 
+ 
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+ void QRfcommServerPrivate::_q_newConnection()
+ {
+ }
+diff --git a/src/connectivity/bluetooth/qrfcommserver_p.h b/src/connectivity/bluetooth/qrfcommserver_p.h
+index da6e28b..af40df7 100644
+--- a/src/connectivity/bluetooth/qrfcommserver_p.h
++++ b/src/connectivity/bluetooth/qrfcommserver_p.h
+@@ -51,7 +51,7 @@
+ #include <bt_sock.h>
+ #endif
+ 
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+ QT_FORWARD_DECLARE_CLASS(QSocketNotifier)
+ #endif
+ 
+@@ -83,7 +83,7 @@ public:
+     void _q_disconnected();
+ #endif //QTM_SYMBIAN_BLUETOOTH
+ 
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+     void _q_newConnection();
+ #endif
+ 
+@@ -102,7 +102,7 @@ protected:
+     QRfcommServer *q_ptr;
+ 
+ private:
+-#ifndef QT_NO_DBUS
++#ifdef QTM_BLUEZ_BLUETOOTH
+     QSocketNotifier *socketNotifier;
+ #endif
+ };
+diff --git a/tests/tests.pro b/tests/tests.pro
+index 2f2c355..4800e5e 100644
+--- a/tests/tests.pro
++++ b/tests/tests.pro
+@@ -16,7 +16,9 @@ contains(mobility_modules,systeminfo): SUBDIRS += sysinfo-tester
+ contains(mobility_modules,connectivity) {
+     SUBDIRS += nfctestserver
+ 
+-    linux*:!linux-armcc: SUBDIRS += btclient
++    linux*:!linux-armcc:contains(bluez_enabled, yes):contains(QT_CONFIG, dbus) {
++        SUBDIRS += btclient
++    }
+ }
+ 
+ symbian {
+-- 
+1.7.1
+
diff --git a/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/fix_metaobjectbuilder_build_err.patch b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/fix_metaobjectbuilder_build_err.patch
new file mode 100644
index 0000000..cffb067
--- /dev/null
+++ b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/fix_metaobjectbuilder_build_err.patch
@@ -0,0 +1,4707 @@
+Fix metaobjectbuilder build errors against Qt 4.8 and 4.7
+
+Error message:
+ipc/qmetaobjectbuilder.cpp:803:65: error: invalid conversion from \
+'QMetaObjectExtraData::StaticMetacallFunction {aka void (*)(QObject*, \
+QMetaObject::Call, int, void**)}' to 'QtMobility::QMetaObjectBuilder:: \
+StaticMetacallFunction {aka int (*)(QMetaObject::Call, int, void**)}
+
+Upstream-commit:
+http://qt.gitorious.org/qt-mobility/qt-mobility/commit/f102053b28009b3094b0e5777177208afa6097c5
+
+Task-number: QTMOBILITY-1990
+
+Upstream-Status: Backport
+
+Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
+------------------------------------------------------
+diff --git a/plugins/declarative/common/dynamicproperties.pri b/plugins/declarative/common/dynamicproperties.pri
+index 52737a3..4bd06de 100644
+--- a/plugins/declarative/common/dynamicproperties.pri
++++ b/plugins/declarative/common/dynamicproperties.pri
+@@ -1,6 +1,8 @@
+ INCLUDEPATH += ../../../plugins/declarative/common/dynamicproperties/
+-HEADERS += ../../../plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject_p.h \
+-	   ../../../plugins/declarative/common/dynamicproperties/qmetaobjectbuilder_p.h
+-SOURCES += ../../../plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject.cpp \
+-           ../../../src/serviceframework/ipc/qmetaobjectbuilder.cpp
+-
++HEADERS += ../../../plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject_p.h
++SOURCES += ../../../plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject.cpp
++include(../../../src/serviceframework/ipc/metaobjectbuilder.pri)
++INCLUDEPATH += ../../../src/serviceframework/$$OBJECTBUILDER_INCLUDEPATH
++DEPENDPATH += ../../../src/serviceframework/$$OBJECTBUILDER_DEPENDPATH
++HEADERS += ../../../src/serviceframework/$$OBJECTBUILDER_HEADERS
++SOURCES += ../../../src/serviceframework/$$OBJECTBUILDER_SOURCES
+diff --git a/plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject.cpp b/plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject.cpp
+index 79a2064..9eb6810 100644
+--- a/plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject.cpp
++++ b/plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject.cpp
+@@ -65,8 +65,7 @@ public:
+     {
+         int id = mob.propertyCount();
+         mob.addSignal("__" + QByteArray::number(id) + "()");
+-        QMetaPropertyBuilder build = mob.addProperty(name, type, id);
+-        build.setDynamic(true);
++        mob.addProperty(name, type, id);
+         qFree(mem);
+         mem = mob.toMetaObject();
+ 
+diff --git a/plugins/declarative/common/dynamicproperties/qmetaobjectbuilder_p.h b/plugins/declarative/common/dynamicproperties/qmetaobjectbuilder_p.h
+deleted file mode 100644
+index bd937e4..0000000
+--- a/plugins/declarative/common/dynamicproperties/qmetaobjectbuilder_p.h
++++ /dev/null
+@@ -1,48 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+-** All rights reserved.
+-** Contact: Nokia Corporation (qt-info@nokia.com)
+-**
+-** This file is part of the Qt Mobility Components.
+-**
+-** $QT_BEGIN_LICENSE:LGPL$
+-** No Commercial Usage
+-** This file contains pre-release code and may not be distributed.
+-** You may use this file in accordance with the terms and conditions
+-** contained in the Technology Preview License Agreement accompanying
+-** this package.
+-**
+-** GNU Lesser General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU Lesser
+-** General Public License version 2.1 as published by the Free Software
+-** Foundation and appearing in the file LICENSE.LGPL included in the
+-** packaging of this file.  Please review the following information to
+-** ensure the GNU Lesser General Public License version 2.1 requirements
+-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+-**
+-** In addition, as a special exception, Nokia gives you certain additional
+-** rights.  These rights are described in the Nokia Qt LGPL Exception
+-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+-**
+-** If you have questions regarding the use of this file, please contact
+-** Nokia at qt-info@nokia.com.
+-**
+-**
+-**
+-**
+-**
+-**
+-**
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-
+-/*
+-This header gets used in a number of different QML plugins
+-and also in the source tree of Mobility itself.
+-
+-So this header is just a wrapper to grab it from there.
+-*/
+-#include "../../../../src/serviceframework/ipc/qmetaobjectbuilder_p.h"
+diff --git a/src/serviceframework/ipc/ipc.pri b/src/serviceframework/ipc/ipc.pri
+index 28b910f..d809f59 100644
+--- a/src/serviceframework/ipc/ipc.pri
++++ b/src/serviceframework/ipc/ipc.pri
+@@ -25,9 +25,14 @@ else {
+     }
+ }
+ 
++include(metaobjectbuilder.pri)
++INCLUDEPATH += $$OBJECTBUILDER_INCLUDEPATH
++DEPENDPATH += $$OBJECTBUILDER_DEPENDPATH
++PRIVATE_HEADERS += $$OBJECTBUILDER_HEADERS
++SOURCES += $$OBJECTBUILDER_SOURCES
++
+ PRIVATE_HEADERS += ipc/qslotinvoker_p.h \
+     ipc/qsignalintercepter_p.h \
+-    ipc/qmetaobjectbuilder_p.h \
+     ipc/instancemanager_p.h \
+     ipc/qservicepackage_p.h \
+     ipc/proxyobject_p.h \
+@@ -37,7 +42,6 @@ PRIVATE_HEADERS += ipc/qslotinvoker_p.h \
+ 
+ SOURCES += ipc/qslotinvoker.cpp \
+     ipc/qsignalintercepter.cpp \
+-    ipc/qmetaobjectbuilder.cpp \
+     ipc/instancemanager.cpp \
+     ipc/qservicepackage.cpp \
+     ipc/proxyobject.cpp \
+diff --git a/src/serviceframework/ipc/metaobjectbuilder.pri b/src/serviceframework/ipc/metaobjectbuilder.pri
+new file mode 100644
+index 0000000..cc905f9
+--- /dev/null
++++ b/src/serviceframework/ipc/metaobjectbuilder.pri
+@@ -0,0 +1,12 @@
++#check version for 4.7 ...
++contains(QT_MAJOR_VERSION, 4):lessThan(QT_MINOR_VERSION, 8) {
++  OBJECTBUILDER_INCLUDEPATH += ipc
++  OBJECTBUILDER_DEPENDPATH += ipc
++  OBJECTBUILDER_HEADERS += ipc/qmetaobjectbuilder_47_p.h
++  OBJECTBUILDER_SOURCES += ipc/qmetaobjectbuilder_47.cpp
++} else {
++  OBJECTBUILDER_INCLUDEPATH += ipc
++  OBJECTBUILDER_DEPENDPATH += ipc
++  OBJECTBUILDER_HEADERS += ipc/qmetaobjectbuilder_p.h
++  OBJECTBUILDER_SOURCES += ipc/qmetaobjectbuilder.cpp
++}
+diff --git a/src/serviceframework/ipc/qmetaobjectbuilder.cpp b/src/serviceframework/ipc/qmetaobjectbuilder.cpp
+index b19eb1a..6ffaa20 100644
+--- a/src/serviceframework/ipc/qmetaobjectbuilder.cpp
++++ b/src/serviceframework/ipc/qmetaobjectbuilder.cpp
+@@ -117,6 +117,8 @@ enum PropertyFlags  {
+     EnumOrFlag = 0x00000008,
+     StdCppSet = 0x00000100,
+ //    Override = 0x00000200,
++    Constant = 0x00000400,
++    Final = 0x00000800,
+     Designable = 0x00001000,
+     ResolveDesignable = 0x00002000,
+     Scriptable = 0x00004000,
+@@ -128,7 +130,7 @@ enum PropertyFlags  {
+     User = 0x00100000,
+     ResolveUser = 0x00200000,
+     Notify = 0x00400000,
+-    Dynamic = 0x00800000
++    Revisioned = 0x00800000
+ };
+ 
+ enum MethodFlags  {
+@@ -145,7 +147,8 @@ enum MethodFlags  {
+ 
+     MethodCompatibility = 0x10,
+     MethodCloned = 0x20,
+-    MethodScriptable = 0x40
++    MethodScriptable = 0x40,
++    MethodRevisioned = 0x80
+ };
+ 
+ struct QMetaObjectPrivate
+@@ -623,6 +626,8 @@ QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& protot
+     property.setUser(prototype.isUser());
+     property.setStdCppSet(prototype.hasStdCppSet());
+     property.setEnumOrFlag(prototype.isEnumType());
++    property.setConstant(prototype.isConstant());
++    property.setFinal(prototype.isFinal());
+     if (prototype.hasNotifySignal()) {
+         // Find an existing method for the notify signal, or add a new one.
+         QMetaMethod method = prototype.notifySignal();
+@@ -796,7 +801,7 @@ void QMetaObjectBuilder::addMetaObject
+     }
+ 
+     if ((members & StaticMetacall) != 0) {
+-        if (priv(prototype->d.data)->revision >= 2) {
++        if (priv(prototype->d.data)->revision >= 6) {
+             const QMetaObjectExtraData *extra =
+                 (const QMetaObjectExtraData *)(prototype->d.extradata);
+             if (extra && extra->static_metacall)
+@@ -1266,8 +1271,8 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
+     char *str = reinterpret_cast<char *>(buf + size);
+     if (buf) {
+         if (relocatable) {
+-            meta->d.stringdata = reinterpret_cast<const char *>((intptr_t)size);
+-            meta->d.data = reinterpret_cast<uint *>((intptr_t)pmetaSize);
++            meta->d.stringdata = reinterpret_cast<const char *>((quintptr)size);
++            meta->d.data = reinterpret_cast<uint *>((quintptr)pmetaSize);
+         } else {
+             meta->d.stringdata = str;
+             meta->d.data = reinterpret_cast<uint *>(data);
+@@ -1504,8 +1509,8 @@ void QMetaObjectBuilder::fromRelocatableData(QMetaObject *output,
+     const char *buf = data.constData();
+     const QMetaObject *dataMo = reinterpret_cast<const QMetaObject *>(buf);
+ 
+-    intptr_t stringdataOffset = (intptr_t)dataMo->d.stringdata;
+-    intptr_t dataOffset = (intptr_t)dataMo->d.data;
++    quintptr stringdataOffset = (quintptr)dataMo->d.stringdata;
++    quintptr dataOffset = (quintptr)dataMo->d.data;
+ 
+     output->d.superdata = superclass;
+     output->d.stringdata = buf + stringdataOffset;
+@@ -2289,16 +2294,27 @@ bool QMetaPropertyBuilder::isEnumOrFlag() const
+ }
+ 
+ /*!
+-    Returns true if the property has the dynamic flag set;
+-    otherwise returns false.  The default value is false.
++    Returns true if the property is constant; otherwise returns false.
++    The default value is false.
++*/
++bool QMetaPropertyBuilder::isConstant() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->flag(Constant);
++    else
++        return false;
++}
+ 
+-    \sa setDynamic()
++/*!
++    Returns true if the property is final; otherwise returns false.
++    The default value is false.
+ */
+-bool QMetaPropertyBuilder::isDynamic() const
++bool QMetaPropertyBuilder::isFinal() const
+ {
+     QMetaPropertyBuilderPrivate *d = d_func();
+     if (d)
+-        return d->flag(Dynamic);
++        return d->flag(Final);
+     else
+         return false;
+ }
+@@ -2427,16 +2443,27 @@ void QMetaPropertyBuilder::setEnumOrFlag(bool value)
+ }
+ 
+ /*!
+-    Sets this property to have the dynamic flag if \a value is
+-    true.
++    Sets the \c CONSTANT flag on this property to \a value.
++
++    \sa isConstant()
++*/
++void QMetaPropertyBuilder::setConstant(bool value)
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        d->setFlag(Constant, value);
++}
++
++/*!
++    Sets the \c FINAL flag on this property to \a value.
+ 
+-    \sa isDynamic()
++    \sa isFinal()
+ */
+-void QMetaPropertyBuilder::setDynamic(bool value)
++void QMetaPropertyBuilder::setFinal(bool value)
+ {
+     QMetaPropertyBuilderPrivate *d = d_func();
+     if (d)
+-        d->setFlag(Dynamic, value);
++        d->setFlag(Final, value);
+ }
+ 
+ /*!
+diff --git a/src/serviceframework/ipc/qmetaobjectbuilder_47.cpp b/src/serviceframework/ipc/qmetaobjectbuilder_47.cpp
+new file mode 100644
+index 0000000..509d6c6
+--- /dev/null
++++ b/src/serviceframework/ipc/qmetaobjectbuilder_47.cpp
+@@ -0,0 +1,2583 @@
++/****************************************************************************
++**
++** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
++** All rights reserved.
++** Contact: Nokia Corporation (qt-info@nokia.com)
++**
++** This file is part of the QtDeclarative module of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** No Commercial Usage
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
++**
++** GNU Lesser General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU Lesser
++** General Public License version 2.1 as published by the Free Software
++** Foundation and appearing in the file LICENSE.LGPL included in the
++** packaging of this file.  Please review the following information to
++** ensure the GNU Lesser General Public License version 2.1 requirements
++** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
++**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights.  These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
++**
++**
++**
++**
++**
++**
++**
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++#include "qmetaobjectbuilder_47_p.h"
++#include <QDebug>
++
++#ifndef Q_OS_WIN
++#include <stdint.h>
++#endif
++
++QTM_BEGIN_NAMESPACE
++
++/*!
++    \class QMetaObjectBuilder
++    \internal
++    \brief The QMetaObjectBuilder class supports building QMetaObject objects at runtime.
++    \since 1.1
++
++*/
++
++/*!
++    \enum QMetaObjectBuilder::AddMember
++    This enum defines which members of QMetaObject should be copied by QMetaObjectBuilder::addMetaObject()
++
++    \value ClassName Add the class name.
++    \value SuperClass Add the super class.
++    \value Methods Add methods that aren't signals or slots.
++    \value Signals Add signals.
++    \value Slots Add slots.
++    \value Constructors Add constructors.
++    \value Properties Add properties.
++    \value Enumerators Add enumerators.
++    \value ClassInfos Add items of class information.
++    \value RelatedMetaObjects Add related meta objects.
++    \value StaticMetacall Add the static metacall function.
++    \value PublicMethods Add public methods (ignored for signals).
++    \value ProtectedMethods Add protected methods (ignored for signals).
++    \value PrivateMethods All private methods (ignored for signals).
++    \value AllMembers Add all members.
++    \value AllPrimaryMembers Add everything except the class name, super class, and static metacall function.
++*/
++
++// copied from moc's generator.cpp
++uint qvariant_nameToType(const char* name)
++{
++    if (!name)
++        return 0;
++
++    if (strcmp(name, "QVariant") == 0)
++        return 0xffffffff;
++    if (strcmp(name, "QCString") == 0)
++        return QMetaType::QByteArray;
++    if (strcmp(name, "Q_LLONG") == 0)
++        return QMetaType::LongLong;
++    if (strcmp(name, "Q_ULLONG") == 0)
++        return QMetaType::ULongLong;
++    if (strcmp(name, "QIconSet") == 0)
++        return QMetaType::QIcon;
++
++    uint tp = QMetaType::type(name);
++    return tp < QMetaType::User ? tp : 0;
++}
++
++/*
++  Returns true if the type is a QVariant types.
++*/
++bool isVariantType(const char* type)
++{
++    return qvariant_nameToType(type) != 0;
++}
++
++// copied from qmetaobject.cpp
++// do not touch without touching the moc as well
++enum PropertyFlags  {
++    Invalid = 0x00000000,
++    Readable = 0x00000001,
++    Writable = 0x00000002,
++    Resettable = 0x00000004,
++    EnumOrFlag = 0x00000008,
++    StdCppSet = 0x00000100,
++//    Override = 0x00000200,
++    Designable = 0x00001000,
++    ResolveDesignable = 0x00002000,
++    Scriptable = 0x00004000,
++    ResolveScriptable = 0x00008000,
++    Stored = 0x00010000,
++    ResolveStored = 0x00020000,
++    Editable = 0x00040000,
++    ResolveEditable = 0x00080000,
++    User = 0x00100000,
++    ResolveUser = 0x00200000,
++    Notify = 0x00400000,
++    Dynamic = 0x00800000
++};
++
++enum MethodFlags  {
++    AccessPrivate = 0x00,
++    AccessProtected = 0x01,
++    AccessPublic = 0x02,
++    AccessMask = 0x03, //mask
++
++    MethodMethod = 0x00,
++    MethodSignal = 0x04,
++    MethodSlot = 0x08,
++    MethodConstructor = 0x0c,
++    MethodTypeMask = 0x0c,
++
++    MethodCompatibility = 0x10,
++    MethodCloned = 0x20,
++    MethodScriptable = 0x40
++};
++
++struct QMetaObjectPrivate
++{
++    int revision;
++    int className;
++    int classInfoCount, classInfoData;
++    int methodCount, methodData;
++    int propertyCount, propertyData;
++    int enumeratorCount, enumeratorData;
++    int constructorCount, constructorData;
++    int flags;
++};
++
++static inline const QMetaObjectPrivate *priv(const uint* data)
++{ return reinterpret_cast<const QMetaObjectPrivate*>(data); }
++// end of copied lines from qmetaobject.cpp
++
++class QMetaMethodBuilderPrivate
++{
++public:
++    QMetaMethodBuilderPrivate
++            (QMetaMethod::MethodType _methodType,
++             const QByteArray& _signature,
++             const QByteArray& _returnType = QByteArray(),
++             QMetaMethod::Access _access = QMetaMethod::Public)
++        : signature(QMetaObject::normalizedSignature(_signature.constData())),
++          returnType(QMetaObject::normalizedType(_returnType)),
++          attributes(((int)_access) | (((int)_methodType) << 2))
++    {
++    }
++
++    QByteArray signature;
++    QByteArray returnType;
++    QList<QByteArray> parameterNames;
++    QByteArray tag;
++    int attributes;
++
++    QMetaMethod::MethodType methodType() const
++    {
++        return (QMetaMethod::MethodType)((attributes & MethodTypeMask) >> 2);
++    }
++
++    QMetaMethod::Access access() const
++    {
++        return (QMetaMethod::Access)(attributes & AccessMask);
++    }
++
++    void setAccess(QMetaMethod::Access value)
++    {
++        attributes = ((attributes & ~AccessMask) | (int)value);
++    }
++};
++
++class QMetaPropertyBuilderPrivate
++{
++public:
++    QMetaPropertyBuilderPrivate
++            (const QByteArray& _name, const QByteArray& _type, int notifierIdx=-1)
++        : name(_name),
++          type(QMetaObject::normalizedType(_type.constData())),
++          flags(Readable | Writable | Scriptable), notifySignal(-1)
++    {
++        if (notifierIdx >= 0) {
++            flags |= Notify;
++            notifySignal = notifierIdx;
++        }
++    }
++
++    QByteArray name;
++    QByteArray type;
++    int flags;
++    int notifySignal;
++
++    bool flag(int f) const
++    {
++        return ((flags & f) != 0);
++    }
++
++    void setFlag(int f, bool value)
++    {
++        if (value)
++            flags |= f;
++        else
++            flags &= ~f;
++    }
++};
++
++class QMetaEnumBuilderPrivate
++{
++public:
++    QMetaEnumBuilderPrivate(const QByteArray& _name)
++        : name(_name), isFlag(false)
++    {
++    }
++
++    QByteArray name;
++    bool isFlag;
++    QList<QByteArray> keys;
++    QList<int> values;
++};
++
++class QMetaObjectBuilderPrivate
++{
++public:
++    QMetaObjectBuilderPrivate()
++        : flags(0)
++    {
++        superClass = &QObject::staticMetaObject;
++        staticMetacallFunction = 0;
++    }
++
++    QByteArray className;
++    const QMetaObject *superClass;
++    QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction;
++    QList<QMetaMethodBuilderPrivate> methods;
++    QList<QMetaMethodBuilderPrivate> constructors;
++    QList<QMetaPropertyBuilderPrivate> properties;
++    QList<QByteArray> classInfoNames;
++    QList<QByteArray> classInfoValues;
++    QList<QMetaEnumBuilderPrivate> enumerators;
++#ifdef Q_NO_DATA_RELOCATION
++    QList<QMetaObjectAccessor> relatedMetaObjects;
++#else
++    QList<const QMetaObject *> relatedMetaObjects;
++#endif
++    int flags;
++};
++
++/*!
++    Constructs a new QMetaObjectBuilder.
++*/
++QMetaObjectBuilder::QMetaObjectBuilder()
++{
++    d = new QMetaObjectBuilderPrivate();
++}
++
++/*!
++    Constructs a new QMetaObjectBuilder which is a copy of the
++    meta object information in \a prototype.  Note: the super class
++    contents for \a prototype are not copied, only the immediate
++    class that is defined by \a prototype.
++
++    The \a members parameter indicates which members of \a prototype
++    should be added.  The default is AllMembers.
++
++    \sa addMetaObject()
++*/
++QMetaObjectBuilder::QMetaObjectBuilder
++    (const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members)
++{
++    d = new QMetaObjectBuilderPrivate();
++    addMetaObject(prototype, members);
++}
++
++/*!
++    Destroys this meta object builder.
++*/
++QMetaObjectBuilder::~QMetaObjectBuilder()
++{
++    delete d;
++}
++
++/*!
++    Returns the name of the class being constructed by this
++    meta object builder.  The default value is an empty QByteArray.
++
++    \sa setClassName(), superClass()
++*/
++QByteArray QMetaObjectBuilder::className() const
++{
++    return d->className;
++}
++
++/*!
++    Sets the \a name of the class being constructed by this
++    meta object builder.
++
++    \sa className(), setSuperClass()
++*/
++void QMetaObjectBuilder::setClassName(const QByteArray& name)
++{
++    d->className = name;
++}
++
++/*!
++    Returns the superclass meta object of the class being constructed
++    by this meta object builder.  The default value is the meta object
++    for QObject.
++
++    \sa setSuperClass(), className()
++*/
++const QMetaObject *QMetaObjectBuilder::superClass() const
++{
++    return d->superClass;
++}
++
++/*!
++    Sets the superclass meta object of the class being constructed
++    by this meta object builder to \a meta.  The \a meta parameter
++    must not be null.
++
++    \sa superClass(), setClassName()
++*/
++void QMetaObjectBuilder::setSuperClass(const QMetaObject *meta)
++{
++    Q_ASSERT(meta);
++    d->superClass = meta;
++}
++
++/*!
++    Returns the flags of the class being constructed by this meta object
++    builder.
++
++    \sa setFlags()
++*/
++QMetaObjectBuilder::MetaObjectFlags QMetaObjectBuilder::flags() const
++{
++    return (QMetaObjectBuilder::MetaObjectFlags)d->flags;
++}
++
++/*!
++    Sets the \a flags of the class being constructed by this meta object
++    builder.
++
++    \sa flags()
++*/
++void QMetaObjectBuilder::setFlags(MetaObjectFlags flags)
++{
++    d->flags = flags;
++}
++
++/*!
++    Returns the number of methods in this class, excluding the number
++    of methods in the base class.  These include signals and slots
++    as well as normal member functions.
++
++    \sa addMethod(), method(), removeMethod(), indexOfMethod()
++*/
++int QMetaObjectBuilder::methodCount() const
++{
++    return d->methods.size();
++}
++
++/*!
++    Returns the number of constructors in this class.
++
++    \sa addConstructor(), constructor(), removeConstructor(), indexOfConstructor()
++*/
++int QMetaObjectBuilder::constructorCount() const
++{
++    return d->constructors.size();
++}
++
++/*!
++    Returns the number of properties in this class, excluding the number
++    of properties in the base class.
++
++    \sa addProperty(), property(), removeProperty(), indexOfProperty()
++*/
++int QMetaObjectBuilder::propertyCount() const
++{
++    return d->properties.size();
++}
++
++/*!
++    Returns the number of enumerators in this class, excluding the
++    number of enumerators in the base class.
++
++    \sa addEnumerator(), enumerator(), removeEnumerator()
++    \sa indexOfEnumerator()
++*/
++int QMetaObjectBuilder::enumeratorCount() const
++{
++    return d->enumerators.size();
++}
++
++/*!
++    Returns the number of items of class information in this class,
++    exclusing the number of items of class information in the base class.
++
++    \sa addClassInfo(), classInfoName(), classInfoValue(), removeClassInfo()
++    \sa indexOfClassInfo()
++*/
++int QMetaObjectBuilder::classInfoCount() const
++{
++    return d->classInfoNames.size();
++}
++
++/*!
++    Returns the number of related meta objects that are associated
++    with this class.
++
++    Related meta objects are used when resolving the enumerated type
++    associated with a property, where the enumerated type is in a
++    different class from the property.
++
++    \sa addRelatedMetaObject(), relatedMetaObject()
++    \sa removeRelatedMetaObject()
++*/
++int QMetaObjectBuilder::relatedMetaObjectCount() const
++{
++    return d->relatedMetaObjects.size();
++}
++
++/*!
++    Adds a new public method to this class with the specified \a signature.
++    Returns an object that can be used to adjust the other attributes
++    of the method.  The \a signature will be normalized before it is
++    added to the class.
++
++    \sa method(), methodCount(), removeMethod(), indexOfMethod()
++*/
++QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray& signature)
++{
++    int index = d->methods.size();
++    d->methods.append(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature));
++    return QMetaMethodBuilder(this, index);
++}
++
++/*!
++    Adds a new public method to this class with the specified
++    \a signature and \a returnType.  Returns an object that can be
++    used to adjust the other attributes of the method.  The \a signature
++    and \a returnType will be normalized before they are added to
++    the class.  If \a returnType is empty, then it indicates that
++    the method has \c{void} as its return type.
++
++    \sa method(), methodCount(), removeMethod(), indexOfMethod()
++*/
++QMetaMethodBuilder QMetaObjectBuilder::addMethod
++    (const QByteArray& signature, const QByteArray& returnType)
++{
++    int index = d->methods.size();
++    d->methods.append(QMetaMethodBuilderPrivate
++        (QMetaMethod::Method, signature, returnType));
++    return QMetaMethodBuilder(this, index);
++}
++
++/*!
++    Adds a new public method to this class that has the same information as
++    \a prototype.  This is used to clone the methods of an existing
++    QMetaObject.  Returns an object that can be used to adjust the
++    attributes of the method.
++
++    This function will detect if \a prototype is an ordinary method,
++    signal, slot, or constructor and act accordingly.
++
++    \sa method(), methodCount(), removeMethod(), indexOfMethod()
++*/
++QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QMetaMethod& prototype)
++{
++    QMetaMethodBuilder method;
++    if (prototype.methodType() == QMetaMethod::Method)
++        method = addMethod(prototype.signature());
++    else if (prototype.methodType() == QMetaMethod::Signal)
++        method = addSignal(prototype.signature());
++    else if (prototype.methodType() == QMetaMethod::Slot)
++        method = addSlot(prototype.signature());
++    else if (prototype.methodType() == QMetaMethod::Constructor)
++        method = addConstructor(prototype.signature());
++    method.setReturnType(prototype.typeName());
++    method.setParameterNames(prototype.parameterNames());
++    method.setTag(prototype.tag());
++    method.setAccess(prototype.access());
++    method.setAttributes(prototype.attributes());
++    return method;
++}
++
++/*!
++    Adds a new public slot to this class with the specified \a signature.
++    Returns an object that can be used to adjust the other attributes
++    of the slot.  The \a signature will be normalized before it is
++    added to the class.
++
++    \sa addMethod(), addSignal(), indexOfSlot()
++*/
++QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature)
++{
++    int index = d->methods.size();
++    d->methods.append(QMetaMethodBuilderPrivate(QMetaMethod::Slot, signature));
++    return QMetaMethodBuilder(this, index);
++}
++
++/*!
++    Adds a new signal to this class with the specified \a signature.
++    Returns an object that can be used to adjust the other attributes
++    of the signal.  The \a signature will be normalized before it is
++    added to the class.
++
++    \sa addMethod(), addSlot(), indexOfSignal()
++*/
++QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray& signature)
++{
++    int index = d->methods.size();
++    d->methods.append(QMetaMethodBuilderPrivate
++        (QMetaMethod::Signal, signature, QByteArray(), QMetaMethod::Protected));
++    return QMetaMethodBuilder(this, index);
++}
++
++/*!
++    Adds a new constructor to this class with the specified \a signature.
++    Returns an object that can be used to adjust the other attributes
++    of the constructor.  The \a signature will be normalized before it is
++    added to the class.
++
++    \sa constructor(), constructorCount(), removeConstructor()
++    \sa indexOfConstructor()
++*/
++QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray& signature)
++{
++    int index = d->constructors.size();
++    d->constructors.append(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature));
++    return QMetaMethodBuilder(this, -(index + 1));
++}
++
++/*!
++    Adds a new constructor to this class that has the same information as
++    \a prototype.  This is used to clone the constructors of an existing
++    QMetaObject.  Returns an object that can be used to adjust the
++    attributes of the constructor.
++
++    This function requires that \a prototype be a constructor.
++
++    \sa constructor(), constructorCount(), removeConstructor()
++    \sa indexOfConstructor()
++*/
++QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod& prototype)
++{
++    Q_ASSERT(prototype.methodType() == QMetaMethod::Constructor);
++    QMetaMethodBuilder ctor = addConstructor(prototype.signature());
++    ctor.setReturnType(prototype.typeName());
++    ctor.setParameterNames(prototype.parameterNames());
++    ctor.setTag(prototype.tag());
++    ctor.setAccess(prototype.access());
++    ctor.setAttributes(prototype.attributes());
++    return ctor;
++}
++
++/*!
++    Adds a new readable/writable property to this class with the
++    specified \a name and \a type.  Returns an object that can be used
++    to adjust the other attributes of the property.  The \a type will
++    be normalized before it is added to the class. \a notifierId will
++    be registered as the property's \e notify signal.
++
++    \sa property(), propertyCount(), removeProperty(), indexOfProperty()
++*/
++QMetaPropertyBuilder QMetaObjectBuilder::addProperty
++    (const QByteArray& name, const QByteArray& type, int notifierId)
++{
++    int index = d->properties.size();
++    d->properties.append(QMetaPropertyBuilderPrivate(name, type, notifierId));
++    return QMetaPropertyBuilder(this, index);
++}
++
++/*!
++    Adds a new property to this class that has the same information as
++    \a prototype.  This is used to clone the properties of an existing
++    QMetaObject.  Returns an object that can be used to adjust the
++    attributes of the property.
++
++    \sa property(), propertyCount(), removeProperty(), indexOfProperty()
++*/
++QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& prototype)
++{
++    QMetaPropertyBuilder property = addProperty(prototype.name(), prototype.typeName());
++    property.setReadable(prototype.isReadable());
++    property.setWritable(prototype.isWritable());
++    property.setResettable(prototype.isResettable());
++    property.setDesignable(prototype.isDesignable());
++    property.setScriptable(prototype.isScriptable());
++    property.setStored(prototype.isStored());
++    property.setEditable(prototype.isEditable());
++    property.setUser(prototype.isUser());
++    property.setStdCppSet(prototype.hasStdCppSet());
++    property.setEnumOrFlag(prototype.isEnumType());
++    if (prototype.hasNotifySignal()) {
++        // Find an existing method for the notify signal, or add a new one.
++        QMetaMethod method = prototype.notifySignal();
++        int index = indexOfMethod(method.signature());
++        if (index == -1)
++            index = addMethod(method).index();
++        d->properties[property._index].notifySignal = index;
++        d->properties[property._index].setFlag(Notify, true);
++    }
++    return property;
++}
++
++/*!
++    Adds a new enumerator to this class with the specified
++    \a name.  Returns an object that can be used to adjust
++    the other attributes of the enumerator.
++
++    \sa enumerator(), enumeratorCount(), removeEnumerator(),
++    \sa indexOfEnumerator()
++*/
++QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray& name)
++{
++    int index = d->enumerators.size();
++    d->enumerators.append(QMetaEnumBuilderPrivate(name));
++    return QMetaEnumBuilder(this, index);
++}
++
++/*!
++    Adds a new enumerator to this class that has the same information as
++    \a prototype.  This is used to clone the enumerators of an existing
++    QMetaObject.  Returns an object that can be used to adjust the
++    attributes of the enumerator.
++
++    \sa enumerator(), enumeratorCount(), removeEnumerator(),
++    \sa indexOfEnumerator()
++*/
++QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QMetaEnum& prototype)
++{
++    QMetaEnumBuilder en = addEnumerator(prototype.name());
++    en.setIsFlag(prototype.isFlag());
++    int count = prototype.keyCount();
++    for (int index = 0; index < count; ++index)
++        en.addKey(prototype.key(index), prototype.value(index));
++    return en;
++}
++
++/*!
++    Adds \a name and \a value as an item of class information to this class.
++    Returns the index of the new item of class information.
++
++    \sa classInfoCount(), classInfoName(), classInfoValue(), removeClassInfo()
++    \sa indexOfClassInfo()
++*/
++int QMetaObjectBuilder::addClassInfo(const QByteArray& name, const QByteArray& value)
++{
++    int index = d->classInfoNames.size();
++    d->classInfoNames += name;
++    d->classInfoValues += value;
++    return index;
++}
++
++/*!
++    Adds \a meta to this class as a related meta object.  Returns
++    the index of the new related meta object entry.
++
++    Related meta objects are used when resolving the enumerated type
++    associated with a property, where the enumerated type is in a
++    different class from the property.
++
++    \sa relatedMetaObjectCount(), relatedMetaObject()
++    \sa removeRelatedMetaObject()
++*/
++#ifdef Q_NO_DATA_RELOCATION
++int QMetaObjectBuilder::addRelatedMetaObject(const QMetaObjectAccessor &meta)
++#else
++int QMetaObjectBuilder::addRelatedMetaObject(const QMetaObject *meta)
++#endif
++{
++    Q_ASSERT(meta);
++    int index = d->relatedMetaObjects.size();
++    d->relatedMetaObjects.append(meta);
++    return index;
++}
++
++/*!
++    Adds the contents of \a prototype to this meta object builder.
++    This function is useful for cloning the contents of an existing QMetaObject.
++
++    The \a members parameter indicates which members of \a prototype
++    should be added.  The default is AllMembers.
++*/
++void QMetaObjectBuilder::addMetaObject
++        (const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members)
++{
++    Q_ASSERT(prototype);
++    int index;
++
++    if ((members & ClassName) != 0)
++        d->className = prototype->className();
++
++    if ((members & SuperClass) != 0)
++        d->superClass = prototype->superClass();
++
++    if ((members & (Methods | Signals | Slots)) != 0) {
++        for (index = prototype->methodOffset(); index < prototype->methodCount(); ++index) {
++            QMetaMethod method = prototype->method(index);
++            if (method.methodType() != QMetaMethod::Signal) {
++                if (method.access() == QMetaMethod::Public && (members & PublicMethods) == 0)
++                    continue;
++                if (method.access() == QMetaMethod::Private && (members & PrivateMethods) == 0)
++                    continue;
++                if (method.access() == QMetaMethod::Protected && (members & ProtectedMethods) == 0)
++                    continue;
++            }
++            if (method.methodType() == QMetaMethod::Method && (members & Methods) != 0) {
++                addMethod(method);
++            } else if (method.methodType() == QMetaMethod::Signal &&
++                       (members & Signals) != 0) {
++                addMethod(method);
++            } else if (method.methodType() == QMetaMethod::Slot &&
++                       (members & Slots) != 0) {
++                addMethod(method);
++            }
++        }
++    }
++
++    if ((members & Constructors) != 0) {
++        for (index = 0; index < prototype->constructorCount(); ++index)
++            addConstructor(prototype->constructor(index));
++    }
++
++    if ((members & Properties) != 0) {
++        for (index = prototype->propertyOffset(); index < prototype->propertyCount(); ++index)
++            addProperty(prototype->property(index));
++    }
++
++    if ((members & Enumerators) != 0) {
++        for (index = prototype->enumeratorOffset(); index < prototype->enumeratorCount(); ++index)
++            addEnumerator(prototype->enumerator(index));
++    }
++
++    if ((members & ClassInfos) != 0) {
++        for (index = prototype->classInfoOffset(); index < prototype->classInfoCount(); ++index) {
++            QMetaClassInfo ci = prototype->classInfo(index);
++            addClassInfo(ci.name(), ci.value());
++        }
++    }
++
++    if ((members & RelatedMetaObjects) != 0) {
++#ifdef Q_NO_DATA_RELOCATION
++        const QMetaObjectAccessor *objects = 0;
++#else
++        const QMetaObject **objects;
++        if (priv(prototype->d.data)->revision < 2) {
++            objects = (const QMetaObject **)(prototype->d.extradata);
++        } else
++#endif
++        {
++            const QMetaObjectExtraData *extra = (const QMetaObjectExtraData *)(prototype->d.extradata);
++            if (extra)
++                objects = extra->objects;
++            else
++                objects = 0;
++        }
++        if (objects) {
++            while (*objects != 0) {
++                addRelatedMetaObject(*objects);
++                ++objects;
++            }
++        }
++    }
++
++    if ((members & StaticMetacall) != 0) {
++        if (priv(prototype->d.data)->revision >= 2) {
++            const QMetaObjectExtraData *extra =
++                (const QMetaObjectExtraData *)(prototype->d.extradata);
++            if (extra && extra->static_metacall)
++                setStaticMetacallFunction(extra->static_metacall);
++        }
++    }
++}
++
++/*!
++    Returns the method at \a index in this class.
++
++    \sa methodCount(), addMethod(), removeMethod(), indexOfMethod()
++*/
++QMetaMethodBuilder QMetaObjectBuilder::method(int index) const
++{
++    if (index >= 0 && index < d->methods.size())
++        return QMetaMethodBuilder(this, index);
++    else
++        return QMetaMethodBuilder();
++}
++
++/*!
++    Returns the constructor at \a index in this class.
++
++    \sa methodCount(), addMethod(), removeMethod(), indexOfConstructor()
++*/
++QMetaMethodBuilder QMetaObjectBuilder::constructor(int index) const
++{
++    if (index >= 0 && index < d->constructors.size())
++        return QMetaMethodBuilder(this, -(index + 1));
++    else
++        return QMetaMethodBuilder();
++}
++
++/*!
++    Returns the property at \a index in this class.
++
++    \sa methodCount(), addMethod(), removeMethod(), indexOfProperty()
++*/
++QMetaPropertyBuilder QMetaObjectBuilder::property(int index) const
++{
++    if (index >= 0 && index < d->properties.size())
++        return QMetaPropertyBuilder(this, index);
++    else
++        return QMetaPropertyBuilder();
++}
++
++/*!
++    Returns the enumerator at \a index in this class.
++
++    \sa enumeratorCount(), addEnumerator(), removeEnumerator()
++    \sa indexOfEnumerator()
++*/
++QMetaEnumBuilder QMetaObjectBuilder::enumerator(int index) const
++{
++    if (index >= 0 && index < d->enumerators.size())
++        return QMetaEnumBuilder(this, index);
++    else
++        return QMetaEnumBuilder();
++}
++
++/*!
++    Returns the related meta object at \a index in this class.
++
++    Related meta objects are used when resolving the enumerated type
++    associated with a property, where the enumerated type is in a
++    different class from the property.
++
++    \sa relatedMetaObjectCount(), addRelatedMetaObject()
++    \sa removeRelatedMetaObject()
++*/
++const QMetaObject *QMetaObjectBuilder::relatedMetaObject(int index) const
++{
++    if (index >= 0 && index < d->relatedMetaObjects.size())
++#ifdef Q_NO_DATA_RELOCATION
++        return &((*(d->relatedMetaObjects[index]))());
++#else
++        return d->relatedMetaObjects[index];
++#endif
++    else
++        return 0;
++}
++
++/*!
++    Returns the name of the item of class information at \a index
++    in this class.
++
++    \sa classInfoCount(), addClassInfo(), classInfoValue(), removeClassInfo()
++    \sa indexOfClassInfo()
++*/
++QByteArray QMetaObjectBuilder::classInfoName(int index) const
++{
++    if (index >= 0 && index < d->classInfoNames.size())
++        return d->classInfoNames[index];
++    else
++        return QByteArray();
++}
++
++/*!
++    Returns the value of the item of class information at \a index
++    in this class.
++
++    \sa classInfoCount(), addClassInfo(), classInfoName(), removeClassInfo()
++    \sa indexOfClassInfo()
++*/
++QByteArray QMetaObjectBuilder::classInfoValue(int index) const
++{
++    if (index >= 0 && index < d->classInfoValues.size())
++        return d->classInfoValues[index];
++    else
++        return QByteArray();
++}
++
++/*!
++    Removes the method at \a index from this class.  The indices of
++    all following methods will be adjusted downwards by 1.  If the
++    method is registered as a notify signal on a property, then the
++    notify signal will be removed from the property.
++
++    \sa methodCount(), addMethod(), method(), indexOfMethod()
++*/
++void QMetaObjectBuilder::removeMethod(int index)
++{
++    if (index >= 0 && index < d->methods.size()) {
++        d->methods.removeAt(index);
++        for (int prop = 0; prop < d->properties.size(); ++prop) {
++            // Adjust the indices of property notify signal references.
++            if (d->properties[prop].notifySignal == index) {
++                d->properties[prop].notifySignal = -1;
++                d->properties[prop].setFlag(Notify, false);
++            } else if (d->properties[prop].notifySignal > index)
++                (d->properties[prop].notifySignal)--;
++        }
++    }
++}
++
++/*!
++    Removes the constructor at \a index from this class.  The indices of
++    all following constructors will be adjusted downwards by 1.
++
++    \sa constructorCount(), addConstructor(), constructor()
++    \sa indexOfConstructor()
++*/
++void QMetaObjectBuilder::removeConstructor(int index)
++{
++    if (index >= 0 && index < d->constructors.size())
++        d->constructors.removeAt(index);
++}
++
++/*!
++    Removes the property at \a index from this class.  The indices of
++    all following properties will be adjusted downwards by 1.
++
++    \sa propertyCount(), addProperty(), property(), indexOfProperty()
++*/
++void QMetaObjectBuilder::removeProperty(int index)
++{
++    if (index >= 0 && index < d->properties.size())
++        d->properties.removeAt(index);
++}
++
++/*!
++    Removes the enumerator at \a index from this class.  The indices of
++    all following enumerators will be adjusted downwards by 1.
++
++    \sa enumertorCount(), addEnumerator(), enumerator()
++    \sa indexOfEnumerator()
++*/
++void QMetaObjectBuilder::removeEnumerator(int index)
++{
++    if (index >= 0 && index < d->enumerators.size())
++        d->enumerators.removeAt(index);
++}
++
++/*!
++    Removes the item of class information at \a index from this class.
++    The indices of all following items will be adjusted downwards by 1.
++
++    \sa classInfoCount(), addClassInfo(), classInfoName(), classInfoValue()
++    \sa indexOfClassInfo()
++*/
++void QMetaObjectBuilder::removeClassInfo(int index)
++{
++    if (index >= 0 && index < d->classInfoNames.size()) {
++        d->classInfoNames.removeAt(index);
++        d->classInfoValues.removeAt(index);
++    }
++}
++
++/*!
++    Removes the related meta object at \a index from this class.
++    The indices of all following related meta objects will be adjusted
++    downwards by 1.
++
++    Related meta objects are used when resolving the enumerated type
++    associated with a property, where the enumerated type is in a
++    different class from the property.
++
++    \sa relatedMetaObjectCount(), addRelatedMetaObject()
++    \sa relatedMetaObject()
++*/
++void QMetaObjectBuilder::removeRelatedMetaObject(int index)
++{
++    if (index >= 0 && index < d->relatedMetaObjects.size())
++        d->relatedMetaObjects.removeAt(index);
++}
++
++/*!
++    Finds a method with the specified \a signature and returns its index;
++    otherwise returns -1.  The \a signature will be normalized by this method.
++
++    \sa method(), methodCount(), addMethod(), removeMethod()
++*/
++int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature)
++{
++    QByteArray sig = QMetaObject::normalizedSignature(signature);
++    for (int index = 0; index < d->methods.size(); ++index) {
++        if (sig == d->methods[index].signature)
++            return index;
++    }
++    return -1;
++}
++
++/*!
++    Finds a signal with the specified \a signature and returns its index;
++    otherwise returns -1.  The \a signature will be normalized by this method.
++
++    \sa indexOfMethod(), indexOfSlot()
++*/
++int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature)
++{
++    QByteArray sig = QMetaObject::normalizedSignature(signature);
++    for (int index = 0; index < d->methods.size(); ++index) {
++        if (sig == d->methods[index].signature &&
++                d->methods[index].methodType() == QMetaMethod::Signal)
++            return index;
++    }
++    return -1;
++}
++
++/*!
++    Finds a slot with the specified \a signature and returns its index;
++    otherwise returns -1.  The \a signature will be normalized by this method.
++
++    \sa indexOfMethod(), indexOfSignal()
++*/
++int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature)
++{
++    QByteArray sig = QMetaObject::normalizedSignature(signature);
++    for (int index = 0; index < d->methods.size(); ++index) {
++        if (sig == d->methods[index].signature &&
++                d->methods[index].methodType() == QMetaMethod::Slot)
++            return index;
++    }
++    return -1;
++}
++
++/*!
++    Finds a constructor with the specified \a signature and returns its index;
++    otherwise returns -1.  The \a signature will be normalized by this method.
++
++    \sa constructor(), constructorCount(), addConstructor(), removeConstructor()
++*/
++int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature)
++{
++    QByteArray sig = QMetaObject::normalizedSignature(signature);
++    for (int index = 0; index < d->constructors.size(); ++index) {
++        if (sig == d->constructors[index].signature)
++            return index;
++    }
++    return -1;
++}
++
++/*!
++    Finds a property with the specified \a name and returns its index;
++    otherwise returns -1.
++
++    \sa property(), propertyCount(), addProperty(), removeProperty()
++*/
++int QMetaObjectBuilder::indexOfProperty(const QByteArray& name)
++{
++    for (int index = 0; index < d->properties.size(); ++index) {
++        if (name == d->properties[index].name)
++            return index;
++    }
++    return -1;
++}
++
++/*!
++    Finds an enumerator with the specified \a name and returns its index;
++    otherwise returns -1.
++
++    \sa enumertor(), enumeratorCount(), addEnumerator(), removeEnumerator()
++*/
++int QMetaObjectBuilder::indexOfEnumerator(const QByteArray& name)
++{
++    for (int index = 0; index < d->enumerators.size(); ++index) {
++        if (name == d->enumerators[index].name)
++            return index;
++    }
++    return -1;
++}
++
++/*!
++    Finds an item of class information with the specified \a name and
++    returns its index; otherwise returns -1.
++
++    \sa classInfoName(), classInfoValue(), classInfoCount(), addClassInfo()
++    \sa removeClassInfo()
++*/
++int QMetaObjectBuilder::indexOfClassInfo(const QByteArray& name)
++{
++    for (int index = 0; index < d->classInfoNames.size(); ++index) {
++        if (name == d->classInfoNames[index])
++            return index;
++    }
++    return -1;
++}
++
++// Align on a specific type boundary.
++#define ALIGN(size,type)    \
++    (size) = ((size) + sizeof(type) - 1) & ~(sizeof(type) - 1)
++
++// Build a string into a QMetaObject representation.  Returns the
++// position in the string table where the string was placed.
++static int buildString
++    (char *buf, char *str, int *offset, const QByteArray& value, int empty)
++{
++    if (value.size() == 0 && empty >= 0)
++        return empty;
++    if (buf) {
++        memcpy(str + *offset, value.constData(), value.size());
++        str[*offset + value.size()] = '\0';
++    }
++    int posn = *offset;
++    *offset += value.size() + 1;
++    return posn;
++}
++
++// Build the parameter array string for a method.
++static QByteArray buildParameterNames
++        (const QByteArray& signature, const QList<QByteArray>& parameterNames)
++{
++    // If the parameter name list is specified, then concatenate them.
++    if (!parameterNames.isEmpty()) {
++        QByteArray names;
++        bool first = true;
++        foreach (const QByteArray &name, parameterNames) {
++            if (first)
++                first = false;
++            else
++                names += (char)',';
++            names += name;
++        }
++        return names;
++    }
++
++    // Count commas in the signature, excluding those inside template arguments.
++    int index = signature.indexOf('(');
++    if (index < 0)
++        return QByteArray();
++    ++index;
++    if (index >= signature.size())
++        return QByteArray();
++    if (signature[index] == ')')
++        return QByteArray();
++    int count = 1;
++    int brackets = 0;
++    while (index < signature.size() && signature[index] != ',') {
++        char ch = signature[index++];
++        if (ch == '<')
++            ++brackets;
++        else if (ch == '>')
++            --brackets;
++        else if (ch == ',' && brackets <= 0)
++            ++count;
++    }
++    return QByteArray(count - 1, ',');
++}
++
++// Build a QMetaObject in "buf" based on the information in "d".
++// If "buf" is null, then return the number of bytes needed to
++// build the QMetaObject.  Returns -1 if the metaobject if
++// relocatable is set, but the metaobject contains extradata.
++static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
++                           bool relocatable)
++{
++    int size = 0;
++    int dataIndex;
++    int enumIndex;
++    int index;
++    bool hasNotifySignals = false;
++
++    if (relocatable &&
++        (d->relatedMetaObjects.size() > 0 || d->staticMetacallFunction))
++        return -1;
++
++    // Create the main QMetaObject structure at the start of the buffer.
++    QMetaObject *meta = reinterpret_cast<QMetaObject *>(buf);
++    size += sizeof(QMetaObject);
++    ALIGN(size, int);
++    if (buf) {
++        if (!relocatable) meta->d.superdata = d->superClass;
++        meta->d.extradata = 0;
++    }
++
++    // Populate the QMetaObjectPrivate structure.
++    QMetaObjectPrivate *pmeta
++        = reinterpret_cast<QMetaObjectPrivate *>(buf + size);
++    int pmetaSize = size;
++    dataIndex = 13;     // Number of fields in the QMetaObjectPrivate.
++    for (index = 0; index < d->properties.size(); ++index) {
++        if (d->properties[index].notifySignal != -1) {
++            hasNotifySignals = true;
++            break;
++        }
++    }
++    if (buf) {
++        pmeta->revision = 3;
++        pmeta->flags = d->flags;
++        pmeta->className = 0;   // Class name is always the first string.
++
++        pmeta->classInfoCount = d->classInfoNames.size();
++        pmeta->classInfoData = dataIndex;
++        dataIndex += 2 * d->classInfoNames.size();
++
++        pmeta->methodCount = d->methods.size();
++        pmeta->methodData = dataIndex;
++        dataIndex += 5 * d->methods.size();
++
++        pmeta->propertyCount = d->properties.size();
++        pmeta->propertyData = dataIndex;
++        dataIndex += 3 * d->properties.size();
++        if (hasNotifySignals)
++            dataIndex += d->properties.size();
++
++        pmeta->enumeratorCount = d->enumerators.size();
++        pmeta->enumeratorData = dataIndex;
++        dataIndex += 4 * d->enumerators.size();
++
++        pmeta->constructorCount = d->constructors.size();
++        pmeta->constructorData = dataIndex;
++        dataIndex += 5 * d->constructors.size();
++    } else {
++        dataIndex += 2 * d->classInfoNames.size();
++        dataIndex += 5 * d->methods.size();
++        dataIndex += 3 * d->properties.size();
++        if (hasNotifySignals)
++            dataIndex += d->properties.size();
++        dataIndex += 4 * d->enumerators.size();
++        dataIndex += 5 * d->constructors.size();
++    }
++
++    // Allocate space for the enumerator key names and values.
++    enumIndex = dataIndex;
++    for (index = 0; index < d->enumerators.size(); ++index) {
++        QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
++        dataIndex += 2 * enumerator->keys.size();
++    }
++
++    // Zero terminator at the end of the data offset table.
++    ++dataIndex;
++
++    // Find the start of the data and string tables.
++    int *data = reinterpret_cast<int *>(pmeta);
++    size += dataIndex * sizeof(int);
++    char *str = reinterpret_cast<char *>(buf + size);
++    if (buf) {
++        if (relocatable) {
++            meta->d.stringdata = reinterpret_cast<const char *>((intptr_t)size);
++            meta->d.data = reinterpret_cast<uint *>((intptr_t)pmetaSize);
++        } else {
++            meta->d.stringdata = str;
++            meta->d.data = reinterpret_cast<uint *>(data);
++        }
++    }
++
++    // Reset the current data position to just past the QMetaObjectPrivate.
++    dataIndex = 13;
++
++    // Add the class name to the string table.
++    int offset = 0;
++    buildString(buf, str, &offset, d->className, -1);
++
++    // Add a common empty string, which is used to indicate "void"
++    // method returns, empty tag strings, etc.
++    int empty = buildString(buf, str, &offset, QByteArray(), -1);
++
++    // Output the class infos,
++    for (index = 0; index < d->classInfoNames.size(); ++index) {
++        int name = buildString(buf, str, &offset, d->classInfoNames[index], empty);
++        int value = buildString(buf, str, &offset, d->classInfoValues[index], empty);
++        if (buf) {
++            data[dataIndex] = name;
++            data[dataIndex + 1] = value;
++        }
++        dataIndex += 2;
++    }
++
++    // Output the methods in the class.
++    for (index = 0; index < d->methods.size(); ++index) {
++        QMetaMethodBuilderPrivate *method = &(d->methods[index]);
++        int sig = buildString(buf, str, &offset, method->signature, empty);
++        int params;
++        QByteArray names = buildParameterNames
++            (method->signature, method->parameterNames);
++        params = buildString(buf, str, &offset, names, empty);
++        int ret = buildString(buf, str, &offset, method->returnType, empty);
++        int tag = buildString(buf, str, &offset, method->tag, empty);
++        int attrs = method->attributes;
++        if (buf) {
++            data[dataIndex]     = sig;
++            data[dataIndex + 1] = params;
++            data[dataIndex + 2] = ret;
++            data[dataIndex + 3] = tag;
++            data[dataIndex + 4] = attrs;
++        }
++        dataIndex += 5;
++    }
++
++    // Output the properties in the class.
++    for (index = 0; index < d->properties.size(); ++index) {
++        QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);
++        int name = buildString(buf, str, &offset, prop->name, empty);
++        int type = buildString(buf, str, &offset, prop->type, empty);
++        int flags = prop->flags;
++
++        if (!isVariantType(prop->type)) {
++            flags |= EnumOrFlag;
++        } else {
++            flags |= qvariant_nameToType(prop->type) << 24;
++        }
++
++        if (buf) {
++            data[dataIndex]     = name;
++            data[dataIndex + 1] = type;
++            data[dataIndex + 2] = flags;
++        }
++        dataIndex += 3;
++    }
++    if (hasNotifySignals) {
++        for (index = 0; index < d->properties.size(); ++index) {
++            QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);
++            if (buf) {
++                if (prop->notifySignal != -1)
++                    data[dataIndex] = prop->notifySignal;
++                else
++                    data[dataIndex] = 0;
++            }
++            ++dataIndex;
++        }
++    }
++
++    // Output the enumerators in the class.
++    for (index = 0; index < d->enumerators.size(); ++index) {
++        QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
++        int name = buildString(buf, str, &offset, enumerator->name, empty);
++        int isFlag = (int)(enumerator->isFlag);
++        int count = enumerator->keys.size();
++        int enumOffset = enumIndex;
++        if (buf) {
++            data[dataIndex]     = name;
++            data[dataIndex + 1] = isFlag;
++            data[dataIndex + 2] = count;
++            data[dataIndex + 3] = enumOffset;
++        }
++        for (int key = 0; key < count; ++key) {
++            int keyIndex = buildString(buf, str, &offset, enumerator->keys[key], empty);
++            if (buf) {
++                data[enumOffset++] = keyIndex;
++                data[enumOffset++] = enumerator->values[key];
++            }
++        }
++        dataIndex += 4;
++        enumIndex += 2 * count;
++    }
++
++    // Output the constructors in the class.
++    for (index = 0; index < d->constructors.size(); ++index) {
++        QMetaMethodBuilderPrivate *method = &(d->constructors[index]);
++        int sig = buildString(buf, str, &offset, method->signature, empty);
++        int params;
++        QByteArray names = buildParameterNames
++            (method->signature, method->parameterNames);
++        params = buildString(buf, str, &offset, names, empty);
++        int ret = buildString(buf, str, &offset, method->returnType, empty);
++        int tag = buildString(buf, str, &offset, method->tag, empty);
++        int attrs = method->attributes;
++        if (buf) {
++            data[dataIndex]     = sig;
++            data[dataIndex + 1] = params;
++            data[dataIndex + 2] = ret;
++            data[dataIndex + 3] = tag;
++            data[dataIndex + 4] = attrs;
++        }
++        dataIndex += 5;
++    }
++
++    // One more empty string to act as a terminator.
++    buildString(buf, str, &offset, QByteArray(), -1);
++    size += offset;
++
++    // Output the zero terminator in the data array.
++    if (buf)
++        data[enumIndex] = 0;
++
++    // Create the extradata block if we need one.
++    if (d->relatedMetaObjects.size() > 0 || d->staticMetacallFunction) {
++        ALIGN(size, QMetaObject **);
++        ALIGN(size, QMetaObjectBuilder::StaticMetacallFunction);
++        QMetaObjectExtraData *extra =
++            reinterpret_cast<QMetaObjectExtraData *>(buf + size);
++        size += sizeof(QMetaObjectExtraData);
++        ALIGN(size, QMetaObject *);
++#ifdef Q_NO_DATA_RELOCATION
++        QMetaObjectAccessor *objects =
++            reinterpret_cast<QMetaObjectAccessor *>(buf + size);
++#else
++        const QMetaObject **objects =
++            reinterpret_cast<const QMetaObject **>(buf + size);
++#endif
++        if (buf) {
++            if (d->relatedMetaObjects.size() > 0) {
++                extra->objects = objects;
++                for (index = 0; index < d->relatedMetaObjects.size(); ++index)
++                    objects[index] = d->relatedMetaObjects[index];
++                objects[index] = 0;
++            } else {
++                extra->objects = 0;
++            }
++            extra->static_metacall = d->staticMetacallFunction;
++            meta->d.extradata = reinterpret_cast<void *>(extra);
++        }
++        if (d->relatedMetaObjects.size() > 0)
++            size += sizeof(QMetaObject *) * (d->relatedMetaObjects.size() + 1);
++    }
++
++    // Align the final size and return it.
++    ALIGN(size, void *);
++    return size;
++}
++
++/*!
++    Converts this meta object builder into a concrete QMetaObject.
++    The return value should be deallocated using qFree() once it
++    is no longer needed.
++
++    The returned meta object is a snapshot of the state of the
++    QMetaObjectBuilder.  Any further modifications to the QMetaObjectBuilder
++    will not be reflected in previous meta objects returned by
++    this method.
++*/
++QMetaObject *QMetaObjectBuilder::toMetaObject() const
++{
++    int size = buildMetaObject(d, 0, false);
++    char *buf = reinterpret_cast<char *>(qMalloc(size));
++    buildMetaObject(d, buf, false);
++    return reinterpret_cast<QMetaObject *>(buf);
++}
++
++/*
++    \internal
++
++    Converts this meta object builder into relocatable data.  This data can
++    be stored, copied and later passed to fromRelocatableData() to create a
++    concrete QMetaObject.
++
++    The data is specific to the architecture on which it was created, but is not
++    specific to the process that created it.  Not all meta object builder's can
++    be converted to data in this way.  If \a ok is provided, it will be set to
++    true if the conversion succeeds, and false otherwise.  If a
++    staticMetacallFunction() or any relatedMetaObject()'s are specified the
++    conversion to relocatable data will fail.
++*/
++QByteArray QMetaObjectBuilder::toRelocatableData(bool *ok) const
++{
++    int size = buildMetaObject(d, 0, true);
++    if (size == -1) {
++        if (ok) *ok = false;
++        return QByteArray();
++    }
++
++    QByteArray data;
++    data.resize(size);
++    char *buf = data.data();
++    buildMetaObject(d, buf, true);
++    if (ok) *ok = true;
++    return data;
++}
++
++/*
++    \internal
++
++    Sets the \a data returned from toRelocatableData() onto a concrete
++    QMetaObject instance, \a output.  As the meta object's super class is not
++    saved in the relocatable data, it must be passed as \a superClass.
++*/
++void QMetaObjectBuilder::fromRelocatableData(QMetaObject *output,
++                                             const QMetaObject *superclass,
++                                             const QByteArray &data)
++{
++    if (!output)
++        return;
++
++    const char *buf = data.constData();
++    const QMetaObject *dataMo = reinterpret_cast<const QMetaObject *>(buf);
++
++    intptr_t stringdataOffset = (intptr_t)dataMo->d.stringdata;
++    intptr_t dataOffset = (intptr_t)dataMo->d.data;
++
++    output->d.superdata = superclass;
++    output->d.stringdata = buf + stringdataOffset;
++    output->d.data = reinterpret_cast<const uint *>(buf + dataOffset);
++}
++
++/*!
++    \typedef QMetaObjectBuilder::StaticMetacallFunction
++
++    Typedef for static metacall functions.  The three parameters are
++    the call type value, the constructor index, and the
++    array of parameters.
++*/
++
++/*!
++    Returns the static metacall function to use to construct objects
++    of this class.  The default value is null.
++
++    \sa setStaticMetacallFunction()
++*/
++QMetaObjectBuilder::StaticMetacallFunction QMetaObjectBuilder::staticMetacallFunction() const
++{
++    return d->staticMetacallFunction;
++}
++
++/*!
++    Sets the static metacall function to use to construct objects
++    of this class to \a value.  The default value is null.
++
++    \sa staticMetacallFunction()
++*/
++void QMetaObjectBuilder::setStaticMetacallFunction
++        (QMetaObjectBuilder::StaticMetacallFunction value)
++{
++    d->staticMetacallFunction = value;
++}
++
++#ifndef QT_NO_DATASTREAM
++
++/*!
++    Serializes the contents of the meta object builder onto \a stream.
++
++    \sa deserialize()
++*/
++void QMetaObjectBuilder::serialize(QDataStream& stream) const
++{
++    int index;
++
++    // Write the class and super class names.
++    stream << d->className;
++    if (d->superClass)
++        stream << QByteArray(d->superClass->className());
++    else
++        stream << QByteArray();
++
++    // Write the counts for each type of class member.
++    stream << d->classInfoNames.size();
++    stream << d->methods.size();
++    stream << d->properties.size();
++    stream << d->enumerators.size();
++    stream << d->constructors.size();
++    stream << d->relatedMetaObjects.size();
++
++    // Write the items of class information.
++    for (index = 0; index < d->classInfoNames.size(); ++index) {
++        stream << d->classInfoNames[index];
++        stream << d->classInfoValues[index];
++    }
++
++    // Write the methods.
++    for (index = 0; index < d->methods.size(); ++index) {
++        const QMetaMethodBuilderPrivate *method = &(d->methods[index]);
++        stream << method->signature;
++        stream << method->returnType;
++        stream << method->parameterNames;
++        stream << method->tag;
++        stream << method->attributes;
++    }
++
++    // Write the properties.
++    for (index = 0; index < d->properties.size(); ++index) {
++        const QMetaPropertyBuilderPrivate *property = &(d->properties[index]);
++        stream << property->name;
++        stream << property->type;
++        stream << property->flags;
++        stream << property->notifySignal;
++    }
++
++    // Write the enumerators.
++    for (index = 0; index < d->enumerators.size(); ++index) {
++        const QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
++        stream << enumerator->name;
++        stream << enumerator->isFlag;
++        stream << enumerator->keys;
++        stream << enumerator->values;
++    }
++
++    // Write the constructors.
++    for (index = 0; index < d->constructors.size(); ++index) {
++        const QMetaMethodBuilderPrivate *method = &(d->constructors[index]);
++        stream << method->signature;
++        stream << method->returnType;
++        stream << method->parameterNames;
++        stream << method->tag;
++        stream << method->attributes;
++    }
++
++    // Write the related meta objects.
++#ifdef Q_NO_DATA_RELOCATION
++    //the related meta objects will be function pointers
++    //which you have to add to the builder manually.
++    //e.g.
++    //builder2.addRelatedMetaObject(QLocale::getStaticMetaObject);
++#else
++    for (index = 0; index < d->relatedMetaObjects.size(); ++index) {
++        const QMetaObject *meta = d->relatedMetaObjects[index];
++        stream << QByteArray(meta->className());
++    }
++#endif
++
++    // Add an extra empty QByteArray for additional data in future versions.
++    // This should help maintain backwards compatibility, allowing older
++    // versions to read newer data.
++    stream << QByteArray();
++}
++
++// Resolve a class name using the name reference map.
++static const QMetaObject *resolveClassName
++        (const QMap<QByteArray, const QMetaObject *>& references,
++         const QByteArray& name)
++{
++    if (name == QByteArray("QObject"))
++        return &QObject::staticMetaObject;
++    else
++        return references.value(name, 0);
++}
++
++/*!
++    Deserializes a meta object builder from \a stream into
++    this meta object builder.
++
++    The \a references parameter specifies a mapping from class names
++    to QMetaObject instances for resolving the super class name and
++    related meta objects in the object that is deserialized.
++    The meta object for QObject is implicitly added to \a references
++    and does not need to be supplied.
++
++    The QDataStream::status() value on \a stream will be set to
++    QDataStream::ReadCorruptData if the input data is corrupt.
++    The status will be set to QDataStream::ReadPastEnd if the
++    input was exhausted before the full meta object was read.
++
++    \sa serialize()
++*/
++void QMetaObjectBuilder::deserialize
++        (QDataStream& stream,
++         const QMap<QByteArray, const QMetaObject *>& references)
++{
++    QByteArray name;
++    const QMetaObject *cl;
++    int index;
++
++    // Clear all members in the builder to their default states.
++    d->className.clear();
++    d->superClass = &QObject::staticMetaObject;
++    d->classInfoNames.clear();
++    d->classInfoValues.clear();
++    d->methods.clear();
++    d->properties.clear();
++    d->enumerators.clear();
++    d->constructors.clear();
++    d->relatedMetaObjects.clear();
++    d->staticMetacallFunction = 0;
++
++    // Read the class and super class names.
++    stream >> d->className;
++    stream >> name;
++    if (name.isEmpty()) {
++        d->superClass = 0;
++    } else if ((cl = resolveClassName(references, name)) != 0) {
++        d->superClass = cl;
++    } else {
++        stream.setStatus(QDataStream::ReadCorruptData);
++        return;
++    }
++
++    // Read the counts for each type of class member.
++    int classInfoCount, methodCount, propertyCount;
++    int enumeratorCount, constructorCount, relatedMetaObjectCount;
++    stream >> classInfoCount;
++    stream >> methodCount;
++    stream >> propertyCount;
++    stream >> enumeratorCount;
++    stream >> constructorCount;
++    stream >> relatedMetaObjectCount;
++    if (classInfoCount < 0 || methodCount < 0 ||
++        propertyCount < 0 || enumeratorCount < 0 ||
++        constructorCount < 0 || relatedMetaObjectCount < 0) {
++        stream.setStatus(QDataStream::ReadCorruptData);
++        return;
++    }
++
++    // Read the items of class information.
++    for (index = 0; index < classInfoCount; ++index) {
++        if (stream.status() != QDataStream::Ok)
++            return;
++        QByteArray value;
++        stream >> name;
++        stream >> value;
++        addClassInfo(name, value);
++    }
++
++    // Read the member methods.
++    for (index = 0; index < methodCount; ++index) {
++        if (stream.status() != QDataStream::Ok)
++            return;
++        stream >> name;
++        addMethod(name);
++        QMetaMethodBuilderPrivate *method = &(d->methods[index]);
++        stream >> method->returnType;
++        stream >> method->parameterNames;
++        stream >> method->tag;
++        stream >> method->attributes;
++        if (method->methodType() == QMetaMethod::Constructor) {
++            // Cannot add a constructor in this set of methods.
++            stream.setStatus(QDataStream::ReadCorruptData);
++            return;
++        }
++    }
++
++    // Read the properties.
++    for (index = 0; index < propertyCount; ++index) {
++        if (stream.status() != QDataStream::Ok)
++            return;
++        QByteArray type;
++        stream >> name;
++        stream >> type;
++        addProperty(name, type);
++        QMetaPropertyBuilderPrivate *property = &(d->properties[index]);
++        stream >> property->flags;
++        stream >> property->notifySignal;
++        if (property->notifySignal < -1 ||
++            property->notifySignal >= d->methods.size()) {
++            // Notify signal method index is out of range.
++            stream.setStatus(QDataStream::ReadCorruptData);
++            return;
++        }
++        if (property->notifySignal >= 0 &&
++            d->methods[property->notifySignal].methodType() != QMetaMethod::Signal) {
++            // Notify signal method index does not refer to a signal.
++            stream.setStatus(QDataStream::ReadCorruptData);
++            return;
++        }
++    }
++
++    // Read the enumerators.
++    for (index = 0; index < enumeratorCount; ++index) {
++        if (stream.status() != QDataStream::Ok)
++            return;
++        stream >> name;
++        addEnumerator(name);
++        QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
++        stream >> enumerator->isFlag;
++        stream >> enumerator->keys;
++        stream >> enumerator->values;
++        if (enumerator->keys.size() != enumerator->values.size()) {
++            // Mismatch between number of keys and number of values.
++            stream.setStatus(QDataStream::ReadCorruptData);
++            return;
++        }
++    }
++
++    // Read the constructor methods.
++    for (index = 0; index < constructorCount; ++index) {
++        if (stream.status() != QDataStream::Ok)
++            return;
++        stream >> name;
++        addConstructor(name);
++        QMetaMethodBuilderPrivate *method = &(d->constructors[index]);
++        stream >> method->returnType;
++        stream >> method->parameterNames;
++        stream >> method->tag;
++        stream >> method->attributes;
++        if (method->methodType() != QMetaMethod::Constructor) {
++            // The type must be Constructor.
++            stream.setStatus(QDataStream::ReadCorruptData);
++            return;
++        }
++    }
++
++    // Read the related meta objects.
++#ifdef Q_NO_DATA_RELOCATION
++    //the related meta objects will be function pointers
++    //which you have to add to the builder manually.
++    //e.g.
++    //builder2.addRelatedMetaObject(QLocale::getStaticMetaObject);
++#else
++    for (index = 0; index < relatedMetaObjectCount; ++index) {
++        if (stream.status() != QDataStream::Ok)
++            return;
++        stream >> name;
++        cl = resolveClassName(references, name);
++        if (!cl) {
++            stream.setStatus(QDataStream::ReadCorruptData);
++            return;
++        }
++        addRelatedMetaObject(cl);
++    }
++#endif
++
++    // Read the extra data block, which is reserved for future use.
++    stream >> name;
++}
++
++#endif // !QT_NO_DATASTREAM
++
++/*!
++    \class QMetaMethodBuilder
++    \internal
++    \brief The QMetaMethodBuilder class enables modifications to a method definition on a meta object builder.
++*/
++
++QMetaMethodBuilderPrivate *QMetaMethodBuilder::d_func() const
++{
++    // Positive indices indicate methods, negative indices indicate constructors.
++    if (_mobj && _index >= 0 && _index < _mobj->d->methods.size())
++        return &(_mobj->d->methods[_index]);
++    else if (_mobj && -_index >= 1 && -_index <= _mobj->d->constructors.size())
++        return &(_mobj->d->constructors[(-_index) - 1]);
++    else
++        return 0;
++}
++
++/*!
++    \fn QMetaMethodBuilder::QMetaMethodBuilder()
++    \internal
++*/
++
++/*!
++    Returns the index of this method within its QMetaObjectBuilder.
++*/
++int QMetaMethodBuilder::index() const
++{
++    if (_index >= 0)
++        return _index;          // Method, signal, or slot
++    else
++        return (-_index) - 1;   // Constructor
++}
++
++/*!
++    Returns the type of this method (signal, slot, method, or constructor).
++*/
++QMetaMethod::MethodType QMetaMethodBuilder::methodType() const
++{
++    QMetaMethodBuilderPrivate *d = d_func();
++    if (d)
++        return d->methodType();
++    else
++        return QMetaMethod::Method;
++}
++
++/*!
++    Returns the signature of this method.
++
++    \sa parameterNames(), returnType()
++*/
++QByteArray QMetaMethodBuilder::signature() const
++{
++    QMetaMethodBuilderPrivate *d = d_func();
++    if (d)
++        return d->signature;
++    else
++        return QByteArray();
++}
++
++/*!
++    Returns the return type for this method; empty if the method's
++    return type is \c{void}.
++
++    \sa setReturnType(), signature()
++*/
++QByteArray QMetaMethodBuilder::returnType() const
++{
++    QMetaMethodBuilderPrivate *d = d_func();
++    if (d)
++        return d->returnType;
++    else
++        return QByteArray();
++}
++
++/*!
++    Sets the return type for this method to \a value.  If \a value
++    is empty, then the method's return type is \c{void}.  The \a value
++    will be normalized before it is added to the method.
++
++    \sa returnType(), signature()
++*/
++void QMetaMethodBuilder::setReturnType(const QByteArray& value)
++{
++    QMetaMethodBuilderPrivate *d = d_func();
++    if (d)
++        d->returnType = QMetaObject::normalizedType(value);
++}
++
++/*!
++    Returns the list of parameter names for this method.
++
++    \sa setParameterNames()
++*/
++QList<QByteArray> QMetaMethodBuilder::parameterNames() const
++{
++    QMetaMethodBuilderPrivate *d = d_func();
++    if (d)
++        return d->parameterNames;
++    else
++        return QList<QByteArray>();
++}
++
++/*!
++    Sets the list of parameter names for this method to \a value.
++
++    \sa parameterNames()
++*/
++void QMetaMethodBuilder::setParameterNames(const QList<QByteArray>& value)
++{
++    QMetaMethodBuilderPrivate *d = d_func();
++    if (d)
++        d->parameterNames = value;
++}
++
++/*!
++    Returns the tag associated with this method.
++
++    \sa setTag()
++*/
++QByteArray QMetaMethodBuilder::tag() const
++{
++    QMetaMethodBuilderPrivate *d = d_func();
++    if (d)
++        return d->tag;
++    else
++        return QByteArray();
++}
++
++/*!
++    Sets the tag associated with this method to \a value.
++
++    \sa setTag()
++*/
++void QMetaMethodBuilder::setTag(const QByteArray& value)
++{
++    QMetaMethodBuilderPrivate *d = d_func();
++    if (d)
++        d->tag = value;
++}
++
++/*!
++    Returns the access specification of this method (private, protected,
++    or public).  The default value is QMetaMethod::Public for methods,
++    slots, and constructors.  The default value is QMetaMethod::Protected
++    for signals.
++
++    \sa setAccess()
++*/
++QMetaMethod::Access QMetaMethodBuilder::access() const
++{
++    QMetaMethodBuilderPrivate *d = d_func();
++    if (d)
++        return d->access();
++    else
++        return QMetaMethod::Public;
++}
++
++/*!
++    Sets the access specification of this method (private, protected,
++    or public) to \a value.  If the method is a signal, this function
++    will be ignored.
++
++    \sa access()
++*/
++void QMetaMethodBuilder::setAccess(QMetaMethod::Access value)
++{
++    QMetaMethodBuilderPrivate *d = d_func();
++    if (d && d->methodType() != QMetaMethod::Signal)
++        d->setAccess(value);
++}
++
++/*!
++    Returns the additional attributes for this method.
++
++    \sa setAttributes()
++*/
++int QMetaMethodBuilder::attributes() const
++{
++    QMetaMethodBuilderPrivate *d = d_func();
++    if (d)
++        return (d->attributes >> 4);
++    else
++        return 0;
++}
++
++/*!
++    Sets the additional attributes for this method to \a value.
++
++    \sa attributes()
++*/
++void QMetaMethodBuilder::setAttributes(int value)
++{
++    QMetaMethodBuilderPrivate *d = d_func();
++    if (d)
++        d->attributes = ((d->attributes & 0x0f) | (value << 4));
++}
++
++/*!
++    \class QMetaPropertyBuilder
++    \internal
++    \brief The QMetaPropertyBuilder class enables modifications to a property definition on a meta object builder.
++*/
++
++QMetaPropertyBuilderPrivate *QMetaPropertyBuilder::d_func() const
++{
++    if (_mobj && _index >= 0 && _index < _mobj->d->properties.size())
++        return &(_mobj->d->properties[_index]);
++    else
++        return 0;
++}
++
++/*!
++    \fn QMetaPropertyBuilder::QMetaPropertyBuilder()
++    \internal
++*/
++
++/*!
++    \fn int QMetaPropertyBuilder::index() const
++
++    Returns the index of this property within its QMetaObjectBuilder.
++*/
++
++/*!
++    Returns the name associated with this property.
++
++    \sa type()
++*/
++QByteArray QMetaPropertyBuilder::name() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->name;
++    else
++        return QByteArray();
++}
++
++/*!
++    Returns the type associated with this property.
++
++    \sa name()
++*/
++QByteArray QMetaPropertyBuilder::type() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->type;
++    else
++        return QByteArray();
++}
++
++/*!
++    Returns true if this property has a notify signal; false otherwise.
++
++    \sa notifySignal(), setNotifySignal(), removeNotifySignal()
++*/
++bool QMetaPropertyBuilder::hasNotifySignal() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->flag(Notify);
++    else
++        return false;
++}
++
++/*!
++    Returns the notify signal associated with this property.
++
++    \sa hasNotifySignal(), setNotifySignal(), removeNotifySignal()
++*/
++QMetaMethodBuilder QMetaPropertyBuilder::notifySignal() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d && d->notifySignal >= 0)
++        return QMetaMethodBuilder(_mobj, d->notifySignal);
++    else
++        return QMetaMethodBuilder();
++}
++
++/*!
++    Sets the notify signal associated with this property to \a value.
++
++    \sa hasNotifySignal(), notifySignal(), removeNotifySignal()
++*/
++void QMetaPropertyBuilder::setNotifySignal(const QMetaMethodBuilder& value)
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d) {
++        if (value._mobj) {
++            d->notifySignal = value._index;
++            d->setFlag(Notify, true);
++        } else {
++            d->notifySignal = -1;
++            d->setFlag(Notify, false);
++        }
++    }
++}
++
++/*!
++    Removes the notify signal from this property.
++
++    \sa hasNotifySignal(), notifySignal(), setNotifySignal()
++*/
++void QMetaPropertyBuilder::removeNotifySignal()
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d) {
++        d->notifySignal = -1;
++        d->setFlag(Notify, false);
++    }
++}
++
++/*!
++    Returns true if this property is readable; otherwise returns false.
++    The default value is true.
++
++    \sa setReadable(), isWritable()
++*/
++bool QMetaPropertyBuilder::isReadable() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->flag(Readable);
++    else
++        return false;
++}
++
++/*!
++    Returns true if this property is writable; otherwise returns false.
++    The default value is true.
++
++    \sa setWritable(), isReadable()
++*/
++bool QMetaPropertyBuilder::isWritable() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->flag(Writable);
++    else
++        return false;
++}
++
++/*!
++    Returns true if this property can be reset to a default value; otherwise
++    returns false.  The default value is false.
++
++    \sa setResettable()
++*/
++bool QMetaPropertyBuilder::isResettable() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->flag(Resettable);
++    else
++        return false;
++}
++
++/*!
++    Returns true if this property is designable; otherwise returns false.
++    This default value is false.
++
++    \sa setDesignable(), isScriptable(), isStored()
++*/
++bool QMetaPropertyBuilder::isDesignable() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->flag(Designable);
++    else
++        return false;
++}
++
++/*!
++    Returns true if the property is scriptable; otherwise returns false.
++    This default value is true.
++
++    \sa setScriptable(), isDesignable(), isStored()
++*/
++bool QMetaPropertyBuilder::isScriptable() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->flag(Scriptable);
++    else
++        return false;
++}
++
++/*!
++    Returns true if the property is stored; otherwise returns false.
++    This default value is false.
++
++    \sa setStored(), isDesignable(), isScriptable()
++*/
++bool QMetaPropertyBuilder::isStored() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->flag(Stored);
++    else
++        return false;
++}
++
++/*!
++    Returns true if the property is editable; otherwise returns false.
++    This default value is false.
++
++    \sa setEditable(), isDesignable(), isScriptable(), isStored()
++*/
++bool QMetaPropertyBuilder::isEditable() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->flag(Editable);
++    else
++        return false;
++}
++
++/*!
++    Returns true if this property is designated as the \c USER
++    property, i.e., the one that the user can edit or that is
++    significant in some other way.  Otherwise it returns
++    false.  This default value is false.
++
++    \sa setUser(), isDesignable(), isScriptable()
++*/
++bool QMetaPropertyBuilder::isUser() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->flag(User);
++    else
++        return false;
++}
++
++/*!
++    Returns true if the property has a C++ setter function that
++    follows Qt's standard "name" / "setName" pattern. Designer and uic
++    query hasStdCppSet() in order to avoid expensive
++    QObject::setProperty() calls. All properties in Qt [should] follow
++    this pattern.  The default value is false.
++
++    \sa setStdCppSet()
++*/
++bool QMetaPropertyBuilder::hasStdCppSet() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->flag(StdCppSet);
++    else
++        return false;
++}
++
++/*!
++    Returns true if the property is an enumerator or flag type;
++    otherwise returns false.  This default value is false.
++
++    \sa setEnumOrFlag()
++*/
++bool QMetaPropertyBuilder::isEnumOrFlag() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->flag(EnumOrFlag);
++    else
++        return false;
++}
++
++/*!
++    Returns true if the property has the dynamic flag set;
++    otherwise returns false.  The default value is false.
++
++    \sa setDynamic()
++*/
++bool QMetaPropertyBuilder::isDynamic() const
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        return d->flag(Dynamic);
++    else
++        return false;
++}
++
++/*!
++    Sets this property to readable if \a value is true.
++
++    \sa isReadable(), setWritable()
++*/
++void QMetaPropertyBuilder::setReadable(bool value)
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        d->setFlag(Readable, value);
++}
++
++/*!
++    Sets this property to writable if \a value is true.
++
++    \sa isWritable(), setReadable()
++*/
++void QMetaPropertyBuilder::setWritable(bool value)
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        d->setFlag(Writable, value);
++}
++
++/*!
++    Sets this property to resettable if \a value is true.
++
++    \sa isResettable()
++*/
++void QMetaPropertyBuilder::setResettable(bool value)
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        d->setFlag(Resettable, value);
++}
++
++/*!
++    Sets this property to designable if \a value is true.
++
++    \sa isDesignable(), setScriptable(), setStored()
++*/
++void QMetaPropertyBuilder::setDesignable(bool value)
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        d->setFlag(Designable, value);
++}
++
++/*!
++    Sets this property to scriptable if \a value is true.
++
++    \sa isScriptable(), setDesignable(), setStored()
++*/
++void QMetaPropertyBuilder::setScriptable(bool value)
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        d->setFlag(Scriptable, value);
++}
++
++/*!
++    Sets this property to storable if \a value is true.
++
++    \sa isStored(), setDesignable(), setScriptable()
++*/
++void QMetaPropertyBuilder::setStored(bool value)
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        d->setFlag(Stored, value);
++}
++
++/*!
++    Sets this property to editable if \a value is true.
++
++    \sa isEditable(), setDesignable(), setScriptable(), setStored()
++*/
++void QMetaPropertyBuilder::setEditable(bool value)
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        d->setFlag(Editable, value);
++}
++
++/*!
++    Sets the \c USER flag on this property to \a value.
++
++    \sa isUser(), setDesignable(), setScriptable()
++*/
++void QMetaPropertyBuilder::setUser(bool value)
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        d->setFlag(User, value);
++}
++
++/*!
++    Sets the C++ setter flag on this property to \a value, which is
++    true if the property has a C++ setter function that follows Qt's
++    standard "name" / "setName" pattern.
++
++    \sa hasStdCppSet()
++*/
++void QMetaPropertyBuilder::setStdCppSet(bool value)
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        d->setFlag(StdCppSet, value);
++}
++
++/*!
++    Sets this property to be of an enumerator or flag type if
++    \a value is true.
++
++    \sa isEnumOrFlag()
++*/
++void QMetaPropertyBuilder::setEnumOrFlag(bool value)
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        d->setFlag(EnumOrFlag, value);
++}
++
++/*!
++    Sets this property to have the dynamic flag if \a value is
++    true.
++
++    \sa isDynamic()
++*/
++void QMetaPropertyBuilder::setDynamic(bool value)
++{
++    QMetaPropertyBuilderPrivate *d = d_func();
++    if (d)
++        d->setFlag(Dynamic, value);
++}
++
++/*!
++    \class QMetaEnumBuilder
++    \internal
++    \brief The QMetaEnumBuilder class enables modifications to an enumerator definition on a meta object builder.
++*/
++
++QMetaEnumBuilderPrivate *QMetaEnumBuilder::d_func() const
++{
++    if (_mobj && _index >= 0 && _index < _mobj->d->enumerators.size())
++        return &(_mobj->d->enumerators[_index]);
++    else
++        return 0;
++}
++
++/*!
++    \fn QMetaEnumBuilder::QMetaEnumBuilder()
++    \internal
++*/
++
++/*!
++    \fn int QMetaEnumBuilder::index() const
++
++    Returns the index of this enumerator within its QMetaObjectBuilder.
++*/
++
++/*!
++    Returns the name of the enumerator (without the scope).
++*/
++QByteArray QMetaEnumBuilder::name() const
++{
++    QMetaEnumBuilderPrivate *d = d_func();
++    if (d)
++        return d->name;
++    else
++        return QByteArray();
++}
++
++/*!
++    Returns true if this enumerator is used as a flag; otherwise returns
++    false.
++
++    \sa setIsFlag()
++*/
++bool QMetaEnumBuilder::isFlag() const
++{
++    QMetaEnumBuilderPrivate *d = d_func();
++    if (d)
++        return d->isFlag;
++    else
++        return false;
++}
++
++/*!
++    Sets this enumerator to be used as a flag if \a value is true.
++
++    \sa isFlag()
++*/
++void QMetaEnumBuilder::setIsFlag(bool value)
++{
++    QMetaEnumBuilderPrivate *d = d_func();
++    if (d)
++        d->isFlag = value;
++}
++
++/*!
++    Returns the number of keys.
++
++    \sa key(), addKey()
++*/
++int QMetaEnumBuilder::keyCount() const
++{
++    QMetaEnumBuilderPrivate *d = d_func();
++    if (d)
++        return d->keys.size();
++    else
++        return 0;
++}
++
++/*!
++    Returns the key with the given \a index, or an empty QByteArray
++    if no such key exists.
++
++    \sa keyCount(), addKey(), value()
++*/
++QByteArray QMetaEnumBuilder::key(int index) const
++{
++    QMetaEnumBuilderPrivate *d = d_func();
++    if (d && index >= 0 && index < d->keys.size())
++        return d->keys[index];
++    else
++        return QByteArray();
++}
++
++/*!
++    Returns the value with the given \a index; or returns -1 if there
++    is no such value.
++
++    \sa keyCount(), addKey(), key()
++*/
++int QMetaEnumBuilder::value(int index) const
++{
++    QMetaEnumBuilderPrivate *d = d_func();
++    if (d && index >= 0 && index < d->keys.size())
++        return d->values[index];
++    else
++        return -1;
++}
++
++/*!
++    Adds a new key called \a name to this enumerator, associated
++    with \a value.  Returns the index of the new key.
++
++    \sa keyCount(), key(), value(), removeKey()
++*/
++int QMetaEnumBuilder::addKey(const QByteArray& name, int value)
++{
++    QMetaEnumBuilderPrivate *d = d_func();
++    if (d) {
++        int index = d->keys.size();
++        d->keys += name;
++        d->values += value;
++        return index;
++    } else {
++        return -1;
++    }
++}
++
++/*!
++    Removes the key at \a index from this enumerator.
++
++    \sa addKey()
++*/
++void QMetaEnumBuilder::removeKey(int index)
++{
++    QMetaEnumBuilderPrivate *d = d_func();
++    if (d && index >= 0 && index < d->keys.size()) {
++        d->keys.removeAt(index);
++        d->values.removeAt(index);
++    }
++}
++
++QTM_END_NAMESPACE
+diff --git a/src/serviceframework/ipc/qmetaobjectbuilder_47_p.h b/src/serviceframework/ipc/qmetaobjectbuilder_47_p.h
+new file mode 100644
+index 0000000..5f25e0f
+--- /dev/null
++++ b/src/serviceframework/ipc/qmetaobjectbuilder_47_p.h
+@@ -0,0 +1,338 @@
++/****************************************************************************
++**
++** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
++** All rights reserved.
++** Contact: Nokia Corporation (qt-info@nokia.com)
++**
++** This file is part of the Qt Mobility Components.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** No Commercial Usage
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
++**
++** GNU Lesser General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU Lesser
++** General Public License version 2.1 as published by the Free Software
++** Foundation and appearing in the file LICENSE.LGPL included in the
++** packaging of this file.  Please review the following information to
++** ensure the GNU Lesser General Public License version 2.1 requirements
++** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
++**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights.  These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
++**
++**
++**
++**
++**
++**
++**
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++#ifndef QMETAOBJECTBUILDER_H
++#define QMETAOBJECTBUILDER_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists for the convenience
++// of moc.  This header file may change from version to version without notice,
++// or even be removed.
++//
++// We mean it.
++//
++
++#include <qmobilityglobal.h>
++#include <QtCore/qobject.h>
++#include <QtCore/qmetaobject.h>
++#include <QtCore/qdatastream.h>
++#include <QtCore/qmap.h>
++
++QTM_BEGIN_NAMESPACE
++
++class QMetaObjectBuilderPrivate;
++class QMetaMethodBuilder;
++class QMetaMethodBuilderPrivate;
++class QMetaPropertyBuilder;
++class QMetaPropertyBuilderPrivate;
++class QMetaEnumBuilder;
++class QMetaEnumBuilderPrivate;
++
++#ifdef IGNORE_METAOBJECTBUILDER_EXPORT
++  class QMetaObjectBuilder
++#else
++  class QM_AUTOTEST_EXPORT QMetaObjectBuilder
++#endif
++{
++public:
++    enum AddMember
++    {
++        ClassName               = 0x00000001,
++        SuperClass              = 0x00000002,
++        Methods                 = 0x00000004,
++        Signals                 = 0x00000008,
++        Slots                   = 0x00000010,
++        Constructors            = 0x00000020,
++        Properties              = 0x00000040,
++        Enumerators             = 0x00000080,
++        ClassInfos              = 0x00000100,
++        RelatedMetaObjects      = 0x00000200,
++        StaticMetacall          = 0x00000400,
++        PublicMethods           = 0x00000800,
++        ProtectedMethods        = 0x00001000,
++        PrivateMethods          = 0x00002000,
++        AllMembers              = 0x7FFFFFFF,
++        AllPrimaryMembers       = 0x7FFFFBFC
++    };
++    Q_DECLARE_FLAGS(AddMembers, AddMember)
++
++    enum MetaObjectFlag {
++        DynamicMetaObject = 0x01
++    };
++    Q_DECLARE_FLAGS(MetaObjectFlags, MetaObjectFlag)
++
++    QMetaObjectBuilder();
++    explicit QMetaObjectBuilder(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers);
++    virtual ~QMetaObjectBuilder();
++
++    QByteArray className() const;
++    void setClassName(const QByteArray& name);
++
++    const QMetaObject *superClass() const;
++    void setSuperClass(const QMetaObject *meta);
++
++    MetaObjectFlags flags() const;
++    void setFlags(MetaObjectFlags);
++
++    int methodCount() const;
++    int constructorCount() const;
++    int propertyCount() const;
++    int enumeratorCount() const;
++    int classInfoCount() const;
++    int relatedMetaObjectCount() const;
++
++    QMetaMethodBuilder addMethod(const QByteArray& signature);
++    QMetaMethodBuilder addMethod(const QByteArray& signature, const QByteArray& returnType);
++    QMetaMethodBuilder addMethod(const QMetaMethod& prototype);
++
++    QMetaMethodBuilder addSlot(const QByteArray& signature);
++    QMetaMethodBuilder addSignal(const QByteArray& signature);
++
++    QMetaMethodBuilder addConstructor(const QByteArray& signature);
++    QMetaMethodBuilder addConstructor(const QMetaMethod& prototype);
++
++    QMetaPropertyBuilder addProperty(const QByteArray& name, const QByteArray& type, int notifierId=-1);
++    QMetaPropertyBuilder addProperty(const QMetaProperty& prototype);
++
++    QMetaEnumBuilder addEnumerator(const QByteArray& name);
++    QMetaEnumBuilder addEnumerator(const QMetaEnum& prototype);
++
++    int addClassInfo(const QByteArray& name, const QByteArray& value);
++
++#ifdef Q_NO_DATA_RELOCATION
++    int addRelatedMetaObject(const QMetaObjectAccessor &meta);
++#else
++    int addRelatedMetaObject(const QMetaObject *meta);
++#endif
++
++    void addMetaObject(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers);
++
++    QMetaMethodBuilder method(int index) const;
++    QMetaMethodBuilder constructor(int index) const;
++    QMetaPropertyBuilder property(int index) const;
++    QMetaEnumBuilder enumerator(int index) const;
++    const QMetaObject *relatedMetaObject(int index) const;
++
++    QByteArray classInfoName(int index) const;
++    QByteArray classInfoValue(int index) const;
++
++    void removeMethod(int index);
++    void removeConstructor(int index);
++    void removeProperty(int index);
++    void removeEnumerator(int index);
++    void removeClassInfo(int index);
++    void removeRelatedMetaObject(int index);
++
++    int indexOfMethod(const QByteArray& signature);
++    int indexOfSignal(const QByteArray& signature);
++    int indexOfSlot(const QByteArray& signature);
++    int indexOfConstructor(const QByteArray& signature);
++    int indexOfProperty(const QByteArray& name);
++    int indexOfEnumerator(const QByteArray& name);
++    int indexOfClassInfo(const QByteArray& name);
++
++    typedef int (*StaticMetacallFunction)(QMetaObject::Call, int, void **);
++
++    QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction() const;
++    void setStaticMetacallFunction(QMetaObjectBuilder::StaticMetacallFunction value);
++
++    QMetaObject *toMetaObject() const;
++    QByteArray toRelocatableData(bool * = 0) const;
++    static void fromRelocatableData(QMetaObject *, const QMetaObject *, const QByteArray &);
++
++#ifndef QT_NO_DATASTREAM
++    void serialize(QDataStream& stream) const;
++    void deserialize
++        (QDataStream& stream,
++         const QMap<QByteArray, const QMetaObject *>& references);
++#endif
++
++private:
++    Q_DISABLE_COPY(QMetaObjectBuilder)
++
++    QMetaObjectBuilderPrivate *d;
++
++    friend class QMetaMethodBuilder;
++    friend class QMetaPropertyBuilder;
++    friend class QMetaEnumBuilder;
++};
++
++#ifdef IGNORE_METAOBJECTBUILDER_EXPORT
++  class QMetaMethodBuilder
++#else
++  class QM_AUTOTEST_EXPORT QMetaMethodBuilder
++#endif
++{
++public:
++    QMetaMethodBuilder() : _mobj(0), _index(0) {}
++
++    int index() const;
++
++    QMetaMethod::MethodType methodType() const;
++    QByteArray signature() const;
++
++    QByteArray returnType() const;
++    void setReturnType(const QByteArray& value);
++
++    QList<QByteArray> parameterNames() const;
++    void setParameterNames(const QList<QByteArray>& value);
++
++    QByteArray tag() const;
++    void setTag(const QByteArray& value);
++
++    QMetaMethod::Access access() const;
++    void setAccess(QMetaMethod::Access value);
++
++    int attributes() const;
++    void setAttributes(int value);
++
++private:
++    const QMetaObjectBuilder *_mobj;
++    int _index;
++
++    friend class QMetaObjectBuilder;
++    friend class QMetaPropertyBuilder;
++
++    QMetaMethodBuilder(const QMetaObjectBuilder *mobj, int index)
++        : _mobj(mobj), _index(index) {}
++
++    QMetaMethodBuilderPrivate *d_func() const;
++};
++
++#ifdef IGNORE_METAOBJECTBUILDER_EXPORT
++  class QMetaPropertyBuilder
++#else
++  class QM_AUTOTEST_EXPORT QMetaPropertyBuilder
++#endif
++{
++public:
++    QMetaPropertyBuilder() : _mobj(0), _index(0) {}
++
++    int index() const { return _index; }
++
++    QByteArray name() const;
++    QByteArray type() const;
++
++    bool hasNotifySignal() const;
++    QMetaMethodBuilder notifySignal() const;
++    void setNotifySignal(const QMetaMethodBuilder& value);
++    void removeNotifySignal();
++
++    bool isReadable() const;
++    bool isWritable() const;
++    bool isResettable() const;
++    bool isDesignable() const;
++    bool isScriptable() const;
++    bool isStored() const;
++    bool isEditable() const;
++    bool isUser() const;
++    bool hasStdCppSet() const;
++    bool isEnumOrFlag() const;
++    bool isDynamic() const;
++
++    void setReadable(bool value);
++    void setWritable(bool value);
++    void setResettable(bool value);
++    void setDesignable(bool value);
++    void setScriptable(bool value);
++    void setStored(bool value);
++    void setEditable(bool value);
++    void setUser(bool value);
++    void setStdCppSet(bool value);
++    void setEnumOrFlag(bool value);
++    void setDynamic(bool value);
++
++private:
++    const QMetaObjectBuilder *_mobj;
++    int _index;
++
++    friend class QMetaObjectBuilder;
++
++    QMetaPropertyBuilder(const QMetaObjectBuilder *mobj, int index)
++        : _mobj(mobj), _index(index) {}
++
++    QMetaPropertyBuilderPrivate *d_func() const;
++};
++
++#ifdef IGNORE_METAOBJECTBUILDER_EXPORT
++  class QMetaEnumBuilder
++#else
++  class QM_AUTOTEST_EXPORT QMetaEnumBuilder
++#endif
++{
++public:
++    QMetaEnumBuilder() : _mobj(0), _index(0) {}
++
++    int index() const { return _index; }
++
++    QByteArray name() const;
++
++    bool isFlag() const;
++    void setIsFlag(bool value);
++
++    int keyCount() const;
++    QByteArray key(int index) const;
++    int value(int index) const;
++
++    int addKey(const QByteArray& name, int value);
++    void removeKey(int index);
++
++private:
++    const QMetaObjectBuilder *_mobj;
++    int _index;
++
++    friend class QMetaObjectBuilder;
++
++    QMetaEnumBuilder(const QMetaObjectBuilder *mobj, int index)
++        : _mobj(mobj), _index(index) {}
++
++    QMetaEnumBuilderPrivate *d_func() const;
++};
++
++Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::AddMembers)
++Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::MetaObjectFlags)
++
++QTM_END_NAMESPACE
++
++#endif
+diff --git a/src/serviceframework/ipc/qmetaobjectbuilder_p.h b/src/serviceframework/ipc/qmetaobjectbuilder_p.h
+index 5f25e0f..7f29ddc 100644
+--- a/src/serviceframework/ipc/qmetaobjectbuilder_p.h
++++ b/src/serviceframework/ipc/qmetaobjectbuilder_p.h
+@@ -69,6 +69,8 @@ class QMetaPropertyBuilderPrivate;
+ class QMetaEnumBuilder;
+ class QMetaEnumBuilderPrivate;
+ 
++typedef const QMetaObject& (*QMetaObjectAccessor)();
++
+ #ifdef IGNORE_METAOBJECTBUILDER_EXPORT
+   class QMetaObjectBuilder
+ #else
+@@ -172,7 +174,7 @@ public:
+     int indexOfEnumerator(const QByteArray& name);
+     int indexOfClassInfo(const QByteArray& name);
+ 
+-    typedef int (*StaticMetacallFunction)(QMetaObject::Call, int, void **);
++    typedef QMetaObjectExtraData::StaticMetacallFunction StaticMetacallFunction;
+ 
+     QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction() const;
+     void setStaticMetacallFunction(QMetaObjectBuilder::StaticMetacallFunction value);
+@@ -269,7 +271,8 @@ public:
+     bool isUser() const;
+     bool hasStdCppSet() const;
+     bool isEnumOrFlag() const;
+-    bool isDynamic() const;
++    bool isConstant() const;
++    bool isFinal() const;
+ 
+     void setReadable(bool value);
+     void setWritable(bool value);
+@@ -281,7 +284,8 @@ public:
+     void setUser(bool value);
+     void setStdCppSet(bool value);
+     void setEnumOrFlag(bool value);
+-    void setDynamic(bool value);
++    void setConstant(bool value);
++    void setFinal(bool value);
+ 
+ private:
+     const QMetaObjectBuilder *_mobj;
+diff --git a/tests/auto/qmetaobjectbuilder/qmetaobjectbuilder.pro b/tests/auto/qmetaobjectbuilder/qmetaobjectbuilder.pro
+index 4cbc03a..fa6123b 100644
+--- a/tests/auto/qmetaobjectbuilder/qmetaobjectbuilder.pro
++++ b/tests/auto/qmetaobjectbuilder/qmetaobjectbuilder.pro
+@@ -9,7 +9,11 @@ QT = core
+ include(../../../common.pri)
+ 
+ # Input 
+-SOURCES += tst_qmetaobjectbuilder.cpp
++contains(QT_MAJOR_VERSION, 4):lessThan(QT_MINOR_VERSION, 8) {
++    SOURCES += tst_qmetaobjectbuilder_47.cpp
++} else {
++    SOURCES += tst_qmetaobjectbuilder.cpp
++}
+ 
+ CONFIG += mobility
+ MOBILITY = serviceframework
+diff --git a/tests/auto/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
+index 48ba43c..470d9e5 100644
+--- a/tests/auto/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
++++ b/tests/auto/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
+@@ -149,9 +149,9 @@ void tst_QMetaObjectBuilder::mocVersionCheck()
+     // whenenver moc changes.  Once QMetaObjectBuilder has been
+     // updated, this test can be changed to check for the next version.
+     int version = int(QObject::staticMetaObject.d.data[0]);
+-    QVERIFY(version == 4 || version == 5);
++    QVERIFY(version == 4 || version == 5 || version == 6);
+     version = int(staticMetaObject.d.data[0]);
+-    QVERIFY(version == 4 || version == 5);
++    QVERIFY(version == 4 || version == 5 || version == 6);
+ }
+ 
+ void tst_QMetaObjectBuilder::create()
+@@ -555,7 +555,8 @@ void tst_QMetaObjectBuilder::property()
+     QVERIFY(!nullProp.isUser());
+     QVERIFY(!nullProp.hasStdCppSet());
+     QVERIFY(!nullProp.isEnumOrFlag());
+-    QVERIFY(!nullProp.isDynamic());
++    QVERIFY(!nullProp.isConstant());
++    QVERIFY(!nullProp.isFinal());
+     QCOMPARE(nullProp.index(), 0);
+ 
+     // Add a property and check its attributes.
+@@ -573,7 +574,8 @@ void tst_QMetaObjectBuilder::property()
+     QVERIFY(!prop1.isUser());
+     QVERIFY(!prop1.hasStdCppSet());
+     QVERIFY(!prop1.isEnumOrFlag());
+-    QVERIFY(!prop1.isDynamic());
++    QVERIFY(!prop1.isConstant());
++    QVERIFY(!prop1.isFinal());
+     QCOMPARE(prop1.index(), 0);
+     QCOMPARE(builder.propertyCount(), 1);
+ 
+@@ -592,7 +594,8 @@ void tst_QMetaObjectBuilder::property()
+     QVERIFY(!prop2.isUser());
+     QVERIFY(!prop2.hasStdCppSet());
+     QVERIFY(!prop2.isEnumOrFlag());
+-    QVERIFY(!prop2.isDynamic());
++    QVERIFY(!prop2.isConstant());
++    QVERIFY(!prop2.isFinal());
+     QCOMPARE(prop2.index(), 1);
+     QCOMPARE(builder.propertyCount(), 2);
+ 
+@@ -614,7 +617,8 @@ void tst_QMetaObjectBuilder::property()
+     prop1.setUser(true);
+     prop1.setStdCppSet(true);
+     prop1.setEnumOrFlag(true);
+-    prop1.setDynamic(true);
++    prop1.setConstant(true);
++    prop1.setFinal(true);
+ 
+     // Check that prop1 is changed, but prop2 is not.
+     QCOMPARE(prop1.name(), QByteArray("foo"));
+@@ -629,7 +633,8 @@ void tst_QMetaObjectBuilder::property()
+     QVERIFY(prop1.isUser());
+     QVERIFY(prop1.hasStdCppSet());
+     QVERIFY(prop1.isEnumOrFlag());
+-    QVERIFY(prop1.isDynamic());
++    QVERIFY(prop1.isConstant());
++    QVERIFY(prop1.isFinal());
+     QVERIFY(prop2.isReadable());
+     QVERIFY(prop2.isWritable());
+     QCOMPARE(prop2.name(), QByteArray("bar"));
+@@ -642,7 +647,8 @@ void tst_QMetaObjectBuilder::property()
+     QVERIFY(!prop2.isUser());
+     QVERIFY(!prop2.hasStdCppSet());
+     QVERIFY(!prop2.isEnumOrFlag());
+-    QVERIFY(!prop2.isDynamic());
++    QVERIFY(!prop2.isConstant());
++    QVERIFY(!prop2.isFinal());
+ 
+     // Remove prop1 and check that prop2 becomes index 0.
+     builder.removeProperty(0);
+@@ -658,7 +664,8 @@ void tst_QMetaObjectBuilder::property()
+     QVERIFY(!prop2.isUser());
+     QVERIFY(!prop2.hasStdCppSet());
+     QVERIFY(!prop2.isEnumOrFlag());
+-    QVERIFY(!prop2.isDynamic());
++    QVERIFY(!prop2.isConstant());
++    QVERIFY(!prop2.isFinal());
+     QCOMPARE(prop2.index(), 0);
+ 
+     // Perform index-based lookup again.
+@@ -682,7 +689,8 @@ void tst_QMetaObjectBuilder::property()
+             prop2.setUser(false); \
+             prop2.setStdCppSet(false); \
+             prop2.setEnumOrFlag(false); \
+-            prop2.setDynamic(false); \
++            prop2.setConstant(false); \
++            prop2.setFinal(false); \
+         } while (0)
+ #define COUNT_FLAGS() \
+         ((prop2.isReadable() ? 1 : 0) + \
+@@ -695,7 +703,8 @@ void tst_QMetaObjectBuilder::property()
+          (prop2.isUser() ? 1 : 0) + \
+          (prop2.hasStdCppSet() ? 1 : 0) + \
+          (prop2.isEnumOrFlag() ? 1 : 0) + \
+-         (prop2.isDynamic() ? 1 : 0)) 
++         (prop2.isConstant() ? 1 : 0) + \
++         (prop2.isFinal() ? 1 : 0))
+ #define CHECK_FLAG(setFunc,isFunc) \
+         do { \
+             CLEAR_FLAGS(); \
+@@ -714,7 +723,8 @@ void tst_QMetaObjectBuilder::property()
+     CHECK_FLAG(setUser, isUser);
+     CHECK_FLAG(setStdCppSet, hasStdCppSet);
+     CHECK_FLAG(setEnumOrFlag, isEnumOrFlag);
+-    CHECK_FLAG(setDynamic, isDynamic);
++    CHECK_FLAG(setConstant, isConstant);
++    CHECK_FLAG(setFinal, isFinal);
+ 
+     // Check that nothing else changed.
+     QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Properties));
+@@ -958,9 +968,9 @@ void tst_QMetaObjectBuilder::relatedMetaObject()
+     QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::RelatedMetaObjects));
+ }
+ 
+-static int smetacall(QMetaObject::Call, int, void **)
++static void smetacall(QObject *, QMetaObject::Call, int, void **)
+ {
+-    return 0;
++    return;
+ }
+ 
+ void tst_QMetaObjectBuilder::staticMetacall()
+@@ -1263,8 +1273,8 @@ bool tst_QMetaObjectBuilder::sameMetaObject
+         if (extra1 && extra2) {
+             if (extra1->static_metacall != extra2->static_metacall)
+                 return false;
+-            //objects1 = extra1->objects;
+-            //objects2 = extra1->objects;
++            objects1 = extra1->objects;
++            objects2 = extra1->objects;
+         }
+     } else if (meta1->d.data[0] == meta2->d.data[0] && meta1->d.data[0] == 1) {
+         objects1 = (const QMetaObject **)(meta1->d.extradata);
+diff --git a/tests/auto/qmetaobjectbuilder/tst_qmetaobjectbuilder_47.cpp b/tests/auto/qmetaobjectbuilder/tst_qmetaobjectbuilder_47.cpp
+new file mode 100644
+index 0000000..96a7eca
+--- /dev/null
++++ b/tests/auto/qmetaobjectbuilder/tst_qmetaobjectbuilder_47.cpp
+@@ -0,0 +1,1283 @@
++/****************************************************************************
++**
++** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
++** All rights reserved.
++** Contact: Nokia Corporation (qt-info@nokia.com)
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** No Commercial Usage
++** This file contains pre-release code and may not be distributed.
++** You may use this file in accordance with the terms and conditions
++** contained in the Technology Preview License Agreement accompanying
++** this package.
++**
++** GNU Lesser General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU Lesser
++** General Public License version 2.1 as published by the Free Software
++** Foundation and appearing in the file LICENSE.LGPL included in the
++** packaging of this file.  Please review the following information to
++** ensure the GNU Lesser General Public License version 2.1 requirements
++** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
++**
++** In addition, as a special exception, Nokia gives you certain additional
++** rights.  These rights are described in the Nokia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** If you have questions regarding the use of this file, please contact
++** Nokia at qt-info@nokia.com.
++**
++**
++**
++**
++**
++**
++**
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++//TESTED_COMPONENT=src/serviceframework
++
++#include <qmobilityglobal.h>
++#include <QtTest/QtTest>
++#include <QtCore/qlocale.h>
++#include <qmetaobjectbuilder_47_p.h>
++
++QTM_USE_NAMESPACE
++
++class tst_QMetaObjectBuilder : public QObject
++{
++    Q_OBJECT
++public:
++    tst_QMetaObjectBuilder() {}
++    ~tst_QMetaObjectBuilder() {}
++
++private slots:
++    void mocVersionCheck();
++    void create();
++    void className();
++    void superClass();
++    void flags();
++    void method();
++    void slot();
++    void signal();
++    void constructor();
++    void property();
++    void notifySignal();
++    void enumerator();
++    void classInfo();
++    void relatedMetaObject();
++    void staticMetacall();
++    void copyMetaObject();
++    void serialize();
++    void removeNotifySignal();
++
++private:
++    static bool checkForSideEffects
++        (const QMetaObjectBuilder& builder,
++         QMetaObjectBuilder::AddMembers members);
++    static bool sameMetaObject
++        (const QMetaObject *meta1, const QMetaObject *meta2);
++};
++
++#ifdef Q_NO_DATA_RELOCATION
++const QMetaObject *meta;
++#endif
++
++// Dummy class that has something of every type of thing moc can generate.
++class SomethingOfEverything : public QObject
++{
++    Q_OBJECT
++    Q_CLASSINFO("ci_foo", "ABC")
++    Q_CLASSINFO("ci_bar", "DEF")
++    Q_PROPERTY(QString prop READ prop WRITE setProp NOTIFY propChanged)
++    Q_PROPERTY(QString prop2 READ prop WRITE setProp)
++    Q_PROPERTY(SomethingEnum eprop READ eprop)
++    Q_PROPERTY(SomethingFlagEnum fprop READ fprop)
++    Q_PROPERTY(QLocale::Language language READ language)
++    Q_ENUMS(SomethingEnum)
++    Q_FLAGS(SomethingFlagEnum)
++public:
++    Q_INVOKABLE SomethingOfEverything() {}
++    ~SomethingOfEverything() {}
++
++    enum SomethingEnum
++    {
++        GHI,
++        JKL = 10
++    };
++
++    enum SomethingFlagEnum
++    {
++        XYZ = 1,
++        UVW = 8
++    };
++
++    Q_INVOKABLE Q_SCRIPTABLE void method1() {}
++
++    QString prop() const { return QString(); }
++    void setProp(const QString& v) { Q_UNUSED(v); }
++
++    SomethingOfEverything::SomethingEnum eprop() const { return GHI; }
++    SomethingOfEverything::SomethingFlagEnum fprop() const { return XYZ; }
++    QLocale::Language language() const { return QLocale::English; }
++
++public slots:
++    void slot1(const QString&) {}
++    void slot2(int, const QString&) {}
++
++private slots:
++    void slot3() {}
++
++protected slots:
++    Q_SCRIPTABLE void slot4(int) {}
++    void slot5(int a, const QString& b) { Q_UNUSED(a); Q_UNUSED(b); }
++
++signals:
++    void sig1();
++    void sig2(int x, const QString& y);
++    void propChanged(const QString&);
++};
++
++void tst_QMetaObjectBuilder::mocVersionCheck()
++{
++    // This test will fail when the moc version number is changed.
++    // It is intended as a reminder to also update QMetaObjectBuilder
++    // whenenver moc changes.  Once QMetaObjectBuilder has been
++    // updated, this test can be changed to check for the next version.
++    int version = int(QObject::staticMetaObject.d.data[0]);
++    QVERIFY(version == 4 || version == 5 || version == 6);
++    version = int(staticMetaObject.d.data[0]);
++    QVERIFY(version == 4 || version == 5 || version == 6);
++}
++
++void tst_QMetaObjectBuilder::create()
++{
++    QMetaObjectBuilder builder;
++    QVERIFY(builder.className().isEmpty());
++    QVERIFY(builder.superClass() == &QObject::staticMetaObject);
++    QCOMPARE(builder.methodCount(), 0);
++    QCOMPARE(builder.constructorCount(), 0);
++    QCOMPARE(builder.propertyCount(), 0);
++    QCOMPARE(builder.enumeratorCount(), 0);
++    QCOMPARE(builder.classInfoCount(), 0);
++    QCOMPARE(builder.relatedMetaObjectCount(), 0);
++    QVERIFY(builder.staticMetacallFunction() == 0);
++}
++
++void tst_QMetaObjectBuilder::className()
++{
++    QMetaObjectBuilder builder;
++
++    // Change the class name.
++    builder.setClassName("Foo");
++    QCOMPARE(builder.className(), QByteArray("Foo"));
++
++    // Change it again.
++    builder.setClassName("Bar");
++    QCOMPARE(builder.className(), QByteArray("Bar"));
++
++    // Clone the class name off a static QMetaObject.
++    builder.addMetaObject(&QObject::staticMetaObject, QMetaObjectBuilder::ClassName);
++    QCOMPARE(builder.className(), QByteArray("QObject"));
++
++    // Check that nothing else changed.
++    QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::ClassName));
++}
++
++void tst_QMetaObjectBuilder::superClass()
++{
++    QMetaObjectBuilder builder;
++
++    // Change the super class.
++    builder.setSuperClass(&QObject::staticMetaObject);
++    QVERIFY(builder.superClass() == &QObject::staticMetaObject);
++
++    // Change it again.
++    builder.setSuperClass(&staticMetaObject);
++    QVERIFY(builder.superClass() == &staticMetaObject);
++
++    // Clone the super class off a static QMetaObject.
++    builder.addMetaObject(&QObject::staticMetaObject, QMetaObjectBuilder::SuperClass);
++    QVERIFY(builder.superClass() == 0);
++    builder.addMetaObject(&staticMetaObject, QMetaObjectBuilder::SuperClass);
++    QVERIFY(builder.superClass() == staticMetaObject.superClass());
++
++    // Check that nothing else changed.
++    QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::SuperClass));
++}
++
++void tst_QMetaObjectBuilder::flags()
++{
++    QMetaObjectBuilder builder;
++
++    // Check default
++    QVERIFY(builder.flags() == 0);
++
++    // Set flags
++    builder.setFlags(QMetaObjectBuilder::DynamicMetaObject);
++    QVERIFY(builder.flags() == QMetaObjectBuilder::DynamicMetaObject);
++}
++
++void tst_QMetaObjectBuilder::method()
++{
++    QMetaObjectBuilder builder;
++
++    // Check null method
++    QMetaMethodBuilder nullMethod;
++    QCOMPARE(nullMethod.signature(), QByteArray());
++    QVERIFY(nullMethod.methodType() == QMetaMethod::Method);
++    QVERIFY(nullMethod.returnType().isEmpty());
++    QVERIFY(nullMethod.parameterNames().isEmpty());
++    QVERIFY(nullMethod.tag().isEmpty());
++    QVERIFY(nullMethod.access() == QMetaMethod::Public);
++    QCOMPARE(nullMethod.attributes(), 0);
++    QCOMPARE(nullMethod.index(), 0);
++
++    // Add a method and check its attributes.
++    QMetaMethodBuilder method1 = builder.addMethod("foo(const QString&, int)");
++    QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
++    QVERIFY(method1.methodType() == QMetaMethod::Method);
++    QVERIFY(method1.returnType().isEmpty());
++    QVERIFY(method1.parameterNames().isEmpty());
++    QVERIFY(method1.tag().isEmpty());
++    QVERIFY(method1.access() == QMetaMethod::Public);
++    QCOMPARE(method1.attributes(), 0);
++    QCOMPARE(method1.index(), 0);
++    QCOMPARE(builder.methodCount(), 1);
++
++    // Add another method and check again.
++    QMetaMethodBuilder method2 = builder.addMethod("bar(QString)", "int");
++    QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
++    QVERIFY(method2.methodType() == QMetaMethod::Method);
++    QCOMPARE(method2.returnType(), QByteArray("int"));
++    QVERIFY(method2.parameterNames().isEmpty());
++    QVERIFY(method2.tag().isEmpty());
++    QVERIFY(method2.access() == QMetaMethod::Public);
++    QCOMPARE(method2.attributes(), 0);
++    QCOMPARE(method2.index(), 1);
++    QCOMPARE(builder.methodCount(), 2);
++
++    // Perform index-based lookup.
++    QCOMPARE(builder.indexOfMethod("foo(const QString&, int)"), 0);
++    QCOMPARE(builder.indexOfMethod("bar(QString)"), 1);
++    QCOMPARE(builder.indexOfMethod("baz()"), -1);
++
++    // Modify the attributes on method1.
++    method1.setReturnType("int");
++    method1.setParameterNames(QList<QByteArray>() << "a" << "b");
++    method1.setTag("tag");
++    method1.setAccess(QMetaMethod::Private);
++    method1.setAttributes(42);
++
++    // Check that method1 is changed, but method2 is not.
++    QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
++    QVERIFY(method1.methodType() == QMetaMethod::Method);
++    QCOMPARE(method1.returnType(), QByteArray("int"));
++    QCOMPARE(method1.parameterNames(), QList<QByteArray>() << "a" << "b");
++    QCOMPARE(method1.tag(), QByteArray("tag"));
++    QVERIFY(method1.access() == QMetaMethod::Private);
++    QCOMPARE(method1.attributes(), 42);
++    QCOMPARE(method1.index(), 0);
++    QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
++    QVERIFY(method2.methodType() == QMetaMethod::Method);
++    QCOMPARE(method2.returnType(), QByteArray("int"));
++    QVERIFY(method2.parameterNames().isEmpty());
++    QVERIFY(method2.tag().isEmpty());
++    QVERIFY(method2.access() == QMetaMethod::Public);
++    QCOMPARE(method2.attributes(), 0);
++    QCOMPARE(method2.index(), 1);
++    QCOMPARE(builder.methodCount(), 2);
++
++    // Modify the attributes on method2.
++    method2.setReturnType("QString");
++    method2.setParameterNames(QList<QByteArray>() << "c");
++    method2.setTag("Q_FOO");
++    method2.setAccess(QMetaMethod::Protected);
++    method2.setAttributes(24);
++
++    // This time check that only method2 changed.
++    QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
++    QVERIFY(method1.methodType() == QMetaMethod::Method);
++    QCOMPARE(method1.returnType(), QByteArray("int"));
++    QCOMPARE(method1.parameterNames(), QList<QByteArray>() << "a" << "b");
++    QCOMPARE(method1.tag(), QByteArray("tag"));
++    QVERIFY(method1.access() == QMetaMethod::Private);
++    QCOMPARE(method1.attributes(), 42);
++    QCOMPARE(method1.index(), 0);
++    QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
++    QVERIFY(method2.methodType() == QMetaMethod::Method);
++    QCOMPARE(method2.returnType(), QByteArray("QString"));
++    QCOMPARE(method2.parameterNames(), QList<QByteArray>() << "c");
++    QCOMPARE(method2.tag(), QByteArray("Q_FOO"));
++    QVERIFY(method2.access() == QMetaMethod::Protected);
++    QCOMPARE(method2.attributes(), 24);
++    QCOMPARE(method2.index(), 1);
++    QCOMPARE(builder.methodCount(), 2);
++
++    // Remove method1 and check that method2 becomes index 0.
++    builder.removeMethod(0);
++    QCOMPARE(builder.methodCount(), 1);
++    method2 = builder.method(0);
++    QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
++    QVERIFY(method2.methodType() == QMetaMethod::Method);
++    QCOMPARE(method2.returnType(), QByteArray("QString"));
++    QCOMPARE(method2.parameterNames(), QList<QByteArray>() << "c");
++    QCOMPARE(method2.tag(), QByteArray("Q_FOO"));
++    QVERIFY(method2.access() == QMetaMethod::Protected);
++    QCOMPARE(method2.attributes(), 24);
++    QCOMPARE(method2.index(), 0);
++
++    // Perform index-based lookup again.
++    QCOMPARE(builder.indexOfMethod("foo(const QString&, int)"), -1);
++    QCOMPARE(builder.indexOfMethod("bar(QString)"), 0);
++    QCOMPARE(builder.indexOfMethod("baz()"), -1);
++    QCOMPARE(builder.method(0).signature(), QByteArray("bar(QString)"));
++    QCOMPARE(builder.method(9).signature(), QByteArray());
++
++    // Check that nothing else changed.
++    QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Methods));
++}
++
++void tst_QMetaObjectBuilder::slot()
++{
++    QMetaObjectBuilder builder;
++
++    // Add a slot and check its attributes.
++    QMetaMethodBuilder method1 = builder.addSlot("foo(const QString&, int)");
++    QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
++    QVERIFY(method1.methodType() == QMetaMethod::Slot);
++    QVERIFY(method1.returnType().isEmpty());
++    QVERIFY(method1.parameterNames().isEmpty());
++    QVERIFY(method1.tag().isEmpty());
++    QVERIFY(method1.access() == QMetaMethod::Public);
++    QCOMPARE(method1.attributes(), 0);
++    QCOMPARE(method1.index(), 0);
++    QCOMPARE(builder.methodCount(), 1);
++
++    // Add another slot and check again.
++    QMetaMethodBuilder method2 = builder.addSlot("bar(QString)");
++    QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
++    QVERIFY(method2.methodType() == QMetaMethod::Slot);
++    QVERIFY(method2.returnType().isEmpty());
++    QVERIFY(method2.parameterNames().isEmpty());
++    QVERIFY(method2.tag().isEmpty());
++    QVERIFY(method2.access() == QMetaMethod::Public);
++    QCOMPARE(method2.attributes(), 0);
++    QCOMPARE(method2.index(), 1);
++    QCOMPARE(builder.methodCount(), 2);
++
++    // Perform index-based lookup
++    QCOMPARE(builder.indexOfSlot("foo(const QString &, int)"), 0);
++    QCOMPARE(builder.indexOfSlot("bar(QString)"), 1);
++    QCOMPARE(builder.indexOfSlot("baz()"), -1);
++
++    // Check that nothing else changed.
++    QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Methods));
++}
++
++void tst_QMetaObjectBuilder::signal()
++{
++    QMetaObjectBuilder builder;
++
++    // Add a signal and check its attributes.
++    QMetaMethodBuilder method1 = builder.addSignal("foo(const QString&, int)");
++    QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
++    QVERIFY(method1.methodType() == QMetaMethod::Signal);
++    QVERIFY(method1.returnType().isEmpty());
++    QVERIFY(method1.parameterNames().isEmpty());
++    QVERIFY(method1.tag().isEmpty());
++    QVERIFY(method1.access() == QMetaMethod::Protected);
++    QCOMPARE(method1.attributes(), 0);
++    QCOMPARE(method1.index(), 0);
++    QCOMPARE(builder.methodCount(), 1);
++
++    // Add another signal and check again.
++    QMetaMethodBuilder method2 = builder.addSignal("bar(QString)");
++    QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
++    QVERIFY(method2.methodType() == QMetaMethod::Signal);
++    QVERIFY(method2.returnType().isEmpty());
++    QVERIFY(method2.parameterNames().isEmpty());
++    QVERIFY(method2.tag().isEmpty());
++    QVERIFY(method2.access() == QMetaMethod::Protected);
++    QCOMPARE(method2.attributes(), 0);
++    QCOMPARE(method2.index(), 1);
++    QCOMPARE(builder.methodCount(), 2);
++
++    // Perform index-based lookup
++    QCOMPARE(builder.indexOfSignal("foo(const QString &, int)"), 0);
++    QCOMPARE(builder.indexOfSignal("bar(QString)"), 1);
++    QCOMPARE(builder.indexOfSignal("baz()"), -1);
++
++    // Check that nothing else changed.
++    QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Methods));
++}
++
++void tst_QMetaObjectBuilder::constructor()
++{
++    QMetaObjectBuilder builder;
++
++    // Add a constructor and check its attributes.
++    QMetaMethodBuilder ctor1 = builder.addConstructor("foo(const QString&, int)");
++    QCOMPARE(ctor1.signature(), QByteArray("foo(QString,int)"));
++    QVERIFY(ctor1.methodType() == QMetaMethod::Constructor);
++    QVERIFY(ctor1.returnType().isEmpty());
++    QVERIFY(ctor1.parameterNames().isEmpty());
++    QVERIFY(ctor1.tag().isEmpty());
++    QVERIFY(ctor1.access() == QMetaMethod::Public);
++    QCOMPARE(ctor1.attributes(), 0);
++    QCOMPARE(ctor1.index(), 0);
++    QCOMPARE(builder.constructorCount(), 1);
++
++    // Add another constructor and check again.
++    QMetaMethodBuilder ctor2 = builder.addConstructor("bar(QString)");
++    QCOMPARE(ctor2.signature(), QByteArray("bar(QString)"));
++    QVERIFY(ctor2.methodType() == QMetaMethod::Constructor);
++    QVERIFY(ctor2.returnType().isEmpty());
++    QVERIFY(ctor2.parameterNames().isEmpty());
++    QVERIFY(ctor2.tag().isEmpty());
++    QVERIFY(ctor2.access() == QMetaMethod::Public);
++    QCOMPARE(ctor2.attributes(), 0);
++    QCOMPARE(ctor2.index(), 1);
++    QCOMPARE(builder.constructorCount(), 2);
++
++    // Perform index-based lookup.
++    QCOMPARE(builder.indexOfConstructor("foo(const QString&, int)"), 0);
++    QCOMPARE(builder.indexOfConstructor("bar(QString)"), 1);
++    QCOMPARE(builder.indexOfConstructor("baz()"), -1);
++    QCOMPARE(builder.constructor(1).signature(), QByteArray("bar(QString)"));
++    QCOMPARE(builder.constructor(9).signature(), QByteArray());
++
++    // Modify the attributes on ctor1.
++    ctor1.setReturnType("int");
++    ctor1.setParameterNames(QList<QByteArray>() << "a" << "b");
++    ctor1.setTag("tag");
++    ctor1.setAccess(QMetaMethod::Private);
++    ctor1.setAttributes(42);
++
++    // Check that ctor1 is changed, but ctor2 is not.
++    QCOMPARE(ctor1.signature(), QByteArray("foo(QString,int)"));
++    QVERIFY(ctor1.methodType() == QMetaMethod::Constructor);
++    QCOMPARE(ctor1.returnType(), QByteArray("int"));
++    QCOMPARE(ctor1.parameterNames(), QList<QByteArray>() << "a" << "b");
++    QCOMPARE(ctor1.tag(), QByteArray("tag"));
++    QVERIFY(ctor1.access() == QMetaMethod::Private);
++    QCOMPARE(ctor1.attributes(), 42);
++    QCOMPARE(ctor1.index(), 0);
++    QCOMPARE(ctor2.signature(), QByteArray("bar(QString)"));
++    QVERIFY(ctor2.methodType() == QMetaMethod::Constructor);
++    QVERIFY(ctor2.returnType().isEmpty());
++    QVERIFY(ctor2.parameterNames().isEmpty());
++    QVERIFY(ctor2.tag().isEmpty());
++    QVERIFY(ctor2.access() == QMetaMethod::Public);
++    QCOMPARE(ctor2.attributes(), 0);
++    QCOMPARE(ctor2.index(), 1);
++    QCOMPARE(builder.constructorCount(), 2);
++
++    // Modify the attributes on ctor2.
++    ctor2.setReturnType("QString");
++    ctor2.setParameterNames(QList<QByteArray>() << "c");
++    ctor2.setTag("Q_FOO");
++    ctor2.setAccess(QMetaMethod::Protected);
++    ctor2.setAttributes(24);
++
++    // This time check that only ctor2 changed.
++    QCOMPARE(ctor1.signature(), QByteArray("foo(QString,int)"));
++    QVERIFY(ctor1.methodType() == QMetaMethod::Constructor);
++    QCOMPARE(ctor1.returnType(), QByteArray("int"));
++    QCOMPARE(ctor1.parameterNames(), QList<QByteArray>() << "a" << "b");
++    QCOMPARE(ctor1.tag(), QByteArray("tag"));
++    QVERIFY(ctor1.access() == QMetaMethod::Private);
++    QCOMPARE(ctor1.attributes(), 42);
++    QCOMPARE(ctor1.index(), 0);
++    QCOMPARE(ctor2.signature(), QByteArray("bar(QString)"));
++    QVERIFY(ctor2.methodType() == QMetaMethod::Constructor);
++    QCOMPARE(ctor2.returnType(), QByteArray("QString"));
++    QCOMPARE(ctor2.parameterNames(), QList<QByteArray>() << "c");
++    QCOMPARE(ctor2.tag(), QByteArray("Q_FOO"));
++    QVERIFY(ctor2.access() == QMetaMethod::Protected);
++    QCOMPARE(ctor2.attributes(), 24);
++    QCOMPARE(ctor2.index(), 1);
++    QCOMPARE(builder.constructorCount(), 2);
++
++    // Remove ctor1 and check that ctor2 becomes index 0.
++    builder.removeConstructor(0);
++    QCOMPARE(builder.constructorCount(), 1);
++    ctor2 = builder.constructor(0);
++    QCOMPARE(ctor2.signature(), QByteArray("bar(QString)"));
++    QVERIFY(ctor2.methodType() == QMetaMethod::Constructor);
++    QCOMPARE(ctor2.returnType(), QByteArray("QString"));
++    QCOMPARE(ctor2.parameterNames(), QList<QByteArray>() << "c");
++    QCOMPARE(ctor2.tag(), QByteArray("Q_FOO"));
++    QVERIFY(ctor2.access() == QMetaMethod::Protected);
++    QCOMPARE(ctor2.attributes(), 24);
++    QCOMPARE(ctor2.index(), 0);
++
++    // Perform index-based lookup again.
++    QCOMPARE(builder.indexOfConstructor("foo(const QString&, int)"), -1);
++    QCOMPARE(builder.indexOfConstructor("bar(QString)"), 0);
++    QCOMPARE(builder.indexOfConstructor("baz()"), -1);
++
++    // Add constructor from prototype
++    QMetaMethod prototype = SomethingOfEverything::staticMetaObject.constructor(0);
++    QMetaMethodBuilder prototypeConstructor = builder.addMethod(prototype);
++    QCOMPARE(builder.constructorCount(), 2);
++
++    QCOMPARE(prototypeConstructor.signature(), QByteArray("SomethingOfEverything()"));
++    QVERIFY(prototypeConstructor.methodType() == QMetaMethod::Constructor);
++    QCOMPARE(prototypeConstructor.returnType(), QByteArray());
++    QVERIFY(prototypeConstructor.access() == QMetaMethod::Public);
++    QCOMPARE(prototypeConstructor.index(), 1);
++
++    // Check that nothing else changed.
++    QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Constructors));
++}
++
++void tst_QMetaObjectBuilder::property()
++{
++    QMetaObjectBuilder builder;
++
++    // Null property builder
++    QMetaPropertyBuilder nullProp;
++    QCOMPARE(nullProp.name(), QByteArray());
++    QCOMPARE(nullProp.type(), QByteArray());
++    QVERIFY(!nullProp.hasNotifySignal());
++    QVERIFY(!nullProp.isReadable());
++    QVERIFY(!nullProp.isWritable());
++    QVERIFY(!nullProp.isResettable());
++    QVERIFY(!nullProp.isDesignable());
++    QVERIFY(!nullProp.isScriptable());
++    QVERIFY(!nullProp.isStored());
++    QVERIFY(!nullProp.isEditable());
++    QVERIFY(!nullProp.isUser());
++    QVERIFY(!nullProp.hasStdCppSet());
++    QVERIFY(!nullProp.isEnumOrFlag());
++   QCOMPARE(nullProp.index(), 0);
++
++    // Add a property and check its attributes.
++    QMetaPropertyBuilder prop1 = builder.addProperty("foo", "const QString &");
++    QCOMPARE(prop1.name(), QByteArray("foo"));
++    QCOMPARE(prop1.type(), QByteArray("QString"));
++    QVERIFY(!prop1.hasNotifySignal());
++    QVERIFY(prop1.isReadable());
++    QVERIFY(prop1.isWritable());
++    QVERIFY(!prop1.isResettable());
++    QVERIFY(!prop1.isDesignable());
++    QVERIFY(prop1.isScriptable());
++    QVERIFY(!prop1.isStored());
++    QVERIFY(!prop1.isEditable());
++    QVERIFY(!prop1.isUser());
++    QVERIFY(!prop1.hasStdCppSet());
++    QVERIFY(!prop1.isEnumOrFlag());
++
++    QCOMPARE(prop1.index(), 0);
++    QCOMPARE(builder.propertyCount(), 1);
++
++    // Add another property and check again.
++    QMetaPropertyBuilder prop2 = builder.addProperty("bar", "int");
++    QCOMPARE(prop2.name(), QByteArray("bar"));
++    QCOMPARE(prop2.type(), QByteArray("int"));
++    QVERIFY(!prop2.hasNotifySignal());
++    QVERIFY(prop2.isReadable());
++    QVERIFY(prop2.isWritable());
++    QVERIFY(!prop2.isResettable());
++    QVERIFY(!prop2.isDesignable());
++    QVERIFY(prop2.isScriptable());
++    QVERIFY(!prop2.isStored());
++    QVERIFY(!prop2.isEditable());
++    QVERIFY(!prop2.isUser());
++    QVERIFY(!prop2.hasStdCppSet());
++    QVERIFY(!prop2.isEnumOrFlag());
++
++    QCOMPARE(prop2.index(), 1);
++    QCOMPARE(builder.propertyCount(), 2);
++
++    // Perform index-based lookup.
++    QCOMPARE(builder.indexOfProperty("foo"), 0);
++    QCOMPARE(builder.indexOfProperty("bar"), 1);
++    QCOMPARE(builder.indexOfProperty("baz"), -1);
++    QCOMPARE(builder.property(1).name(), QByteArray("bar"));
++    QCOMPARE(builder.property(9).name(), QByteArray());
++
++    // Modify the attributes on prop1.
++    prop1.setReadable(false);
++    prop1.setWritable(false);
++    prop1.setResettable(true);
++    prop1.setDesignable(true);
++    prop1.setScriptable(false);
++    prop1.setStored(true);
++    prop1.setEditable(true);
++    prop1.setUser(true);
++    prop1.setStdCppSet(true);
++    prop1.setEnumOrFlag(true);
++
++    // Check that prop1 is changed, but prop2 is not.
++    QCOMPARE(prop1.name(), QByteArray("foo"));
++    QCOMPARE(prop1.type(), QByteArray("QString"));
++    QVERIFY(!prop1.isReadable());
++    QVERIFY(!prop1.isWritable());
++    QVERIFY(prop1.isResettable());
++    QVERIFY(prop1.isDesignable());
++    QVERIFY(!prop1.isScriptable());
++    QVERIFY(prop1.isStored());
++    QVERIFY(prop1.isEditable());
++    QVERIFY(prop1.isUser());
++    QVERIFY(prop1.hasStdCppSet());
++    QVERIFY(prop1.isEnumOrFlag());
++    QVERIFY(prop2.isReadable());
++    QVERIFY(prop2.isWritable());
++    QCOMPARE(prop2.name(), QByteArray("bar"));
++    QCOMPARE(prop2.type(), QByteArray("int"));
++    QVERIFY(!prop2.isResettable());
++    QVERIFY(!prop2.isDesignable());
++    QVERIFY(prop2.isScriptable());
++    QVERIFY(!prop2.isStored());
++    QVERIFY(!prop2.isEditable());
++    QVERIFY(!prop2.isUser());
++    QVERIFY(!prop2.hasStdCppSet());
++    QVERIFY(!prop2.isEnumOrFlag());
++
++    // Remove prop1 and check that prop2 becomes index 0.
++    builder.removeProperty(0);
++    QCOMPARE(builder.propertyCount(), 1);
++    prop2 = builder.property(0);
++    QCOMPARE(prop2.name(), QByteArray("bar"));
++    QCOMPARE(prop2.type(), QByteArray("int"));
++    QVERIFY(!prop2.isResettable());
++    QVERIFY(!prop2.isDesignable());
++    QVERIFY(prop2.isScriptable());
++    QVERIFY(!prop2.isStored());
++    QVERIFY(!prop2.isEditable());
++    QVERIFY(!prop2.isUser());
++    QVERIFY(!prop2.hasStdCppSet());
++    QVERIFY(!prop2.isEnumOrFlag());
++    QCOMPARE(prop2.index(), 0);
++
++    // Perform index-based lookup again.
++    QCOMPARE(builder.indexOfProperty("foo"), -1);
++    QCOMPARE(builder.indexOfProperty("bar"), 0);
++    QCOMPARE(builder.indexOfProperty("baz"), -1);
++
++    // Check for side-effects between the flags on prop2.
++    // Setting a flag to true shouldn't set any of the others to true.
++    // This checks for cut-and-paste bugs in the implementation where
++    // the flag code was pasted but the flag name was not changed.
++#define CLEAR_FLAGS() \
++        do { \
++            prop2.setReadable(false); \
++            prop2.setWritable(false); \
++            prop2.setResettable(false); \
++            prop2.setDesignable(false); \
++            prop2.setScriptable(false); \
++            prop2.setStored(false); \
++            prop2.setEditable(false); \
++            prop2.setUser(false); \
++            prop2.setStdCppSet(false); \
++            prop2.setEnumOrFlag(false); \
++        } while (0)
++#define COUNT_FLAGS() \
++        ((prop2.isReadable() ? 1 : 0) + \
++         (prop2.isWritable() ? 1 : 0) + \
++         (prop2.isResettable() ? 1 : 0) + \
++         (prop2.isDesignable() ? 1 : 0) + \
++         (prop2.isScriptable() ? 1 : 0) + \
++         (prop2.isStored() ? 1 : 0) + \
++         (prop2.isEditable() ? 1 : 0) + \
++         (prop2.isUser() ? 1 : 0) + \
++         (prop2.hasStdCppSet() ? 1 : 0) + \
++         (prop2.isEnumOrFlag() ? 1 : 0))
++#define CHECK_FLAG(setFunc,isFunc) \
++        do { \
++            CLEAR_FLAGS(); \
++            QCOMPARE(COUNT_FLAGS(), 0); \
++            prop2.setFunc(true); \
++            QVERIFY(prop2.isFunc()); \
++            QCOMPARE(COUNT_FLAGS(), 1); \
++        } while (0)
++    CHECK_FLAG(setReadable, isReadable);
++    CHECK_FLAG(setWritable, isWritable);
++    CHECK_FLAG(setResettable, isResettable);
++    CHECK_FLAG(setDesignable, isDesignable);
++    CHECK_FLAG(setScriptable, isScriptable);
++    CHECK_FLAG(setStored, isStored);
++    CHECK_FLAG(setEditable, isEditable);
++    CHECK_FLAG(setUser, isUser);
++    CHECK_FLAG(setStdCppSet, hasStdCppSet);
++    CHECK_FLAG(setEnumOrFlag, isEnumOrFlag);
++
++    // Check that nothing else changed.
++    QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Properties));
++
++    // Add property from prototype
++    QMetaProperty prototype = SomethingOfEverything::staticMetaObject.property(1);
++    QVERIFY(prototype.name() == QByteArray("prop"));
++    QMetaPropertyBuilder prototypeProp = builder.addProperty(prototype);
++    QCOMPARE(prototypeProp.name(), QByteArray("prop"));
++    QVERIFY(prototypeProp.hasNotifySignal());
++    QCOMPARE(prototypeProp.notifySignal().signature(), QByteArray("propChanged(QString)"));
++    QCOMPARE(builder.methodCount(), 1);
++    QCOMPARE(builder.method(0).signature(), QByteArray("propChanged(QString)"));
++}
++
++void tst_QMetaObjectBuilder::notifySignal()
++{
++    QMetaObjectBuilder builder;
++
++    QMetaPropertyBuilder prop = builder.addProperty("foo", "const QString &");
++    builder.addSlot("setFoo(QString)");
++    QMetaMethodBuilder notify = builder.addSignal("fooChanged(QString)");
++
++    QVERIFY(!prop.hasNotifySignal());
++    QCOMPARE(prop.notifySignal().index(), 0);
++
++    prop.setNotifySignal(notify);
++    QVERIFY(prop.hasNotifySignal());
++    QCOMPARE(prop.notifySignal().index(), 1);
++
++    prop.setNotifySignal(QMetaMethodBuilder());
++    QVERIFY(!prop.hasNotifySignal());
++    QCOMPARE(prop.notifySignal().index(), 0);
++
++    prop.setNotifySignal(notify);
++    prop.removeNotifySignal();
++    QVERIFY(!prop.hasNotifySignal());
++    QCOMPARE(prop.notifySignal().index(), 0);
++
++    QCOMPARE(builder.methodCount(), 2);
++    QCOMPARE(builder.propertyCount(), 1);
++
++    // Check that nothing else changed except methods and properties.
++    QVERIFY(checkForSideEffects
++        (builder, QMetaObjectBuilder::Methods | QMetaObjectBuilder::Properties));
++}
++
++void tst_QMetaObjectBuilder::enumerator()
++{
++    QMetaObjectBuilder builder;
++
++    // Add an enumerator and check its attributes.
++    QMetaEnumBuilder enum1 = builder.addEnumerator("foo");
++    QCOMPARE(enum1.name(), QByteArray("foo"));
++    QVERIFY(!enum1.isFlag());
++    QCOMPARE(enum1.keyCount(), 0);
++    QCOMPARE(enum1.index(), 0);
++    QCOMPARE(builder.enumeratorCount(), 1);
++
++    // Add another enumerator and check again.
++    QMetaEnumBuilder enum2 = builder.addEnumerator("bar");
++    QCOMPARE(enum2.name(), QByteArray("bar"));
++    QVERIFY(!enum2.isFlag());
++    QCOMPARE(enum2.keyCount(), 0);
++    QCOMPARE(enum2.index(), 1);
++    QCOMPARE(builder.enumeratorCount(), 2);
++
++    // Perform index-based lookup.
++    QCOMPARE(builder.indexOfEnumerator("foo"), 0);
++    QCOMPARE(builder.indexOfEnumerator("bar"), 1);
++    QCOMPARE(builder.indexOfEnumerator("baz"), -1);
++    QCOMPARE(builder.enumerator(1).name(), QByteArray("bar"));
++    QCOMPARE(builder.enumerator(9).name(), QByteArray());
++
++    // Modify the attributes on enum1.
++    enum1.setIsFlag(true);
++    QCOMPARE(enum1.addKey("ABC", 0), 0);
++    QCOMPARE(enum1.addKey("DEF", 1), 1);
++    QCOMPARE(enum1.addKey("GHI", -1), 2);
++
++    // Check that enum1 is changed, but enum2 is not.
++    QCOMPARE(enum1.name(), QByteArray("foo"));
++    QVERIFY(enum1.isFlag());
++    QCOMPARE(enum1.keyCount(), 3);
++    QCOMPARE(enum1.index(), 0);
++    QCOMPARE(enum1.key(0), QByteArray("ABC"));
++    QCOMPARE(enum1.key(1), QByteArray("DEF"));
++    QCOMPARE(enum1.key(2), QByteArray("GHI"));
++    QCOMPARE(enum1.key(3), QByteArray());
++    QCOMPARE(enum1.value(0), 0);
++    QCOMPARE(enum1.value(1), 1);
++    QCOMPARE(enum1.value(2), -1);
++    QCOMPARE(enum2.name(), QByteArray("bar"));
++    QVERIFY(!enum2.isFlag());
++    QCOMPARE(enum2.keyCount(), 0);
++    QCOMPARE(enum2.index(), 1);
++
++    // Modify the attributes on enum2.
++    enum2.setIsFlag(true);
++    QCOMPARE(enum2.addKey("XYZ", 10), 0);
++    QCOMPARE(enum2.addKey("UVW", 19), 1);
++
++    // This time check that only method2 changed.
++    QCOMPARE(enum1.name(), QByteArray("foo"));
++    QVERIFY(enum1.isFlag());
++    QCOMPARE(enum1.keyCount(), 3);
++    QCOMPARE(enum1.index(), 0);
++    QCOMPARE(enum1.key(0), QByteArray("ABC"));
++    QCOMPARE(enum1.key(1), QByteArray("DEF"));
++    QCOMPARE(enum1.key(2), QByteArray("GHI"));
++    QCOMPARE(enum1.key(3), QByteArray());
++    QCOMPARE(enum1.value(0), 0);
++    QCOMPARE(enum1.value(1), 1);
++    QCOMPARE(enum1.value(2), -1);
++    QCOMPARE(enum2.name(), QByteArray("bar"));
++    QVERIFY(enum2.isFlag());
++    QCOMPARE(enum2.keyCount(), 2);
++    QCOMPARE(enum2.index(), 1);
++    QCOMPARE(enum2.key(0), QByteArray("XYZ"));
++    QCOMPARE(enum2.key(1), QByteArray("UVW"));
++    QCOMPARE(enum2.key(2), QByteArray());
++    QCOMPARE(enum2.value(0), 10);
++    QCOMPARE(enum2.value(1), 19);
++
++    // Remove enum1 key
++    enum1.removeKey(2);
++    QCOMPARE(enum1.name(), QByteArray("foo"));
++    QVERIFY(enum1.isFlag());
++    QCOMPARE(enum1.keyCount(), 2);
++    QCOMPARE(enum1.index(), 0);
++    QCOMPARE(enum1.key(0), QByteArray("ABC"));
++    QCOMPARE(enum1.key(1), QByteArray("DEF"));
++    QCOMPARE(enum1.key(2), QByteArray());
++    QCOMPARE(enum1.value(0), 0);
++    QCOMPARE(enum1.value(1), 1);
++    QCOMPARE(enum1.value(2), -1);
++    QCOMPARE(enum2.name(), QByteArray("bar"));
++    QVERIFY(enum2.isFlag());
++    QCOMPARE(enum2.keyCount(), 2);
++    QCOMPARE(enum2.index(), 1);
++    QCOMPARE(enum2.key(0), QByteArray("XYZ"));
++    QCOMPARE(enum2.key(1), QByteArray("UVW"));
++    QCOMPARE(enum2.key(2), QByteArray());
++    QCOMPARE(enum2.value(0), 10);
++    QCOMPARE(enum2.value(1), 19);
++
++    // Remove enum1 and check that enum2 becomes index 0.
++    builder.removeEnumerator(0);
++    QCOMPARE(builder.enumeratorCount(), 1);
++    enum2 = builder.enumerator(0);
++    QCOMPARE(enum2.name(), QByteArray("bar"));
++    QVERIFY(enum2.isFlag());
++    QCOMPARE(enum2.keyCount(), 2);
++    QCOMPARE(enum2.index(), 0);
++    QCOMPARE(enum2.key(0), QByteArray("XYZ"));
++    QCOMPARE(enum2.key(1), QByteArray("UVW"));
++    QCOMPARE(enum2.key(2), QByteArray());
++    QCOMPARE(enum2.value(0), 10);
++    QCOMPARE(enum2.value(1), 19);
++
++    // Perform index-based lookup again.
++    QCOMPARE(builder.indexOfEnumerator("foo"), -1);
++    QCOMPARE(builder.indexOfEnumerator("bar"), 0);
++    QCOMPARE(builder.indexOfEnumerator("baz"), -1);
++
++    // Check that nothing else changed.
++    QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Enumerators));
++}
++
++void tst_QMetaObjectBuilder::classInfo()
++{
++    QMetaObjectBuilder builder;
++
++    // Add two items of class information and check their attributes.
++    QCOMPARE(builder.addClassInfo("foo", "value1"), 0);
++    QCOMPARE(builder.addClassInfo("bar", "value2"), 1);
++    QCOMPARE(builder.classInfoName(0), QByteArray("foo"));
++    QCOMPARE(builder.classInfoValue(0), QByteArray("value1"));
++    QCOMPARE(builder.classInfoName(1), QByteArray("bar"));
++    QCOMPARE(builder.classInfoValue(1), QByteArray("value2"));
++    QCOMPARE(builder.classInfoName(9), QByteArray());
++    QCOMPARE(builder.classInfoValue(9), QByteArray());
++    QCOMPARE(builder.classInfoCount(), 2);
++
++    // Perform index-based lookup.
++    QCOMPARE(builder.indexOfClassInfo("foo"), 0);
++    QCOMPARE(builder.indexOfClassInfo("bar"), 1);
++    QCOMPARE(builder.indexOfClassInfo("baz"), -1);
++
++    // Remove the first one and check again.
++    builder.removeClassInfo(0);
++    QCOMPARE(builder.classInfoName(0), QByteArray("bar"));
++    QCOMPARE(builder.classInfoValue(0), QByteArray("value2"));
++    QCOMPARE(builder.classInfoCount(), 1);
++
++    // Perform index-based lookup again.
++    QCOMPARE(builder.indexOfClassInfo("foo"), -1);
++    QCOMPARE(builder.indexOfClassInfo("bar"), 0);
++    QCOMPARE(builder.indexOfClassInfo("baz"), -1);
++
++    // Check that nothing else changed.
++    QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::ClassInfos));
++}
++
++#ifdef Q_NO_DATA_RELOCATION
++const QMetaObject& staticMetaObjectGlobal() 
++{
++  return QObject::staticMetaObject;
++}
++
++const QMetaObject& staticMetaObjectLocal() 
++{
++  return *meta;
++}
++#endif
++
++
++void tst_QMetaObjectBuilder::relatedMetaObject()
++{
++    QMetaObjectBuilder builder;
++    
++    // Add two related meta objects and check their attributes.
++#ifdef Q_NO_DATA_RELOCATION
++    meta = &staticMetaObject;
++    QCOMPARE(builder.addRelatedMetaObject(&staticMetaObjectGlobal), 0);    
++    QCOMPARE(builder.addRelatedMetaObject(&staticMetaObjectLocal), 1);
++#else
++    QCOMPARE(builder.addRelatedMetaObject(&QObject::staticMetaObject), 0);
++    QCOMPARE(builder.addRelatedMetaObject(&staticMetaObject), 1);
++#endif
++    QVERIFY(builder.relatedMetaObject(0) == &QObject::staticMetaObject);
++    QVERIFY(builder.relatedMetaObject(1) == &staticMetaObject);
++    QCOMPARE(builder.relatedMetaObjectCount(), 2);
++
++    // Remove the first one and check again.
++    builder.removeRelatedMetaObject(0);
++    QVERIFY(builder.relatedMetaObject(0) == &staticMetaObject);
++    QCOMPARE(builder.relatedMetaObjectCount(), 1);
++
++    // Check that nothing else changed.
++    QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::RelatedMetaObjects));
++}
++
++static int smetacall(QMetaObject::Call, int, void **)
++{
++    return 0;
++}
++
++void tst_QMetaObjectBuilder::staticMetacall()
++{
++    QMetaObjectBuilder builder;
++    QVERIFY(!builder.staticMetacallFunction());
++    builder.setStaticMetacallFunction(smetacall);
++    QVERIFY(builder.staticMetacallFunction() == smetacall);
++    QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::StaticMetacall));
++}
++
++// Copy the entire contents of a static QMetaObject and then check
++// that QMetaObjectBuilder will produce an exact copy as output.
++void tst_QMetaObjectBuilder::copyMetaObject()
++{
++    QMetaObjectBuilder builder(&QObject::staticMetaObject);
++    QMetaObject *meta = builder.toMetaObject();
++    QVERIFY(sameMetaObject(meta, &QObject::staticMetaObject));
++    qFree(meta);
++
++    QMetaObjectBuilder builder2(&staticMetaObject);
++    meta = builder2.toMetaObject();
++    QVERIFY(sameMetaObject(meta, &staticMetaObject));
++    qFree(meta);
++
++    QMetaObjectBuilder builder3(&SomethingOfEverything::staticMetaObject);
++    meta = builder3.toMetaObject();
++    QVERIFY(sameMetaObject(meta, &SomethingOfEverything::staticMetaObject));
++    qFree(meta);
++}
++
++// Serialize and deserialize a meta object and check that
++// it round-trips to the exact same value.
++void tst_QMetaObjectBuilder::serialize()
++{
++    // Full QMetaObjectBuilder
++    {
++    QMetaObjectBuilder builder(&SomethingOfEverything::staticMetaObject);
++    QMetaObject *meta = builder.toMetaObject();
++
++    QByteArray data;
++    QDataStream stream(&data, QIODevice::WriteOnly | QIODevice::Append);
++    builder.serialize(stream);
++
++    QMetaObjectBuilder builder2;
++    QDataStream stream2(data);
++    QMap<QByteArray, const QMetaObject *> references;
++    references.insert(QByteArray("QLocale"), &QLocale::staticMetaObject);
++    builder2.deserialize(stream2, references);
++#ifdef Q_NO_DATA_RELOCATION
++    //the related meta objects will be function pointers
++    //which you have to add to the builder manually.
++    builder2.addRelatedMetaObject(QLocale::getStaticMetaObject);
++#endif
++    builder2.setStaticMetacallFunction(builder.staticMetacallFunction());
++    QMetaObject *meta2 = builder2.toMetaObject();
++
++    QVERIFY(sameMetaObject(meta, meta2));
++    qFree(meta);
++    qFree(meta2);
++    }
++
++    // Partial QMetaObjectBuilder
++    {
++    QMetaObjectBuilder builder;
++    builder.setClassName("Test");
++    builder.addProperty("foo", "int");
++
++    QByteArray data;
++    QDataStream stream(&data, QIODevice::WriteOnly | QIODevice::Append);
++    builder.serialize(stream);
++
++    QMetaObjectBuilder builder2;
++    QDataStream stream2(data);
++    builder2.deserialize(stream2, QMap<QByteArray, const QMetaObject *>());
++
++    QCOMPARE(builder.superClass(), builder2.superClass());
++    QCOMPARE(builder.className(), builder2.className());
++    QCOMPARE(builder.propertyCount(), builder2.propertyCount());
++    QCOMPARE(builder.property(0).name(), builder2.property(0).name());
++    QCOMPARE(builder.property(0).type(), builder2.property(0).type());
++    }
++}
++
++// Check that removing a method updates notify signals appropriately
++void tst_QMetaObjectBuilder::removeNotifySignal()
++{
++    QMetaObjectBuilder builder;
++
++    QMetaMethodBuilder method1 = builder.addSignal("foo(const QString&, int)");
++    QMetaMethodBuilder method2 = builder.addSignal("bar(QString)");
++
++    // Setup property
++    QMetaPropertyBuilder prop = builder.addProperty("prop", "const QString &");
++    prop.setNotifySignal(method2);
++    QVERIFY(prop.hasNotifySignal());
++    QCOMPARE(prop.notifySignal().index(), 1);
++
++    // Remove non-notify signal
++    builder.removeMethod(0);
++    QVERIFY(prop.hasNotifySignal());
++    QCOMPARE(prop.notifySignal().index(), 0);
++
++    // Remove notify signal
++    builder.removeMethod(0);
++    QVERIFY(!prop.hasNotifySignal());
++}
++
++// Check that the only changes to a "builder" relative to the default
++// state is specified by "members".
++bool tst_QMetaObjectBuilder::checkForSideEffects
++        (const QMetaObjectBuilder& builder,
++         QMetaObjectBuilder::AddMembers members)
++{
++    if ((members & QMetaObjectBuilder::ClassName) == 0) {
++        if (!builder.className().isEmpty())
++            return false;
++    }
++
++    if ((members & QMetaObjectBuilder::SuperClass) == 0) {
++        if (builder.superClass() != &QObject::staticMetaObject)
++            return false;
++    }
++
++    if ((members & QMetaObjectBuilder::Methods) == 0) {
++        if (builder.methodCount() != 0)
++            return false;
++    }
++
++    if ((members & QMetaObjectBuilder::Constructors) == 0) {
++        if (builder.constructorCount() != 0)
++            return false;
++    }
++
++    if ((members & QMetaObjectBuilder::Properties) == 0) {
++        if (builder.propertyCount() != 0)
++            return false;
++    }
++
++    if ((members & QMetaObjectBuilder::Enumerators) == 0) {
++        if (builder.enumeratorCount() != 0)
++            return false;
++    }
++
++    if ((members & QMetaObjectBuilder::ClassInfos) == 0) {
++        if (builder.classInfoCount() != 0)
++            return false;
++    }
++
++    if ((members & QMetaObjectBuilder::RelatedMetaObjects) == 0) {
++        if (builder.relatedMetaObjectCount() != 0)
++            return false;
++    }
++
++    if ((members & QMetaObjectBuilder::StaticMetacall) == 0) {
++        if (builder.staticMetacallFunction() != 0)
++            return false;
++    }
++
++    return true;
++}
++
++static bool sameMethod(const QMetaMethod& method1, const QMetaMethod& method2)
++{
++    if (QByteArray(method1.signature()) != QByteArray(method2.signature()))
++        return false;
++
++    if (QByteArray(method1.typeName()) != QByteArray(method2.typeName()))
++        return false;
++
++    if (method1.parameterNames() != method2.parameterNames())
++        return false;
++
++    if (QByteArray(method1.tag()) != QByteArray(method2.tag()))
++        return false;
++
++    if (method1.access() != method2.access())
++        return false;
++
++    if (method1.methodType() != method2.methodType())
++        return false;
++
++    if (method1.attributes() != method2.attributes())
++        return false;
++
++    return true;
++}
++
++static bool sameProperty(const QMetaProperty& prop1, const QMetaProperty& prop2)
++{
++    if (QByteArray(prop1.name()) != QByteArray(prop2.name()))
++        return false;
++
++    if (QByteArray(prop1.typeName()) != QByteArray(prop2.typeName()))
++        return false;
++
++    if (prop1.isReadable() != prop2.isReadable() ||
++        prop1.isWritable() != prop2.isWritable() ||
++        prop1.isResettable() != prop2.isResettable() ||
++        prop1.isDesignable() != prop2.isDesignable() ||
++        prop1.isScriptable() != prop2.isScriptable() ||
++        prop1.isStored() != prop2.isStored() ||
++        prop1.isEditable() != prop2.isEditable() ||
++        prop1.isUser() != prop2.isUser() ||
++        prop1.isFlagType() != prop2.isFlagType() ||
++        prop1.isEnumType() != prop2.isEnumType() ||
++        prop1.hasNotifySignal() != prop2.hasNotifySignal() ||
++        prop1.hasStdCppSet() != prop2.hasStdCppSet())
++        return false;
++
++    if (prop1.hasNotifySignal()) {
++        if (prop1.notifySignalIndex() != prop2.notifySignalIndex())
++            return false;
++    }
++
++    return true;
++}
++
++static bool sameEnumerator(const QMetaEnum& enum1, const QMetaEnum& enum2)
++{
++    if (QByteArray(enum1.name()) != QByteArray(enum2.name()))
++        return false;
++
++    if (enum1.isFlag() != enum2.isFlag())
++        return false;
++
++    if (enum1.keyCount() != enum2.keyCount())
++        return false;
++
++    for (int index = 0; index < enum1.keyCount(); ++index) {
++        if (QByteArray(enum1.key(index)) != QByteArray(enum2.key(index)))
++            return false;
++        if (enum1.value(index) != enum2.value(index))
++            return false;
++    }
++
++    if (QByteArray(enum1.scope()) != QByteArray(enum2.scope()))
++        return false;
++
++    return true;
++}
++
++// Determine if two meta objects are identical.
++bool tst_QMetaObjectBuilder::sameMetaObject
++        (const QMetaObject *meta1, const QMetaObject *meta2)
++{
++    int index;
++
++    if (strcmp(meta1->className(), meta2->className()) != 0)
++        return false;
++
++    if (meta1->superClass() != meta2->superClass())
++        return false;
++
++    if (meta1->constructorCount() != meta2->constructorCount() ||
++        meta1->methodCount() != meta2->methodCount() ||
++        meta1->enumeratorCount() != meta2->enumeratorCount() ||
++        meta1->propertyCount() != meta2->propertyCount() ||
++        meta1->classInfoCount() != meta2->classInfoCount())
++        return false;
++
++    for (index = 0; index < meta1->constructorCount(); ++index) {
++        if (!sameMethod(meta1->constructor(index), meta2->constructor(index)))
++            return false;
++    }
++
++    for (index = 0; index < meta1->methodCount(); ++index) {
++        if (!sameMethod(meta1->method(index), meta2->method(index)))
++            return false;
++    }
++
++    for (index = 0; index < meta1->propertyCount(); ++index) {
++        if (!sameProperty(meta1->property(index), meta2->property(index)))
++            return false;
++    }
++
++    for (index = 0; index < meta1->enumeratorCount(); ++index) {
++        if (!sameEnumerator(meta1->enumerator(index), meta2->enumerator(index)))
++            return false;
++    }
++
++    for (index = 0; index < meta1->classInfoCount(); ++index) {
++        if (QByteArray(meta1->classInfo(index).name()) !=
++            QByteArray(meta2->classInfo(index).name()))
++            return false;
++        if (QByteArray(meta1->classInfo(index).value()) !=
++            QByteArray(meta2->classInfo(index).value()))
++            return false;
++    }
++
++    const QMetaObject **objects1 = 0;
++    const QMetaObject **objects2 = 0;
++    if (meta1->d.data[0] == meta2->d.data[0] && meta1->d.data[0] >= 2) {
++        QMetaObjectExtraData *extra1 = (QMetaObjectExtraData *)(meta1->d.extradata);
++        QMetaObjectExtraData *extra2 = (QMetaObjectExtraData *)(meta2->d.extradata);
++        if (extra1 && !extra2)
++            return false;
++        if (extra2 && !extra1)
++            return false;
++        if (extra1 && extra2) {
++            if (extra1->static_metacall != extra2->static_metacall)
++                return false;
++            //objects1 = extra1->objects;
++            //objects2 = extra1->objects;
++        }
++    } else if (meta1->d.data[0] == meta2->d.data[0] && meta1->d.data[0] == 1) {
++        objects1 = (const QMetaObject **)(meta1->d.extradata);
++        objects2 = (const QMetaObject **)(meta2->d.extradata);
++    }
++    if (objects1 && !objects2)
++        return false;
++    if (objects2 && !objects1)
++        return false;
++    if (objects1 && objects2) {
++        while (*objects1 != 0 && *objects2 != 0) {
++            if (*objects1 != *objects2)
++                return false;
++            ++objects1;
++            ++objects2;
++        }
++    }
++
++    return true;
++}
++
++QTEST_MAIN(tst_QMetaObjectBuilder)
++
++#include "tst_qmetaobjectbuilder_47.moc"
diff --git a/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/gcc-scope.patch b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/gcc-scope.patch
new file mode 100644
index 0000000..f01ee9f
--- /dev/null
+++ b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/gcc-scope.patch
@@ -0,0 +1,48 @@
+
+Fixes issues like below
+
+| qaudiooutput_pulse.cpp: In member function 'bool QPulseAudioOutput::open()':
+| qaudiooutput_pulse.cpp:255:75: error: '::getpid' has not been declared
+| make[3]: *** [../../../build/Debug/qtmedia_pulse/qaudiooutput_pulse.o] Error 1
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+Upstream-Status: Pending
+
+Index: qt-mobility-opensource-src-1.2.0/plugins/multimedia/pulseaudio/qaudiooutput_pulse.cpp
+===================================================================
+--- qt-mobility-opensource-src-1.2.0.orig/plugins/multimedia/pulseaudio/qaudiooutput_pulse.cpp	2012-03-31 07:26:24.457018348 -0700
++++ qt-mobility-opensource-src-1.2.0/plugins/multimedia/pulseaudio/qaudiooutput_pulse.cpp	2012-03-31 07:27:53.309022654 -0700
+@@ -46,7 +46,7 @@
+ #include "qaudiodeviceinfo_pulse.h"
+ #include "qpulseaudioengine.h"
+ #include "qpulsehelpers.h"
+-
++#include <unistd.h>
+ QT_BEGIN_NAMESPACE
+ 
+ const int PeriodTimeMs = 20;
+Index: qt-mobility-opensource-src-1.2.0/plugins/multimedia/pulseaudio/qaudioinput_pulse.cpp
+===================================================================
+--- qt-mobility-opensource-src-1.2.0.orig/plugins/multimedia/pulseaudio/qaudioinput_pulse.cpp	2012-03-31 07:29:19.997026831 -0700
++++ qt-mobility-opensource-src-1.2.0/plugins/multimedia/pulseaudio/qaudioinput_pulse.cpp	2012-03-31 07:29:39.541027625 -0700
+@@ -46,6 +46,7 @@
+ #include "qaudiodeviceinfo_pulse.h"
+ #include "qpulseaudioengine.h"
+ #include "qpulsehelpers.h"
++#include <unistd.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+Index: qt-mobility-opensource-src-1.2.0/plugins/multimedia/pulseaudio/qpulseaudioengine.cpp
+===================================================================
+--- qt-mobility-opensource-src-1.2.0.orig/plugins/multimedia/pulseaudio/qpulseaudioengine.cpp	2012-03-31 07:33:24.805038719 -0700
++++ qt-mobility-opensource-src-1.2.0/plugins/multimedia/pulseaudio/qpulseaudioengine.cpp	2012-03-31 07:33:46.889039783 -0700
+@@ -46,6 +46,7 @@
+ #include "qaudiodeviceinfo_pulse.h"
+ #include "qaudiooutput_pulse.h"
+ #include "qpulsehelpers.h"
++#include <unistd.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
diff --git a/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-configure.patch b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-configure.patch
new file mode 100644
index 0000000..d61ec03
--- /dev/null
+++ b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-configure.patch
@@ -0,0 +1,17 @@
+When building qt-mobility, the qa_configure stage failed because the catalogue /usr/lib
+is used in some Makefiles within configure tests. We manually removed this catalogue.
+
+Upstream-Status: Inappropriate [embedded]
+Signed-off-by: Dmitry Cherukhin <dima_ch@emcraft.com>
+
+--- qt-mobility-opensource-src-1.2.0/configure.orig	2011-05-10 10:06:01.000000000 +0200
++++ qt-mobility-opensource-src-1.2.0/configure	2011-11-08 12:34:56.347645968 +0100
+@@ -583,6 +583,8 @@
+     fi
+ 
+     $QMAKE_EXEC $QMKSPEC "$relpath/config.tests/$2/$2.pro" 2>> "$CONFIG_LOG" >> "$CONFIG_LOG"
++    cp Makefile Makefile.old
++    sed -e 's@-L/usr/lib@@' <Makefile.old >Makefile
+     printf  " ."
+     "$MAKE" clean >> "$CONFIG_LOG"
+     printf "."
diff --git a/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-no-opengl.patch b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-no-opengl.patch
new file mode 100644
index 0000000..1724995
--- /dev/null
+++ b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-no-opengl.patch
@@ -0,0 +1,38 @@
+Upstream-Status: Inappropriate [configuration]
+
+diff --git a/examples/declarative-camera/declarative-camera.pro b/examples/declarative-camera/declarative-camera.pro
+index 8164fbc..54fd8ad 100644
+--- a/examples/declarative-camera/declarative-camera.pro
++++ b/examples/declarative-camera/declarative-camera.pro
+@@ -5,10 +5,10 @@ TEMPLATE=app
+ 
+ QT += declarative network
+ 
+-!maemo5 {
+-    contains(QT_CONFIG, opengl) {
+-        QT += opengl
+-    }
++contains(QT_CONFIG, opengl): !maemo5 {
++   QT += opengl
++} else {
++   DEFINES += QT_NO_OPENGL
+ }
+ 
+ win32 {
+diff --git a/examples/videographicsitem/videographicsitem.pro b/examples/videographicsitem/videographicsitem.pro
+index 8461beb..eedee2f 100644
+--- a/examples/videographicsitem/videographicsitem.pro
++++ b/examples/videographicsitem/videographicsitem.pro
+@@ -9,7 +9,11 @@ MOBILITY = multimedia
+ 
+ QMAKE_RPATHDIR += $$DESTDIR
+ 
+-!symbian:contains(QT_CONFIG, opengl): QT += opengl
++contains(QT_CONFIG, opengl): !symbian {
++   QT += opengl
++} else {
++   DEFINES += QT_NO_OPENGL
++}
+ 
+ HEADERS   += videoplayer.h \
+              videoitem.h
diff --git a/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-no-xvideo.patch b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-no-xvideo.patch
new file mode 100644
index 0000000..6046752
--- /dev/null
+++ b/meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-no-xvideo.patch
@@ -0,0 +1,26 @@
+QMake pro files don't explicitly define QT_NO_XVIDEO if the
+configuration lacks xvideo, but plugins code relies on this define.
+
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+Upstream-Status: Inappropriate [configuration]
+---
+ plugins/multimedia/gstreamer/gstreamer.pro | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/plugins/multimedia/gstreamer/gstreamer.pro b/plugins/multimedia/gstreamer/gstreamer.pro
+--- a/plugins/multimedia/gstreamer/gstreamer.pro
++++ b/plugins/multimedia/gstreamer/gstreamer.pro
+@@ -19,6 +19,10 @@ LIBS += \
+     -lasound
+ }
+ 
++unix:!contains(QT_CONFIG, xvideo) {
++    DEFINES += QT_NO_XVIDEO
++}
++
+ CONFIG += link_pkgconfig
+ 
+ PKGCONFIG += \
+-- 
+1.8.1.2
+
diff --git a/meta-oe/recipes-qt/qt-mobility/qt-mobility-embedded_1.2.0.bb b/meta-oe/recipes-qt/qt-mobility/qt-mobility-embedded_1.2.0.bb
new file mode 100644
index 0000000..998de2a
--- /dev/null
+++ b/meta-oe/recipes-qt/qt-mobility/qt-mobility-embedded_1.2.0.bb
@@ -0,0 +1,11 @@
+SUMMARY = "Mobile device API extensions for Qt/Embedded 4.x"
+DEPENDS = "qt4-embedded"
+SECTION = "libs"
+qtm_embedded := "embedded"
+qtm_dir = "qtopia"
+qtm_glflags := "-=opengl"
+qtm_extra_config := "gstreamer-photography_enabled = no"
+
+inherit qt4e
+require qt-mobility_${PV}.inc
+
diff --git a/meta-oe/recipes-qt/qt-mobility/qt-mobility-x11_1.2.0.bb b/meta-oe/recipes-qt/qt-mobility/qt-mobility-x11_1.2.0.bb
new file mode 100644
index 0000000..e7e4b3c
--- /dev/null
+++ b/meta-oe/recipes-qt/qt-mobility/qt-mobility-x11_1.2.0.bb
@@ -0,0 +1,10 @@
+SUMMARY = "Mobile device API extensions for Qt/X11 4.x"
+DEPENDS = "qt4-x11-free"
+SECTION = "x11/libs"
+qtm_embedded := ""
+qtm_dir = "qt4"
+qtm_glflags := "${@bb.utils.contains('DISTRO_FEATURES', 'opengl', '+=opengl', '-=opengl', d)} "
+qtm_extra_config := ""
+
+inherit qt4x11
+require qt-mobility_${PV}.inc
diff --git a/meta-oe/recipes-qt/qt-mobility/qt-mobility_1.2.0.inc b/meta-oe/recipes-qt/qt-mobility/qt-mobility_1.2.0.inc
new file mode 100644
index 0000000..56631bb
--- /dev/null
+++ b/meta-oe/recipes-qt/qt-mobility/qt-mobility_1.2.0.inc
@@ -0,0 +1,112 @@
+HOMEPAGE = "http://qt-project.org/"
+DEPENDS = "gstreamer util-linux"
+
+inherit bluetooth
+
+PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'pulseaudio', 'pulseaudio', '', d)} \
+                   ${@bb.utils.contains('DISTRO_FEATURES', 'bluetooth', '${BLUEZ}', '', d)}"
+PACKAGECONFIG[bluez4] = ",,bluez4"
+PACKAGECONFIG[pulseaudio] = ",,pulseaudio"
+
+LICENSE = "LGPLv2.1"
+LIC_FILES_CHKSUM = "file://LICENSE.LGPL;md5=fbc093901857fcd118f065f900982c24 \
+		    file://LGPL_EXCEPTION.txt;md5=411080a56ff917a5a1aa08c98acae354"
+
+FILESEXTRAPATHS =. "${FILE_DIRNAME}/qt-mobility-${PV}:"
+SRC_URI = "http://pkgs.fedoraproject.org/repo/pkgs/qt-mobility/qt-mobility-opensource-src-${PV}.tar.gz/ea5db5a8d3dd4709c2926dceda646bd8/qt-mobility-opensource-src-${PV}.tar.gz \
+           file://qt-mobility-configure.patch \
+           file://0001-gstvideoconnector-fixed-buffers-allocation.patch \
+           file://0002-Remove-unnecessary-rpaths-from-qml_device-example.patch \
+           file://qt-mobility-no-opengl.patch \
+           file://gcc-scope.patch \
+           file://qt-mobility-no-xvideo.patch \
+           file://fix_metaobjectbuilder_build_err.patch \
+           file://0001-fix-embedded-usage-doesn-t-work-outside-of-Qt.patch \
+           file://fix-compile-error-no-bluez.patch \
+	   "
+
+SRC_URI[md5sum]="ea5db5a8d3dd4709c2926dceda646bd8"
+SRC_URI[sha256sum]="ee3c88975e04139ac9589f76d4be646d44fcbc4c8c1cf2db621abc154cf0ba44"
+
+PR = "r8"
+
+S = "${WORKDIR}/qt-mobility-opensource-src-${PV}"
+
+qtm_bin		:= "/usr/bin/${qtm_dir}"
+qtm_lib		:= "/usr/lib"
+qtm_include	:= "/usr/include/${qtm_dir}"
+qtm_examples	:= "/usr/bin/${qtm_dir}/examples/QtMobility"
+qtm_demos	:= "/usr/bin/${qtm_dir}/demos/QtMobility"
+qtm_plugins	:= "/usr/lib/${qtm_dir}/plugins/QtMobility"
+qtm_data	:= "/usr/share/${qtm_dir}"
+qtm_imports	:= "/usr/lib/${qtm_dir}/imports"
+
+QTM_MODULES_LIST ?= "bearer contacts gallery location publishsubscribe messaging multimedia \
+systeminfo serviceframework sensors versit organizer feedback connectivity"
+
+do_configure_prepend() {
+	cp qtmobility.pro qtmobility.pro.old
+	sed -e 's@...QT_INSTALL_DATA.@${qtm_data}@' <qtmobility.pro.old >qtmobility.pro
+	for NAME in plugins/declarative/*/*.pro
+	do
+	    cp $NAME $NAME.old
+	    sed -e 's@...QT_INSTALL_IMPORTS.@${qtm_imports}@' <$NAME.old >$NAME
+	done
+	cp staticconfig.pri staticconfig.pri.old
+	echo "include(${STAGING_DATADIR}/${qtm_dir}/mkspecs/qconfig.pri)" >staticconfig.pri
+	cat staticconfig.pri.old >>staticconfig.pri
+
+        cat > features/platformconfig/oe.pri <<EOF
+qmf_enabled = no
+networkmanager_enabled = no
+corewlan_enabled = no
+immersion_enabled = no
+meegotouchfeedback_enabled = no
+maemo-icd_enabled = no
+maemo-icd-network-wlan_enabled = no
+maemo5-contacts_enabled = no
+maemo5-calendar_enabled = no
+maemo6-landmarks_enabled = no
+bme_enabled = no
+bluez_enabled = ${@bb.utils.contains('PACKAGECONFIG', 'bluez4', 'yes', 'no', d)}
+proj_enabled = no
+gstreamer-photography_enabled = no
+gstreamer-appsrc_enabled = yes
+blkid_enabled = yes
+pulseaudio_enabled = ${@bb.utils.contains('PACKAGECONFIG', 'pulseaudio', 'yes', 'no', d)}
+udev_enabled = yes
+iphb_enabled = no
+nfc_symbian_enabled = no
+sensord_enabled = no
+geoclue-master_enabled = no
+gypsy_enabled = no
+${qtm_extra_config}
+EOF
+
+	./configure -qmake-exec qmake2 -prefix /usr -staticconfig oe -examples -demos -modules "${QTM_MODULES_LIST}"
+	echo QT_MOBILITY_BIN = ${qtm_bin} >>./config.pri
+	echo QT_MOBILITY_LIB = ${qtm_lib} >>./config.pri
+	echo QT_MOBILITY_INCLUDE = ${qtm_include} >>./config.pri
+	echo QT_MOBILITY_PLUGINS = ${qtm_plugins} >>./config.pri
+	echo QT_MOBILITY_EXAMPLES = ${qtm_examples} >>./config.pri
+	echo QT_MOBILITY_DEMOS = ${qtm_demos} >>./config.pri
+	echo QT_CONFIG ${qtm_glflags} >>./config.pri
+	echo CONFIG += ${qtm_embedded} >>./config.pri
+}
+
+do_install() {
+	for NAME in */*.prf
+	do
+	    cp $NAME $NAME.old
+	    sed -e 's@/usr@${STAGING_BINDIR}/..@' <$NAME.old >$NAME
+	done
+	oe_runmake install INSTALL_ROOT=${D}
+}
+
+PACKAGES = "${PN}-dbg ${PN} ${PN}-dev"
+
+FILES_${PN}-dbg = "${qtm_bin}/.debug ${qtm_examples}/.debug ${qtm_demos}/.debug \
+                   ${qtm_lib}/.debug ${qtm_plugins}/*/.debug  ${qtm_imports}/*/.debug \
+                   ${qtm_imports}/*/*/.debug ${bindir}/.debug /usr/src/debug"
+FILES_${PN} = "${qtm_bin} ${qtm_examples} ${qtm_demos} ${qtm_lib}/*.so.1* ${qtm_plugins} ${qtm_imports}"
+FILES_${PN}-dev = "${exec_prefix}"
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/4] recipes-multimedia: add gstreamer-0.10 recipes
  2015-05-18 14:12 [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core Alexander Kanavin
  2015-05-18 14:12 ` [PATCH 1/4] python-gst: move it from oe-core to meta-multimedia Alexander Kanavin
  2015-05-18 14:12 ` [PATCH 2/4] recipes-qt: move qt-mobility from oe-core to meta-oe Alexander Kanavin
@ 2015-05-18 14:12 ` Alexander Kanavin
  2015-05-18 14:12 ` [PATCH 4/4] Rename gstreamer directory to gstreamer-0.10 Alexander Kanavin
  2015-05-21 11:06 ` [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core Martin Jansa
  4 siblings, 0 replies; 20+ messages in thread
From: Alexander Kanavin @ 2015-05-18 14:12 UTC (permalink / raw)
  To: openembedded-devel

So that they can be removed from oe-core
https://bugzilla.yoctoproject.org/show_bug.cgi?id=6294

Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com>
---
 .../0001-aacdec-check-channel-count.patch          |   34 +
 .../0001-alac-fix-nb_samples-order-case.patch      |   30 +
 .../0001-alsdec-check-block-length.patch           |   61 +
 ...ac3dec-Check-coding-mode-against-channels.patch |   37 +
 ...util-fix-signedness-in-sizeof-comparissio.patch |   40 +
 ...le-use-av_image_get_linesize-to-calculate.patch |   50 +
 ...c-parser-reset-indexes-on-realloc-failure.patch |   50 +
 ...a-Perform-pointer-advance-and-checks-befo.patch |   81 +
 .../0001-avcodec-smc-fix-off-by-1-error.patch      |   32 +
 ...egtsenc-Check-data-array-size-in-mpegts_w.patch |   69 +
 .../0001-eamad-fix-out-of-array-accesses.patch     |   29 +
 ...-error-concealment-initialize-block-index.patch |   29 +
 ...alment-Check-that-the-picture-is-not-in-a.patch |   37 +
 .../0001-ffserver-set-oformat.patch                |   36 +
 ...t-ref-count-check-and-limit-fix-out-of-ar.patch |   29 +
 ...t-parameters-from-SPS-whenever-it-changes.patch |  145 +
 ...rror-concealment-when-SPS-and-slices-are-.patch |   33 +
 .../0001-h264_sei-Fix-infinite-loop.patch          |   39 +
 ...01-huffyuvdec-Check-init_vlc-return-codes.patch |   87 +
 .../0001-huffyuvdec-Skip-len-0-cases.patch         |   61 +
 ...f-compute-probe-buffer-size-more-reliably.patch |   45 +
 .../0001-mjpegdec-check-SE.patch                   |   32 +
 ...heck-RLE-size-before-copying.-Fix-out-of-.patch |   34 +
 ...er-dont-access-out-of-array-elements-at-t.patch |   44 +
 ...array-index-before-use-fix-out-of-array-a.patch |   30 +
 .../0001-qdm2dec-fix-buffer-overflow.patch         |   58 +
 ...001-roqvideodec-check-dimensions-validity.patch |   36 +
 ...Check-that-the-last-indexes-are-within-th.patch |   32 +
 ...-vp3-Copy-all-3-frames-for-thread-updates.patch |   32 +
 ...-read-for-negative-tokens-and-memleaks-on.patch |  183 +
 ...o-check-chunk-sizes-before-reading-chunks.patch |   51 +
 ...egdec-check-bits-per-pixel-for-changes-si.patch |   68 +
 .../gst-ffmpeg-0.10.13/configure-fix.patch         |   22 +
 .../gst-ffmpeg-CVE-2013-0855.patch                 |  100 +
 .../gst-ffmpeg-CVE-2013-3674.patch                 |   26 +
 .../gst-ffmpeg-0.10.13/h264_qpel_mmx.patch         |   57 +
 .../gstreamer/gst-ffmpeg-0.10.13/libav-9.patch     | 9304 ++++++++++++++++++++
 .../gst-ffmpeg-0.10.13/libav_e500mc.patch          |   21 +
 .../gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch |   19 +
 .../gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff   |   16 +
 .../gstreamer/gst-ffmpeg_0.10.13.bb                |   90 +
 .../gstreamer/gst-fluendo-mp3_0.10.31.bb           |   14 +
 .../gstreamer/gst-fluendo-mpegdemux_0.10.85.bb     |   12 +
 .../recipes-multimedia/gstreamer/gst-fluendo.inc   |   14 +
 .../gstreamer/gst-meta-base_0.10.bb                |   73 +
 .../gstreamer/gst-openmax/gcc_4.6.patch            |   18 +
 .../gstreamer/gst-openmax/ptr-array.patch          |   46 +
 .../gstreamer/gst-openmax_0.10.1.bb                |   35 +
 .../gstreamer/gst-plugins-bad_0.10.23.bb           |   50 +
 ...le-Fix-build-on-x86-if-emmintrin.h-is-ava.patch |   37 +
 .../configure.ac-fix-subparse-plugin.patch         |   27 +
 .../gst-plugins-base-tremor.patch                  |   20 +
 .../gstreamer/gst-plugins-base_0.10.36.bb          |   39 +
 ...-conditional-gl-framebuffer-undefined-use.patch |   35 +
 .../gstreamer/gst-plugins-gl_0.10.3.bb             |   25 +
 ...ild-with-recent-kernels-the-v4l2_buffer-i.patch |   33 +
 ...define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch |   45 +
 .../0407-mulawdec-fix-integer-overrun.patch        |   47 +
 .../gstreamer/gst-plugins-good_0.10.31.bb          |   47 +
 .../gstreamer/gst-plugins-ugly_0.10.19.bb          |   29 +
 .../recipes-multimedia/gstreamer/gst-plugins.inc   |   28 +
 ...ix-self-comparison-always-evaluates-to-tr.patch |   32 +
 .../gstreamer/gstreamer-0.10.36/check_fix.patch    |   19 +
 .../gst-inspect-check-error.patch                  |   16 +
 ...mer-change-priv_gst_parse_yylex-arguments.patch |   33 +
 .../gstreamer-0.10.36/gstregistrybinary.c          |  487 +
 .../gstreamer-0.10.36/gstregistrybinary.h          |  194 +
 .../gstreamer/gstreamer_0.10.36.bb                 |   51 +
 68 files changed, 12815 insertions(+)
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.31.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.85.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo.inc
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb

diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
new file mode 100644
index 0000000..7da0e14
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
@@ -0,0 +1,34 @@
+gst-ffmpeg: aacdec: check channel count
+
+Prevent out of array accesses
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 96f452ac647dae33c53c242ef3266b65a9beafb6)
+
+Upstream-Status: Backport 
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+---
+ libavcodec/aacdec.c |    5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
+index 239153a..6c17c33 100644
+--- a/gst-libs/ext/libav/libavcodec/aacdec.c
++++ b/gst-libs/ext/libav/libavcodec/aacdec.c
+@@ -914,6 +914,11 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
+         }
+     }
+ 
++    if (avctx->channels > MAX_CHANNELS) {
++        av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
++        return AVERROR_INVALIDDATA;
++    }
++
+     AAC_INIT_VLC_STATIC( 0, 304);
+     AAC_INIT_VLC_STATIC( 1, 270);
+     AAC_INIT_VLC_STATIC( 2, 550);
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
new file mode 100644
index 0000000..10ce0f3
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
@@ -0,0 +1,30 @@
+From e0884eadf6a15e93142131b695f48776f9a0ac31 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Sat, 10 Nov 2012 17:14:04 +0100
+Subject: [PATCH] alac: fix nb_samples < order case
+
+Upstream-Status: Backport
+
+Commit e0884eadf6a15e93142131b695f48776f9a0ac31 release/1.0
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit fd4f4923cce6a2cbf4f48640b4ac706e614a1594)
+---
+ libavcodec/alac.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libavcodec/alac.c b/libavcodec/alac.c
+index 9cd1737..e8e844a 100644
+--- a/gst-libs/ext/libav/libavcodec/alac.c
++++ b/gst-libs/ext/libav/libavcodec/alac.c
+@@ -278,7 +278,7 @@ static void predictor_decompress_fir_ada
+ 
+     /* read warm-up samples */
+     if (predictor_coef_num > 0)
+-        for (i = 0; i < predictor_coef_num; i++) {
++        for (i = 0; i < predictor_coef_num && i < output_size; i++) {
+             int32_t val;
+ 
+             val = buffer_out[i] + error_buffer[i+1];
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
new file mode 100644
index 0000000..73980f4
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
@@ -0,0 +1,61 @@
+From 6df0d3e2916c223dbe4262bf1b876dff1cb3f980 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Wed, 12 Dec 2012 12:28:45 +0100
+Subject: [PATCH] alsdec: check block length
+
+Upstream-Status: Backport
+
+Commit 6df0d3e2916c223dbe4262bf1b876dff1cb3f980 release/1.0
+
+Fix writing over the end
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 0ceca269b66ec12a23bf0907bd2c220513cdbf16)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/alsdec.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
+index 46dd0b4..1095b01 100644
+--- a/gst-libs/ext/libav/libavcodec/alsdec.c
++++ b/gst-libs/ext/libav/libavcodec/alsdec.c
+@@ -552,12 +552,15 @@ static void get_block_sizes(ALSDecContext *ctx, unsigned int *div_blocks,
+ 
+ /** Read the block data for a constant block
+  */
+-static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
++static int read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
+ {
+     ALSSpecificConfig *sconf = &ctx->sconf;
+     AVCodecContext *avctx    = ctx->avctx;
+     GetBitContext *gb        = &ctx->gb;
+ 
++    if (bd->block_length <= 0)
++        return -1;
++
+     *bd->raw_samples = 0;
+     *bd->const_block = get_bits1(gb);    // 1 = constant value, 0 = zero block (silence)
+     bd->js_blocks    = get_bits1(gb);
+@@ -572,6 +575,8 @@ static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
+ 
+     // ensure constant block decoding by reusing this field
+     *bd->const_block = 1;
++
++    return 0;
+ }
+ 
+ 
+@@ -971,7 +976,8 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
+         if (read_var_block_data(ctx, bd))
+             return -1;
+     } else {
+-        read_const_block_data(ctx, bd);
++        if (read_const_block_data(ctx, bd) < 0)
++            return -1;
+     }
+ 
+     return 0;
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
new file mode 100644
index 0000000..42cb5f4
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
@@ -0,0 +1,37 @@
+From 2502914c5f8eb77659d7c0868396862557a63245 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Fri, 9 Nov 2012 13:26:20 +0100
+Subject: [PATCH] atrac3dec: Check coding mode against channels.
+
+Upstream-Status: Backport
+
+Commit 2502914c5f8eb77659d7c0868396862557a63245 release/1.0
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 13451f5520ce6b0afde861b2285dda659f8d4fb4)
+
+Conflicts:
+
+	libavcodec/atrac3.c
+---
+ libavcodec/atrac3.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
+index 7d076be..1da4c78 100644
+--- a/gst-libs/ext/libav/libavcodec/atrac3.c
++++ b/gst-libs/ext/libav/libavcodec/atrac3.c
+@@ -955,6 +955,11 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
+     }
+     /* Check the extradata. */
+ 
++    if (q->codingMode == JOINT_STEREO && avctx->channels < 2) {
++        av_log(avctx, AV_LOG_ERROR, "Invalid coding mode\n");
++        return AVERROR_INVALIDDATA;
++    }
++
+     if (q->atrac3version != 4) {
+         av_log(avctx,AV_LOG_ERROR,"Version %d != 4.\n",q->atrac3version);
+         return AVERROR_INVALIDDATA;
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
new file mode 100644
index 0000000..31fa51a
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
@@ -0,0 +1,40 @@
+From a99aff4e4bbef8e64b51f267cd1769214e1b4e80 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Fri, 30 Aug 2013 23:40:47 +0200
+Subject: [PATCH] avcodec/dsputil: fix signedness in sizeof() comparissions
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 454a11a1c9c686c78aa97954306fb63453299760)
+
+Upstream-Status: Backport
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/dsputil.c |    4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
+index 53dc2eb..6264832 100644
+--- a/gst-libs/ext/libav/libavcodec/dsputil.c
++++ b/gst-libs/ext/libav/libavcodec/dsputil.c
+@@ -1912,7 +1912,7 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
+ 
+ static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
+     long i;
+-    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
++    for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
+         long a = *(long*)(src+i);
+         long b = *(long*)(dst+i);
+         *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
+@@ -1937,7 +1937,7 @@ static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
+         }
+     }else
+ #endif
+-    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
++    for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
+         long a = *(long*)(src1+i);
+         long b = *(long*)(src2+i);
+         *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
new file mode 100644
index 0000000..b0a3fb1
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
@@ -0,0 +1,50 @@
+From 573d5fdedae72bf59d8c0b0766fdee171063d36f Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Sun, 16 Feb 2014 23:08:52 +0100
+Subject: [PATCH] avcodec/msrle: use av_image_get_linesize() to calculate the
+ linesize
+
+Upstream-Status: Backport
+
+Commit 573d5fdedae72bf59d8c0b0766fdee171063d36f release/0.9
+
+Fixes out of array access
+Fixes: 14a74a0a2dc67ede543f0e35d834fbbe-asan_heap-oob_49572c_556_cov_215466444_44_001_engine_room.mov
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit c919e1ca2ecfc47d796382973ba0e48b8f6f92a2)
+
+Conflicts:
+
+	libavcodec/msrle.c
+(cherry picked from commit bc1c8ec5e65098fd2ccd8456f667151dfc9cda42)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/msrle.c |    3 ++-
+ 1 files changed, 2 insertions(+), 1 deletions(-)
+
+diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c
+index 30159bb..c39ae7b 100644
+--- a/gst-libs/ext/libav/libavcodec/msrle.c
++++ b/gst-libs/ext/libav/libavcodec/msrle.c
+@@ -35,6 +35,7 @@
+ #include "avcodec.h"
+ #include "dsputil.h"
+ #include "msrledec.h"
++#include "libavutil/imgutils.h"
+ 
+ typedef struct MsrleContext {
+     AVCodecContext *avctx;
+@@ -107,7 +108,7 @@ static int msrle_decode_frame(AVCodecContext *avctx,
+ 
+     /* FIXME how to correctly detect RLE ??? */
+     if (avctx->height * istride == avpkt->size) { /* assume uncompressed */
+-        int linesize = avctx->width * avctx->bits_per_coded_sample / 8;
++        int linesize = av_image_get_linesize(avctx->pix_fmt, avctx->width, 0);
+         uint8_t *ptr = s->frame.data[0];
+         uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
+         int i, j;
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
new file mode 100644
index 0000000..5ff6583
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
@@ -0,0 +1,50 @@
+gst-ffmpeg: avcodec/parser: reset indexes on realloc failure
+
+Fixes Ticket2982
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit f31011e9abfb2ae75bb32bc44e2c34194c8dc40a)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+
+Upstream-Status: Backport 
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+
+---
+ libavcodec/parser.c |   10 +++++++---
+ 1 files changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/parser.c b/libavcodec/parser.c
+index 2c6de6e..66eca06 100644
+--- a/gst-libs/ext/libav/libavcodec/parser.c
++++ b/gst-libs/ext/libav/libavcodec/parser.c
+@@ -241,8 +241,10 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
+     if(next == END_NOT_FOUND){
+         void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
+ 
+-        if(!new_buffer)
++        if(!new_buffer) {
++            pc->index = 0;
+             return AVERROR(ENOMEM);
++        }
+         pc->buffer = new_buffer;
+         memcpy(&pc->buffer[pc->index], *buf, *buf_size);
+         pc->index += *buf_size;
+@@ -255,9 +257,11 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
+     /* append to buffer */
+     if(pc->index){
+         void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
+-
+-        if(!new_buffer)
++        if(!new_buffer) {
++            pc->overread_index =
++            pc->index = 0;
+             return AVERROR(ENOMEM);
++        }
+         pc->buffer = new_buffer;
+         if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
+             memcpy(&pc->buffer[pc->index], *buf,
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
new file mode 100644
index 0000000..7f6eb48
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
@@ -0,0 +1,81 @@
+gst-ffmpeg: avcodec/rpza: Perform pointer advance and checks before
+ using the pointers
+
+Fixes out of array accesses
+Fixes Ticket2850
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 3819db745da2ac7fb3faacb116788c32f4753f34)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+
+Upstream-Status: Backport 
+
+Singed-off-by: Yue Tao <yue.tao@windriver.com>
+
+---
+ libavcodec/rpza.c |    8 ++++----
+ 1 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c
+index 635b406..f291a95 100644
+--- a/gst-libs/ext/libav/libavcodec/rpza.c
++++ b/gst-libs/ext/libav/libavcodec/rpza.c
+@@ -83,7 +83,7 @@ static void rpza_decode_stream(RpzaContext *s)
+     unsigned short *pixels = (unsigned short *)s->frame.data[0];
+ 
+     int row_ptr = 0;
+-    int pixel_ptr = 0;
++    int pixel_ptr = -4;
+     int block_ptr;
+     int pixel_x, pixel_y;
+     int total_blocks;
+@@ -139,6 +139,7 @@ static void rpza_decode_stream(RpzaContext *s)
+             colorA = AV_RB16 (&s->buf[stream_ptr]);
+             stream_ptr += 2;
+             while (n_blocks--) {
++                ADVANCE_BLOCK()
+                 block_ptr = row_ptr + pixel_ptr;
+                 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+                     for (pixel_x = 0; pixel_x < 4; pixel_x++){
+@@ -147,7 +148,6 @@ static void rpza_decode_stream(RpzaContext *s)
+                     }
+                     block_ptr += row_inc;
+                 }
+-                ADVANCE_BLOCK();
+             }
+             break;
+ 
+@@ -184,6 +184,7 @@ static void rpza_decode_stream(RpzaContext *s)
+             color4[2] |= ((21 * ta + 11 * tb) >> 5);
+ 
+             while (n_blocks--) {
++                ADVANCE_BLOCK();
+                 block_ptr = row_ptr + pixel_ptr;
+                 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+                     index = s->buf[stream_ptr++];
+@@ -194,12 +195,12 @@ static void rpza_decode_stream(RpzaContext *s)
+                     }
+                     block_ptr += row_inc;
+                 }
+-                ADVANCE_BLOCK();
+             }
+             break;
+ 
+         /* Fill block with 16 colors */
+         case 0x00:
++            ADVANCE_BLOCK();
+             block_ptr = row_ptr + pixel_ptr;
+             for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+                 for (pixel_x = 0; pixel_x < 4; pixel_x++){
+@@ -213,7 +214,6 @@ static void rpza_decode_stream(RpzaContext *s)
+                 }
+                 block_ptr += row_inc;
+             }
+-            ADVANCE_BLOCK();
+             break;
+ 
+         /* Unknown opcode */
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
new file mode 100644
index 0000000..3ca6fc4
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
@@ -0,0 +1,32 @@
+From c17a0ad1df15a94d0b1239adc2afb593bdf0a153 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Fri, 3 Oct 2014 22:50:45 +0200
+Subject: [PATCH 1/2] avcodec/smc: fix off by 1 error
+
+Upstream-Status: Backport
+
+Fixes out of array access
+Fixes: asan_heap-oob_1685bf0_5_asan_heap-oob_1f35116_430_smc.mov
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/smc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/gst-libs/ext/libav/libavcodec/smc.c b/gst-libs/ext/libav/libavcodec/smc.c
+index 3cd5e53..dec9f71 100644
+--- a/gst-libs/ext/libav/libavcodec/smc.c
++++ b/gst-libs/ext/libav/libavcodec/smc.c
+@@ -69,7 +69,7 @@ typedef struct SmcContext {
+         row_ptr += stride * 4; \
+     } \
+     total_blocks--; \
+-    if (total_blocks < 0) \
++    if (total_blocks < 0 + !!n_blocks) \
+     { \
+         av_log(s->avctx, AV_LOG_INFO, "warning: block counter just went negative (this should not happen)\n"); \
+         return; \
+-- 
+2.1.0
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
new file mode 100644
index 0000000..68bb66e
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
@@ -0,0 +1,69 @@
+From 12770701856a05b6b3cd706f708f8e9a4e8a1336 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Thu, 13 Feb 2014 13:59:51 +0100
+Subject: [PATCH] avformat/mpegtsenc: Check data array size in
+ mpegts_write_pmt()
+
+Upstream-Status: Backport
+
+COmmit 12770701856a05b6b3cd706f708f8e9a4e8a1336 release/0.11
+
+Prevents out of array writes
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 842b6c14bcfc1c5da1a2d288fd65386eb8c158ad)
+
+Conflicts:
+
+	libavformat/mpegtsenc.c
+(cherry picked from commit e87de3f50b765134588d0b048c32ed4b8acc16fb)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavformat/mpegtsenc.c |    9 +++++++--
+ 1 files changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
+index 793e205..a12d19f 100644
+--- a/gst-libs/ext/libav/libavformat/mpegtsenc.c
++++ b/gst-libs/ext/libav/libavformat/mpegtsenc.c
+@@ -240,7 +240,7 @@ static void mpegts_write_pat(AVFormatContext *s)
+                           data, q - data);
+ }
+ 
+-static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
++static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
+ {
+     //    MpegTSWrite *ts = s->priv_data;
+     uint8_t data[1012], *q, *desc_length_ptr, *program_info_length_ptr;
+@@ -293,6 +293,10 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
+             stream_type = STREAM_TYPE_PRIVATE_DATA;
+             break;
+         }
++
++        if (q - data > sizeof(data) - 32)
++            return AVERROR(EINVAL);
++
+         *q++ = stream_type;
+         put16(&q, 0xe000 | ts_st->pid);
+         desc_length_ptr = q;
+@@ -324,7 +328,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
+                 len_ptr = q++;
+                 *len_ptr = 0;
+ 
+-                for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next + 1) {
++                for (p = lang->value; next && *len_ptr < 255 / 4 * 4 && q - data < sizeof(data) - 4; p = next + 1) {
+                     next = strchr(p, ',');
+                     if (strlen(p) != 3 && (!next || next != p + 3))
+                         continue; /* not a 3-letter code */
+@@ -386,6 +390,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
+     }
+     mpegts_write_section1(&service->pmt, PMT_TID, service->sid, 0, 0, 0,
+                           data, q - data);
++    return 0;
+ }
+ 
+ /* NOTE: str == NULL is accepted for an empty string */
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
new file mode 100644
index 0000000..f45e3fd
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
@@ -0,0 +1,29 @@
+From 63ac64864c6e0e84355aa3caa5b92208997a9a8d Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Sat, 17 Nov 2012 16:26:55 +0100
+Subject: [PATCH] eamad: fix out of array accesses
+
+Upstream-Status: Backport
+
+Commit 63ac64864c6e0e84355aa3caa5b92208997a9a8d release/1.1
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/eamad.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c
+index 2805195..e38650e 100644
+--- a/gst-libs/ext/libav/libavcodec/eamad.c
++++ b/gst-libs/ext/libav/libavcodec/eamad.c
+@@ -237,7 +237,7 @@ static int decode_frame(AVCodecContext *avctx,
+     int chunk_type;
+     int inter;
+ 
+-    if (buf_size < 17) {
++    if (buf_size < 26) {
+         av_log(avctx, AV_LOG_ERROR, "Input buffer too small\n");
+         *data_size = 0;
+         return -1;
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
new file mode 100644
index 0000000..e0e4239
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
@@ -0,0 +1,29 @@
+gst-ffmpeg: error concealment: initialize block index.
+
+Fixes CVE-2011-3941 (out of bounds write)
+
+Upstream-Status: Backport 
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/error_resilience.c |    3 +++
+ 1 files changed, 3 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
+index 8bb5d0c..d55c000 100644
+--- a/gst-libs/ext/libav/libavcodec/error_resilience.c
++++ b/gst-libs/ext/libav/libavcodec/error_resilience.c
+@@ -45,6 +45,9 @@ static void decode_mb(MpegEncContext *s, int ref){
+     s->dest[1] = s->current_picture.data[1] + (s->mb_y * (16>>s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16>>s->chroma_x_shift);
+     s->dest[2] = s->current_picture.data[2] + (s->mb_y * (16>>s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16>>s->chroma_x_shift);
+ 
++    ff_init_block_index(s);
++    ff_update_block_index(s);
++
+     if(CONFIG_H264_DECODER && s->codec_id == CODEC_ID_H264){
+         H264Context *h= (void*)s;
+         h->mb_xy= s->mb_x + s->mb_y*s->mb_stride;
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
new file mode 100644
index 0000000..8eef6e9
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
@@ -0,0 +1,37 @@
+gst-ffmpeg: error_concealment: Check that the picture is not in a half
+
+Fixes state becoming inconsistent
+Fixes a null pointer dereference
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 23318a57358358e7a4dc551e830e4503f0638cfe)
+
+Upstream-Status: Backport 
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+
+---
+ libavcodec/error_resilience.c |    6 ++++++
+ 1 files changed, 6 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
+index 01f7424..2b6bc42 100644
+--- a/gst-libs/ext/libav/libavcodec/error_resilience.c
++++ b/gst-libs/ext/libav/libavcodec/error_resilience.c
+@@ -793,6 +793,12 @@ void ff_er_frame_end(MpegEncContext *s){
+        s->picture_structure != PICT_FRAME || // we dont support ER of field pictures yet, though it should not crash if enabled
+        s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return;
+ 
++    if (   s->picture_structure == PICT_FRAME
++        && s->current_picture.linesize[0] != s->current_picture_ptr->linesize[0]) {
++        av_log(s->avctx, AV_LOG_ERROR, "Error concealment not possible, frame not fully initialized\n");
++        return;
++    }
++
+     if(s->current_picture.motion_val[0] == NULL){
+         av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
+ 
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
new file mode 100644
index 0000000..80325db
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
@@ -0,0 +1,36 @@
+gst-ffmpeg: ffserver: set oformat
+
+Fix Ticket1986
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit cbe43e62c9ac7d4aefdc13476f6f691bd626525f)
+
+Upstream-Status: Backport 
+
+---
+ ffserver.c |    4 +++-
+ 1 files changed, 3 insertions(+), 1 deletions(-)
+
+diff --git a/ffserver.c b/ffserver.c
+index 4044d0f..8740140 100644
+--- a/gst-libs/ext/libav/ffserver.c
++++ b/gst-libs/ext/libav/ffserver.c
+@@ -2937,12 +2937,14 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
+ {
+     AVFormatContext *avc;
+     AVStream *avs = NULL;
++    AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
+     int i;
+ 
+     avc =  avformat_alloc_context();
+-    if (avc == NULL) {
++    if (avc == NULL || !rtp_format) {
+         return -1;
+     }
++    avc->oformat = rtp_format;
+     av_dict_set(&avc->metadata, "title",
+                stream->title[0] ? stream->title : "No Title", 0);
+     avc->nb_streams = stream->nb_streams;
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
new file mode 100644
index 0000000..d4f55b2
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
@@ -0,0 +1,29 @@
+From d6c184880ee2e09fd68c0ae217173832cee5afc1 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Sun, 18 Nov 2012 16:29:04 +0100
+Subject: [PATCH] h264: correct ref count check and limit, fix out of array
+ accesses.
+
+Upstream-Status: Backport
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/h264.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libavcodec/h264.c b/libavcodec/h264.c
+index da43f1e..32cede5 100644
+--- a/gst-libs/ext/libav/libavcodec/h264.c
++++ b/gst-libs/ext/libav/libavcodec/h264.c
+@@ -2870,6 +2870,9 @@ static int decode_slice_header(H264Conte
+             h->ref_count[0]= get_ue_golomb(&s->gb) + 1;
+             if(h->slice_type_nos==AV_PICTURE_TYPE_B)
+                 h->ref_count[1]= get_ue_golomb(&s->gb) + 1;
++            else
++                // full range is spec-ok in this case, even for frames
++                h->ref_count[1] = 1;
+ 
+             if(h->ref_count[0]-1 > 32-1 || h->ref_count[1]-1 > 32-1){
+                 av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
new file mode 100644
index 0000000..05a9de3
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
@@ -0,0 +1,145 @@
+gst-ffmpeg: h264: set parameters from SPS whenever it changes
+    
+Fixes a crash in the fuzzed sample sample_varPAR.avi_s26638 with
+alternating bit depths.
+
+Upstream-Status: Backport
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+
+diff --git a/gst-libs/ext/libav/libavcodec/h264.c.old b/gst-libs/ext/libav/libavcodec/h264.c
+index 3621f41..718906a 100644
+--- a/gst-libs/ext/libav/libavcodec/h264.c.old
++++ b/gst-libs/ext/libav/libavcodec/h264.c
+@@ -2491,6 +2491,34 @@ int ff_h264_get_profile(SPS *sps)
+     return profile;
+ }
+ 
++static int h264_set_parameter_from_sps(H264Context *h)
++{
++    MpegEncContext *s = &h->s;
++    AVCodecContext * avctx= s->avctx;
++
++    if (s->flags& CODEC_FLAG_LOW_DELAY ||
++        (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames))
++        s->low_delay=1;
++
++    if(avctx->has_b_frames < 2)
++        avctx->has_b_frames= !s->low_delay;
++
++    if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
++        if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
++            avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
++            h->pixel_shift = h->sps.bit_depth_luma > 8;
++
++            ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
++            ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
++            dsputil_init(&s->dsp, s->avctx);
++        } else {
++            av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
++            return -1;
++        }
++    }
++    return 0;
++}
++
+ /**
+  * decodes a slice header.
+  * This will also call MPV_common_init() and frame_start() as needed.
+@@ -2505,7 +2533,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
+     MpegEncContext * const s0 = &h0->s;
+     unsigned int first_mb_in_slice;
+     unsigned int pps_id;
+-    int num_ref_idx_active_override_flag;
++    int num_ref_idx_active_override_flag, ret;
+     unsigned int slice_type, tmp, i, j;
+     int default_ref_list_done = 0;
+     int last_pic_structure;
+@@ -2569,7 +2597,17 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
+         av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS %u referenced\n", h->pps.sps_id);
+         return -1;
+     }
+-    h->sps = *h0->sps_buffers[h->pps.sps_id];
++
++    if (h->pps.sps_id != h->current_sps_id ||
++        h0->sps_buffers[h->pps.sps_id]->new) {
++        h0->sps_buffers[h->pps.sps_id]->new = 0;
++
++        h->current_sps_id = h->pps.sps_id;
++        h->sps            = *h0->sps_buffers[h->pps.sps_id];
++
++        if ((ret = h264_set_parameter_from_sps(h)) < 0)
++            return ret;
++    }
+ 
+     s->avctx->profile = ff_h264_get_profile(&h->sps);
+     s->avctx->level   = h->sps.level_idc;
+@@ -3811,26 +3811,8 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
+         case NAL_SPS:
+             init_get_bits(&s->gb, ptr, bit_length);
+             ff_h264_decode_seq_parameter_set(h);
+-
+-            if (s->flags& CODEC_FLAG_LOW_DELAY ||
+-                (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames))
+-                s->low_delay=1;
+-
+-            if(avctx->has_b_frames < 2)
+-                avctx->has_b_frames= !s->low_delay;
+-
+-            if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
+-                if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
+-                    avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
+-                    h->pixel_shift = h->sps.bit_depth_luma > 8;
+-
+-                    ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
+-                    ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
+-                    dsputil_init(&s->dsp, s->avctx);
+-                } else {
+-                    av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
+-                    return -1;
+-                }
++            if (h264_set_parameter_from_sps(h) < 0) {
++                return -1;
+             }
+             break;
+         case NAL_PPS:
+diff --git a/gst-libs/ext/libav/libavcodec/h264.h.old b/gst-libs/ext/libav/libavcodec/h264.h
+index e3cc815..b77ad98 100644
+--- a/gst-libs/ext/libav/libavcodec/h264.h.old
++++ b/gst-libs/ext/libav/libavcodec/h264.h
+@@ -202,6 +202,7 @@ typedef struct SPS{
+     int bit_depth_chroma;              ///< bit_depth_chroma_minus8 + 8
+     int residual_color_transform_flag; ///< residual_colour_transform_flag
+     int constraint_set_flags;          ///< constraint_set[0-3]_flag
++    int new;                              ///< flag to keep track if the decoder context needs re-init due to changed SPS
+ }SPS;
+ 
+ /**
+@@ -333,6 +334,7 @@ typedef struct H264Context{
+     int emu_edge_width;
+     int emu_edge_height;
+ 
++    unsigned current_sps_id; ///< id of the current SPS
+     SPS sps; ///< current sps
+ 
+     /**
+diff --git a/gst-libs/ext/libav/libavcodec/h264_ps.c.old b/gst-libs/ext/libav/libavcodec/h264_ps.c
+index 7491807..0929098 100644
+--- a/gst-libs/ext/libav/libavcodec/h264_ps.c.old
++++ b/gst-libs/ext/libav/libavcodec/h264_ps.c
+@@ -438,10 +438,13 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
+                sps->timing_info_present_flag ? sps->time_scale : 0
+                );
+     }
++    sps->new = 1;
+ 
+     av_free(h->sps_buffers[sps_id]);
+-    h->sps_buffers[sps_id]= sps;
+-    h->sps = *sps;
++    h->sps_buffers[sps_id] = sps;
++    h->sps                 = *sps;
++    h->current_sps_id      = sps_id;
++
+     return 0;
+ fail:
+     av_free(sps);
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
new file mode 100644
index 0000000..5d45c1a
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
@@ -0,0 +1,33 @@
+gst-ffmpeg: h264: skip error concealment when SPS and slices are
+ mismatching
+
+Fixes out of array accesses
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 695af8eed642ff0104834495652d1ee784a4c14d)
+
+Upstream-Status: Backport
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+---
+ libavcodec/h264.c |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/libavcodec/h264.c b/libavcodec/h264.c
+index da144db..0aab4e7 100644
+--- a/gst-libs/ext/libav/libavcodec/h264.c
++++ b/gst-libs/ext/libav/libavcodec/h264.c
+@@ -2351,7 +2351,7 @@ static int field_end(H264Context *h, int in_setup)
+      * past end by one (callers fault) and resync_mb_y != 0
+      * causes problems for the first MB line, too.
+      */
+-    if (!FIELD_PICTURE)
++    if (!FIELD_PICTURE && h->current_slice && !h->sps.new)
+         ff_er_frame_end(s);
+ 
+     ff_MPV_frame_end(s);
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
new file mode 100644
index 0000000..1e62b50
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
@@ -0,0 +1,39 @@
+gst-ffmpeg: h264_sei: Fix infinite loop.
+
+Fixsot yet fixed parts of CVE-2011-3946.
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+
+Upstream-Status: Backport 
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+
+---
+ libavcodec/h264_sei.c |    4 ++++
+ 1 files changed, 4 insertions(+), 0 deletions(-)
+
+
+diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
+index 374e53d..80d70e5 100644
+--- a/gst-libs/ext/libav/libavcodec/h264_sei.c
++++ b/gst-libs/ext/libav/libavcodec/h264_sei.c
+@@ -169,11 +169,15 @@ int ff_h264_decode_sei(H264Context *h){
+ 
+         type=0;
+         do{
++            if (get_bits_left(&s->gb) < 8)
++                return -1;
+             type+= show_bits(&s->gb, 8);
+         }while(get_bits(&s->gb, 8) == 255);
+ 
+         size=0;
+         do{
++            if (get_bits_left(&s->gb) < 8)
++                return -1;
+             size+= show_bits(&s->gb, 8);
+         }while(get_bits(&s->gb, 8) == 255);
+ 
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
new file mode 100644
index 0000000..e859e44
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
@@ -0,0 +1,87 @@
+From b666debffec1fcbb19ef377635a53b9a58bca8a4 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Tue, 29 Jan 2013 18:29:41 +0100
+Subject: [PATCH] huffyuvdec: Check init_vlc() return codes.
+
+Upstream-Status: Backport
+
+Commit b666debffec1fcbb19ef377635a53b9a58bca8a4 release/1.0
+
+Prevents out of array writes
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit f67a0d115254461649470452058fa3c28c0df294)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/huffyuv.c | 14 ++++++++++----
+ 1 file changed, 10 insertions(+), 4 deletions(-)
+
+diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
+index 58da789..993e524 100644
+--- a/gst-libs/ext/libav/libavcodec/huffyuv.c
++++ b/gst-libs/ext/libav/libavcodec/huffyuv.c
+@@ -33,6 +33,7 @@
+ #include "put_bits.h"
+ #include "dsputil.h"
+ #include "thread.h"
++#include "libavutil/avassert.h"
+ 
+ #define VLC_BITS 11
+ 
+@@ -287,6 +287,7 @@ static void generate_joint_tables(HYuvCo
+                     int len1 = s->len[p][u];
+                     if (len1 > limit || !len1)
+                         continue;
++                    av_assert0(i < (1 << VLC_BITS));
+                     len[i] = len0 + len1;
+                     bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
+                     symbols[i] = (y<<8) + u;
+@@ -320,6 +321,7 @@ static void generate_joint_tables(HYuvCo
+                     int len2 = s->len[2][r&255];
+                     if (len2 > limit1 || !len2)
+                         continue;
++                    av_assert0(i < (1 << VLC_BITS));
+                     len[i] = len0 + len1 + len2;
+                     bits[i] = (code << len2) + s->bits[2][r&255];
+                     if(s->decorrelate){
+@@ -343,6 +345,7 @@ static void generate_joint_tables(HYuvCo
+ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length){
+     GetBitContext gb;
+     int i;
++    int ret;
+ 
+     init_get_bits(&gb, src, length*8);
+ 
+@@ -353,7 +356,9 @@ static int read_huffman_tables(HYuvConte
+             return -1;
+         }
+         free_vlc(&s->vlc[i]);
+-        init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
++        if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
++                           s->bits[i], 4, 4, 0)) < 0)
++            return ret;
+     }
+ 
+     generate_joint_tables(s);
+@@ -365,6 +370,7 @@ static int read_old_huffman_tables(HYuvC
+ #if 1
+     GetBitContext gb;
+     int i;
++    int ret;
+ 
+     init_get_bits(&gb, classic_shift_luma, sizeof(classic_shift_luma)*8);
+     if(read_len_table(s->len[0], &gb)<0)
+@@ -385,7 +391,9 @@ static int read_old_huffman_tables(HYuvC
+ 
+     for(i=0; i<3; i++){
+         free_vlc(&s->vlc[i]);
+-        init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
++        if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
++                            s->bits[i], 4, 4, 0)) < 0)
++            return ret;
+     }
+ 
+     generate_joint_tables(s);
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
new file mode 100644
index 0000000..94bf4b6
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
@@ -0,0 +1,61 @@
+From db0f7f7394e1f994ed38db043f78ed0f10bde0da Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Tue, 29 Jan 2013 19:22:33 +0100
+Subject: [PATCH] huffyuvdec: Skip len==0 cases
+
+Upstream-Status: Backport
+
+Commit db0f7f7394e1f994ed38db043f78ed0f10bde0da release/1.0
+
+Fixes vlc decoding for hypothetical files that would contain such cases.
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 0dfc01c2bbf4b71bb56201bc4a393321e15d1b31)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/huffyuv.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
+index 993e524..72ed351 100644
+--- a/gst-libs/ext/libav/libavcodec/huffyuv.c
++++ b/gst-libs/ext/libav/libavcodec/huffyuv.c
+@@ -281,11 +281,11 @@ static void generate_joint_tables(HYuvCo
+             for(i=y=0; y<256; y++){
+                 int len0 = s->len[0][y];
+                 int limit = VLC_BITS - len0;
+-                if(limit <= 0)
++                if(limit <= 0 || !len0)
+                     continue;
+                 for(u=0; u<256; u++){
+                     int len1 = s->len[p][u];
+-                    if(len1 > limit)
++                    if (len1 > limit || !len1)
+                         continue;
+                     len[i] = len0 + len1;
+                     bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
+@@ -308,17 +308,17 @@ static void generate_joint_tables(HYuvCo
+         for(i=0, g=-16; g<16; g++){
+             int len0 = s->len[p0][g&255];
+             int limit0 = VLC_BITS - len0;
+-            if(limit0 < 2)
++            if (limit0 < 2 || !len0)
+                 continue;
+             for(b=-16; b<16; b++){
+                 int len1 = s->len[p1][b&255];
+                 int limit1 = limit0 - len1;
+-                if(limit1 < 1)
++                if (limit1 < 1 || !len1)
+                     continue;
+                 code = (s->bits[p0][g&255] << len1) + s->bits[p1][b&255];
+                 for(r=-16; r<16; r++){
+                     int len2 = s->len[2][r&255];
+-                    if(len2 > limit1)
++                    if (len2 > limit1 || !len2)
+                         continue;
+                     len[i] = len0 + len1 + len2;
+                     bits[i] = (code << len2) + s->bits[2][r&255];
+-- 
+1.8.5.2.233.g932f7e4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
new file mode 100644
index 0000000..ea4aa22
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
@@ -0,0 +1,45 @@
+gst-ffmpeg: lavf: compute probe buffer size more reliably.
+
+The previous code computes the offset by reversing the growth
+of the allocated buffer size: it is complex and did lead to
+inconsistencies when the size limit is reached.
+
+Fix trac ticket #1991.
+(cherry picked from commit 03847eb8259291b4ff1bd840bd779d0699d71f96)
+
+Conflicts:
+	libavformat/utils.c
+
+Upstream-Status: Backport
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+
+---
+ libavformat/utils.c |    4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libavformat/utils.c b/libavformat/utils.c
+index 7940037..be73c4a 100644
+--- a/gst-libs/ext/libav/libavformat/utils.c
++++ b/gst-libs/ext/libav/libavformat/utils.c
+@@ -459,7 +459,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
+ {
+     AVProbeData pd = { filename ? filename : "", NULL, -offset };
+     unsigned char *buf = NULL;
+-    int ret = 0, probe_size;
++    int ret = 0, probe_size, buf_offset = 0;
+ 
+     if (!max_probe_size) {
+         max_probe_size = PROBE_BUF_MAX;
+@@ -499,7 +499,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
+             score = 0;
+             ret = 0;            /* error was end of file, nothing read */
+         }
+-        pd.buf_size += ret;
++        pd.buf_size = buf_offset += ret;
+         pd.buf = &buf[offset];
+ 
+         memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
new file mode 100644
index 0000000..d90bafa
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
@@ -0,0 +1,32 @@
+From 1f41cffe1e3e79620f587545bdfcbd7e6e68ed29 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Sun, 11 Nov 2012 00:01:24 +0100
+Subject: [PATCH] mjpegdec: check SE.
+
+Upstream-Status: Backport
+
+Commit 1f41cffe1e3e79620f587545bdfcbd7e6e68ed29 release/1.1
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/mjpegdec.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
+index 6b5266d..0a71a6f 100644
+--- a/gst-libs/ext/libav/libavcodec/mjpegdec.c
++++ b/gst-libs/ext/libav/libavcodec/mjpegdec.c
+@@ -905,6 +905,11 @@ static int mjpeg_decode_scan_progressive
+     int16_t *quant_matrix = s->quant_matrixes[ s->quant_index[c] ];
+     GetBitContext mb_bitmask_gb;
+ 
++    if (se > 63) {
++        av_log(s->avctx, AV_LOG_ERROR, "SE %d is too large\n", se);
++        return AVERROR_INVALIDDATA;
++    }
++
+     if (mb_bitmask) {
+         init_get_bits(&mb_bitmask_gb, mb_bitmask, s->mb_width*s->mb_height);
+     }
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
new file mode 100644
index 0000000..1041347
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
@@ -0,0 +1,34 @@
+From 28bf685bfc6d0c744369cdf367f61a78d80d0b01 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Thu, 15 Nov 2012 16:41:28 +0100
+Subject: [PATCH] pgssubdec: check RLE size before copying. Fix out of array
+ accesses
+
+Upstream-Status: Backport
+
+Commit 28bf685bfc6d0c744369cdf367f61a78d80d0b01 release/1.1
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit c0d68be555f5858703383040e04fcd6529777061)
+---
+ libavcodec/pgssubdec.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
+index 728f178..26a3c2a 100644
+--- a/gst-libs/ext/libav/libavcodec/pgssubdec.c
++++ b/gst-libs/ext/libav/libavcodec/pgssubdec.c
+@@ -202,6 +202,11 @@ static int parse_picture_segment(AVCodec
+         return -1;
+     }
+ 
++    if (buf_size > rle_bitmap_len) {
++        av_log(avctx, AV_LOG_ERROR, "too much RLE data\n");
++        return AVERROR_INVALIDDATA;
++    }
++
+     ctx->picture.w = width;
+     ctx->picture.h = height;
+ 
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
new file mode 100644
index 0000000..1e5fb7d
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
@@ -0,0 +1,44 @@
+gst-ffmpeg: pngdec/filter: dont access out of array elements at the end
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+
+Upstream-Status: Backport 
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+---
+ libavcodec/pngdec.c |   12 ++++--------
+ 1 files changed, 4 insertions(+), 8 deletions(-)
+
+diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
+index 97c0ad1..193e35e 100644
+--- a/gst-libs/ext/libav/libavcodec/pngdec.c
++++ b/gst-libs/ext/libav/libavcodec/pngdec.c
+@@ -190,7 +190,7 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w
+     if(bpp >= 2) g = dst[1];\
+     if(bpp >= 3) b = dst[2];\
+     if(bpp >= 4) a = dst[3];\
+-    for(; i < size; i+=bpp) {\
++    for(; i <= size - bpp; i+=bpp) {\
+         dst[i+0] = r = op(r, src[i+0], last[i+0]);\
+         if(bpp == 1) continue;\
+         dst[i+1] = g = op(g, src[i+1], last[i+1]);\
+@@ -206,13 +206,9 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w
+     else if(bpp == 2) UNROLL1(2, op)\
+     else if(bpp == 3) UNROLL1(3, op)\
+     else if(bpp == 4) UNROLL1(4, op)\
+-    else {\
+-        for (; i < size; i += bpp) {\
+-            int j;\
+-            for (j = 0; j < bpp; j++)\
+-                dst[i+j] = op(dst[i+j-bpp], src[i+j], last[i+j]);\
+-        }\
+-    }
++    for (; i < size; i++) {\
++        dst[i] = op(dst[i-bpp], src[i], last[i]);\
++    }\
+ 
+ /* NOTE: 'dst' can be equal to 'last' */
+ static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
new file mode 100644
index 0000000..8c94232
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
@@ -0,0 +1,30 @@
+gst-ffmpeg: qdm2: check array index before use, fix out of array
+ accesses
+
+Upstream-Status: Backport 
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/qdm2.c |    5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
+index 4cf4b2f..1dfb8d5 100644
+--- a/gst-libs/ext/libav/libavcodec/qdm2.c
++++ b/gst-libs/ext/libav/libavcodec/qdm2.c
+@@ -1257,6 +1257,11 @@ static void qdm2_decode_super_block (QDM2Context *q)
+     for (i = 0; packet_bytes > 0; i++) {
+         int j;
+ 
++        if (i>=FF_ARRAY_ELEMS(q->sub_packet_list_A)) {
++            SAMPLES_NEEDED_2("too many packet bytes");
++            return;
++        }
++
+         q->sub_packet_list_A[i].next = NULL;
+ 
+         if (i > 0) {
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
new file mode 100644
index 0000000..43ffc03
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
@@ -0,0 +1,58 @@
+gst-ffmpeg: qdm2dec: fix buffer overflow. Fixes NGS00144
+
+This also adds a few lines of code from master that are needed for this fix.
+
+Thanks to Phillip for suggestions to improve the patch.
+Found-by: Phillip Langlois
+
+Upstream-Status: Backport 
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/qdm2.c |    9 +++++++--
+ 1 files changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
+index 3aa9e5b..e000df8 100644
+--- a/gst-libs/ext/libav/libavcodec/qdm2.c
++++ b/gst-libs/ext/libav/libavcodec/qdm2.c
+@@ -76,6 +76,7 @@ do { \
+ #define SAMPLES_NEEDED_2(why) \
+      av_log (NULL,AV_LOG_INFO,"This file triggers some missing code. Please contact the developers.\nPosition: %s\n",why);
+ 
++#define QDM2_MAX_FRAME_SIZE 512
+ 
+ typedef int8_t sb_int8_array[2][30][64];
+ 
+@@ -168,7 +169,7 @@ typedef struct {
+     /// I/O data
+     const uint8_t *compressed_data;
+     int compressed_size;
+-    float output_buffer[1024];
++    float output_buffer[QDM2_MAX_FRAME_SIZE * MPA_MAX_CHANNELS * 2];
+ 
+     /// Synthesis filter
+     MPADSPContext mpadsp;
+@@ -1819,6 +1820,9 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
+     s->group_order = av_log2(s->group_size) + 1;
+     s->frame_size = s->group_size / 16; // 16 iterations per super block
+ 
++    if (s->frame_size > QDM2_MAX_FRAME_SIZE)
++        return AVERROR_INVALIDDATA;
++
+     s->sub_sampling = s->fft_order - 7;
+     s->frequency_range = 255 / (1 << (2 - s->sub_sampling));
+ 
+@@ -1887,6 +1891,9 @@ static int qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
+     int ch, i;
+     const int frame_size = (q->frame_size * q->channels);
+ 
++    if((unsigned)frame_size > FF_ARRAY_ELEMS(q->output_buffer)/2)
++        return -1;
++
+     /* select input buffer */
+     q->compressed_data = in;
+     q->compressed_size = q->checksum_size;
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
new file mode 100644
index 0000000..7e58afc
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
@@ -0,0 +1,36 @@
+From 391e0fc6c90ced6656b74f50f3a487b6dc76ea63 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Thu, 29 Nov 2012 15:18:17 +0100
+Subject: [PATCH] roqvideodec: check dimensions validity
+
+Upstream-Status: Backport
+
+Commit 391e0fc6c90ced6656b74f50f3a487b6dc76ea63 release/0.7
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 3ae610451170cd5a28b33950006ff0bd23036845)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/roqvideodec.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c
+index f0977f6..4e34231 100644
+--- a/gst-libs/ext/libav/libavcodec/roqvideodec.c
++++ b/gst-libs/ext/libav/libavcodec/roqvideodec.c
+@@ -157,6 +157,12 @@ static av_cold int roq_decode_init(AVCodecContext *avctx)
+     RoqContext *s = avctx->priv_data;
+ 
+     s->avctx = avctx;
++
++    if (avctx->width%16 || avctx->height%16) {
++         av_log_ask_for_sample(avctx, "dimensions not being a multiple of 16 are unsupported\n");
++         return AVERROR_PATCHWELCOME;
++    }
++
+     s->width = avctx->width;
+     s->height = avctx->height;
+     avcodec_get_frame_defaults(&s->frames[0]);
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
new file mode 100644
index 0000000..15b1614
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
@@ -0,0 +1,32 @@
+gst-ffmpeg: smackerdec: Check that the last indexes are within the
+ table.
+
+Fixes CVE-2011-3944
+
+Upstream-Status: Backport 
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/smacker.c |    5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
+index 30f99b4..2a8bae8 100644
+--- a/gst-libs/ext/libav/libavcodec/smacker.c
++++ b/gst-libs/ext/libav/libavcodec/smacker.c
+@@ -259,6 +259,11 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
+     if(ctx.last[0] == -1) ctx.last[0] = huff.current++;
+     if(ctx.last[1] == -1) ctx.last[1] = huff.current++;
+     if(ctx.last[2] == -1) ctx.last[2] = huff.current++;
++    if(huff.current > huff.length){
++        ctx.last[0] = ctx.last[1] = ctx.last[2] = 1;
++        av_log(smk->avctx, AV_LOG_ERROR, "bigtree damaged\n");
++        return -1;
++    }
+ 
+     *recodes = huff.values;
+ 
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
new file mode 100644
index 0000000..a1989cf
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
@@ -0,0 +1,32 @@
+gst-ffmpeg: vp3: Copy all 3 frames for thread updates.
+
+This fixes a double release of the current frame on deinit.
+Fixes CVE-2011-3934
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+
+Upstream-Status: Backport
+
+Signed-off-by: Yue.Tao <yue.tao@windriver.com>
+
+---
+ libavcodec/vp3.c |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
+index 738ae9f..b5daafc 100644
+--- a/gst-libs/ext/libav/libavcodec/vp3.c
++++ b/gst-libs/ext/libav/libavcodec/vp3.c
+@@ -1859,7 +1859,7 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
+         ||s->width != s1->width
+         ||s->height!= s1->height) {
+         if (s != s1)
+-            copy_fields(s, s1, golden_frame, current_frame);
++            copy_fields(s, s1, golden_frame, keyframe);
+         return -1;
+     }
+ 
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
new file mode 100644
index 0000000..e83d8f4
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
@@ -0,0 +1,183 @@
+gst-ffmpeg: vp3: fix oob read for negative tokens and memleaks on error.
+
+Upstream-Status: Backport 
+
+Signed-off-by: Yue.Tao <yue.tao@windriver.com>
+
+---
+ libavcodec/vp3.c |   59 +++++++++++++++++++++++++++++++++++++++++------------
+ 1 files changed, 45 insertions(+), 14 deletions(-)
+
+diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
+index 36715bb..ce14e63 100644
+--- a/gst-libs/ext/libav/libavcodec/vp3.c
++++ b/gst-libs/ext/libav/libavcodec/vp3.c
+@@ -45,6 +45,7 @@
+ #define FRAGMENT_PIXELS 8
+ 
+ static av_cold int vp3_decode_end(AVCodecContext *avctx);
++static void vp3_decode_flush(AVCodecContext *avctx);
+ 
+ //FIXME split things out into their own arrays
+ typedef struct Vp3Fragment {
+@@ -890,7 +891,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
+             /* decode a VLC into a token */
+             token = get_vlc2(gb, vlc_table, 11, 3);
+             /* use the token to get a zero run, a coefficient, and an eob run */
+-            if (token <= 6) {
++            if ((unsigned) token <= 6U) {
+                 eob_run = eob_run_base[token];
+                 if (eob_run_get_bits[token])
+                     eob_run += get_bits(gb, eob_run_get_bits[token]);
+@@ -908,7 +909,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
+                     coeff_i        += eob_run;
+                     eob_run = 0;
+                 }
+-            } else {
++            } else if (token >= 0) {
+                 bits_to_get = coeff_get_bits[token];
+                 if (bits_to_get)
+                     bits_to_get = get_bits(gb, bits_to_get);
+@@ -942,6 +943,10 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
+                 for (i = coeff_index+1; i <= coeff_index+zero_run; i++)
+                     s->num_coded_frags[plane][i]--;
+                 coeff_i++;
++            } else {
++                av_log(s->avctx, AV_LOG_ERROR,
++                       "Invalid token %d\n", token);
++                return -1;
+             }
+     }
+ 
+@@ -991,6 +996,8 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
+     /* unpack the Y plane DC coefficients */
+     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0,
+         0, residual_eob_run);
++    if (residual_eob_run < 0)
++        return residual_eob_run;
+ 
+     /* reverse prediction of the Y-plane DC coefficients */
+     reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]);
+@@ -998,8 +1005,12 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
+     /* unpack the C plane DC coefficients */
+     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
+         1, residual_eob_run);
++    if (residual_eob_run < 0)
++        return residual_eob_run;
+     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
+         2, residual_eob_run);
++    if (residual_eob_run < 0)
++        return residual_eob_run;
+ 
+     /* reverse prediction of the C-plane DC coefficients */
+     if (!(s->avctx->flags & CODEC_FLAG_GRAY))
+@@ -1036,11 +1047,17 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
+     for (i = 1; i <= 63; i++) {
+             residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i,
+                 0, residual_eob_run);
++            if (residual_eob_run < 0)
++                return residual_eob_run;
+ 
+             residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
+                 1, residual_eob_run);
++            if (residual_eob_run < 0)
++                return residual_eob_run;
+             residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
+                 2, residual_eob_run);
++            if (residual_eob_run < 0)
++                return residual_eob_run;
+     }
+ 
+     return 0;
+@@ -1777,10 +1794,15 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
+     Vp3DecodeContext *s = dst->priv_data, *s1 = src->priv_data;
+     int qps_changed = 0, i, err;
+ 
++#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
++
+     if (!s1->current_frame.data[0]
+         ||s->width != s1->width
+-        ||s->height!= s1->height)
++        ||s->height!= s1->height) {
++        if (s != s1)
++            copy_fields(s, s1, golden_frame, current_frame);
+         return -1;
++    }
+ 
+     if (s != s1) {
+         // init tables if the first frame hasn't been decoded
+@@ -1796,8 +1818,6 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
+             memcpy(s->motion_val[1], s1->motion_val[1], c_fragment_count * sizeof(*s->motion_val[1]));
+         }
+ 
+-#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
+-
+         // copy previous frame data
+         copy_fields(s, s1, golden_frame, dsp);
+ 
+@@ -1987,9 +2007,6 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
+     Vp3DecodeContext *s = avctx->priv_data;
+     int i;
+ 
+-    if (avctx->is_copy && !s->current_frame.data[0])
+-        return 0;
+-
+     av_free(s->superblock_coding);
+     av_free(s->all_fragments);
+     av_free(s->coded_fragment_list[0]);
+@@ -2016,12 +2033,7 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
+     free_vlc(&s->motion_vector_vlc);
+ 
+     /* release all frames */
+-    if (s->golden_frame.data[0])
+-        ff_thread_release_buffer(avctx, &s->golden_frame);
+-    if (s->last_frame.data[0] && s->last_frame.type != FF_BUFFER_TYPE_COPY)
+-        ff_thread_release_buffer(avctx, &s->last_frame);
+-    /* no need to release the current_frame since it will always be pointing
+-     * to the same frame as either the golden or last frame */
++    vp3_decode_flush(avctx);
+ 
+     return 0;
+ }
+@@ -2341,6 +2353,23 @@ static void vp3_decode_flush(AVCodecContext *avctx)
+         ff_thread_release_buffer(avctx, &s->current_frame);
+ }
+ 
++static int vp3_init_thread_copy(AVCodecContext *avctx)
++{
++    Vp3DecodeContext *s = avctx->priv_data;
++
++    s->superblock_coding      = NULL;
++    s->all_fragments          = NULL;
++    s->coded_fragment_list[0] = NULL;
++    s->dct_tokens_base        = NULL;
++    s->superblock_fragments   = NULL;
++    s->macroblock_coding      = NULL;
++    s->motion_val[0]          = NULL;
++    s->motion_val[1]          = NULL;
++    s->edge_emu_buffer        = NULL;
++
++    return 0;
++}
++
+ AVCodec ff_theora_decoder = {
+     .name           = "theora",
+     .type           = AVMEDIA_TYPE_VIDEO,
+@@ -2352,6 +2381,7 @@ AVCodec ff_theora_decoder = {
+     .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
+     .flush = vp3_decode_flush,
+     .long_name = NULL_IF_CONFIG_SMALL("Theora"),
++    .init_thread_copy      = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
+     .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
+ };
+ #endif
+@@ -2367,5 +2397,6 @@ AVCodec ff_vp3_decoder = {
+     .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
+     .flush = vp3_decode_flush,
+     .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"),
++    .init_thread_copy      = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
+     .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
+ };
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
new file mode 100644
index 0000000..7e4f682
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
@@ -0,0 +1,51 @@
+From 2cac35086c9e103fa98960c546d5017e7363803a Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Fri, 25 Jan 2013 06:11:59 +0100
+Subject: [PATCH] vqavideo: check chunk sizes before reading chunks
+
+Upstream-Status: Backport
+
+Commit 2cac35086c9e103fa98960c546d5017e7363803a release/0.7
+
+Fixes out of array writes
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit ab6c9332bfa1e20127a16392a0b85a4aa4840889)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/vqavideo.c |   10 ++++++++++
+ 1 files changed, 10 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
+index d1eab5b..6e1ce6c 100644
+--- a/gst-libs/ext/libav/libavcodec/vqavideo.c
++++ b/gst-libs/ext/libav/libavcodec/vqavideo.c
+@@ -527,6 +527,11 @@ static void vqa_decode_chunk(VqaContext *s)
+         chunk_size = AV_RB32(&s->buf[cbp0_chunk + 4]);
+         cbp0_chunk += CHUNK_PREAMBLE_SIZE;
+ 
++        if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
++            av_log(s->avctx, AV_LOG_ERROR, "cbp0 chunk too large (0x%X bytes)\n", chunk_size);
++            return AVERROR_INVALIDDATA;
++        }
++
+         /* accumulate partial codebook */
+         memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
+             &s->buf[cbp0_chunk], chunk_size);
+@@ -550,6 +555,11 @@ static void vqa_decode_chunk(VqaContext *s)
+         chunk_size = AV_RB32(&s->buf[cbpz_chunk + 4]);
+         cbpz_chunk += CHUNK_PREAMBLE_SIZE;
+ 
++        if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
++            av_log(s->avctx, AV_LOG_ERROR, "cbpz chunk too large (0x%X bytes)\n", chunk_size);
++            return AVERROR_INVALIDDATA;
++        }
++
+         /* accumulate partial codebook */
+         memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
+             &s->buf[cbpz_chunk], chunk_size);
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
new file mode 100644
index 0000000..c8bafd5
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
@@ -0,0 +1,68 @@
+From 6043c431c97d55173f339fafbd033d3c0642e2e9 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Fri, 3 Oct 2014 01:50:27 +0200
+Subject: [PATCH 2/2] avcodec/mjpegdec: check bits per pixel for changes
+ similar to dimensions
+
+Upstream-Status: Backport
+
+Fixes out of array accesses
+Fixes: asan_heap-oob_16668e9_2_asan_heap-oob_16668e9_346_miss_congeniality_pegasus_mjpg.avi
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+
+Conflicts:
+	libavcodec/mjpegdec.c
+---
+ libavcodec/mjpegdec.c | 15 ++++++++-------
+ 1 file changed, 8 insertions(+), 7 deletions(-)
+
+diff --git a/gst-libs/ext/libav/libavcodec/mjpegdec.c b/gst-libs/ext/libav/libavcodec/mjpegdec.c
+index 84343c0..c0137d8 100644
+--- a/gst-libs/ext/libav/libavcodec/mjpegdec.c
++++ b/gst-libs/ext/libav/libavcodec/mjpegdec.c
+@@ -210,16 +210,16 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
+ 
+ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
+ {
+-    int len, nb_components, i, width, height, pix_fmt_id;
++    int len, nb_components, i, bits, width, height, pix_fmt_id;
+ 
+     /* XXX: verify len field validity */
+     len = get_bits(&s->gb, 16);
+-    s->bits= get_bits(&s->gb, 8);
++    bits= get_bits(&s->gb, 8);
+ 
+-    if(s->pegasus_rct) s->bits=9;
+-    if(s->bits==9 && !s->pegasus_rct) s->rct=1;    //FIXME ugly
++    if(s->pegasus_rct) bits=9;
++    if(bits==9 && !s->pegasus_rct) s->rct=1;    //FIXME ugly
+ 
+-    if (s->bits != 8 && !s->lossless){
++    if (bits != 8 && !s->lossless){
+         av_log(s->avctx, AV_LOG_ERROR, "only 8 bits/component accepted\n");
+         return -1;
+     }
+@@ -239,7 +239,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
+     if (nb_components <= 0 ||
+         nb_components > MAX_COMPONENTS)
+         return -1;
+-    if (s->ls && !(s->bits <= 8 || nb_components == 1)){
++    if (s->ls && !(bits <= 8 || nb_components == 1)){
+         av_log(s->avctx, AV_LOG_ERROR, "only <= 8 bits/component or 16-bit gray accepted for JPEG-LS\n");
+         return -1;
+     }
+@@ -272,10 +272,11 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
+ 
+     /* if different size, realloc/alloc picture */
+     /* XXX: also check h_count and v_count */
+-    if (width != s->width || height != s->height) {
++    if (width != s->width || height != s->height || bits != s->bits) {
+         av_freep(&s->qscale_table);
+ 
+         s->width = width;
++        s->bits= bits;
+         s->height = height;
+         s->interlaced = 0;
+ 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch
new file mode 100644
index 0000000..9ef6f7c
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch
@@ -0,0 +1,22 @@
+Disable yasm for libav when --disable-yasm
+
+Upstream-Status: Inappropriate [configuration]
+
+Signed-off-by: Shane Wang <shane.wang@intel.com>
+
+diff -r f2f8f74c6e30 configure.ac
+--- a/configure.ac	Thu Dec 22 23:56:09 2011 +0800
++++ b/configure.ac	Thu Dec 22 23:57:37 2011 +0800
+@@ -325,6 +325,12 @@
+         --enable-gpl"
+   fi
+ 
++ AC_ARG_ENABLE(yasm,
++              [AC_HELP_STRING([--disable-yasm], [disable use of yasm assembler])])
++  if test "x$enable_yasm" = "xno"; then
++    embffmpeg_configure_args="$embffmpeg_configure_args --disable-yasm"
++  fi
++
+   # if we are cross-compiling, tell ffmpeg so
+   target_os=`echo $host_os | sed 's/-gnu//'`
+   if test "x$cross_compiling" = xyes; then
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
new file mode 100644
index 0000000..3c8d8e3
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
@@ -0,0 +1,100 @@
+gst-ffmpeg: Security Advisory - ffmpeg - CVE-2013-0855
+
+Upstream-Status: Backport 
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+
+diff --git a/gst-libs/ext/libav/libavcodec/alac.c.old b/gst-libs/ext/libav/libavcodec/alac.c
+index 2a0df8c..bcbd56d 100644
+--- a/gst-libs/ext/libav/libavcodec/alac.c.old
++++ b/gst-libs/ext/libav/libavcodec/alac.c
+@@ -87,18 +87,44 @@ typedef struct {
+     int wasted_bits;
+ } ALACContext;
+ 
+-static void allocate_buffers(ALACContext *alac)
++static av_cold int alac_decode_close(AVCodecContext *avctx)
++{
++    ALACContext *alac = avctx->priv_data;
++
++    int chan;
++    for (chan = 0; chan < MAX_CHANNELS; chan++) {
++        av_freep(&alac->predicterror_buffer[chan]);
++        av_freep(&alac->outputsamples_buffer[chan]);
++        av_freep(&alac->wasted_bits_buffer[chan]);
++    }
++
++    return 0;
++}
++
++static int allocate_buffers(ALACContext *alac)
+ {
+     int chan;
++    int buf_size;
++
++    if (alac->setinfo_max_samples_per_frame > INT_MAX / sizeof(int32_t))
++        goto buf_alloc_fail;
++    buf_size = alac->setinfo_max_samples_per_frame * sizeof(int32_t);
++
+     for (chan = 0; chan < MAX_CHANNELS; chan++) {
+-        alac->predicterror_buffer[chan] =
+-            av_malloc(alac->setinfo_max_samples_per_frame * 4);
+ 
+-        alac->outputsamples_buffer[chan] =
+-            av_malloc(alac->setinfo_max_samples_per_frame * 4);
++        FF_ALLOC_OR_GOTO(alac->avctx, alac->predicterror_buffer[chan],
++                         buf_size, buf_alloc_fail);
+ 
+-        alac->wasted_bits_buffer[chan] = av_malloc(alac->setinfo_max_samples_per_frame * 4);
++        FF_ALLOC_OR_GOTO(alac->avctx, alac->outputsamples_buffer[chan],
++                         buf_size, buf_alloc_fail);
++
++        FF_ALLOC_OR_GOTO(alac->avctx, alac->wasted_bits_buffer[chan],
++                         buf_size, buf_alloc_fail);
+     }
++    return 0;
++buf_alloc_fail:
++    alac_decode_close(alac->avctx);
++    return AVERROR(ENOMEM);
+ }
+ 
+ static int alac_set_info(ALACContext *alac)
+@@ -131,8 +157,6 @@ static int alac_set_info(ALACContext *alac)
+     bytestream_get_be32(&ptr);      /* bitrate ? */
+     bytestream_get_be32(&ptr);      /* samplerate */
+ 
+-    allocate_buffers(alac);
+-
+     return 0;
+ }
+ 
+@@ -659,6 +683,7 @@ static int alac_decode_frame(AVCodecContext *avctx,
+ 
+ static av_cold int alac_decode_init(AVCodecContext * avctx)
+ {
++    int ret;
+     ALACContext *alac = avctx->priv_data;
+     alac->avctx = avctx;
+     alac->numchannels = alac->avctx->channels;
+@@ -674,18 +699,9 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
+         return -1;
+     }
+ 
+-    return 0;
+-}
+-
+-static av_cold int alac_decode_close(AVCodecContext *avctx)
+-{
+-    ALACContext *alac = avctx->priv_data;
+-
+-    int chan;
+-    for (chan = 0; chan < MAX_CHANNELS; chan++) {
+-        av_freep(&alac->predicterror_buffer[chan]);
+-        av_freep(&alac->outputsamples_buffer[chan]);
+-        av_freep(&alac->wasted_bits_buffer[chan]);
++    if ((ret = allocate_buffers(alac)) < 0) {
++        av_log(avctx, AV_LOG_ERROR, "Error allocating buffers\n");
++        return ret;
+     }
+ 
+     return 0;
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
new file mode 100644
index 0000000..aa385f5
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
@@ -0,0 +1,26 @@
+avcodec/cdgraphics: check buffer size before use
+
+Fixes out of array accesses
+
+Backported from:http://git.videolan.org/?p=ffmpeg.git;a=commit;h=ad002e1a13a8df934bd6cb2c84175a4780ab8942
+
+Upstream-Status: Backport
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+Signed-off-by: Ming Liu <ming.liu@windriver.com>
+
+diff -urpN a/gst-libs/ext/libav/libavcodec/cdgraphics.c b/gst-libs/ext/libav/libavcodec/cdgraphics.c
+--- a/gst-libs/ext/libav/libavcodec/cdgraphics.c	2013-07-18 13:17:08.399876575 +0800
++++ b/gst-libs/ext/libav/libavcodec/cdgraphics.c	2013-07-18 13:18:05.880502267 +0800
+@@ -291,7 +291,9 @@ static int cdg_decode_frame(AVCodecConte
+     inst    = bytestream_get_byte(&buf);
+     inst    &= CDG_MASK;
+     buf += 2;  /// skipping 2 unneeded bytes
+-    bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
++
++    if (buf_size > CDG_HEADER_SIZE)
++        bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
+ 
+     if ((command & CDG_MASK) == CDG_COMMAND) {
+         switch (inst) {
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
new file mode 100644
index 0000000..ade24dc
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
@@ -0,0 +1,57 @@
+Backport http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=5f654897e325349dacf2546674e0510bb72ecb50;hp=250cebeb3b348c3da71f9972eb500d6005dc01f1
+
+Fixes these errors on x86
+
+libavcodec/x86/h264_qpel_mmx.c: Assembler messages:
+libavcodec/x86/h264_qpel_mmx.c:1294: Error: operand type mismatch for `cmp'
+libavcodec/x86/h264_qpel_mmx.c:1294: Error: operand type mismatch for `cmp'
+libavcodec/x86/h264_qpel_mmx.c:1298: Error: operand type mismatch for `cmp'
+libavcodec/x86/h264_qpel_mmx.c:1298: Error: operand type mismatch for `cmp'
+libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
+libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
+libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
+make[5]: *** [libavcodec/x86/dsputil_mmx.o] Error 1
+
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Upstream-Status: Backport
+Index: gst-ffmpeg-0.10.13/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c
+===================================================================
+--- gst-ffmpeg-0.10.13.orig/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c	2012-03-30 11:39:41.324522051 -0700
++++ gst-ffmpeg-0.10.13/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c	2012-03-30 11:54:08.152564075 -0700
+@@ -398,7 +398,7 @@
+             "2:                         \n\t"\
+             \
+             : "+a"(src), "+c"(dst)\
+-            : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\
++            : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "rm"(h)\
+             : "memory"\
+         );\
+         src += 4-(h+5)*srcStride;\
+@@ -446,7 +446,7 @@
+             QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 15*48)\
+             "2:                     \n\t"\
+             : "+a"(src)\
+-            : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)\
++            : "c"(tmp), "S"((x86_reg)srcStride), "rm"(size)\
+             : "memory"\
+             );\
+         tmp += 4;\
+@@ -823,7 +823,7 @@
+         "2:                          \n\t"\
+         \
+         : "+a"(src), "+c"(dst)\
+-        : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\
++        : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "rm"(h)\
+         : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
+                        "%xmm4", "%xmm5", "%xmm6", "%xmm7",)\
+           "memory"\
+@@ -878,7 +878,7 @@
+             QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 15*48)
+             "2:                         \n\t"
+             : "+a"(src)
+-            : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)
++            : "c"(tmp), "S"((x86_reg)srcStride), "rm"(size)
+             : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3",
+                            "%xmm4", "%xmm5", "%xmm6", "%xmm7",)
+               "memory"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch
new file mode 100644
index 0000000..1860752
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch
@@ -0,0 +1,9304 @@
+Taken from gentoo patchset:
+http://dev.gentoo.org/~tetromino/distfiles/gst-plugins-ffmpeg/gst-ffmpeg-0.10.13_p2012.11-libav-9-patches.tar.xz
+
+Upstream-Status: Pending
+
+Contains following changes, rebased to apply on top of our changes
+0002-Fix-includes-for-systemwide-build.patch
+0003-libav-Switch-to-non-deprecated-symbols.patch
+0005-av-Update-for-some-constant-changes.patch
+0006-av-Remove-palette-support-for-now.patch
+0007-av-Port-remaining-simple-bits.patch
+0008-av-Use-av_codec_is_-en-de-coder-API-instead-of-priva.patch
+0009-avprotocol-Port-from-the-URL-protocol-handler-to-san.patch
+0010-avdec-don-t-wait-for-keyframe.patch
+
+Following changes were skipped:
+0001-Partially-revert-commit-0300801b.patch
+0004-av-update-to-use-AVOption-variants.patch
+0011-av_get_bits_per_sample_format-was-removed-in-libav-9.patch
+
+Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
+
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.c	2011-10-31 11:14:03.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.c	2014-08-08 15:26:07.872857555 +0200
+@@ -151,9 +151,6 @@
+ #endif
+   gst_ffmpegaudioresample_register (plugin);
+ 
+-  av_register_protocol2 (&gstreamer_protocol, sizeof (URLProtocol));
+-  av_register_protocol2 (&gstpipe_protocol, sizeof (URLProtocol));
+-
+   /* Now we can return the pointer to the newly created Plugin object. */
+   return TRUE;
+ }
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.h gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.h
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.h	2011-05-17 10:53:16.000000000 +0200
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.h	2014-08-08 15:26:07.872857555 +0200
+@@ -58,10 +58,13 @@
+ int gst_ffmpeg_avcodec_close (AVCodecContext *avctx);
+ int gst_ffmpeg_av_find_stream_info(AVFormatContext *ic);
+ 
+-G_END_DECLS
++int gst_ffmpegdata_open (GstPad * pad, int flags, AVIOContext ** context);
++int gst_ffmpegdata_close (AVIOContext * h);
++typedef struct _GstFFMpegPipe GstFFMpegPipe;
++int gst_ffmpeg_pipe_open (GstFFMpegPipe *ffpipe, int flags, AVIOContext ** context);
++int gst_ffmpeg_pipe_close (AVIOContext * h);
+ 
+-extern URLProtocol gstreamer_protocol;
+-extern URLProtocol gstpipe_protocol;
++G_END_DECLS
+ 
+ /* use GST_FFMPEG URL_STREAMHEADER with URL_WRONLY if the first
+  * buffer should be used as streamheader property on the pad's caps. */
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcfg.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcfg.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcfg.c	2011-07-12 16:35:27.000000000 +0200
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcfg.c	2014-08-08 15:24:17.899853612 +0200
+@@ -147,7 +147,6 @@
+       {FF_DCT_FASTINT, "Fast Integer", "fastint"},
+       {FF_DCT_INT, "Accurate Integer", "int"},
+       {FF_DCT_MMX, "MMX", "mmx"},
+-      {FF_DCT_MLIB, "MLIB", "mlib"},
+       {FF_DCT_ALTIVEC, "ALTIVEC", "altivec"},
+       {FF_DCT_FAAN, "FAAN", "faan"},
+       {0, NULL, NULL},
+@@ -173,8 +172,6 @@
+       {FF_IDCT_SIMPLE, "Simple", "simple"},
+       {FF_IDCT_SIMPLEMMX, "Simple MMX", "simplemmx"},
+       {FF_IDCT_LIBMPEG2MMX, "LIBMPEG2MMX", "libmpeg2mmx"},
+-      {FF_IDCT_PS2, "PS2", "ps2"},
+-      {FF_IDCT_MLIB, "MLIB", "mlib"},
+       {FF_IDCT_ARM, "ARM", "arm"},
+       {FF_IDCT_ALTIVEC, "ALTIVEC", "altivec"},
+       {FF_IDCT_SH4, "SH4", "sh4"},
+@@ -263,16 +260,11 @@
+ 
+   if (!ffmpeg_flags_type) {
+     static const GFlagsValue ffmpeg_flags[] = {
+-      {CODEC_FLAG_OBMC, "Use overlapped block motion compensation (h263+)",
+-          "obmc"},
+       {CODEC_FLAG_QSCALE, "Use fixed qscale", "qscale"},
+       {CODEC_FLAG_4MV, "Allow 4 MV per MB", "4mv"},
+-      {CODEC_FLAG_H263P_AIV, "H.263 alternative inter VLC", "aiv"},
+       {CODEC_FLAG_QPEL, "Quartel Pel Motion Compensation", "qpel"},
+       {CODEC_FLAG_GMC, "GMC", "gmc"},
+       {CODEC_FLAG_MV0, "Always try a MB with MV (0,0)", "mv0"},
+-      {CODEC_FLAG_PART,
+-          "Store MV, DC and AC coefficients in seperate partitions", "part"},
+       {CODEC_FLAG_LOOP_FILTER, "Loop filter", "loop-filter"},
+       {CODEC_FLAG_GRAY, "Only decode/encode grayscale", "gray"},
+       {CODEC_FLAG_NORMALIZE_AQP,
+@@ -282,13 +274,9 @@
+           "global-headers"},
+       {CODEC_FLAG_AC_PRED, "H263 Advanced Intra Coding / MPEG4 AC prediction",
+           "aic"},
+-      {CODEC_FLAG_H263P_UMV, "Unlimited Motion Vector", "umv"},
+       {CODEC_FLAG_CBP_RD, "Rate Distoration Optimization for CBP", "cbp-rd"},
+       {CODEC_FLAG_QP_RD, "Rate Distoration Optimization for QP selection",
+           "qp-rd"},
+-      {CODEC_FLAG_H263P_SLICE_STRUCT, "H263 slice struct", "ss"},
+-      {CODEC_FLAG_SVCD_SCAN_OFFSET,
+-          "Reserve space for SVCD scan offset user data", "scanoffset"},
+       {CODEC_FLAG_CLOSED_GOP, "Closed GOP", "closedgop"},
+       {0, NULL, NULL},
+     };
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c	2011-10-31 11:14:03.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c	2014-08-08 15:31:30.968869139 +0200
+@@ -25,8 +25,10 @@
+ #include <gst/gst.h>
+ #ifdef HAVE_FFMPEG_UNINSTALLED
+ #include <avcodec.h>
++#include <channel_layout.h>
+ #else
+ #include <libavcodec/avcodec.h>
++#include <libavutil/channel_layout.h>
+ #endif
+ #include <string.h>
+ 
+@@ -35,43 +37,6 @@
+ 
+ #include <gst/pbutils/codec-utils.h>
+ 
+-/*
+- * Read a palette from a caps.
+- */
+-
+-static void
+-gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
+-{
+-  GstStructure *str = gst_caps_get_structure (caps, 0);
+-  const GValue *palette_v;
+-  const GstBuffer *palette;
+-
+-  /* do we have a palette? */
+-  if ((palette_v = gst_structure_get_value (str, "palette_data")) && context) {
+-    palette = gst_value_get_buffer (palette_v);
+-    if (GST_BUFFER_SIZE (palette) >= AVPALETTE_SIZE) {
+-      if (context->palctrl)
+-        av_free (context->palctrl);
+-      context->palctrl = av_malloc (sizeof (AVPaletteControl));
+-      context->palctrl->palette_changed = 1;
+-      memcpy (context->palctrl->palette, GST_BUFFER_DATA (palette),
+-          AVPALETTE_SIZE);
+-    }
+-  }
+-}
+-
+-static void
+-gst_ffmpeg_set_palette (GstCaps * caps, AVCodecContext * context)
+-{
+-  if (context->palctrl) {
+-    GstBuffer *palette = gst_buffer_new_and_alloc (AVPALETTE_SIZE);
+-
+-    memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
+-        AVPALETTE_SIZE);
+-    gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, palette, NULL);
+-  }
+-}
+-
+ /* IMPORTANT: Keep this sorted by the ffmpeg channel masks */
+ static const struct
+ {
+@@ -79,26 +44,26 @@
+   GstAudioChannelPosition gst;
+ } _ff_to_gst_layout[] = {
+   {
+-  CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
+-  CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
+-  CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
+-  CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
+-  CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
+-  CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
+-  CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
+-  CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
+-  CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
+-  CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
+-  CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
+-  CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+-  CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+-  CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+-  CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+-  CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+-  CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+-  CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+-  CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
+-  CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
++  AV_CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
++  AV_CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
++  AV_CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
++  AV_CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
++  AV_CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
++  AV_CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
++  AV_CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
++  AV_CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
++  AV_CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
++  AV_CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
++  AV_CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
++  AV_CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
++  AV_CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
+ };
+ 
+ static GstAudioChannelPosition *
+@@ -342,8 +307,8 @@
+ 
+     if (channel_layout == 0) {
+       const guint64 default_channel_set[] = {
+-        0, 0, CH_LAYOUT_SURROUND, CH_LAYOUT_QUAD, CH_LAYOUT_5POINT0,
+-        CH_LAYOUT_5POINT1, 0, CH_LAYOUT_7POINT1
++        0, 0, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_5POINT0,
++        AV_CH_LAYOUT_5POINT1, 0, AV_CH_LAYOUT_7POINT1
+       };
+ 
+       switch (codec_id) {
+@@ -1267,8 +1232,6 @@
+     case CODEC_ID_FLIC:
+     case CODEC_ID_VMDVIDEO:
+     case CODEC_ID_VMDAUDIO:
+-    case CODEC_ID_SONIC:
+-    case CODEC_ID_SONIC_LS:
+     case CODEC_ID_SNOW:
+     case CODEC_ID_VIXL:
+     case CODEC_ID_QPEG:
+@@ -1689,11 +1652,6 @@
+       gst_buffer_unref (data);
+     }
+ 
+-    /* palette */
+-    if (context) {
+-      gst_ffmpeg_set_palette (caps, context);
+-    }
+-
+     GST_LOG ("caps for codec_id=%d: %" GST_PTR_FORMAT, codec_id, caps);
+ 
+   } else {
+@@ -1830,9 +1788,6 @@
+             "bpp", G_TYPE_INT, bpp,
+             "depth", G_TYPE_INT, depth,
+             "endianness", G_TYPE_INT, endianness, NULL);
+-        if (caps && context) {
+-          gst_ffmpeg_set_palette (caps, context);
+-        }
+       }
+     } else if (fmt) {
+       caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-yuv",
+@@ -1857,7 +1812,7 @@
+  */
+ 
+ static GstCaps *
+-gst_ffmpeg_smpfmt_to_caps (enum SampleFormat sample_fmt,
++gst_ffmpeg_smpfmt_to_caps (enum AVSampleFormat sample_fmt,
+     AVCodecContext * context, enum CodecID codec_id)
+ {
+   GstCaps *caps = NULL;
+@@ -1867,22 +1822,22 @@
+   gboolean signedness = FALSE;
+ 
+   switch (sample_fmt) {
+-    case SAMPLE_FMT_S16:
++    case AV_SAMPLE_FMT_S16:
+       signedness = TRUE;
+       bpp = 16;
+       break;
+ 
+-    case SAMPLE_FMT_S32:
++    case AV_SAMPLE_FMT_S32:
+       signedness = TRUE;
+       bpp = 32;
+       break;
+ 
+-    case SAMPLE_FMT_FLT:
++    case AV_SAMPLE_FMT_FLT:
+       integer = FALSE;
+       bpp = 32;
+       break;
+ 
+-    case SAMPLE_FMT_DBL:
++    case AV_SAMPLE_FMT_DBL:
+       integer = FALSE;
+       bpp = 64;
+       break;
+@@ -1941,12 +1896,12 @@
+     }
+   } else {
+     GstCaps *temp;
+-    enum SampleFormat i;
++    enum AVSampleFormat i;
+     AVCodecContext ctx = { 0, };
+ 
+     ctx.channels = -1;
+     caps = gst_caps_new_empty ();
+-    for (i = 0; i <= SAMPLE_FMT_DBL; i++) {
++    for (i = 0; i <= AV_SAMPLE_FMT_DBL; i++) {
+       temp = gst_ffmpeg_smpfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
+       if (temp != NULL) {
+         gst_caps_append (caps, temp);
+@@ -2049,9 +2004,9 @@
+         gst_structure_get_int (structure, "endianness", &endianness)) {
+       if (endianness == G_BYTE_ORDER) {
+         if (width == 32)
+-          context->sample_fmt = SAMPLE_FMT_FLT;
++          context->sample_fmt = AV_SAMPLE_FMT_FLT;
+         else if (width == 64)
+-          context->sample_fmt = SAMPLE_FMT_DBL;
++          context->sample_fmt = AV_SAMPLE_FMT_DBL;
+       }
+     }
+   } else {
+@@ -2062,9 +2017,9 @@
+         gst_structure_get_int (structure, "endianness", &endianness)) {
+       if ((endianness == G_BYTE_ORDER) && (signedness == TRUE)) {
+         if ((width == 16) && (depth == 16))
+-          context->sample_fmt = SAMPLE_FMT_S16;
++          context->sample_fmt = AV_SAMPLE_FMT_S16;
+         else if ((width == 32) && (depth == 32))
+-          context->sample_fmt = SAMPLE_FMT_S32;
++          context->sample_fmt = AV_SAMPLE_FMT_S32;
+       }
+     }
+   }
+@@ -2190,7 +2145,6 @@
+       } else {
+         if (bpp == 8) {
+           context->pix_fmt = PIX_FMT_PAL8;
+-          gst_ffmpeg_get_palette (caps, context);
+         }
+       }
+     }
+@@ -2576,7 +2530,6 @@
+   switch (codec_type) {
+     case AVMEDIA_TYPE_VIDEO:
+       gst_ffmpeg_caps_to_pixfmt (caps, context, codec_id == CODEC_ID_RAWVIDEO);
+-      gst_ffmpeg_get_palette (caps, context);
+       break;
+     case AVMEDIA_TYPE_AUDIO:
+       gst_ffmpeg_caps_to_smpfmt (caps, context, FALSE);
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.orig
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.orig	1970-01-01 01:00:00.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.orig	2014-08-08 15:30:34.006867097 +0200
+@@ -0,0 +1,3447 @@
++/* GStreamer
++ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
++ * This file:
++ * Copyright (c) 2002-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 <gst/gst.h>
++#ifdef HAVE_FFMPEG_UNINSTALLED
++#include <avcodec.h>
++#include <channel_layout.h>>
++#else
++#include <libavcodec/avcodec.h>
++#include <libavutil/channel_layout.h>
++#endif
++#include <string.h>
++
++#include "gstffmpeg.h"
++#include "gstffmpegcodecmap.h"
++
++#include <gst/pbutils/codec-utils.h>
++
++/*
++ * Read a palette from a caps.
++ */
++
++static void
++gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
++{
++  GstStructure *str = gst_caps_get_structure (caps, 0);
++  const GValue *palette_v;
++  const GstBuffer *palette;
++
++  /* do we have a palette? */
++  if ((palette_v = gst_structure_get_value (str, "palette_data")) && context) {
++    palette = gst_value_get_buffer (palette_v);
++    if (GST_BUFFER_SIZE (palette) >= AVPALETTE_SIZE) {
++      if (context->palctrl)
++        av_free (context->palctrl);
++      context->palctrl = av_malloc (sizeof (AVPaletteControl));
++      context->palctrl->palette_changed = 1;
++      memcpy (context->palctrl->palette, GST_BUFFER_DATA (palette),
++          AVPALETTE_SIZE);
++    }
++  }
++}
++
++static void
++gst_ffmpeg_set_palette (GstCaps * caps, AVCodecContext * context)
++{
++  if (context->palctrl) {
++    GstBuffer *palette = gst_buffer_new_and_alloc (AVPALETTE_SIZE);
++
++    memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
++        AVPALETTE_SIZE);
++    gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, palette, NULL);
++  }
++}
++
++/* IMPORTANT: Keep this sorted by the ffmpeg channel masks */
++static const struct
++{
++  guint64 ff;
++  GstAudioChannelPosition gst;
++} _ff_to_gst_layout[] = {
++  {
++  AV_CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
++  AV_CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
++  AV_CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
++  AV_CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
++  AV_CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
++  AV_CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
++  AV_CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
++  AV_CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
++  AV_CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
++  AV_CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
++  AV_CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
++  AV_CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
++  AV_CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
++};
++
++static GstAudioChannelPosition *
++gst_ff_channel_layout_to_gst (guint64 channel_layout, guint channels)
++{
++  guint nchannels = 0, i, j;
++  GstAudioChannelPosition *pos = NULL;
++  gboolean none_layout = FALSE;
++
++  for (i = 0; i < 64; i++) {
++    if ((channel_layout & (G_GUINT64_CONSTANT (1) << i)) != 0) {
++      nchannels++;
++    }
++  }
++
++  if (channel_layout == 0) {
++    nchannels = channels;
++    none_layout = TRUE;
++  }
++
++  if (nchannels != channels) {
++    GST_ERROR ("Number of channels is different (%u != %u)", channels,
++        nchannels);
++    return NULL;
++  }
++
++  pos = g_new (GstAudioChannelPosition, nchannels);
++
++  for (i = 0, j = 0; i < G_N_ELEMENTS (_ff_to_gst_layout); i++) {
++    if ((channel_layout & _ff_to_gst_layout[i].ff) != 0) {
++      pos[j++] = _ff_to_gst_layout[i].gst;
++
++      if (_ff_to_gst_layout[i].gst == GST_AUDIO_CHANNEL_POSITION_NONE)
++        none_layout = TRUE;
++    }
++  }
++
++  if (j != nchannels) {
++    GST_WARNING ("Unknown channels in channel layout - assuming NONE layout");
++    none_layout = TRUE;
++  }
++
++  if (!none_layout && !gst_audio_check_channel_positions (pos, nchannels)) {
++    GST_ERROR ("Invalid channel layout %" G_GUINT64_FORMAT
++        " - assuming NONE layout", channel_layout);
++    none_layout = TRUE;
++  }
++
++  if (none_layout) {
++    if (nchannels == 1) {
++      pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_MONO;
++    } else if (nchannels == 2) {
++      pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
++      pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
++    } else if (channel_layout == 0) {
++      g_free (pos);
++      pos = NULL;
++    } else {
++      for (i = 0; i < nchannels; i++)
++        pos[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
++    }
++  }
++
++  if (nchannels == 1 && pos[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER) {
++    GST_DEBUG ("mono common case; won't set channel positions");
++    g_free (pos);
++    pos = NULL;
++  } else if (nchannels == 2 && pos[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT
++      && pos[1] == GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT) {
++    GST_DEBUG ("stereo common case; won't set channel positions");
++    g_free (pos);
++    pos = NULL;
++  }
++
++  return pos;
++}
++
++/* this macro makes a caps width fixed or unfixed width/height
++ * properties depending on whether we've got a context.
++ *
++ * See below for why we use this.
++ *
++ * We should actually do this stuff at the end, like in riff-media.c,
++ * but I'm too lazy today. Maybe later.
++ */
++static GstCaps *
++gst_ff_vid_caps_new (AVCodecContext * context, enum CodecID codec_id,
++    const char *mimetype, const char *fieldname, ...)
++{
++  GstStructure *structure = NULL;
++  GstCaps *caps = NULL;
++  va_list var_args;
++  gint i;
++
++  GST_LOG ("context:%p, codec_id:%d, mimetype:%s", context, codec_id, mimetype);
++
++  /* fixed, non probing context */
++  if (context != NULL && context->width != -1) {
++    gint num, denom;
++
++    caps = gst_caps_new_simple (mimetype,
++        "width", G_TYPE_INT, context->width,
++        "height", G_TYPE_INT, context->height, NULL);
++
++    num = context->time_base.den / context->ticks_per_frame;
++    denom = context->time_base.num;
++
++    if (!denom) {
++      GST_LOG ("invalid framerate: %d/0, -> %d/1", num, num);
++      denom = 1;
++    }
++    if (gst_util_fraction_compare (num, denom, 1000, 1) > 0) {
++      GST_LOG ("excessive framerate: %d/%d, -> 0/1", num, denom);
++      num = 0;
++      denom = 1;
++    }
++    GST_LOG ("setting framerate: %d/%d", num, denom);
++    gst_caps_set_simple (caps,
++        "framerate", GST_TYPE_FRACTION, num, denom, NULL);
++  } else {
++    /* so we are after restricted caps in this case */
++    switch (codec_id) {
++      case CODEC_ID_H261:
++      {
++        caps = gst_caps_new_simple (mimetype,
++            "width", G_TYPE_INT, 352,
++            "height", G_TYPE_INT, 288,
++            "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
++        gst_caps_append (caps, gst_caps_new_simple (mimetype,
++                "width", G_TYPE_INT, 176,
++                "height", G_TYPE_INT, 144,
++                "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL));
++        break;
++      }
++      case CODEC_ID_H263:
++      {
++        /* 128x96, 176x144, 352x288, 704x576, and 1408x1152. slightly reordered
++         * because we want automatic negotiation to go as close to 320x240 as
++         * possible. */
++        const static gint widths[] = { 352, 704, 176, 1408, 128 };
++        const static gint heights[] = { 288, 576, 144, 1152, 96 };
++        GstCaps *temp;
++        gint n_sizes = G_N_ELEMENTS (widths);
++
++        caps = gst_caps_new_empty ();
++        for (i = 0; i < n_sizes; i++) {
++          temp = gst_caps_new_simple (mimetype,
++              "width", G_TYPE_INT, widths[i],
++              "height", G_TYPE_INT, heights[i],
++              "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
++
++          gst_caps_append (caps, temp);
++        }
++        break;
++      }
++      case CODEC_ID_DVVIDEO:
++      {
++        static struct
++        {
++          guint32 csp;
++          gint width, height;
++          gint par_n, par_d;
++          gint framerate_n, framerate_d;
++        } profiles[] = {
++          {
++          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 480, 10, 11, 30000, 1001}, {
++          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 480, 40, 33, 30000, 1001}, {
++          GST_MAKE_FOURCC ('I', '4', '2', '0'), 720, 576, 59, 54, 25, 1}, {
++          GST_MAKE_FOURCC ('I', '4', '2', '0'), 720, 576, 118, 81, 25, 1}, {
++          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 576, 59, 54, 25, 1}, {
++          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 576, 118, 81, 25, 1}
++        };
++        GstCaps *temp;
++        gint n_sizes = G_N_ELEMENTS (profiles);
++
++        caps = gst_caps_new_empty ();
++        for (i = 0; i < n_sizes; i++) {
++          temp = gst_caps_new_simple (mimetype,
++              "width", G_TYPE_INT, profiles[i].width,
++              "height", G_TYPE_INT, profiles[i].height,
++              "framerate", GST_TYPE_FRACTION, profiles[i].framerate_n,
++              profiles[i].framerate_d, "pixel-aspect-ratio", GST_TYPE_FRACTION,
++              profiles[i].par_n, profiles[i].par_d, NULL);
++
++          gst_caps_append (caps, temp);
++        }
++        break;
++      }
++      case CODEC_ID_DNXHD:
++      {
++        caps = gst_caps_new_simple (mimetype,
++            "width", G_TYPE_INT, 1920,
++            "height", G_TYPE_INT, 1080,
++            "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
++        gst_caps_append (caps, gst_caps_new_simple (mimetype,
++                "width", G_TYPE_INT, 1280,
++                "height", G_TYPE_INT, 720,
++                "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL));
++        break;
++      }
++      default:
++        break;
++    }
++  }
++
++  /* no fixed caps or special restrictions applied;
++   * default unfixed setting */
++  if (!caps) {
++    GST_DEBUG ("Creating default caps");
++    caps = gst_caps_new_simple (mimetype,
++        "width", GST_TYPE_INT_RANGE, 16, 4096,
++        "height", GST_TYPE_INT_RANGE, 16, 4096,
++        "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
++  }
++
++  for (i = 0; i < gst_caps_get_size (caps); i++) {
++    va_start (var_args, fieldname);
++    structure = gst_caps_get_structure (caps, i);
++    gst_structure_set_valist (structure, fieldname, var_args);
++    va_end (var_args);
++  }
++
++  return caps;
++}
++
++/* same for audio - now with channels/sample rate
++ */
++static GstCaps *
++gst_ff_aud_caps_new (AVCodecContext * context, enum CodecID codec_id,
++    const char *mimetype, const char *fieldname, ...)
++{
++  GstCaps *caps = NULL;
++  GstStructure *structure = NULL;
++  gint i;
++  va_list var_args;
++
++  /* fixed, non-probing context */
++  if (context != NULL && context->channels != -1) {
++    GstAudioChannelPosition *pos;
++    guint64 channel_layout = context->channel_layout;
++
++    if (channel_layout == 0) {
++      const guint64 default_channel_set[] = {
++        0, 0, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_5POINT0,
++        AV_CH_LAYOUT_5POINT1, 0, AV_CH_LAYOUT_7POINT1
++      };
++
++      switch (codec_id) {
++        case CODEC_ID_EAC3:
++        case CODEC_ID_AC3:
++        case CODEC_ID_DTS:
++          if (context->channels > 0
++              && context->channels < G_N_ELEMENTS (default_channel_set))
++            channel_layout = default_channel_set[context->channels - 1];
++          break;
++        default:
++          break;
++      }
++    }
++
++    caps = gst_caps_new_simple (mimetype,
++        "rate", G_TYPE_INT, context->sample_rate,
++        "channels", G_TYPE_INT, context->channels, NULL);
++
++    pos = gst_ff_channel_layout_to_gst (channel_layout, context->channels);
++    if (pos != NULL) {
++      gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
++      g_free (pos);
++    }
++  } else {
++    gint maxchannels = 2;
++    const gint *rates = NULL;
++    gint n_rates = 0;
++
++    /* so we must be after restricted caps in this case */
++    switch (codec_id) {
++      case CODEC_ID_AAC:
++      case CODEC_ID_AAC_LATM:
++      case CODEC_ID_DTS:
++        maxchannels = 6;
++        break;
++      case CODEC_ID_MP2:
++      {
++        const static gint l_rates[] =
++            { 48000, 44100, 32000, 24000, 22050, 16000 };
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        break;
++      }
++      case CODEC_ID_EAC3:
++      case CODEC_ID_AC3:
++      {
++        const static gint l_rates[] = { 48000, 44100, 32000 };
++        maxchannels = 6;
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        break;
++      }
++      case CODEC_ID_ADPCM_G722:
++      {
++        const static gint l_rates[] = { 16000 };
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        maxchannels = 1;
++        break;
++      }
++      case CODEC_ID_ADPCM_G726:
++      {
++        const static gint l_rates[] = { 8000 };
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        maxchannels = 1;
++        break;
++      }
++      case CODEC_ID_ADPCM_SWF:
++      {
++        const static gint l_rates[] = { 11025, 22050, 44100 };
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        break;
++      }
++      case CODEC_ID_ROQ_DPCM:
++      {
++        const static gint l_rates[] = { 22050 };
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        break;
++      }
++      case CODEC_ID_AMR_NB:
++      {
++        const static gint l_rates[] = { 8000 };
++        maxchannels = 1;
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        break;
++      }
++      case CODEC_ID_AMR_WB:
++      {
++        const static gint l_rates[] = { 16000 };
++        maxchannels = 1;
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        break;
++      }
++      default:
++        break;
++    }
++
++    /* TODO: handle context->channel_layouts here to set
++     * the list of channel layouts supported by the encoder.
++     * Unfortunately no encoder uses this yet....
++     */
++    /* regardless of encode/decode, open up channels if applicable */
++    /* Until decoders/encoders expose the maximum number of channels
++     * they support, we whitelist them here. */
++    switch (codec_id) {
++      case CODEC_ID_WMAPRO:
++      case CODEC_ID_TRUEHD:
++        maxchannels = 8;
++        break;
++      default:
++        break;
++    }
++
++    if (maxchannels == 1)
++      caps = gst_caps_new_simple (mimetype,
++          "channels", G_TYPE_INT, maxchannels, NULL);
++    else
++      caps = gst_caps_new_simple (mimetype,
++          "channels", GST_TYPE_INT_RANGE, 1, maxchannels, NULL);
++    if (n_rates) {
++      GValue list = { 0, };
++      GstStructure *structure;
++
++      g_value_init (&list, GST_TYPE_LIST);
++      for (i = 0; i < n_rates; i++) {
++        GValue v = { 0, };
++
++        g_value_init (&v, G_TYPE_INT);
++        g_value_set_int (&v, rates[i]);
++        gst_value_list_append_value (&list, &v);
++        g_value_unset (&v);
++      }
++      structure = gst_caps_get_structure (caps, 0);
++      gst_structure_set_value (structure, "rate", &list);
++      g_value_unset (&list);
++    } else
++      gst_caps_set_simple (caps, "rate", GST_TYPE_INT_RANGE, 4000, 96000, NULL);
++  }
++
++  for (i = 0; i < gst_caps_get_size (caps); i++) {
++    va_start (var_args, fieldname);
++    structure = gst_caps_get_structure (caps, i);
++    gst_structure_set_valist (structure, fieldname, var_args);
++    va_end (var_args);
++  }
++
++  return caps;
++}
++
++/* Convert a FFMPEG codec ID and optional AVCodecContext
++ * to a GstCaps. If the context is ommitted, no fixed values
++ * for video/audio size will be included in the GstCaps
++ *
++ * CodecID is primarily meant for compressed data GstCaps!
++ *
++ * encode is a special parameter. gstffmpegdec will say
++ * FALSE, gstffmpegenc will say TRUE. The output caps
++ * depends on this, in such a way that it will be very
++ * specific, defined, fixed and correct caps for encoders,
++ * yet very wide, "forgiving" caps for decoders. Example
++ * for mp3: decode: audio/mpeg,mpegversion=1,layer=[1-3]
++ * but encode: audio/mpeg,mpegversion=1,layer=3,bitrate=x,
++ * rate=x,channels=x.
++ */
++
++GstCaps *
++gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
++    AVCodecContext * context, gboolean encode)
++{
++  GstCaps *caps = NULL;
++  gboolean buildcaps = FALSE;
++
++  GST_LOG ("codec_id:%d, context:%p, encode:%d", codec_id, context, encode);
++
++  switch (codec_id) {
++    case CODEC_ID_MPEG1VIDEO:
++      /* FIXME: bitrate */
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
++          "mpegversion", G_TYPE_INT, 1,
++          "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
++      break;
++
++    case CODEC_ID_MPEG2VIDEO:
++      if (encode) {
++        /* FIXME: bitrate */
++        caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
++            "mpegversion", G_TYPE_INT, 2,
++            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
++      } else {
++        /* decode both MPEG-1 and MPEG-2; width/height/fps are all in
++         * the MPEG video stream headers, so may be omitted from caps. */
++        caps = gst_caps_new_simple ("video/mpeg",
++            "mpegversion", GST_TYPE_INT_RANGE, 1, 2,
++            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
++      }
++      break;
++
++    case CODEC_ID_MPEG2VIDEO_XVMC:
++      /* this is a special ID - don't need it in GStreamer, I think */
++      break;
++
++    case CODEC_ID_H263:
++      if (encode) {
++        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h263",
++            "variant", G_TYPE_STRING, "itu",
++            "h263version", G_TYPE_STRING, "h263", NULL);
++      } else {
++        /* don't pass codec_id, we can decode other variants with the H263
++         * decoder that don't have specific size requirements
++         */
++        caps = gst_ff_vid_caps_new (context, CODEC_ID_NONE, "video/x-h263",
++            "variant", G_TYPE_STRING, "itu", NULL);
++      }
++      break;
++
++    case CODEC_ID_H263P:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h263",
++          "variant", G_TYPE_STRING, "itu",
++          "h263version", G_TYPE_STRING, "h263p", NULL);
++      if (encode && context) {
++
++        gst_caps_set_simple (caps,
++            "annex-f", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_4MV,
++            "annex-j", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_LOOP_FILTER,
++            "annex-i", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_AC_PRED,
++            "annex-t", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_AC_PRED,
++            NULL);
++      }
++      break;
++
++    case CODEC_ID_H263I:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-intel-h263",
++          "variant", G_TYPE_STRING, "intel", NULL);
++      break;
++
++    case CODEC_ID_H261:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h261", NULL);
++      break;
++
++    case CODEC_ID_RV10:
++    case CODEC_ID_RV20:
++    case CODEC_ID_RV30:
++    case CODEC_ID_RV40:
++    {
++      gint version;
++
++      switch (codec_id) {
++        case CODEC_ID_RV40:
++          version = 4;
++          break;
++        case CODEC_ID_RV30:
++          version = 3;
++          break;
++        case CODEC_ID_RV20:
++          version = 2;
++          break;
++        default:
++          version = 1;
++          break;
++      }
++
++      /* FIXME: context->sub_id must be filled in during decoding */
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-pn-realvideo",
++          "systemstream", G_TYPE_BOOLEAN, FALSE,
++          "rmversion", G_TYPE_INT, version, NULL);
++      if (context) {
++        gst_caps_set_simple (caps, "format", G_TYPE_INT, context->sub_id, NULL);
++        if (context->extradata_size >= 8) {
++          gst_caps_set_simple (caps,
++              "subformat", G_TYPE_INT, GST_READ_UINT32_BE (context->extradata),
++              NULL);
++        }
++      }
++    }
++      break;
++
++    case CODEC_ID_MP1:
++      /* FIXME: bitrate */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
++          "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 1, NULL);
++      break;
++
++    case CODEC_ID_MP2:
++      /* FIXME: bitrate */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
++          "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 2, NULL);
++      break;
++
++    case CODEC_ID_MP3:
++      if (encode) {
++        /* FIXME: bitrate */
++        caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
++            "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
++      } else {
++        /* Decodes MPEG-1 layer 1/2/3. Samplerate, channels et al are
++         * in the MPEG audio header, so may be omitted from caps. */
++        caps = gst_caps_new_simple ("audio/mpeg",
++            "mpegversion", G_TYPE_INT, 1,
++            "layer", GST_TYPE_INT_RANGE, 1, 3, NULL);
++      }
++      break;
++
++    case CODEC_ID_MUSEPACK7:
++      caps =
++          gst_ff_aud_caps_new (context, codec_id,
++          "audio/x-ffmpeg-parsed-musepack", "streamversion", G_TYPE_INT, 7,
++          NULL);
++      break;
++
++    case CODEC_ID_MUSEPACK8:
++      caps =
++          gst_ff_aud_caps_new (context, codec_id,
++          "audio/x-ffmpeg-parsed-musepack", "streamversion", G_TYPE_INT, 8,
++          NULL);
++      break;
++
++    case CODEC_ID_AC3:
++      /* FIXME: bitrate */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-ac3", NULL);
++      break;
++
++    case CODEC_ID_EAC3:
++      /* FIXME: bitrate */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-eac3", NULL);
++      break;
++
++    case CODEC_ID_TRUEHD:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-true-hd", NULL);
++      break;
++
++    case CODEC_ID_ATRAC1:
++      caps =
++          gst_ff_aud_caps_new (context, codec_id, "audio/x-vnd.sony.atrac1",
++          NULL);
++      break;
++
++    case CODEC_ID_ATRAC3:
++      caps =
++          gst_ff_aud_caps_new (context, codec_id, "audio/x-vnd.sony.atrac3",
++          NULL);
++      break;
++
++    case CODEC_ID_DTS:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dts", NULL);
++      break;
++
++    case CODEC_ID_APE:
++      caps =
++          gst_ff_aud_caps_new (context, codec_id, "audio/x-ffmpeg-parsed-ape",
++          NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "depth", G_TYPE_INT, context->bits_per_coded_sample, NULL);
++      }
++      break;
++
++    case CODEC_ID_MLP:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mlp", NULL);
++      break;
++
++    case CODEC_ID_IMC:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-imc", NULL);
++      break;
++
++      /* MJPEG is normal JPEG, Motion-JPEG and Quicktime MJPEG-A. MJPEGB
++       * is Quicktime's MJPEG-B. LJPEG is lossless JPEG. I don't know what
++       * sp5x is, but it's apparently something JPEG... We don't separate
++       * between those in GStreamer. Should we (at least between MJPEG,
++       * MJPEG-B and sp5x decoding...)? */
++    case CODEC_ID_MJPEG:
++    case CODEC_ID_LJPEG:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/jpeg", NULL);
++      break;
++
++    case CODEC_ID_SP5X:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/sp5x", NULL);
++      break;
++
++    case CODEC_ID_MJPEGB:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mjpeg-b", NULL);
++      break;
++
++    case CODEC_ID_MPEG4:
++      if (encode && context != NULL) {
++        /* I'm not exactly sure what ffmpeg outputs... ffmpeg itself uses
++         * the AVI fourcc 'DIVX', but 'mp4v' for Quicktime... */
++        switch (context->codec_tag) {
++          case GST_MAKE_FOURCC ('D', 'I', 'V', 'X'):
++            caps = gst_ff_vid_caps_new (context, codec_id, "video/x-divx",
++                "divxversion", G_TYPE_INT, 5, NULL);
++            break;
++          case GST_MAKE_FOURCC ('m', 'p', '4', 'v'):
++          default:
++            /* FIXME: bitrate */
++            caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
++                "systemstream", G_TYPE_BOOLEAN, FALSE,
++                "mpegversion", G_TYPE_INT, 4, NULL);
++            break;
++        }
++      } else {
++        /* The trick here is to separate xvid, divx, mpeg4, 3ivx et al */
++        caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
++            "mpegversion", G_TYPE_INT, 4,
++            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
++        if (encode) {
++          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
++                  "video/x-divx", "divxversion", G_TYPE_INT, 5, NULL));
++        } else {
++          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
++                  "video/x-divx", "divxversion", GST_TYPE_INT_RANGE, 4, 5,
++                  NULL));
++          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
++                  "video/x-xvid", NULL));
++          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
++                  "video/x-3ivx", NULL));
++        }
++      }
++      break;
++
++    case CODEC_ID_RAWVIDEO:
++      caps =
++          gst_ffmpeg_codectype_to_caps (AVMEDIA_TYPE_VIDEO, context, codec_id,
++          encode);
++      break;
++
++    case CODEC_ID_MSMPEG4V1:
++    case CODEC_ID_MSMPEG4V2:
++    case CODEC_ID_MSMPEG4V3:
++    {
++      gint version = 41 + codec_id - CODEC_ID_MSMPEG4V1;
++
++      /* encode-FIXME: bitrate */
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-msmpeg",
++          "msmpegversion", G_TYPE_INT, version, NULL);
++      if (!encode && codec_id == CODEC_ID_MSMPEG4V3) {
++        gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
++                "video/x-divx", "divxversion", G_TYPE_INT, 3, NULL));
++      }
++    }
++      break;
++
++    case CODEC_ID_WMV1:
++    case CODEC_ID_WMV2:
++    {
++      gint version = (codec_id == CODEC_ID_WMV1) ? 1 : 2;
++
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
++          "wmvversion", G_TYPE_INT, version, NULL);
++    }
++      break;
++
++    case CODEC_ID_FLV1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-flash-video",
++          "flvversion", G_TYPE_INT, 1, NULL);
++      break;
++
++    case CODEC_ID_SVQ1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-svq",
++          "svqversion", G_TYPE_INT, 1, NULL);
++      break;
++
++    case CODEC_ID_SVQ3:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-svq",
++          "svqversion", G_TYPE_INT, 3, NULL);
++      break;
++
++    case CODEC_ID_DVAUDIO:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dv", NULL);
++      break;
++
++    case CODEC_ID_DVVIDEO:
++    {
++      if (encode && context) {
++        guint32 fourcc;
++
++        switch (context->pix_fmt) {
++          case PIX_FMT_YUYV422:
++            fourcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
++            break;
++          case PIX_FMT_YUV420P:
++            fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
++            break;
++          case PIX_FMT_YUVA420P:
++            fourcc = GST_MAKE_FOURCC ('A', '4', '2', '0');
++            break;
++          case PIX_FMT_YUV411P:
++            fourcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
++            break;
++          case PIX_FMT_YUV422P:
++            fourcc = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
++            break;
++          case PIX_FMT_YUV410P:
++            fourcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
++            break;
++          default:
++            GST_WARNING
++                ("Couldnt' find fourcc for pixfmt %d, defaulting to I420",
++                context->pix_fmt);
++            fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
++            break;
++        }
++        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dv",
++            "systemstream", G_TYPE_BOOLEAN, FALSE,
++            "format", GST_TYPE_FOURCC, fourcc, NULL);
++      } else {
++        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dv",
++            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
++      }
++    }
++      break;
++
++    case CODEC_ID_WMAV1:
++    case CODEC_ID_WMAV2:
++    {
++      gint version = (codec_id == CODEC_ID_WMAV1) ? 1 : 2;
++
++      if (context) {
++        caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
++            "wmaversion", G_TYPE_INT, version,
++            "block_align", G_TYPE_INT, context->block_align,
++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++      } else {
++        caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
++            "wmaversion", G_TYPE_INT, version,
++            "block_align", GST_TYPE_INT_RANGE, 0, G_MAXINT,
++            "bitrate", GST_TYPE_INT_RANGE, 0, G_MAXINT, NULL);
++      }
++    }
++      break;
++    case CODEC_ID_WMAPRO:
++    {
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
++          "wmaversion", G_TYPE_INT, 3, NULL);
++      break;
++    }
++
++    case CODEC_ID_WMAVOICE:
++    {
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wms", NULL);
++      break;
++    }
++
++    case CODEC_ID_MACE3:
++    case CODEC_ID_MACE6:
++    {
++      gint version = (codec_id == CODEC_ID_MACE3) ? 3 : 6;
++
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mace",
++          "maceversion", G_TYPE_INT, version, NULL);
++    }
++      break;
++
++    case CODEC_ID_HUFFYUV:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-huffyuv", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "bpp", G_TYPE_INT, context->bits_per_coded_sample, NULL);
++      }
++      break;
++
++    case CODEC_ID_CYUV:
++      caps =
++          gst_ff_vid_caps_new (context, codec_id, "video/x-compressed-yuv",
++          NULL);
++      break;
++
++    case CODEC_ID_H264:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h264", NULL);
++      break;
++
++    case CODEC_ID_INDEO5:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
++          "indeoversion", G_TYPE_INT, 5, NULL);
++      break;
++
++    case CODEC_ID_INDEO3:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
++          "indeoversion", G_TYPE_INT, 3, NULL);
++      break;
++
++    case CODEC_ID_INDEO2:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
++          "indeoversion", G_TYPE_INT, 2, NULL);
++      break;
++
++    case CODEC_ID_FLASHSV:
++      caps =
++          gst_ff_vid_caps_new (context, codec_id, "video/x-flash-screen", NULL);
++      break;
++
++    case CODEC_ID_VP3:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp3", NULL);
++      break;
++
++    case CODEC_ID_VP5:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp5", NULL);
++      break;
++
++    case CODEC_ID_VP6:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6", NULL);
++      break;
++
++    case CODEC_ID_VP6F:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6-flash", NULL);
++      break;
++
++    case CODEC_ID_VP6A:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6-alpha", NULL);
++      break;
++
++    case CODEC_ID_VP8:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp8", NULL);
++      break;
++
++    case CODEC_ID_THEORA:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-theora", NULL);
++      break;
++
++    case CODEC_ID_AAC:
++    {
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg", NULL);
++
++      if (!encode) {
++        GValue arr = { 0, };
++        GValue item = { 0, };
++
++        g_value_init (&arr, GST_TYPE_LIST);
++        g_value_init (&item, G_TYPE_INT);
++        g_value_set_int (&item, 2);
++        gst_value_list_append_value (&arr, &item);
++        g_value_set_int (&item, 4);
++        gst_value_list_append_value (&arr, &item);
++        g_value_unset (&item);
++
++        gst_caps_set_value (caps, "mpegversion", &arr);
++        g_value_unset (&arr);
++
++        g_value_init (&arr, GST_TYPE_LIST);
++        g_value_init (&item, G_TYPE_STRING);
++        g_value_set_string (&item, "raw");
++        gst_value_list_append_value (&arr, &item);
++        g_value_set_string (&item, "adts");
++        gst_value_list_append_value (&arr, &item);
++        g_value_set_string (&item, "adif");
++        gst_value_list_append_value (&arr, &item);
++        g_value_unset (&item);
++
++        gst_caps_set_value (caps, "stream-format", &arr);
++        g_value_unset (&arr);
++      } else {
++        gst_caps_set_simple (caps, "mpegversion", G_TYPE_INT, 4,
++            "stream-format", G_TYPE_STRING, "raw",
++            "base-profile", G_TYPE_STRING, "lc", NULL);
++
++        if (context && context->extradata_size > 0)
++          gst_codec_utils_aac_caps_set_level_and_profile (caps,
++              context->extradata, context->extradata_size);
++      }
++
++      break;
++    }
++    case CODEC_ID_AAC_LATM:    /* LATM/LOAS AAC syntax */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
++          "mpegversion", G_TYPE_INT, 4, "stream-format", G_TYPE_STRING, "loas",
++          NULL);
++      break;
++
++    case CODEC_ID_ASV1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-asus",
++          "asusversion", G_TYPE_INT, 1, NULL);
++      break;
++    case CODEC_ID_ASV2:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-asus",
++          "asusversion", G_TYPE_INT, 2, NULL);
++      break;
++
++    case CODEC_ID_FFV1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ffv",
++          "ffvversion", G_TYPE_INT, 1, NULL);
++      break;
++
++    case CODEC_ID_4XM:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-4xm", NULL);
++      break;
++
++    case CODEC_ID_XAN_WC3:
++    case CODEC_ID_XAN_WC4:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-xan",
++          "wcversion", G_TYPE_INT, 3 - CODEC_ID_XAN_WC3 + codec_id, NULL);
++      break;
++
++    case CODEC_ID_CLJR:
++      caps =
++          gst_ff_vid_caps_new (context, codec_id,
++          "video/x-cirrus-logic-accupak", NULL);
++      break;
++
++    case CODEC_ID_FRAPS:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-fraps", NULL);
++      break;
++
++    case CODEC_ID_MDEC:
++    case CODEC_ID_ROQ:
++    case CODEC_ID_INTERPLAY_VIDEO:
++      buildcaps = TRUE;
++      break;
++
++    case CODEC_ID_VCR1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ati-vcr",
++          "vcrversion", G_TYPE_INT, 1, NULL);
++      break;
++
++    case CODEC_ID_RPZA:
++      caps =
++          gst_ff_vid_caps_new (context, codec_id, "video/x-apple-video", NULL);
++      break;
++
++    case CODEC_ID_CINEPAK:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-cinepak", NULL);
++      break;
++
++      /* WS_VQA belogns here (order) */
++
++    case CODEC_ID_MSRLE:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-rle",
++          "layout", G_TYPE_STRING, "microsoft", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
++      } else {
++        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 1, 64, NULL);
++      }
++      break;
++
++    case CODEC_ID_QTRLE:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-rle",
++          "layout", G_TYPE_STRING, "quicktime", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
++      } else {
++        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 1, 64, NULL);
++      }
++      break;
++
++    case CODEC_ID_MSVIDEO1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-msvideocodec",
++          "msvideoversion", G_TYPE_INT, 1, NULL);
++      break;
++
++    case CODEC_ID_WMV3:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
++          "wmvversion", G_TYPE_INT, 3, NULL);
++      break;
++    case CODEC_ID_VC1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
++          "wmvversion", G_TYPE_INT, 3, "format", GST_TYPE_FOURCC,
++          GST_MAKE_FOURCC ('W', 'V', 'C', '1'), NULL);
++      break;
++    case CODEC_ID_QDM2:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-qdm2", NULL);
++      break;
++
++    case CODEC_ID_MSZH:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mszh", NULL);
++      break;
++
++    case CODEC_ID_ZLIB:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-zlib", NULL);
++      break;
++
++    case CODEC_ID_TRUEMOTION1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-truemotion",
++          "trueversion", G_TYPE_INT, 1, NULL);
++      break;
++    case CODEC_ID_TRUEMOTION2:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-truemotion",
++          "trueversion", G_TYPE_INT, 2, NULL);
++      break;
++
++    case CODEC_ID_ULTI:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ultimotion",
++          NULL);
++      break;
++
++    case CODEC_ID_TSCC:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-camtasia", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
++      } else {
++        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 8, 32, NULL);
++      }
++      break;
++
++    case CODEC_ID_KMVC:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-kmvc", NULL);
++      break;
++
++    case CODEC_ID_NUV:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-nuv", NULL);
++      break;
++
++    case CODEC_ID_GIF:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/gif", NULL);
++      break;
++
++    case CODEC_ID_PNG:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/png", NULL);
++      break;
++
++    case CODEC_ID_PPM:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/ppm", NULL);
++      break;
++
++    case CODEC_ID_PBM:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/pbm", NULL);
++      break;
++
++    case CODEC_ID_PAM:
++      caps =
++          gst_ff_vid_caps_new (context, codec_id, "image/x-portable-anymap",
++          NULL);
++      break;
++
++    case CODEC_ID_PGM:
++      caps =
++          gst_ff_vid_caps_new (context, codec_id, "image/x-portable-graymap",
++          NULL);
++      break;
++
++    case CODEC_ID_PCX:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-pcx", NULL);
++      break;
++
++    case CODEC_ID_SGI:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-sgi", NULL);
++      break;
++
++    case CODEC_ID_TARGA:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-tga", NULL);
++      break;
++
++    case CODEC_ID_TIFF:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/tiff", NULL);
++      break;
++
++    case CODEC_ID_SUNRAST:
++      caps =
++          gst_ff_vid_caps_new (context, codec_id, "image/x-sun-raster", NULL);
++      break;
++
++    case CODEC_ID_SMC:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-smc", NULL);
++      break;
++
++    case CODEC_ID_QDRAW:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-qdrw", NULL);
++      break;
++
++    case CODEC_ID_DNXHD:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dnxhd", NULL);
++      break;
++
++    case CODEC_ID_MIMIC:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mimic", NULL);
++      break;
++
++    case CODEC_ID_VMNC:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vmnc", NULL);
++      break;
++
++    case CODEC_ID_TRUESPEECH:
++      caps =
++          gst_ff_aud_caps_new (context, codec_id, "audio/x-truespeech", NULL);
++      break;
++
++    case CODEC_ID_QCELP:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/qcelp", NULL);
++      break;
++
++    case CODEC_ID_AMV:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-amv", NULL);
++      break;
++
++    case CODEC_ID_AASC:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-aasc", NULL);
++      break;
++
++    case CODEC_ID_LOCO:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-loco", NULL);
++      break;
++
++    case CODEC_ID_ZMBV:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-zmbv", NULL);
++      break;
++
++    case CODEC_ID_LAGARITH:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-lagarith", NULL);
++      break;
++
++    case CODEC_ID_CSCD:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-camstudio", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
++      } else {
++        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 8, 32, NULL);
++      }
++      break;
++
++    case CODEC_ID_WS_VQA:
++    case CODEC_ID_IDCIN:
++    case CODEC_ID_8BPS:
++    case CODEC_ID_FLIC:
++    case CODEC_ID_VMDVIDEO:
++    case CODEC_ID_VMDAUDIO:
++    case CODEC_ID_SNOW:
++    case CODEC_ID_VIXL:
++    case CODEC_ID_QPEG:
++    case CODEC_ID_PGMYUV:
++    case CODEC_ID_FFVHUFF:
++    case CODEC_ID_WNV1:
++    case CODEC_ID_MP3ADU:
++    case CODEC_ID_MP3ON4:
++    case CODEC_ID_WESTWOOD_SND1:
++    case CODEC_ID_MMVIDEO:
++    case CODEC_ID_AVS:
++    case CODEC_ID_CAVS:
++      buildcaps = TRUE;
++      break;
++
++      /* weird quasi-codecs for the demuxers only */
++    case CODEC_ID_PCM_S16LE:
++    case CODEC_ID_PCM_S16BE:
++    case CODEC_ID_PCM_U16LE:
++    case CODEC_ID_PCM_U16BE:
++    case CODEC_ID_PCM_S8:
++    case CODEC_ID_PCM_U8:
++    {
++      gint width = 0, depth = 0, endianness = 0;
++      gboolean signedness = FALSE;      /* blabla */
++
++      switch (codec_id) {
++        case CODEC_ID_PCM_S16LE:
++          width = 16;
++          depth = 16;
++          endianness = G_LITTLE_ENDIAN;
++          signedness = TRUE;
++          break;
++        case CODEC_ID_PCM_S16BE:
++          width = 16;
++          depth = 16;
++          endianness = G_BIG_ENDIAN;
++          signedness = TRUE;
++          break;
++        case CODEC_ID_PCM_U16LE:
++          width = 16;
++          depth = 16;
++          endianness = G_LITTLE_ENDIAN;
++          signedness = FALSE;
++          break;
++        case CODEC_ID_PCM_U16BE:
++          width = 16;
++          depth = 16;
++          endianness = G_BIG_ENDIAN;
++          signedness = FALSE;
++          break;
++        case CODEC_ID_PCM_S8:
++          width = 8;
++          depth = 8;
++          endianness = G_BYTE_ORDER;
++          signedness = TRUE;
++          break;
++        case CODEC_ID_PCM_U8:
++          width = 8;
++          depth = 8;
++          endianness = G_BYTE_ORDER;
++          signedness = FALSE;
++          break;
++        default:
++          g_assert (0);         /* don't worry, we never get here */
++          break;
++      }
++
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-int",
++          "width", G_TYPE_INT, width,
++          "depth", G_TYPE_INT, depth,
++          "endianness", G_TYPE_INT, endianness,
++          "signed", G_TYPE_BOOLEAN, signedness, NULL);
++    }
++      break;
++
++    case CODEC_ID_PCM_MULAW:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mulaw", NULL);
++      break;
++
++    case CODEC_ID_PCM_ALAW:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-alaw", NULL);
++      break;
++
++    case CODEC_ID_ADPCM_G722:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/G722", NULL);
++      if (context)
++        gst_caps_set_simple (caps,
++            "block_align", G_TYPE_INT, context->block_align,
++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++      break;
++
++    case CODEC_ID_ADPCM_G726:
++    {
++      /* the G726 decoder can also handle G721 */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-adpcm",
++          "layout", G_TYPE_STRING, "g726", NULL);
++      if (context)
++        gst_caps_set_simple (caps,
++            "block_align", G_TYPE_INT, context->block_align,
++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++
++      if (!encode) {
++        gst_caps_append (caps, gst_caps_new_simple ("audio/x-adpcm",
++                "layout", G_TYPE_STRING, "g721",
++                "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL));
++      }
++      break;
++    }
++    case CODEC_ID_ADPCM_IMA_QT:
++    case CODEC_ID_ADPCM_IMA_WAV:
++    case CODEC_ID_ADPCM_IMA_DK3:
++    case CODEC_ID_ADPCM_IMA_DK4:
++    case CODEC_ID_ADPCM_IMA_WS:
++    case CODEC_ID_ADPCM_IMA_SMJPEG:
++    case CODEC_ID_ADPCM_IMA_AMV:
++    case CODEC_ID_ADPCM_IMA_ISS:
++    case CODEC_ID_ADPCM_IMA_EA_EACS:
++    case CODEC_ID_ADPCM_IMA_EA_SEAD:
++    case CODEC_ID_ADPCM_MS:
++    case CODEC_ID_ADPCM_4XM:
++    case CODEC_ID_ADPCM_XA:
++    case CODEC_ID_ADPCM_ADX:
++    case CODEC_ID_ADPCM_EA:
++    case CODEC_ID_ADPCM_CT:
++    case CODEC_ID_ADPCM_SWF:
++    case CODEC_ID_ADPCM_YAMAHA:
++    case CODEC_ID_ADPCM_SBPRO_2:
++    case CODEC_ID_ADPCM_SBPRO_3:
++    case CODEC_ID_ADPCM_SBPRO_4:
++    case CODEC_ID_ADPCM_EA_R1:
++    case CODEC_ID_ADPCM_EA_R2:
++    case CODEC_ID_ADPCM_EA_R3:
++    case CODEC_ID_ADPCM_EA_MAXIS_XA:
++    case CODEC_ID_ADPCM_EA_XAS:
++    case CODEC_ID_ADPCM_THP:
++    {
++      const gchar *layout = NULL;
++
++      switch (codec_id) {
++        case CODEC_ID_ADPCM_IMA_QT:
++          layout = "quicktime";
++          break;
++        case CODEC_ID_ADPCM_IMA_WAV:
++          layout = "dvi";
++          break;
++        case CODEC_ID_ADPCM_IMA_DK3:
++          layout = "dk3";
++          break;
++        case CODEC_ID_ADPCM_IMA_DK4:
++          layout = "dk4";
++          break;
++        case CODEC_ID_ADPCM_IMA_WS:
++          layout = "westwood";
++          break;
++        case CODEC_ID_ADPCM_IMA_SMJPEG:
++          layout = "smjpeg";
++          break;
++        case CODEC_ID_ADPCM_IMA_AMV:
++          layout = "amv";
++          break;
++        case CODEC_ID_ADPCM_IMA_ISS:
++          layout = "iss";
++          break;
++        case CODEC_ID_ADPCM_IMA_EA_EACS:
++          layout = "ea-eacs";
++          break;
++        case CODEC_ID_ADPCM_IMA_EA_SEAD:
++          layout = "ea-sead";
++          break;
++        case CODEC_ID_ADPCM_MS:
++          layout = "microsoft";
++          break;
++        case CODEC_ID_ADPCM_4XM:
++          layout = "4xm";
++          break;
++        case CODEC_ID_ADPCM_XA:
++          layout = "xa";
++          break;
++        case CODEC_ID_ADPCM_ADX:
++          layout = "adx";
++          break;
++        case CODEC_ID_ADPCM_EA:
++          layout = "ea";
++          break;
++        case CODEC_ID_ADPCM_CT:
++          layout = "ct";
++          break;
++        case CODEC_ID_ADPCM_SWF:
++          layout = "swf";
++          break;
++        case CODEC_ID_ADPCM_YAMAHA:
++          layout = "yamaha";
++          break;
++        case CODEC_ID_ADPCM_SBPRO_2:
++          layout = "sbpro2";
++          break;
++        case CODEC_ID_ADPCM_SBPRO_3:
++          layout = "sbpro3";
++          break;
++        case CODEC_ID_ADPCM_SBPRO_4:
++          layout = "sbpro4";
++          break;
++        case CODEC_ID_ADPCM_EA_R1:
++          layout = "ea-r1";
++          break;
++        case CODEC_ID_ADPCM_EA_R2:
++          layout = "ea-r3";
++          break;
++        case CODEC_ID_ADPCM_EA_R3:
++          layout = "ea-r3";
++          break;
++        case CODEC_ID_ADPCM_EA_MAXIS_XA:
++          layout = "ea-maxis-xa";
++          break;
++        case CODEC_ID_ADPCM_EA_XAS:
++          layout = "ea-xas";
++          break;
++        case CODEC_ID_ADPCM_THP:
++          layout = "thp";
++          break;
++        default:
++          g_assert (0);         /* don't worry, we never get here */
++          break;
++      }
++
++      /* FIXME: someone please check whether we need additional properties
++       * in this caps definition. */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-adpcm",
++          "layout", G_TYPE_STRING, layout, NULL);
++      if (context)
++        gst_caps_set_simple (caps,
++            "block_align", G_TYPE_INT, context->block_align,
++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++    }
++      break;
++
++    case CODEC_ID_AMR_NB:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/AMR", NULL);
++      break;
++
++    case CODEC_ID_AMR_WB:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/AMR-WB", NULL);
++      break;
++
++    case CODEC_ID_GSM:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-gsm", NULL);
++      break;
++
++    case CODEC_ID_GSM_MS:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/ms-gsm", NULL);
++      break;
++
++    case CODEC_ID_NELLYMOSER:
++      caps =
++          gst_ff_aud_caps_new (context, codec_id, "audio/x-nellymoser", NULL);
++      break;
++
++    case CODEC_ID_SIPR:
++    {
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-sipro", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "leaf_size", G_TYPE_INT, context->block_align,
++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++      }
++    }
++      break;
++
++    case CODEC_ID_RA_144:
++    case CODEC_ID_RA_288:
++    case CODEC_ID_COOK:
++    {
++      gint version = 0;
++
++      switch (codec_id) {
++        case CODEC_ID_RA_144:
++          version = 1;
++          break;
++        case CODEC_ID_RA_288:
++          version = 2;
++          break;
++        case CODEC_ID_COOK:
++          version = 8;
++          break;
++        default:
++          break;
++      }
++
++      /* FIXME: properties? */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-pn-realaudio",
++          "raversion", G_TYPE_INT, version, NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "leaf_size", G_TYPE_INT, context->block_align,
++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++      }
++    }
++      break;
++
++    case CODEC_ID_ROQ_DPCM:
++    case CODEC_ID_INTERPLAY_DPCM:
++    case CODEC_ID_XAN_DPCM:
++    case CODEC_ID_SOL_DPCM:
++    {
++      const gchar *layout = NULL;
++
++      switch (codec_id) {
++        case CODEC_ID_ROQ_DPCM:
++          layout = "roq";
++          break;
++        case CODEC_ID_INTERPLAY_DPCM:
++          layout = "interplay";
++          break;
++        case CODEC_ID_XAN_DPCM:
++          layout = "xan";
++          break;
++        case CODEC_ID_SOL_DPCM:
++          layout = "sol";
++          break;
++        default:
++          g_assert (0);         /* don't worry, we never get here */
++          break;
++      }
++
++      /* FIXME: someone please check whether we need additional properties
++       * in this caps definition. */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dpcm",
++          "layout", G_TYPE_STRING, layout, NULL);
++      if (context)
++        gst_caps_set_simple (caps,
++            "block_align", G_TYPE_INT, context->block_align,
++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++    }
++      break;
++
++    case CODEC_ID_SHORTEN:
++      caps = gst_caps_new_simple ("audio/x-shorten", NULL);
++      break;
++
++    case CODEC_ID_ALAC:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-alac", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "samplesize", G_TYPE_INT, context->bits_per_coded_sample, NULL);
++      }
++      break;
++
++    case CODEC_ID_FLAC:
++      /* Note that ffmpeg has no encoder yet, but just for safety. In the
++       * encoder case, we want to add things like samplerate, channels... */
++      if (!encode) {
++        caps = gst_caps_new_simple ("audio/x-flac", NULL);
++      }
++      break;
++
++    case CODEC_ID_DVD_SUBTITLE:
++    case CODEC_ID_DVB_SUBTITLE:
++      caps = NULL;
++      break;
++    case CODEC_ID_BMP:
++      caps = gst_caps_new_simple ("image/bmp", NULL);
++      break;
++    case CODEC_ID_TTA:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-tta", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "samplesize", G_TYPE_INT, context->bits_per_coded_sample, NULL);
++      }
++      break;
++    case CODEC_ID_TWINVQ:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-twin-vq", NULL);
++      break;
++    default:
++      GST_DEBUG ("Unknown codec ID %d, please add mapping here", codec_id);
++      break;
++  }
++
++  if (buildcaps) {
++    AVCodec *codec;
++
++    if ((codec = avcodec_find_decoder (codec_id)) ||
++        (codec = avcodec_find_encoder (codec_id))) {
++      gchar *mime = NULL;
++
++      GST_LOG ("Could not create stream format caps for %s", codec->name);
++
++      switch (codec->type) {
++        case AVMEDIA_TYPE_VIDEO:
++          mime = g_strdup_printf ("video/x-gst_ff-%s", codec->name);
++          caps = gst_ff_vid_caps_new (context, codec_id, mime, NULL);
++          g_free (mime);
++          break;
++        case AVMEDIA_TYPE_AUDIO:
++          mime = g_strdup_printf ("audio/x-gst_ff-%s", codec->name);
++          caps = gst_ff_aud_caps_new (context, codec_id, mime, NULL);
++          if (context)
++            gst_caps_set_simple (caps,
++                "block_align", G_TYPE_INT, context->block_align,
++                "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++          g_free (mime);
++          break;
++        default:
++          break;
++      }
++    }
++  }
++
++  if (caps != NULL) {
++
++    /* set private data */
++    if (context && context->extradata_size > 0) {
++      GstBuffer *data = gst_buffer_new_and_alloc (context->extradata_size);
++
++      memcpy (GST_BUFFER_DATA (data), context->extradata,
++          context->extradata_size);
++      gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, data, NULL);
++      gst_buffer_unref (data);
++    }
++
++    /* palette */
++    if (context) {
++      gst_ffmpeg_set_palette (caps, context);
++    }
++
++    GST_LOG ("caps for codec_id=%d: %" GST_PTR_FORMAT, codec_id, caps);
++
++  } else {
++    GST_LOG ("No caps found for codec_id=%d", codec_id);
++  }
++
++  return caps;
++}
++
++/* Convert a FFMPEG Pixel Format and optional AVCodecContext
++ * to a GstCaps. If the context is ommitted, no fixed values
++ * for video/audio size will be included in the GstCaps
++ *
++ * See below for usefullness
++ */
++
++GstCaps *
++gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context,
++    enum CodecID codec_id)
++{
++  GstCaps *caps = NULL;
++
++  int bpp = 0, depth = 0, endianness = 0;
++  gulong g_mask = 0, r_mask = 0, b_mask = 0, a_mask = 0;
++  guint32 fmt = 0;
++
++  switch (pix_fmt) {
++    case PIX_FMT_YUVJ420P:
++    case PIX_FMT_YUV420P:
++      fmt = GST_MAKE_FOURCC ('I', '4', '2', '0');
++      break;
++    case PIX_FMT_YUVA420P:
++      fmt = GST_MAKE_FOURCC ('A', '4', '2', '0');
++      break;
++    case PIX_FMT_YUYV422:
++      fmt = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
++      break;
++    case PIX_FMT_RGB24:
++      bpp = depth = 24;
++      endianness = G_BIG_ENDIAN;
++      r_mask = 0xff0000;
++      g_mask = 0x00ff00;
++      b_mask = 0x0000ff;
++      break;
++    case PIX_FMT_BGR24:
++      bpp = depth = 24;
++      endianness = G_BIG_ENDIAN;
++      r_mask = 0x0000ff;
++      g_mask = 0x00ff00;
++      b_mask = 0xff0000;
++      break;
++    case PIX_FMT_YUVJ422P:
++    case PIX_FMT_YUV422P:
++      fmt = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
++      break;
++    case PIX_FMT_YUVJ444P:
++    case PIX_FMT_YUV444P:
++      fmt = GST_MAKE_FOURCC ('Y', '4', '4', '4');
++      break;
++    case PIX_FMT_RGB32:
++      bpp = 32;
++      depth = 32;
++      endianness = G_BIG_ENDIAN;
++#if (G_BYTE_ORDER == G_BIG_ENDIAN)
++      r_mask = 0x00ff0000;
++      g_mask = 0x0000ff00;
++      b_mask = 0x000000ff;
++      a_mask = 0xff000000;
++#else
++      r_mask = 0x0000ff00;
++      g_mask = 0x00ff0000;
++      b_mask = 0xff000000;
++      a_mask = 0x000000ff;
++#endif
++      break;
++    case PIX_FMT_YUV410P:
++      fmt = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
++      break;
++    case PIX_FMT_YUV411P:
++      fmt = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
++      break;
++    case PIX_FMT_RGB565:
++      bpp = depth = 16;
++      endianness = G_BYTE_ORDER;
++      r_mask = 0xf800;
++      g_mask = 0x07e0;
++      b_mask = 0x001f;
++      break;
++    case PIX_FMT_RGB555:
++      bpp = 16;
++      depth = 15;
++      endianness = G_BYTE_ORDER;
++      r_mask = 0x7c00;
++      g_mask = 0x03e0;
++      b_mask = 0x001f;
++      break;
++    case PIX_FMT_PAL8:
++      bpp = depth = 8;
++      endianness = G_BYTE_ORDER;
++      break;
++    case PIX_FMT_GRAY8:
++      bpp = depth = 8;
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-gray",
++          "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, NULL);
++      break;
++    default:
++      /* give up ... */
++      break;
++  }
++
++  if (caps == NULL) {
++    if (bpp != 0) {
++      if (r_mask != 0) {
++        if (a_mask) {
++          caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
++              "bpp", G_TYPE_INT, bpp,
++              "depth", G_TYPE_INT, depth,
++              "red_mask", G_TYPE_INT, r_mask,
++              "green_mask", G_TYPE_INT, g_mask,
++              "blue_mask", G_TYPE_INT, b_mask,
++              "alpha_mask", G_TYPE_INT, a_mask,
++              "endianness", G_TYPE_INT, endianness, NULL);
++        } else {
++          caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
++              "bpp", G_TYPE_INT, bpp,
++              "depth", G_TYPE_INT, depth,
++              "red_mask", G_TYPE_INT, r_mask,
++              "green_mask", G_TYPE_INT, g_mask,
++              "blue_mask", G_TYPE_INT, b_mask,
++              "endianness", G_TYPE_INT, endianness, NULL);
++        }
++      } else {
++        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
++            "bpp", G_TYPE_INT, bpp,
++            "depth", G_TYPE_INT, depth,
++            "endianness", G_TYPE_INT, endianness, NULL);
++        if (caps && context) {
++          gst_ffmpeg_set_palette (caps, context);
++        }
++      }
++    } else if (fmt) {
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-yuv",
++          "format", GST_TYPE_FOURCC, fmt, NULL);
++    }
++  }
++
++  if (caps != NULL) {
++    GST_DEBUG ("caps for pix_fmt=%d: %" GST_PTR_FORMAT, pix_fmt, caps);
++  } else {
++    GST_LOG ("No caps found for pix_fmt=%d", pix_fmt);
++  }
++
++  return caps;
++}
++
++/* Convert a FFMPEG Sample Format and optional AVCodecContext
++ * to a GstCaps. If the context is ommitted, no fixed values
++ * for video/audio size will be included in the GstCaps
++ *
++ * See below for usefullness
++ */
++
++static GstCaps *
++gst_ffmpeg_smpfmt_to_caps (enum AVSampleFormat sample_fmt,
++    AVCodecContext * context, enum CodecID codec_id)
++{
++  GstCaps *caps = NULL;
++
++  int bpp = 0;
++  gboolean integer = TRUE;
++  gboolean signedness = FALSE;
++
++  switch (sample_fmt) {
++    case AV_SAMPLE_FMT_S16:
++      signedness = TRUE;
++      bpp = 16;
++      break;
++
++    case AV_SAMPLE_FMT_S32:
++      signedness = TRUE;
++      bpp = 32;
++      break;
++
++    case AV_SAMPLE_FMT_FLT:
++      integer = FALSE;
++      bpp = 32;
++      break;
++
++    case AV_SAMPLE_FMT_DBL:
++      integer = FALSE;
++      bpp = 64;
++      break;
++    default:
++      /* .. */
++      break;
++  }
++
++  if (bpp) {
++    if (integer) {
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-int",
++          "signed", G_TYPE_BOOLEAN, signedness,
++          "endianness", G_TYPE_INT, G_BYTE_ORDER,
++          "width", G_TYPE_INT, bpp, "depth", G_TYPE_INT, bpp, NULL);
++    } else {
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-float",
++          "endianness", G_TYPE_INT, G_BYTE_ORDER,
++          "width", G_TYPE_INT, bpp, NULL);
++    }
++  }
++
++  if (caps != NULL) {
++    GST_LOG ("caps for sample_fmt=%d: %" GST_PTR_FORMAT, sample_fmt, caps);
++  } else {
++    GST_LOG ("No caps found for sample_fmt=%d", sample_fmt);
++  }
++
++  return caps;
++}
++
++GstCaps *
++gst_ffmpeg_codectype_to_audio_caps (AVCodecContext * context,
++    enum CodecID codec_id, gboolean encode, AVCodec * codec)
++{
++  GstCaps *caps = NULL;
++
++  GST_DEBUG ("context:%p, codec_id:%d, encode:%d, codec:%p",
++      context, codec_id, encode, codec);
++  if (codec)
++    GST_DEBUG ("sample_fmts:%p, samplerates:%p",
++        codec->sample_fmts, codec->supported_samplerates);
++
++  if (context) {
++    /* Specific codec context */
++    caps = gst_ffmpeg_smpfmt_to_caps (context->sample_fmt, context, codec_id);
++  } else if (codec && codec->sample_fmts) {
++    GstCaps *temp;
++    int i;
++
++    caps = gst_caps_new_empty ();
++    for (i = 0; codec->sample_fmts[i] != -1; i++) {
++      temp =
++          gst_ffmpeg_smpfmt_to_caps (codec->sample_fmts[i], context, codec_id);
++      if (temp != NULL)
++        gst_caps_append (caps, temp);
++    }
++  } else {
++    GstCaps *temp;
++    enum AVSampleFormat i;
++    AVCodecContext ctx = { 0, };
++
++    ctx.channels = -1;
++    caps = gst_caps_new_empty ();
++    for (i = 0; i <= AV_SAMPLE_FMT_DBL; i++) {
++      temp = gst_ffmpeg_smpfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
++      if (temp != NULL) {
++        gst_caps_append (caps, temp);
++      }
++    }
++  }
++  return caps;
++}
++
++GstCaps *
++gst_ffmpeg_codectype_to_video_caps (AVCodecContext * context,
++    enum CodecID codec_id, gboolean encode, AVCodec * codec)
++{
++  GstCaps *caps;
++
++  GST_LOG ("context:%p, codec_id:%d, encode:%d, codec:%p",
++      context, codec_id, encode, codec);
++
++  if (context) {
++    caps = gst_ffmpeg_pixfmt_to_caps (context->pix_fmt, context, codec_id);
++  } else {
++    GstCaps *temp;
++    enum PixelFormat i;
++    AVCodecContext ctx = { 0, };
++
++    caps = gst_caps_new_empty ();
++    for (i = 0; i < PIX_FMT_NB; i++) {
++      ctx.width = -1;
++      ctx.pix_fmt = i;
++      temp = gst_ffmpeg_pixfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
++      if (temp != NULL) {
++        gst_caps_append (caps, temp);
++      }
++    }
++  }
++  return caps;
++}
++
++/* Convert a FFMPEG codec Type and optional AVCodecContext
++ * to a GstCaps. If the context is ommitted, no fixed values
++ * for video/audio size will be included in the GstCaps
++ *
++ * AVMediaType is primarily meant for uncompressed data GstCaps!
++ */
++
++GstCaps *
++gst_ffmpeg_codectype_to_caps (enum AVMediaType codec_type,
++    AVCodecContext * context, enum CodecID codec_id, gboolean encode)
++{
++  GstCaps *caps;
++
++  switch (codec_type) {
++    case AVMEDIA_TYPE_VIDEO:
++      caps =
++          gst_ffmpeg_codectype_to_video_caps (context, codec_id, encode, NULL);
++      break;
++    case AVMEDIA_TYPE_AUDIO:
++      caps =
++          gst_ffmpeg_codectype_to_audio_caps (context, codec_id, encode, NULL);
++      break;
++    default:
++      caps = NULL;
++      break;
++  }
++
++  return caps;
++}
++
++/* Convert a GstCaps (audio/raw) to a FFMPEG SampleFmt
++ * and other audio properties in a AVCodecContext.
++ *
++ * For usefullness, see below
++ */
++
++static void
++gst_ffmpeg_caps_to_smpfmt (const GstCaps * caps,
++    AVCodecContext * context, gboolean raw)
++{
++  GstStructure *structure;
++  gint depth = 0, width = 0, endianness = 0;
++  gboolean signedness = FALSE;
++  const gchar *name;
++
++  g_return_if_fail (gst_caps_get_size (caps) == 1);
++  structure = gst_caps_get_structure (caps, 0);
++
++  gst_structure_get_int (structure, "channels", &context->channels);
++  gst_structure_get_int (structure, "rate", &context->sample_rate);
++  gst_structure_get_int (structure, "block_align", &context->block_align);
++  gst_structure_get_int (structure, "bitrate", &context->bit_rate);
++
++  if (!raw)
++    return;
++
++  name = gst_structure_get_name (structure);
++
++  if (!strcmp (name, "audio/x-raw-float")) {
++    /* FLOAT */
++    if (gst_structure_get_int (structure, "width", &width) &&
++        gst_structure_get_int (structure, "endianness", &endianness)) {
++      if (endianness == G_BYTE_ORDER) {
++        if (width == 32)
++          context->sample_fmt = AV_SAMPLE_FMT_FLT;
++        else if (width == 64)
++          context->sample_fmt = AV_SAMPLE_FMT_DBL;
++      }
++    }
++  } else {
++    /* INT */
++    if (gst_structure_get_int (structure, "width", &width) &&
++        gst_structure_get_int (structure, "depth", &depth) &&
++        gst_structure_get_boolean (structure, "signed", &signedness) &&
++        gst_structure_get_int (structure, "endianness", &endianness)) {
++      if ((endianness == G_BYTE_ORDER) && (signedness == TRUE)) {
++        if ((width == 16) && (depth == 16))
++          context->sample_fmt = AV_SAMPLE_FMT_S16;
++        else if ((width == 32) && (depth == 32))
++          context->sample_fmt = AV_SAMPLE_FMT_S32;
++      }
++    }
++  }
++}
++
++
++/* Convert a GstCaps (video/raw) to a FFMPEG PixFmt
++ * and other video properties in a AVCodecContext.
++ *
++ * For usefullness, see below
++ */
++
++static void
++gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
++    AVCodecContext * context, gboolean raw)
++{
++  GstStructure *structure;
++  const GValue *fps;
++  const GValue *par = NULL;
++
++  GST_DEBUG ("converting caps %" GST_PTR_FORMAT, caps);
++  g_return_if_fail (gst_caps_get_size (caps) == 1);
++  structure = gst_caps_get_structure (caps, 0);
++
++  gst_structure_get_int (structure, "width", &context->width);
++  gst_structure_get_int (structure, "height", &context->height);
++  gst_structure_get_int (structure, "bpp", &context->bits_per_coded_sample);
++
++  fps = gst_structure_get_value (structure, "framerate");
++  if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
++
++    /* somehow these seem mixed up.. */
++    context->time_base.den = gst_value_get_fraction_numerator (fps);
++    context->time_base.num = gst_value_get_fraction_denominator (fps);
++    context->ticks_per_frame = 1;
++
++    GST_DEBUG ("setting framerate %d/%d = %lf",
++        context->time_base.den, context->time_base.num,
++        1. * context->time_base.den / context->time_base.num);
++  }
++
++  par = gst_structure_get_value (structure, "pixel-aspect-ratio");
++  if (par && GST_VALUE_HOLDS_FRACTION (par)) {
++
++    context->sample_aspect_ratio.num = gst_value_get_fraction_numerator (par);
++    context->sample_aspect_ratio.den = gst_value_get_fraction_denominator (par);
++
++    GST_DEBUG ("setting pixel-aspect-ratio %d/%d = %lf",
++        context->sample_aspect_ratio.den, context->sample_aspect_ratio.num,
++        1. * context->sample_aspect_ratio.den /
++        context->sample_aspect_ratio.num);
++  }
++
++  if (!raw)
++    return;
++
++  g_return_if_fail (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps));
++
++  if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
++    guint32 fourcc;
++
++    if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
++      switch (fourcc) {
++        case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
++          context->pix_fmt = PIX_FMT_YUYV422;
++          break;
++        case GST_MAKE_FOURCC ('I', '4', '2', '0'):
++          context->pix_fmt = PIX_FMT_YUV420P;
++          break;
++        case GST_MAKE_FOURCC ('A', '4', '2', '0'):
++          context->pix_fmt = PIX_FMT_YUVA420P;
++          break;
++        case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
++          context->pix_fmt = PIX_FMT_YUV411P;
++          break;
++        case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
++          context->pix_fmt = PIX_FMT_YUV422P;
++          break;
++        case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
++          context->pix_fmt = PIX_FMT_YUV410P;
++          break;
++#if 0
++        case FIXME:
++          context->pix_fmt = PIX_FMT_YUV444P;
++          break;
++#endif
++      }
++    }
++  } else if (strcmp (gst_structure_get_name (structure),
++          "video/x-raw-rgb") == 0) {
++    gint bpp = 0, rmask = 0, endianness = 0;
++
++    if (gst_structure_get_int (structure, "bpp", &bpp) &&
++        gst_structure_get_int (structure, "endianness", &endianness)) {
++      if (gst_structure_get_int (structure, "red_mask", &rmask)) {
++        switch (bpp) {
++          case 32:
++#if (G_BYTE_ORDER == G_BIG_ENDIAN)
++            if (rmask == 0x00ff0000)
++#else
++            if (rmask == 0x0000ff00)
++#endif
++              context->pix_fmt = PIX_FMT_RGB32;
++            break;
++          case 24:
++            if (rmask == 0x0000FF)
++              context->pix_fmt = PIX_FMT_BGR24;
++            else
++              context->pix_fmt = PIX_FMT_RGB24;
++            break;
++          case 16:
++            if (endianness == G_BYTE_ORDER)
++              context->pix_fmt = PIX_FMT_RGB565;
++            break;
++          case 15:
++            if (endianness == G_BYTE_ORDER)
++              context->pix_fmt = PIX_FMT_RGB555;
++            break;
++          default:
++            /* nothing */
++            break;
++        }
++      } else {
++        if (bpp == 8) {
++          context->pix_fmt = PIX_FMT_PAL8;
++          gst_ffmpeg_get_palette (caps, context);
++        }
++      }
++    }
++  } else if (strcmp (gst_structure_get_name (structure),
++          "video/x-raw-gray") == 0) {
++    gint bpp = 0;
++
++    if (gst_structure_get_int (structure, "bpp", &bpp)) {
++      switch (bpp) {
++        case 8:
++          context->pix_fmt = PIX_FMT_GRAY8;
++          break;
++      }
++    }
++  }
++}
++
++/* Convert a GstCaps and a FFMPEG codec Type to a
++ * AVCodecContext. If the context is ommitted, no fixed values
++ * for video/audio size will be included in the context
++ *
++ * AVMediaType is primarily meant for uncompressed data GstCaps!
++ */
++
++void
++gst_ffmpeg_caps_with_codectype (enum AVMediaType type,
++    const GstCaps * caps, AVCodecContext * context)
++{
++  if (context == NULL)
++    return;
++
++  switch (type) {
++    case AVMEDIA_TYPE_VIDEO:
++      gst_ffmpeg_caps_to_pixfmt (caps, context, TRUE);
++      break;
++
++    case AVMEDIA_TYPE_AUDIO:
++      gst_ffmpeg_caps_to_smpfmt (caps, context, TRUE);
++      break;
++
++    default:
++      /* unknown */
++      break;
++  }
++}
++
++#if 0
++static void
++nal_escape (guint8 * dst, guint8 * src, guint size, guint * destsize)
++{
++  guint8 *dstp = dst;
++  guint8 *srcp = src;
++  guint8 *end = src + size;
++  gint count = 0;
++
++  while (srcp < end) {
++    if (count == 2 && *srcp <= 0x03) {
++      GST_DEBUG ("added escape code");
++      *dstp++ = 0x03;
++      count = 0;
++    }
++    if (*srcp == 0)
++      count++;
++    else
++      count = 0;
++
++    GST_DEBUG ("copy %02x, count %d", *srcp, count);
++    *dstp++ = *srcp++;
++  }
++  *destsize = dstp - dst;
++}
++
++/* copy the config, escaping NAL units as we iterate them, if something fails we
++ * copy everything and hope for the best. */
++static void
++copy_config (guint8 * dst, guint8 * src, guint size, guint * destsize)
++{
++  guint8 *dstp = dst;
++  guint8 *srcp = src;
++  gint cnt, i;
++  guint nalsize, esize;
++
++  /* check size */
++  if (size < 7)
++    goto full_copy;
++
++  /* check version */
++  if (*srcp != 1)
++    goto full_copy;
++
++  cnt = *(srcp + 5) & 0x1f;     /* Number of sps */
++
++  GST_DEBUG ("num SPS %d", cnt);
++
++  memcpy (dstp, srcp, 6);
++  srcp += 6;
++  dstp += 6;
++
++  for (i = 0; i < cnt; i++) {
++    GST_DEBUG ("copy SPS %d", i);
++    nalsize = (srcp[0] << 8) | srcp[1];
++    nal_escape (dstp + 2, srcp + 2, nalsize, &esize);
++    dstp[0] = esize >> 8;
++    dstp[1] = esize & 0xff;
++    dstp += esize + 2;
++    srcp += nalsize + 2;
++  }
++
++  cnt = *(dstp++) = *(srcp++);  /* Number of pps */
++
++  GST_DEBUG ("num PPS %d", cnt);
++
++  for (i = 0; i < cnt; i++) {
++    GST_DEBUG ("copy PPS %d", i);
++    nalsize = (srcp[0] << 8) | srcp[1];
++    nal_escape (dstp + 2, srcp + 2, nalsize, &esize);
++    dstp[0] = esize >> 8;
++    dstp[1] = esize & 0xff;
++    dstp += esize + 2;
++    srcp += nalsize + 2;
++  }
++  *destsize = dstp - dst;
++
++  return;
++
++full_copy:
++  {
++    GST_DEBUG ("something unexpected, doing full copy");
++    memcpy (dst, src, size);
++    *destsize = size;
++    return;
++  }
++}
++#endif
++
++/*
++ * caps_with_codecid () transforms a GstCaps for a known codec
++ * ID into a filled-in context.
++ * codec_data from caps will override possible extradata already in the context
++ */
++
++void
++gst_ffmpeg_caps_with_codecid (enum CodecID codec_id,
++    enum AVMediaType codec_type, const GstCaps * caps, AVCodecContext * context)
++{
++  GstStructure *str;
++  const GValue *value;
++  const GstBuffer *buf;
++
++  GST_LOG ("codec_id:%d, codec_type:%d, caps:%" GST_PTR_FORMAT " context:%p",
++      codec_id, codec_type, caps, context);
++
++  if (!context || !gst_caps_get_size (caps))
++    return;
++
++  str = gst_caps_get_structure (caps, 0);
++
++  /* extradata parsing (esds [mpeg4], wma/wmv, msmpeg4v1/2/3, etc.) */
++  if ((value = gst_structure_get_value (str, "codec_data"))) {
++    guint size;
++    guint8 *data;
++
++    buf = GST_BUFFER_CAST (gst_value_get_mini_object (value));
++    size = GST_BUFFER_SIZE (buf);
++    data = GST_BUFFER_DATA (buf);
++
++    /* free the old one if it is there */
++    if (context->extradata)
++      av_free (context->extradata);
++
++#if 0
++    if (codec_id == CODEC_ID_H264) {
++      guint extrasize;
++
++      GST_DEBUG ("copy, escaping codec_data %d", size);
++      /* ffmpeg h264 expects the codec_data to be escaped, there is no real
++       * reason for this but let's just escape it for now. Start by allocating
++       * enough space, x2 is more than enough.
++       *
++       * FIXME, we disabled escaping because some file already contain escaped
++       * codec_data and then we escape twice and fail. It's better to leave it
++       * as is, as that is what most players do. */
++      context->extradata =
++          av_mallocz (GST_ROUND_UP_16 (size * 2 +
++              FF_INPUT_BUFFER_PADDING_SIZE));
++      copy_config (context->extradata, data, size, &extrasize);
++      GST_DEBUG ("escaped size: %d", extrasize);
++      context->extradata_size = extrasize;
++    } else
++#endif
++    {
++      /* allocate with enough padding */
++      GST_DEBUG ("copy codec_data");
++      context->extradata =
++          av_mallocz (GST_ROUND_UP_16 (size + FF_INPUT_BUFFER_PADDING_SIZE));
++      memcpy (context->extradata, data, size);
++      context->extradata_size = size;
++    }
++
++    /* Hack for VC1. Sometimes the first (length) byte is 0 for some files */
++    if (codec_id == CODEC_ID_VC1 && size > 0 && data[0] == 0) {
++      context->extradata[0] = (guint8) size;
++    }
++
++    GST_DEBUG ("have codec data of size %d", size);
++  } else if (context->extradata == NULL && codec_id != CODEC_ID_AAC_LATM &&
++      codec_id != CODEC_ID_FLAC) {
++    /* no extradata, alloc dummy with 0 sized, some codecs insist on reading
++     * extradata anyway which makes then segfault. */
++    context->extradata =
++        av_mallocz (GST_ROUND_UP_16 (FF_INPUT_BUFFER_PADDING_SIZE));
++    context->extradata_size = 0;
++    GST_DEBUG ("no codec data");
++  }
++
++  switch (codec_id) {
++    case CODEC_ID_MPEG4:
++    {
++      const gchar *mime = gst_structure_get_name (str);
++
++      if (!strcmp (mime, "video/x-divx"))
++        context->codec_tag = GST_MAKE_FOURCC ('D', 'I', 'V', 'X');
++      else if (!strcmp (mime, "video/x-xvid"))
++        context->codec_tag = GST_MAKE_FOURCC ('X', 'V', 'I', 'D');
++      else if (!strcmp (mime, "video/x-3ivx"))
++        context->codec_tag = GST_MAKE_FOURCC ('3', 'I', 'V', '1');
++      else if (!strcmp (mime, "video/mpeg"))
++        context->codec_tag = GST_MAKE_FOURCC ('m', 'p', '4', 'v');
++    }
++      break;
++
++    case CODEC_ID_SVQ3:
++      /* FIXME: this is a workaround for older gst-plugins releases
++       * (<= 0.8.9). This should be removed at some point, because
++       * it causes wrong decoded frame order. */
++      if (!context->extradata) {
++        gint halfpel_flag, thirdpel_flag, low_delay, unknown_svq3_flag;
++        guint16 flags;
++
++        if (gst_structure_get_int (str, "halfpel_flag", &halfpel_flag) ||
++            gst_structure_get_int (str, "thirdpel_flag", &thirdpel_flag) ||
++            gst_structure_get_int (str, "low_delay", &low_delay) ||
++            gst_structure_get_int (str, "unknown_svq3_flag",
++                &unknown_svq3_flag)) {
++          context->extradata = (guint8 *) av_mallocz (0x64);
++          g_stpcpy ((gchar *) context->extradata, "SVQ3");
++          flags = 1 << 3;
++          flags |= low_delay;
++          flags = flags << 2;
++          flags |= unknown_svq3_flag;
++          flags = flags << 6;
++          flags |= halfpel_flag;
++          flags = flags << 1;
++          flags |= thirdpel_flag;
++          flags = flags << 3;
++
++          flags = GUINT16_FROM_LE (flags);
++
++          memcpy ((gchar *) context->extradata + 0x62, &flags, 2);
++          context->extradata_size = 0x64;
++        }
++      }
++      break;
++
++    case CODEC_ID_MSRLE:
++    case CODEC_ID_QTRLE:
++    case CODEC_ID_TSCC:
++    case CODEC_ID_CSCD:
++    case CODEC_ID_APE:
++    {
++      gint depth;
++
++      if (gst_structure_get_int (str, "depth", &depth)) {
++        context->bits_per_coded_sample = depth;
++      } else {
++        GST_WARNING ("No depth field in caps %" GST_PTR_FORMAT, caps);
++      }
++
++    }
++      break;
++
++    case CODEC_ID_RV10:
++    case CODEC_ID_RV20:
++    case CODEC_ID_RV30:
++    case CODEC_ID_RV40:
++    {
++      gint format;
++
++      if (gst_structure_get_int (str, "format", &format))
++        context->sub_id = format;
++
++      break;
++    }
++    case CODEC_ID_COOK:
++    case CODEC_ID_RA_288:
++    case CODEC_ID_RA_144:
++    case CODEC_ID_SIPR:
++    {
++      gint leaf_size;
++      gint bitrate;
++
++      if (gst_structure_get_int (str, "leaf_size", &leaf_size))
++        context->block_align = leaf_size;
++      if (gst_structure_get_int (str, "bitrate", &bitrate))
++        context->bit_rate = bitrate;
++    }
++    case CODEC_ID_ALAC:
++      gst_structure_get_int (str, "samplesize",
++          &context->bits_per_coded_sample);
++      break;
++
++    case CODEC_ID_DVVIDEO:
++    {
++      guint32 fourcc;
++
++      if (gst_structure_get_fourcc (str, "format", &fourcc))
++        switch (fourcc) {
++          case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
++            context->pix_fmt = PIX_FMT_YUYV422;
++            break;
++          case GST_MAKE_FOURCC ('I', '4', '2', '0'):
++            context->pix_fmt = PIX_FMT_YUV420P;
++            break;
++          case GST_MAKE_FOURCC ('A', '4', '2', '0'):
++            context->pix_fmt = PIX_FMT_YUVA420P;
++            break;
++          case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
++            context->pix_fmt = PIX_FMT_YUV411P;
++            break;
++          case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
++            context->pix_fmt = PIX_FMT_YUV422P;
++            break;
++          case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
++            context->pix_fmt = PIX_FMT_YUV410P;
++            break;
++          default:
++            GST_WARNING ("couldn't convert fourcc %" GST_FOURCC_FORMAT
++                " to a pixel format", GST_FOURCC_ARGS (fourcc));
++            break;
++        }
++      break;
++    }
++    case CODEC_ID_H263P:
++    {
++      gboolean val;
++
++      if (!gst_structure_get_boolean (str, "annex-f", &val) || val)
++        context->flags |= CODEC_FLAG_4MV;
++      else
++        context->flags &= ~CODEC_FLAG_4MV;
++      if ((!gst_structure_get_boolean (str, "annex-i", &val) || val) &&
++          (!gst_structure_get_boolean (str, "annex-t", &val) || val))
++        context->flags |= CODEC_FLAG_AC_PRED;
++      else
++        context->flags &= ~CODEC_FLAG_AC_PRED;
++      if (!gst_structure_get_boolean (str, "annex-j", &val) || val)
++        context->flags |= CODEC_FLAG_LOOP_FILTER;
++      else
++        context->flags &= ~CODEC_FLAG_LOOP_FILTER;
++      break;
++    }
++    case CODEC_ID_ADPCM_G726:
++    {
++      const gchar *layout;
++
++      if ((layout = gst_structure_get_string (str, "layout"))) {
++        if (!strcmp (layout, "g721")) {
++          context->sample_rate = 8000;
++          context->channels = 1;
++          context->bit_rate = 32000;
++        }
++      }
++      break;
++    }
++    default:
++      break;
++  }
++
++  if (!gst_caps_is_fixed (caps))
++    return;
++
++  /* common properties (width, height, fps) */
++  switch (codec_type) {
++    case AVMEDIA_TYPE_VIDEO:
++      gst_ffmpeg_caps_to_pixfmt (caps, context, codec_id == CODEC_ID_RAWVIDEO);
++      gst_ffmpeg_get_palette (caps, context);
++      break;
++    case AVMEDIA_TYPE_AUDIO:
++      gst_ffmpeg_caps_to_smpfmt (caps, context, FALSE);
++      break;
++    default:
++      break;
++  }
++
++  /* fixup of default settings */
++  switch (codec_id) {
++    case CODEC_ID_QCELP:
++      /* QCELP is always mono, no matter what the caps say */
++      context->channels = 1;
++      break;
++    default:
++      break;
++  }
++}
++
++/* _formatid_to_caps () is meant for muxers/demuxers, it
++ * transforms a name (ffmpeg way of ID'ing these, why don't
++ * they have unique numerical IDs?) to the corresponding
++ * caps belonging to that mux-format
++ *
++ * Note: we don't need any additional info because the caps
++ * isn't supposed to contain any useful info besides the
++ * media type anyway
++ */
++
++GstCaps *
++gst_ffmpeg_formatid_to_caps (const gchar * format_name)
++{
++  GstCaps *caps = NULL;
++
++  if (!strcmp (format_name, "mpeg")) {
++    caps = gst_caps_new_simple ("video/mpeg",
++        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
++  } else if (!strcmp (format_name, "mpegts")) {
++    caps = gst_caps_new_simple ("video/mpegts",
++        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
++  } else if (!strcmp (format_name, "rm")) {
++    caps = gst_caps_new_simple ("application/x-pn-realmedia",
++        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
++  } else if (!strcmp (format_name, "asf")) {
++    caps = gst_caps_new_simple ("video/x-ms-asf", NULL);
++  } else if (!strcmp (format_name, "avi")) {
++    caps = gst_caps_new_simple ("video/x-msvideo", NULL);
++  } else if (!strcmp (format_name, "wav")) {
++    caps = gst_caps_new_simple ("audio/x-wav", NULL);
++  } else if (!strcmp (format_name, "ape")) {
++    caps = gst_caps_new_simple ("application/x-ape", NULL);
++  } else if (!strcmp (format_name, "swf")) {
++    caps = gst_caps_new_simple ("application/x-shockwave-flash", NULL);
++  } else if (!strcmp (format_name, "au")) {
++    caps = gst_caps_new_simple ("audio/x-au", NULL);
++  } else if (!strcmp (format_name, "dv")) {
++    caps = gst_caps_new_simple ("video/x-dv",
++        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
++  } else if (!strcmp (format_name, "4xm")) {
++    caps = gst_caps_new_simple ("video/x-4xm", NULL);
++  } else if (!strcmp (format_name, "matroska")) {
++    caps = gst_caps_new_simple ("video/x-matroska", NULL);
++  } else if (!strcmp (format_name, "mp3")) {
++    caps = gst_caps_new_simple ("application/x-id3", NULL);
++  } else if (!strcmp (format_name, "flic")) {
++    caps = gst_caps_new_simple ("video/x-fli", NULL);
++  } else if (!strcmp (format_name, "flv")) {
++    caps = gst_caps_new_simple ("video/x-flv", NULL);
++  } else if (!strcmp (format_name, "tta")) {
++    caps = gst_caps_new_simple ("audio/x-ttafile", NULL);
++  } else if (!strcmp (format_name, "aiff")) {
++    caps = gst_caps_new_simple ("audio/x-aiff", NULL);
++  } else if (!strcmp (format_name, "mov_mp4_m4a_3gp_3g2")) {
++    caps =
++        gst_caps_from_string
++        ("application/x-3gp; video/quicktime; audio/x-m4a");
++  } else if (!strcmp (format_name, "mov")) {
++    caps = gst_caps_from_string ("video/quicktime,variant=(string)apple");
++  } else if (!strcmp (format_name, "mp4")) {
++    caps = gst_caps_from_string ("video/quicktime,variant=(string)iso");
++  } else if (!strcmp (format_name, "3gp")) {
++    caps = gst_caps_from_string ("video/quicktime,variant=(string)3gpp");
++  } else if (!strcmp (format_name, "3g2")) {
++    caps = gst_caps_from_string ("video/quicktime,variant=(string)3g2");
++  } else if (!strcmp (format_name, "psp")) {
++    caps = gst_caps_from_string ("video/quicktime,variant=(string)psp");
++  } else if (!strcmp (format_name, "ipod")) {
++    caps = gst_caps_from_string ("video/quicktime,variant=(string)ipod");
++  } else if (!strcmp (format_name, "aac")) {
++    caps = gst_caps_new_simple ("audio/mpeg",
++        "mpegversion", G_TYPE_INT, 4, NULL);
++  } else if (!strcmp (format_name, "gif")) {
++    caps = gst_caps_from_string ("image/gif");
++  } else if (!strcmp (format_name, "ogg")) {
++    caps = gst_caps_from_string ("application/ogg");
++  } else if (!strcmp (format_name, "mxf") || !strcmp (format_name, "mxf_d10")) {
++    caps = gst_caps_from_string ("application/mxf");
++  } else if (!strcmp (format_name, "gxf")) {
++    caps = gst_caps_from_string ("application/gxf");
++  } else if (!strcmp (format_name, "yuv4mpegpipe")) {
++    caps = gst_caps_new_simple ("application/x-yuv4mpeg",
++        "y4mversion", G_TYPE_INT, 2, NULL);
++  } else if (!strcmp (format_name, "mpc")) {
++    caps = gst_caps_from_string ("audio/x-musepack, streamversion = (int) 7");
++  } else if (!strcmp (format_name, "vqf")) {
++    caps = gst_caps_from_string ("audio/x-vqf");
++  } else if (!strcmp (format_name, "nsv")) {
++    caps = gst_caps_from_string ("video/x-nsv");
++  } else if (!strcmp (format_name, "amr")) {
++    caps = gst_caps_from_string ("audio/x-amr-nb-sh");
++  } else if (!strcmp (format_name, "webm")) {
++    caps = gst_caps_from_string ("video/webm");
++  } else {
++    gchar *name;
++
++    GST_LOG ("Could not create stream format caps for %s", format_name);
++    name = g_strdup_printf ("application/x-gst_ff-%s", format_name);
++    caps = gst_caps_new_simple (name, NULL);
++    g_free (name);
++  }
++
++  return caps;
++}
++
++gboolean
++gst_ffmpeg_formatid_get_codecids (const gchar * format_name,
++    enum CodecID ** video_codec_list, enum CodecID ** audio_codec_list,
++    AVOutputFormat * plugin)
++{
++  static enum CodecID tmp_vlist[] = {
++    CODEC_ID_NONE,
++    CODEC_ID_NONE
++  };
++  static enum CodecID tmp_alist[] = {
++    CODEC_ID_NONE,
++    CODEC_ID_NONE
++  };
++
++  GST_LOG ("format_name : %s", format_name);
++
++  if (!strcmp (format_name, "mp4")) {
++    static enum CodecID mp4_video_list[] = {
++      CODEC_ID_MPEG4, CODEC_ID_H264,
++      CODEC_ID_MJPEG,
++      CODEC_ID_NONE
++    };
++    static enum CodecID mp4_audio_list[] = {
++      CODEC_ID_AAC, CODEC_ID_MP3,
++      CODEC_ID_NONE
++    };
++
++    *video_codec_list = mp4_video_list;
++    *audio_codec_list = mp4_audio_list;
++  } else if (!strcmp (format_name, "mpeg")) {
++    static enum CodecID mpeg_video_list[] = { CODEC_ID_MPEG1VIDEO,
++      CODEC_ID_MPEG2VIDEO,
++      CODEC_ID_H264,
++      CODEC_ID_NONE
++    };
++    static enum CodecID mpeg_audio_list[] = { CODEC_ID_MP1,
++      CODEC_ID_MP2,
++      CODEC_ID_MP3,
++      CODEC_ID_NONE
++    };
++
++    *video_codec_list = mpeg_video_list;
++    *audio_codec_list = mpeg_audio_list;
++  } else if (!strcmp (format_name, "dvd")) {
++    static enum CodecID mpeg_video_list[] = { CODEC_ID_MPEG2VIDEO,
++      CODEC_ID_NONE
++    };
++    static enum CodecID mpeg_audio_list[] = { CODEC_ID_MP2,
++      CODEC_ID_AC3,
++      CODEC_ID_DTS,
++      CODEC_ID_PCM_S16BE,
++      CODEC_ID_NONE
++    };
++
++    *video_codec_list = mpeg_video_list;
++    *audio_codec_list = mpeg_audio_list;
++  } else if (!strcmp (format_name, "mpegts")) {
++    static enum CodecID mpegts_video_list[] = { CODEC_ID_MPEG1VIDEO,
++      CODEC_ID_MPEG2VIDEO,
++      CODEC_ID_H264,
++      CODEC_ID_NONE
++    };
++    static enum CodecID mpegts_audio_list[] = { CODEC_ID_MP2,
++      CODEC_ID_MP3,
++      CODEC_ID_AC3,
++      CODEC_ID_DTS,
++      CODEC_ID_AAC,
++      CODEC_ID_NONE
++    };
++
++    *video_codec_list = mpegts_video_list;
++    *audio_codec_list = mpegts_audio_list;
++  } else if (!strcmp (format_name, "vob")) {
++    static enum CodecID vob_video_list[] =
++        { CODEC_ID_MPEG2VIDEO, CODEC_ID_NONE };
++    static enum CodecID vob_audio_list[] = { CODEC_ID_MP2, CODEC_ID_AC3,
++      CODEC_ID_DTS, CODEC_ID_NONE
++    };
++
++    *video_codec_list = vob_video_list;
++    *audio_codec_list = vob_audio_list;
++  } else if (!strcmp (format_name, "flv")) {
++    static enum CodecID flv_video_list[] = { CODEC_ID_FLV1, CODEC_ID_NONE };
++    static enum CodecID flv_audio_list[] = { CODEC_ID_MP3, CODEC_ID_NONE };
++
++    *video_codec_list = flv_video_list;
++    *audio_codec_list = flv_audio_list;
++  } else if (!strcmp (format_name, "asf")) {
++    static enum CodecID asf_video_list[] =
++        { CODEC_ID_WMV1, CODEC_ID_WMV2, CODEC_ID_MSMPEG4V3, CODEC_ID_NONE };
++    static enum CodecID asf_audio_list[] =
++        { CODEC_ID_WMAV1, CODEC_ID_WMAV2, CODEC_ID_MP3, CODEC_ID_NONE };
++
++    *video_codec_list = asf_video_list;
++    *audio_codec_list = asf_audio_list;
++  } else if (!strcmp (format_name, "dv")) {
++    static enum CodecID dv_video_list[] = { CODEC_ID_DVVIDEO, CODEC_ID_NONE };
++    static enum CodecID dv_audio_list[] = { CODEC_ID_PCM_S16LE, CODEC_ID_NONE };
++
++    *video_codec_list = dv_video_list;
++    *audio_codec_list = dv_audio_list;
++  } else if (!strcmp (format_name, "mov")) {
++    static enum CodecID mov_video_list[] = {
++      CODEC_ID_SVQ1, CODEC_ID_SVQ3, CODEC_ID_MPEG4,
++      CODEC_ID_H263, CODEC_ID_H263P,
++      CODEC_ID_H264, CODEC_ID_DVVIDEO,
++      CODEC_ID_MJPEG,
++      CODEC_ID_NONE
++    };
++    static enum CodecID mov_audio_list[] = {
++      CODEC_ID_PCM_MULAW, CODEC_ID_PCM_ALAW, CODEC_ID_ADPCM_IMA_QT,
++      CODEC_ID_MACE3, CODEC_ID_MACE6, CODEC_ID_AAC,
++      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
++      CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE,
++      CODEC_ID_MP3, CODEC_ID_NONE
++    };
++
++    *video_codec_list = mov_video_list;
++    *audio_codec_list = mov_audio_list;
++  } else if ((!strcmp (format_name, "3gp") || !strcmp (format_name, "3g2"))) {
++    static enum CodecID tgp_video_list[] = {
++      CODEC_ID_MPEG4, CODEC_ID_H263, CODEC_ID_H263P, CODEC_ID_H264,
++      CODEC_ID_NONE
++    };
++    static enum CodecID tgp_audio_list[] = {
++      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
++      CODEC_ID_AAC,
++      CODEC_ID_NONE
++    };
++
++    *video_codec_list = tgp_video_list;
++    *audio_codec_list = tgp_audio_list;
++  } else if (!strcmp (format_name, "mmf")) {
++    static enum CodecID mmf_audio_list[] = {
++      CODEC_ID_ADPCM_YAMAHA, CODEC_ID_NONE
++    };
++    *video_codec_list = NULL;
++    *audio_codec_list = mmf_audio_list;
++  } else if (!strcmp (format_name, "amr")) {
++    static enum CodecID amr_audio_list[] = {
++      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
++      CODEC_ID_NONE
++    };
++    *video_codec_list = NULL;
++    *audio_codec_list = amr_audio_list;
++  } else if (!strcmp (format_name, "gif")) {
++    static enum CodecID gif_image_list[] = {
++      CODEC_ID_RAWVIDEO, CODEC_ID_NONE
++    };
++    *video_codec_list = gif_image_list;
++    *audio_codec_list = NULL;
++  } else if ((plugin->audio_codec != CODEC_ID_NONE) ||
++      (plugin->video_codec != CODEC_ID_NONE)) {
++    tmp_vlist[0] = plugin->video_codec;
++    tmp_alist[0] = plugin->audio_codec;
++
++    *video_codec_list = tmp_vlist;
++    *audio_codec_list = tmp_alist;
++  } else {
++    GST_LOG ("Format %s not found", format_name);
++    return FALSE;
++  }
++
++  return TRUE;
++}
++
++/* Convert a GstCaps to a FFMPEG codec ID. Size et all
++ * are omitted, that can be queried by the user itself,
++ * we're not eating the GstCaps or anything
++ * A pointer to an allocated context is also needed for
++ * optional extra info
++ */
++
++enum CodecID
++gst_ffmpeg_caps_to_codecid (const GstCaps * caps, AVCodecContext * context)
++{
++  enum CodecID id = CODEC_ID_NONE;
++  const gchar *mimetype;
++  const GstStructure *structure;
++  gboolean video = FALSE, audio = FALSE;        /* we want to be sure! */
++
++  g_return_val_if_fail (caps != NULL, CODEC_ID_NONE);
++  g_return_val_if_fail (gst_caps_get_size (caps) == 1, CODEC_ID_NONE);
++  structure = gst_caps_get_structure (caps, 0);
++
++  mimetype = gst_structure_get_name (structure);
++
++  if (!strcmp (mimetype, "video/x-raw-rgb") ||
++      !strcmp (mimetype, "video/x-raw-yuv")) {
++    id = CODEC_ID_RAWVIDEO;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-raw-int")) {
++    gint depth, width, endianness;
++    gboolean signedness;
++
++    if (gst_structure_get_int (structure, "endianness", &endianness) &&
++        gst_structure_get_boolean (structure, "signed", &signedness) &&
++        gst_structure_get_int (structure, "width", &width) &&
++        gst_structure_get_int (structure, "depth", &depth) && depth == width) {
++      switch (depth) {
++        case 8:
++          if (signedness) {
++            id = CODEC_ID_PCM_S8;
++          } else {
++            id = CODEC_ID_PCM_U8;
++          }
++          break;
++        case 16:
++          switch (endianness) {
++            case G_BIG_ENDIAN:
++              if (signedness) {
++                id = CODEC_ID_PCM_S16BE;
++              } else {
++                id = CODEC_ID_PCM_U16BE;
++              }
++              break;
++            case G_LITTLE_ENDIAN:
++              if (signedness) {
++                id = CODEC_ID_PCM_S16LE;
++              } else {
++                id = CODEC_ID_PCM_U16LE;
++              }
++              break;
++          }
++          break;
++      }
++      if (id != CODEC_ID_NONE)
++        audio = TRUE;
++    }
++  } else if (!strcmp (mimetype, "audio/x-mulaw")) {
++    id = CODEC_ID_PCM_MULAW;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-alaw")) {
++    id = CODEC_ID_PCM_ALAW;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-dv")) {
++    gboolean sys_strm;
++
++    if (gst_structure_get_boolean (structure, "systemstream", &sys_strm) &&
++        !sys_strm) {
++      id = CODEC_ID_DVVIDEO;
++      video = TRUE;
++    }
++  } else if (!strcmp (mimetype, "audio/x-dv")) {        /* ??? */
++    id = CODEC_ID_DVAUDIO;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-h263")) {
++    const gchar *h263version =
++        gst_structure_get_string (structure, "h263version");
++    if (h263version && !strcmp (h263version, "h263p"))
++      id = CODEC_ID_H263P;
++    else
++      id = CODEC_ID_H263;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-intel-h263")) {
++    id = CODEC_ID_H263I;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-h261")) {
++    id = CODEC_ID_H261;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/mpeg")) {
++    gboolean sys_strm;
++    gint mpegversion;
++
++    if (gst_structure_get_boolean (structure, "systemstream", &sys_strm) &&
++        gst_structure_get_int (structure, "mpegversion", &mpegversion) &&
++        !sys_strm) {
++      switch (mpegversion) {
++        case 1:
++          id = CODEC_ID_MPEG1VIDEO;
++          break;
++        case 2:
++          id = CODEC_ID_MPEG2VIDEO;
++          break;
++        case 4:
++          id = CODEC_ID_MPEG4;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      video = TRUE;
++  } else if (!strcmp (mimetype, "image/jpeg")) {
++    id = CODEC_ID_MJPEG;        /* A... B... */
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-jpeg-b")) {
++    id = CODEC_ID_MJPEGB;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-wmv")) {
++    gint wmvversion = 0;
++
++    if (gst_structure_get_int (structure, "wmvversion", &wmvversion)) {
++      switch (wmvversion) {
++        case 1:
++          id = CODEC_ID_WMV1;
++          break;
++        case 2:
++          id = CODEC_ID_WMV2;
++          break;
++        case 3:
++        {
++          guint32 fourcc;
++
++          /* WMV3 unless the fourcc exists and says otherwise */
++          id = CODEC_ID_WMV3;
++
++          if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
++            if ((fourcc == GST_MAKE_FOURCC ('W', 'V', 'C', '1')) ||
++                (fourcc == GST_MAKE_FOURCC ('W', 'M', 'V', 'A'))) {
++              id = CODEC_ID_VC1;
++            }
++          }
++        }
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      video = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-vorbis")) {
++    id = CODEC_ID_VORBIS;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-qdm2")) {
++    id = CODEC_ID_QDM2;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/mpeg")) {
++    gint layer = 0;
++    gint mpegversion = 0;
++
++    if (gst_structure_get_int (structure, "mpegversion", &mpegversion)) {
++      switch (mpegversion) {
++        case 2:                /* ffmpeg uses faad for both... */
++        case 4:
++          id = CODEC_ID_AAC;
++          break;
++        case 1:
++          if (gst_structure_get_int (structure, "layer", &layer)) {
++            switch (layer) {
++              case 1:
++                id = CODEC_ID_MP1;
++                break;
++              case 2:
++                id = CODEC_ID_MP2;
++                break;
++              case 3:
++                id = CODEC_ID_MP3;
++                break;
++            }
++          }
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-musepack")) {
++    gint streamversion = -1;
++
++    if (gst_structure_get_int (structure, "streamversion", &streamversion)) {
++      if (streamversion == 7)
++        id = CODEC_ID_MUSEPACK7;
++    } else {
++      id = CODEC_ID_MUSEPACK7;
++    }
++  } else if (!strcmp (mimetype, "audio/x-wma")) {
++    gint wmaversion = 0;
++
++    if (gst_structure_get_int (structure, "wmaversion", &wmaversion)) {
++      switch (wmaversion) {
++        case 1:
++          id = CODEC_ID_WMAV1;
++          break;
++        case 2:
++          id = CODEC_ID_WMAV2;
++          break;
++        case 3:
++          id = CODEC_ID_WMAPRO;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-wms")) {
++    id = CODEC_ID_WMAVOICE;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-ac3")) {
++    id = CODEC_ID_AC3;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-eac3")) {
++    id = CODEC_ID_EAC3;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-vnd.sony.atrac3") ||
++      !strcmp (mimetype, "audio/atrac3")) {
++    id = CODEC_ID_ATRAC3;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-dts")) {
++    id = CODEC_ID_DTS;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "application/x-ape")) {
++    id = CODEC_ID_APE;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-msmpeg")) {
++    gint msmpegversion = 0;
++
++    if (gst_structure_get_int (structure, "msmpegversion", &msmpegversion)) {
++      switch (msmpegversion) {
++        case 41:
++          id = CODEC_ID_MSMPEG4V1;
++          break;
++        case 42:
++          id = CODEC_ID_MSMPEG4V2;
++          break;
++        case 43:
++          id = CODEC_ID_MSMPEG4V3;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-svq")) {
++    gint svqversion = 0;
++
++    if (gst_structure_get_int (structure, "svqversion", &svqversion)) {
++      switch (svqversion) {
++        case 1:
++          id = CODEC_ID_SVQ1;
++          break;
++        case 3:
++          id = CODEC_ID_SVQ3;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-huffyuv")) {
++    id = CODEC_ID_HUFFYUV;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-mace")) {
++    gint maceversion = 0;
++
++    if (gst_structure_get_int (structure, "maceversion", &maceversion)) {
++      switch (maceversion) {
++        case 3:
++          id = CODEC_ID_MACE3;
++          break;
++        case 6:
++          id = CODEC_ID_MACE6;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-theora")) {
++    id = CODEC_ID_THEORA;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-vp3")) {
++    id = CODEC_ID_VP3;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-vp5")) {
++    id = CODEC_ID_VP5;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-vp6")) {
++    id = CODEC_ID_VP6;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-vp6-flash")) {
++    id = CODEC_ID_VP6F;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-vp6-alpha")) {
++    id = CODEC_ID_VP6A;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-vp8")) {
++    id = CODEC_ID_VP8;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-flash-screen")) {
++    id = CODEC_ID_FLASHSV;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-indeo")) {
++    gint indeoversion = 0;
++
++    if (gst_structure_get_int (structure, "indeoversion", &indeoversion)) {
++      switch (indeoversion) {
++        case 5:
++          id = CODEC_ID_INDEO5;
++          break;
++        case 3:
++          id = CODEC_ID_INDEO3;
++          break;
++        case 2:
++          id = CODEC_ID_INDEO2;
++          break;
++      }
++      if (id != CODEC_ID_NONE)
++        video = TRUE;
++    }
++  } else if (!strcmp (mimetype, "video/x-divx")) {
++    gint divxversion = 0;
++
++    if (gst_structure_get_int (structure, "divxversion", &divxversion)) {
++      switch (divxversion) {
++        case 3:
++          id = CODEC_ID_MSMPEG4V3;
++          break;
++        case 4:
++        case 5:
++          id = CODEC_ID_MPEG4;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-3ivx")) {
++    id = CODEC_ID_MPEG4;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-xvid")) {
++    id = CODEC_ID_MPEG4;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-ffv")) {
++    gint ffvversion = 0;
++
++    if (gst_structure_get_int (structure, "ffvversion", &ffvversion) &&
++        ffvversion == 1) {
++      id = CODEC_ID_FFV1;
++      video = TRUE;
++    }
++  } else if (!strcmp (mimetype, "audio/x-adpcm")) {
++    const gchar *layout;
++
++    layout = gst_structure_get_string (structure, "layout");
++    if (layout == NULL) {
++      /* break */
++    } else if (!strcmp (layout, "quicktime")) {
++      id = CODEC_ID_ADPCM_IMA_QT;
++    } else if (!strcmp (layout, "microsoft")) {
++      id = CODEC_ID_ADPCM_MS;
++    } else if (!strcmp (layout, "dvi")) {
++      id = CODEC_ID_ADPCM_IMA_WAV;
++    } else if (!strcmp (layout, "4xm")) {
++      id = CODEC_ID_ADPCM_4XM;
++    } else if (!strcmp (layout, "smjpeg")) {
++      id = CODEC_ID_ADPCM_IMA_SMJPEG;
++    } else if (!strcmp (layout, "dk3")) {
++      id = CODEC_ID_ADPCM_IMA_DK3;
++    } else if (!strcmp (layout, "dk4")) {
++      id = CODEC_ID_ADPCM_IMA_DK4;
++    } else if (!strcmp (layout, "westwood")) {
++      id = CODEC_ID_ADPCM_IMA_WS;
++    } else if (!strcmp (layout, "iss")) {
++      id = CODEC_ID_ADPCM_IMA_ISS;
++    } else if (!strcmp (layout, "xa")) {
++      id = CODEC_ID_ADPCM_XA;
++    } else if (!strcmp (layout, "adx")) {
++      id = CODEC_ID_ADPCM_ADX;
++    } else if (!strcmp (layout, "ea")) {
++      id = CODEC_ID_ADPCM_EA;
++    } else if (!strcmp (layout, "g726")) {
++      id = CODEC_ID_ADPCM_G726;
++    } else if (!strcmp (layout, "g721")) {
++      id = CODEC_ID_ADPCM_G726;
++    } else if (!strcmp (layout, "ct")) {
++      id = CODEC_ID_ADPCM_CT;
++    } else if (!strcmp (layout, "swf")) {
++      id = CODEC_ID_ADPCM_SWF;
++    } else if (!strcmp (layout, "yamaha")) {
++      id = CODEC_ID_ADPCM_YAMAHA;
++    } else if (!strcmp (layout, "sbpro2")) {
++      id = CODEC_ID_ADPCM_SBPRO_2;
++    } else if (!strcmp (layout, "sbpro3")) {
++      id = CODEC_ID_ADPCM_SBPRO_3;
++    } else if (!strcmp (layout, "sbpro4")) {
++      id = CODEC_ID_ADPCM_SBPRO_4;
++    }
++    if (id != CODEC_ID_NONE)
++      audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-4xm")) {
++    id = CODEC_ID_4XM;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-dpcm")) {
++    const gchar *layout;
++
++    layout = gst_structure_get_string (structure, "layout");
++    if (!layout) {
++      /* .. */
++    } else if (!strcmp (layout, "roq")) {
++      id = CODEC_ID_ROQ_DPCM;
++    } else if (!strcmp (layout, "interplay")) {
++      id = CODEC_ID_INTERPLAY_DPCM;
++    } else if (!strcmp (layout, "xan")) {
++      id = CODEC_ID_XAN_DPCM;
++    } else if (!strcmp (layout, "sol")) {
++      id = CODEC_ID_SOL_DPCM;
++    }
++    if (id != CODEC_ID_NONE)
++      audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-flac")) {
++    id = CODEC_ID_FLAC;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-shorten")) {
++    id = CODEC_ID_SHORTEN;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-alac")) {
++    id = CODEC_ID_ALAC;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-cinepak")) {
++    id = CODEC_ID_CINEPAK;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-pn-realvideo")) {
++    gint rmversion;
++
++    if (gst_structure_get_int (structure, "rmversion", &rmversion)) {
++      switch (rmversion) {
++        case 1:
++          id = CODEC_ID_RV10;
++          break;
++        case 2:
++          id = CODEC_ID_RV20;
++          break;
++        case 3:
++          id = CODEC_ID_RV30;
++          break;
++        case 4:
++          id = CODEC_ID_RV40;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      video = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-sipro")) {
++    id = CODEC_ID_SIPR;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-pn-realaudio")) {
++    gint raversion;
++
++    if (gst_structure_get_int (structure, "raversion", &raversion)) {
++      switch (raversion) {
++        case 1:
++          id = CODEC_ID_RA_144;
++          break;
++        case 2:
++          id = CODEC_ID_RA_288;
++          break;
++        case 8:
++          id = CODEC_ID_COOK;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-rle")) {
++    const gchar *layout;
++
++    if ((layout = gst_structure_get_string (structure, "layout"))) {
++      if (!strcmp (layout, "microsoft")) {
++        id = CODEC_ID_MSRLE;
++        video = TRUE;
++      }
++    }
++  } else if (!strcmp (mimetype, "video/x-xan")) {
++    gint wcversion = 0;
++
++    if ((gst_structure_get_int (structure, "wcversion", &wcversion))) {
++      switch (wcversion) {
++        case 3:
++          id = CODEC_ID_XAN_WC3;
++          video = TRUE;
++          break;
++        case 4:
++          id = CODEC_ID_XAN_WC4;
++          video = TRUE;
++          break;
++        default:
++          break;
++      }
++    }
++  } else if (!strcmp (mimetype, "audio/AMR")) {
++    audio = TRUE;
++    id = CODEC_ID_AMR_NB;
++  } else if (!strcmp (mimetype, "audio/AMR-WB")) {
++    id = CODEC_ID_AMR_WB;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/qcelp")) {
++    id = CODEC_ID_QCELP;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-h264")) {
++    id = CODEC_ID_H264;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-flash-video")) {
++    gint flvversion = 0;
++
++    if ((gst_structure_get_int (structure, "flvversion", &flvversion))) {
++      switch (flvversion) {
++        case 1:
++          id = CODEC_ID_FLV1;
++          video = TRUE;
++          break;
++        default:
++          break;
++      }
++    }
++
++  } else if (!strcmp (mimetype, "audio/x-nellymoser")) {
++    id = CODEC_ID_NELLYMOSER;
++    audio = TRUE;
++  } else if (!strncmp (mimetype, "audio/x-gst_ff-", 15)) {
++    gchar ext[16];
++    AVCodec *codec;
++
++    if (strlen (mimetype) <= 30 &&
++        sscanf (mimetype, "audio/x-gst_ff-%s", ext) == 1) {
++      if ((codec = avcodec_find_decoder_by_name (ext)) ||
++          (codec = avcodec_find_encoder_by_name (ext))) {
++        id = codec->id;
++        audio = TRUE;
++      }
++    }
++  } else if (!strncmp (mimetype, "video/x-gst_ff-", 15)) {
++    gchar ext[16];
++    AVCodec *codec;
++
++    if (strlen (mimetype) <= 30 &&
++        sscanf (mimetype, "video/x-gst_ff-%s", ext) == 1) {
++      if ((codec = avcodec_find_decoder_by_name (ext)) ||
++          (codec = avcodec_find_encoder_by_name (ext))) {
++        id = codec->id;
++        video = TRUE;
++      }
++    }
++  }
++
++  if (context != NULL) {
++    if (video == TRUE) {
++      context->codec_type = AVMEDIA_TYPE_VIDEO;
++    } else if (audio == TRUE) {
++      context->codec_type = AVMEDIA_TYPE_AUDIO;
++    } else {
++      context->codec_type = AVMEDIA_TYPE_UNKNOWN;
++    }
++    context->codec_id = id;
++    gst_ffmpeg_caps_with_codecid (id, context->codec_type, caps, context);
++  }
++
++  if (id != CODEC_ID_NONE) {
++    GST_DEBUG ("The id=%d belongs to the caps %" GST_PTR_FORMAT, id, caps);
++  } else {
++    GST_WARNING ("Couldn't figure out the id for caps %" GST_PTR_FORMAT, caps);
++  }
++
++  return id;
++}
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.rej gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.rej
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.rej	1970-01-01 01:00:00.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.rej	2014-08-08 15:31:06.055868246 +0200
+@@ -0,0 +1,12 @@
++--- ext/ffmpeg/gstffmpegcodecmap.c
+++++ ext/ffmpeg/gstffmpegcodecmap.c
++@@ -1884,9 +1842,6 @@
++             gst_ff_vid_caps_new (context, codec_id, encode, "video/x-raw-rgb",
++             "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, "endianness",
++             G_TYPE_INT, endianness, NULL);
++-        if (caps && context) {
++-          gst_ffmpeg_set_palette (caps, context);
++-        }
++       }
++     } else if (fmt) {
++       caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-raw-yuv",
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c	2014-08-08 14:46:31.462772351 +0200
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c	2014-08-08 15:32:18.608870847 +0200
+@@ -88,7 +88,6 @@
+       gint depth;
+     } audio;
+   } format;
+-  gboolean waiting_for_key;
+   gboolean discont;
+   gboolean clear_ts;
+ 
+@@ -438,7 +437,6 @@
+   ffmpegdec->pcache = NULL;
+   ffmpegdec->par = NULL;
+   ffmpegdec->opened = FALSE;
+-  ffmpegdec->waiting_for_key = TRUE;
+   ffmpegdec->skip_frame = ffmpegdec->lowres = 0;
+   ffmpegdec->direct_rendering = DEFAULT_DIRECT_RENDERING;
+   ffmpegdec->do_padding = DEFAULT_DO_PADDING;
+@@ -608,11 +606,6 @@
+     gst_ffmpeg_avcodec_close (ffmpegdec->context);
+   ffmpegdec->opened = FALSE;
+ 
+-  if (ffmpegdec->context->palctrl) {
+-    av_free (ffmpegdec->context->palctrl);
+-    ffmpegdec->context->palctrl = NULL;
+-  }
+-
+   if (ffmpegdec->context->extradata) {
+     av_free (ffmpegdec->context->extradata);
+     ffmpegdec->context->extradata = NULL;
+@@ -864,7 +857,7 @@
+ 
+   /* workaround encoder bugs */
+   ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
+-  ffmpegdec->context->error_recognition = 1;
++  ffmpegdec->context->err_recognition = 1;
+ 
+   /* for slow cpus */
+   ffmpegdec->context->lowres = ffmpegdec->lowres;
+@@ -944,7 +937,7 @@
+   fsize = gst_ffmpeg_avpicture_get_size (ffmpegdec->context->pix_fmt,
+       width, height);
+ 
+-  if (!ffmpegdec->context->palctrl && ffmpegdec->can_allocate_aligned) {
++  if (ffmpegdec->can_allocate_aligned) {
+     GST_LOG_OBJECT (ffmpegdec, "calling pad_alloc");
+     /* no pallete, we can use the buffer size to alloc */
+     ret = gst_pad_alloc_buffer_and_set_caps (ffmpegdec->srcpad,
+@@ -1083,7 +1076,6 @@
+   /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to
+    * the opaque data. */
+   picture->type = FF_BUFFER_TYPE_USER;
+-  picture->age = 256 * 256 * 256 * 64;
+   picture->opaque = buf;
+ 
+ #ifdef EXTRA_REF
+@@ -1414,10 +1406,6 @@
+   } else {
+     if (diff >= 0) {
+       /* we're too slow, try to speed up */
+-      if (ffmpegdec->waiting_for_key) {
+-        /* we were waiting for a keyframe, that's ok */
+-        goto skipping;
+-      }
+       /* switch to skip_frame mode */
+       goto skip_frame;
+     }
+@@ -1427,11 +1415,6 @@
+   ffmpegdec->processed++;
+   return TRUE;
+ 
+-skipping:
+-  {
+-    res = FALSE;
+-    goto drop_qos;
+-  }
+ normal_mode:
+   {
+     if (ffmpegdec->context->skip_frame != AVDISCARD_DEFAULT) {
+@@ -1528,43 +1511,6 @@
+ }
+ 
+ 
+-/* figure out if the current picture is a keyframe, return TRUE if that is
+- * the case. */
+-static gboolean
+-check_keyframe (GstFFMpegDec * ffmpegdec)
+-{
+-  GstFFMpegDecClass *oclass;
+-  gboolean is_itype = FALSE;
+-  gboolean is_reference = FALSE;
+-  gboolean iskeyframe;
+-
+-  /* figure out if we are dealing with a keyframe */
+-  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+-
+-  /* remember that we have B frames, we need this for the DTS -> PTS conversion
+-   * code */
+-  if (!ffmpegdec->has_b_frames && ffmpegdec->picture->pict_type == FF_B_TYPE) {
+-    GST_DEBUG_OBJECT (ffmpegdec, "we have B frames");
+-    ffmpegdec->has_b_frames = TRUE;
+-  }
+-
+-  is_itype = (ffmpegdec->picture->pict_type == FF_I_TYPE);
+-  is_reference = (ffmpegdec->picture->reference == 1);
+-
+-  iskeyframe = (is_itype || is_reference || ffmpegdec->picture->key_frame)
+-      || (oclass->in_plugin->id == CODEC_ID_INDEO3)
+-      || (oclass->in_plugin->id == CODEC_ID_MSZH)
+-      || (oclass->in_plugin->id == CODEC_ID_ZLIB)
+-      || (oclass->in_plugin->id == CODEC_ID_VP3)
+-      || (oclass->in_plugin->id == CODEC_ID_HUFFYUV);
+-
+-  GST_LOG_OBJECT (ffmpegdec,
+-      "current picture: type: %d, is_keyframe:%d, is_itype:%d, is_reference:%d",
+-      ffmpegdec->picture->pict_type, iskeyframe, is_itype, is_reference);
+-
+-  return iskeyframe;
+-}
+-
+ /* get an outbuf buffer with the current picture */
+ static GstFlowReturn
+ get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
+@@ -1694,7 +1640,6 @@
+ {
+   gint len = -1;
+   gint have_data;
+-  gboolean iskeyframe;
+   gboolean mode_switch;
+   gboolean decode;
+   gint skip_frame = AVDISCARD_DEFAULT;
+@@ -1809,7 +1754,6 @@
+     gst_ffmpegdec_negotiate (ffmpegdec, TRUE);
+   }
+ 
+-
+   /* Whether a frame is interlaced or not is unknown at the time of
+      buffer allocation, so caps on the buffer in opaque will have
+      the previous frame's interlaced flag set. So if interlacedness
+@@ -1831,10 +1775,6 @@
+     }
+   }
+ 
+-  /* check if we are dealing with a keyframe here, this will also check if we
+-   * are dealing with B frames. */
+-  iskeyframe = check_keyframe (ffmpegdec);
+-
+   /* check that the timestamps go upwards */
+   if (ffmpegdec->last_out != -1 && ffmpegdec->last_out > out_pts) {
+     /* timestamps go backwards, this means frames were reordered and we must
+@@ -1865,7 +1805,7 @@
+    * timestamps */
+   if (!ffmpegdec->reordered_in && ffmpegdec->reordered_out) {
+     /* PTS and DTS are the same for keyframes */
+-    if (!iskeyframe && ffmpegdec->next_out != -1) {
++    if (ffmpegdec->next_out != -1) {
+       /* interpolate all timestamps except for keyframes, FIXME, this is
+        * wrong when QoS is active. */
+       GST_DEBUG_OBJECT (ffmpegdec, "interpolate timestamps");
+@@ -1874,16 +1814,6 @@
+     }
+   }
+ 
+-  /* when we're waiting for a keyframe, see if we have one or drop the current
+-   * non-keyframe */
+-  if (G_UNLIKELY (ffmpegdec->waiting_for_key)) {
+-    if (G_LIKELY (!iskeyframe))
+-      goto drop_non_keyframe;
+-
+-    /* we have a keyframe, we can stop waiting for one */
+-    ffmpegdec->waiting_for_key = FALSE;
+-  }
+-
+   /* get a handle to the output buffer */
+   *ret = get_output_buffer (ffmpegdec, outbuf);
+   if (G_UNLIKELY (*ret != GST_FLOW_OK))
+@@ -2000,20 +1930,11 @@
+   else
+     ffmpegdec->next_out = -1;
+ 
+-  /* palette is not part of raw video frame in gst and the size
+-   * of the outgoing buffer needs to be adjusted accordingly */
+-  if (ffmpegdec->context->palctrl != NULL)
+-    GST_BUFFER_SIZE (*outbuf) -= AVPALETTE_SIZE;
+-
+   /* now see if we need to clip the buffer against the segment boundaries. */
+   if (G_UNLIKELY (!clip_video_buffer (ffmpegdec, *outbuf, out_timestamp,
+               out_duration)))
+     goto clipped;
+ 
+-  /* mark as keyframe or delta unit */
+-  if (!iskeyframe)
+-    GST_BUFFER_FLAG_SET (*outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
+-
+   if (ffmpegdec->picture->top_field_first)
+     GST_BUFFER_FLAG_SET (*outbuf, GST_VIDEO_BUFFER_TFF);
+ 
+@@ -2024,11 +1945,6 @@
+   return len;
+ 
+   /* special cases */
+-drop_non_keyframe:
+-  {
+-    GST_WARNING_OBJECT (ffmpegdec, "Dropping non-keyframe (seek/init)");
+-    goto beach;
+-  }
+ no_output:
+   {
+     GST_DEBUG_OBJECT (ffmpegdec, "no output buffer");
+@@ -2422,7 +2338,6 @@
+       gst_ffmpegdec_reset_ts (ffmpegdec);
+       gst_ffmpegdec_reset_qos (ffmpegdec);
+       gst_ffmpegdec_flush_pcache (ffmpegdec);
+-      ffmpegdec->waiting_for_key = TRUE;
+       gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
+       clear_queued (ffmpegdec);
+       break;
+@@ -2560,17 +2475,6 @@
+ 
+   oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+ 
+-  /* do early keyframe check pretty bad to rely on the keyframe flag in the
+-   * source for this as it might not even be parsed (UDP/file/..).  */
+-  if (G_UNLIKELY (ffmpegdec->waiting_for_key)) {
+-    GST_DEBUG_OBJECT (ffmpegdec, "waiting for keyframe");
+-    if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_DELTA_UNIT) &&
+-        oclass->in_plugin->type != AVMEDIA_TYPE_AUDIO)
+-      goto skip_keyframe;
+-
+-    GST_DEBUG_OBJECT (ffmpegdec, "got keyframe");
+-    ffmpegdec->waiting_for_key = FALSE;
+-  }
+   /* parse cache joining. If there is cached data */
+   if (ffmpegdec->pcache) {
+     /* join with previous data */
+@@ -2805,12 +2709,6 @@
+     gst_buffer_unref (inbuf);
+     return GST_FLOW_NOT_NEGOTIATED;
+   }
+-skip_keyframe:
+-  {
+-    GST_DEBUG_OBJECT (ffmpegdec, "skipping non keyframe");
+-    gst_buffer_unref (inbuf);
+-    return GST_FLOW_OK;
+-  }
+ }
+ 
+ static GstStateChangeReturn
+@@ -2936,7 +2834,7 @@
+     gchar *plugin_name;
+ 
+     /* only decoders */
+-    if (!in_plugin->decode) {
++    if (!av_codec_is_decoder (in_plugin)) {
+       goto next;
+     }
+ 
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.orig
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.orig	1970-01-01 01:00:00.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.orig	2014-08-08 15:31:06.057868246 +0200
+@@ -0,0 +1,2973 @@
++/* 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 <assert.h>
++#include <string.h>
++
++#ifdef HAVE_FFMPEG_UNINSTALLED
++#include <avcodec.h>
++#else
++#include <libavcodec/avcodec.h>
++#endif
++
++#include <gst/gst.h>
++#include <gst/video/video.h>
++
++#include "gstffmpeg.h"
++#include "gstffmpegcodecmap.h"
++#include "gstffmpegutils.h"
++
++/* define to enable alternative buffer refcounting algorithm */
++#undef EXTRA_REF
++
++typedef struct _GstFFMpegDec GstFFMpegDec;
++
++#define MAX_TS_MASK 0xff
++
++/* for each incomming buffer we keep all timing info in a structure like this.
++ * We keep a circular array of these structures around to store the timing info.
++ * The index in the array is what we pass as opaque data (to pictures) and
++ * pts (to parsers) so that ffmpeg can remember them for us. */
++typedef struct
++{
++  gint idx;
++  GstClockTime timestamp;
++  GstClockTime duration;
++  gint64 offset;
++} GstTSInfo;
++
++struct _GstFFMpegDec
++{
++  GstElement element;
++
++  /* We need to keep track of our pads, so we do so here. */
++  GstPad *srcpad;
++  GstPad *sinkpad;
++
++  /* decoding */
++  AVCodecContext *context;
++  AVFrame *picture;
++  gboolean opened;
++  union
++  {
++    struct
++    {
++      gint width, height;
++      gint clip_width, clip_height;
++      gint par_n, par_d;
++      gint fps_n, fps_d;
++      gint old_fps_n, old_fps_d;
++      gboolean interlaced;
++
++      enum PixelFormat pix_fmt;
++    } video;
++    struct
++    {
++      gint channels;
++      gint samplerate;
++      gint depth;
++    } audio;
++  } format;
++  gboolean discont;
++  gboolean clear_ts;
++
++  /* for tracking DTS/PTS */
++  gboolean has_b_frames;
++  gboolean reordered_in;
++  GstClockTime last_in;
++  GstClockTime last_diff;
++  guint last_frames;
++  gboolean reordered_out;
++  GstClockTime last_out;
++  GstClockTime next_out;
++
++  /* parsing */
++  gboolean turnoff_parser;      /* used for turning off aac raw parsing
++                                 * See bug #566250 */
++  AVCodecParserContext *pctx;
++  GstBuffer *pcache;
++  guint8 *padded;
++  guint padded_size;
++
++  GValue *par;                  /* pixel aspect ratio of incoming data */
++  gboolean current_dr;          /* if direct rendering is enabled */
++  gboolean extra_ref;           /* keep extra ref around in get/release */
++
++  /* some properties */
++  enum AVDiscard skip_frame;
++  gint lowres;
++  gboolean direct_rendering;
++  gboolean do_padding;
++  gboolean debug_mv;
++  gboolean crop;
++  int max_threads;
++
++  /* QoS stuff *//* with LOCK */
++  gdouble proportion;
++  GstClockTime earliest_time;
++  gint64 processed;
++  gint64 dropped;
++
++  /* clipping segment */
++  GstSegment segment;
++
++  gboolean is_realvideo;
++
++  GstTSInfo ts_info[MAX_TS_MASK + 1];
++  gint ts_idx;
++
++  /* reverse playback queue */
++  GList *queued;
++
++  /* Can downstream allocate 16bytes aligned data. */
++  gboolean can_allocate_aligned;
++};
++
++typedef struct _GstFFMpegDecClass GstFFMpegDecClass;
++
++struct _GstFFMpegDecClass
++{
++  GstElementClass parent_class;
++
++  AVCodec *in_plugin;
++  GstPadTemplate *srctempl, *sinktempl;
++};
++
++#define GST_TS_INFO_NONE &ts_info_none
++static const GstTSInfo ts_info_none = { -1, -1, -1, -1 };
++
++static const GstTSInfo *
++gst_ts_info_store (GstFFMpegDec * dec, GstClockTime timestamp,
++    GstClockTime duration, gint64 offset)
++{
++  gint idx = dec->ts_idx;
++  dec->ts_info[idx].idx = idx;
++  dec->ts_info[idx].timestamp = timestamp;
++  dec->ts_info[idx].duration = duration;
++  dec->ts_info[idx].offset = offset;
++  dec->ts_idx = (idx + 1) & MAX_TS_MASK;
++
++  return &dec->ts_info[idx];
++}
++
++static const GstTSInfo *
++gst_ts_info_get (GstFFMpegDec * dec, gint idx)
++{
++  if (G_UNLIKELY (idx < 0 || idx > MAX_TS_MASK))
++    return GST_TS_INFO_NONE;
++
++  return &dec->ts_info[idx];
++}
++
++#define GST_TYPE_FFMPEGDEC \
++  (gst_ffmpegdec_get_type())
++#define GST_FFMPEGDEC(obj) \
++  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGDEC,GstFFMpegDec))
++#define GST_FFMPEGDEC_CLASS(klass) \
++  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGDEC,GstFFMpegDecClass))
++#define GST_IS_FFMPEGDEC(obj) \
++  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGDEC))
++#define GST_IS_FFMPEGDEC_CLASS(klass) \
++  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGDEC))
++
++#define DEFAULT_LOWRES			0
++#define DEFAULT_SKIPFRAME		0
++#define DEFAULT_DIRECT_RENDERING	TRUE
++#define DEFAULT_DO_PADDING		TRUE
++#define DEFAULT_DEBUG_MV		FALSE
++#define DEFAULT_CROP			TRUE
++#define DEFAULT_MAX_THREADS		1
++
++enum
++{
++  PROP_0,
++  PROP_LOWRES,
++  PROP_SKIPFRAME,
++  PROP_DIRECT_RENDERING,
++  PROP_DO_PADDING,
++  PROP_DEBUG_MV,
++  PROP_CROP,
++  PROP_MAX_THREADS,
++  PROP_LAST
++};
++
++/* A number of function prototypes are given so we can refer to them later. */
++static void gst_ffmpegdec_base_init (GstFFMpegDecClass * klass);
++static void gst_ffmpegdec_class_init (GstFFMpegDecClass * klass);
++static void gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec);
++static void gst_ffmpegdec_finalize (GObject * object);
++
++static gboolean gst_ffmpegdec_query (GstPad * pad, GstQuery * query);
++static gboolean gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event);
++
++static gboolean gst_ffmpegdec_setcaps (GstPad * pad, GstCaps * caps);
++static gboolean gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event);
++static GstFlowReturn gst_ffmpegdec_chain (GstPad * pad, GstBuffer * buf);
++
++static GstStateChangeReturn gst_ffmpegdec_change_state (GstElement * element,
++    GstStateChange transition);
++
++static void gst_ffmpegdec_set_property (GObject * object,
++    guint prop_id, const GValue * value, GParamSpec * pspec);
++static void gst_ffmpegdec_get_property (GObject * object,
++    guint prop_id, GValue * value, GParamSpec * pspec);
++
++static gboolean gst_ffmpegdec_negotiate (GstFFMpegDec * ffmpegdec,
++    gboolean force);
++
++/* some sort of bufferpool handling, but different */
++static int gst_ffmpegdec_get_buffer (AVCodecContext * context,
++    AVFrame * picture);
++static void gst_ffmpegdec_release_buffer (AVCodecContext * context,
++    AVFrame * picture);
++
++static void gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec);
++
++#define GST_FFDEC_PARAMS_QDATA g_quark_from_static_string("ffdec-params")
++
++static GstElementClass *parent_class = NULL;
++
++#define GST_FFMPEGDEC_TYPE_LOWRES (gst_ffmpegdec_lowres_get_type())
++static GType
++gst_ffmpegdec_lowres_get_type (void)
++{
++  static GType ffmpegdec_lowres_type = 0;
++
++  if (!ffmpegdec_lowres_type) {
++    static const GEnumValue ffmpegdec_lowres[] = {
++      {0, "0", "full"},
++      {1, "1", "1/2-size"},
++      {2, "2", "1/4-size"},
++      {0, NULL, NULL},
++    };
++
++    ffmpegdec_lowres_type =
++        g_enum_register_static ("GstFFMpegDecLowres", ffmpegdec_lowres);
++  }
++
++  return ffmpegdec_lowres_type;
++}
++
++#define GST_FFMPEGDEC_TYPE_SKIPFRAME (gst_ffmpegdec_skipframe_get_type())
++static GType
++gst_ffmpegdec_skipframe_get_type (void)
++{
++  static GType ffmpegdec_skipframe_type = 0;
++
++  if (!ffmpegdec_skipframe_type) {
++    static const GEnumValue ffmpegdec_skipframe[] = {
++      {0, "0", "Skip nothing"},
++      {1, "1", "Skip B-frames"},
++      {2, "2", "Skip IDCT/Dequantization"},
++      {5, "5", "Skip everything"},
++      {0, NULL, NULL},
++    };
++
++    ffmpegdec_skipframe_type =
++        g_enum_register_static ("GstFFMpegDecSkipFrame", ffmpegdec_skipframe);
++  }
++
++  return ffmpegdec_skipframe_type;
++}
++
++static void
++gst_ffmpegdec_base_init (GstFFMpegDecClass * klass)
++{
++  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
++  GstPadTemplate *sinktempl, *srctempl;
++  GstCaps *sinkcaps, *srccaps;
++  AVCodec *in_plugin;
++  gchar *longname, *classification, *description;
++
++  in_plugin =
++      (AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
++      GST_FFDEC_PARAMS_QDATA);
++  g_assert (in_plugin != NULL);
++
++  /* construct the element details struct */
++  longname = g_strdup_printf ("FFmpeg %s decoder", in_plugin->long_name);
++  classification = g_strdup_printf ("Codec/Decoder/%s",
++      (in_plugin->type == AVMEDIA_TYPE_VIDEO) ? "Video" : "Audio");
++  description = g_strdup_printf ("FFmpeg %s decoder", in_plugin->name);
++  gst_element_class_set_details_simple (element_class, longname, classification,
++      description,
++      "Wim Taymans <wim.taymans@gmail.com>, "
++      "Ronald Bultje <rbultje@ronald.bitfreak.net>, "
++      "Edward Hervey <bilboed@bilboed.com>");
++  g_free (longname);
++  g_free (classification);
++  g_free (description);
++
++  /* get the caps */
++  sinkcaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, FALSE);
++  if (!sinkcaps) {
++    GST_DEBUG ("Couldn't get sink caps for decoder '%s'", in_plugin->name);
++    sinkcaps = gst_caps_from_string ("unknown/unknown");
++  }
++  if (in_plugin->type == AVMEDIA_TYPE_VIDEO) {
++    srccaps = gst_caps_from_string ("video/x-raw-rgb; video/x-raw-yuv");
++  } else {
++    srccaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
++        in_plugin->id, FALSE, in_plugin);
++  }
++  if (!srccaps) {
++    GST_DEBUG ("Couldn't get source caps for decoder '%s'", in_plugin->name);
++    srccaps = gst_caps_from_string ("unknown/unknown");
++  }
++
++  /* pad templates */
++  sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
++      GST_PAD_ALWAYS, sinkcaps);
++  srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
++
++  gst_element_class_add_pad_template (element_class, srctempl);
++  gst_element_class_add_pad_template (element_class, sinktempl);
++
++  klass->in_plugin = in_plugin;
++  klass->srctempl = srctempl;
++  klass->sinktempl = sinktempl;
++}
++
++static void
++gst_ffmpegdec_class_init (GstFFMpegDecClass * klass)
++{
++  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
++  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
++
++  parent_class = g_type_class_peek_parent (klass);
++
++  gobject_class->finalize = gst_ffmpegdec_finalize;
++
++  gobject_class->set_property = gst_ffmpegdec_set_property;
++  gobject_class->get_property = gst_ffmpegdec_get_property;
++
++  if (klass->in_plugin->type == AVMEDIA_TYPE_VIDEO) {
++    int caps;
++
++    g_object_class_install_property (gobject_class, PROP_SKIPFRAME,
++        g_param_spec_enum ("skip-frame", "Skip frames",
++            "Which types of frames to skip during decoding",
++            GST_FFMPEGDEC_TYPE_SKIPFRAME, 0,
++            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++    g_object_class_install_property (gobject_class, PROP_LOWRES,
++        g_param_spec_enum ("lowres", "Low resolution",
++            "At which resolution to decode images", GST_FFMPEGDEC_TYPE_LOWRES,
++            0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++    g_object_class_install_property (gobject_class, PROP_DIRECT_RENDERING,
++        g_param_spec_boolean ("direct-rendering", "Direct Rendering",
++            "Enable direct rendering", DEFAULT_DIRECT_RENDERING,
++            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++    g_object_class_install_property (gobject_class, PROP_DO_PADDING,
++        g_param_spec_boolean ("do-padding", "Do Padding",
++            "Add 0 padding before decoding data", DEFAULT_DO_PADDING,
++            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++    g_object_class_install_property (gobject_class, PROP_DEBUG_MV,
++        g_param_spec_boolean ("debug-mv", "Debug motion vectors",
++            "Whether ffmpeg should print motion vectors on top of the image",
++            DEFAULT_DEBUG_MV, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++#if 0
++    g_object_class_install_property (gobject_class, PROP_CROP,
++        g_param_spec_boolean ("crop", "Crop",
++            "Crop images to the display region",
++            DEFAULT_CROP, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++#endif
++
++    caps = klass->in_plugin->capabilities;
++    if (caps & (CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS)) {
++      g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_THREADS,
++          g_param_spec_int ("max-threads", "Maximum decode threads",
++              "Maximum number of worker threads to spawn. (0 = auto)",
++              0, G_MAXINT, DEFAULT_MAX_THREADS,
++              G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++    }
++  }
++
++  gstelement_class->change_state = gst_ffmpegdec_change_state;
++}
++
++static void
++gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec)
++{
++  GstFFMpegDecClass *oclass;
++
++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++
++  /* setup pads */
++  ffmpegdec->sinkpad = gst_pad_new_from_template (oclass->sinktempl, "sink");
++  gst_pad_set_setcaps_function (ffmpegdec->sinkpad,
++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_setcaps));
++  gst_pad_set_event_function (ffmpegdec->sinkpad,
++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_sink_event));
++  gst_pad_set_chain_function (ffmpegdec->sinkpad,
++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_chain));
++  gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->sinkpad);
++
++  ffmpegdec->srcpad = gst_pad_new_from_template (oclass->srctempl, "src");
++  gst_pad_use_fixed_caps (ffmpegdec->srcpad);
++  gst_pad_set_event_function (ffmpegdec->srcpad,
++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_src_event));
++  gst_pad_set_query_function (ffmpegdec->srcpad,
++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_query));
++  gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->srcpad);
++
++  /* some ffmpeg data */
++  ffmpegdec->context = avcodec_alloc_context ();
++  ffmpegdec->picture = avcodec_alloc_frame ();
++  ffmpegdec->pctx = NULL;
++  ffmpegdec->pcache = NULL;
++  ffmpegdec->par = NULL;
++  ffmpegdec->opened = FALSE;
++  ffmpegdec->skip_frame = ffmpegdec->lowres = 0;
++  ffmpegdec->direct_rendering = DEFAULT_DIRECT_RENDERING;
++  ffmpegdec->do_padding = DEFAULT_DO_PADDING;
++  ffmpegdec->debug_mv = DEFAULT_DEBUG_MV;
++  ffmpegdec->crop = DEFAULT_CROP;
++  ffmpegdec->max_threads = DEFAULT_MAX_THREADS;
++
++  ffmpegdec->format.video.par_n = -1;
++  ffmpegdec->format.video.fps_n = -1;
++  ffmpegdec->format.video.old_fps_n = -1;
++  gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
++
++  /* We initially assume downstream can allocate 16 bytes aligned buffers */
++  ffmpegdec->can_allocate_aligned = TRUE;
++}
++
++static void
++gst_ffmpegdec_finalize (GObject * object)
++{
++  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
++
++  if (ffmpegdec->context != NULL) {
++    av_free (ffmpegdec->context);
++    ffmpegdec->context = NULL;
++  }
++
++  if (ffmpegdec->picture != NULL) {
++    av_free (ffmpegdec->picture);
++    ffmpegdec->picture = NULL;
++  }
++
++  G_OBJECT_CLASS (parent_class)->finalize (object);
++}
++
++static gboolean
++gst_ffmpegdec_query (GstPad * pad, GstQuery * query)
++{
++  GstFFMpegDec *ffmpegdec;
++  GstPad *peer;
++  gboolean res;
++
++  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
++
++  res = FALSE;
++
++  if ((peer = gst_pad_get_peer (ffmpegdec->sinkpad))) {
++    /* just forward to peer */
++    res = gst_pad_query (peer, query);
++    gst_object_unref (peer);
++  }
++#if 0
++  {
++    GstFormat bfmt;
++
++    bfmt = GST_FORMAT_BYTES;
++
++    /* ok, do bitrate calc... */
++    if ((type != GST_QUERY_POSITION && type != GST_QUERY_TOTAL) ||
++        *fmt != GST_FORMAT_TIME || ffmpegdec->context->bit_rate == 0 ||
++        !gst_pad_query (peer, type, &bfmt, value))
++      return FALSE;
++
++    if (ffmpegdec->pcache && type == GST_QUERY_POSITION)
++      *value -= GST_BUFFER_SIZE (ffmpegdec->pcache);
++    *value *= GST_SECOND / ffmpegdec->context->bit_rate;
++  }
++#endif
++
++  gst_object_unref (ffmpegdec);
++
++  return res;
++}
++
++static void
++gst_ffmpegdec_reset_ts (GstFFMpegDec * ffmpegdec)
++{
++  ffmpegdec->last_in = GST_CLOCK_TIME_NONE;
++  ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
++  ffmpegdec->last_frames = 0;
++  ffmpegdec->last_out = GST_CLOCK_TIME_NONE;
++  ffmpegdec->next_out = GST_CLOCK_TIME_NONE;
++  ffmpegdec->reordered_in = FALSE;
++  ffmpegdec->reordered_out = FALSE;
++}
++
++static void
++gst_ffmpegdec_update_qos (GstFFMpegDec * ffmpegdec, gdouble proportion,
++    GstClockTime timestamp)
++{
++  GST_LOG_OBJECT (ffmpegdec, "update QOS: %f, %" GST_TIME_FORMAT,
++      proportion, GST_TIME_ARGS (timestamp));
++
++  GST_OBJECT_LOCK (ffmpegdec);
++  ffmpegdec->proportion = proportion;
++  ffmpegdec->earliest_time = timestamp;
++  GST_OBJECT_UNLOCK (ffmpegdec);
++}
++
++static void
++gst_ffmpegdec_reset_qos (GstFFMpegDec * ffmpegdec)
++{
++  gst_ffmpegdec_update_qos (ffmpegdec, 0.5, GST_CLOCK_TIME_NONE);
++  ffmpegdec->processed = 0;
++  ffmpegdec->dropped = 0;
++}
++
++static void
++gst_ffmpegdec_read_qos (GstFFMpegDec * ffmpegdec, gdouble * proportion,
++    GstClockTime * timestamp)
++{
++  GST_OBJECT_LOCK (ffmpegdec);
++  *proportion = ffmpegdec->proportion;
++  *timestamp = ffmpegdec->earliest_time;
++  GST_OBJECT_UNLOCK (ffmpegdec);
++}
++
++static gboolean
++gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event)
++{
++  GstFFMpegDec *ffmpegdec;
++  gboolean res;
++
++  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
++
++  switch (GST_EVENT_TYPE (event)) {
++    case GST_EVENT_QOS:
++    {
++      gdouble proportion;
++      GstClockTimeDiff diff;
++      GstClockTime timestamp;
++
++      gst_event_parse_qos (event, &proportion, &diff, &timestamp);
++
++      /* update our QoS values */
++      gst_ffmpegdec_update_qos (ffmpegdec, proportion, timestamp + diff);
++
++      /* forward upstream */
++      res = gst_pad_push_event (ffmpegdec->sinkpad, event);
++      break;
++    }
++    default:
++      /* forward upstream */
++      res = gst_pad_push_event (ffmpegdec->sinkpad, event);
++      break;
++  }
++
++  gst_object_unref (ffmpegdec);
++
++  return res;
++}
++
++/* with LOCK */
++static void
++gst_ffmpegdec_close (GstFFMpegDec * ffmpegdec)
++{
++  if (!ffmpegdec->opened)
++    return;
++
++  GST_LOG_OBJECT (ffmpegdec, "closing ffmpeg codec");
++
++  if (ffmpegdec->par) {
++    g_free (ffmpegdec->par);
++    ffmpegdec->par = NULL;
++  }
++
++  if (ffmpegdec->context->priv_data)
++    gst_ffmpeg_avcodec_close (ffmpegdec->context);
++  ffmpegdec->opened = FALSE;
++
++  if (ffmpegdec->context->extradata) {
++    av_free (ffmpegdec->context->extradata);
++    ffmpegdec->context->extradata = NULL;
++  }
++
++  if (ffmpegdec->pctx) {
++    if (ffmpegdec->pcache) {
++      gst_buffer_unref (ffmpegdec->pcache);
++      ffmpegdec->pcache = NULL;
++    }
++    av_parser_close (ffmpegdec->pctx);
++    ffmpegdec->pctx = NULL;
++  }
++
++  ffmpegdec->format.video.par_n = -1;
++  ffmpegdec->format.video.fps_n = -1;
++  ffmpegdec->format.video.old_fps_n = -1;
++  ffmpegdec->format.video.interlaced = FALSE;
++}
++
++/* with LOCK */
++static gboolean
++gst_ffmpegdec_open (GstFFMpegDec * ffmpegdec)
++{
++  GstFFMpegDecClass *oclass;
++
++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++
++  if (gst_ffmpeg_avcodec_open (ffmpegdec->context, oclass->in_plugin) < 0)
++    goto could_not_open;
++
++  ffmpegdec->opened = TRUE;
++  ffmpegdec->is_realvideo = FALSE;
++
++  GST_LOG_OBJECT (ffmpegdec, "Opened ffmpeg codec %s, id %d",
++      oclass->in_plugin->name, oclass->in_plugin->id);
++
++  /* open a parser if we can */
++  switch (oclass->in_plugin->id) {
++    case CODEC_ID_MPEG4:
++    case CODEC_ID_MJPEG:
++    case CODEC_ID_VC1:
++      GST_LOG_OBJECT (ffmpegdec, "not using parser, blacklisted codec");
++      ffmpegdec->pctx = NULL;
++      break;
++    case CODEC_ID_H264:
++      /* For H264, only use a parser if there is no context data, if there is, 
++       * we're talking AVC */
++      if (ffmpegdec->context->extradata_size == 0) {
++        GST_LOG_OBJECT (ffmpegdec, "H264 with no extradata, creating parser");
++        ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
++      } else {
++        GST_LOG_OBJECT (ffmpegdec,
++            "H264 with extradata implies framed data - not using parser");
++        ffmpegdec->pctx = NULL;
++      }
++      break;
++    case CODEC_ID_RV10:
++    case CODEC_ID_RV30:
++    case CODEC_ID_RV20:
++    case CODEC_ID_RV40:
++      ffmpegdec->is_realvideo = TRUE;
++      break;
++    default:
++      if (!ffmpegdec->turnoff_parser) {
++        ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
++        if (ffmpegdec->pctx)
++          GST_LOG_OBJECT (ffmpegdec, "Using parser %p", ffmpegdec->pctx);
++        else
++          GST_LOG_OBJECT (ffmpegdec, "No parser for codec");
++      } else {
++        GST_LOG_OBJECT (ffmpegdec, "Parser deactivated for format");
++      }
++      break;
++  }
++
++  switch (oclass->in_plugin->type) {
++    case AVMEDIA_TYPE_VIDEO:
++      ffmpegdec->format.video.width = 0;
++      ffmpegdec->format.video.height = 0;
++      ffmpegdec->format.video.clip_width = -1;
++      ffmpegdec->format.video.clip_height = -1;
++      ffmpegdec->format.video.pix_fmt = PIX_FMT_NB;
++      ffmpegdec->format.video.interlaced = FALSE;
++      break;
++    case AVMEDIA_TYPE_AUDIO:
++      ffmpegdec->format.audio.samplerate = 0;
++      ffmpegdec->format.audio.channels = 0;
++      ffmpegdec->format.audio.depth = 0;
++      break;
++    default:
++      break;
++  }
++
++  gst_ffmpegdec_reset_ts (ffmpegdec);
++  /* FIXME, reset_qos holds the LOCK */
++  ffmpegdec->proportion = 0.0;
++  ffmpegdec->earliest_time = -1;
++
++  return TRUE;
++
++  /* ERRORS */
++could_not_open:
++  {
++    gst_ffmpegdec_close (ffmpegdec);
++    GST_DEBUG_OBJECT (ffmpegdec, "ffdec_%s: Failed to open FFMPEG codec",
++        oclass->in_plugin->name);
++    return FALSE;
++  }
++}
++
++static gboolean
++gst_ffmpegdec_setcaps (GstPad * pad, GstCaps * caps)
++{
++  GstFFMpegDec *ffmpegdec;
++  GstFFMpegDecClass *oclass;
++  GstStructure *structure;
++  const GValue *par;
++  const GValue *fps;
++  gboolean ret = TRUE;
++
++  ffmpegdec = (GstFFMpegDec *) (gst_pad_get_parent (pad));
++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++
++  GST_DEBUG_OBJECT (pad, "setcaps called");
++
++  GST_OBJECT_LOCK (ffmpegdec);
++
++  /* stupid check for VC1 */
++  if ((oclass->in_plugin->id == CODEC_ID_WMV3) ||
++      (oclass->in_plugin->id == CODEC_ID_VC1))
++    oclass->in_plugin->id = gst_ffmpeg_caps_to_codecid (caps, NULL);
++
++  /* close old session */
++  if (ffmpegdec->opened) {
++    GST_OBJECT_UNLOCK (ffmpegdec);
++    gst_ffmpegdec_drain (ffmpegdec);
++    GST_OBJECT_LOCK (ffmpegdec);
++    gst_ffmpegdec_close (ffmpegdec);
++
++    /* and reset the defaults that were set when a context is created */
++    avcodec_get_context_defaults (ffmpegdec->context);
++  }
++
++  /* set buffer functions */
++  ffmpegdec->context->get_buffer = gst_ffmpegdec_get_buffer;
++  ffmpegdec->context->release_buffer = gst_ffmpegdec_release_buffer;
++  ffmpegdec->context->draw_horiz_band = NULL;
++
++  /* default is to let format decide if it needs a parser */
++  ffmpegdec->turnoff_parser = FALSE;
++
++  ffmpegdec->has_b_frames = FALSE;
++
++  GST_LOG_OBJECT (ffmpegdec, "size %dx%d", ffmpegdec->context->width,
++      ffmpegdec->context->height);
++
++  /* get size and so */
++  gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
++      oclass->in_plugin->type, caps, ffmpegdec->context);
++
++  GST_LOG_OBJECT (ffmpegdec, "size after %dx%d", ffmpegdec->context->width,
++      ffmpegdec->context->height);
++
++  if (!ffmpegdec->context->time_base.den || !ffmpegdec->context->time_base.num) {
++    GST_DEBUG_OBJECT (ffmpegdec, "forcing 25/1 framerate");
++    ffmpegdec->context->time_base.num = 1;
++    ffmpegdec->context->time_base.den = 25;
++  }
++
++  /* get pixel aspect ratio if it's set */
++  structure = gst_caps_get_structure (caps, 0);
++
++  par = gst_structure_get_value (structure, "pixel-aspect-ratio");
++  if (par) {
++    GST_DEBUG_OBJECT (ffmpegdec, "sink caps have pixel-aspect-ratio of %d:%d",
++        gst_value_get_fraction_numerator (par),
++        gst_value_get_fraction_denominator (par));
++    /* should be NULL */
++    if (ffmpegdec->par)
++      g_free (ffmpegdec->par);
++    ffmpegdec->par = g_new0 (GValue, 1);
++    gst_value_init_and_copy (ffmpegdec->par, par);
++  }
++
++  /* get the framerate from incoming caps. fps_n is set to -1 when
++   * there is no valid framerate */
++  fps = gst_structure_get_value (structure, "framerate");
++  if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
++    ffmpegdec->format.video.fps_n = gst_value_get_fraction_numerator (fps);
++    ffmpegdec->format.video.fps_d = gst_value_get_fraction_denominator (fps);
++    GST_DEBUG_OBJECT (ffmpegdec, "Using framerate %d/%d from incoming caps",
++        ffmpegdec->format.video.fps_n, ffmpegdec->format.video.fps_d);
++  } else {
++    ffmpegdec->format.video.fps_n = -1;
++    GST_DEBUG_OBJECT (ffmpegdec, "Using framerate from codec");
++  }
++
++  /* figure out if we can use direct rendering */
++  ffmpegdec->current_dr = FALSE;
++  ffmpegdec->extra_ref = FALSE;
++  if (ffmpegdec->direct_rendering) {
++    GST_DEBUG_OBJECT (ffmpegdec, "trying to enable direct rendering");
++    if (oclass->in_plugin->capabilities & CODEC_CAP_DR1) {
++      if (oclass->in_plugin->id == CODEC_ID_H264) {
++        GST_DEBUG_OBJECT (ffmpegdec, "disable direct rendering setup for H264");
++        /* does not work, many stuff reads outside of the planes */
++        ffmpegdec->current_dr = FALSE;
++        ffmpegdec->extra_ref = TRUE;
++      } else if ((oclass->in_plugin->id == CODEC_ID_SVQ1) ||
++          (oclass->in_plugin->id == CODEC_ID_VP5) ||
++          (oclass->in_plugin->id == CODEC_ID_VP6) ||
++          (oclass->in_plugin->id == CODEC_ID_VP6F) ||
++          (oclass->in_plugin->id == CODEC_ID_VP6A)) {
++        GST_DEBUG_OBJECT (ffmpegdec,
++            "disable direct rendering setup for broken stride support");
++        /* does not work, uses a incompatible stride. See #610613 */
++        ffmpegdec->current_dr = FALSE;
++        ffmpegdec->extra_ref = TRUE;
++      } else {
++        GST_DEBUG_OBJECT (ffmpegdec, "enabled direct rendering");
++        ffmpegdec->current_dr = TRUE;
++      }
++    } else {
++      GST_DEBUG_OBJECT (ffmpegdec, "direct rendering not supported");
++    }
++  }
++  if (ffmpegdec->current_dr) {
++    /* do *not* draw edges when in direct rendering, for some reason it draws
++     * outside of the memory. */
++    ffmpegdec->context->flags |= CODEC_FLAG_EMU_EDGE;
++  }
++
++  /* for AAC we only use av_parse if not on stream-format==raw or ==loas */
++  if (oclass->in_plugin->id == CODEC_ID_AAC
++      || oclass->in_plugin->id == CODEC_ID_AAC_LATM) {
++    const gchar *format = gst_structure_get_string (structure, "stream-format");
++
++    if (format == NULL || strcmp (format, "raw") == 0) {
++      ffmpegdec->turnoff_parser = TRUE;
++    }
++  }
++
++  /* for FLAC, don't parse if it's already parsed */
++  if (oclass->in_plugin->id == CODEC_ID_FLAC) {
++    if (gst_structure_has_field (structure, "streamheader"))
++      ffmpegdec->turnoff_parser = TRUE;
++  }
++
++  /* workaround encoder bugs */
++  ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
++  ffmpegdec->context->err_recognition = 1;
++
++  /* for slow cpus */
++  ffmpegdec->context->lowres = ffmpegdec->lowres;
++  ffmpegdec->context->skip_frame = ffmpegdec->skip_frame;
++
++  /* ffmpeg can draw motion vectors on top of the image (not every decoder
++   * supports it) */
++  ffmpegdec->context->debug_mv = ffmpegdec->debug_mv;
++
++  if (ffmpegdec->max_threads == 0)
++    ffmpegdec->context->thread_count = gst_ffmpeg_auto_max_threads ();
++  else
++    ffmpegdec->context->thread_count = ffmpegdec->max_threads;
++
++  /* open codec - we don't select an output pix_fmt yet,
++   * simply because we don't know! We only get it
++   * during playback... */
++  if (!gst_ffmpegdec_open (ffmpegdec))
++    goto open_failed;
++
++  /* clipping region */
++  gst_structure_get_int (structure, "width",
++      &ffmpegdec->format.video.clip_width);
++  gst_structure_get_int (structure, "height",
++      &ffmpegdec->format.video.clip_height);
++
++  GST_DEBUG_OBJECT (pad, "clipping to %dx%d",
++      ffmpegdec->format.video.clip_width, ffmpegdec->format.video.clip_height);
++
++  /* take into account the lowres property */
++  if (ffmpegdec->format.video.clip_width != -1)
++    ffmpegdec->format.video.clip_width >>= ffmpegdec->lowres;
++  if (ffmpegdec->format.video.clip_height != -1)
++    ffmpegdec->format.video.clip_height >>= ffmpegdec->lowres;
++
++  GST_DEBUG_OBJECT (pad, "final clipping to %dx%d",
++      ffmpegdec->format.video.clip_width, ffmpegdec->format.video.clip_height);
++
++done:
++  GST_OBJECT_UNLOCK (ffmpegdec);
++
++  gst_object_unref (ffmpegdec);
++
++  return ret;
++
++  /* ERRORS */
++open_failed:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec, "Failed to open");
++    if (ffmpegdec->par) {
++      g_free (ffmpegdec->par);
++      ffmpegdec->par = NULL;
++    }
++    ret = FALSE;
++    goto done;
++  }
++}
++
++static GstFlowReturn
++alloc_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf,
++    gint width, gint height)
++{
++  GstFlowReturn ret;
++  gint fsize;
++
++  ret = GST_FLOW_ERROR;
++  *outbuf = NULL;
++
++  GST_LOG_OBJECT (ffmpegdec, "alloc output buffer");
++
++  /* see if we need renegotiation */
++  if (G_UNLIKELY (!gst_ffmpegdec_negotiate (ffmpegdec, FALSE)))
++    goto negotiate_failed;
++
++  /* get the size of the gstreamer output buffer given a
++   * width/height/format */
++  fsize = gst_ffmpeg_avpicture_get_size (ffmpegdec->context->pix_fmt,
++      width, height);
++
++  if (ffmpegdec->can_allocate_aligned) {
++    GST_LOG_OBJECT (ffmpegdec, "calling pad_alloc");
++    /* no pallete, we can use the buffer size to alloc */
++    ret = gst_pad_alloc_buffer_and_set_caps (ffmpegdec->srcpad,
++        GST_BUFFER_OFFSET_NONE, fsize,
++        GST_PAD_CAPS (ffmpegdec->srcpad), outbuf);
++    if (G_UNLIKELY (ret != GST_FLOW_OK))
++      goto alloc_failed;
++
++    /* If buffer isn't 128-bit aligned, create a memaligned one ourselves */
++    if (((uintptr_t) GST_BUFFER_DATA (*outbuf)) % 16) {
++      GST_DEBUG_OBJECT (ffmpegdec,
++          "Downstream can't allocate aligned buffers.");
++      ffmpegdec->can_allocate_aligned = FALSE;
++      gst_buffer_unref (*outbuf);
++      *outbuf = new_aligned_buffer (fsize, GST_PAD_CAPS (ffmpegdec->srcpad));
++    }
++  } else {
++    GST_LOG_OBJECT (ffmpegdec,
++        "not calling pad_alloc, we have a pallete or downstream can't give 16 byte aligned buffers.");
++    /* for paletted data we can't use pad_alloc_buffer(), because
++     * fsize contains the size of the palette, so the overall size
++     * is bigger than ffmpegcolorspace's unit size, which will
++     * prompt GstBaseTransform to complain endlessly ... */
++    *outbuf = new_aligned_buffer (fsize, GST_PAD_CAPS (ffmpegdec->srcpad));
++    ret = GST_FLOW_OK;
++  }
++  /* set caps, we do this here because the buffer is still writable here and we
++   * are sure to be negotiated */
++  gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (ffmpegdec->srcpad));
++
++  return ret;
++
++  /* special cases */
++negotiate_failed:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec, "negotiate failed");
++    return GST_FLOW_NOT_NEGOTIATED;
++  }
++alloc_failed:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec, "pad_alloc failed %d (%s)", ret,
++        gst_flow_get_name (ret));
++    return ret;
++  }
++}
++
++static int
++gst_ffmpegdec_get_buffer (AVCodecContext * context, AVFrame * picture)
++{
++  GstBuffer *buf = NULL;
++  GstFFMpegDec *ffmpegdec;
++  gint width, height;
++  gint coded_width, coded_height;
++  gint res;
++
++  ffmpegdec = (GstFFMpegDec *) context->opaque;
++
++  GST_DEBUG_OBJECT (ffmpegdec, "getting buffer");
++
++  /* apply the last info we have seen to this picture, when we get the
++   * picture back from ffmpeg we can use this to correctly timestamp the output
++   * buffer */
++  picture->reordered_opaque = context->reordered_opaque;
++  /* make sure we don't free the buffer when it's not ours */
++  picture->opaque = NULL;
++
++  /* take width and height before clipping */
++  width = context->width;
++  height = context->height;
++  coded_width = context->coded_width;
++  coded_height = context->coded_height;
++
++  GST_LOG_OBJECT (ffmpegdec, "dimension %dx%d, coded %dx%d", width, height,
++      coded_width, coded_height);
++  if (!ffmpegdec->current_dr) {
++    GST_LOG_OBJECT (ffmpegdec, "direct rendering disabled, fallback alloc");
++    res = avcodec_default_get_buffer (context, picture);
++
++    GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", picture->linesize[0],
++        picture->linesize[1], picture->linesize[2]);
++    GST_LOG_OBJECT (ffmpegdec, "data %u %u %u", 0,
++        (guint) (picture->data[1] - picture->data[0]),
++        (guint) (picture->data[2] - picture->data[0]));
++    return res;
++  }
++
++  switch (context->codec_type) {
++    case AVMEDIA_TYPE_VIDEO:
++      /* some ffmpeg video plugins don't see the point in setting codec_type ... */
++    case AVMEDIA_TYPE_UNKNOWN:
++    {
++      GstFlowReturn ret;
++      gint clip_width, clip_height;
++
++      /* take final clipped output size */
++      if ((clip_width = ffmpegdec->format.video.clip_width) == -1)
++        clip_width = width;
++      if ((clip_height = ffmpegdec->format.video.clip_height) == -1)
++        clip_height = height;
++
++      GST_LOG_OBJECT (ffmpegdec, "raw outsize %d/%d", width, height);
++
++      /* this is the size ffmpeg needs for the buffer */
++      avcodec_align_dimensions (context, &width, &height);
++
++      GST_LOG_OBJECT (ffmpegdec, "aligned outsize %d/%d, clip %d/%d",
++          width, height, clip_width, clip_height);
++
++      if (width != clip_width || height != clip_height) {
++        /* We can't alloc if we need to clip the output buffer later */
++        GST_LOG_OBJECT (ffmpegdec, "we need clipping, fallback alloc");
++        return avcodec_default_get_buffer (context, picture);
++      }
++
++      /* alloc with aligned dimensions for ffmpeg */
++      ret = alloc_output_buffer (ffmpegdec, &buf, width, height);
++      if (G_UNLIKELY (ret != GST_FLOW_OK)) {
++        /* alloc default buffer when we can't get one from downstream */
++        GST_LOG_OBJECT (ffmpegdec, "alloc failed, fallback alloc");
++        return avcodec_default_get_buffer (context, picture);
++      }
++
++      /* copy the right pointers and strides in the picture object */
++      gst_ffmpeg_avpicture_fill ((AVPicture *) picture,
++          GST_BUFFER_DATA (buf), context->pix_fmt, width, height);
++      break;
++    }
++    case AVMEDIA_TYPE_AUDIO:
++    default:
++      GST_ERROR_OBJECT (ffmpegdec,
++          "_get_buffer() should never get called for non-video buffers !");
++      g_assert_not_reached ();
++      break;
++  }
++
++  /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to
++   * the opaque data. */
++  picture->type = FF_BUFFER_TYPE_USER;
++  picture->opaque = buf;
++
++#ifdef EXTRA_REF
++  if (picture->reference != 0 || ffmpegdec->extra_ref) {
++    GST_DEBUG_OBJECT (ffmpegdec, "adding extra ref");
++    gst_buffer_ref (buf);
++  }
++#endif
++
++  GST_LOG_OBJECT (ffmpegdec, "returned buffer %p", buf);
++
++  return 0;
++}
++
++static void
++gst_ffmpegdec_release_buffer (AVCodecContext * context, AVFrame * picture)
++{
++  gint i;
++  GstBuffer *buf;
++  GstFFMpegDec *ffmpegdec;
++
++  ffmpegdec = (GstFFMpegDec *) context->opaque;
++
++  /* check if it was our buffer */
++  if (picture->opaque == NULL) {
++    GST_DEBUG_OBJECT (ffmpegdec, "default release buffer");
++    avcodec_default_release_buffer (context, picture);
++    return;
++  }
++
++  /* we remove the opaque data now */
++  buf = GST_BUFFER_CAST (picture->opaque);
++  GST_DEBUG_OBJECT (ffmpegdec, "release buffer %p", buf);
++  picture->opaque = NULL;
++
++#ifdef EXTRA_REF
++  if (picture->reference != 0 || ffmpegdec->extra_ref) {
++    GST_DEBUG_OBJECT (ffmpegdec, "remove extra ref");
++    gst_buffer_unref (buf);
++  }
++#else
++  gst_buffer_unref (buf);
++#endif
++
++  /* zero out the reference in ffmpeg */
++  for (i = 0; i < 4; i++) {
++    picture->data[i] = NULL;
++    picture->linesize[i] = 0;
++  }
++}
++
++static void
++gst_ffmpegdec_add_pixel_aspect_ratio (GstFFMpegDec * ffmpegdec,
++    GstStructure * s)
++{
++  gboolean demuxer_par_set = FALSE;
++  gboolean decoder_par_set = FALSE;
++  gint demuxer_num = 1, demuxer_denom = 1;
++  gint decoder_num = 1, decoder_denom = 1;
++
++  GST_OBJECT_LOCK (ffmpegdec);
++
++  if (ffmpegdec->par) {
++    demuxer_num = gst_value_get_fraction_numerator (ffmpegdec->par);
++    demuxer_denom = gst_value_get_fraction_denominator (ffmpegdec->par);
++    demuxer_par_set = TRUE;
++    GST_DEBUG_OBJECT (ffmpegdec, "Demuxer PAR: %d:%d", demuxer_num,
++        demuxer_denom);
++  }
++
++  if (ffmpegdec->context->sample_aspect_ratio.num &&
++      ffmpegdec->context->sample_aspect_ratio.den) {
++    decoder_num = ffmpegdec->context->sample_aspect_ratio.num;
++    decoder_denom = ffmpegdec->context->sample_aspect_ratio.den;
++    decoder_par_set = TRUE;
++    GST_DEBUG_OBJECT (ffmpegdec, "Decoder PAR: %d:%d", decoder_num,
++        decoder_denom);
++  }
++
++  GST_OBJECT_UNLOCK (ffmpegdec);
++
++  if (!demuxer_par_set && !decoder_par_set)
++    goto no_par;
++
++  if (demuxer_par_set && !decoder_par_set)
++    goto use_demuxer_par;
++
++  if (decoder_par_set && !demuxer_par_set)
++    goto use_decoder_par;
++
++  /* Both the demuxer and the decoder provide a PAR. If one of
++   * the two PARs is 1:1 and the other one is not, use the one
++   * that is not 1:1. */
++  if (demuxer_num == demuxer_denom && decoder_num != decoder_denom)
++    goto use_decoder_par;
++
++  if (decoder_num == decoder_denom && demuxer_num != demuxer_denom)
++    goto use_demuxer_par;
++
++  /* Both PARs are non-1:1, so use the PAR provided by the demuxer */
++  goto use_demuxer_par;
++
++use_decoder_par:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec,
++        "Setting decoder provided pixel-aspect-ratio of %u:%u", decoder_num,
++        decoder_denom);
++    gst_structure_set (s, "pixel-aspect-ratio", GST_TYPE_FRACTION, decoder_num,
++        decoder_denom, NULL);
++    return;
++  }
++
++use_demuxer_par:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec,
++        "Setting demuxer provided pixel-aspect-ratio of %u:%u", demuxer_num,
++        demuxer_denom);
++    gst_structure_set (s, "pixel-aspect-ratio", GST_TYPE_FRACTION, demuxer_num,
++        demuxer_denom, NULL);
++    return;
++  }
++no_par:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec,
++        "Neither demuxer nor codec provide a pixel-aspect-ratio");
++    return;
++  }
++}
++
++static gboolean
++gst_ffmpegdec_negotiate (GstFFMpegDec * ffmpegdec, gboolean force)
++{
++  GstFFMpegDecClass *oclass;
++  GstCaps *caps;
++
++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++
++  switch (oclass->in_plugin->type) {
++    case AVMEDIA_TYPE_VIDEO:
++      if (!force && ffmpegdec->format.video.width == ffmpegdec->context->width
++          && ffmpegdec->format.video.height == ffmpegdec->context->height
++          && ffmpegdec->format.video.fps_n == ffmpegdec->format.video.old_fps_n
++          && ffmpegdec->format.video.fps_d == ffmpegdec->format.video.old_fps_d
++          && ffmpegdec->format.video.pix_fmt == ffmpegdec->context->pix_fmt
++          && ffmpegdec->format.video.par_n ==
++          ffmpegdec->context->sample_aspect_ratio.num
++          && ffmpegdec->format.video.par_d ==
++          ffmpegdec->context->sample_aspect_ratio.den)
++        return TRUE;
++      GST_DEBUG_OBJECT (ffmpegdec,
++          "Renegotiating video from %dx%d@ %d:%d PAR %d/%d fps to %dx%d@ %d:%d PAR %d/%d fps",
++          ffmpegdec->format.video.width, ffmpegdec->format.video.height,
++          ffmpegdec->format.video.par_n, ffmpegdec->format.video.par_d,
++          ffmpegdec->format.video.old_fps_n, ffmpegdec->format.video.old_fps_n,
++          ffmpegdec->context->width, ffmpegdec->context->height,
++          ffmpegdec->context->sample_aspect_ratio.num,
++          ffmpegdec->context->sample_aspect_ratio.den,
++          ffmpegdec->format.video.fps_n, ffmpegdec->format.video.fps_d);
++      ffmpegdec->format.video.width = ffmpegdec->context->width;
++      ffmpegdec->format.video.height = ffmpegdec->context->height;
++      ffmpegdec->format.video.old_fps_n = ffmpegdec->format.video.fps_n;
++      ffmpegdec->format.video.old_fps_d = ffmpegdec->format.video.fps_d;
++      ffmpegdec->format.video.pix_fmt = ffmpegdec->context->pix_fmt;
++      ffmpegdec->format.video.par_n =
++          ffmpegdec->context->sample_aspect_ratio.num;
++      ffmpegdec->format.video.par_d =
++          ffmpegdec->context->sample_aspect_ratio.den;
++      break;
++    case AVMEDIA_TYPE_AUDIO:
++    {
++      gint depth = av_smp_format_depth (ffmpegdec->context->sample_fmt);
++      if (!force && ffmpegdec->format.audio.samplerate ==
++          ffmpegdec->context->sample_rate &&
++          ffmpegdec->format.audio.channels == ffmpegdec->context->channels &&
++          ffmpegdec->format.audio.depth == depth)
++        return TRUE;
++      GST_DEBUG_OBJECT (ffmpegdec,
++          "Renegotiating audio from %dHz@%dchannels (%d) to %dHz@%dchannels (%d)",
++          ffmpegdec->format.audio.samplerate, ffmpegdec->format.audio.channels,
++          ffmpegdec->format.audio.depth,
++          ffmpegdec->context->sample_rate, ffmpegdec->context->channels, depth);
++      ffmpegdec->format.audio.samplerate = ffmpegdec->context->sample_rate;
++      ffmpegdec->format.audio.channels = ffmpegdec->context->channels;
++      ffmpegdec->format.audio.depth = depth;
++    }
++      break;
++    default:
++      break;
++  }
++
++  caps = gst_ffmpeg_codectype_to_caps (oclass->in_plugin->type,
++      ffmpegdec->context, oclass->in_plugin->id, FALSE);
++
++  if (caps == NULL)
++    goto no_caps;
++
++  switch (oclass->in_plugin->type) {
++    case AVMEDIA_TYPE_VIDEO:
++    {
++      gint width, height;
++      gboolean interlaced;
++
++      width = ffmpegdec->format.video.clip_width;
++      height = ffmpegdec->format.video.clip_height;
++      interlaced = ffmpegdec->format.video.interlaced;
++
++      if (width != -1 && height != -1) {
++        /* overwrite the output size with the dimension of the
++         * clipping region but only if they are smaller. */
++        if (width < ffmpegdec->context->width)
++          gst_caps_set_simple (caps, "width", G_TYPE_INT, width, NULL);
++        if (height < ffmpegdec->context->height)
++          gst_caps_set_simple (caps, "height", G_TYPE_INT, height, NULL);
++      }
++      gst_caps_set_simple (caps, "interlaced", G_TYPE_BOOLEAN, interlaced,
++          NULL);
++
++      /* If a demuxer provided a framerate then use it (#313970) */
++      if (ffmpegdec->format.video.fps_n != -1) {
++        gst_caps_set_simple (caps, "framerate",
++            GST_TYPE_FRACTION, ffmpegdec->format.video.fps_n,
++            ffmpegdec->format.video.fps_d, NULL);
++      }
++      gst_ffmpegdec_add_pixel_aspect_ratio (ffmpegdec,
++          gst_caps_get_structure (caps, 0));
++      break;
++    }
++    case AVMEDIA_TYPE_AUDIO:
++    {
++      break;
++    }
++    default:
++      break;
++  }
++
++  if (!gst_pad_set_caps (ffmpegdec->srcpad, caps))
++    goto caps_failed;
++
++  gst_caps_unref (caps);
++
++  return TRUE;
++
++  /* ERRORS */
++no_caps:
++  {
++#ifdef HAVE_FFMPEG_UNINSTALLED
++    /* using internal ffmpeg snapshot */
++    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
++        ("Could not find GStreamer caps mapping for FFmpeg codec '%s'.",
++            oclass->in_plugin->name), (NULL));
++#else
++    /* using external ffmpeg */
++    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
++        ("Could not find GStreamer caps mapping for FFmpeg codec '%s', and "
++            "you are using an external libavcodec. This is most likely due to "
++            "a packaging problem and/or libavcodec having been upgraded to a "
++            "version that is not compatible with this version of "
++            "gstreamer-ffmpeg. Make sure your gstreamer-ffmpeg and libavcodec "
++            "packages come from the same source/repository.",
++            oclass->in_plugin->name), (NULL));
++#endif
++    return FALSE;
++  }
++caps_failed:
++  {
++    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
++        ("Could not set caps for ffmpeg decoder (%s), not fixed?",
++            oclass->in_plugin->name));
++    gst_caps_unref (caps);
++
++    return FALSE;
++  }
++}
++
++/* perform qos calculations before decoding the next frame.
++ *
++ * Sets the skip_frame flag and if things are really bad, skips to the next
++ * keyframe.
++ * 
++ * Returns TRUE if the frame should be decoded, FALSE if the frame can be dropped
++ * entirely.
++ */
++static gboolean
++gst_ffmpegdec_do_qos (GstFFMpegDec * ffmpegdec, GstClockTime timestamp,
++    gboolean * mode_switch)
++{
++  GstClockTimeDiff diff;
++  gdouble proportion;
++  GstClockTime qostime, earliest_time;
++  gboolean res = TRUE;
++
++  *mode_switch = FALSE;
++
++  /* no timestamp, can't do QoS */
++  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (timestamp)))
++    goto no_qos;
++
++  /* get latest QoS observation values */
++  gst_ffmpegdec_read_qos (ffmpegdec, &proportion, &earliest_time);
++
++  /* skip qos if we have no observation (yet) */
++  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (earliest_time))) {
++    /* no skip_frame initialy */
++    ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
++    goto no_qos;
++  }
++
++  /* qos is done on running time of the timestamp */
++  qostime = gst_segment_to_running_time (&ffmpegdec->segment, GST_FORMAT_TIME,
++      timestamp);
++
++  /* timestamp can be out of segment, then we don't do QoS */
++  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (qostime)))
++    goto no_qos;
++
++  /* see how our next timestamp relates to the latest qos timestamp. negative
++   * values mean we are early, positive values mean we are too late. */
++  diff = GST_CLOCK_DIFF (qostime, earliest_time);
++
++  GST_DEBUG_OBJECT (ffmpegdec, "QOS: qostime %" GST_TIME_FORMAT
++      ", earliest %" GST_TIME_FORMAT, GST_TIME_ARGS (qostime),
++      GST_TIME_ARGS (earliest_time));
++
++  /* if we using less than 40% of the available time, we can try to
++   * speed up again when we were slow. */
++  if (proportion < 0.4 && diff < 0) {
++    goto normal_mode;
++  } else {
++    if (diff >= 0) {
++      /* we're too slow, try to speed up */
++      /* switch to skip_frame mode */
++      goto skip_frame;
++    }
++  }
++
++no_qos:
++  ffmpegdec->processed++;
++  return TRUE;
++
++normal_mode:
++  {
++    if (ffmpegdec->context->skip_frame != AVDISCARD_DEFAULT) {
++      ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
++      *mode_switch = TRUE;
++      GST_DEBUG_OBJECT (ffmpegdec, "QOS: normal mode %g < 0.4", proportion);
++    }
++    ffmpegdec->processed++;
++    return TRUE;
++  }
++skip_frame:
++  {
++    if (ffmpegdec->context->skip_frame != AVDISCARD_NONREF) {
++      ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
++      *mode_switch = TRUE;
++      GST_DEBUG_OBJECT (ffmpegdec,
++          "QOS: hurry up, diff %" G_GINT64_FORMAT " >= 0", diff);
++    }
++    goto drop_qos;
++  }
++drop_qos:
++  {
++    GstClockTime stream_time, jitter;
++    GstMessage *qos_msg;
++
++    ffmpegdec->dropped++;
++    stream_time =
++        gst_segment_to_stream_time (&ffmpegdec->segment, GST_FORMAT_TIME,
++        timestamp);
++    jitter = GST_CLOCK_DIFF (qostime, earliest_time);
++    qos_msg =
++        gst_message_new_qos (GST_OBJECT_CAST (ffmpegdec), FALSE, qostime,
++        stream_time, timestamp, GST_CLOCK_TIME_NONE);
++    gst_message_set_qos_values (qos_msg, jitter, proportion, 1000000);
++    gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
++        ffmpegdec->processed, ffmpegdec->dropped);
++    gst_element_post_message (GST_ELEMENT_CAST (ffmpegdec), qos_msg);
++
++    return res;
++  }
++}
++
++/* returns TRUE if buffer is within segment, else FALSE.
++ * if Buffer is on segment border, it's timestamp and duration will be clipped */
++static gboolean
++clip_video_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
++    GstClockTime in_dur)
++{
++  gboolean res = TRUE;
++  gint64 cstart, cstop;
++  GstClockTime stop;
++
++  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 (G_UNLIKELY (dec->segment.format != GST_FORMAT_TIME))
++    goto beach;
++
++  /* we need a start time */
++  if (G_UNLIKELY (!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 */
++  res =
++      gst_segment_clip (&dec->segment, GST_FORMAT_TIME, in_ts, stop, &cstart,
++      &cstop);
++  if (G_UNLIKELY (!res))
++    goto beach;
++
++  /* we're pretty sure the duration of this buffer is not till the end of this
++   * segment (which _clip will assume when the stop is -1) */
++  if (stop == GST_CLOCK_TIME_NONE)
++    cstop = GST_CLOCK_TIME_NONE;
++
++  /* 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;
++
++  GST_LOG_OBJECT (dec,
++      "clipped timestamp:%" GST_TIME_FORMAT " , duration:%" GST_TIME_FORMAT,
++      GST_TIME_ARGS (cstart), GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
++
++beach:
++  GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
++  return res;
++}
++
++
++/* get an outbuf buffer with the current picture */
++static GstFlowReturn
++get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
++{
++  GstFlowReturn ret;
++
++  ret = GST_FLOW_OK;
++  *outbuf = NULL;
++
++  if (ffmpegdec->picture->opaque != NULL) {
++    /* we allocated a picture already for ffmpeg to decode into, let's pick it
++     * up and use it now. */
++    *outbuf = (GstBuffer *) ffmpegdec->picture->opaque;
++    GST_LOG_OBJECT (ffmpegdec, "using opaque buffer %p", *outbuf);
++#ifndef EXTRA_REF
++    gst_buffer_ref (*outbuf);
++#endif
++  } else {
++    AVPicture pic, *outpic;
++    gint width, height;
++
++    GST_LOG_OBJECT (ffmpegdec, "get output buffer");
++
++    /* figure out size of output buffer, this is the clipped output size because
++     * we will copy the picture into it but only when the clipping region is
++     * smaller than the actual picture size. */
++    if ((width = ffmpegdec->format.video.clip_width) == -1)
++      width = ffmpegdec->context->width;
++    else if (width > ffmpegdec->context->width)
++      width = ffmpegdec->context->width;
++
++    if ((height = ffmpegdec->format.video.clip_height) == -1)
++      height = ffmpegdec->context->height;
++    else if (height > ffmpegdec->context->height)
++      height = ffmpegdec->context->height;
++
++    GST_LOG_OBJECT (ffmpegdec, "clip width %d/height %d", width, height);
++
++    ret = alloc_output_buffer (ffmpegdec, outbuf, width, height);
++    if (G_UNLIKELY (ret != GST_FLOW_OK))
++      goto alloc_failed;
++
++    /* original ffmpeg code does not handle odd sizes correctly.
++     * This patched up version does */
++    gst_ffmpeg_avpicture_fill (&pic, GST_BUFFER_DATA (*outbuf),
++        ffmpegdec->context->pix_fmt, width, height);
++
++    outpic = (AVPicture *) ffmpegdec->picture;
++
++    GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", outpic->linesize[0],
++        outpic->linesize[1], outpic->linesize[2]);
++    GST_LOG_OBJECT (ffmpegdec, "data %u %u %u", 0,
++        (guint) (outpic->data[1] - outpic->data[0]),
++        (guint) (outpic->data[2] - outpic->data[0]));
++
++    av_picture_copy (&pic, outpic, ffmpegdec->context->pix_fmt, width, height);
++  }
++  ffmpegdec->picture->reordered_opaque = -1;
++
++  return ret;
++
++  /* special cases */
++alloc_failed:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec, "pad_alloc failed");
++    return ret;
++  }
++}
++
++static void
++clear_queued (GstFFMpegDec * ffmpegdec)
++{
++  g_list_foreach (ffmpegdec->queued, (GFunc) gst_mini_object_unref, NULL);
++  g_list_free (ffmpegdec->queued);
++  ffmpegdec->queued = NULL;
++}
++
++static GstFlowReturn
++flush_queued (GstFFMpegDec * ffmpegdec)
++{
++  GstFlowReturn res = GST_FLOW_OK;
++
++  while (ffmpegdec->queued) {
++    GstBuffer *buf = GST_BUFFER_CAST (ffmpegdec->queued->data);
++
++    GST_LOG_OBJECT (ffmpegdec, "pushing buffer %p, offset %"
++        G_GUINT64_FORMAT ", timestamp %"
++        GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT, buf,
++        GST_BUFFER_OFFSET (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 (ffmpegdec->srcpad, buf);
++
++    ffmpegdec->queued =
++        g_list_delete_link (ffmpegdec->queued, ffmpegdec->queued);
++  }
++  return res;
++}
++
++static void
++gst_avpacket_init (AVPacket * packet, guint8 * data, guint size)
++{
++  memset (packet, 0, sizeof (AVPacket));
++  packet->data = data;
++  packet->size = size;
++}
++
++/* gst_ffmpegdec_[video|audio]_frame:
++ * ffmpegdec:
++ * data: pointer to the data to decode
++ * size: size of data in bytes
++ * in_timestamp: incoming timestamp.
++ * in_duration: incoming duration.
++ * in_offset: incoming offset (frame number).
++ * outbuf: outgoing buffer. Different from NULL ONLY if it contains decoded data.
++ * ret: Return flow.
++ *
++ * Returns: number of bytes used in decoding. The check for successful decode is
++ *   outbuf being non-NULL.
++ */
++static gint
++gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
++    guint8 * data, guint size,
++    const GstTSInfo * dec_info, GstBuffer ** outbuf, GstFlowReturn * ret)
++{
++  gint len = -1;
++  gint have_data;
++  gboolean mode_switch;
++  gboolean decode;
++  gint skip_frame = AVDISCARD_DEFAULT;
++  GstClockTime out_timestamp, out_duration, out_pts;
++  gint64 out_offset;
++  const GstTSInfo *out_info;
++  AVPacket packet;
++
++  *ret = GST_FLOW_OK;
++  *outbuf = NULL;
++
++  ffmpegdec->context->opaque = ffmpegdec;
++
++  /* in case we skip frames */
++  ffmpegdec->picture->pict_type = -1;
++
++  /* run QoS code, we don't stop decoding the frame when we are late because
++   * else we might skip a reference frame */
++  decode = gst_ffmpegdec_do_qos (ffmpegdec, dec_info->timestamp, &mode_switch);
++
++  if (ffmpegdec->is_realvideo && data != NULL) {
++    gint slice_count;
++    gint i;
++
++    /* setup the slice table for realvideo */
++    if (ffmpegdec->context->slice_offset == NULL)
++      ffmpegdec->context->slice_offset = g_malloc (sizeof (guint32) * 1000);
++
++    slice_count = (*data++) + 1;
++    ffmpegdec->context->slice_count = slice_count;
++
++    for (i = 0; i < slice_count; i++) {
++      data += 4;
++      ffmpegdec->context->slice_offset[i] = GST_READ_UINT32_LE (data);
++      data += 4;
++    }
++  }
++
++  if (!decode) {
++    /* no decoding needed, save previous skip_frame value and brutely skip
++     * decoding everything */
++    skip_frame = ffmpegdec->context->skip_frame;
++    ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
++  }
++
++  /* save reference to the timing info */
++  ffmpegdec->context->reordered_opaque = (gint64) dec_info->idx;
++  ffmpegdec->picture->reordered_opaque = (gint64) dec_info->idx;
++
++  GST_DEBUG_OBJECT (ffmpegdec, "stored opaque values idx %d", dec_info->idx);
++
++  /* now decode the frame */
++  gst_avpacket_init (&packet, data, size);
++  len = avcodec_decode_video2 (ffmpegdec->context,
++      ffmpegdec->picture, &have_data, &packet);
++
++  /* restore previous state */
++  if (!decode)
++    ffmpegdec->context->skip_frame = skip_frame;
++
++  GST_DEBUG_OBJECT (ffmpegdec, "after decode: len %d, have_data %d",
++      len, have_data);
++
++  /* when we are in skip_frame mode, don't complain when ffmpeg returned
++   * no data because we told it to skip stuff. */
++  if (len < 0 && (mode_switch || ffmpegdec->context->skip_frame))
++    len = 0;
++
++  if (len > 0 && have_data <= 0 && (mode_switch
++          || ffmpegdec->context->skip_frame)) {
++    /* we consumed some bytes but nothing decoded and we are skipping frames,
++     * disable the interpollation of DTS timestamps */
++    ffmpegdec->last_out = -1;
++  }
++
++  /* no data, we're done */
++  if (len < 0 || have_data <= 0)
++    goto beach;
++
++  /* get the output picture timing info again */
++  out_info = gst_ts_info_get (ffmpegdec, ffmpegdec->picture->reordered_opaque);
++  out_pts = out_info->timestamp;
++  out_duration = out_info->duration;
++  out_offset = out_info->offset;
++
++  GST_DEBUG_OBJECT (ffmpegdec,
++      "pts %" G_GUINT64_FORMAT " duration %" G_GUINT64_FORMAT " offset %"
++      G_GINT64_FORMAT, out_pts, out_duration, out_offset);
++  GST_DEBUG_OBJECT (ffmpegdec, "picture: pts %" G_GUINT64_FORMAT,
++      (guint64) ffmpegdec->picture->pts);
++  GST_DEBUG_OBJECT (ffmpegdec, "picture: num %d",
++      ffmpegdec->picture->coded_picture_number);
++  GST_DEBUG_OBJECT (ffmpegdec, "picture: ref %d",
++      ffmpegdec->picture->reference);
++  GST_DEBUG_OBJECT (ffmpegdec, "picture: display %d",
++      ffmpegdec->picture->display_picture_number);
++  GST_DEBUG_OBJECT (ffmpegdec, "picture: opaque %p",
++      ffmpegdec->picture->opaque);
++  GST_DEBUG_OBJECT (ffmpegdec, "picture: reordered opaque %" G_GUINT64_FORMAT,
++      (guint64) ffmpegdec->picture->reordered_opaque);
++  GST_DEBUG_OBJECT (ffmpegdec, "repeat_pict:%d",
++      ffmpegdec->picture->repeat_pict);
++  GST_DEBUG_OBJECT (ffmpegdec, "interlaced_frame:%d",
++      ffmpegdec->picture->interlaced_frame);
++
++  if (G_UNLIKELY (ffmpegdec->picture->interlaced_frame !=
++          ffmpegdec->format.video.interlaced)) {
++    GST_WARNING ("Change in interlacing ! picture:%d, recorded:%d",
++        ffmpegdec->picture->interlaced_frame,
++        ffmpegdec->format.video.interlaced);
++    ffmpegdec->format.video.interlaced = ffmpegdec->picture->interlaced_frame;
++    gst_ffmpegdec_negotiate (ffmpegdec, TRUE);
++  }
++
++  /* Whether a frame is interlaced or not is unknown at the time of
++     buffer allocation, so caps on the buffer in opaque will have
++     the previous frame's interlaced flag set. So if interlacedness
++     has changed since allocation, we update the buffer (if any)
++     caps now with the correct interlaced flag. */
++  if (ffmpegdec->picture->opaque != NULL) {
++    GstBuffer *buffer = ffmpegdec->picture->opaque;
++    if (GST_BUFFER_CAPS (buffer) && GST_PAD_CAPS (ffmpegdec->srcpad)) {
++      GstStructure *s = gst_caps_get_structure (GST_BUFFER_CAPS (buffer), 0);
++      gboolean interlaced;
++      gboolean found = gst_structure_get_boolean (s, "interlaced", &interlaced);
++      if (!found || (!!interlaced != !!ffmpegdec->format.video.interlaced)) {
++        GST_DEBUG_OBJECT (ffmpegdec,
++            "Buffer interlacing does not match pad, updating");
++        buffer = gst_buffer_make_metadata_writable (buffer);
++        gst_buffer_set_caps (buffer, GST_PAD_CAPS (ffmpegdec->srcpad));
++        ffmpegdec->picture->opaque = buffer;
++      }
++    }
++  }
++
++  /* check that the timestamps go upwards */
++  if (ffmpegdec->last_out != -1 && ffmpegdec->last_out > out_pts) {
++    /* timestamps go backwards, this means frames were reordered and we must
++     * be dealing with DTS as the buffer timestamps */
++    if (!ffmpegdec->reordered_out) {
++      GST_DEBUG_OBJECT (ffmpegdec, "detected reordered out timestamps");
++      ffmpegdec->reordered_out = TRUE;
++    }
++    if (ffmpegdec->reordered_in) {
++      /* we reset the input reordering here because we want to recover from an
++       * occasionally wrong reordered input timestamp */
++      GST_DEBUG_OBJECT (ffmpegdec, "assuming DTS input timestamps");
++      ffmpegdec->reordered_in = FALSE;
++    }
++  }
++
++  if (out_pts == 0 && out_pts == ffmpegdec->last_out) {
++    GST_LOG_OBJECT (ffmpegdec, "ffmpeg returns 0 timestamps, ignoring");
++    /* some codecs only output 0 timestamps, when that happens, make us select an
++     * output timestamp based on the input timestamp. We do this by making the
++     * ffmpeg timestamp and the interpollated next timestamp invalid. */
++    out_pts = -1;
++    ffmpegdec->next_out = -1;
++  } else
++    ffmpegdec->last_out = out_pts;
++
++  /* we assume DTS as input timestamps unless we see reordered input
++   * timestamps */
++  if (!ffmpegdec->reordered_in && ffmpegdec->reordered_out) {
++    /* PTS and DTS are the same for keyframes */
++    if (ffmpegdec->next_out != -1) {
++      /* interpolate all timestamps except for keyframes, FIXME, this is
++       * wrong when QoS is active. */
++      GST_DEBUG_OBJECT (ffmpegdec, "interpolate timestamps");
++      out_pts = -1;
++      out_offset = -1;
++    }
++  }
++
++  /* get a handle to the output buffer */
++  *ret = get_output_buffer (ffmpegdec, outbuf);
++  if (G_UNLIKELY (*ret != GST_FLOW_OK))
++    goto no_output;
++
++  /*
++   * Timestamps:
++   *
++   *  1) Copy picture timestamp if valid
++   *  2) else interpolate from previous output timestamp
++   *  3) else copy input timestamp
++   */
++  out_timestamp = -1;
++  if (out_pts != -1) {
++    /* Get (interpolated) timestamp from FFMPEG */
++    out_timestamp = (GstClockTime) out_pts;
++    GST_LOG_OBJECT (ffmpegdec, "using timestamp %" GST_TIME_FORMAT
++        " returned by ffmpeg", GST_TIME_ARGS (out_timestamp));
++  }
++  if (!GST_CLOCK_TIME_IS_VALID (out_timestamp) && ffmpegdec->next_out != -1) {
++    out_timestamp = ffmpegdec->next_out;
++    GST_LOG_OBJECT (ffmpegdec, "using next timestamp %" GST_TIME_FORMAT,
++        GST_TIME_ARGS (out_timestamp));
++  }
++  if (!GST_CLOCK_TIME_IS_VALID (out_timestamp)) {
++    out_timestamp = dec_info->timestamp;
++    GST_LOG_OBJECT (ffmpegdec, "using in timestamp %" GST_TIME_FORMAT,
++        GST_TIME_ARGS (out_timestamp));
++  }
++  GST_BUFFER_TIMESTAMP (*outbuf) = out_timestamp;
++
++  /*
++   * Offset:
++   *  0) Use stored input offset (from opaque)
++   *  1) Use value converted from timestamp if valid
++   *  2) Use input offset if valid
++   */
++  if (out_offset != GST_BUFFER_OFFSET_NONE) {
++    /* out_offset already contains the offset from ts_info */
++    GST_LOG_OBJECT (ffmpegdec, "Using offset returned by ffmpeg");
++  } else if (out_timestamp != GST_CLOCK_TIME_NONE) {
++    GstFormat out_fmt = GST_FORMAT_DEFAULT;
++    GST_LOG_OBJECT (ffmpegdec, "Using offset converted from timestamp");
++    /* FIXME, we should really remove this as it's not nice at all to do
++     * upstream queries for each frame to get the frame offset. We also can't
++     * really remove this because it is the only way of setting frame offsets
++     * on outgoing buffers. We should have metadata so that the upstream peer
++     * can set a frame number on the encoded data. */
++    gst_pad_query_peer_convert (ffmpegdec->sinkpad,
++        GST_FORMAT_TIME, out_timestamp, &out_fmt, &out_offset);
++  } else if (dec_info->offset != GST_BUFFER_OFFSET_NONE) {
++    /* FIXME, the input offset is input media specific and might not
++     * be the same for the output media. (byte offset as input, frame number
++     * as output, for example) */
++    GST_LOG_OBJECT (ffmpegdec, "using in_offset %" G_GINT64_FORMAT,
++        dec_info->offset);
++    out_offset = dec_info->offset;
++  } else {
++    GST_LOG_OBJECT (ffmpegdec, "no valid offset found");
++    out_offset = GST_BUFFER_OFFSET_NONE;
++  }
++  GST_BUFFER_OFFSET (*outbuf) = out_offset;
++
++  /*
++   * Duration:
++   *
++   *  1) Use reordered input duration if valid
++   *  2) Else use input duration
++   *  3) else use input framerate
++   *  4) else use ffmpeg framerate
++   */
++  if (GST_CLOCK_TIME_IS_VALID (out_duration)) {
++    /* We have a valid (reordered) duration */
++    GST_LOG_OBJECT (ffmpegdec, "Using duration returned by ffmpeg");
++  } else if (GST_CLOCK_TIME_IS_VALID (dec_info->duration)) {
++    GST_LOG_OBJECT (ffmpegdec, "using in_duration");
++    out_duration = dec_info->duration;
++  } else if (GST_CLOCK_TIME_IS_VALID (ffmpegdec->last_diff)) {
++    GST_LOG_OBJECT (ffmpegdec, "using last-diff");
++    out_duration = ffmpegdec->last_diff;
++  } else {
++    /* if we have an input framerate, use that */
++    if (ffmpegdec->format.video.fps_n != -1 &&
++        (ffmpegdec->format.video.fps_n != 1000 &&
++            ffmpegdec->format.video.fps_d != 1)) {
++      GST_LOG_OBJECT (ffmpegdec, "using input framerate for duration");
++      out_duration = gst_util_uint64_scale_int (GST_SECOND,
++          ffmpegdec->format.video.fps_d, ffmpegdec->format.video.fps_n);
++    } else {
++      /* don't try to use the decoder's framerate when it seems a bit abnormal,
++       * which we assume when den >= 1000... */
++      if (ffmpegdec->context->time_base.num != 0 &&
++          (ffmpegdec->context->time_base.den > 0 &&
++              ffmpegdec->context->time_base.den < 1000)) {
++        GST_LOG_OBJECT (ffmpegdec, "using decoder's framerate for duration");
++        out_duration = gst_util_uint64_scale_int (GST_SECOND,
++            ffmpegdec->context->time_base.num *
++            ffmpegdec->context->ticks_per_frame,
++            ffmpegdec->context->time_base.den);
++      } else {
++        GST_LOG_OBJECT (ffmpegdec, "no valid duration found");
++      }
++    }
++  }
++
++  /* Take repeat_pict into account */
++  if (GST_CLOCK_TIME_IS_VALID (out_duration)) {
++    out_duration += out_duration * ffmpegdec->picture->repeat_pict / 2;
++  }
++  GST_BUFFER_DURATION (*outbuf) = out_duration;
++
++  if (out_timestamp != -1 && out_duration != -1 && out_duration != 0)
++    ffmpegdec->next_out = out_timestamp + out_duration;
++  else
++    ffmpegdec->next_out = -1;
++
++  /* now see if we need to clip the buffer against the segment boundaries. */
++  if (G_UNLIKELY (!clip_video_buffer (ffmpegdec, *outbuf, out_timestamp,
++              out_duration)))
++    goto clipped;
++
++  if (ffmpegdec->picture->top_field_first)
++    GST_BUFFER_FLAG_SET (*outbuf, GST_VIDEO_BUFFER_TFF);
++
++
++beach:
++  GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
++      *ret, *outbuf, len);
++  return len;
++
++  /* special cases */
++no_output:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec, "no output buffer");
++    len = -1;
++    goto beach;
++  }
++clipped:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec, "buffer clipped");
++    gst_buffer_unref (*outbuf);
++    *outbuf = NULL;
++    goto beach;
++  }
++}
++
++/* returns TRUE if buffer is within segment, else FALSE.
++ * if Buffer is on segment border, it's timestamp and duration will be clipped */
++static gboolean
++clip_audio_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
++    GstClockTime in_dur)
++{
++  GstClockTime stop;
++  gint64 diff, ctime, cstop;
++  gboolean res = TRUE;
++
++  GST_LOG_OBJECT (dec,
++      "timestamp:%" GST_TIME_FORMAT ", duration:%" GST_TIME_FORMAT
++      ", size %u", GST_TIME_ARGS (in_ts), GST_TIME_ARGS (in_dur),
++      GST_BUFFER_SIZE (buf));
++
++  /* can't clip without TIME segment */
++  if (G_UNLIKELY (dec->segment.format != GST_FORMAT_TIME))
++    goto beach;
++
++  /* we need a start time */
++  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (in_ts)))
++    goto beach;
++
++  /* trust duration */
++  stop = in_ts + in_dur;
++
++  res = gst_segment_clip (&dec->segment, GST_FORMAT_TIME, in_ts, stop, &ctime,
++      &cstop);
++  if (G_UNLIKELY (!res))
++    goto out_of_segment;
++
++  /* see if some clipping happened */
++  if (G_UNLIKELY ((diff = ctime - in_ts) > 0)) {
++    /* bring clipped time to bytes */
++    diff =
++        gst_util_uint64_scale_int (diff, dec->format.audio.samplerate,
++        GST_SECOND) * (dec->format.audio.depth * dec->format.audio.channels);
++
++    GST_DEBUG_OBJECT (dec, "clipping start to %" GST_TIME_FORMAT " %"
++        G_GINT64_FORMAT " bytes", GST_TIME_ARGS (ctime), diff);
++
++    GST_BUFFER_SIZE (buf) -= diff;
++    GST_BUFFER_DATA (buf) += diff;
++  }
++  if (G_UNLIKELY ((diff = stop - cstop) > 0)) {
++    /* bring clipped time to bytes */
++    diff =
++        gst_util_uint64_scale_int (diff, dec->format.audio.samplerate,
++        GST_SECOND) * (dec->format.audio.depth * dec->format.audio.channels);
++
++    GST_DEBUG_OBJECT (dec, "clipping stop to %" GST_TIME_FORMAT " %"
++        G_GINT64_FORMAT " bytes", GST_TIME_ARGS (cstop), diff);
++
++    GST_BUFFER_SIZE (buf) -= diff;
++  }
++  GST_BUFFER_TIMESTAMP (buf) = ctime;
++  GST_BUFFER_DURATION (buf) = cstop - ctime;
++
++beach:
++  GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
++  return res;
++
++  /* ERRORS */
++out_of_segment:
++  {
++    GST_LOG_OBJECT (dec, "out of segment");
++    goto beach;
++  }
++}
++
++static gint
++gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec,
++    AVCodec * in_plugin, guint8 * data, guint size,
++    const GstTSInfo * dec_info, GstBuffer ** outbuf, GstFlowReturn * ret)
++{
++  gint len = -1;
++  gint have_data = AVCODEC_MAX_AUDIO_FRAME_SIZE;
++  GstClockTime out_timestamp, out_duration;
++  gint64 out_offset;
++  AVPacket packet;
++
++  GST_DEBUG_OBJECT (ffmpegdec,
++      "size:%d, offset:%" G_GINT64_FORMAT ", ts:%" GST_TIME_FORMAT ", dur:%"
++      GST_TIME_FORMAT ", ffmpegdec->next_out:%" GST_TIME_FORMAT, size,
++      dec_info->offset, GST_TIME_ARGS (dec_info->timestamp),
++      GST_TIME_ARGS (dec_info->duration), GST_TIME_ARGS (ffmpegdec->next_out));
++
++  *outbuf =
++      new_aligned_buffer (AVCODEC_MAX_AUDIO_FRAME_SIZE,
++      GST_PAD_CAPS (ffmpegdec->srcpad));
++
++  gst_avpacket_init (&packet, data, size);
++  len = avcodec_decode_audio3 (ffmpegdec->context,
++      (int16_t *) GST_BUFFER_DATA (*outbuf), &have_data, &packet);
++  GST_DEBUG_OBJECT (ffmpegdec,
++      "Decode audio: len=%d, have_data=%d", len, have_data);
++
++  if (len >= 0 && have_data > 0) {
++    GST_DEBUG_OBJECT (ffmpegdec, "Creating output buffer");
++    if (!gst_ffmpegdec_negotiate (ffmpegdec, FALSE)) {
++      gst_buffer_unref (*outbuf);
++      *outbuf = NULL;
++      len = -1;
++      goto beach;
++    }
++
++    /* Buffer size */
++    GST_BUFFER_SIZE (*outbuf) = have_data;
++
++    /*
++     * Timestamps:
++     *
++     *  1) Copy input timestamp if valid
++     *  2) else interpolate from previous input timestamp
++     */
++    /* always take timestamps from the input buffer if any */
++    if (GST_CLOCK_TIME_IS_VALID (dec_info->timestamp)) {
++      out_timestamp = dec_info->timestamp;
++    } else {
++      out_timestamp = ffmpegdec->next_out;
++    }
++
++    /*
++     * Duration:
++     *
++     *  1) calculate based on number of samples
++     */
++    out_duration = gst_util_uint64_scale (have_data, GST_SECOND,
++        ffmpegdec->format.audio.depth * ffmpegdec->format.audio.channels *
++        ffmpegdec->format.audio.samplerate);
++
++    /* offset:
++     *
++     * Just copy
++     */
++    out_offset = dec_info->offset;
++
++    GST_DEBUG_OBJECT (ffmpegdec,
++        "Buffer created. Size:%d , timestamp:%" GST_TIME_FORMAT " , duration:%"
++        GST_TIME_FORMAT, have_data,
++        GST_TIME_ARGS (out_timestamp), GST_TIME_ARGS (out_duration));
++
++    GST_BUFFER_TIMESTAMP (*outbuf) = out_timestamp;
++    GST_BUFFER_DURATION (*outbuf) = out_duration;
++    GST_BUFFER_OFFSET (*outbuf) = out_offset;
++    gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (ffmpegdec->srcpad));
++
++    /* the next timestamp we'll use when interpolating */
++    if (GST_CLOCK_TIME_IS_VALID (out_timestamp))
++      ffmpegdec->next_out = out_timestamp + out_duration;
++
++    /* now see if we need to clip the buffer against the segment boundaries. */
++    if (G_UNLIKELY (!clip_audio_buffer (ffmpegdec, *outbuf, out_timestamp,
++                out_duration)))
++      goto clipped;
++
++  } else {
++    gst_buffer_unref (*outbuf);
++    *outbuf = NULL;
++  }
++
++  /* If we don't error out after the first failed read with the AAC decoder,
++   * we must *not* carry on pushing data, else we'll cause segfaults... */
++  if (len == -1 && (in_plugin->id == CODEC_ID_AAC
++          || in_plugin->id == CODEC_ID_AAC_LATM)) {
++    GST_ELEMENT_ERROR (ffmpegdec, STREAM, DECODE, (NULL),
++        ("Decoding of AAC stream by FFMPEG failed."));
++    *ret = GST_FLOW_ERROR;
++  }
++
++beach:
++  GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
++      *ret, *outbuf, len);
++  return len;
++
++  /* ERRORS */
++clipped:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec, "buffer clipped");
++    gst_buffer_unref (*outbuf);
++    *outbuf = NULL;
++    goto beach;
++  }
++}
++
++/* gst_ffmpegdec_frame:
++ * ffmpegdec:
++ * data: pointer to the data to decode
++ * size: size of data in bytes
++ * got_data: 0 if no data was decoded, != 0 otherwise.
++ * in_time: timestamp of data
++ * in_duration: duration of data
++ * ret: GstFlowReturn to return in the chain function
++ *
++ * Decode the given frame and pushes it downstream.
++ *
++ * Returns: Number of bytes used in decoding, -1 on error/failure.
++ */
++
++static gint
++gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec,
++    guint8 * data, guint size, gint * got_data, const GstTSInfo * dec_info,
++    GstFlowReturn * ret)
++{
++  GstFFMpegDecClass *oclass;
++  GstBuffer *outbuf = NULL;
++  gint have_data = 0, len = 0;
++
++  if (G_UNLIKELY (ffmpegdec->context->codec == NULL))
++    goto no_codec;
++
++  GST_LOG_OBJECT (ffmpegdec, "data:%p, size:%d, id:%d", data, size,
++      dec_info->idx);
++
++  *ret = GST_FLOW_OK;
++  ffmpegdec->context->frame_number++;
++
++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++
++  switch (oclass->in_plugin->type) {
++    case AVMEDIA_TYPE_VIDEO:
++      len =
++          gst_ffmpegdec_video_frame (ffmpegdec, data, size, dec_info, &outbuf,
++          ret);
++      break;
++    case AVMEDIA_TYPE_AUDIO:
++      len =
++          gst_ffmpegdec_audio_frame (ffmpegdec, oclass->in_plugin, data, size,
++          dec_info, &outbuf, ret);
++
++      /* if we did not get an output buffer and we have a pending discont, don't
++       * clear the input timestamps, we will put them on the next buffer because
++       * else we might create the first buffer with a very big timestamp gap. */
++      if (outbuf == NULL && ffmpegdec->discont) {
++        GST_DEBUG_OBJECT (ffmpegdec, "no buffer but keeping timestamp");
++        ffmpegdec->clear_ts = FALSE;
++      }
++      break;
++    default:
++      GST_ERROR_OBJECT (ffmpegdec, "Asked to decode non-audio/video frame !");
++      g_assert_not_reached ();
++      break;
++  }
++
++  if (outbuf)
++    have_data = 1;
++
++  if (len < 0 || have_data < 0) {
++    GST_WARNING_OBJECT (ffmpegdec,
++        "ffdec_%s: decoding error (len: %d, have_data: %d)",
++        oclass->in_plugin->name, len, have_data);
++    *got_data = 0;
++    goto beach;
++  } else if (len == 0 && have_data == 0) {
++    *got_data = 0;
++    goto beach;
++  } else {
++    /* this is where I lost my last clue on ffmpeg... */
++    *got_data = 1;
++  }
++
++  if (outbuf) {
++    GST_LOG_OBJECT (ffmpegdec,
++        "Decoded data, now pushing buffer %p with offset %" G_GINT64_FORMAT
++        ", timestamp %" GST_TIME_FORMAT " and duration %" GST_TIME_FORMAT,
++        outbuf, GST_BUFFER_OFFSET (outbuf),
++        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
++        GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)));
++
++    /* mark pending discont */
++    if (ffmpegdec->discont) {
++      GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
++      ffmpegdec->discont = FALSE;
++    }
++
++    if (ffmpegdec->segment.rate > 0.0) {
++      /* and off we go */
++      *ret = gst_pad_push (ffmpegdec->srcpad, outbuf);
++    } else {
++      /* reverse playback, queue frame till later when we get a discont. */
++      GST_DEBUG_OBJECT (ffmpegdec, "queued frame");
++      ffmpegdec->queued = g_list_prepend (ffmpegdec->queued, outbuf);
++      *ret = GST_FLOW_OK;
++    }
++  } else {
++    GST_DEBUG_OBJECT (ffmpegdec, "We didn't get a decoded buffer");
++  }
++
++beach:
++  return len;
++
++  /* ERRORS */
++no_codec:
++  {
++    GST_ERROR_OBJECT (ffmpegdec, "no codec context");
++    return -1;
++  }
++}
++
++static void
++gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec)
++{
++  GstFFMpegDecClass *oclass;
++
++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++
++  if (oclass->in_plugin->capabilities & CODEC_CAP_DELAY) {
++    gint have_data, len, try = 0;
++
++    GST_LOG_OBJECT (ffmpegdec,
++        "codec has delay capabilities, calling until ffmpeg has drained everything");
++
++    do {
++      GstFlowReturn ret;
++
++      len =
++          gst_ffmpegdec_frame (ffmpegdec, NULL, 0, &have_data, &ts_info_none,
++          &ret);
++      if (len < 0 || have_data == 0)
++        break;
++    } while (try++ < 10);
++  }
++  if (ffmpegdec->segment.rate < 0.0) {
++    /* if we have some queued frames for reverse playback, flush them now */
++    flush_queued (ffmpegdec);
++  }
++}
++
++static void
++gst_ffmpegdec_flush_pcache (GstFFMpegDec * ffmpegdec)
++{
++  if (ffmpegdec->pctx) {
++    gint size, bsize;
++    guint8 *data;
++    guint8 bdata[FF_INPUT_BUFFER_PADDING_SIZE];
++
++    bsize = FF_INPUT_BUFFER_PADDING_SIZE;
++    memset (bdata, 0, bsize);
++
++    /* parse some dummy data to work around some ffmpeg weirdness where it keeps
++     * the previous pts around */
++    av_parser_parse2 (ffmpegdec->pctx, ffmpegdec->context,
++        &data, &size, bdata, bsize, -1, -1, -1);
++    ffmpegdec->pctx->pts = -1;
++    ffmpegdec->pctx->dts = -1;
++  }
++
++  if (ffmpegdec->pcache) {
++    gst_buffer_unref (ffmpegdec->pcache);
++    ffmpegdec->pcache = NULL;
++  }
++}
++
++static gboolean
++gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event)
++{
++  GstFFMpegDec *ffmpegdec;
++  gboolean ret = FALSE;
++
++  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
++
++  GST_DEBUG_OBJECT (ffmpegdec, "Handling %s event",
++      GST_EVENT_TYPE_NAME (event));
++
++  switch (GST_EVENT_TYPE (event)) {
++    case GST_EVENT_EOS:
++    {
++      gst_ffmpegdec_drain (ffmpegdec);
++      break;
++    }
++    case GST_EVENT_FLUSH_STOP:
++    {
++      if (ffmpegdec->opened) {
++        avcodec_flush_buffers (ffmpegdec->context);
++      }
++      gst_ffmpegdec_reset_ts (ffmpegdec);
++      gst_ffmpegdec_reset_qos (ffmpegdec);
++      gst_ffmpegdec_flush_pcache (ffmpegdec);
++      gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
++      clear_queued (ffmpegdec);
++      break;
++    }
++    case GST_EVENT_NEWSEGMENT:
++    {
++      gboolean update;
++      GstFormat fmt;
++      gint64 start, stop, time;
++      gdouble rate, arate;
++
++      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &fmt,
++          &start, &stop, &time);
++
++      switch (fmt) {
++        case GST_FORMAT_TIME:
++          /* fine, our native segment format */
++          break;
++        case GST_FORMAT_BYTES:
++        {
++          gint bit_rate;
++
++          bit_rate = ffmpegdec->context->bit_rate;
++
++          /* convert to time or fail */
++          if (!bit_rate)
++            goto no_bitrate;
++
++          GST_DEBUG_OBJECT (ffmpegdec, "bitrate: %d", bit_rate);
++
++          /* convert values to TIME */
++          if (start != -1)
++            start = gst_util_uint64_scale_int (start, GST_SECOND, bit_rate);
++          if (stop != -1)
++            stop = gst_util_uint64_scale_int (stop, GST_SECOND, bit_rate);
++          if (time != -1)
++            time = gst_util_uint64_scale_int (time, GST_SECOND, bit_rate);
++
++          /* unref old event */
++          gst_event_unref (event);
++
++          /* create new converted time segment */
++          fmt = GST_FORMAT_TIME;
++          /* FIXME, bitrate is not good enough too find a good stop, let's
++           * hope start and time were 0... meh. */
++          stop = -1;
++          event = gst_event_new_new_segment (update, rate, fmt,
++              start, stop, time);
++          break;
++        }
++        default:
++          /* invalid format */
++          goto invalid_format;
++      }
++
++      /* drain pending frames before trying to use the new segment, queued
++       * buffers belonged to the previous segment. */
++      if (ffmpegdec->context->codec)
++        gst_ffmpegdec_drain (ffmpegdec);
++
++      GST_DEBUG_OBJECT (ffmpegdec,
++          "NEWSEGMENT in time start %" GST_TIME_FORMAT " -- stop %"
++          GST_TIME_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
++
++      /* and store the values */
++      gst_segment_set_newsegment_full (&ffmpegdec->segment, update,
++          rate, arate, fmt, start, stop, time);
++      break;
++    }
++    default:
++      break;
++  }
++
++  /* and push segment downstream */
++  ret = gst_pad_push_event (ffmpegdec->srcpad, event);
++
++done:
++  gst_object_unref (ffmpegdec);
++
++  return ret;
++
++  /* ERRORS */
++no_bitrate:
++  {
++    GST_WARNING_OBJECT (ffmpegdec, "no bitrate to convert BYTES to TIME");
++    gst_event_unref (event);
++    goto done;
++  }
++invalid_format:
++  {
++    GST_WARNING_OBJECT (ffmpegdec, "unknown format received in NEWSEGMENT");
++    gst_event_unref (event);
++    goto done;
++  }
++}
++
++static GstFlowReturn
++gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
++{
++  GstFFMpegDec *ffmpegdec;
++  GstFFMpegDecClass *oclass;
++  guint8 *data, *bdata;
++  gint size, bsize, len, have_data;
++  GstFlowReturn ret = GST_FLOW_OK;
++  GstClockTime in_timestamp;
++  GstClockTime in_duration;
++  gboolean discont;
++  gint64 in_offset;
++  const GstTSInfo *in_info;
++  const GstTSInfo *dec_info;
++
++  ffmpegdec = (GstFFMpegDec *) (GST_PAD_PARENT (pad));
++
++  if (G_UNLIKELY (!ffmpegdec->opened))
++    goto not_negotiated;
++
++  discont = GST_BUFFER_IS_DISCONT (inbuf);
++
++  /* The discont flags marks a buffer that is not continuous with the previous
++   * buffer. This means we need to clear whatever data we currently have. We
++   * currently also wait for a new keyframe, which might be suboptimal in the
++   * case of a network error, better show the errors than to drop all data.. */
++  if (G_UNLIKELY (discont)) {
++    GST_DEBUG_OBJECT (ffmpegdec, "received DISCONT");
++    /* drain what we have queued */
++    gst_ffmpegdec_drain (ffmpegdec);
++    gst_ffmpegdec_flush_pcache (ffmpegdec);
++    avcodec_flush_buffers (ffmpegdec->context);
++    ffmpegdec->discont = TRUE;
++    gst_ffmpegdec_reset_ts (ffmpegdec);
++  }
++  /* by default we clear the input timestamp after decoding each frame so that
++   * interpollation can work. */
++  ffmpegdec->clear_ts = TRUE;
++
++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++
++  /* parse cache joining. If there is cached data */
++  if (ffmpegdec->pcache) {
++    /* join with previous data */
++    GST_LOG_OBJECT (ffmpegdec, "join parse cache");
++    inbuf = gst_buffer_join (ffmpegdec->pcache, inbuf);
++    /* no more cached data, we assume we can consume the complete cache */
++    ffmpegdec->pcache = NULL;
++  }
++
++  in_timestamp = GST_BUFFER_TIMESTAMP (inbuf);
++  in_duration = GST_BUFFER_DURATION (inbuf);
++  in_offset = GST_BUFFER_OFFSET (inbuf);
++
++  /* get handle to timestamp info, we can pass this around to ffmpeg */
++  in_info = gst_ts_info_store (ffmpegdec, in_timestamp, in_duration, in_offset);
++
++  if (in_timestamp != -1) {
++    /* check for increasing timestamps if they are jumping backwards, we
++     * probably are dealing with PTS as timestamps */
++    if (!ffmpegdec->reordered_in && ffmpegdec->last_in != -1) {
++      if (in_timestamp < ffmpegdec->last_in) {
++        GST_LOG_OBJECT (ffmpegdec, "detected reordered input timestamps");
++        ffmpegdec->reordered_in = TRUE;
++        ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
++      } else if (in_timestamp > ffmpegdec->last_in) {
++        GstClockTime diff;
++        /* keep track of timestamp diff to estimate duration */
++        diff = in_timestamp - ffmpegdec->last_in;
++        /* need to scale with amount of frames in the interval */
++        if (ffmpegdec->last_frames)
++          diff /= ffmpegdec->last_frames;
++
++        GST_LOG_OBJECT (ffmpegdec, "estimated duration %" GST_TIME_FORMAT " %u",
++            GST_TIME_ARGS (diff), ffmpegdec->last_frames);
++
++        ffmpegdec->last_diff = diff;
++      }
++    }
++    ffmpegdec->last_in = in_timestamp;
++    ffmpegdec->last_frames = 0;
++  }
++
++  GST_LOG_OBJECT (ffmpegdec,
++      "Received new data of size %u, offset:%" G_GUINT64_FORMAT ", ts:%"
++      GST_TIME_FORMAT ", dur:%" GST_TIME_FORMAT ", info %d",
++      GST_BUFFER_SIZE (inbuf), GST_BUFFER_OFFSET (inbuf),
++      GST_TIME_ARGS (in_timestamp), GST_TIME_ARGS (in_duration), in_info->idx);
++
++  /* workarounds, functions write to buffers:
++   *  libavcodec/svq1.c:svq1_decode_frame writes to the given buffer.
++   *  libavcodec/svq3.c:svq3_decode_slice_header too.
++   * ffmpeg devs know about it and will fix it (they said). */
++  if (oclass->in_plugin->id == CODEC_ID_SVQ1 ||
++      oclass->in_plugin->id == CODEC_ID_SVQ3) {
++    inbuf = gst_buffer_make_writable (inbuf);
++  }
++
++  bdata = GST_BUFFER_DATA (inbuf);
++  bsize = GST_BUFFER_SIZE (inbuf);
++
++  if (ffmpegdec->do_padding) {
++    /* add padding */
++    if (ffmpegdec->padded_size < bsize + FF_INPUT_BUFFER_PADDING_SIZE) {
++      ffmpegdec->padded_size = bsize + FF_INPUT_BUFFER_PADDING_SIZE;
++      ffmpegdec->padded = g_realloc (ffmpegdec->padded, ffmpegdec->padded_size);
++      GST_LOG_OBJECT (ffmpegdec, "resized padding buffer to %d",
++          ffmpegdec->padded_size);
++    }
++    memcpy (ffmpegdec->padded, bdata, bsize);
++    memset (ffmpegdec->padded + bsize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
++
++    bdata = ffmpegdec->padded;
++  }
++
++  do {
++    guint8 tmp_padding[FF_INPUT_BUFFER_PADDING_SIZE];
++
++    /* parse, if at all possible */
++    if (ffmpegdec->pctx) {
++      gint res;
++
++      GST_LOG_OBJECT (ffmpegdec,
++          "Calling av_parser_parse2 with offset %" G_GINT64_FORMAT ", ts:%"
++          GST_TIME_FORMAT " size %d", in_offset, GST_TIME_ARGS (in_timestamp),
++          bsize);
++
++      /* feed the parser. We pass the timestamp info so that we can recover all
++       * info again later */
++      res = av_parser_parse2 (ffmpegdec->pctx, ffmpegdec->context,
++          &data, &size, bdata, bsize, in_info->idx, in_info->idx, in_offset);
++
++      GST_LOG_OBJECT (ffmpegdec,
++          "parser returned res %d and size %d, id %" G_GINT64_FORMAT, res, size,
++          ffmpegdec->pctx->pts);
++
++      /* store pts for decoding */
++      if (ffmpegdec->pctx->pts != AV_NOPTS_VALUE && ffmpegdec->pctx->pts != -1)
++        dec_info = gst_ts_info_get (ffmpegdec, ffmpegdec->pctx->pts);
++      else {
++        /* ffmpeg sometimes loses track after a flush, help it by feeding a
++         * valid start time */
++        ffmpegdec->pctx->pts = in_info->idx;
++        ffmpegdec->pctx->dts = in_info->idx;
++        dec_info = in_info;
++      }
++
++      GST_LOG_OBJECT (ffmpegdec, "consuming %d bytes. id %d", size,
++          dec_info->idx);
++
++      if (res) {
++        /* there is output, set pointers for next round. */
++        bsize -= res;
++        bdata += res;
++      } else {
++        /* Parser did not consume any data, make sure we don't clear the
++         * timestamp for the next round */
++        ffmpegdec->clear_ts = FALSE;
++      }
++
++      /* if there is no output, we must break and wait for more data. also the
++       * timestamp in the context is not updated. */
++      if (size == 0) {
++        if (bsize > 0)
++          continue;
++        else
++          break;
++      }
++    } else {
++      data = bdata;
++      size = bsize;
++
++      dec_info = in_info;
++    }
++
++    if (ffmpegdec->do_padding) {
++      /* add temporary padding */
++      memcpy (tmp_padding, data + size, FF_INPUT_BUFFER_PADDING_SIZE);
++      memset (data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
++    }
++
++    /* decode a frame of audio/video now */
++    len =
++        gst_ffmpegdec_frame (ffmpegdec, data, size, &have_data, dec_info, &ret);
++
++    if (ffmpegdec->do_padding) {
++      memcpy (data + size, tmp_padding, FF_INPUT_BUFFER_PADDING_SIZE);
++    }
++
++    if (ret != GST_FLOW_OK) {
++      GST_LOG_OBJECT (ffmpegdec, "breaking because of flow ret %s",
++          gst_flow_get_name (ret));
++      /* bad flow retun, make sure we discard all data and exit */
++      bsize = 0;
++      break;
++    }
++    if (!ffmpegdec->pctx) {
++      if (len == 0 && !have_data) {
++        /* nothing was decoded, this could be because no data was available or
++         * because we were skipping frames.
++         * If we have no context we must exit and wait for more data, we keep the
++         * data we tried. */
++        GST_LOG_OBJECT (ffmpegdec, "Decoding didn't return any data, breaking");
++        break;
++      } else if (len < 0) {
++        /* a decoding error happened, we must break and try again with next data. */
++        GST_LOG_OBJECT (ffmpegdec, "Decoding error, breaking");
++        bsize = 0;
++        break;
++      }
++      /* prepare for the next round, for codecs with a context we did this
++       * already when using the parser. */
++      bsize -= len;
++      bdata += len;
++    } else {
++      if (len == 0) {
++        /* nothing was decoded, this could be because no data was available or
++         * because we were skipping frames. Since we have a parser we can
++         * continue with the next frame */
++        GST_LOG_OBJECT (ffmpegdec,
++            "Decoding didn't return any data, trying next");
++      } else if (len < 0) {
++        /* we have a context that will bring us to the next frame */
++        GST_LOG_OBJECT (ffmpegdec, "Decoding error, trying next");
++      }
++    }
++
++    /* make sure we don't use the same old timestamp for the next frame and let
++     * the interpollation take care of it. */
++    if (ffmpegdec->clear_ts) {
++      in_timestamp = GST_CLOCK_TIME_NONE;
++      in_duration = GST_CLOCK_TIME_NONE;
++      in_offset = GST_BUFFER_OFFSET_NONE;
++      in_info = GST_TS_INFO_NONE;
++    } else {
++      ffmpegdec->clear_ts = TRUE;
++    }
++    ffmpegdec->last_frames++;
++
++    GST_LOG_OBJECT (ffmpegdec, "Before (while bsize>0).  bsize:%d , bdata:%p",
++        bsize, bdata);
++  } while (bsize > 0);
++
++  /* keep left-over */
++  if (ffmpegdec->pctx && bsize > 0) {
++    in_timestamp = GST_BUFFER_TIMESTAMP (inbuf);
++    in_offset = GST_BUFFER_OFFSET (inbuf);
++
++    GST_LOG_OBJECT (ffmpegdec,
++        "Keeping %d bytes of data with offset %" G_GINT64_FORMAT ", timestamp %"
++        GST_TIME_FORMAT, bsize, in_offset, GST_TIME_ARGS (in_timestamp));
++
++    ffmpegdec->pcache = gst_buffer_create_sub (inbuf,
++        GST_BUFFER_SIZE (inbuf) - bsize, bsize);
++    /* we keep timestamp, even though all we really know is that the correct
++     * timestamp is not below the one from inbuf */
++    GST_BUFFER_TIMESTAMP (ffmpegdec->pcache) = in_timestamp;
++    GST_BUFFER_OFFSET (ffmpegdec->pcache) = in_offset;
++  } else if (bsize > 0) {
++    GST_DEBUG_OBJECT (ffmpegdec, "Dropping %d bytes of data", bsize);
++  }
++  gst_buffer_unref (inbuf);
++
++  return ret;
++
++  /* ERRORS */
++not_negotiated:
++  {
++    oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
++        ("ffdec_%s: input format was not set before data start",
++            oclass->in_plugin->name));
++    gst_buffer_unref (inbuf);
++    return GST_FLOW_NOT_NEGOTIATED;
++  }
++}
++
++static GstStateChangeReturn
++gst_ffmpegdec_change_state (GstElement * element, GstStateChange transition)
++{
++  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) element;
++  GstStateChangeReturn ret;
++
++  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
++
++  switch (transition) {
++    case GST_STATE_CHANGE_PAUSED_TO_READY:
++      GST_OBJECT_LOCK (ffmpegdec);
++      gst_ffmpegdec_close (ffmpegdec);
++      GST_OBJECT_UNLOCK (ffmpegdec);
++      clear_queued (ffmpegdec);
++      g_free (ffmpegdec->padded);
++      ffmpegdec->padded = NULL;
++      ffmpegdec->padded_size = 0;
++      ffmpegdec->can_allocate_aligned = TRUE;
++      break;
++    default:
++      break;
++  }
++
++  return ret;
++}
++
++static void
++gst_ffmpegdec_set_property (GObject * object,
++    guint prop_id, const GValue * value, GParamSpec * pspec)
++{
++  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
++
++  switch (prop_id) {
++    case PROP_LOWRES:
++      ffmpegdec->lowres = ffmpegdec->context->lowres = g_value_get_enum (value);
++      break;
++    case PROP_SKIPFRAME:
++      ffmpegdec->skip_frame = ffmpegdec->context->skip_frame =
++          g_value_get_enum (value);
++      break;
++    case PROP_DIRECT_RENDERING:
++      ffmpegdec->direct_rendering = g_value_get_boolean (value);
++      break;
++    case PROP_DO_PADDING:
++      ffmpegdec->do_padding = g_value_get_boolean (value);
++      break;
++    case PROP_DEBUG_MV:
++      ffmpegdec->debug_mv = ffmpegdec->context->debug_mv =
++          g_value_get_boolean (value);
++      break;
++    case PROP_CROP:
++      ffmpegdec->crop = g_value_get_boolean (value);
++      break;
++    case PROP_MAX_THREADS:
++      ffmpegdec->max_threads = g_value_get_int (value);
++      break;
++    default:
++      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
++      break;
++  }
++}
++
++static void
++gst_ffmpegdec_get_property (GObject * object,
++    guint prop_id, GValue * value, GParamSpec * pspec)
++{
++  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
++
++  switch (prop_id) {
++    case PROP_LOWRES:
++      g_value_set_enum (value, ffmpegdec->context->lowres);
++      break;
++    case PROP_SKIPFRAME:
++      g_value_set_enum (value, ffmpegdec->context->skip_frame);
++      break;
++    case PROP_DIRECT_RENDERING:
++      g_value_set_boolean (value, ffmpegdec->direct_rendering);
++      break;
++    case PROP_DO_PADDING:
++      g_value_set_boolean (value, ffmpegdec->do_padding);
++      break;
++    case PROP_DEBUG_MV:
++      g_value_set_boolean (value, ffmpegdec->context->debug_mv);
++      break;
++    case PROP_CROP:
++      g_value_set_boolean (value, ffmpegdec->crop);
++      break;
++    case PROP_MAX_THREADS:
++      g_value_set_int (value, ffmpegdec->max_threads);
++      break;
++    default:
++      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
++      break;
++  }
++}
++
++gboolean
++gst_ffmpegdec_register (GstPlugin * plugin)
++{
++  GTypeInfo typeinfo = {
++    sizeof (GstFFMpegDecClass),
++    (GBaseInitFunc) gst_ffmpegdec_base_init,
++    NULL,
++    (GClassInitFunc) gst_ffmpegdec_class_init,
++    NULL,
++    NULL,
++    sizeof (GstFFMpegDec),
++    0,
++    (GInstanceInitFunc) gst_ffmpegdec_init,
++  };
++  GType type;
++  AVCodec *in_plugin;
++  gint rank;
++
++  in_plugin = av_codec_next (NULL);
++
++  GST_LOG ("Registering decoders");
++
++  while (in_plugin) {
++    gchar *type_name;
++    gchar *plugin_name;
++
++    /* only decoders */
++    if (!in_plugin->decode) {
++      goto next;
++    }
++
++    /* no quasi-codecs, please */
++    if (in_plugin->id == CODEC_ID_RAWVIDEO ||
++        in_plugin->id == CODEC_ID_V210 ||
++        in_plugin->id == CODEC_ID_V210X ||
++        in_plugin->id == CODEC_ID_R210 ||
++        (in_plugin->id >= CODEC_ID_PCM_S16LE &&
++            in_plugin->id <= CODEC_ID_PCM_BLURAY)) {
++      goto next;
++    }
++
++    /* No decoders depending on external libraries (we don't build them, but
++     * people who build against an external ffmpeg might have them.
++     * We have native gstreamer plugins for all of those libraries anyway. */
++    if (!strncmp (in_plugin->name, "lib", 3)) {
++      GST_DEBUG
++          ("Not using external library decoder %s. Use the gstreamer-native ones instead.",
++          in_plugin->name);
++      goto next;
++    }
++
++    /* No vdpau plugins until we can figure out how to properly use them
++     * outside of ffmpeg. */
++    if (g_str_has_suffix (in_plugin->name, "_vdpau")) {
++      GST_DEBUG
++          ("Ignoring VDPAU decoder %s. We can't handle this outside of ffmpeg",
++          in_plugin->name);
++      goto next;
++    }
++
++    if (g_str_has_suffix (in_plugin->name, "_xvmc")) {
++      GST_DEBUG
++          ("Ignoring XVMC decoder %s. We can't handle this outside of ffmpeg",
++          in_plugin->name);
++      goto next;
++    }
++
++    GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name);
++
++    /* no codecs for which we're GUARANTEED to have better alternatives */
++    /* MPEG1VIDEO : the mpeg2video decoder is preferred */
++    /* MP1 : Use MP3 for decoding */
++    /* MP2 : Use MP3 for decoding */
++    /* Theora: Use libtheora based theoradec */
++    if (!strcmp (in_plugin->name, "gif") ||
++        !strcmp (in_plugin->name, "vorbis") ||
++        !strcmp (in_plugin->name, "theora") ||
++        !strcmp (in_plugin->name, "mpeg1video") ||
++        !strcmp (in_plugin->name, "wavpack") ||
++        !strcmp (in_plugin->name, "mp1") ||
++        !strcmp (in_plugin->name, "mp2") ||
++        !strcmp (in_plugin->name, "libfaad") ||
++        !strcmp (in_plugin->name, "mpeg4aac") ||
++        !strcmp (in_plugin->name, "ass") ||
++        !strcmp (in_plugin->name, "srt") ||
++        !strcmp (in_plugin->name, "pgssub") ||
++        !strcmp (in_plugin->name, "dvdsub") ||
++        !strcmp (in_plugin->name, "dvbsub")) {
++      GST_LOG ("Ignoring decoder %s", in_plugin->name);
++      goto next;
++    }
++
++    /* construct the type */
++    plugin_name = g_strdup ((gchar *) in_plugin->name);
++    g_strdelimit (plugin_name, NULL, '_');
++    type_name = g_strdup_printf ("ffdec_%s", plugin_name);
++    g_free (plugin_name);
++
++    type = g_type_from_name (type_name);
++
++    if (!type) {
++      /* create the gtype now */
++      type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
++      g_type_set_qdata (type, GST_FFDEC_PARAMS_QDATA, (gpointer) in_plugin);
++    }
++
++    /* (Ronald) MPEG-4 gets a higher priority because it has been well-
++     * tested and by far outperforms divxdec/xviddec - so we prefer it.
++     * msmpeg4v3 same, as it outperforms divxdec for divx3 playback.
++     * VC1/WMV3 are not working and thus unpreferred for now. */
++    switch (in_plugin->id) {
++      case CODEC_ID_MPEG4:
++      case CODEC_ID_MSMPEG4V3:
++      case CODEC_ID_H264:
++      case CODEC_ID_RA_144:
++      case CODEC_ID_RA_288:
++      case CODEC_ID_RV10:
++      case CODEC_ID_RV20:
++      case CODEC_ID_RV30:
++      case CODEC_ID_RV40:
++      case CODEC_ID_COOK:
++        rank = GST_RANK_SECONDARY;
++        break;
++        /* DVVIDEO: we have a good dv decoder, fast on both ppc as well as x86.
++         * They say libdv's quality is better though. leave as secondary.
++         * note: if you change this, see the code in gstdv.c in good/ext/dv.
++         *
++         * SIPR: decoder should have a higher rank than realaudiodec.
++         */
++      case CODEC_ID_DVVIDEO:
++      case CODEC_ID_SIPR:
++        rank = GST_RANK_SECONDARY;
++        break;
++      case CODEC_ID_MP3:
++        rank = GST_RANK_NONE;
++        break;
++        /* TEMPORARILY DISABLING AC3/EAC3/DTS for 0.10.12 release
++         * due to downmixing failure.
++         * See Bug #608892 for more details */
++      case CODEC_ID_EAC3:
++      case CODEC_ID_AC3:
++      case CODEC_ID_DTS:
++        rank = GST_RANK_NONE;
++        break;
++      default:
++        rank = GST_RANK_MARGINAL;
++        break;
++    }
++    if (!gst_element_register (plugin, type_name, rank, type)) {
++      g_warning ("Failed to register %s", type_name);
++      g_free (type_name);
++      return FALSE;
++    }
++
++    g_free (type_name);
++
++  next:
++    in_plugin = av_codec_next (in_plugin);
++  }
++
++  GST_LOG ("Finished Registering decoders");
++
++  return TRUE;
++}
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.rej gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.rej
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.rej	1970-01-01 01:00:00.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.rej	2014-08-08 15:26:38.471858652 +0200
+@@ -0,0 +1,11 @@
++--- ext/ffmpeg/gstffmpegdec.c
+++++ ext/ffmpeg/gstffmpegdec.c
++@@ -1565,7 +1564,7 @@
++         gst_message_new_latency (GST_OBJECT_CAST (ffmpegdec)));
++   }
++ 
++-  is_itype = (ffmpegdec->picture->pict_type == FF_I_TYPE);
+++  is_itype = (ffmpegdec->picture->pict_type == AV_PICTURE_TYPE_I);
++   is_reference = (ffmpegdec->picture->reference == 1);
++ 
++   iskeyframe = (is_itype || is_reference || ffmpegdec->picture->key_frame)
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdemux.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdemux.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdemux.c	2011-07-13 11:07:28.000000000 +0200
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdemux.c	2014-08-08 15:26:07.874857555 +0200
+@@ -343,8 +343,11 @@
+   demux->audiopads = 0;
+ 
+   /* close demuxer context from ffmpeg */
+-  av_close_input_file (demux->context);
+-  demux->context = NULL;
++  if (demux->seekable)
++    gst_ffmpegdata_close (demux->context->pb);
++  else
++    gst_ffmpeg_pipe_close (demux->context->pb);
++  avformat_close_input (&demux->context);
+ 
+   GST_OBJECT_LOCK (demux);
+   demux->opened = FALSE;
+@@ -1146,9 +1149,9 @@
+ static gboolean
+ gst_ffmpegdemux_open (GstFFMpegDemux * demux)
+ {
++  AVIOContext *iocontext = NULL;
+   GstFFMpegDemuxClass *oclass =
+       (GstFFMpegDemuxClass *) G_OBJECT_GET_CLASS (demux);
+-  gchar *location;
+   gint res, n_streams, i;
+ #if 0
+   /* Re-enable once converted to new AVMetaData API
+@@ -1164,15 +1167,14 @@
+ 
+   /* open via our input protocol hack */
+   if (demux->seekable)
+-    location = g_strdup_printf ("gstreamer://%p", demux->sinkpad);
++    res = gst_ffmpegdata_open (demux->sinkpad, AVIO_FLAG_READ, &iocontext);
+   else
+-    location = g_strdup_printf ("gstpipe://%p", &demux->ffpipe);
+-  GST_DEBUG_OBJECT (demux, "about to call av_open_input_file %s", location);
++    res = gst_ffmpeg_pipe_open (&demux->ffpipe, AVIO_FLAG_READ, &iocontext);
+ 
+-  res = av_open_input_file (&demux->context, location,
+-      oclass->in_plugin, 0, NULL);
++  demux->context = avformat_alloc_context ();
++  demux->context->pb = iocontext;
++  res = avformat_open_input (&demux->context, NULL, oclass->in_plugin, NULL);
+ 
+-  g_free (location);
+   GST_DEBUG_OBJECT (demux, "av_open_input returned %d", res);
+   if (res < 0)
+     goto open_failed;
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegenc.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegenc.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegenc.c	2011-10-31 11:14:03.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegenc.c	2014-08-08 15:32:18.608870847 +0200
+@@ -770,7 +770,7 @@
+   GST_OBJECT_UNLOCK (ffmpegenc);
+ 
+   if (force_keyframe)
+-    ffmpegenc->picture->pict_type = FF_I_TYPE;
++    ffmpegenc->picture->pict_type = AV_PICTURE_TYPE_I;
+ 
+   frame_size = gst_ffmpeg_avpicture_fill ((AVPicture *) ffmpegenc->picture,
+       GST_BUFFER_DATA (inbuf),
+@@ -1136,7 +1136,7 @@
+       const GstStructure *s;
+       s = gst_event_get_structure (event);
+       if (gst_structure_has_name (s, "GstForceKeyUnit")) {
+-        ffmpegenc->picture->pict_type = FF_I_TYPE;
++        ffmpegenc->picture->pict_type = AV_PICTURE_TYPE_I;
+       }
+       break;
+     }
+@@ -1339,7 +1339,7 @@
+     }
+ 
+     /* only encoders */
+-    if (!in_plugin->encode) {
++    if (!av_codec_is_encoder (in_plugin)) {
+       goto next;
+     }
+ 
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c	2011-07-13 11:07:28.000000000 +0200
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c	2014-08-08 15:26:07.874857555 +0200
+@@ -24,8 +24,10 @@
+ #include <string.h>
+ #ifdef HAVE_FFMPEG_UNINSTALLED
+ #include <avformat.h>
++#include <opt.h>
+ #else
+ #include <libavformat/avformat.h>
++#include <libavutil/opt.h>
+ #endif
+ 
+ #include <gst/gst.h>
+@@ -336,9 +338,6 @@
+   ffmpegmux->context = g_new0 (AVFormatContext, 1);
+   ffmpegmux->context->oformat = oclass->in_plugin;
+   ffmpegmux->context->nb_streams = 0;
+-  g_snprintf (ffmpegmux->context->filename,
+-      sizeof (ffmpegmux->context->filename),
+-      "gstreamer://%p", ffmpegmux->srcpad);
+   ffmpegmux->opened = FALSE;
+ 
+   ffmpegmux->videopads = 0;
+@@ -450,10 +449,10 @@
+   gst_element_add_pad (element, pad);
+ 
+   /* AVStream needs to be created */
+-  st = av_new_stream (ffmpegmux->context, collect_pad->padnum);
++  st = avformat_new_stream (ffmpegmux->context, NULL);
++  st->id = collect_pad->padnum;
+   st->codec->codec_type = type;
+   st->codec->codec_id = CODEC_ID_NONE;  /* this is a check afterwards */
+-  st->stream_copy = 1;          /* we're not the actual encoder */
+   st->codec->bit_rate = bitrate;
+   st->codec->frame_size = framesize;
+   /* we fill in codec during capsnego */
+@@ -485,7 +484,7 @@
+   collect_pad = (GstFFMpegMuxPad *) gst_pad_get_element_private (pad);
+ 
+   st = ffmpegmux->context->streams[collect_pad->padnum];
+-  ffmpegmux->context->preload = ffmpegmux->preload;
++  av_opt_set_int (&ffmpegmux->context, "preload", ffmpegmux->preload, 0);
+   ffmpegmux->context->max_delay = ffmpegmux->max_delay;
+ 
+   /* for the format-specific guesses, we'll go to
+@@ -552,7 +551,7 @@
+ 
+   /* open "file" (gstreamer protocol to next element) */
+   if (!ffmpegmux->opened) {
+-    int open_flags = URL_WRONLY;
++    int open_flags = AVIO_FLAG_WRITE;
+ 
+     /* we do need all streams to have started capsnego,
+      * or things will go horribly wrong */
+@@ -646,19 +645,13 @@
+       open_flags |= GST_FFMPEG_URL_STREAMHEADER;
+     }
+ 
+-    if (url_fopen (&ffmpegmux->context->pb,
+-            ffmpegmux->context->filename, open_flags) < 0) {
++    if (gst_ffmpegdata_open (ffmpegmux->srcpad, open_flags,
++            &ffmpegmux->context->pb) < 0) {
+       GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, TOO_LAZY, (NULL),
+           ("Failed to open stream context in ffmux"));
+       return GST_FLOW_ERROR;
+     }
+ 
+-    if (av_set_parameters (ffmpegmux->context, NULL) < 0) {
+-      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, INIT, (NULL),
+-          ("Failed to initialize muxer"));
+-      return GST_FLOW_ERROR;
+-    }
+-
+     /* now open the mux format */
+     if (av_write_header (ffmpegmux->context) < 0) {
+       GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, SETTINGS, (NULL),
+@@ -670,7 +663,7 @@
+     ffmpegmux->opened = TRUE;
+ 
+     /* flush the header so it will be used as streamheader */
+-    put_flush_packet (ffmpegmux->context->pb);
++    avio_flush (ffmpegmux->context->pb);
+   }
+ 
+   /* take the one with earliest timestamp,
+@@ -770,8 +763,8 @@
+     /* close down */
+     av_write_trailer (ffmpegmux->context);
+     ffmpegmux->opened = FALSE;
+-    put_flush_packet (ffmpegmux->context->pb);
+-    url_fclose (ffmpegmux->context->pb);
++    avio_flush (ffmpegmux->context->pb);
++    gst_ffmpegdata_close (ffmpegmux->context->pb);
+     gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_eos ());
+     return GST_FLOW_UNEXPECTED;
+   }
+@@ -795,6 +788,10 @@
+       break;
+     case GST_STATE_CHANGE_PAUSED_TO_READY:
+       gst_collect_pads_stop (ffmpegmux->collect);
++      if (ffmpegmux->opened) {
++        ffmpegmux->opened = FALSE;
++        gst_ffmpegdata_close (ffmpegmux->context->pb);
++      }
+       break;
+     default:
+       break;
+@@ -809,7 +806,7 @@
+       gst_tag_setter_reset_tags (GST_TAG_SETTER (ffmpegmux));
+       if (ffmpegmux->opened) {
+         ffmpegmux->opened = FALSE;
+-        url_fclose (ffmpegmux->context->pb);
++        avio_close (ffmpegmux->context->pb);
+       }
+       break;
+     case GST_STATE_CHANGE_READY_TO_NULL:
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c.orig
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c.orig	1970-01-01 01:00:00.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c.orig	2011-07-13 11:07:28.000000000 +0200
+@@ -0,0 +1,970 @@
++/* 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>
++#ifdef HAVE_FFMPEG_UNINSTALLED
++#include <avformat.h>
++#else
++#include <libavformat/avformat.h>
++#endif
++
++#include <gst/gst.h>
++#include <gst/base/gstcollectpads.h>
++
++#include "gstffmpeg.h"
++#include "gstffmpegcodecmap.h"
++#include "gstffmpegutils.h"
++
++typedef struct _GstFFMpegMux GstFFMpegMux;
++typedef struct _GstFFMpegMuxPad GstFFMpegMuxPad;
++
++struct _GstFFMpegMuxPad
++{
++  GstCollectData collect;       /* we extend the CollectData */
++
++  gint padnum;
++};
++
++struct _GstFFMpegMux
++{
++  GstElement element;
++
++  GstCollectPads *collect;
++  /* We need to keep track of our pads, so we do so here. */
++  GstPad *srcpad;
++
++  AVFormatContext *context;
++  gboolean opened;
++
++  gint videopads, audiopads;
++
++  /*< private > */
++  /* event_function is the collectpads default eventfunction */
++  GstPadEventFunction event_function;
++  int preload;
++  int max_delay;
++};
++
++typedef struct _GstFFMpegMuxClass GstFFMpegMuxClass;
++
++struct _GstFFMpegMuxClass
++{
++  GstElementClass parent_class;
++
++  AVOutputFormat *in_plugin;
++};
++
++#define GST_TYPE_FFMPEGMUX \
++  (gst_ffmpegdec_get_type())
++#define GST_FFMPEGMUX(obj) \
++  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGMUX,GstFFMpegMux))
++#define GST_FFMPEGMUX_CLASS(klass) \
++  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGMUX,GstFFMpegMuxClass))
++#define GST_IS_FFMPEGMUX(obj) \
++  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGMUX))
++#define GST_IS_FFMPEGMUX_CLASS(klass) \
++  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGMUX))
++
++enum
++{
++  /* FILL ME */
++  LAST_SIGNAL
++};
++
++enum
++{
++  ARG_0,
++  /* FILL ME */
++};
++
++enum
++{
++  PROP_0,
++  PROP_PRELOAD,
++  PROP_MAXDELAY
++};
++
++/* A number of function prototypes are given so we can refer to them later. */
++static void gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass);
++static void gst_ffmpegmux_base_init (gpointer g_class);
++static void gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux,
++    GstFFMpegMuxClass * g_class);
++static void gst_ffmpegmux_finalize (GObject * object);
++
++static gboolean gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps);
++static GstPad *gst_ffmpegmux_request_new_pad (GstElement * element,
++    GstPadTemplate * templ, const gchar * name);
++static GstFlowReturn gst_ffmpegmux_collected (GstCollectPads * pads,
++    gpointer user_data);
++
++static gboolean gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event);
++
++static GstStateChangeReturn gst_ffmpegmux_change_state (GstElement * element,
++    GstStateChange transition);
++
++static void gst_ffmpegmux_set_property (GObject * object, guint prop_id,
++    const GValue * value, GParamSpec * pspec);
++static void gst_ffmpegmux_get_property (GObject * object, guint prop_id,
++    GValue * value, GParamSpec * pspec);
++
++static GstCaps *gst_ffmpegmux_get_id_caps (enum CodecID *id_list);
++static void gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * caps,
++    const gchar * field, guint num, const gint * values);
++
++#define GST_FFMUX_PARAMS_QDATA g_quark_from_static_string("ffmux-params")
++
++static GstElementClass *parent_class = NULL;
++
++/*static guint gst_ffmpegmux_signals[LAST_SIGNAL] = { 0 }; */
++
++typedef struct
++{
++  const char *name;
++  const char *replacement;
++} GstFFMpegMuxReplacement;
++
++static const char *
++gst_ffmpegmux_get_replacement (const char *name)
++{
++  static const GstFFMpegMuxReplacement blacklist[] = {
++    {"avi", "avimux"},
++    {"matroska", "matroskamux"},
++    {"mov", "qtmux"},
++    {"mpegts", "mpegtsmux"},
++    {"mp4", "mp4mux"},
++    {"mpjpeg", "multipartmux"},
++    {"ogg", "oggmux"},
++    {"wav", "wavenc"},
++    {"webm", "webmmux"},
++    {"mxf", "mxfmux"},
++    {"3gp", "gppmux"},
++    {"yuv4mpegpipe", "y4menc"},
++    {"aiff", "aiffmux"},
++    {"adts", "aacparse"},
++    {"asf", "asfmux"},
++    {"asf_stream", "asfmux"},
++    {"flv", "flvmux"},
++    {"mp3", "id3v2mux"},
++    {"mp2", "id3v2mux"}
++  };
++  int i;
++
++  for (i = 0; i < sizeof (blacklist) / sizeof (blacklist[0]); i++) {
++    if (strcmp (blacklist[i].name, name) == 0) {
++      return blacklist[i].replacement;
++    }
++  }
++
++  return NULL;
++}
++
++static gboolean
++gst_ffmpegmux_is_formatter (const char *name)
++{
++  static const char *replace[] = {
++    "mp2", "mp3", NULL
++  };
++  int i;
++
++  for (i = 0; replace[i]; i++)
++    if (strcmp (replace[i], name) == 0)
++      return TRUE;
++  return FALSE;
++}
++
++static void
++gst_ffmpegmux_base_init (gpointer g_class)
++{
++  GstFFMpegMuxClass *klass = (GstFFMpegMuxClass *) g_class;
++  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
++  GstPadTemplate *videosinktempl, *audiosinktempl, *srctempl;
++  AVOutputFormat *in_plugin;
++  GstCaps *srccaps, *audiosinkcaps, *videosinkcaps;
++  enum CodecID *video_ids = NULL, *audio_ids = NULL;
++  gchar *longname, *description;
++  const char *replacement;
++  gboolean is_formatter;
++
++  in_plugin =
++      (AVOutputFormat *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
++      GST_FFMUX_PARAMS_QDATA);
++  g_assert (in_plugin != NULL);
++
++  /* construct the element details struct */
++  replacement = gst_ffmpegmux_get_replacement (in_plugin->name);
++  is_formatter = gst_ffmpegmux_is_formatter (in_plugin->name);
++  if (replacement != NULL) {
++    longname =
++        g_strdup_printf ("FFmpeg %s %s (not recommended, use %s instead)",
++        in_plugin->long_name, is_formatter ? "formatter" : "muxer",
++        replacement);
++    description =
++        g_strdup_printf ("FFmpeg %s %s (not recommended, use %s instead)",
++        in_plugin->long_name, is_formatter ? "formatter" : "muxer",
++        replacement);
++  } else {
++    longname = g_strdup_printf ("FFmpeg %s %s", in_plugin->long_name,
++        is_formatter ? "formatter" : "muxer");
++    description = g_strdup_printf ("FFmpeg %s %s", in_plugin->long_name,
++        is_formatter ? "formatter" : "muxer");
++  }
++  gst_element_class_set_details_simple (element_class, longname,
++      is_formatter ? "Formatter/Metadata" : "Codec/Muxer", description,
++      "Wim Taymans <wim.taymans@chello.be>, "
++      "Ronald Bultje <rbultje@ronald.bitfreak.net>");
++  g_free (longname);
++  g_free (description);
++
++  /* Try to find the caps that belongs here */
++  srccaps = gst_ffmpeg_formatid_to_caps (in_plugin->name);
++  if (!srccaps) {
++    GST_DEBUG ("Couldn't get source caps for muxer '%s', skipping format",
++        in_plugin->name);
++    goto beach;
++  }
++
++  if (!gst_ffmpeg_formatid_get_codecids (in_plugin->name,
++          &video_ids, &audio_ids, in_plugin)) {
++    gst_caps_unref (srccaps);
++    GST_DEBUG
++        ("Couldn't get sink caps for muxer '%s'. Most likely because no input format mapping exists.",
++        in_plugin->name);
++    goto beach;
++  }
++
++  videosinkcaps = video_ids ? gst_ffmpegmux_get_id_caps (video_ids) : NULL;
++  audiosinkcaps = audio_ids ? gst_ffmpegmux_get_id_caps (audio_ids) : NULL;
++
++  /* fix up allowed caps for some muxers */
++  /* FIXME : This should be in gstffmpegcodecmap.c ! */
++  if (strcmp (in_plugin->name, "flv") == 0) {
++    const gint rates[] = { 44100, 22050, 11025 };
++
++    gst_ffmpeg_mux_simple_caps_set_int_list (audiosinkcaps, "rate", 3, rates);
++  } else if (strcmp (in_plugin->name, "gif") == 0) {
++    if (videosinkcaps)
++      gst_caps_unref (videosinkcaps);
++
++    videosinkcaps =
++        gst_caps_from_string ("video/x-raw-rgb, bpp=(int)24, depth=(int)24");
++  }
++
++  /* pad templates */
++  srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
++  gst_element_class_add_pad_template (element_class, srctempl);
++
++  if (audiosinkcaps) {
++    audiosinktempl = gst_pad_template_new ("audio_%d",
++        GST_PAD_SINK, GST_PAD_REQUEST, audiosinkcaps);
++    gst_element_class_add_pad_template (element_class, audiosinktempl);
++  }
++
++  if (videosinkcaps) {
++    videosinktempl = gst_pad_template_new ("video_%d",
++        GST_PAD_SINK, GST_PAD_REQUEST, videosinkcaps);
++    gst_element_class_add_pad_template (element_class, videosinktempl);
++  }
++
++beach:
++  klass->in_plugin = in_plugin;
++}
++
++static void
++gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass)
++{
++  GObjectClass *gobject_class;
++  GstElementClass *gstelement_class;
++
++  gobject_class = (GObjectClass *) klass;
++  gstelement_class = (GstElementClass *) klass;
++
++  parent_class = g_type_class_peek_parent (klass);
++
++  gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_ffmpegmux_set_property);
++  gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_ffmpegmux_get_property);
++
++  g_object_class_install_property (gobject_class, PROP_PRELOAD,
++      g_param_spec_int ("preload", "preload",
++          "Set the initial demux-decode delay (in microseconds)", 0, G_MAXINT,
++          0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++
++  g_object_class_install_property (gobject_class, PROP_MAXDELAY,
++      g_param_spec_int ("maxdelay", "maxdelay",
++          "Set the maximum demux-decode delay (in microseconds)", 0, G_MAXINT,
++          0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++
++  gstelement_class->request_new_pad = gst_ffmpegmux_request_new_pad;
++  gstelement_class->change_state = gst_ffmpegmux_change_state;
++  gobject_class->finalize = gst_ffmpegmux_finalize;
++}
++
++static void
++gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux, GstFFMpegMuxClass * g_class)
++{
++  GstElementClass *klass = GST_ELEMENT_CLASS (g_class);
++  GstFFMpegMuxClass *oclass = (GstFFMpegMuxClass *) klass;
++  GstPadTemplate *templ = gst_element_class_get_pad_template (klass, "src");
++
++  ffmpegmux->srcpad = gst_pad_new_from_template (templ, "src");
++  gst_pad_set_caps (ffmpegmux->srcpad, gst_pad_template_get_caps (templ));
++  gst_element_add_pad (GST_ELEMENT (ffmpegmux), ffmpegmux->srcpad);
++
++  ffmpegmux->collect = gst_collect_pads_new ();
++  gst_collect_pads_set_function (ffmpegmux->collect,
++      (GstCollectPadsFunction) gst_ffmpegmux_collected, ffmpegmux);
++
++  ffmpegmux->context = g_new0 (AVFormatContext, 1);
++  ffmpegmux->context->oformat = oclass->in_plugin;
++  ffmpegmux->context->nb_streams = 0;
++  g_snprintf (ffmpegmux->context->filename,
++      sizeof (ffmpegmux->context->filename),
++      "gstreamer://%p", ffmpegmux->srcpad);
++  ffmpegmux->opened = FALSE;
++
++  ffmpegmux->videopads = 0;
++  ffmpegmux->audiopads = 0;
++  ffmpegmux->preload = 0;
++  ffmpegmux->max_delay = 0;
++}
++
++static void
++gst_ffmpegmux_set_property (GObject * object, guint prop_id,
++    const GValue * value, GParamSpec * pspec)
++{
++  GstFFMpegMux *src;
++
++  src = (GstFFMpegMux *) object;
++
++  switch (prop_id) {
++    case PROP_PRELOAD:
++      src->preload = g_value_get_int (value);
++      break;
++    case PROP_MAXDELAY:
++      src->max_delay = g_value_get_int (value);
++      break;
++    default:
++      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
++      break;
++  }
++}
++
++static void
++gst_ffmpegmux_get_property (GObject * object, guint prop_id, GValue * value,
++    GParamSpec * pspec)
++{
++  GstFFMpegMux *src;
++
++  src = (GstFFMpegMux *) object;
++
++  switch (prop_id) {
++    case PROP_PRELOAD:
++      g_value_set_int (value, src->preload);
++      break;
++    case PROP_MAXDELAY:
++      g_value_set_int (value, src->max_delay);
++      break;
++    default:
++      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
++      break;
++  }
++}
++
++
++static void
++gst_ffmpegmux_finalize (GObject * object)
++{
++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) object;
++
++  g_free (ffmpegmux->context);
++  gst_object_unref (ffmpegmux->collect);
++
++  if (G_OBJECT_CLASS (parent_class)->finalize)
++    G_OBJECT_CLASS (parent_class)->finalize (object);
++}
++
++static GstPad *
++gst_ffmpegmux_request_new_pad (GstElement * element,
++    GstPadTemplate * templ, const gchar * name)
++{
++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) element;
++  GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
++  GstFFMpegMuxPad *collect_pad;
++  gchar *padname;
++  GstPad *pad;
++  AVStream *st;
++  enum AVMediaType type;
++  gint bitrate = 0, framesize = 0;
++
++  g_return_val_if_fail (templ != NULL, NULL);
++  g_return_val_if_fail (templ->direction == GST_PAD_SINK, NULL);
++  g_return_val_if_fail (ffmpegmux->opened == FALSE, NULL);
++
++  /* figure out a name that *we* like */
++  if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
++    padname = g_strdup_printf ("video_%d", ffmpegmux->videopads++);
++    type = AVMEDIA_TYPE_VIDEO;
++    bitrate = 64 * 1024;
++    framesize = 1152;
++  } else if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
++    padname = g_strdup_printf ("audio_%d", ffmpegmux->audiopads++);
++    type = AVMEDIA_TYPE_AUDIO;
++    bitrate = 285 * 1024;
++  } else {
++    g_warning ("ffmux: unknown pad template!");
++    return NULL;
++  }
++
++  /* create pad */
++  pad = gst_pad_new_from_template (templ, padname);
++  collect_pad = (GstFFMpegMuxPad *)
++      gst_collect_pads_add_pad (ffmpegmux->collect, pad,
++      sizeof (GstFFMpegMuxPad));
++  collect_pad->padnum = ffmpegmux->context->nb_streams;
++
++  /* small hack to put our own event pad function and chain up to collect pad */
++  ffmpegmux->event_function = GST_PAD_EVENTFUNC (pad);
++  gst_pad_set_event_function (pad,
++      GST_DEBUG_FUNCPTR (gst_ffmpegmux_sink_event));
++
++  gst_pad_set_setcaps_function (pad, GST_DEBUG_FUNCPTR (gst_ffmpegmux_setcaps));
++  gst_element_add_pad (element, pad);
++
++  /* AVStream needs to be created */
++  st = av_new_stream (ffmpegmux->context, collect_pad->padnum);
++  st->codec->codec_type = type;
++  st->codec->codec_id = CODEC_ID_NONE;  /* this is a check afterwards */
++  st->stream_copy = 1;          /* we're not the actual encoder */
++  st->codec->bit_rate = bitrate;
++  st->codec->frame_size = framesize;
++  /* we fill in codec during capsnego */
++
++  /* we love debug output (c) (tm) (r) */
++  GST_DEBUG ("Created %s pad for ffmux_%s element",
++      padname, ((GstFFMpegMuxClass *) klass)->in_plugin->name);
++  g_free (padname);
++
++  return pad;
++}
++
++/**
++ * gst_ffmpegmux_setcaps
++ * @pad: #GstPad
++ * @caps: New caps.
++ *
++ * Set caps to pad.
++ *
++ * Returns: #TRUE on success.
++ */
++static gboolean
++gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps)
++{
++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (gst_pad_get_parent (pad));
++  GstFFMpegMuxPad *collect_pad;
++  AVStream *st;
++
++  collect_pad = (GstFFMpegMuxPad *) gst_pad_get_element_private (pad);
++
++  st = ffmpegmux->context->streams[collect_pad->padnum];
++  ffmpegmux->context->preload = ffmpegmux->preload;
++  ffmpegmux->context->max_delay = ffmpegmux->max_delay;
++
++  /* for the format-specific guesses, we'll go to
++   * our famous codec mapper */
++  if (gst_ffmpeg_caps_to_codecid (caps, st->codec) == CODEC_ID_NONE)
++    goto not_accepted;
++
++  /* copy over the aspect ratios, ffmpeg expects the stream aspect to match the
++   * codec aspect. */
++  st->sample_aspect_ratio = st->codec->sample_aspect_ratio;
++
++  GST_LOG_OBJECT (pad, "accepted caps %" GST_PTR_FORMAT, caps);
++  return TRUE;
++
++  /* ERRORS */
++not_accepted:
++  {
++    GST_LOG_OBJECT (pad, "rejecting caps %" GST_PTR_FORMAT, caps);
++    return FALSE;
++  }
++}
++
++
++static gboolean
++gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event)
++{
++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) gst_pad_get_parent (pad);
++  gboolean res = TRUE;
++
++  switch (GST_EVENT_TYPE (event)) {
++    case GST_EVENT_TAG:{
++      GstTagList *taglist;
++      GstTagSetter *setter = GST_TAG_SETTER (ffmpegmux);
++      const GstTagMergeMode mode = gst_tag_setter_get_tag_merge_mode (setter);
++
++      gst_event_parse_tag (event, &taglist);
++      gst_tag_setter_merge_tags (setter, taglist, mode);
++      break;
++    }
++    default:
++      break;
++  }
++
++  /* chaining up to collectpads default event function */
++  res = ffmpegmux->event_function (pad, event);
++
++  gst_object_unref (ffmpegmux);
++  return res;
++}
++
++static GstFlowReturn
++gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
++{
++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) user_data;
++  GSList *collected;
++  GstFFMpegMuxPad *best_pad;
++  GstClockTime best_time;
++#if 0
++  /* Re-enable once converted to new AVMetaData API
++   * See #566605
++   */
++  const GstTagList *tags;
++#endif
++
++  /* open "file" (gstreamer protocol to next element) */
++  if (!ffmpegmux->opened) {
++    int open_flags = URL_WRONLY;
++
++    /* we do need all streams to have started capsnego,
++     * or things will go horribly wrong */
++    for (collected = ffmpegmux->collect->data; collected;
++        collected = g_slist_next (collected)) {
++      GstFFMpegMuxPad *collect_pad = (GstFFMpegMuxPad *) collected->data;
++      AVStream *st = ffmpegmux->context->streams[collect_pad->padnum];
++
++      /* check whether the pad has successfully completed capsnego */
++      if (st->codec->codec_id == CODEC_ID_NONE) {
++        GST_ELEMENT_ERROR (ffmpegmux, CORE, NEGOTIATION, (NULL),
++            ("no caps set on stream %d (%s)", collect_pad->padnum,
++                (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ?
++                "video" : "audio"));
++        return GST_FLOW_ERROR;
++      }
++      /* set framerate for audio */
++      if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
++        switch (st->codec->codec_id) {
++          case CODEC_ID_PCM_S16LE:
++          case CODEC_ID_PCM_S16BE:
++          case CODEC_ID_PCM_U16LE:
++          case CODEC_ID_PCM_U16BE:
++          case CODEC_ID_PCM_S8:
++          case CODEC_ID_PCM_U8:
++            st->codec->frame_size = 1;
++            break;
++          default:
++          {
++            GstBuffer *buffer;
++
++            /* FIXME : This doesn't work for RAW AUDIO...
++             * in fact I'm wondering if it even works for any kind of audio... */
++            buffer = gst_collect_pads_peek (ffmpegmux->collect,
++                (GstCollectData *) collect_pad);
++            if (buffer) {
++              st->codec->frame_size =
++                  st->codec->sample_rate *
++                  GST_BUFFER_DURATION (buffer) / GST_SECOND;
++              gst_buffer_unref (buffer);
++            }
++          }
++        }
++      }
++    }
++
++#if 0
++    /* Re-enable once converted to new AVMetaData API
++     * See #566605
++     */
++
++    /* tags */
++    tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (ffmpegmux));
++    if (tags) {
++      gint i;
++      gchar *s;
++
++      /* get the interesting ones */
++      if (gst_tag_list_get_string (tags, GST_TAG_TITLE, &s)) {
++        strncpy (ffmpegmux->context->title, s,
++            sizeof (ffmpegmux->context->title));
++      }
++      if (gst_tag_list_get_string (tags, GST_TAG_ARTIST, &s)) {
++        strncpy (ffmpegmux->context->author, s,
++            sizeof (ffmpegmux->context->author));
++      }
++      if (gst_tag_list_get_string (tags, GST_TAG_COPYRIGHT, &s)) {
++        strncpy (ffmpegmux->context->copyright, s,
++            sizeof (ffmpegmux->context->copyright));
++      }
++      if (gst_tag_list_get_string (tags, GST_TAG_COMMENT, &s)) {
++        strncpy (ffmpegmux->context->comment, s,
++            sizeof (ffmpegmux->context->comment));
++      }
++      if (gst_tag_list_get_string (tags, GST_TAG_ALBUM, &s)) {
++        strncpy (ffmpegmux->context->album, s,
++            sizeof (ffmpegmux->context->album));
++      }
++      if (gst_tag_list_get_string (tags, GST_TAG_GENRE, &s)) {
++        strncpy (ffmpegmux->context->genre, s,
++            sizeof (ffmpegmux->context->genre));
++      }
++      if (gst_tag_list_get_int (tags, GST_TAG_TRACK_NUMBER, &i)) {
++        ffmpegmux->context->track = i;
++      }
++    }
++#endif
++
++    /* set the streamheader flag for gstffmpegprotocol if codec supports it */
++    if (!strcmp (ffmpegmux->context->oformat->name, "flv")) {
++      open_flags |= GST_FFMPEG_URL_STREAMHEADER;
++    }
++
++    if (url_fopen (&ffmpegmux->context->pb,
++            ffmpegmux->context->filename, open_flags) < 0) {
++      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, TOO_LAZY, (NULL),
++          ("Failed to open stream context in ffmux"));
++      return GST_FLOW_ERROR;
++    }
++
++    if (av_set_parameters (ffmpegmux->context, NULL) < 0) {
++      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, INIT, (NULL),
++          ("Failed to initialize muxer"));
++      return GST_FLOW_ERROR;
++    }
++
++    /* now open the mux format */
++    if (av_write_header (ffmpegmux->context) < 0) {
++      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, SETTINGS, (NULL),
++          ("Failed to write file header - check codec settings"));
++      return GST_FLOW_ERROR;
++    }
++
++    /* we're now opened */
++    ffmpegmux->opened = TRUE;
++
++    /* flush the header so it will be used as streamheader */
++    put_flush_packet (ffmpegmux->context->pb);
++  }
++
++  /* take the one with earliest timestamp,
++   * and push it forward */
++  best_pad = NULL;
++  best_time = GST_CLOCK_TIME_NONE;
++  for (collected = ffmpegmux->collect->data; collected;
++      collected = g_slist_next (collected)) {
++    GstFFMpegMuxPad *collect_pad = (GstFFMpegMuxPad *) collected->data;
++    GstBuffer *buffer = gst_collect_pads_peek (ffmpegmux->collect,
++        (GstCollectData *) collect_pad);
++
++    /* if there's no buffer, just continue */
++    if (buffer == NULL) {
++      continue;
++    }
++
++    /* if we have no buffer yet, just use the first one */
++    if (best_pad == NULL) {
++      best_pad = collect_pad;
++      best_time = GST_BUFFER_TIMESTAMP (buffer);
++      goto next_pad;
++    }
++
++    /* if we do have one, only use this one if it's older */
++    if (GST_BUFFER_TIMESTAMP (buffer) < best_time) {
++      best_time = GST_BUFFER_TIMESTAMP (buffer);
++      best_pad = collect_pad;
++    }
++
++  next_pad:
++    gst_buffer_unref (buffer);
++
++    /* Mux buffers with invalid timestamp first */
++    if (!GST_CLOCK_TIME_IS_VALID (best_time))
++      break;
++  }
++
++  /* now handle the buffer, or signal EOS if we have
++   * no buffers left */
++  if (best_pad != NULL) {
++    GstBuffer *buf;
++    AVPacket pkt;
++    gboolean need_free = FALSE;
++
++    /* push out current buffer */
++    buf = gst_collect_pads_pop (ffmpegmux->collect,
++        (GstCollectData *) best_pad);
++
++    ffmpegmux->context->streams[best_pad->padnum]->codec->frame_number++;
++
++    /* set time */
++    pkt.pts = gst_ffmpeg_time_gst_to_ff (GST_BUFFER_TIMESTAMP (buf),
++        ffmpegmux->context->streams[best_pad->padnum]->time_base);
++    pkt.dts = pkt.pts;
++
++    if (strcmp (ffmpegmux->context->oformat->name, "gif") == 0) {
++      AVStream *st = ffmpegmux->context->streams[best_pad->padnum];
++      AVPicture src, dst;
++
++      need_free = TRUE;
++      pkt.size = st->codec->width * st->codec->height * 3;
++      pkt.data = g_malloc (pkt.size);
++
++      dst.data[0] = pkt.data;
++      dst.data[1] = NULL;
++      dst.data[2] = NULL;
++      dst.linesize[0] = st->codec->width * 3;
++
++      gst_ffmpeg_avpicture_fill (&src, GST_BUFFER_DATA (buf),
++          PIX_FMT_RGB24, st->codec->width, st->codec->height);
++
++      av_picture_copy (&dst, &src, PIX_FMT_RGB24,
++          st->codec->width, st->codec->height);
++    } else {
++      pkt.data = GST_BUFFER_DATA (buf);
++      pkt.size = GST_BUFFER_SIZE (buf);
++    }
++
++    pkt.stream_index = best_pad->padnum;
++    pkt.flags = 0;
++
++    if (!GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT))
++      pkt.flags |= AV_PKT_FLAG_KEY;
++
++    if (GST_BUFFER_DURATION_IS_VALID (buf))
++      pkt.duration =
++          gst_ffmpeg_time_gst_to_ff (GST_BUFFER_DURATION (buf),
++          ffmpegmux->context->streams[best_pad->padnum]->time_base);
++    else
++      pkt.duration = 0;
++    av_write_frame (ffmpegmux->context, &pkt);
++    gst_buffer_unref (buf);
++    if (need_free)
++      g_free (pkt.data);
++  } else {
++    /* close down */
++    av_write_trailer (ffmpegmux->context);
++    ffmpegmux->opened = FALSE;
++    put_flush_packet (ffmpegmux->context->pb);
++    url_fclose (ffmpegmux->context->pb);
++    gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_eos ());
++    return GST_FLOW_UNEXPECTED;
++  }
++
++  return GST_FLOW_OK;
++}
++
++static GstStateChangeReturn
++gst_ffmpegmux_change_state (GstElement * element, GstStateChange transition)
++{
++  GstFlowReturn ret;
++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (element);
++
++  switch (transition) {
++    case GST_STATE_CHANGE_NULL_TO_READY:
++      break;
++    case GST_STATE_CHANGE_READY_TO_PAUSED:
++      gst_collect_pads_start (ffmpegmux->collect);
++      break;
++    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
++      break;
++    case GST_STATE_CHANGE_PAUSED_TO_READY:
++      gst_collect_pads_stop (ffmpegmux->collect);
++      break;
++    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_tag_setter_reset_tags (GST_TAG_SETTER (ffmpegmux));
++      if (ffmpegmux->opened) {
++        ffmpegmux->opened = FALSE;
++        url_fclose (ffmpegmux->context->pb);
++      }
++      break;
++    case GST_STATE_CHANGE_READY_TO_NULL:
++      break;
++    default:
++      break;
++  }
++
++  return ret;
++}
++
++static GstCaps *
++gst_ffmpegmux_get_id_caps (enum CodecID *id_list)
++{
++  GstCaps *caps, *t;
++  gint i;
++
++  caps = gst_caps_new_empty ();
++  for (i = 0; id_list[i] != CODEC_ID_NONE; i++) {
++    if ((t = gst_ffmpeg_codecid_to_caps (id_list[i], NULL, TRUE)))
++      gst_caps_append (caps, t);
++  }
++  if (gst_caps_is_empty (caps)) {
++    gst_caps_unref (caps);
++    return NULL;
++  }
++
++  return caps;
++}
++
++/* set a list of integer values on the caps, e.g. for sample rates */
++static void
++gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * caps, const gchar * field,
++    guint num, const gint * values)
++{
++  GValue list = { 0, };
++  GValue val = { 0, };
++  gint i;
++
++  g_return_if_fail (GST_CAPS_IS_SIMPLE (caps));
++
++  g_value_init (&list, GST_TYPE_LIST);
++  g_value_init (&val, G_TYPE_INT);
++
++  for (i = 0; i < num; ++i) {
++    g_value_set_int (&val, values[i]);
++    gst_value_list_append_value (&list, &val);
++  }
++
++  gst_structure_set_value (gst_caps_get_structure (caps, 0), field, &list);
++
++  g_value_unset (&val);
++  g_value_unset (&list);
++}
++
++gboolean
++gst_ffmpegmux_register (GstPlugin * plugin)
++{
++  GTypeInfo typeinfo = {
++    sizeof (GstFFMpegMuxClass),
++    (GBaseInitFunc) gst_ffmpegmux_base_init,
++    NULL,
++    (GClassInitFunc) gst_ffmpegmux_class_init,
++    NULL,
++    NULL,
++    sizeof (GstFFMpegMux),
++    0,
++    (GInstanceInitFunc) gst_ffmpegmux_init,
++  };
++  static const GInterfaceInfo tag_setter_info = {
++    NULL, NULL, NULL
++  };
++  GType type;
++  AVOutputFormat *in_plugin;
++
++  in_plugin = av_oformat_next (NULL);
++
++  GST_LOG ("Registering muxers");
++
++  while (in_plugin) {
++    gchar *type_name;
++    gchar *p;
++    GstRank rank = GST_RANK_MARGINAL;
++
++    if ((!strncmp (in_plugin->name, "u16", 3)) ||
++        (!strncmp (in_plugin->name, "s16", 3)) ||
++        (!strncmp (in_plugin->name, "u24", 3)) ||
++        (!strncmp (in_plugin->name, "s24", 3)) ||
++        (!strncmp (in_plugin->name, "u8", 2)) ||
++        (!strncmp (in_plugin->name, "s8", 2)) ||
++        (!strncmp (in_plugin->name, "u32", 3)) ||
++        (!strncmp (in_plugin->name, "s32", 3)) ||
++        (!strncmp (in_plugin->name, "f32", 3)) ||
++        (!strncmp (in_plugin->name, "f64", 3)) ||
++        (!strncmp (in_plugin->name, "raw", 3)) ||
++        (!strncmp (in_plugin->name, "crc", 3)) ||
++        (!strncmp (in_plugin->name, "null", 4)) ||
++        (!strncmp (in_plugin->name, "gif", 3)) ||
++        (!strncmp (in_plugin->name, "frame", 5)) ||
++        (!strncmp (in_plugin->name, "image", 5)) ||
++        (!strncmp (in_plugin->name, "mulaw", 5)) ||
++        (!strncmp (in_plugin->name, "alaw", 4)) ||
++        (!strncmp (in_plugin->name, "h26", 3)) ||
++        (!strncmp (in_plugin->name, "rtp", 3)) ||
++        (!strncmp (in_plugin->name, "ass", 3)) ||
++        (!strncmp (in_plugin->name, "ffmetadata", 10)) ||
++        (!strncmp (in_plugin->name, "srt", 3))
++        ) {
++      GST_LOG ("Ignoring muxer %s", in_plugin->name);
++      goto next;
++    }
++
++    if ((!strncmp (in_plugin->long_name, "raw ", 4))) {
++      GST_LOG ("Ignoring raw muxer %s", in_plugin->name);
++      goto next;
++    }
++
++    if (gst_ffmpegmux_get_replacement (in_plugin->name))
++      rank = GST_RANK_NONE;
++
++    /* FIXME : We need a fast way to know whether we have mappings for this
++     * muxer type. */
++
++    /* construct the type */
++    type_name = g_strdup_printf ("ffmux_%s", in_plugin->name);
++
++    p = type_name;
++
++    while (*p) {
++      if (*p == '.')
++        *p = '_';
++      p++;
++    }
++
++    type = g_type_from_name (type_name);
++
++    if (!type) {
++      /* create the type now */
++      type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
++      g_type_set_qdata (type, GST_FFMUX_PARAMS_QDATA, (gpointer) in_plugin);
++      g_type_add_interface_static (type, GST_TYPE_TAG_SETTER, &tag_setter_info);
++    }
++
++    if (!gst_element_register (plugin, type_name, rank, type)) {
++      g_free (type_name);
++      return FALSE;
++    }
++
++    g_free (type_name);
++
++  next:
++    in_plugin = av_oformat_next (in_plugin);
++  }
++
++  GST_LOG ("Finished registering muxers");
++
++  return TRUE;
++}
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegprotocol.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegprotocol.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegprotocol.c	2011-07-12 16:35:28.000000000 +0200
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegprotocol.c	2014-08-08 15:26:07.875857555 +0200
+@@ -46,63 +46,14 @@
+ };
+ 
+ static int
+-gst_ffmpegdata_open (URLContext * h, const char *filename, int flags)
+-{
+-  GstProtocolInfo *info;
+-  GstPad *pad;
+-
+-  GST_LOG ("Opening %s", filename);
+-
+-  info = g_new0 (GstProtocolInfo, 1);
+-
+-  info->set_streamheader = flags & GST_FFMPEG_URL_STREAMHEADER;
+-  flags &= ~GST_FFMPEG_URL_STREAMHEADER;
+-  h->flags &= ~GST_FFMPEG_URL_STREAMHEADER;
+-
+-  /* we don't support R/W together */
+-  if (flags != URL_RDONLY && flags != URL_WRONLY) {
+-    GST_WARNING ("Only read-only or write-only are supported");
+-    return -EINVAL;
+-  }
+-
+-  if (sscanf (&filename[12], "%p", &pad) != 1) {
+-    GST_WARNING ("could not decode pad from %s", filename);
+-    return -EIO;
+-  }
+-
+-  /* make sure we're a pad and that we're of the right type */
+-  g_return_val_if_fail (GST_IS_PAD (pad), -EINVAL);
+-
+-  switch (flags) {
+-    case URL_RDONLY:
+-      g_return_val_if_fail (GST_PAD_IS_SINK (pad), -EINVAL);
+-      break;
+-    case URL_WRONLY:
+-      g_return_val_if_fail (GST_PAD_IS_SRC (pad), -EINVAL);
+-      break;
+-  }
+-
+-  info->eos = FALSE;
+-  info->pad = pad;
+-  info->offset = 0;
+-
+-  h->priv_data = (void *) info;
+-  h->is_streamed = FALSE;
+-  h->max_packet_size = 0;
+-
+-  return 0;
+-}
+-
+-static int
+-gst_ffmpegdata_peek (URLContext * h, unsigned char *buf, int size)
++gst_ffmpegdata_peek (void *priv_data, unsigned char *buf, int size)
+ {
+   GstProtocolInfo *info;
+   GstBuffer *inbuf = NULL;
+   GstFlowReturn ret;
+   int total = 0;
+ 
+-  g_return_val_if_fail (h->flags == URL_RDONLY, AVERROR (EIO));
+-  info = (GstProtocolInfo *) h->priv_data;
++  info = (GstProtocolInfo *) priv_data;
+ 
+   GST_DEBUG ("Pulling %d bytes at position %" G_GUINT64_FORMAT, size,
+       info->offset);
+@@ -134,17 +85,17 @@
+ }
+ 
+ static int
+-gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size)
++gst_ffmpegdata_read (void *priv_data, unsigned char *buf, int size)
+ {
+   gint res;
+   GstProtocolInfo *info;
+ 
+-  info = (GstProtocolInfo *) h->priv_data;
++  info = (GstProtocolInfo *) priv_data;
+ 
+   GST_DEBUG ("Reading %d bytes of data at position %" G_GUINT64_FORMAT, size,
+       info->offset);
+ 
+-  res = gst_ffmpegdata_peek (h, buf, size);
++  res = gst_ffmpegdata_peek (priv_data, buf, size);
+   if (res >= 0)
+     info->offset += res;
+ 
+@@ -154,15 +105,13 @@
+ }
+ 
+ static int
+-gst_ffmpegdata_write (URLContext * h, const unsigned char *buf, int size)
++gst_ffmpegdata_write (void *priv_data, const unsigned char *buf, int size)
+ {
+   GstProtocolInfo *info;
+   GstBuffer *outbuf;
+ 
+   GST_DEBUG ("Writing %d bytes", size);
+-  info = (GstProtocolInfo *) h->priv_data;
+-
+-  g_return_val_if_fail (h->flags != URL_RDONLY, -EIO);
++  info = (GstProtocolInfo *) priv_data;
+ 
+   /* create buffer and push data further */
+   if (gst_pad_alloc_buffer_and_set_caps (info->pad,
+@@ -179,7 +128,7 @@
+ }
+ 
+ static int64_t
+-gst_ffmpegdata_seek (URLContext * h, int64_t pos, int whence)
++gst_ffmpegdata_seek (void *priv_data, int64_t pos, int whence)
+ {
+   GstProtocolInfo *info;
+   guint64 newpos = 0;
+@@ -187,70 +136,62 @@
+   GST_DEBUG ("Seeking to %" G_GINT64_FORMAT ", whence=%d",
+       (gint64) pos, whence);
+ 
+-  info = (GstProtocolInfo *) h->priv_data;
++  info = (GstProtocolInfo *) priv_data;
+ 
+   /* TODO : if we are push-based, we need to return sensible info */
+ 
+-  switch (h->flags) {
+-    case URL_RDONLY:
+-    {
+-      /* sinkpad */
+-      switch (whence) {
+-        case SEEK_SET:
+-          newpos = (guint64) pos;
+-          break;
+-        case SEEK_CUR:
+-          newpos = info->offset + pos;
+-          break;
+-        case SEEK_END:
+-        case AVSEEK_SIZE:
+-          /* ffmpeg wants to know the current end position in bytes ! */
+-        {
+-          GstFormat format = GST_FORMAT_BYTES;
+-          gint64 duration;
+-
+-          GST_DEBUG ("Seek end");
+-
+-          if (gst_pad_is_linked (info->pad))
+-            if (gst_pad_query_duration (GST_PAD_PEER (info->pad), &format,
+-                    &duration))
+-              newpos = ((guint64) duration) + pos;
+-        }
+-          break;
+-        default:
+-          g_assert (0);
+-          break;
++  if (GST_PAD_IS_SINK (info->pad)) {
++    /* sinkpad */
++    switch (whence) {
++      case SEEK_SET:
++        newpos = (guint64) pos;
++        break;
++      case SEEK_CUR:
++        newpos = info->offset + pos;
++        break;
++      case SEEK_END:
++      case AVSEEK_SIZE:
++        /* ffmpeg wants to know the current end position in bytes ! */
++      {
++        GstFormat format = GST_FORMAT_BYTES;
++        gint64 duration;
++
++        GST_DEBUG ("Seek end");
++
++        if (gst_pad_is_linked (info->pad))
++          if (gst_pad_query_duration (GST_PAD_PEER (info->pad), &format,
++                  &duration))
++            newpos = ((guint64) duration) + pos;
+       }
+-      /* FIXME : implement case for push-based behaviour */
+-      if (whence != AVSEEK_SIZE)
+-        info->offset = newpos;
++        break;
++      default:
++        g_assert (0);
++        break;
+     }
+-      break;
+-    case URL_WRONLY:
+-    {
+-      /* srcpad */
+-      switch (whence) {
+-        case SEEK_SET:
+-          info->offset = (guint64) pos;
+-          gst_pad_push_event (info->pad, gst_event_new_new_segment
+-              (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
+-                  GST_CLOCK_TIME_NONE, info->offset));
+-          break;
+-        case SEEK_CUR:
+-          info->offset += pos;
+-          gst_pad_push_event (info->pad, gst_event_new_new_segment
+-              (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
+-                  GST_CLOCK_TIME_NONE, info->offset));
+-          break;
+-        default:
+-          break;
+-      }
+-      newpos = info->offset;
++    /* FIXME : implement case for push-based behaviour */
++    if (whence != AVSEEK_SIZE)
++      info->offset = newpos;
++  } else if (GST_PAD_IS_SRC (info->pad)) {
++    /* srcpad */
++    switch (whence) {
++      case SEEK_SET:
++        info->offset = (guint64) pos;
++        gst_pad_push_event (info->pad, gst_event_new_new_segment
++            (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
++                GST_CLOCK_TIME_NONE, info->offset));
++        break;
++      case SEEK_CUR:
++        info->offset += pos;
++        gst_pad_push_event (info->pad, gst_event_new_new_segment
++            (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
++                GST_CLOCK_TIME_NONE, info->offset));
++        break;
++      default:
++        break;
+     }
+-      break;
+-    default:
+-      g_assert (0);
+-      break;
++    newpos = info->offset;
++  } else {
++    g_assert_not_reached ();
+   }
+ 
+   GST_DEBUG ("Now at offset %" G_GUINT64_FORMAT " (returning %" G_GUINT64_FORMAT
+@@ -258,85 +199,91 @@
+   return newpos;
+ }
+ 
+-static int
+-gst_ffmpegdata_close (URLContext * h)
++int
++gst_ffmpegdata_close (AVIOContext * h)
+ {
+   GstProtocolInfo *info;
+ 
+-  info = (GstProtocolInfo *) h->priv_data;
++  info = (GstProtocolInfo *) h->opaque;
+   if (info == NULL)
+     return 0;
+ 
+   GST_LOG ("Closing file");
+ 
+-  switch (h->flags) {
+-    case URL_WRONLY:
+-    {
+-      /* send EOS - that closes down the stream */
+-      gst_pad_push_event (info->pad, gst_event_new_eos ());
+-      break;
+-    }
+-    default:
+-      break;
++  if (GST_PAD_IS_SRC (info->pad)) {
++    /* send EOS - that closes down the stream */
++    gst_pad_push_event (info->pad, gst_event_new_eos ());
+   }
+ 
+   /* clean up data */
+   g_free (info);
+-  h->priv_data = NULL;
++  h->opaque = NULL;
++
++  av_freep (&h->buffer);
++  av_free (h);
+ 
+   return 0;
+ }
+ 
++int
++gst_ffmpegdata_open (GstPad * pad, int flags, AVIOContext ** context)
++{
++  GstProtocolInfo *info;
++  static const int buffer_size = 4096;
++  unsigned char *buffer = NULL;
+ 
+-URLProtocol gstreamer_protocol = {
+-  /*.name = */ "gstreamer",
+-  /*.url_open = */ gst_ffmpegdata_open,
+-  /*.url_read = */ gst_ffmpegdata_read,
+-  /*.url_write = */ gst_ffmpegdata_write,
+-  /*.url_seek = */ gst_ffmpegdata_seek,
+-  /*.url_close = */ gst_ffmpegdata_close,
+-};
++  info = g_new0 (GstProtocolInfo, 1);
+ 
++  info->set_streamheader = flags & GST_FFMPEG_URL_STREAMHEADER;
++  flags &= ~GST_FFMPEG_URL_STREAMHEADER;
+ 
+-/* specialized protocol for cross-thread pushing,
+- * based on ffmpeg's pipe protocol */
++  /* we don't support R/W together */
++  if ((flags & AVIO_FLAG_WRITE) && (flags & AVIO_FLAG_READ)) {
++    GST_WARNING ("Only read-only or write-only are supported");
++    return -EINVAL;
++  }
+ 
+-static int
+-gst_ffmpeg_pipe_open (URLContext * h, const char *filename, int flags)
+-{
+-  GstFFMpegPipe *ffpipe;
++  /* make sure we're a pad and that we're of the right type */
++  g_return_val_if_fail (GST_IS_PAD (pad), -EINVAL);
+ 
+-  GST_LOG ("Opening %s", filename);
++  if ((flags & AVIO_FLAG_READ))
++    g_return_val_if_fail (GST_PAD_IS_SINK (pad), -EINVAL);
++  if ((flags & AVIO_FLAG_WRITE))
++    g_return_val_if_fail (GST_PAD_IS_SRC (pad), -EINVAL);
+ 
+-  /* we don't support W together */
+-  if (flags != URL_RDONLY) {
+-    GST_WARNING ("Only read-only is supported");
+-    return -EINVAL;
+-  }
++  info->eos = FALSE;
++  info->pad = pad;
++  info->offset = 0;
+ 
+-  if (sscanf (&filename[10], "%p", &ffpipe) != 1) {
+-    GST_WARNING ("could not decode pipe info from %s", filename);
+-    return -EIO;
++  buffer = av_malloc (buffer_size);
++  if (buffer == NULL) {
++    GST_WARNING ("Failed to allocate buffer");
++    return -ENOMEM;
+   }
+ 
+-  /* sanity check */
+-  g_return_val_if_fail (GST_IS_ADAPTER (ffpipe->adapter), -EINVAL);
+-
+-  h->priv_data = (void *) ffpipe;
+-  h->is_streamed = TRUE;
+-  h->max_packet_size = 0;
++  *context =
++      avio_alloc_context (buffer, buffer_size, flags, (void *) info,
++      gst_ffmpegdata_read, gst_ffmpegdata_write, gst_ffmpegdata_seek);
++  (*context)->seekable = AVIO_SEEKABLE_NORMAL;
++  if (!(flags & AVIO_FLAG_WRITE)) {
++    (*context)->buf_ptr = (*context)->buf_end;
++    (*context)->write_flag = 0;
++  }
+ 
+   return 0;
+ }
+ 
++/* specialized protocol for cross-thread pushing,
++ * based on ffmpeg's pipe protocol */
++
+ static int
+-gst_ffmpeg_pipe_read (URLContext * h, unsigned char *buf, int size)
++gst_ffmpeg_pipe_read (void *priv_data, unsigned char *buf, int size)
+ {
+   GstFFMpegPipe *ffpipe;
+   const guint8 *data;
+   guint available;
+ 
+-  ffpipe = (GstFFMpegPipe *) h->priv_data;
++  ffpipe = (GstFFMpegPipe *) priv_data;
+ 
+   GST_LOG ("requested size %d", size);
+ 
+@@ -367,21 +314,38 @@
+   return size;
+ }
+ 
+-static int
+-gst_ffmpeg_pipe_close (URLContext * h)
++int
++gst_ffmpeg_pipe_close (AVIOContext * h)
+ {
+   GST_LOG ("Closing pipe");
+ 
+-  h->priv_data = NULL;
++  h->opaque = NULL;
++  av_freep (&h->buffer);
++  av_free (h);
+ 
+   return 0;
+ }
+ 
+-URLProtocol gstpipe_protocol = {
+-  "gstpipe",
+-  gst_ffmpeg_pipe_open,
+-  gst_ffmpeg_pipe_read,
+-  NULL,
+-  NULL,
+-  gst_ffmpeg_pipe_close,
+-};
++int
++gst_ffmpeg_pipe_open (GstFFMpegPipe * ffpipe, int flags, AVIOContext ** context)
++{
++  static const int buffer_size = 4096;
++  unsigned char *buffer = NULL;
++
++  /* sanity check */
++  g_return_val_if_fail (GST_IS_ADAPTER (ffpipe->adapter), -EINVAL);
++
++  buffer = av_malloc (buffer_size);
++  if (buffer == NULL) {
++    GST_WARNING ("Failed to allocate buffer");
++    return -ENOMEM;
++  }
++
++  *context =
++      avio_alloc_context (buffer, buffer_size, 0, (void *) ffpipe,
++      gst_ffmpeg_pipe_read, NULL, NULL);
++  (*context)->seekable = 0;
++  (*context)->buf_ptr = (*context)->buf_end;
++
++  return 0;
++}
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c	2011-07-13 11:07:28.000000000 +0200
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c	2014-08-08 15:34:04.007874626 +0200
+@@ -25,6 +25,11 @@
+ #ifdef __APPLE__
+ #include <sys/sysctl.h>
+ #endif
++#ifdef HAVE_FFMPEG_UNINSTALLED
++#include <avformat.h>
++#else
++#include <libavformat/avformat.h>
++#endif
+ 
+ G_CONST_RETURN gchar *
+ gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
+@@ -39,21 +44,21 @@
+ }
+ 
+ gint
+-av_smp_format_depth (enum SampleFormat smp_fmt)
++av_smp_format_depth (enum AVSampleFormat smp_fmt)
+ {
+   gint depth = -1;
+   switch (smp_fmt) {
+-    case SAMPLE_FMT_U8:
++    case AV_SAMPLE_FMT_U8:
+       depth = 1;
+       break;
+-    case SAMPLE_FMT_S16:
++    case AV_SAMPLE_FMT_S16:
+       depth = 2;
+       break;
+-    case SAMPLE_FMT_S32:
+-    case SAMPLE_FMT_FLT:
++    case AV_SAMPLE_FMT_S32:
++    case AV_SAMPLE_FMT_FLT:
+       depth = 4;
+       break;
+-    case SAMPLE_FMT_DBL:
++    case AV_SAMPLE_FMT_DBL:
+       depth = 8;
+       break;
+     default:
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c.orig
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c.orig	1970-01-01 01:00:00.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c.orig	2011-07-13 11:07:28.000000000 +0200
+@@ -0,0 +1,483 @@
++/* GStreamer
++ * Copyright (c) 2009 Edward Hervey <bilboed@bilboed.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.
++ */
++
++#ifdef HAVE_CONFIG_H
++#include "config.h"
++#endif
++#include "gstffmpegutils.h"
++#include <unistd.h>
++#ifdef __APPLE__
++#include <sys/sysctl.h>
++#endif
++
++G_CONST_RETURN gchar *
++gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
++{
++  AVCodec *codec;
++  /* Let's use what ffmpeg can provide us */
++
++  if ((codec = avcodec_find_decoder (codec_id)) ||
++      (codec = avcodec_find_encoder (codec_id)))
++    return codec->long_name;
++  return NULL;
++}
++
++gint
++av_smp_format_depth (enum SampleFormat smp_fmt)
++{
++  gint depth = -1;
++  switch (smp_fmt) {
++    case SAMPLE_FMT_U8:
++      depth = 1;
++      break;
++    case SAMPLE_FMT_S16:
++      depth = 2;
++      break;
++    case SAMPLE_FMT_S32:
++    case SAMPLE_FMT_FLT:
++      depth = 4;
++      break;
++    case SAMPLE_FMT_DBL:
++      depth = 8;
++      break;
++    default:
++      GST_ERROR ("UNHANDLED SAMPLE FORMAT !");
++      break;
++  }
++  return depth;
++}
++
++
++/*
++ * Fill in pointers to memory in a AVPicture, where
++ * everything is aligned by 4 (as required by X).
++ * This is mostly a copy from imgconvert.c with some
++ * small changes.
++ */
++
++#define FF_COLOR_RGB      0     /* RGB color space */
++#define FF_COLOR_GRAY     1     /* gray color space */
++#define FF_COLOR_YUV      2     /* YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */
++#define FF_COLOR_YUV_JPEG 3     /* YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */
++
++#define FF_PIXEL_PLANAR   0     /* each channel has one component in AVPicture */
++#define FF_PIXEL_PACKED   1     /* only one components containing all the channels */
++#define FF_PIXEL_PALETTE  2     /* one components containing indexes for a palette */
++
++typedef struct PixFmtInfo
++{
++  const char *name;
++  uint8_t nb_channels;          /* number of channels (including alpha) */
++  uint8_t color_type;           /* color type (see FF_COLOR_xxx constants) */
++  uint8_t pixel_type;           /* pixel storage type (see FF_PIXEL_xxx constants) */
++  uint8_t is_alpha:1;           /* true if alpha can be specified */
++  uint8_t x_chroma_shift;       /* X chroma subsampling factor is 2 ^ shift */
++  uint8_t y_chroma_shift;       /* Y chroma subsampling factor is 2 ^ shift */
++  uint8_t depth;                /* bit depth of the color components */
++} PixFmtInfo;
++
++
++/* this table gives more information about formats */
++static PixFmtInfo pix_fmt_info[PIX_FMT_NB];
++void
++gst_ffmpeg_init_pix_fmt_info (void)
++{
++  /* YUV formats */
++  pix_fmt_info[PIX_FMT_YUV420P].name = g_strdup ("yuv420p");
++  pix_fmt_info[PIX_FMT_YUV420P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUV420P].color_type = FF_COLOR_YUV;
++  pix_fmt_info[PIX_FMT_YUV420P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUV420P].depth = 8,
++      pix_fmt_info[PIX_FMT_YUV420P].x_chroma_shift = 1,
++      pix_fmt_info[PIX_FMT_YUV420P].y_chroma_shift = 1;
++
++  pix_fmt_info[PIX_FMT_YUV422P].name = g_strdup ("yuv422p");
++  pix_fmt_info[PIX_FMT_YUV422P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUV422P].color_type = FF_COLOR_YUV;
++  pix_fmt_info[PIX_FMT_YUV422P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUV422P].depth = 8;
++  pix_fmt_info[PIX_FMT_YUV422P].x_chroma_shift = 1;
++  pix_fmt_info[PIX_FMT_YUV422P].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_YUV444P].name = g_strdup ("yuv444p");
++  pix_fmt_info[PIX_FMT_YUV444P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUV444P].color_type = FF_COLOR_YUV;
++  pix_fmt_info[PIX_FMT_YUV444P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUV444P].depth = 8;
++  pix_fmt_info[PIX_FMT_YUV444P].x_chroma_shift = 0;
++  pix_fmt_info[PIX_FMT_YUV444P].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_YUYV422].name = g_strdup ("yuv422");
++  pix_fmt_info[PIX_FMT_YUYV422].nb_channels = 1;
++  pix_fmt_info[PIX_FMT_YUYV422].color_type = FF_COLOR_YUV;
++  pix_fmt_info[PIX_FMT_YUYV422].pixel_type = FF_PIXEL_PACKED;
++  pix_fmt_info[PIX_FMT_YUYV422].depth = 8;
++  pix_fmt_info[PIX_FMT_YUYV422].x_chroma_shift = 1;
++  pix_fmt_info[PIX_FMT_YUYV422].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_YUV410P].name = g_strdup ("yuv410p");
++  pix_fmt_info[PIX_FMT_YUV410P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUV410P].color_type = FF_COLOR_YUV;
++  pix_fmt_info[PIX_FMT_YUV410P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUV410P].depth = 8;
++  pix_fmt_info[PIX_FMT_YUV410P].x_chroma_shift = 2;
++  pix_fmt_info[PIX_FMT_YUV410P].y_chroma_shift = 2;
++
++  pix_fmt_info[PIX_FMT_YUV411P].name = g_strdup ("yuv411p");
++  pix_fmt_info[PIX_FMT_YUV411P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUV411P].color_type = FF_COLOR_YUV;
++  pix_fmt_info[PIX_FMT_YUV411P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUV411P].depth = 8;
++  pix_fmt_info[PIX_FMT_YUV411P].x_chroma_shift = 2;
++  pix_fmt_info[PIX_FMT_YUV411P].y_chroma_shift = 0;
++
++  /* JPEG YUV */
++  pix_fmt_info[PIX_FMT_YUVJ420P].name = g_strdup ("yuvj420p");
++  pix_fmt_info[PIX_FMT_YUVJ420P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUVJ420P].color_type = FF_COLOR_YUV_JPEG;
++  pix_fmt_info[PIX_FMT_YUVJ420P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUVJ420P].depth = 8;
++  pix_fmt_info[PIX_FMT_YUVJ420P].x_chroma_shift = 1;
++  pix_fmt_info[PIX_FMT_YUVJ420P].y_chroma_shift = 1;
++
++  pix_fmt_info[PIX_FMT_YUVJ422P].name = g_strdup ("yuvj422p");
++  pix_fmt_info[PIX_FMT_YUVJ422P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUVJ422P].color_type = FF_COLOR_YUV_JPEG;
++  pix_fmt_info[PIX_FMT_YUVJ422P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUVJ422P].depth = 8;
++  pix_fmt_info[PIX_FMT_YUVJ422P].x_chroma_shift = 1;
++  pix_fmt_info[PIX_FMT_YUVJ422P].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_YUVJ444P].name = g_strdup ("yuvj444p");
++  pix_fmt_info[PIX_FMT_YUVJ444P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUVJ444P].color_type = FF_COLOR_YUV_JPEG;
++  pix_fmt_info[PIX_FMT_YUVJ444P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUVJ444P].depth = 8;
++  pix_fmt_info[PIX_FMT_YUVJ444P].x_chroma_shift = 0;
++  pix_fmt_info[PIX_FMT_YUVJ444P].y_chroma_shift = 0;
++
++  /* RGB formats */
++  pix_fmt_info[PIX_FMT_RGB24].name = g_strdup ("rgb24");
++  pix_fmt_info[PIX_FMT_RGB24].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_RGB24].color_type = FF_COLOR_RGB;
++  pix_fmt_info[PIX_FMT_RGB24].pixel_type = FF_PIXEL_PACKED;
++  pix_fmt_info[PIX_FMT_RGB24].depth = 8;
++  pix_fmt_info[PIX_FMT_RGB24].x_chroma_shift = 0;
++  pix_fmt_info[PIX_FMT_RGB24].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_BGR24].name = g_strdup ("bgr24");
++  pix_fmt_info[PIX_FMT_BGR24].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_BGR24].color_type = FF_COLOR_RGB;
++  pix_fmt_info[PIX_FMT_BGR24].pixel_type = FF_PIXEL_PACKED;
++  pix_fmt_info[PIX_FMT_BGR24].depth = 8;
++  pix_fmt_info[PIX_FMT_BGR24].x_chroma_shift = 0;
++  pix_fmt_info[PIX_FMT_BGR24].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_RGB32].name = g_strdup ("rgba32");
++  pix_fmt_info[PIX_FMT_RGB32].nb_channels = 4;
++  pix_fmt_info[PIX_FMT_RGB32].is_alpha = 1;
++  pix_fmt_info[PIX_FMT_RGB32].color_type = FF_COLOR_RGB;
++  pix_fmt_info[PIX_FMT_RGB32].pixel_type = FF_PIXEL_PACKED;
++  pix_fmt_info[PIX_FMT_RGB32].depth = 8;
++  pix_fmt_info[PIX_FMT_RGB32].x_chroma_shift = 0;
++  pix_fmt_info[PIX_FMT_RGB32].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_RGB565].name = g_strdup ("rgb565");
++  pix_fmt_info[PIX_FMT_RGB565].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_RGB565].color_type = FF_COLOR_RGB;
++  pix_fmt_info[PIX_FMT_RGB565].pixel_type = FF_PIXEL_PACKED;
++  pix_fmt_info[PIX_FMT_RGB565].depth = 5;
++  pix_fmt_info[PIX_FMT_RGB565].x_chroma_shift = 0;
++  pix_fmt_info[PIX_FMT_RGB565].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_RGB555].name = g_strdup ("rgb555");
++  pix_fmt_info[PIX_FMT_RGB555].nb_channels = 4;
++  pix_fmt_info[PIX_FMT_RGB555].is_alpha = 1;
++  pix_fmt_info[PIX_FMT_RGB555].color_type = FF_COLOR_RGB;
++  pix_fmt_info[PIX_FMT_RGB555].pixel_type = FF_PIXEL_PACKED;
++  pix_fmt_info[PIX_FMT_RGB555].depth = 5;
++  pix_fmt_info[PIX_FMT_RGB555].x_chroma_shift = 0;
++  pix_fmt_info[PIX_FMT_RGB555].y_chroma_shift = 0;
++
++  /* gray / mono formats */
++  pix_fmt_info[PIX_FMT_GRAY8].name = g_strdup ("gray");
++  pix_fmt_info[PIX_FMT_GRAY8].nb_channels = 1;
++  pix_fmt_info[PIX_FMT_GRAY8].color_type = FF_COLOR_GRAY;
++  pix_fmt_info[PIX_FMT_GRAY8].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_GRAY8].depth = 8;
++
++  pix_fmt_info[PIX_FMT_MONOWHITE].name = g_strdup ("monow");
++  pix_fmt_info[PIX_FMT_MONOWHITE].nb_channels = 1;
++  pix_fmt_info[PIX_FMT_MONOWHITE].color_type = FF_COLOR_GRAY;
++  pix_fmt_info[PIX_FMT_MONOWHITE].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_MONOWHITE].depth = 1;
++
++  pix_fmt_info[PIX_FMT_MONOBLACK].name = g_strdup ("monob");
++  pix_fmt_info[PIX_FMT_MONOBLACK].nb_channels = 1;
++  pix_fmt_info[PIX_FMT_MONOBLACK].color_type = FF_COLOR_GRAY;
++  pix_fmt_info[PIX_FMT_MONOBLACK].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_MONOBLACK].depth = 1;
++
++  /* paletted formats */
++  pix_fmt_info[PIX_FMT_PAL8].name = g_strdup ("pal8");
++  pix_fmt_info[PIX_FMT_PAL8].nb_channels = 4;
++  pix_fmt_info[PIX_FMT_PAL8].is_alpha = 1;
++  pix_fmt_info[PIX_FMT_PAL8].color_type = FF_COLOR_RGB;
++  pix_fmt_info[PIX_FMT_PAL8].pixel_type = FF_PIXEL_PALETTE;
++  pix_fmt_info[PIX_FMT_PAL8].depth = 8;
++
++  pix_fmt_info[PIX_FMT_YUVA420P].name = g_strdup ("yuva420p");
++  pix_fmt_info[PIX_FMT_YUVA420P].nb_channels = 4;
++  pix_fmt_info[PIX_FMT_YUVA420P].is_alpha = 1;
++  pix_fmt_info[PIX_FMT_YUVA420P].color_type = FF_COLOR_YUV;
++  pix_fmt_info[PIX_FMT_YUVA420P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUVA420P].depth = 8,
++      pix_fmt_info[PIX_FMT_YUVA420P].x_chroma_shift = 1,
++      pix_fmt_info[PIX_FMT_YUVA420P].y_chroma_shift = 1;
++};
++
++int
++gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height)
++{
++  AVPicture dummy_pict;
++
++  return gst_ffmpeg_avpicture_fill (&dummy_pict, NULL, pix_fmt, width, height);
++}
++
++#define GEN_MASK(x) ((1<<(x))-1)
++#define ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) & ~GEN_MASK(x))
++#define ROUND_UP_2(x) ROUND_UP_X (x, 1)
++#define ROUND_UP_4(x) ROUND_UP_X (x, 2)
++#define ROUND_UP_8(x) ROUND_UP_X (x, 3)
++#define DIV_ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) >> (x))
++
++int
++gst_ffmpeg_avpicture_fill (AVPicture * picture,
++    uint8_t * ptr, enum PixelFormat pix_fmt, int width, int height)
++{
++  int size, w2, h2, size2;
++  int stride, stride2;
++  PixFmtInfo *pinfo;
++
++  pinfo = &pix_fmt_info[pix_fmt];
++
++  switch (pix_fmt) {
++    case PIX_FMT_YUV420P:
++    case PIX_FMT_YUV422P:
++    case PIX_FMT_YUV444P:
++    case PIX_FMT_YUV410P:
++    case PIX_FMT_YUV411P:
++    case PIX_FMT_YUVJ420P:
++    case PIX_FMT_YUVJ422P:
++    case PIX_FMT_YUVJ444P:
++      stride = ROUND_UP_4 (width);
++      h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
++      size = stride * h2;
++      w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
++      stride2 = ROUND_UP_4 (w2);
++      h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift);
++      size2 = stride2 * h2;
++      picture->data[0] = ptr;
++      picture->data[1] = picture->data[0] + size;
++      picture->data[2] = picture->data[1] + size2;
++      picture->data[3] = NULL;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = stride2;
++      picture->linesize[2] = stride2;
++      picture->linesize[3] = 0;
++      GST_DEBUG ("planes %d %d %d", 0, size, size + size2);
++      GST_DEBUG ("strides %d %d %d", stride, stride2, stride2);
++      return size + 2 * size2;
++    case PIX_FMT_YUVA420P:
++      stride = ROUND_UP_4 (width);
++      h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
++      size = stride * h2;
++      w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
++      stride2 = ROUND_UP_4 (w2);
++      h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift);
++      size2 = stride2 * h2;
++      picture->data[0] = ptr;
++      picture->data[1] = picture->data[0] + size;
++      picture->data[2] = picture->data[1] + size2;
++      picture->data[3] = picture->data[2] + size2;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = stride2;
++      picture->linesize[2] = stride2;
++      picture->linesize[3] = stride;
++      GST_DEBUG ("planes %d %d %d %d", 0, size, size + size2, size + 2 * size2);
++      GST_DEBUG ("strides %d %d %d %d", stride, stride2, stride2, stride);
++      return 2 * size + 2 * size2;
++    case PIX_FMT_RGB24:
++    case PIX_FMT_BGR24:
++      stride = ROUND_UP_4 (width * 3);
++      size = stride * height;
++      picture->data[0] = ptr;
++      picture->data[1] = NULL;
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = 0;
++      picture->linesize[2] = 0;
++      picture->linesize[3] = 0;
++      return size;
++      /*case PIX_FMT_AYUV4444:
++         case PIX_FMT_BGR32:
++         case PIX_FMT_BGRA32:
++         case PIX_FMT_RGB32: */
++    case PIX_FMT_RGB32:
++      stride = width * 4;
++      size = stride * height;
++      picture->data[0] = ptr;
++      picture->data[1] = NULL;
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = 0;
++      picture->linesize[2] = 0;
++      picture->linesize[3] = 0;
++      return size;
++    case PIX_FMT_RGB555:
++    case PIX_FMT_RGB565:
++    case PIX_FMT_YUYV422:
++    case PIX_FMT_UYVY422:
++      stride = ROUND_UP_4 (width * 2);
++      size = stride * height;
++      picture->data[0] = ptr;
++      picture->data[1] = NULL;
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = 0;
++      picture->linesize[2] = 0;
++      picture->linesize[3] = 0;
++      return size;
++    case PIX_FMT_UYYVYY411:
++      /* FIXME, probably not the right stride */
++      stride = ROUND_UP_4 (width);
++      size = stride * height;
++      picture->data[0] = ptr;
++      picture->data[1] = NULL;
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      picture->linesize[0] = width + width / 2;
++      picture->linesize[1] = 0;
++      picture->linesize[2] = 0;
++      picture->linesize[3] = 0;
++      return size + size / 2;
++    case PIX_FMT_GRAY8:
++      stride = ROUND_UP_4 (width);
++      size = stride * height;
++      picture->data[0] = ptr;
++      picture->data[1] = NULL;
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = 0;
++      picture->linesize[2] = 0;
++      picture->linesize[3] = 0;
++      return size;
++    case PIX_FMT_MONOWHITE:
++    case PIX_FMT_MONOBLACK:
++      stride = ROUND_UP_4 ((width + 7) >> 3);
++      size = stride * height;
++      picture->data[0] = ptr;
++      picture->data[1] = NULL;
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = 0;
++      picture->linesize[2] = 0;
++      picture->linesize[3] = 0;
++      return size;
++    case PIX_FMT_PAL8:
++      /* already forced to be with stride, so same result as other function */
++      stride = ROUND_UP_4 (width);
++      size = stride * height;
++      picture->data[0] = ptr;
++      picture->data[1] = ptr + size;    /* palette is stored here as 256 32 bit words */
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = 4;
++      picture->linesize[2] = 0;
++      picture->linesize[3] = 0;
++      return size + 256 * 4;
++    default:
++      picture->data[0] = NULL;
++      picture->data[1] = NULL;
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      return -1;
++  }
++
++  return 0;
++}
++
++/* Create a GstBuffer of the requested size and caps.
++ * The memory will be allocated by ffmpeg, making sure it's properly aligned
++ * for any processing. */
++
++GstBuffer *
++new_aligned_buffer (gint size, GstCaps * caps)
++{
++  GstBuffer *buf;
++
++  buf = gst_buffer_new ();
++  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = av_malloc (size);
++  GST_BUFFER_SIZE (buf) = size;
++  GST_BUFFER_FREE_FUNC (buf) = av_free;
++  if (caps)
++    gst_buffer_set_caps (buf, caps);
++
++  return buf;
++}
++
++int
++gst_ffmpeg_auto_max_threads (void)
++{
++  static gsize n_threads = 0;
++  if (g_once_init_enter (&n_threads)) {
++    int n = 1;
++#if defined(_WIN32)
++    {
++      const char *s = getenv ("NUMBER_OF_PROCESSORS");
++      if (s) {
++        n = atoi (s);
++      }
++    }
++#elif defined(__APPLE__)
++    {
++      int mib[] = { CTL_HW, HW_NCPU };
++      size_t dataSize = sizeof (int);
++
++      if (sysctl (mib, 2, &n_threads, &dataSize, NULL, 0)) {
++        n = 1;
++      }
++    }
++#else
++    n = sysconf (_SC_NPROCESSORS_CONF);
++#endif
++    if (n < 1)
++      n = 1;
++
++    g_once_init_leave (&n_threads, n);
++  }
++
++  return (int) (n_threads);
++}
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h	2011-11-02 14:04:05.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h	2014-08-08 15:34:04.007874626 +0200
+@@ -23,6 +23,7 @@
+ #ifdef HAVE_FFMPEG_UNINSTALLED
+ #include <avcodec.h>
+ #else
++#include <libavutil/mathematics.h>
+ #include <libavcodec/avcodec.h>
+ #endif
+ #include <gst/gst.h>
+@@ -87,7 +88,7 @@
+ gst_ffmpeg_get_codecid_longname (enum CodecID codec_id);
+ 
+ gint
+-av_smp_format_depth(enum SampleFormat smp_fmt);
++av_smp_format_depth(enum AVSampleFormat smp_fmt);
+ 
+ GstBuffer *
+ new_aligned_buffer (gint size, GstCaps * caps);
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h.orig
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h.orig	1970-01-01 01:00:00.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h.orig	2014-08-08 15:26:38.473858652 +0200
+@@ -0,0 +1,95 @@
++/* GStreamer
++ * Copyright (C) <2009> Edward Hervey <bilboed@bilboed.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.
++ */
++
++#ifndef __GST_FFMPEG_UTILS_H__
++#define __GST_FFMPEG_UTILS_H__
++
++#ifdef HAVE_FFMPEG_UNINSTALLED
++#include <avcodec.h>
++#else
++#include <libavcodec/avcodec.h>
++#endif
++#include <gst/gst.h>
++
++/*
++ *Get the size of an picture
++ */
++int
++gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height);
++
++/*
++ * Fill in pointers in an AVPicture, aligned by 4 (required by X).
++ */
++
++int
++gst_ffmpeg_avpicture_fill (AVPicture * picture,
++                           uint8_t *   ptr,
++                           enum PixelFormat pix_fmt,
++                           int         width,
++                           int         height);
++
++/*
++ * Convert from/to a GStreamer <-> FFMpeg timestamp.
++ */
++static inline guint64
++gst_ffmpeg_time_ff_to_gst (gint64 pts, AVRational base)
++{
++  guint64 out;
++
++  if (pts == AV_NOPTS_VALUE){
++    out = GST_CLOCK_TIME_NONE;
++  } else {
++    AVRational bq = { 1, GST_SECOND };
++    out = av_rescale_q (pts, base, bq);
++  }
++
++  return out;
++}
++
++static inline gint64
++gst_ffmpeg_time_gst_to_ff (guint64 time, AVRational base)
++{
++  gint64 out;
++
++  if (!GST_CLOCK_TIME_IS_VALID (time) || base.num == 0) {
++    out = AV_NOPTS_VALUE;
++  } else {
++    AVRational bq = { 1, GST_SECOND };
++    out = av_rescale_q (time, bq, base);
++  }
++
++  return out;
++}
++
++void 
++gst_ffmpeg_init_pix_fmt_info(void);
++
++int
++gst_ffmpeg_auto_max_threads(void);
++
++G_CONST_RETURN gchar *
++gst_ffmpeg_get_codecid_longname (enum CodecID codec_id);
++
++gint
++av_smp_format_depth(enum AVSampleFormat smp_fmt);
++
++GstBuffer *
++new_aligned_buffer (gint size, GstCaps * caps);
++
++#endif /* __GST_FFMPEG_UTILS_H__ */
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch
new file mode 100644
index 0000000..eba4988
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch
@@ -0,0 +1,21 @@
+diff --git a/gst-libs/ext/libav/configure b/gst-libs/ext/libav/configure
+index 8473069..4f74952 100755
+--- a/gst-libs/ext/libav/configure
++++ b/gst-libs/ext/libav/configure
+Fix gst-ffmpeg build issues for libav on e500mc (fsl-p4080)
+
+Upstream-Status: Backport
+
+Signed-off-by: Yao Zhao <yao.zhao@windriver.com>
+
+@@ -2210,6 +2210,10 @@ elif enabled ppc; then
+             cpuflags="-mcpu=cell"
+             enable ldbrx
+         ;;
++        e500mc)
++            cpuflags="-mcpu=e500mc"
++            disable altivec
++        ;;
+         e500v2)
+             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
+             disable altivec
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch
new file mode 100644
index 0000000..d9ea2c2
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch
@@ -0,0 +1,19 @@
+libav: Add configs for ppc e5500
+
+Upstream-Status: Pending
+
+Signed-off-by: Jesse Zhang <sen.zhang@windriver.com>
+
+--- gst-ffmpeg-0.10.13/gst-libs/ext/libav/configure	2013-06-20 05:18:36.073104964 -0400
++++ gst-ffmpeg-0.10.13/gst-libs/ext/libav/configure	2013-06-20 05:18:38.269104150 -0400
+@@ -2222,6 +2222,10 @@
+             cpuflags="-mcpu=8540 -mhard-float"
+             disable altivec
+         ;;
++        e5500)
++            cpuflags="-mcpu=e5500 -mhard-float"
++            disable altivec
++        ;;
+     esac
+ 
+ elif enabled x86; then
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff
new file mode 100644
index 0000000..5f08afe
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff
@@ -0,0 +1,16 @@
+Lower the rank of ffmpeg plugin so codecs that hook into accelerated pieces (e.g. dsp or hw engines) can get picked over this
+Derived from OE by Dongxiao Xu <dongxiao.xu@intel.com>
+
+Upstream-Status: Inappropriate [embedded specific]
+
+--- /tmp/gstffmpegdec.c	2009-03-05 09:31:15.000000000 +0100
++++ gst-ffmpeg-0.10.6/ext/ffmpeg/gstffmpegdec.c	2009-03-05 09:33:09.000000000 +0100
+@@ -2588,7 +2588,7 @@
+       case CODEC_ID_MSMPEG4V3:
+       case CODEC_ID_H264:
+       case CODEC_ID_COOK:
+-        rank = GST_RANK_PRIMARY;
++        rank = GST_RANK_SECONDARY;
+         break;
+       case CODEC_ID_DVVIDEO:
+         /* we have a good dv decoder, fast on both ppc as well as x86. they say
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb
new file mode 100644
index 0000000..b5c838f
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb
@@ -0,0 +1,90 @@
+SUMMARY = "FFmpeg-based GStreamer plug-in"
+SECTION = "multimedia"
+LICENSE = "GPLv2+ & LGPLv2+ & ( (GPLv2+ & LGPLv2.1+) | (GPLv3+ & LGPLv3+) )"
+LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
+                    file://ext/libpostproc/gstpostproc.c;beginline=1;endline=18;md5=5896e445e41681324381f5869ee33d38 \
+                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
+                    file://ext/ffmpeg/gstffmpeg.h;beginline=1;endline=18;md5=ff65467b0c53cdfa98d0684c1bc240a9 \
+                    file://gst-libs/ext/libav/LICENSE;md5=abc3b8cb02856aa7823bbbd162d16232 \
+                    file://gst-libs/ext/libav/COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
+                    file://gst-libs/ext/libav/COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \
+                    file://gst-libs/ext/libav/COPYING.LGPLv2.1;md5=e344c8fa836c3a41c4cbd79d7bd3a379 \
+                    file://gst-libs/ext/libav/COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02"
+LICENSE_FLAGS = "commercial"
+HOMEPAGE = "http://www.gstreamer.net/"
+DEPENDS = "gstreamer gst-plugins-base zlib bzip2 yasm-native libpostproc"
+
+inherit autotools-brokensep pkgconfig
+
+SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2 \
+           file://lower-rank.diff \
+           file://configure-fix.patch \
+           file://h264_qpel_mmx.patch \
+           file://libav_e500mc.patch \
+           file://libav_e5500.patch \
+           file://gst-ffmpeg-CVE-2013-3674.patch \
+           file://0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch \
+           file://0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch \
+           file://0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch \
+           file://0001-huffyuvdec-Skip-len-0-cases.patch \
+           file://0001-huffyuvdec-Check-init_vlc-return-codes.patch \
+           file://0001-alsdec-check-block-length.patch \
+           file://0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch \
+           file://0001-atrac3dec-Check-coding-mode-against-channels.patch \
+           file://0001-eamad-fix-out-of-array-accesses.patch \
+           file://0001-mjpegdec-check-SE.patch \
+           file://0001-alac-fix-nb_samples-order-case.patch \
+           file://0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch \
+           file://0001-roqvideodec-check-dimensions-validity.patch \
+           file://0001-aacdec-check-channel-count.patch \
+           file://0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch \
+           file://0001-error_concealment-Check-that-the-picture-is-not-in-a.patch \
+           file://0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch \
+           file://0001-vp3-Copy-all-3-frames-for-thread-updates.patch \
+           file://0001-h264_sei-Fix-infinite-loop.patch \
+           file://0001-avcodec-parser-reset-indexes-on-realloc-failure.patch \
+           file://0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch \
+           file://gst-ffmpeg-CVE-2013-0855.patch \
+           file://0001-qdm2dec-fix-buffer-overflow.patch \
+           file://0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch \
+           file://0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch \
+           file://0001-error-concealment-initialize-block-index.patch \
+           file://0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch \
+           file://0001-lavf-compute-probe-buffer-size-more-reliably.patch \
+           file://0001-ffserver-set-oformat.patch \
+           file://0001-h264-set-parameters-from-SPS-whenever-it-changes.patch \
+           file://0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch \
+           file://0001-avcodec-smc-fix-off-by-1-error.patch \
+           file://0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch \
+           file://libav-9.patch \
+"
+
+SRC_URI[md5sum] = "7f5beacaf1312db2db30a026b36888c4"
+SRC_URI[sha256sum] = "76fca05b08e00134e3cb92fa347507f42cbd48ddb08ed3343a912def187fbb62"
+
+PR = "r8"
+
+GSTREAMER_DEBUG ?= "--disable-debug"
+
+FFMPEG_EXTRA_CONFIGURE = "--with-ffmpeg-extra-configure"
+# pass --cpu for powerpc. get cpu name by stripping "ppc" or "ppc64"
+# from DEFAULTTUNE
+FFMPEG_CPU_powerpc = "--cpu=${@d.getVar('DEFAULTTUNE')[3:]}"
+FFMPEG_CPU_powerpc64 = "--cpu=${@d.getVar('DEFAULTTUNE')[5:]}"
+FFMPEG_EXTRA_CONFIGURE_COMMON_ARG = "--target-os=linux ${FFMPEG_CPU} \
+  --cc='${CC}' --as='${CC}' --ld='${CC}' --nm='${NM}' --ar='${AR}' \
+  --ranlib='${RANLIB}' \
+  ${GSTREAMER_DEBUG}"
+FFMPEG_EXTRA_CONFIGURE_COMMON = \
+'${FFMPEG_EXTRA_CONFIGURE}="${FFMPEG_EXTRA_CONFIGURE_COMMON_ARG}"'
+
+EXTRA_OECONF = "${FFMPEG_EXTRA_CONFIGURE_COMMON}"
+
+PACKAGECONFIG ??= "external-libav"
+PACKAGECONFIG[external-libav] = "--with-system-ffmpeg,,libav"
+PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
+
+FILES_${PN} += "${libdir}/gstreamer-0.10/*.so"
+FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug"
+FILES_${PN}-dev += "${libdir}/gstreamer-0.10/*.la"
+FILES_${PN}-staticdev += "${libdir}/gstreamer-0.10/*.a"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.31.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.31.bb
new file mode 100644
index 0000000..1e2cd2a
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.31.bb
@@ -0,0 +1,14 @@
+require gst-fluendo.inc
+
+SUMMARY = "Fluendo closed-format mp3 GStreamer plug-in"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://COPYING;md5=259a43dd1c9854b71fc396f74699f4d2"
+LICENSE_FLAGS = "commercial"
+
+GSTREAMER_DEBUG ?= "--disable-debug"
+EXTRA_OECONF += "${GSTREAMER_DEBUG} --with-gstreamer-api=0.10"
+
+acpaths = "-I ${S}/common/m4 -I ${S}/m4"
+
+SRC_URI[md5sum] = "adf0390f3416bb72f91c358528be0c38"
+SRC_URI[sha256sum] = "dae0d0559a4e159c0dd92b7e18de059a5783f8d038904c7de4ca6393f7d55c7d"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.85.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.85.bb
new file mode 100644
index 0000000..7bba41a
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.85.bb
@@ -0,0 +1,12 @@
+require gst-fluendo.inc
+
+SUMMARY = "Fluendo MPEG Transport Stream and Program Stream demuxer for GStreamer"
+LICENSE = "MPLv1.1"
+LIC_FILES_CHKSUM = "file://COPYING;md5=be282f1c3cc9a98cc0dc5c2b25dfc510 \
+                    file://src/gstmpegdemux.h;beginline=1;endline=19;md5=a9e90033f59897b91664d9f2a2ff01dd"
+LICENSE_FLAGS = "commercial"
+
+acpaths = "-I ${S}/common/m4 -I ${S}/m4"
+
+SRC_URI[md5sum] = "7c4fb993f80b9ae631b11897733f0970"
+SRC_URI[sha256sum] = "df04c91cc8e5d9a892c2492ed989974b4547beaa2a3647649e85113317897424"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo.inc b/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo.inc
new file mode 100644
index 0000000..7a77d62
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo.inc
@@ -0,0 +1,14 @@
+SUMMARY = "Fluendo closed-format GStreamer plug-in"
+SECTION = "multimedia"
+HOMEPAGE = "https://core.fluendo.com/gstreamer/trac/wiki"
+DEPENDS = "gstreamer gst-plugins-base zlib"
+
+inherit autotools pkgconfig
+
+SRC_URI = "http://core.fluendo.com/gstreamer/src/${BPN}/${BPN}-${PV}.tar.bz2"
+
+FILES_${PN} += "${libdir}/gstreamer-0.10/*.so"
+FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug"
+FILES_${PN}-dev += "${libdir}/gstreamer-0.10/*.la ${libdir}/gstreamer-0.10/*.a"
+
+EXTRA_OECONF = "--disable-valgrind"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb
new file mode 100644
index 0000000..039abe1
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb
@@ -0,0 +1,73 @@
+SUMMARY = "GStreamer package groups"
+LICENSE = "MIT"
+
+COMMERCIAL_PLUGINS = "${COMMERCIAL_AUDIO_PLUGINS} ${COMMERCIAL_VIDEO_PLUGINS}"
+DEPENDS_UGLY="${@'gst-plugins-ugly' if 'ugly' in COMMERCIAL_PLUGINS.split('-') else ''}"
+DEPENDS_BAD="${@'gst-plugins-bad' if 'bad' in COMMERCIAL_PLUGINS.split('-') else ''}"
+DEPENDS = "gstreamer gst-plugins-base gst-plugins-good ${DEPENDS_UGLY} ${DEPENDS_BAD}"
+
+LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
+                    file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+
+
+PR = "r13"
+
+PACKAGES = "\
+    gst-meta-base \
+    gst-meta-x11-base \
+    gst-meta-audio \
+    gst-meta-debug \
+    gst-meta-video"
+
+ALLOW_EMPTY_gst-meta-base = "1"
+ALLOW_EMPTY_gst-meta-x11-base = "1"
+ALLOW_EMPTY_gst-meta-audio = "1"
+ALLOW_EMPTY_gst-meta-debug = "1"
+ALLOW_EMPTY_gst-meta-video = "1"
+
+RDEPENDS_gst-meta-base = "\
+    ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'gst-meta-x11-base', '', d)} \
+    gstreamer \
+    gst-plugins-base-playbin \
+    gst-plugins-base-decodebin \
+    gst-plugins-base-decodebin2 \
+    gst-plugins-base-gio \
+    gst-plugins-base-alsa \
+    gst-plugins-base-volume \
+    gst-plugins-base-audioconvert \
+    gst-plugins-base-audioresample \
+    gst-plugins-base-typefindfunctions \
+    gst-plugins-base-videoscale \
+    gst-plugins-base-ffmpegcolorspace \
+    gst-plugins-good-autodetect \
+    gst-plugins-good-souphttpsrc"
+
+RRECOMMENDS_gst-meta-x11-base = "\
+    gst-plugins-base-ximagesink \
+    gst-plugins-base-xvimagesink"
+
+RDEPENDS_gst-meta-audio = "\
+    gst-meta-base \
+    gst-plugins-base-vorbis \
+    gst-plugins-base-ogg \
+    gst-plugins-good-wavparse \
+    gst-plugins-good-flac \
+    ${COMMERCIAL_AUDIO_PLUGINS}"
+
+
+RDEPENDS_gst-meta-debug = "\
+    gst-meta-base \
+    gst-plugins-good-debug \
+    gst-plugins-base-audiotestsrc \
+    gst-plugins-base-videotestsrc"
+
+
+RDEPENDS_gst-meta-video = "\
+    gst-meta-base \
+    gst-plugins-good-avi \
+    gst-plugins-good-matroska \
+    gst-plugins-base-theora \
+    ${COMMERCIAL_VIDEO_PLUGINS}"
+
+RRECOMMENDS_gst-meta-video = "\
+    gst-meta-audio"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch
new file mode 100644
index 0000000..57a63b5
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch
@@ -0,0 +1,18 @@
+Upstream-Status: Pending
+
+Signed-off-by: Saul Wold <sgw@linux.intel.com>
+
+Index: gst-openmax-0.10.1/omx/gstomx.c
+===================================================================
+--- gst-openmax-0.10.1.orig/omx/gstomx.c	2010-09-30 18:00:24.000000000 -0700
++++ gst-openmax-0.10.1/omx/gstomx.c	2011-05-17 23:08:08.794535872 -0700
+@@ -238,7 +238,8 @@
+     const gchar *element_name = gst_structure_nth_field_name (element_table, i);
+     GstStructure *element = get_element_entry (element_name);
+     const gchar *type_name, *parent_type_name;
+-    const gchar *component_name, *component_role, *library_name;
++    const gchar *component_name, *library_name;
++    const gchar __attribute__((__unused__)) *component_role;
+     GType type;
+     gint rank;
+ 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch
new file mode 100644
index 0000000..5965bba
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch
@@ -0,0 +1,46 @@
+Rename static functions that use GLib naming conventions as one of them
+(g_ptr_array_insert) has now been added to GLib.
+
+Upstream-Status: Pending
+Signed-off-by: Ross Burton <ross.burton@intel.com>
+
+diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
+index 423e441..579dbf5 100644
+--- a/omx/gstomx_util.c
++++ b/omx/gstomx_util.c
+@@ -85,7 +85,7 @@ static gboolean initialized;
+  */
+ 
+ static void
+-g_ptr_array_clear (GPtrArray * array)
++omx_g_ptr_array_clear (GPtrArray * array)
+ {
+   guint index;
+   for (index = 0; index < array->len; index++)
+@@ -93,7 +93,7 @@ g_ptr_array_clear (GPtrArray * array)
+ }
+ 
+ static void
+-g_ptr_array_insert (GPtrArray * array, guint index, gpointer data)
++omx_g_ptr_array_insert (GPtrArray * array, guint index, gpointer data)
+ {
+   if (index + 1 > array->len) {
+     g_ptr_array_set_size (array, index + 1);
+@@ -394,7 +394,7 @@ g_omx_core_unload (GOmxCore * core)
+   }
+ 
+   core_for_each_port (core, g_omx_port_free);
+-  g_ptr_array_clear (core->ports);
++  omx_g_ptr_array_clear (core->ports);
+ }
+ 
+ static inline GOmxPort *
+@@ -418,7 +418,7 @@ g_omx_core_new_port (GOmxCore * core, guint index)
+   }
+ 
+   port = g_omx_port_new (core, index);
+-  g_ptr_array_insert (core->ports, index, port);
++  omx_g_ptr_array_insert (core->ports, index, port);
+ 
+   return port;
+ }
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb
new file mode 100644
index 0000000..2e01579
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb
@@ -0,0 +1,35 @@
+SUMMARY = "GStreamer plug-in for communication with OpenMAX IL components"
+DESCRIPTION = "GstOpenMAX is a GStreamer plug-in that allows \
+communication with OpenMAX Integration Layer (IL) components. OpenMAX \
+IL is an industry standard that provides an abstraction layer for \
+computer graphics, video, and sound routines."
+HOMEPAGE = "http://freedesktop.org/wiki/GstOpenMAX"
+DEPENDS = "gstreamer"
+RDEPENDS_${PN} = "libomxil"
+LICENSE = "LGPLv2.1"
+LICENSE_FLAGS = "commercial"
+LIC_FILES_CHKSUM = "file://COPYING;md5=fbc093901857fcd118f065f900982c24 \
+                    file://util/sem.h;beginline=1;endline=20;md5=accce5550d5583b839b441a0623f09fc"
+
+SRC_URI = "http://gstreamer.freedesktop.org/src/gst-openmax/gst-openmax-${PV}.tar.bz2 \
+           file://gcc_4.6.patch \
+           file://ptr-array.patch \
+           "
+
+inherit autotools pkgconfig
+
+# Tell configure that this isn't a development snapshot so we don't want
+# -Werror (hopefully fixed in 0.10.2)
+export GST_CVS="no"
+
+EXTRA_OECONF += "--disable-valgrind"
+
+PR = "r4"
+
+FILES_${PN} += "${libdir}/gstreamer-0.10/libgstomx.so"
+FILES_${PN}-dev += "${libdir}/gstreamer-0.10/libgstomx.la"
+FILES_${PN}-staticdev += "${libdir}/gstreamer-0.10/libgstomx.a"
+FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug/"
+
+SRC_URI[md5sum] = "4d0370bfe99dea20918c84347abadb4e"
+SRC_URI[sha256sum] = "9074d5a0591995133d19cfb15144f19664f902c1623f996595695cf2c2070e1f"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb
new file mode 100644
index 0000000..0f64871
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb
@@ -0,0 +1,50 @@
+require gst-plugins.inc
+
+LICENSE = "GPLv2+ & LGPLv2+ & LGPLv2.1+ "
+LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
+                    file://gst/tta/filters.h;beginline=12;endline=29;md5=629b0c7a665d155a6677778f4460ec06 \
+                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
+                    file://gst/tta/crc32.h;beginline=12;endline=29;md5=71a904d99ce7ae0c1cf129891b98145c"
+
+DEPENDS += "gst-plugins-base"
+
+PR = "r4"
+
+inherit gettext gsettings
+
+EXTRA_OECONF += "--disable-experimental \
+                 --disable-sdl --disable-cdaudio --disable-directfb \
+                 --disable-vdpau --disable-apexsink"
+
+PACKAGECONFIG ??= "bzip curl \
+                   ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'rsvg', '', d)}"
+
+PACKAGECONFIG[bzip] = "--enable-bz2,--disable-bz2,bzip2"
+PACKAGECONFIG[curl] = "--enable-curl,--disable-curl,curl"
+PACKAGECONFIG[rsvg] = "--enable-rsvg,--disable-rsvg,librsvg,"
+PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
+PACKAGECONFIG[neon] = "--enable-neon,--disable-neon,neon"
+PACKAGECONFIG[mms] = "--enable-libmms,--disable-libmms,libmms"
+PACKAGECONFIG[cog] = "--enable-cog,--disable-cog,libpng"
+PACKAGECONFIG[faad] = "--enable-faad,--disable-faad,faad2"
+PACKAGECONFIG[jp2k] = "--enable-jp2k,--disable-jp2k,jasper"
+PACKAGECONFIG[modplug] = "--enable-modplug,--disable-modplug,libmodplug"
+PACKAGECONFIG[opus] = "--enable-opus,--disable-opus,libopus"
+PACKAGECONFIG[sndfile] = "--enable-sndfile,--disable-sndfile,libsndfile1"
+PACKAGECONFIG[vp8] = "--enable-vp8,--disable-vp8,libvpx"
+PACKAGECONFIG[ass] = "--enable-assrender,--disable-assrender,libass"
+PACKAGECONFIG[openal] = "--enable-openal,--disable-openal,openal-soft"
+PACKAGECONFIG[schro] = "--enable-schro,--disable-schro,schroedinger"
+PACKAGECONFIG[dc1394] = "--enable-dc1394,--disable-dc1394,libdc1394"
+PACKAGECONFIG[faac] = "--enable-faac,--disable-faac,faac"
+PACKAGECONFIG[rtmp] = "--enable-rtmp,--disable-rtmp,rtmpdump"
+
+ARM_INSTRUCTION_SET = "arm"
+
+do_configure_prepend() {
+	# This m4 file contains nastiness which conflicts with libtool 2.2.2
+	rm ${S}/m4/lib-link.m4 || true
+}
+
+SRC_URI[md5sum] = "fcb09798114461955260e4d940db5987"
+SRC_URI[sha256sum] = "0eae7d1a1357ae8377fded6a1b42e663887beabe0e6cc336e2ef9ada42e11491"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
new file mode 100644
index 0000000..5214256
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
@@ -0,0 +1,37 @@
+audioresample: Fix build on x86 if emmintrin.h is available but can't be used
+
+On x86, EMMINTRIN is defined but not usable without SSE so check for
+__SSE__ and __SSE2__ as well.
+
+https://bugzilla.gnome.org/show_bug.cgi?id=670690
+
+Upstream-Status: Backport
+
+Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
+---
+ gst/audioresample/resample.c |    4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/gst/audioresample/resample.c b/gst/audioresample/resample.c
+index 98d006c..481fa01 100644
+--- a/gst/audioresample/resample.c
++++ b/gst/audioresample/resample.c
+@@ -77,13 +77,13 @@
+ #define EXPORT G_GNUC_INTERNAL
+ 
+ #ifdef _USE_SSE
+-#ifndef HAVE_XMMINTRIN_H
++#if !defined(__SSE__) || !defined(HAVE_XMMINTRIN_H)
+ #undef _USE_SSE
+ #endif
+ #endif
+ 
+ #ifdef _USE_SSE2
+-#ifndef HAVE_EMMINTRIN_H
++#if !defined(__SSE2__) || !defined(HAVE_EMMINTRIN_H)
+ #undef _USE_SSE2
+ #endif
+ #endif
+-- 
+1.7.1
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
new file mode 100644
index 0000000..b8602c8
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
@@ -0,0 +1,27 @@
+Upstream-Status: Submitted [similar patch by other author, bugzilla]
+Bugtracker-URL: https://bugzilla.gnome.org/show_bug.cgi?id=663600
+
+Prepend PKG_CONFIG_SYSROOT to includedir, so configure doesn't
+search for gstconfig.h in /usr/include.
+
+Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
+---
+ configure.ac |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 1901bcf..460fb0a 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -435,7 +435,7 @@ AG_GST_CHECK_PLUGIN(volume)
+ dnl check for gstreamer core features (subsystems)
+ dnl FIXME: this assumes srcdir == builddir for uninstalled setups
+ GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-0.10`"/gst/gstconfig.h"
+-AG_GST_PARSE_SUBSYSTEM_DISABLES($GST_CONFIGPATH)
++AG_GST_PARSE_SUBSYSTEM_DISABLES($PKG_CONFIG_SYSROOT_DIR$GST_CONFIGPATH)
+ AM_CONDITIONAL(USE_XML, test $GST_DISABLE_XML != "1")
+ 
+ dnl disable plug-ins that require libxml2's HTML support if it is not available
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
new file mode 100644
index 0000000..99dbc9d
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
@@ -0,0 +1,20 @@
+Remove -DTREMOR option since Tremor has dropped its internal
+libogg2, and gst-plugins-base has dependency on that.
+
+Upstream-Status: Inappropriate [configuration]
+
+Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
+Signed-off-by: Shane Wang <shane.wang@intel.com>
+
+diff -r 70065fb4e085 ext/vorbis/Makefile.am
+--- a/ext/vorbis/Makefile.am	Tue Mar 13 16:36:56 2012 +0800
++++ b/ext/vorbis/Makefile.am	Tue Mar 13 16:38:53 2012 +0800
+@@ -30,7 +30,7 @@
+ 	gstvorbisdec.c gstvorbisdeclib.c gstvorbiscommon.c
+ libgstivorbisdec_la_CFLAGS = \
+ 	$(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \
+-	-DTREMOR $(IVORBIS_CFLAGS)
++	$(IVORBIS_CFLAGS)
+ libgstivorbisdec_la_LIBADD = \
+ 	$(top_builddir)/gst-libs/gst/tag/libgsttag-@GST_MAJORMINOR@.la \
+ 	$(top_builddir)/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la \
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb
new file mode 100644
index 0000000..c8a9499
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb
@@ -0,0 +1,39 @@
+require gst-plugins.inc
+
+LICENSE = "GPLv2+ & LGPLv2+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
+                    file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=622921ffad8cb18ab906c56052788a3f \
+                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
+                    file://gst/ffmpegcolorspace/utils.c;beginline=1;endline=20;md5=9c83a200b8e597b26ca29df20fc6ecd0"
+
+DEPENDS += "alsa-lib liboil libogg libvorbis libtheora util-linux tremor glib-2.0-native"
+
+SRC_URI += "file://gst-plugins-base-tremor.patch \
+            file://configure.ac-fix-subparse-plugin.patch \
+            file://audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch \
+"
+
+SRC_URI[md5sum] = "776c73883e567f67b9c4a2847d8d041a"
+SRC_URI[sha256sum] = "2cd3b0fa8e9b595db8f514ef7c2bdbcd639a0d63d154c00f8c9b609321f49976"
+
+PR = "r8"
+
+inherit gettext
+
+EXTRA_OECONF += "--disable-freetypetest"
+
+PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}"
+
+PACKAGECONFIG[gnomevfs] = "--enable-gnome_vfs,--disable-gnome_vfs,gnome-vfs"
+PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
+PACKAGECONFIG[pango] = "--enable-pango,--disable-pango,pango"
+PACKAGECONFIG[x11] = "--enable-x --enable-xvideo,--disable-x --disable-xvideo,virtual/libx11 libxv libsm libice"
+
+do_configure_prepend() {
+	# This m4 file contains nastiness which conflicts with libtool 2.2.2
+	rm -f ${S}/m4/lib-link.m4
+}
+
+FILES_${PN} += "${datadir}/${BPN}"
+
+CACHED_CONFIGUREVARS_append_i586 = " ac_cv_header_emmintrin_h=no ac_cv_header_xmmintrin_h=no"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
new file mode 100644
index 0000000..bc2f88b
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
@@ -0,0 +1,35 @@
+From 14d51cbefef19737e7ab2b6818ee1d3bdb248d12 Mon Sep 17 00:00:00 2001
+From: Jeremy Stashluk <jstashluk@dekaresearch.com>
+Date: Wed, 6 Feb 2013 09:59:48 -0500
+Subject: [PATCH] conditional gl framebuffer undefined use
+
+The OpenGL extension GL_ARB_framebuffer_object defines the macro
+GL_FRAMEBUFFER_UNDEFINED. The macro will only need to map to an error
+string if the extension provides functions that might return the macro.
+
+Upstream-Status: Pending
+
+Signed-off-by: Jeremy Stashluk <jstashluk@dekaresearch.com>
+---
+ gst-libs/gst/gl/gstgldisplay.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c
+index 3ed0b71..64c6c2c 100644
+--- a/gst-libs/gst/gl/gstgldisplay.c
++++ b/gst-libs/gst/gl/gstgldisplay.c
+@@ -2177,9 +2177,11 @@ gst_gl_display_check_framebuffer_status (void)
+       GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
+       break;
+ 
++#if defined(GL_ARB_framebuffer_object)
+     case GL_FRAMEBUFFER_UNDEFINED:
+       GST_ERROR ("GL_FRAMEBUFFER_UNDEFINED");
+       break;
++#endif
+ 
+     default:
+       GST_ERROR ("General FBO error");
+-- 
+1.7.9.5
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb
new file mode 100644
index 0000000..90efbcc
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb
@@ -0,0 +1,25 @@
+require recipes-multimedia/gstreamer/gst-plugins.inc
+
+LICENSE = "GPLv2+ & LGPLv2+ & LGPLv2.1+ "
+LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605"
+
+SRC_URI[md5sum] = "ac70ede13f79978d56eaed8abaa3c938"
+SRC_URI[sha256sum] = "48340b6a4b8abce16344a7bc33e74a94fdcce4f57ef6342cdf2f941c429bf210"
+
+SRC_URI += " file://0001-conditional-gl-framebuffer-undefined-use.patch"
+
+DEPENDS += "gst-plugins-base virtual/libgles2 virtual/egl jpeg libpng glew"
+
+PR = "r4"
+
+inherit gettext
+
+# This package doesn't have a configure switch for EGL or GL, so forcibly tell
+# configure that it can't find gl.h so it always uses EGL.  If/when we have some
+# way for machines to specify their preferred GL flavour this can be
+# automatically adapted.
+EXTRA_OECONF += "ac_cv_header_GL_gl_h=no"
+
+ALLOW_EMPTY_${PN} = "1"
+ALLOW_EMPTY_${PN}-apps = "1"
+ALLOW_EMPTY_${PN}-glib = "1"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
new file mode 100644
index 0000000..6456d3c
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
@@ -0,0 +1,33 @@
+From 12d18fe4e98e7c232d59b56d529a0521f293fe6d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com>
+Date: Wed, 5 Sep 2012 18:54:42 +0200
+Subject: [PATCH] v4l2: fix build with recent kernels, the v4l2_buffer input
+ field was removed
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Upstream-Status: Backport
+
+[1] http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=9f2aa8d47f835ea155aaf635f618c0fc1ca87012
+
+Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
+---
+ sys/v4l2/gstv4l2bufferpool.c |    1 -
+ 1 files changed, 0 insertions(+), 1 deletions(-)
+
+diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c
+index b81c6a4..51cc0ce 100644
+--- a/sys/v4l2/gstv4l2bufferpool.c
++++ b/sys/v4l2/gstv4l2bufferpool.c
+@@ -181,7 +181,6 @@ gst_v4l2_buffer_new (GstV4l2BufferPool * pool, guint index, GstCaps * caps)
+     GST_LOG_OBJECT (pool->v4l2elem, "  MMAP offset:  %u",
+         ret->vbuffer.m.offset);
+   GST_LOG_OBJECT (pool->v4l2elem, "  length:    %u", ret->vbuffer.length);
+-  GST_LOG_OBJECT (pool->v4l2elem, "  input:     %u", ret->vbuffer.input);
+ 
+   data = (guint8 *) v4l2_mmap (0, ret->vbuffer.length,
+       PROT_READ | PROT_WRITE, MAP_SHARED, pool->video_fd,
+-- 
+1.7.6.5
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
new file mode 100644
index 0000000..bd0de58
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
@@ -0,0 +1,45 @@
+From ccb01de8096a32d86d47b0d92ec3416c57ee4d25 Mon Sep 17 00:00:00 2001
+From: Bruce Ashfield <bruce.ashfield@windriver.com>
+Date: Thu, 22 Aug 2013 12:15:54 -0400
+Subject: [PATCH] v4l2_calls: define V4L2_CID_HCENTER and V4L2_CID_VCENTER
+
+kernel commit 24b9f5017 [[media] V4L: Remove deprecated image centering controls]
+removed the definitions of V4L2_CID_HCENTER and V4L2_CID_VCENTER after three
+years of depreciation.
+
+The ioctl values are still free, and the case statement which processess them
+in v4l2 userspace falls through to the proper replacement. So in the short
+term, we can explicitly define them using the old absolute values, and everything
+will work.
+
+Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
+---
+ sys/v4l2/v4l2_calls.c |    9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c
+index 309bfb6..3c64544 100644
+--- a/sys/v4l2/v4l2_calls.c
++++ b/sys/v4l2/v4l2_calls.c
+@@ -54,11 +54,16 @@
+ #include "gst/gst-i18n-plugin.h"
+ 
+ /* Those are ioctl calls */
++
++/* V4L2_CID_HCENTER has been removed from the mainline kernel, but
++   the ioctl space is still present. Since these values fall through
++   to their replacement, it is safe (in the short term) to re-use the
++    old values explictily */
+ #ifndef V4L2_CID_HCENTER
+-#define V4L2_CID_HCENTER V4L2_CID_HCENTER_DEPRECATED
++#define V4L2_CID_HCENTER V4L2_CID_BASE+22
+ #endif
+ #ifndef V4L2_CID_VCENTER
+-#define V4L2_CID_VCENTER V4L2_CID_VCENTER_DEPRECATED
++#define V4L2_CID_VCENTER V4L2_CID_BASE+23
+ #endif
+ 
+ GST_DEBUG_CATEGORY_EXTERN (v4l2_debug);
+-- 
+1.7.10.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
new file mode 100644
index 0000000..48b8e98
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
@@ -0,0 +1,47 @@
+From ce94b2c2b91b6db190c121860e12a6afafce7ae1 Mon Sep 17 00:00:00 2001
+From: Roland Krikava <rkrikava@gmail.com>
+Date: Fri, 2 Nov 2012 12:38:44 -0400
+Subject: [PATCH 407/440] mulawdec: fix integer overrun
+
+There might be more than 65535 samples in a chunk of data.
+
+https://bugzilla.gnome.org/show_bug.cgi?id=687469
+
+Commit - 3be45f70220310ec1c60d819f90b5f2ae03b5d83 in 0.10 branch
+
+Upstream Status:  Backported
+
+Signed-off-by: Roland Krikava <rkrikava@gmail.com>
+---
+ gst/law/mulaw-conversion.c |    6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/gst/law/mulaw-conversion.c b/gst/law/mulaw-conversion.c
+index 8afae80..190a9f5 100644
+--- a/gst/law/mulaw-conversion.c
++++ b/gst/law/mulaw-conversion.c
+@@ -51,9 +51,10 @@ mulaw_encode (gint16 * in, guint8 * out, gint numsamples)
+     7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+     7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
+   };
+-  gint16 sign, exponent, mantissa, i;
++  gint16 sign, exponent, mantissa;
+   gint16 sample;
+   guint8 ulawbyte;
++  gint i;
+ 
+   for (i = 0; i < numsamples; i++) {
+     sample = in[i];
+@@ -102,7 +103,8 @@ mulaw_decode (guint8 * in, gint16 * out, gint numsamples)
+   static gint16 exp_lut[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 };
+   gint16 sign, exponent, mantissa;
+   guint8 ulawbyte;
+-  gint16 linear, i;
++  gint16 linear;
++  gint i;
+ 
+   for (i = 0; i < numsamples; i++) {
+     ulawbyte = in[i];
+-- 
+1.7.9.5
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb
new file mode 100644
index 0000000..af18281
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb
@@ -0,0 +1,47 @@
+require gst-plugins.inc
+
+LICENSE = "GPLv2+ & LGPLv2.1+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
+                    file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=622921ffad8cb18ab906c56052788a3f \
+                    file://gst/replaygain/rganalysis.c;beginline=1;endline=23;md5=b60ebefd5b2f5a8e0cab6bfee391a5fe"
+
+PR = "r8"
+
+PACKAGECONFIG ?= "jpeg v4l \
+    ${@bb.utils.contains('DISTRO_FEATURES', 'pulseaudio', 'pulseaudio', '', d)} \
+    ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)} \
+"
+PACKAGECONFIG[pulseaudio] = "--enable-pulse,--disable-pulse,pulseaudio"
+PACKAGECONFIG[jack] = "--enable-jack,--disable-jack,jack"
+PACKAGECONFIG[jpeg] = "--enable-jpeg,--disable-jpeg,jpeg"
+PACKAGECONFIG[wavpack] = "--enable-wavpack,--disable-wavpack,wavpack"
+PACKAGECONFIG[gdkpixbuf] = "--enable-gdk_pixbuf,--disable-gdk_pixbuf,gdk-pixbuf"
+PACKAGECONFIG[v4l] = "--enable-gst_v4l2 --with-gudev,--disable-gst_v4l2 --without-gudev,udev"
+# sub-feature of v4l, but control separately since libv4l is not part of oe-core
+PACKAGECONFIG[libv4l] = "--with-libv4l2,--without-libv4l2,libv4l"
+PACKAGECONFIG[bzip2] = "--enable-bz2,--disable-bz2,bzip2"
+PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
+PACKAGECONFIG[x11] = "--enable-x,--disable-x,virtual/libx11 libxfixes libxdamage"
+
+DEPENDS += "gst-plugins-base gconf cairo libpng zlib libid3tag flac \
+            speex libsoup-2.4 libcap"
+
+inherit gettext gconf
+
+SRC_URI += "file://0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch \
+            file://0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch \
+            file://0407-mulawdec-fix-integer-overrun.patch \
+"
+EXTRA_OECONF += "--disable-aalib --disable-esd --disable-shout2 --disable-libcaca --disable-hal \
+                 --disable-examples --disable-taglib"
+
+do_configure_prepend() {
+	# This m4 file contains nastiness which conflicts with libtool 2.2.2
+	rm ${S}/m4/lib-link.m4 || true
+}
+
+SRC_URI[md5sum] = "24f98a294a2b521e1b29412bdadae2e6"
+SRC_URI[sha256sum] = "7e27840e40a7932ef2dc032d7201f9f41afcaf0b437daf5d1d44dc96d9e35ac6"
+
+FILES_${PN}-gconfelements += "${sysconfdir}/gconf/schemas/gstreamer-0.10.schemas"
+FILES_${PN}-equalizer += "${datadir}/gstreamer-0.10/presets/*.prs"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb
new file mode 100644
index 0000000..2fdf03f
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb
@@ -0,0 +1,29 @@
+require gst-plugins.inc
+
+LICENSE = "GPLv2+ & LGPLv2.1+ & LGPLv2+"
+LICENSE_FLAGS = "commercial"
+LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
+                    file://gst/synaesthesia/synaescope.h;beginline=1;endline=20;md5=99f301df7b80490c6ff8305fcc712838 \
+                    file://tests/check/elements/xingmux.c;beginline=1;endline=21;md5=4c771b8af188724855cb99cadd390068 \
+                    file://gst/mpegstream/gstmpegparse.h;beginline=1;endline=18;md5=ff65467b0c53cdfa98d0684c1bc240a9"
+
+DEPENDS += "gst-plugins-base libid3tag libmad mpeg2dec liba52 lame"
+PR = "r3"
+
+inherit gettext
+
+EXTRA_OECONF += "--with-plugins=a52dec,lame,id3tag,mad,mpeg2dec,mpegstream,mpegaudioparse,asfdemux,realmedia \
+                 --disable-orc"
+
+PACKAGECONFIG ??= ""
+PACKAGECONFIG[x264] = "--enable-x264,--disable-x264,x264"
+PACKAGECONFIG[cdio] = "--enable-cdio,--disable-cdio,libcdio"
+PACKAGECONFIG[dvdread] = "--enable-dvdread,--disable-dvdread,libdvdread"
+
+do_configure_prepend() {
+	# This m4 file contains nastiness which conflicts with libtool 2.2.2
+	rm ${S}/m4/lib-link.m4 || true
+}
+
+SRC_URI[md5sum] = "1d81c593e22a6cdf0f2b4f57eae93df2"
+SRC_URI[sha256sum] = "1ca90059275c0f5dca71d4d1601a8f429b7852baed0723e820703b977e2c8df0"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc
new file mode 100644
index 0000000..c852c53
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc
@@ -0,0 +1,28 @@
+SUMMARY = "Plugins for the GStreamer multimedia framework"
+HOMEPAGE = "http://gstreamer.freedesktop.org/"
+BUGTRACKER = "https://bugzilla.gnome.org/enter_bug.cgi?product=Gstreamer"
+SECTION = "multimedia"
+DEPENDS = "gstreamer"
+
+inherit autotools pkgconfig
+
+SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2"
+
+GSTREAMER_DEBUG ?= "--disable-debug"
+EXTRA_OECONF = "--disable-valgrind ${GSTREAMER_DEBUG} --disable-examples "
+
+acpaths = "-I ${S}/common/m4 -I ${S}/m4"
+
+LIBV = "0.10"
+require gst-plugins-package.inc
+
+PACKAGES_DYNAMIC += "^${PN}-.*"
+
+# apply gstreamer hack after Makefile.in.in in source is replaced by our version from
+# ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in, but before configure is executed
+# http://lists.linuxtogo.org/pipermail/openembedded-core/2012-November/032233.html
+oe_runconf_prepend() {
+	if [ -e ${S}/po/Makefile.in.in ]; then
+		sed -i -e "1a\\" -e 'GETTEXT_PACKAGE = @GETTEXT_PACKAGE@' ${S}/po/Makefile.in.in
+	fi
+}
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
new file mode 100644
index 0000000..d077496
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
@@ -0,0 +1,32 @@
+From ed7f4802222234eef192aa3f74bc92268f338f97 Mon Sep 17 00:00:00 2001
+From: Sebastian Droege <sebastian.droege@collabora.co.uk>
+Date: Tue, 6 Mar 2012 12:28:02 +0100
+Subject: [PATCH] baseparse: Fix 'self-comparison always evaluates to true'
+
+This was really a bug.
+
+Commit is ed7f4802222234eef192aa3f74bc92268f338f97 in 0.10 branch
+
+Upstream Status:  Backported
+
+Signed-off-by: Sebastian Droege <sebastian.droege@collabora.co.uk>
+---
+ libs/gst/base/gstbaseparse.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c
+index 851ec1d..108ee89 100644
+--- a/libs/gst/base/gstbaseparse.c
++++ b/libs/gst/base/gstbaseparse.c
+@@ -3899,7 +3899,7 @@ gst_base_parse_handle_seek (GstBaseParse * parse, GstEvent * event)
+        seek event (in bytes) to upstream. Segment / flush handling happens
+        in corresponding src event handlers */
+     GST_DEBUG_OBJECT (parse, "seek in PUSH mode");
+-    if (seekstop >= 0 && seekpos <= seekpos)
++    if (seekstop >= 0 && seekstop <= seekpos)
+       seekstop = seekpos;
+     new_event = gst_event_new_seek (rate, GST_FORMAT_BYTES, flags,
+         GST_SEEK_TYPE_SET, seekpos, stop_type, seekstop);
+-- 
+1.7.9.5
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch
new file mode 100644
index 0000000..5d8bb13
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch
@@ -0,0 +1,19 @@
+# gstreamer: Fix a problem with configure if check has already been built
+# Richard Purdie <rpurdie@linux.intel.com>
+
+Upstream-Status: Inappropriate [configuration]
+
+diff -urN gstreamer-0.10.29-orig/configure.ac gstreamer-0.10.29/configure.ac
+--- gstreamer-0.10.29-orig/configure.ac	2010-06-26 12:49:27.774930773 +0800
++++ gstreamer-0.10.29/configure.ac	2010-06-26 12:51:12.899200233 +0800
+@@ -543,8 +543,10 @@
+       *) BUILD_CHECK=yes ;;
+     esac
+ ])
++
+ dnl bit of a misnomer, but keep the conditional named like this so we don't
+ dnl have to change too much elsewhere
++HAVE_CHECK=no
+ AM_CONDITIONAL(HAVE_CHECK, test "x$BUILD_CHECK" = "xyes")
+ 
+ dnl configure the desired buffer alignment
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch
new file mode 100644
index 0000000..30be85f
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch
@@ -0,0 +1,16 @@
+# Fix crash with gst-inspect
+# Chris Lord <chris@openedhand.com>
+
+Upstream-Status: Pending
+
+--- gstreamer-0.10.9/tools/gst-inspect.c.old	2006-09-12 11:56:53.000000000 +0100
++++ gstreamer-0.10.9/tools/gst-inspect.c	2006-09-12 11:57:27.000000000 +0100
+@@ -1123,7 +1123,7 @@
+   g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
+   g_option_context_add_group (ctx, gst_init_get_option_group ());
+   if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
+-    g_print ("Error initializing: %s\n", err->message);
++    g_print ("Error initializing: %s\n", err ? err->message : "(null)");
+     exit (1);
+   }
+   g_option_context_free (ctx);
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
new file mode 100644
index 0000000..bf93cb2
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
@@ -0,0 +1,33 @@
+gstreamer: change priv_gst_parse_yylex arguments
+
+Change priv_gst_parse_yylex to fit new bison version, else we will
+get following error:
+
+| grammar.tab.c: In function 'priv_gst_parse_yyparse':
+| grammar.tab.c:67:25: error: too few arguments to function 'priv_gst_parse_yylex'
+|  #define yylex           priv_gst_parse_yylex
+|                          ^
+
+Upstream-Status: Pending
+
+Signed-off-by: Chong Lu <Chong.Lu@windriver.com>
+---
+ gst/parse/grammar.y | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/gst/parse/grammar.y b/gst/parse/grammar.y
+index 24fc87b..24fe906 100644
+--- a/gst/parse/grammar.y
++++ b/gst/parse/grammar.y
+@@ -36,7 +36,7 @@
+ 
+ typedef void* yyscan_t;
+ 
+-int priv_gst_parse_yylex (void * yylval_param , yyscan_t yyscanner);
++int priv_gst_parse_yylex (yyscan_t yyscanner);
+ int priv_gst_parse_yylex_init (yyscan_t scanner);
+ int priv_gst_parse_yylex_destroy (yyscan_t scanner);
+ struct yy_buffer_state * priv_gst_parse_yy_scan_string (char* , yyscan_t);
+-- 
+1.9.1
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c
new file mode 100644
index 0000000..c1f3e71
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c
@@ -0,0 +1,487 @@
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ *                    2000 Wim Taymans <wtay@chello.be>
+ *                    2005 David A. Schleef <ds@schleef.org>
+ *
+ * gstregistryxml.c: GstRegistry object, support routines
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it ulnder 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.
+ */
+
+
+#include <gst/gstregistrybinary.h>
+
+/*
+** Simple handy function to write a memory location to the registry cache file
+*/
+inline static gboolean
+gst_registry_binary_write(GstRegistry *registry, const void *mem, const ssize_t size)
+{
+  if (write(registry->cache_file, mem, size) != size)
+    {
+      GST_ERROR("Failed to write binary registry element: ptr=%p size=%u error=%s\n",
+		mem, size, strerror(errno));
+      return FALSE;
+    }
+  return TRUE;
+}
+
+/*
+** Save features GstBinary style
+*/
+static gboolean 
+gst_registry_binary_fill_feature(GList **list, GstPluginFeature *orig, GstBinaryPluginFeature *dest, const char *name)
+{
+  GstBinaryChunck *chk;
+
+  if ((chk = calloc(1, sizeof (GstBinaryChunck))) == NULL)
+    return FALSE;
+
+  chk->data = dest;
+  chk->size = sizeof (GstBinaryPluginFeature);
+
+  *list = g_list_append(*list, chk);
+
+  dest->rank = orig->rank;
+  if (!strncpy(dest->typename, name, GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN) ||
+      !strncpy(dest->name, orig->name, GST_BINARY_REGISTRY_TYPENAME_NAME_LEN))
+    {
+      GST_ERROR("Failed to write binary registry feature");
+      goto fail;
+    }
+  
+  if (GST_IS_ELEMENT_FACTORY(orig))
+    {
+      GstElementFactory *factory = GST_ELEMENT_FACTORY(orig);
+      
+      if (!strncpy(dest->longname, factory->details.longname, GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN) ||
+	  !strncpy(dest->class, factory->details.klass, GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN) ||
+	  !strncpy(dest->description, factory->details.description, GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN) ||
+	  !strncpy(dest->author, factory->details.author, GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN))
+	{
+	  GST_ERROR("Failed to write binary registry feature");
+	  goto fail;
+	}
+    }
+  
+  dest->npadtemplates = dest->ninterfaces = dest->nuritypes = 0;
+  return TRUE;
+
+ fail:
+  free(chk);
+  return FALSE;
+}
+
+
+/*
+** Initialize the GstBinaryRegistryMagic, setting both our magic number and gstreamer major/minor version
+*/
+inline static gboolean
+gst_registry_binary_initialize_magic(GstBinaryRegistryMagic *m)
+{
+  if (!strncpy(m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) ||
+      !strncpy(m->version, GST_MAJORMINOR, GST_BINARY_REGISTRY_VERSION_LEN))
+    {
+      GST_ERROR("Failed to write magic to the registry magic structure");
+      return FALSE;
+    }
+  return TRUE;
+}
+
+/*
+** Check GstBinaryRegistryMagic validity.
+** Return a pointer pointing right after the magic structure
+*/
+static gchar *
+gst_registry_binary_check_magic(gchar *in)
+{
+  GstBinaryRegistryMagic *m = (GstBinaryRegistryMagic *) in;
+
+  if (m == NULL || m->magic == NULL || m->version == NULL)
+    {
+      GST_ERROR("Binary registry magic structure is broken");
+      return NULL;
+    }
+  if (strncmp(m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) != 0)
+    {
+      GST_ERROR("Binary registry magic is different : %02x%02x%02x%02x != %02x%02x%02x%02x",
+		GST_MAGIC_BINARY_REGISTRY_STR[0] & 0xff, GST_MAGIC_BINARY_REGISTRY_STR[1] & 0xff,
+		GST_MAGIC_BINARY_REGISTRY_STR[2] & 0xff, GST_MAGIC_BINARY_REGISTRY_STR[3] & 0xff,
+		m->magic[0] & 0xff, m->magic[1] & 0xff, m->magic[2] & 0xff, m->magic[3] & 0xff);
+      return NULL;
+    }
+  if (strncmp(m->version, GST_MAJORMINOR, GST_BINARY_REGISTRY_VERSION_LEN))
+    {
+      GST_ERROR("Binary registry magic version is different : %s != %s",
+		GST_MAJORMINOR, m->version);
+      return NULL;
+    }
+  return (in + sizeof (GstBinaryRegistryMagic));
+}
+
+/*
+** Adapt a GstPlugin to our GstBinaryPluginElement structure, and write it to the 
+** registry file.
+*/   
+static gboolean
+gst_registry_binary_save_plugin(GList **list, GstRegistry *registry, GstPlugin *plugin)
+{
+  GstBinaryPluginElement *e;
+  GstBinaryChunck *chk;
+  GList *walk;
+
+  if ((e = calloc(1, sizeof (GstBinaryPluginElement))) == NULL ||
+      (chk = calloc(1, sizeof (GstBinaryChunck))) == NULL)
+    return FALSE;
+
+  chk->data = e;
+  chk->size = sizeof (GstBinaryPluginElement);
+  *list = g_list_append(*list, chk);
+
+  if (!strncpy(e->name, plugin->desc.name, GST_BINARY_REGISTRY_NAME_LEN)		       	||
+      !strncpy(e->description, plugin->desc.description, GST_BINARY_REGISTRY_DESCRIPTION_LEN)	||
+      !strncpy(e->filename, plugin->filename, _POSIX_PATH_MAX)					||
+      !strncpy(e->version, plugin->desc.version, GST_BINARY_REGISTRY_VERSION_LEN)		||
+      !strncpy(e->license, plugin->desc.license, GST_BINARY_REGISTRY_LICENSE_LEN)		||
+      !strncpy(e->source, plugin->desc.source, GST_BINARY_REGISTRY_SOURCE_LEN)			||
+      !strncpy(e->package, plugin->desc.package, GST_BINARY_REGISTRY_PACKAGE_LEN)		||
+      !strncpy(e->origin, plugin->desc.origin, GST_BINARY_REGISTRY_ORIGIN_LEN))
+    {
+      GST_DEBUG("Can't adapt GstPlugin to GstBinaryPluginElement");
+      goto fail;
+    }
+
+  e->size = plugin->file_size;
+  e->m32p = plugin->file_mtime;
+  
+  GList *ft_list = gst_registry_get_feature_list_by_plugin(registry, plugin->desc.name);
+
+  for (walk = ft_list; walk; walk = g_list_next(walk), e->nfeatures++)
+    {
+      GstPluginFeature *curfeat = GST_PLUGIN_FEATURE (walk->data);
+      GstBinaryPluginFeature *newfeat;
+      const char *feat_name = g_type_name(G_OBJECT_TYPE(curfeat));
+      
+      if ((newfeat = calloc(1, sizeof (GstBinaryPluginFeature))) == NULL)
+	  goto fail;
+
+      if (!feat_name || !gst_registry_binary_fill_feature(list, curfeat, newfeat, feat_name))
+	{
+	  GST_ERROR("Can't fill plugin feature, aborting.");
+	  goto fail;
+	}
+    }
+
+  GST_DEBUG("Found %d features in plugin \"%s\"\n", e->nfeatures, e->name);
+  return TRUE;
+
+ fail:
+  free(chk);
+  free(e);
+  return FALSE;
+}
+
+/*
+** Write the cache to file. Part of the code was taken from gstregistryxml.c
+*/
+gboolean 
+gst_registry_binary_write_cache(GstRegistry *registry, const char *location)
+{
+  GList *walk;
+  char *tmp_location;
+  GstBinaryRegistryMagic *magic;
+  GstBinaryChunck *magic_chunck;
+  GList *to_write = NULL;
+ 
+  GST_INFO("Writing binary registry cache");
+
+  g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
+  tmp_location = g_strconcat (location, ".tmpXXXXXX", NULL);
+  registry->cache_file = g_mkstemp (tmp_location);
+  if (registry->cache_file == -1)
+    {
+      char *dir;
+
+      /* oops, I bet the directory doesn't exist */
+      dir = g_path_get_dirname (location);
+      g_mkdir_with_parents (dir, 0777);
+      g_free (dir);
+      
+      registry->cache_file = g_mkstemp (tmp_location);
+    }
+
+  if (registry->cache_file == -1)
+    goto fail;
+
+  if ((magic = calloc(1, sizeof (GstBinaryRegistryMagic))) == NULL ||
+      !gst_registry_binary_initialize_magic(magic))
+    goto fail;
+
+  if ((magic_chunck = calloc(1, sizeof (GstBinaryChunck))) == NULL)
+    goto fail;
+
+  magic_chunck->data = magic;
+  magic_chunck->size = sizeof (GstBinaryRegistryMagic);
+  to_write = g_list_append(to_write, magic_chunck); 
+
+  /* Iterate trough the list of plugins in the GstRegistry and adapt them to our structures */
+  for (walk = g_list_last(registry->plugins); walk; walk = g_list_previous(walk))
+    {
+      GstPlugin *plugin = GST_PLUGIN(walk->data);
+      
+      if (!plugin->filename)
+	continue;
+	  
+      if (plugin->flags & GST_PLUGIN_FLAG_CACHED)
+	{
+	  int ret;
+	  struct stat statbuf;
+	  
+	  ret = g_stat (plugin->filename, &statbuf);
+	  if ((ret = g_stat (plugin->filename, &statbuf)) < 0 	||
+	      plugin->file_mtime != statbuf.st_mtime		||
+	      plugin->file_size != statbuf.st_size)
+	    continue;
+	}
+
+      if (!gst_registry_binary_save_plugin(&to_write, registry, plugin))
+	{
+	  GST_ERROR("Can't write binary plugin information for \"%s\"", plugin->filename);
+	  continue; /* Try anyway */
+	}
+    }
+
+  for (walk = g_list_first(to_write); walk; walk = g_list_next(walk))
+    {
+      GstBinaryChunck *cur = walk->data;
+
+      if (!gst_registry_binary_write(registry, cur->data, cur->size))
+	{
+	  free(cur->data);
+	  free(cur);
+	  g_list_free(to_write);
+	  goto fail;
+	}
+      free(cur->data);
+      free(cur);
+    }
+  g_list_free(to_write);
+
+  if (close(registry->cache_file) < 0)
+    {
+      GST_DEBUG("Can't close registry file : %s", strerror(errno));
+      goto fail;
+    }
+  
+  if (g_file_test (tmp_location, G_FILE_TEST_EXISTS)) {
+#ifdef WIN32
+    remove (location);
+#endif
+    rename (tmp_location, location);
+  }
+
+  g_free (tmp_location);
+  return TRUE;
+
+ fail:
+  g_free(tmp_location);
+  return FALSE;
+}
+
+static GstPluginFeature*
+gst_registry_binary_load_feature(GstBinaryPluginFeature *in)
+{
+  GstPluginFeature *feature;
+  GType type;
+
+  if (!in->typename || !*(in->typename))
+    return NULL;
+
+  /*  GST_INFO("Plugin feature typename : %s", in->typename);*/
+
+  if (!(type = g_type_from_name(in->typename)))
+    {
+      GST_ERROR("Unknown type from typename");
+      return NULL;
+    }
+  feature = g_object_new (type, NULL);
+
+  if (!feature) {
+    GST_ERROR("Can't create feature from type");
+    return NULL;
+  }
+
+  if (!GST_IS_PLUGIN_FEATURE (feature)) {
+    /* don't really know what it is */
+    if (GST_IS_OBJECT (feature))
+      gst_object_unref (feature);
+    else
+      g_object_unref (feature);
+    return NULL;
+  }
+
+  feature->name = g_strdup(in->name);
+  feature->rank = in->rank;
+
+  if (GST_IS_ELEMENT_FACTORY(feature))
+    {
+      GstElementFactory *factory = GST_ELEMENT_FACTORY(feature);
+
+      factory->details.longname = g_strdup(in->longname);
+      factory->details.klass = g_strdup(in->class);
+      factory->details.description = g_strdup(in->description);
+      factory->details.author = g_strdup(in->author);
+
+      /*      GST_INFO("Element factory : %s", factory->details.longname); */
+    }
+
+  GST_DEBUG("Added feature %p with name %s", feature, feature->name);
+  return feature;
+}
+
+/*
+** Make a new plugin from current GstBinaryPluginElement structure
+** and save it to the GstRegistry. Return an offset to the next
+** GstBinaryPluginElement structure.
+*/
+static unsigned long
+gst_registry_binary_get_binary_plugin(GstRegistry *registry, gchar *in)
+{
+  GstBinaryPluginElement *p = (GstBinaryPluginElement *) in;
+  GstPlugin *plugin = NULL;
+  GList *plugin_features = NULL;
+  GstBinaryPluginFeature *feat;
+  unsigned int i;
+  unsigned long offset;
+
+  plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
+
+  plugin->flags |= GST_PLUGIN_FLAG_CACHED;
+
+  plugin->desc.name = g_strdup(p->name);
+  plugin->desc.description= g_strdup(p->description);
+  plugin->filename = g_strdup(p->filename);
+  plugin->desc.version = g_strdup(p->version);
+  plugin->desc.license = g_strdup(p->license);
+  plugin->desc.source = g_strdup(p->source);
+  plugin->desc.package = g_strdup(p->package);
+  plugin->desc.origin = g_strdup(p->origin);
+  plugin->file_mtime = p->m32p;
+  plugin->file_size = p->size;
+  plugin->basename = g_path_get_basename (plugin->filename);
+
+  if (plugin->file_mtime < 0 || plugin->file_size < 0)
+    {
+      GST_ERROR("Plugin time or file size is not valid !");
+      g_free(plugin);
+      return -1;
+    }
+
+  if (p->nfeatures < 0)
+    {
+      GST_ERROR("The number of feature structure is not valid !");
+      gst_object_unref(plugin);
+      return -1;
+    }
+
+  for (feat = (GstBinaryPluginFeature *) (in + sizeof (GstBinaryPluginElement)), i = 0; 
+       i < p->nfeatures; i++, feat++)
+    {
+      GstPluginFeature *gstfeat;
+
+      if ((gstfeat = gst_registry_binary_load_feature(feat)) == NULL)
+	{
+	  g_list_free(plugin_features);
+	  g_free(plugin);
+	  GST_ERROR("Error while loading binary feature");
+	  return -1;
+	}
+      gstfeat->plugin_name = g_strdup(plugin->desc.name);
+      plugin_features = g_list_prepend(plugin_features, gstfeat);
+    }
+  
+  GST_DEBUG("Added plugin \"%s\" to global registry from binary registry", plugin->desc.name); 
+  GList *g;
+
+  gst_registry_add_plugin (registry, plugin);
+  for (g = plugin_features; g; g = g_list_next (g))
+    gst_registry_add_feature (registry, GST_PLUGIN_FEATURE (g->data));
+  /*  g_list_free(plugin_features); */
+
+  offset = sizeof (GstBinaryPluginElement) + p->nfeatures * sizeof (GstBinaryPluginFeature);
+  return offset;
+}
+
+
+/*
+** Read the cache and adapt it to fill GstRegistry
+*/ 
+gboolean 
+gst_registry_binary_read_cache(GstRegistry *registry, const char *location)
+{
+  GMappedFile *mapped = NULL;
+  GTimer *timer = NULL;
+  gchar *contents = NULL;
+  gdouble seconds;
+  unsigned long offset, inc;
+  gsize size;
+
+  /* make sure these types exist */
+  GST_TYPE_ELEMENT_FACTORY;
+  GST_TYPE_TYPE_FIND_FACTORY;
+  GST_TYPE_INDEX_FACTORY;
+
+  timer = g_timer_new ();
+
+  if ((mapped = g_mapped_file_new(location, FALSE, NULL)) == NULL ||
+      (contents = g_mapped_file_get_contents(mapped)) == NULL)
+    {
+      GST_ERROR("Can't load file : %s", strerror(errno));
+      return FALSE;
+    }
+  if ((contents = gst_registry_binary_check_magic(contents)) == NULL)
+    {
+      GST_ERROR("Binary registry type not recognized (invalid magic)");
+      g_mapped_file_free(mapped);
+      return FALSE;
+    }
+
+  if ((size = g_mapped_file_get_length(mapped)) < sizeof (GstBinaryPluginElement))
+    {
+      GST_INFO("No binary plugins structure to read");
+      return TRUE; /* This is not really an error */
+    }
+
+  for (offset = inc = 0; (offset + sizeof (GstBinaryPluginElement)) < size &&
+	 (inc = gst_registry_binary_get_binary_plugin(registry, contents + offset)) > 0;
+       offset += inc)
+    ; /* May want in the future to do something here */
+  if (inc < 0)
+    {
+      GST_DEBUG("Problem while reading binary registry");
+      return FALSE;
+    }
+
+  g_timer_stop (timer);
+  seconds = g_timer_elapsed (timer, NULL);
+  g_timer_destroy (timer);
+
+  GST_INFO ("loaded %s in %f seconds", location, seconds);
+
+  if (mapped)
+    g_mapped_file_free (mapped);
+  return TRUE;
+}
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h
new file mode 100644
index 0000000..2ef24d7
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h
@@ -0,0 +1,194 @@
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ *                    2000 Wim Taymans <wim.taymans@chello.be>
+ *
+ * gstregistry.h: Header for registry handling
+ *
+ * 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.
+ */
+
+/* SUGGESTIONS AND TODO :
+** ====================
+** - Use a compressed registry, but would induce performance loss
+** - Encrypt the registry, for security purpose, but would also reduce performances
+** - Also have a non-mmap based cache reading (work with file descriptors)
+*/
+
+#ifndef __GST_REGISTRYBINARY_H__
+#define __GST_REGISTRYBINARY_H__
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <gst/gst_private.h>
+#include <gst/gstelement.h>
+#include <gst/gsttypefind.h>
+#include <gst/gsttypefindfactory.h>
+#include <gst/gsturi.h>
+#include <gst/gstinfo.h>
+#include <gst/gstenumtypes.h>
+#include <gst/gstregistry.h>
+#include <gst/gstpadtemplate.h>
+
+#include "glib-compat-private.h"
+#include <glib/gstdio.h>
+
+/* A magic, written at the beginning of the file */
+#define GST_MAGIC_BINARY_REGISTRY_STR "\xc0\xde\xf0\x0d"
+#define GST_MAGIC_BINARY_REGISTRY_LEN (4)
+#define GST_MAGIC_BINARY_VERSION_LEN (64)
+
+typedef struct _GstBinaryRegistryMagic
+{
+  char magic[GST_MAGIC_BINARY_REGISTRY_LEN];
+  char version[GST_MAGIC_BINARY_VERSION_LEN];
+} GstBinaryRegistryMagic;
+
+
+/* Used to store pointers to write */
+typedef struct _GstBinaryChunck
+{
+  void *data;
+  unsigned int size;
+} GstBinaryChunck;
+
+
+/* A structure containing (staticely) every information needed for a plugin
+**
+** Notes :
+** "nfeatures" is used to say how many GstBinaryPluginFeature structures we will have 
+** right after the structure itself.
+*/
+
+/* Various lenght defines for our GstBinaryPluginElement structure 
+** Note : We could eventually use smaller size
+*/
+#define GST_BINARY_REGISTRY_NAME_LEN (256)
+#define GST_BINARY_REGISTRY_DESCRIPTION_LEN (1024)
+#define GST_BINARY_REGISTRY_VERSION_LEN (64)
+#define GST_BINARY_REGISTRY_LICENSE_LEN (256)
+#define GST_BINARY_REGISTRY_SOURCE_LEN (256)
+#define GST_BINARY_REGISTRY_PACKAGE_LEN (1024)
+#define GST_BINARY_REGISTRY_ORIGIN_LEN (1024)
+
+typedef struct _GstBinaryPluginElement
+{
+  char name[GST_BINARY_REGISTRY_NAME_LEN];
+  char description[GST_BINARY_REGISTRY_DESCRIPTION_LEN];
+  char filename[_POSIX_PATH_MAX];
+  char version[GST_BINARY_REGISTRY_VERSION_LEN];
+  char license[GST_BINARY_REGISTRY_LICENSE_LEN];
+  char source[GST_BINARY_REGISTRY_SOURCE_LEN];
+  char package[GST_BINARY_REGISTRY_PACKAGE_LEN];
+  char origin[GST_BINARY_REGISTRY_ORIGIN_LEN];
+  unsigned long size;
+  unsigned long m32p;
+  unsigned int nfeatures;
+} GstBinaryPluginElement;
+
+
+/* A structure containing the plugin features
+**
+** Note :
+** "npadtemplates" is used to store the number of GstBinaryPadTemplate structures following the structure itself.
+** "ninterfaces" is used to store the number of GstBinaryInterface structures following the structure itself.
+** "nuritypes" is used to store the number of GstBinaryUriType structures following the structure itself.
+*/
+#define GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN (256)
+#define GST_BINARY_REGISTRY_TYPENAME_NAME_LEN (256)
+#define GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN (1024)
+#define GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN (512)
+#define GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN (1024)
+#define GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN (256)
+
+typedef struct _GstBinaryPluginFeature
+{
+  char typename[GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN];
+  char name[GST_BINARY_REGISTRY_TYPENAME_NAME_LEN];
+  unsigned long rank;
+  char longname[GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN];
+  char class[GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN];
+  char description[GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN];
+  char author[GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN];
+  unsigned int npadtemplates;
+  unsigned int ninterfaces;
+  unsigned int nuritypes;
+} GstBinaryPluginFeature;
+
+
+/* 
+** A structure containing the static pad templates of a plugin feature 
+*/
+#define GST_BINARY_REGISTRY_PADTEMPLATE_NAME_LEN (256)
+#define GST_BINARY_REGISTRY_PADTEMPLATE_CAP_LEN (1024)
+
+typedef struct _GstBinaryPadTemplate
+{
+  char name[GST_BINARY_REGISTRY_PADTEMPLATE_NAME_LEN];
+  char cap[GST_BINARY_REGISTRY_PADTEMPLATE_CAP_LEN];
+  int direction;					/* Either 0:"sink" or 1:"src" */
+  GstPadPresence presence;
+} GstBinaryPadTemplate;
+
+/*
+** A very simple structure defining the plugin feature interface string
+*/
+#define GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN (512)
+typedef struct _GstBinaryInterface
+{
+  char interface[GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN];
+  unsigned long size;
+} GstBinaryInterface;
+
+/* Uri Type */
+typedef struct _GstBinaryUriType
+{
+  GstURIType type;
+  unsigned long nuriprotocols;
+} GstBinaryUriType;
+
+/* 
+** Function prototypes
+*/
+
+/* Local prototypes */
+inline static gboolean gst_registry_binary_write(GstRegistry *registry, const void *mem, const ssize_t size);
+inline static gboolean gst_registry_binary_initialize_magic(GstBinaryRegistryMagic *m);
+static gboolean gst_registry_binary_fill_feature(GList **list, GstPluginFeature *, GstBinaryPluginFeature *, const char *);
+static gboolean gst_registry_binary_save_plugin(GList **list, GstRegistry *registry, GstPlugin *plugin);
+static gchar *gst_registry_binary_check_magic(gchar *in);
+static GstPluginFeature *gst_registry_binary_load_feature(GstBinaryPluginFeature *);
+static unsigned long gst_registry_binary_get_binary_plugin(GstRegistry *registry, gchar *in);
+
+/* Exportable */
+gboolean gst_registry_binary_write_cache(GstRegistry *registry, const char *location);
+gboolean gst_registry_binary_read_cache(GstRegistry *registry, const char *location);
+
+#endif /* !__GST_REGISTRYBINARY_H__ */
+
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb
new file mode 100644
index 0000000..5b30603
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb
@@ -0,0 +1,51 @@
+SUMMARY = "GStreamer multimedia framework"
+DESCRIPTION = "GStreamer is a multimedia framework for encoding and decoding video and sound. \
+It supports a wide range of formats including mp3, ogg, avi, mpeg and quicktime."
+HOMEPAGE = "http://gstreamer.freedesktop.org/"
+BUGTRACKER = "https://bugzilla.gnome.org/enter_bug.cgi?product=Gstreamer"
+SECTION = "multimedia"
+LICENSE = "LGPLv2+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605 \
+                    file://gst/gst.h;beginline=1;endline=21;md5=8e5fe5e87d33a04479fde862e238eaa4"
+DEPENDS = "glib-2.0 libxml2 bison-native flex-native"
+
+PR = "r2"
+
+SRC_URI = "http://gstreamer.freedesktop.org/src/gstreamer/gstreamer-${PV}.tar.bz2 \
+           file://check_fix.patch \
+           file://gst-inspect-check-error.patch \
+           file://0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch \
+           file://gstreamer-change-priv_gst_parse_yylex-arguments.patch \
+"
+
+SRC_URI[md5sum] = "a0cf7d6877f694a1a2ad2b4d1ecb890b"
+SRC_URI[sha256sum] = "e556a529e0a8cf1cd0afd0cab2af5488c9524e7c3f409de29b5d82bb41ae7a30"
+
+inherit autotools pkgconfig gettext
+
+GSTREAMER_DEBUG ?= "--disable-debug"
+EXTRA_OECONF = "--disable-docbook --disable-gtk-doc \
+            --disable-dependency-tracking --disable-check \
+            --disable-examples --disable-tests \
+            --disable-valgrind ${GSTREAMER_DEBUG} \
+            "
+
+CACHED_CONFIGUREVARS += "ac_cv_header_valgrind_valgrind_h=no"
+
+# apply gstreamer hack after Makefile.in.in in source is replaced by our version from
+# ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in, but before configure is executed
+# http://lists.linuxtogo.org/pipermail/openembedded-core/2012-November/032233.html
+oe_runconf_prepend() {
+        sed -i -e "1a\\" -e 'GETTEXT_PACKAGE = @GETTEXT_PACKAGE@' ${S}/po/Makefile.in.in
+}
+
+#do_compile_prepend () {
+#	mv ${WORKDIR}/gstregistrybinary.[ch] ${S}/gst/
+#}
+
+RRECOMMENDS_${PN}_qemux86    += "kernel-module-snd-ens1370 kernel-module-snd-rawmidi"
+RRECOMMENDS_${PN}_qemux86-64 += "kernel-module-snd-ens1370 kernel-module-snd-rawmidi"
+
+FILES_${PN} += " ${libdir}/gstreamer-0.10/*.so"
+FILES_${PN}-dev += " ${libdir}/gstreamer-0.10/*.la ${libdir}/gstreamer-0.10/*.a"
+FILES_${PN}-dbg += " ${libdir}/gstreamer-0.10/.debug/ ${libexecdir}/gstreamer-0.10/.debug/"
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 4/4] Rename gstreamer directory to gstreamer-0.10
  2015-05-18 14:12 [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core Alexander Kanavin
                   ` (2 preceding siblings ...)
  2015-05-18 14:12 ` [PATCH 3/4] recipes-multimedia: add gstreamer-0.10 recipes Alexander Kanavin
@ 2015-05-18 14:12 ` Alexander Kanavin
  2015-05-18 14:16   ` Carlos Rafael Giani
  2015-05-21 11:06 ` [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core Martin Jansa
  4 siblings, 1 reply; 20+ messages in thread
From: Alexander Kanavin @ 2015-05-18 14:12 UTC (permalink / raw)
  To: openembedded-devel

So that it's clear that the recipes it contains are specific to the
obsolete, unmaintained version of gstreamer.

Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com>
---
 .../0001-aacdec-check-channel-count.patch          |   34 +
 .../0001-alac-fix-nb_samples-order-case.patch      |   30 +
 .../0001-alsdec-check-block-length.patch           |   61 +
 ...ac3dec-Check-coding-mode-against-channels.patch |   37 +
 ...util-fix-signedness-in-sizeof-comparissio.patch |   40 +
 ...le-use-av_image_get_linesize-to-calculate.patch |   50 +
 ...c-parser-reset-indexes-on-realloc-failure.patch |   50 +
 ...a-Perform-pointer-advance-and-checks-befo.patch |   81 +
 .../0001-avcodec-smc-fix-off-by-1-error.patch      |   32 +
 ...egtsenc-Check-data-array-size-in-mpegts_w.patch |   69 +
 .../0001-eamad-fix-out-of-array-accesses.patch     |   29 +
 ...-error-concealment-initialize-block-index.patch |   29 +
 ...alment-Check-that-the-picture-is-not-in-a.patch |   37 +
 .../0001-ffserver-set-oformat.patch                |   36 +
 ...t-ref-count-check-and-limit-fix-out-of-ar.patch |   29 +
 ...t-parameters-from-SPS-whenever-it-changes.patch |  145 +
 ...rror-concealment-when-SPS-and-slices-are-.patch |   33 +
 .../0001-h264_sei-Fix-infinite-loop.patch          |   39 +
 ...01-huffyuvdec-Check-init_vlc-return-codes.patch |   87 +
 .../0001-huffyuvdec-Skip-len-0-cases.patch         |   61 +
 ...f-compute-probe-buffer-size-more-reliably.patch |   45 +
 .../0001-mjpegdec-check-SE.patch                   |   32 +
 ...heck-RLE-size-before-copying.-Fix-out-of-.patch |   34 +
 ...er-dont-access-out-of-array-elements-at-t.patch |   44 +
 ...array-index-before-use-fix-out-of-array-a.patch |   30 +
 .../0001-qdm2dec-fix-buffer-overflow.patch         |   58 +
 ...001-roqvideodec-check-dimensions-validity.patch |   36 +
 ...Check-that-the-last-indexes-are-within-th.patch |   32 +
 ...-vp3-Copy-all-3-frames-for-thread-updates.patch |   32 +
 ...-read-for-negative-tokens-and-memleaks-on.patch |  183 +
 ...o-check-chunk-sizes-before-reading-chunks.patch |   51 +
 ...egdec-check-bits-per-pixel-for-changes-si.patch |   68 +
 .../gst-ffmpeg-0.10.13/configure-fix.patch         |   22 +
 .../gst-ffmpeg-CVE-2013-0855.patch                 |  100 +
 .../gst-ffmpeg-CVE-2013-3674.patch                 |   26 +
 .../gst-ffmpeg-0.10.13/h264_qpel_mmx.patch         |   57 +
 .../gst-ffmpeg-0.10.13/libav-9.patch               | 9304 ++++++++++++++++++++
 .../gst-ffmpeg-0.10.13/libav_e500mc.patch          |   21 +
 .../gst-ffmpeg-0.10.13/libav_e5500.patch           |   19 +
 .../gst-ffmpeg-0.10.13/lower-rank.diff             |   16 +
 .../gstreamer-0.10/gst-ffmpeg_0.10.13.bb           |   90 +
 .../gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb      |   14 +
 .../gst-fluendo-mpegdemux_0.10.85.bb               |   12 +
 .../gstreamer-0.10/gst-fluendo.inc                 |   14 +
 .../gstreamer-0.10/gst-meta-base_0.10.bb           |   73 +
 .../gstreamer-0.10/gst-openmax/gcc_4.6.patch       |   18 +
 .../gstreamer-0.10/gst-openmax/ptr-array.patch     |   46 +
 .../gstreamer-0.10/gst-openmax_0.10.1.bb           |   35 +
 .../gstreamer-0.10/gst-plugins-bad_0.10.23.bb      |   50 +
 ...le-Fix-build-on-x86-if-emmintrin.h-is-ava.patch |   37 +
 .../configure.ac-fix-subparse-plugin.patch         |   27 +
 .../gst-plugins-base-tremor.patch                  |   20 +
 .../gstreamer-0.10/gst-plugins-base_0.10.36.bb     |   39 +
 ...-conditional-gl-framebuffer-undefined-use.patch |   35 +
 .../gstreamer-0.10/gst-plugins-gl_0.10.3.bb        |   25 +
 ...ild-with-recent-kernels-the-v4l2_buffer-i.patch |   33 +
 ...define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch |   45 +
 .../0407-mulawdec-fix-integer-overrun.patch        |   47 +
 .../gstreamer-0.10/gst-plugins-good_0.10.31.bb     |   47 +
 .../gstreamer-0.10/gst-plugins-ugly_0.10.19.bb     |   29 +
 .../gstreamer-0.10/gst-plugins.inc                 |   28 +
 ...ecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch |   34 +
 .../gstreamer-0.10/gst-rtsp_0.10.8.bb              |   16 +
 ...ix-self-comparison-always-evaluates-to-tr.patch |   32 +
 .../gstreamer-0.10.36/check_fix.patch              |   19 +
 .../gst-inspect-check-error.patch                  |   16 +
 ...mer-change-priv_gst_parse_yylex-arguments.patch |   33 +
 .../gstreamer-0.10.36/gstregistrybinary.c          |  487 +
 .../gstreamer-0.10.36/gstregistrybinary.h          |  194 +
 .../gstreamer-0.10/gstreamer_0.10.36.bb            |   51 +
 .../gstreamer-0.10/python-gst/python-path.patch    |   28 +
 .../gstreamer-0.10/python-gst_0.10.22.bb           |   29 +
 .../0001-aacdec-check-channel-count.patch          |   34 -
 .../0001-alac-fix-nb_samples-order-case.patch      |   30 -
 .../0001-alsdec-check-block-length.patch           |   61 -
 ...ac3dec-Check-coding-mode-against-channels.patch |   37 -
 ...util-fix-signedness-in-sizeof-comparissio.patch |   40 -
 ...le-use-av_image_get_linesize-to-calculate.patch |   50 -
 ...c-parser-reset-indexes-on-realloc-failure.patch |   50 -
 ...a-Perform-pointer-advance-and-checks-befo.patch |   81 -
 .../0001-avcodec-smc-fix-off-by-1-error.patch      |   32 -
 ...egtsenc-Check-data-array-size-in-mpegts_w.patch |   69 -
 .../0001-eamad-fix-out-of-array-accesses.patch     |   29 -
 ...-error-concealment-initialize-block-index.patch |   29 -
 ...alment-Check-that-the-picture-is-not-in-a.patch |   37 -
 .../0001-ffserver-set-oformat.patch                |   36 -
 ...t-ref-count-check-and-limit-fix-out-of-ar.patch |   29 -
 ...t-parameters-from-SPS-whenever-it-changes.patch |  145 -
 ...rror-concealment-when-SPS-and-slices-are-.patch |   33 -
 .../0001-h264_sei-Fix-infinite-loop.patch          |   39 -
 ...01-huffyuvdec-Check-init_vlc-return-codes.patch |   87 -
 .../0001-huffyuvdec-Skip-len-0-cases.patch         |   61 -
 ...f-compute-probe-buffer-size-more-reliably.patch |   45 -
 .../0001-mjpegdec-check-SE.patch                   |   32 -
 ...heck-RLE-size-before-copying.-Fix-out-of-.patch |   34 -
 ...er-dont-access-out-of-array-elements-at-t.patch |   44 -
 ...array-index-before-use-fix-out-of-array-a.patch |   30 -
 .../0001-qdm2dec-fix-buffer-overflow.patch         |   58 -
 ...001-roqvideodec-check-dimensions-validity.patch |   36 -
 ...Check-that-the-last-indexes-are-within-th.patch |   32 -
 ...-vp3-Copy-all-3-frames-for-thread-updates.patch |   32 -
 ...-read-for-negative-tokens-and-memleaks-on.patch |  183 -
 ...o-check-chunk-sizes-before-reading-chunks.patch |   51 -
 ...egdec-check-bits-per-pixel-for-changes-si.patch |   68 -
 .../gst-ffmpeg-0.10.13/configure-fix.patch         |   22 -
 .../gst-ffmpeg-CVE-2013-0855.patch                 |  100 -
 .../gst-ffmpeg-CVE-2013-3674.patch                 |   26 -
 .../gst-ffmpeg-0.10.13/h264_qpel_mmx.patch         |   57 -
 .../gstreamer/gst-ffmpeg-0.10.13/libav-9.patch     | 9304 --------------------
 .../gst-ffmpeg-0.10.13/libav_e500mc.patch          |   21 -
 .../gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch |   19 -
 .../gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff   |   16 -
 .../gstreamer/gst-ffmpeg_0.10.13.bb                |   90 -
 .../gstreamer/gst-fluendo-mp3_0.10.31.bb           |   14 -
 .../gstreamer/gst-fluendo-mpegdemux_0.10.85.bb     |   12 -
 .../recipes-multimedia/gstreamer/gst-fluendo.inc   |   14 -
 .../gstreamer/gst-meta-base_0.10.bb                |   73 -
 .../gstreamer/gst-openmax/gcc_4.6.patch            |   18 -
 .../gstreamer/gst-openmax/ptr-array.patch          |   46 -
 .../gstreamer/gst-openmax_0.10.1.bb                |   35 -
 .../gstreamer/gst-plugins-bad_0.10.23.bb           |   50 -
 ...le-Fix-build-on-x86-if-emmintrin.h-is-ava.patch |   37 -
 .../configure.ac-fix-subparse-plugin.patch         |   27 -
 .../gst-plugins-base-tremor.patch                  |   20 -
 .../gstreamer/gst-plugins-base_0.10.36.bb          |   39 -
 ...-conditional-gl-framebuffer-undefined-use.patch |   35 -
 .../gstreamer/gst-plugins-gl_0.10.3.bb             |   25 -
 ...ild-with-recent-kernels-the-v4l2_buffer-i.patch |   33 -
 ...define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch |   45 -
 .../0407-mulawdec-fix-integer-overrun.patch        |   47 -
 .../gstreamer/gst-plugins-good_0.10.31.bb          |   47 -
 .../gstreamer/gst-plugins-ugly_0.10.19.bb          |   29 -
 .../recipes-multimedia/gstreamer/gst-plugins.inc   |   28 -
 ...ecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch |   34 -
 .../gstreamer/gst-rtsp_0.10.8.bb                   |   16 -
 ...ix-self-comparison-always-evaluates-to-tr.patch |   32 -
 .../gstreamer/gstreamer-0.10.36/check_fix.patch    |   19 -
 .../gst-inspect-check-error.patch                  |   16 -
 ...mer-change-priv_gst_parse_yylex-arguments.patch |   33 -
 .../gstreamer-0.10.36/gstregistrybinary.c          |  487 -
 .../gstreamer-0.10.36/gstregistrybinary.h          |  194 -
 .../gstreamer/gstreamer_0.10.36.bb                 |   51 -
 .../gstreamer/python-gst/python-path.patch         |   28 -
 .../gstreamer/python-gst_0.10.22.bb                |   29 -
 144 files changed, 12922 insertions(+), 12922 deletions(-)
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/configure-fix.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav-9.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e500mc.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e5500.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/lower-rank.diff
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg_0.10.13.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mpegdemux_0.10.85.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo.inc
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-meta-base_0.10.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/gcc_4.6.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/ptr-array.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax_0.10.1.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-bad_0.10.23.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base_0.10.36.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl_0.10.3.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good_0.10.31.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-ugly_0.10.19.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins.inc
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp_0.10.8.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/check_fix.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gst-inspect-check-error.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.c
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.h
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer_0.10.36.bb
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst/python-path.patch
 create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst_0.10.22.bb
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.31.bb
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.85.bb
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo.inc
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp_0.10.8.bb
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/python-gst/python-path.patch
 delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/python-gst_0.10.22.bb

diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
new file mode 100644
index 0000000..7da0e14
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
@@ -0,0 +1,34 @@
+gst-ffmpeg: aacdec: check channel count
+
+Prevent out of array accesses
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 96f452ac647dae33c53c242ef3266b65a9beafb6)
+
+Upstream-Status: Backport 
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+---
+ libavcodec/aacdec.c |    5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
+index 239153a..6c17c33 100644
+--- a/gst-libs/ext/libav/libavcodec/aacdec.c
++++ b/gst-libs/ext/libav/libavcodec/aacdec.c
+@@ -914,6 +914,11 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
+         }
+     }
+ 
++    if (avctx->channels > MAX_CHANNELS) {
++        av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
++        return AVERROR_INVALIDDATA;
++    }
++
+     AAC_INIT_VLC_STATIC( 0, 304);
+     AAC_INIT_VLC_STATIC( 1, 270);
+     AAC_INIT_VLC_STATIC( 2, 550);
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
new file mode 100644
index 0000000..10ce0f3
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
@@ -0,0 +1,30 @@
+From e0884eadf6a15e93142131b695f48776f9a0ac31 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Sat, 10 Nov 2012 17:14:04 +0100
+Subject: [PATCH] alac: fix nb_samples < order case
+
+Upstream-Status: Backport
+
+Commit e0884eadf6a15e93142131b695f48776f9a0ac31 release/1.0
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit fd4f4923cce6a2cbf4f48640b4ac706e614a1594)
+---
+ libavcodec/alac.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libavcodec/alac.c b/libavcodec/alac.c
+index 9cd1737..e8e844a 100644
+--- a/gst-libs/ext/libav/libavcodec/alac.c
++++ b/gst-libs/ext/libav/libavcodec/alac.c
+@@ -278,7 +278,7 @@ static void predictor_decompress_fir_ada
+ 
+     /* read warm-up samples */
+     if (predictor_coef_num > 0)
+-        for (i = 0; i < predictor_coef_num; i++) {
++        for (i = 0; i < predictor_coef_num && i < output_size; i++) {
+             int32_t val;
+ 
+             val = buffer_out[i] + error_buffer[i+1];
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
new file mode 100644
index 0000000..73980f4
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
@@ -0,0 +1,61 @@
+From 6df0d3e2916c223dbe4262bf1b876dff1cb3f980 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Wed, 12 Dec 2012 12:28:45 +0100
+Subject: [PATCH] alsdec: check block length
+
+Upstream-Status: Backport
+
+Commit 6df0d3e2916c223dbe4262bf1b876dff1cb3f980 release/1.0
+
+Fix writing over the end
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 0ceca269b66ec12a23bf0907bd2c220513cdbf16)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/alsdec.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
+index 46dd0b4..1095b01 100644
+--- a/gst-libs/ext/libav/libavcodec/alsdec.c
++++ b/gst-libs/ext/libav/libavcodec/alsdec.c
+@@ -552,12 +552,15 @@ static void get_block_sizes(ALSDecContext *ctx, unsigned int *div_blocks,
+ 
+ /** Read the block data for a constant block
+  */
+-static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
++static int read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
+ {
+     ALSSpecificConfig *sconf = &ctx->sconf;
+     AVCodecContext *avctx    = ctx->avctx;
+     GetBitContext *gb        = &ctx->gb;
+ 
++    if (bd->block_length <= 0)
++        return -1;
++
+     *bd->raw_samples = 0;
+     *bd->const_block = get_bits1(gb);    // 1 = constant value, 0 = zero block (silence)
+     bd->js_blocks    = get_bits1(gb);
+@@ -572,6 +575,8 @@ static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
+ 
+     // ensure constant block decoding by reusing this field
+     *bd->const_block = 1;
++
++    return 0;
+ }
+ 
+ 
+@@ -971,7 +976,8 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
+         if (read_var_block_data(ctx, bd))
+             return -1;
+     } else {
+-        read_const_block_data(ctx, bd);
++        if (read_const_block_data(ctx, bd) < 0)
++            return -1;
+     }
+ 
+     return 0;
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
new file mode 100644
index 0000000..42cb5f4
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
@@ -0,0 +1,37 @@
+From 2502914c5f8eb77659d7c0868396862557a63245 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Fri, 9 Nov 2012 13:26:20 +0100
+Subject: [PATCH] atrac3dec: Check coding mode against channels.
+
+Upstream-Status: Backport
+
+Commit 2502914c5f8eb77659d7c0868396862557a63245 release/1.0
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 13451f5520ce6b0afde861b2285dda659f8d4fb4)
+
+Conflicts:
+
+	libavcodec/atrac3.c
+---
+ libavcodec/atrac3.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
+index 7d076be..1da4c78 100644
+--- a/gst-libs/ext/libav/libavcodec/atrac3.c
++++ b/gst-libs/ext/libav/libavcodec/atrac3.c
+@@ -955,6 +955,11 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
+     }
+     /* Check the extradata. */
+ 
++    if (q->codingMode == JOINT_STEREO && avctx->channels < 2) {
++        av_log(avctx, AV_LOG_ERROR, "Invalid coding mode\n");
++        return AVERROR_INVALIDDATA;
++    }
++
+     if (q->atrac3version != 4) {
+         av_log(avctx,AV_LOG_ERROR,"Version %d != 4.\n",q->atrac3version);
+         return AVERROR_INVALIDDATA;
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
new file mode 100644
index 0000000..31fa51a
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
@@ -0,0 +1,40 @@
+From a99aff4e4bbef8e64b51f267cd1769214e1b4e80 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Fri, 30 Aug 2013 23:40:47 +0200
+Subject: [PATCH] avcodec/dsputil: fix signedness in sizeof() comparissions
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 454a11a1c9c686c78aa97954306fb63453299760)
+
+Upstream-Status: Backport
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/dsputil.c |    4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
+index 53dc2eb..6264832 100644
+--- a/gst-libs/ext/libav/libavcodec/dsputil.c
++++ b/gst-libs/ext/libav/libavcodec/dsputil.c
+@@ -1912,7 +1912,7 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
+ 
+ static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
+     long i;
+-    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
++    for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
+         long a = *(long*)(src+i);
+         long b = *(long*)(dst+i);
+         *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
+@@ -1937,7 +1937,7 @@ static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
+         }
+     }else
+ #endif
+-    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
++    for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
+         long a = *(long*)(src1+i);
+         long b = *(long*)(src2+i);
+         *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
new file mode 100644
index 0000000..b0a3fb1
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
@@ -0,0 +1,50 @@
+From 573d5fdedae72bf59d8c0b0766fdee171063d36f Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Sun, 16 Feb 2014 23:08:52 +0100
+Subject: [PATCH] avcodec/msrle: use av_image_get_linesize() to calculate the
+ linesize
+
+Upstream-Status: Backport
+
+Commit 573d5fdedae72bf59d8c0b0766fdee171063d36f release/0.9
+
+Fixes out of array access
+Fixes: 14a74a0a2dc67ede543f0e35d834fbbe-asan_heap-oob_49572c_556_cov_215466444_44_001_engine_room.mov
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit c919e1ca2ecfc47d796382973ba0e48b8f6f92a2)
+
+Conflicts:
+
+	libavcodec/msrle.c
+(cherry picked from commit bc1c8ec5e65098fd2ccd8456f667151dfc9cda42)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/msrle.c |    3 ++-
+ 1 files changed, 2 insertions(+), 1 deletions(-)
+
+diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c
+index 30159bb..c39ae7b 100644
+--- a/gst-libs/ext/libav/libavcodec/msrle.c
++++ b/gst-libs/ext/libav/libavcodec/msrle.c
+@@ -35,6 +35,7 @@
+ #include "avcodec.h"
+ #include "dsputil.h"
+ #include "msrledec.h"
++#include "libavutil/imgutils.h"
+ 
+ typedef struct MsrleContext {
+     AVCodecContext *avctx;
+@@ -107,7 +108,7 @@ static int msrle_decode_frame(AVCodecContext *avctx,
+ 
+     /* FIXME how to correctly detect RLE ??? */
+     if (avctx->height * istride == avpkt->size) { /* assume uncompressed */
+-        int linesize = avctx->width * avctx->bits_per_coded_sample / 8;
++        int linesize = av_image_get_linesize(avctx->pix_fmt, avctx->width, 0);
+         uint8_t *ptr = s->frame.data[0];
+         uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
+         int i, j;
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
new file mode 100644
index 0000000..5ff6583
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
@@ -0,0 +1,50 @@
+gst-ffmpeg: avcodec/parser: reset indexes on realloc failure
+
+Fixes Ticket2982
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit f31011e9abfb2ae75bb32bc44e2c34194c8dc40a)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+
+Upstream-Status: Backport 
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+
+---
+ libavcodec/parser.c |   10 +++++++---
+ 1 files changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/parser.c b/libavcodec/parser.c
+index 2c6de6e..66eca06 100644
+--- a/gst-libs/ext/libav/libavcodec/parser.c
++++ b/gst-libs/ext/libav/libavcodec/parser.c
+@@ -241,8 +241,10 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
+     if(next == END_NOT_FOUND){
+         void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
+ 
+-        if(!new_buffer)
++        if(!new_buffer) {
++            pc->index = 0;
+             return AVERROR(ENOMEM);
++        }
+         pc->buffer = new_buffer;
+         memcpy(&pc->buffer[pc->index], *buf, *buf_size);
+         pc->index += *buf_size;
+@@ -255,9 +257,11 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
+     /* append to buffer */
+     if(pc->index){
+         void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
+-
+-        if(!new_buffer)
++        if(!new_buffer) {
++            pc->overread_index =
++            pc->index = 0;
+             return AVERROR(ENOMEM);
++        }
+         pc->buffer = new_buffer;
+         if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
+             memcpy(&pc->buffer[pc->index], *buf,
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
new file mode 100644
index 0000000..7f6eb48
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
@@ -0,0 +1,81 @@
+gst-ffmpeg: avcodec/rpza: Perform pointer advance and checks before
+ using the pointers
+
+Fixes out of array accesses
+Fixes Ticket2850
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 3819db745da2ac7fb3faacb116788c32f4753f34)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+
+Upstream-Status: Backport 
+
+Singed-off-by: Yue Tao <yue.tao@windriver.com>
+
+---
+ libavcodec/rpza.c |    8 ++++----
+ 1 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c
+index 635b406..f291a95 100644
+--- a/gst-libs/ext/libav/libavcodec/rpza.c
++++ b/gst-libs/ext/libav/libavcodec/rpza.c
+@@ -83,7 +83,7 @@ static void rpza_decode_stream(RpzaContext *s)
+     unsigned short *pixels = (unsigned short *)s->frame.data[0];
+ 
+     int row_ptr = 0;
+-    int pixel_ptr = 0;
++    int pixel_ptr = -4;
+     int block_ptr;
+     int pixel_x, pixel_y;
+     int total_blocks;
+@@ -139,6 +139,7 @@ static void rpza_decode_stream(RpzaContext *s)
+             colorA = AV_RB16 (&s->buf[stream_ptr]);
+             stream_ptr += 2;
+             while (n_blocks--) {
++                ADVANCE_BLOCK()
+                 block_ptr = row_ptr + pixel_ptr;
+                 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+                     for (pixel_x = 0; pixel_x < 4; pixel_x++){
+@@ -147,7 +148,6 @@ static void rpza_decode_stream(RpzaContext *s)
+                     }
+                     block_ptr += row_inc;
+                 }
+-                ADVANCE_BLOCK();
+             }
+             break;
+ 
+@@ -184,6 +184,7 @@ static void rpza_decode_stream(RpzaContext *s)
+             color4[2] |= ((21 * ta + 11 * tb) >> 5);
+ 
+             while (n_blocks--) {
++                ADVANCE_BLOCK();
+                 block_ptr = row_ptr + pixel_ptr;
+                 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+                     index = s->buf[stream_ptr++];
+@@ -194,12 +195,12 @@ static void rpza_decode_stream(RpzaContext *s)
+                     }
+                     block_ptr += row_inc;
+                 }
+-                ADVANCE_BLOCK();
+             }
+             break;
+ 
+         /* Fill block with 16 colors */
+         case 0x00:
++            ADVANCE_BLOCK();
+             block_ptr = row_ptr + pixel_ptr;
+             for (pixel_y = 0; pixel_y < 4; pixel_y++) {
+                 for (pixel_x = 0; pixel_x < 4; pixel_x++){
+@@ -213,7 +214,6 @@ static void rpza_decode_stream(RpzaContext *s)
+                 }
+                 block_ptr += row_inc;
+             }
+-            ADVANCE_BLOCK();
+             break;
+ 
+         /* Unknown opcode */
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
new file mode 100644
index 0000000..3ca6fc4
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
@@ -0,0 +1,32 @@
+From c17a0ad1df15a94d0b1239adc2afb593bdf0a153 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Fri, 3 Oct 2014 22:50:45 +0200
+Subject: [PATCH 1/2] avcodec/smc: fix off by 1 error
+
+Upstream-Status: Backport
+
+Fixes out of array access
+Fixes: asan_heap-oob_1685bf0_5_asan_heap-oob_1f35116_430_smc.mov
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/smc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/gst-libs/ext/libav/libavcodec/smc.c b/gst-libs/ext/libav/libavcodec/smc.c
+index 3cd5e53..dec9f71 100644
+--- a/gst-libs/ext/libav/libavcodec/smc.c
++++ b/gst-libs/ext/libav/libavcodec/smc.c
+@@ -69,7 +69,7 @@ typedef struct SmcContext {
+         row_ptr += stride * 4; \
+     } \
+     total_blocks--; \
+-    if (total_blocks < 0) \
++    if (total_blocks < 0 + !!n_blocks) \
+     { \
+         av_log(s->avctx, AV_LOG_INFO, "warning: block counter just went negative (this should not happen)\n"); \
+         return; \
+-- 
+2.1.0
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
new file mode 100644
index 0000000..68bb66e
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
@@ -0,0 +1,69 @@
+From 12770701856a05b6b3cd706f708f8e9a4e8a1336 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Thu, 13 Feb 2014 13:59:51 +0100
+Subject: [PATCH] avformat/mpegtsenc: Check data array size in
+ mpegts_write_pmt()
+
+Upstream-Status: Backport
+
+COmmit 12770701856a05b6b3cd706f708f8e9a4e8a1336 release/0.11
+
+Prevents out of array writes
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 842b6c14bcfc1c5da1a2d288fd65386eb8c158ad)
+
+Conflicts:
+
+	libavformat/mpegtsenc.c
+(cherry picked from commit e87de3f50b765134588d0b048c32ed4b8acc16fb)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavformat/mpegtsenc.c |    9 +++++++--
+ 1 files changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
+index 793e205..a12d19f 100644
+--- a/gst-libs/ext/libav/libavformat/mpegtsenc.c
++++ b/gst-libs/ext/libav/libavformat/mpegtsenc.c
+@@ -240,7 +240,7 @@ static void mpegts_write_pat(AVFormatContext *s)
+                           data, q - data);
+ }
+ 
+-static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
++static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
+ {
+     //    MpegTSWrite *ts = s->priv_data;
+     uint8_t data[1012], *q, *desc_length_ptr, *program_info_length_ptr;
+@@ -293,6 +293,10 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
+             stream_type = STREAM_TYPE_PRIVATE_DATA;
+             break;
+         }
++
++        if (q - data > sizeof(data) - 32)
++            return AVERROR(EINVAL);
++
+         *q++ = stream_type;
+         put16(&q, 0xe000 | ts_st->pid);
+         desc_length_ptr = q;
+@@ -324,7 +328,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
+                 len_ptr = q++;
+                 *len_ptr = 0;
+ 
+-                for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next + 1) {
++                for (p = lang->value; next && *len_ptr < 255 / 4 * 4 && q - data < sizeof(data) - 4; p = next + 1) {
+                     next = strchr(p, ',');
+                     if (strlen(p) != 3 && (!next || next != p + 3))
+                         continue; /* not a 3-letter code */
+@@ -386,6 +390,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
+     }
+     mpegts_write_section1(&service->pmt, PMT_TID, service->sid, 0, 0, 0,
+                           data, q - data);
++    return 0;
+ }
+ 
+ /* NOTE: str == NULL is accepted for an empty string */
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
new file mode 100644
index 0000000..f45e3fd
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
@@ -0,0 +1,29 @@
+From 63ac64864c6e0e84355aa3caa5b92208997a9a8d Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Sat, 17 Nov 2012 16:26:55 +0100
+Subject: [PATCH] eamad: fix out of array accesses
+
+Upstream-Status: Backport
+
+Commit 63ac64864c6e0e84355aa3caa5b92208997a9a8d release/1.1
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/eamad.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c
+index 2805195..e38650e 100644
+--- a/gst-libs/ext/libav/libavcodec/eamad.c
++++ b/gst-libs/ext/libav/libavcodec/eamad.c
+@@ -237,7 +237,7 @@ static int decode_frame(AVCodecContext *avctx,
+     int chunk_type;
+     int inter;
+ 
+-    if (buf_size < 17) {
++    if (buf_size < 26) {
+         av_log(avctx, AV_LOG_ERROR, "Input buffer too small\n");
+         *data_size = 0;
+         return -1;
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
new file mode 100644
index 0000000..e0e4239
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
@@ -0,0 +1,29 @@
+gst-ffmpeg: error concealment: initialize block index.
+
+Fixes CVE-2011-3941 (out of bounds write)
+
+Upstream-Status: Backport 
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/error_resilience.c |    3 +++
+ 1 files changed, 3 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
+index 8bb5d0c..d55c000 100644
+--- a/gst-libs/ext/libav/libavcodec/error_resilience.c
++++ b/gst-libs/ext/libav/libavcodec/error_resilience.c
+@@ -45,6 +45,9 @@ static void decode_mb(MpegEncContext *s, int ref){
+     s->dest[1] = s->current_picture.data[1] + (s->mb_y * (16>>s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16>>s->chroma_x_shift);
+     s->dest[2] = s->current_picture.data[2] + (s->mb_y * (16>>s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16>>s->chroma_x_shift);
+ 
++    ff_init_block_index(s);
++    ff_update_block_index(s);
++
+     if(CONFIG_H264_DECODER && s->codec_id == CODEC_ID_H264){
+         H264Context *h= (void*)s;
+         h->mb_xy= s->mb_x + s->mb_y*s->mb_stride;
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
new file mode 100644
index 0000000..8eef6e9
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
@@ -0,0 +1,37 @@
+gst-ffmpeg: error_concealment: Check that the picture is not in a half
+
+Fixes state becoming inconsistent
+Fixes a null pointer dereference
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 23318a57358358e7a4dc551e830e4503f0638cfe)
+
+Upstream-Status: Backport 
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+
+---
+ libavcodec/error_resilience.c |    6 ++++++
+ 1 files changed, 6 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
+index 01f7424..2b6bc42 100644
+--- a/gst-libs/ext/libav/libavcodec/error_resilience.c
++++ b/gst-libs/ext/libav/libavcodec/error_resilience.c
+@@ -793,6 +793,12 @@ void ff_er_frame_end(MpegEncContext *s){
+        s->picture_structure != PICT_FRAME || // we dont support ER of field pictures yet, though it should not crash if enabled
+        s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return;
+ 
++    if (   s->picture_structure == PICT_FRAME
++        && s->current_picture.linesize[0] != s->current_picture_ptr->linesize[0]) {
++        av_log(s->avctx, AV_LOG_ERROR, "Error concealment not possible, frame not fully initialized\n");
++        return;
++    }
++
+     if(s->current_picture.motion_val[0] == NULL){
+         av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
+ 
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
new file mode 100644
index 0000000..80325db
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
@@ -0,0 +1,36 @@
+gst-ffmpeg: ffserver: set oformat
+
+Fix Ticket1986
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit cbe43e62c9ac7d4aefdc13476f6f691bd626525f)
+
+Upstream-Status: Backport 
+
+---
+ ffserver.c |    4 +++-
+ 1 files changed, 3 insertions(+), 1 deletions(-)
+
+diff --git a/ffserver.c b/ffserver.c
+index 4044d0f..8740140 100644
+--- a/gst-libs/ext/libav/ffserver.c
++++ b/gst-libs/ext/libav/ffserver.c
+@@ -2937,12 +2937,14 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
+ {
+     AVFormatContext *avc;
+     AVStream *avs = NULL;
++    AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
+     int i;
+ 
+     avc =  avformat_alloc_context();
+-    if (avc == NULL) {
++    if (avc == NULL || !rtp_format) {
+         return -1;
+     }
++    avc->oformat = rtp_format;
+     av_dict_set(&avc->metadata, "title",
+                stream->title[0] ? stream->title : "No Title", 0);
+     avc->nb_streams = stream->nb_streams;
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
new file mode 100644
index 0000000..d4f55b2
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
@@ -0,0 +1,29 @@
+From d6c184880ee2e09fd68c0ae217173832cee5afc1 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Sun, 18 Nov 2012 16:29:04 +0100
+Subject: [PATCH] h264: correct ref count check and limit, fix out of array
+ accesses.
+
+Upstream-Status: Backport
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/h264.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libavcodec/h264.c b/libavcodec/h264.c
+index da43f1e..32cede5 100644
+--- a/gst-libs/ext/libav/libavcodec/h264.c
++++ b/gst-libs/ext/libav/libavcodec/h264.c
+@@ -2870,6 +2870,9 @@ static int decode_slice_header(H264Conte
+             h->ref_count[0]= get_ue_golomb(&s->gb) + 1;
+             if(h->slice_type_nos==AV_PICTURE_TYPE_B)
+                 h->ref_count[1]= get_ue_golomb(&s->gb) + 1;
++            else
++                // full range is spec-ok in this case, even for frames
++                h->ref_count[1] = 1;
+ 
+             if(h->ref_count[0]-1 > 32-1 || h->ref_count[1]-1 > 32-1){
+                 av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
new file mode 100644
index 0000000..05a9de3
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
@@ -0,0 +1,145 @@
+gst-ffmpeg: h264: set parameters from SPS whenever it changes
+    
+Fixes a crash in the fuzzed sample sample_varPAR.avi_s26638 with
+alternating bit depths.
+
+Upstream-Status: Backport
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+
+diff --git a/gst-libs/ext/libav/libavcodec/h264.c.old b/gst-libs/ext/libav/libavcodec/h264.c
+index 3621f41..718906a 100644
+--- a/gst-libs/ext/libav/libavcodec/h264.c.old
++++ b/gst-libs/ext/libav/libavcodec/h264.c
+@@ -2491,6 +2491,34 @@ int ff_h264_get_profile(SPS *sps)
+     return profile;
+ }
+ 
++static int h264_set_parameter_from_sps(H264Context *h)
++{
++    MpegEncContext *s = &h->s;
++    AVCodecContext * avctx= s->avctx;
++
++    if (s->flags& CODEC_FLAG_LOW_DELAY ||
++        (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames))
++        s->low_delay=1;
++
++    if(avctx->has_b_frames < 2)
++        avctx->has_b_frames= !s->low_delay;
++
++    if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
++        if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
++            avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
++            h->pixel_shift = h->sps.bit_depth_luma > 8;
++
++            ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
++            ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
++            dsputil_init(&s->dsp, s->avctx);
++        } else {
++            av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
++            return -1;
++        }
++    }
++    return 0;
++}
++
+ /**
+  * decodes a slice header.
+  * This will also call MPV_common_init() and frame_start() as needed.
+@@ -2505,7 +2533,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
+     MpegEncContext * const s0 = &h0->s;
+     unsigned int first_mb_in_slice;
+     unsigned int pps_id;
+-    int num_ref_idx_active_override_flag;
++    int num_ref_idx_active_override_flag, ret;
+     unsigned int slice_type, tmp, i, j;
+     int default_ref_list_done = 0;
+     int last_pic_structure;
+@@ -2569,7 +2597,17 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
+         av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS %u referenced\n", h->pps.sps_id);
+         return -1;
+     }
+-    h->sps = *h0->sps_buffers[h->pps.sps_id];
++
++    if (h->pps.sps_id != h->current_sps_id ||
++        h0->sps_buffers[h->pps.sps_id]->new) {
++        h0->sps_buffers[h->pps.sps_id]->new = 0;
++
++        h->current_sps_id = h->pps.sps_id;
++        h->sps            = *h0->sps_buffers[h->pps.sps_id];
++
++        if ((ret = h264_set_parameter_from_sps(h)) < 0)
++            return ret;
++    }
+ 
+     s->avctx->profile = ff_h264_get_profile(&h->sps);
+     s->avctx->level   = h->sps.level_idc;
+@@ -3811,26 +3811,8 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
+         case NAL_SPS:
+             init_get_bits(&s->gb, ptr, bit_length);
+             ff_h264_decode_seq_parameter_set(h);
+-
+-            if (s->flags& CODEC_FLAG_LOW_DELAY ||
+-                (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames))
+-                s->low_delay=1;
+-
+-            if(avctx->has_b_frames < 2)
+-                avctx->has_b_frames= !s->low_delay;
+-
+-            if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
+-                if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
+-                    avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
+-                    h->pixel_shift = h->sps.bit_depth_luma > 8;
+-
+-                    ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
+-                    ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
+-                    dsputil_init(&s->dsp, s->avctx);
+-                } else {
+-                    av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
+-                    return -1;
+-                }
++            if (h264_set_parameter_from_sps(h) < 0) {
++                return -1;
+             }
+             break;
+         case NAL_PPS:
+diff --git a/gst-libs/ext/libav/libavcodec/h264.h.old b/gst-libs/ext/libav/libavcodec/h264.h
+index e3cc815..b77ad98 100644
+--- a/gst-libs/ext/libav/libavcodec/h264.h.old
++++ b/gst-libs/ext/libav/libavcodec/h264.h
+@@ -202,6 +202,7 @@ typedef struct SPS{
+     int bit_depth_chroma;              ///< bit_depth_chroma_minus8 + 8
+     int residual_color_transform_flag; ///< residual_colour_transform_flag
+     int constraint_set_flags;          ///< constraint_set[0-3]_flag
++    int new;                              ///< flag to keep track if the decoder context needs re-init due to changed SPS
+ }SPS;
+ 
+ /**
+@@ -333,6 +334,7 @@ typedef struct H264Context{
+     int emu_edge_width;
+     int emu_edge_height;
+ 
++    unsigned current_sps_id; ///< id of the current SPS
+     SPS sps; ///< current sps
+ 
+     /**
+diff --git a/gst-libs/ext/libav/libavcodec/h264_ps.c.old b/gst-libs/ext/libav/libavcodec/h264_ps.c
+index 7491807..0929098 100644
+--- a/gst-libs/ext/libav/libavcodec/h264_ps.c.old
++++ b/gst-libs/ext/libav/libavcodec/h264_ps.c
+@@ -438,10 +438,13 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
+                sps->timing_info_present_flag ? sps->time_scale : 0
+                );
+     }
++    sps->new = 1;
+ 
+     av_free(h->sps_buffers[sps_id]);
+-    h->sps_buffers[sps_id]= sps;
+-    h->sps = *sps;
++    h->sps_buffers[sps_id] = sps;
++    h->sps                 = *sps;
++    h->current_sps_id      = sps_id;
++
+     return 0;
+ fail:
+     av_free(sps);
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
new file mode 100644
index 0000000..5d45c1a
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
@@ -0,0 +1,33 @@
+gst-ffmpeg: h264: skip error concealment when SPS and slices are
+ mismatching
+
+Fixes out of array accesses
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 695af8eed642ff0104834495652d1ee784a4c14d)
+
+Upstream-Status: Backport
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+---
+ libavcodec/h264.c |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/libavcodec/h264.c b/libavcodec/h264.c
+index da144db..0aab4e7 100644
+--- a/gst-libs/ext/libav/libavcodec/h264.c
++++ b/gst-libs/ext/libav/libavcodec/h264.c
+@@ -2351,7 +2351,7 @@ static int field_end(H264Context *h, int in_setup)
+      * past end by one (callers fault) and resync_mb_y != 0
+      * causes problems for the first MB line, too.
+      */
+-    if (!FIELD_PICTURE)
++    if (!FIELD_PICTURE && h->current_slice && !h->sps.new)
+         ff_er_frame_end(s);
+ 
+     ff_MPV_frame_end(s);
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
new file mode 100644
index 0000000..1e62b50
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
@@ -0,0 +1,39 @@
+gst-ffmpeg: h264_sei: Fix infinite loop.
+
+Fixsot yet fixed parts of CVE-2011-3946.
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+
+Upstream-Status: Backport 
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+
+---
+ libavcodec/h264_sei.c |    4 ++++
+ 1 files changed, 4 insertions(+), 0 deletions(-)
+
+
+diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
+index 374e53d..80d70e5 100644
+--- a/gst-libs/ext/libav/libavcodec/h264_sei.c
++++ b/gst-libs/ext/libav/libavcodec/h264_sei.c
+@@ -169,11 +169,15 @@ int ff_h264_decode_sei(H264Context *h){
+ 
+         type=0;
+         do{
++            if (get_bits_left(&s->gb) < 8)
++                return -1;
+             type+= show_bits(&s->gb, 8);
+         }while(get_bits(&s->gb, 8) == 255);
+ 
+         size=0;
+         do{
++            if (get_bits_left(&s->gb) < 8)
++                return -1;
+             size+= show_bits(&s->gb, 8);
+         }while(get_bits(&s->gb, 8) == 255);
+ 
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
new file mode 100644
index 0000000..e859e44
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
@@ -0,0 +1,87 @@
+From b666debffec1fcbb19ef377635a53b9a58bca8a4 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Tue, 29 Jan 2013 18:29:41 +0100
+Subject: [PATCH] huffyuvdec: Check init_vlc() return codes.
+
+Upstream-Status: Backport
+
+Commit b666debffec1fcbb19ef377635a53b9a58bca8a4 release/1.0
+
+Prevents out of array writes
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit f67a0d115254461649470452058fa3c28c0df294)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/huffyuv.c | 14 ++++++++++----
+ 1 file changed, 10 insertions(+), 4 deletions(-)
+
+diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
+index 58da789..993e524 100644
+--- a/gst-libs/ext/libav/libavcodec/huffyuv.c
++++ b/gst-libs/ext/libav/libavcodec/huffyuv.c
+@@ -33,6 +33,7 @@
+ #include "put_bits.h"
+ #include "dsputil.h"
+ #include "thread.h"
++#include "libavutil/avassert.h"
+ 
+ #define VLC_BITS 11
+ 
+@@ -287,6 +287,7 @@ static void generate_joint_tables(HYuvCo
+                     int len1 = s->len[p][u];
+                     if (len1 > limit || !len1)
+                         continue;
++                    av_assert0(i < (1 << VLC_BITS));
+                     len[i] = len0 + len1;
+                     bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
+                     symbols[i] = (y<<8) + u;
+@@ -320,6 +321,7 @@ static void generate_joint_tables(HYuvCo
+                     int len2 = s->len[2][r&255];
+                     if (len2 > limit1 || !len2)
+                         continue;
++                    av_assert0(i < (1 << VLC_BITS));
+                     len[i] = len0 + len1 + len2;
+                     bits[i] = (code << len2) + s->bits[2][r&255];
+                     if(s->decorrelate){
+@@ -343,6 +345,7 @@ static void generate_joint_tables(HYuvCo
+ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length){
+     GetBitContext gb;
+     int i;
++    int ret;
+ 
+     init_get_bits(&gb, src, length*8);
+ 
+@@ -353,7 +356,9 @@ static int read_huffman_tables(HYuvConte
+             return -1;
+         }
+         free_vlc(&s->vlc[i]);
+-        init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
++        if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
++                           s->bits[i], 4, 4, 0)) < 0)
++            return ret;
+     }
+ 
+     generate_joint_tables(s);
+@@ -365,6 +370,7 @@ static int read_old_huffman_tables(HYuvC
+ #if 1
+     GetBitContext gb;
+     int i;
++    int ret;
+ 
+     init_get_bits(&gb, classic_shift_luma, sizeof(classic_shift_luma)*8);
+     if(read_len_table(s->len[0], &gb)<0)
+@@ -385,7 +391,9 @@ static int read_old_huffman_tables(HYuvC
+ 
+     for(i=0; i<3; i++){
+         free_vlc(&s->vlc[i]);
+-        init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
++        if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
++                            s->bits[i], 4, 4, 0)) < 0)
++            return ret;
+     }
+ 
+     generate_joint_tables(s);
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
new file mode 100644
index 0000000..94bf4b6
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
@@ -0,0 +1,61 @@
+From db0f7f7394e1f994ed38db043f78ed0f10bde0da Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Tue, 29 Jan 2013 19:22:33 +0100
+Subject: [PATCH] huffyuvdec: Skip len==0 cases
+
+Upstream-Status: Backport
+
+Commit db0f7f7394e1f994ed38db043f78ed0f10bde0da release/1.0
+
+Fixes vlc decoding for hypothetical files that would contain such cases.
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 0dfc01c2bbf4b71bb56201bc4a393321e15d1b31)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/huffyuv.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
+index 993e524..72ed351 100644
+--- a/gst-libs/ext/libav/libavcodec/huffyuv.c
++++ b/gst-libs/ext/libav/libavcodec/huffyuv.c
+@@ -281,11 +281,11 @@ static void generate_joint_tables(HYuvCo
+             for(i=y=0; y<256; y++){
+                 int len0 = s->len[0][y];
+                 int limit = VLC_BITS - len0;
+-                if(limit <= 0)
++                if(limit <= 0 || !len0)
+                     continue;
+                 for(u=0; u<256; u++){
+                     int len1 = s->len[p][u];
+-                    if(len1 > limit)
++                    if (len1 > limit || !len1)
+                         continue;
+                     len[i] = len0 + len1;
+                     bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
+@@ -308,17 +308,17 @@ static void generate_joint_tables(HYuvCo
+         for(i=0, g=-16; g<16; g++){
+             int len0 = s->len[p0][g&255];
+             int limit0 = VLC_BITS - len0;
+-            if(limit0 < 2)
++            if (limit0 < 2 || !len0)
+                 continue;
+             for(b=-16; b<16; b++){
+                 int len1 = s->len[p1][b&255];
+                 int limit1 = limit0 - len1;
+-                if(limit1 < 1)
++                if (limit1 < 1 || !len1)
+                     continue;
+                 code = (s->bits[p0][g&255] << len1) + s->bits[p1][b&255];
+                 for(r=-16; r<16; r++){
+                     int len2 = s->len[2][r&255];
+-                    if(len2 > limit1)
++                    if (len2 > limit1 || !len2)
+                         continue;
+                     len[i] = len0 + len1 + len2;
+                     bits[i] = (code << len2) + s->bits[2][r&255];
+-- 
+1.8.5.2.233.g932f7e4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
new file mode 100644
index 0000000..ea4aa22
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
@@ -0,0 +1,45 @@
+gst-ffmpeg: lavf: compute probe buffer size more reliably.
+
+The previous code computes the offset by reversing the growth
+of the allocated buffer size: it is complex and did lead to
+inconsistencies when the size limit is reached.
+
+Fix trac ticket #1991.
+(cherry picked from commit 03847eb8259291b4ff1bd840bd779d0699d71f96)
+
+Conflicts:
+	libavformat/utils.c
+
+Upstream-Status: Backport
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+
+---
+ libavformat/utils.c |    4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libavformat/utils.c b/libavformat/utils.c
+index 7940037..be73c4a 100644
+--- a/gst-libs/ext/libav/libavformat/utils.c
++++ b/gst-libs/ext/libav/libavformat/utils.c
+@@ -459,7 +459,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
+ {
+     AVProbeData pd = { filename ? filename : "", NULL, -offset };
+     unsigned char *buf = NULL;
+-    int ret = 0, probe_size;
++    int ret = 0, probe_size, buf_offset = 0;
+ 
+     if (!max_probe_size) {
+         max_probe_size = PROBE_BUF_MAX;
+@@ -499,7 +499,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
+             score = 0;
+             ret = 0;            /* error was end of file, nothing read */
+         }
+-        pd.buf_size += ret;
++        pd.buf_size = buf_offset += ret;
+         pd.buf = &buf[offset];
+ 
+         memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
new file mode 100644
index 0000000..d90bafa
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
@@ -0,0 +1,32 @@
+From 1f41cffe1e3e79620f587545bdfcbd7e6e68ed29 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Sun, 11 Nov 2012 00:01:24 +0100
+Subject: [PATCH] mjpegdec: check SE.
+
+Upstream-Status: Backport
+
+Commit 1f41cffe1e3e79620f587545bdfcbd7e6e68ed29 release/1.1
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/mjpegdec.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
+index 6b5266d..0a71a6f 100644
+--- a/gst-libs/ext/libav/libavcodec/mjpegdec.c
++++ b/gst-libs/ext/libav/libavcodec/mjpegdec.c
+@@ -905,6 +905,11 @@ static int mjpeg_decode_scan_progressive
+     int16_t *quant_matrix = s->quant_matrixes[ s->quant_index[c] ];
+     GetBitContext mb_bitmask_gb;
+ 
++    if (se > 63) {
++        av_log(s->avctx, AV_LOG_ERROR, "SE %d is too large\n", se);
++        return AVERROR_INVALIDDATA;
++    }
++
+     if (mb_bitmask) {
+         init_get_bits(&mb_bitmask_gb, mb_bitmask, s->mb_width*s->mb_height);
+     }
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
new file mode 100644
index 0000000..1041347
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
@@ -0,0 +1,34 @@
+From 28bf685bfc6d0c744369cdf367f61a78d80d0b01 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Thu, 15 Nov 2012 16:41:28 +0100
+Subject: [PATCH] pgssubdec: check RLE size before copying. Fix out of array
+ accesses
+
+Upstream-Status: Backport
+
+Commit 28bf685bfc6d0c744369cdf367f61a78d80d0b01 release/1.1
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit c0d68be555f5858703383040e04fcd6529777061)
+---
+ libavcodec/pgssubdec.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
+index 728f178..26a3c2a 100644
+--- a/gst-libs/ext/libav/libavcodec/pgssubdec.c
++++ b/gst-libs/ext/libav/libavcodec/pgssubdec.c
+@@ -202,6 +202,11 @@ static int parse_picture_segment(AVCodec
+         return -1;
+     }
+ 
++    if (buf_size > rle_bitmap_len) {
++        av_log(avctx, AV_LOG_ERROR, "too much RLE data\n");
++        return AVERROR_INVALIDDATA;
++    }
++
+     ctx->picture.w = width;
+     ctx->picture.h = height;
+ 
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
new file mode 100644
index 0000000..1e5fb7d
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
@@ -0,0 +1,44 @@
+gst-ffmpeg: pngdec/filter: dont access out of array elements at the end
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+
+Upstream-Status: Backport 
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+---
+ libavcodec/pngdec.c |   12 ++++--------
+ 1 files changed, 4 insertions(+), 8 deletions(-)
+
+diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
+index 97c0ad1..193e35e 100644
+--- a/gst-libs/ext/libav/libavcodec/pngdec.c
++++ b/gst-libs/ext/libav/libavcodec/pngdec.c
+@@ -190,7 +190,7 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w
+     if(bpp >= 2) g = dst[1];\
+     if(bpp >= 3) b = dst[2];\
+     if(bpp >= 4) a = dst[3];\
+-    for(; i < size; i+=bpp) {\
++    for(; i <= size - bpp; i+=bpp) {\
+         dst[i+0] = r = op(r, src[i+0], last[i+0]);\
+         if(bpp == 1) continue;\
+         dst[i+1] = g = op(g, src[i+1], last[i+1]);\
+@@ -206,13 +206,9 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w
+     else if(bpp == 2) UNROLL1(2, op)\
+     else if(bpp == 3) UNROLL1(3, op)\
+     else if(bpp == 4) UNROLL1(4, op)\
+-    else {\
+-        for (; i < size; i += bpp) {\
+-            int j;\
+-            for (j = 0; j < bpp; j++)\
+-                dst[i+j] = op(dst[i+j-bpp], src[i+j], last[i+j]);\
+-        }\
+-    }
++    for (; i < size; i++) {\
++        dst[i] = op(dst[i-bpp], src[i], last[i]);\
++    }\
+ 
+ /* NOTE: 'dst' can be equal to 'last' */
+ static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
new file mode 100644
index 0000000..8c94232
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
@@ -0,0 +1,30 @@
+gst-ffmpeg: qdm2: check array index before use, fix out of array
+ accesses
+
+Upstream-Status: Backport 
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/qdm2.c |    5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
+index 4cf4b2f..1dfb8d5 100644
+--- a/gst-libs/ext/libav/libavcodec/qdm2.c
++++ b/gst-libs/ext/libav/libavcodec/qdm2.c
+@@ -1257,6 +1257,11 @@ static void qdm2_decode_super_block (QDM2Context *q)
+     for (i = 0; packet_bytes > 0; i++) {
+         int j;
+ 
++        if (i>=FF_ARRAY_ELEMS(q->sub_packet_list_A)) {
++            SAMPLES_NEEDED_2("too many packet bytes");
++            return;
++        }
++
+         q->sub_packet_list_A[i].next = NULL;
+ 
+         if (i > 0) {
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
new file mode 100644
index 0000000..43ffc03
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
@@ -0,0 +1,58 @@
+gst-ffmpeg: qdm2dec: fix buffer overflow. Fixes NGS00144
+
+This also adds a few lines of code from master that are needed for this fix.
+
+Thanks to Phillip for suggestions to improve the patch.
+Found-by: Phillip Langlois
+
+Upstream-Status: Backport 
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/qdm2.c |    9 +++++++--
+ 1 files changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
+index 3aa9e5b..e000df8 100644
+--- a/gst-libs/ext/libav/libavcodec/qdm2.c
++++ b/gst-libs/ext/libav/libavcodec/qdm2.c
+@@ -76,6 +76,7 @@ do { \
+ #define SAMPLES_NEEDED_2(why) \
+      av_log (NULL,AV_LOG_INFO,"This file triggers some missing code. Please contact the developers.\nPosition: %s\n",why);
+ 
++#define QDM2_MAX_FRAME_SIZE 512
+ 
+ typedef int8_t sb_int8_array[2][30][64];
+ 
+@@ -168,7 +169,7 @@ typedef struct {
+     /// I/O data
+     const uint8_t *compressed_data;
+     int compressed_size;
+-    float output_buffer[1024];
++    float output_buffer[QDM2_MAX_FRAME_SIZE * MPA_MAX_CHANNELS * 2];
+ 
+     /// Synthesis filter
+     MPADSPContext mpadsp;
+@@ -1819,6 +1820,9 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
+     s->group_order = av_log2(s->group_size) + 1;
+     s->frame_size = s->group_size / 16; // 16 iterations per super block
+ 
++    if (s->frame_size > QDM2_MAX_FRAME_SIZE)
++        return AVERROR_INVALIDDATA;
++
+     s->sub_sampling = s->fft_order - 7;
+     s->frequency_range = 255 / (1 << (2 - s->sub_sampling));
+ 
+@@ -1887,6 +1891,9 @@ static int qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
+     int ch, i;
+     const int frame_size = (q->frame_size * q->channels);
+ 
++    if((unsigned)frame_size > FF_ARRAY_ELEMS(q->output_buffer)/2)
++        return -1;
++
+     /* select input buffer */
+     q->compressed_data = in;
+     q->compressed_size = q->checksum_size;
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
new file mode 100644
index 0000000..7e58afc
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
@@ -0,0 +1,36 @@
+From 391e0fc6c90ced6656b74f50f3a487b6dc76ea63 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Thu, 29 Nov 2012 15:18:17 +0100
+Subject: [PATCH] roqvideodec: check dimensions validity
+
+Upstream-Status: Backport
+
+Commit 391e0fc6c90ced6656b74f50f3a487b6dc76ea63 release/0.7
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit 3ae610451170cd5a28b33950006ff0bd23036845)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/roqvideodec.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c
+index f0977f6..4e34231 100644
+--- a/gst-libs/ext/libav/libavcodec/roqvideodec.c
++++ b/gst-libs/ext/libav/libavcodec/roqvideodec.c
+@@ -157,6 +157,12 @@ static av_cold int roq_decode_init(AVCodecContext *avctx)
+     RoqContext *s = avctx->priv_data;
+ 
+     s->avctx = avctx;
++
++    if (avctx->width%16 || avctx->height%16) {
++         av_log_ask_for_sample(avctx, "dimensions not being a multiple of 16 are unsupported\n");
++         return AVERROR_PATCHWELCOME;
++    }
++
+     s->width = avctx->width;
+     s->height = avctx->height;
+     avcodec_get_frame_defaults(&s->frames[0]);
+-- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
new file mode 100644
index 0000000..15b1614
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
@@ -0,0 +1,32 @@
+gst-ffmpeg: smackerdec: Check that the last indexes are within the
+ table.
+
+Fixes CVE-2011-3944
+
+Upstream-Status: Backport 
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/smacker.c |    5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
+index 30f99b4..2a8bae8 100644
+--- a/gst-libs/ext/libav/libavcodec/smacker.c
++++ b/gst-libs/ext/libav/libavcodec/smacker.c
+@@ -259,6 +259,11 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
+     if(ctx.last[0] == -1) ctx.last[0] = huff.current++;
+     if(ctx.last[1] == -1) ctx.last[1] = huff.current++;
+     if(ctx.last[2] == -1) ctx.last[2] = huff.current++;
++    if(huff.current > huff.length){
++        ctx.last[0] = ctx.last[1] = ctx.last[2] = 1;
++        av_log(smk->avctx, AV_LOG_ERROR, "bigtree damaged\n");
++        return -1;
++    }
+ 
+     *recodes = huff.values;
+ 
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
new file mode 100644
index 0000000..a1989cf
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
@@ -0,0 +1,32 @@
+gst-ffmpeg: vp3: Copy all 3 frames for thread updates.
+
+This fixes a double release of the current frame on deinit.
+Fixes CVE-2011-3934
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+
+Upstream-Status: Backport
+
+Signed-off-by: Yue.Tao <yue.tao@windriver.com>
+
+---
+ libavcodec/vp3.c |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
+index 738ae9f..b5daafc 100644
+--- a/gst-libs/ext/libav/libavcodec/vp3.c
++++ b/gst-libs/ext/libav/libavcodec/vp3.c
+@@ -1859,7 +1859,7 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
+         ||s->width != s1->width
+         ||s->height!= s1->height) {
+         if (s != s1)
+-            copy_fields(s, s1, golden_frame, current_frame);
++            copy_fields(s, s1, golden_frame, keyframe);
+         return -1;
+     }
+ 
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
new file mode 100644
index 0000000..e83d8f4
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
@@ -0,0 +1,183 @@
+gst-ffmpeg: vp3: fix oob read for negative tokens and memleaks on error.
+
+Upstream-Status: Backport 
+
+Signed-off-by: Yue.Tao <yue.tao@windriver.com>
+
+---
+ libavcodec/vp3.c |   59 +++++++++++++++++++++++++++++++++++++++++------------
+ 1 files changed, 45 insertions(+), 14 deletions(-)
+
+diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
+index 36715bb..ce14e63 100644
+--- a/gst-libs/ext/libav/libavcodec/vp3.c
++++ b/gst-libs/ext/libav/libavcodec/vp3.c
+@@ -45,6 +45,7 @@
+ #define FRAGMENT_PIXELS 8
+ 
+ static av_cold int vp3_decode_end(AVCodecContext *avctx);
++static void vp3_decode_flush(AVCodecContext *avctx);
+ 
+ //FIXME split things out into their own arrays
+ typedef struct Vp3Fragment {
+@@ -890,7 +891,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
+             /* decode a VLC into a token */
+             token = get_vlc2(gb, vlc_table, 11, 3);
+             /* use the token to get a zero run, a coefficient, and an eob run */
+-            if (token <= 6) {
++            if ((unsigned) token <= 6U) {
+                 eob_run = eob_run_base[token];
+                 if (eob_run_get_bits[token])
+                     eob_run += get_bits(gb, eob_run_get_bits[token]);
+@@ -908,7 +909,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
+                     coeff_i        += eob_run;
+                     eob_run = 0;
+                 }
+-            } else {
++            } else if (token >= 0) {
+                 bits_to_get = coeff_get_bits[token];
+                 if (bits_to_get)
+                     bits_to_get = get_bits(gb, bits_to_get);
+@@ -942,6 +943,10 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
+                 for (i = coeff_index+1; i <= coeff_index+zero_run; i++)
+                     s->num_coded_frags[plane][i]--;
+                 coeff_i++;
++            } else {
++                av_log(s->avctx, AV_LOG_ERROR,
++                       "Invalid token %d\n", token);
++                return -1;
+             }
+     }
+ 
+@@ -991,6 +996,8 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
+     /* unpack the Y plane DC coefficients */
+     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0,
+         0, residual_eob_run);
++    if (residual_eob_run < 0)
++        return residual_eob_run;
+ 
+     /* reverse prediction of the Y-plane DC coefficients */
+     reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]);
+@@ -998,8 +1005,12 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
+     /* unpack the C plane DC coefficients */
+     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
+         1, residual_eob_run);
++    if (residual_eob_run < 0)
++        return residual_eob_run;
+     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
+         2, residual_eob_run);
++    if (residual_eob_run < 0)
++        return residual_eob_run;
+ 
+     /* reverse prediction of the C-plane DC coefficients */
+     if (!(s->avctx->flags & CODEC_FLAG_GRAY))
+@@ -1036,11 +1047,17 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
+     for (i = 1; i <= 63; i++) {
+             residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i,
+                 0, residual_eob_run);
++            if (residual_eob_run < 0)
++                return residual_eob_run;
+ 
+             residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
+                 1, residual_eob_run);
++            if (residual_eob_run < 0)
++                return residual_eob_run;
+             residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
+                 2, residual_eob_run);
++            if (residual_eob_run < 0)
++                return residual_eob_run;
+     }
+ 
+     return 0;
+@@ -1777,10 +1794,15 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
+     Vp3DecodeContext *s = dst->priv_data, *s1 = src->priv_data;
+     int qps_changed = 0, i, err;
+ 
++#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
++
+     if (!s1->current_frame.data[0]
+         ||s->width != s1->width
+-        ||s->height!= s1->height)
++        ||s->height!= s1->height) {
++        if (s != s1)
++            copy_fields(s, s1, golden_frame, current_frame);
+         return -1;
++    }
+ 
+     if (s != s1) {
+         // init tables if the first frame hasn't been decoded
+@@ -1796,8 +1818,6 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
+             memcpy(s->motion_val[1], s1->motion_val[1], c_fragment_count * sizeof(*s->motion_val[1]));
+         }
+ 
+-#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
+-
+         // copy previous frame data
+         copy_fields(s, s1, golden_frame, dsp);
+ 
+@@ -1987,9 +2007,6 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
+     Vp3DecodeContext *s = avctx->priv_data;
+     int i;
+ 
+-    if (avctx->is_copy && !s->current_frame.data[0])
+-        return 0;
+-
+     av_free(s->superblock_coding);
+     av_free(s->all_fragments);
+     av_free(s->coded_fragment_list[0]);
+@@ -2016,12 +2033,7 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
+     free_vlc(&s->motion_vector_vlc);
+ 
+     /* release all frames */
+-    if (s->golden_frame.data[0])
+-        ff_thread_release_buffer(avctx, &s->golden_frame);
+-    if (s->last_frame.data[0] && s->last_frame.type != FF_BUFFER_TYPE_COPY)
+-        ff_thread_release_buffer(avctx, &s->last_frame);
+-    /* no need to release the current_frame since it will always be pointing
+-     * to the same frame as either the golden or last frame */
++    vp3_decode_flush(avctx);
+ 
+     return 0;
+ }
+@@ -2341,6 +2353,23 @@ static void vp3_decode_flush(AVCodecContext *avctx)
+         ff_thread_release_buffer(avctx, &s->current_frame);
+ }
+ 
++static int vp3_init_thread_copy(AVCodecContext *avctx)
++{
++    Vp3DecodeContext *s = avctx->priv_data;
++
++    s->superblock_coding      = NULL;
++    s->all_fragments          = NULL;
++    s->coded_fragment_list[0] = NULL;
++    s->dct_tokens_base        = NULL;
++    s->superblock_fragments   = NULL;
++    s->macroblock_coding      = NULL;
++    s->motion_val[0]          = NULL;
++    s->motion_val[1]          = NULL;
++    s->edge_emu_buffer        = NULL;
++
++    return 0;
++}
++
+ AVCodec ff_theora_decoder = {
+     .name           = "theora",
+     .type           = AVMEDIA_TYPE_VIDEO,
+@@ -2352,6 +2381,7 @@ AVCodec ff_theora_decoder = {
+     .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
+     .flush = vp3_decode_flush,
+     .long_name = NULL_IF_CONFIG_SMALL("Theora"),
++    .init_thread_copy      = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
+     .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
+ };
+ #endif
+@@ -2367,5 +2397,6 @@ AVCodec ff_vp3_decoder = {
+     .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
+     .flush = vp3_decode_flush,
+     .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"),
++    .init_thread_copy      = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
+     .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
+ };
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
new file mode 100644
index 0000000..7e4f682
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
@@ -0,0 +1,51 @@
+From 2cac35086c9e103fa98960c546d5017e7363803a Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Fri, 25 Jan 2013 06:11:59 +0100
+Subject: [PATCH] vqavideo: check chunk sizes before reading chunks
+
+Upstream-Status: Backport
+
+Commit 2cac35086c9e103fa98960c546d5017e7363803a release/0.7
+
+Fixes out of array writes
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+(cherry picked from commit ab6c9332bfa1e20127a16392a0b85a4aa4840889)
+
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+---
+ libavcodec/vqavideo.c |   10 ++++++++++
+ 1 files changed, 10 insertions(+), 0 deletions(-)
+
+diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
+index d1eab5b..6e1ce6c 100644
+--- a/gst-libs/ext/libav/libavcodec/vqavideo.c
++++ b/gst-libs/ext/libav/libavcodec/vqavideo.c
+@@ -527,6 +527,11 @@ static void vqa_decode_chunk(VqaContext *s)
+         chunk_size = AV_RB32(&s->buf[cbp0_chunk + 4]);
+         cbp0_chunk += CHUNK_PREAMBLE_SIZE;
+ 
++        if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
++            av_log(s->avctx, AV_LOG_ERROR, "cbp0 chunk too large (0x%X bytes)\n", chunk_size);
++            return AVERROR_INVALIDDATA;
++        }
++
+         /* accumulate partial codebook */
+         memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
+             &s->buf[cbp0_chunk], chunk_size);
+@@ -550,6 +555,11 @@ static void vqa_decode_chunk(VqaContext *s)
+         chunk_size = AV_RB32(&s->buf[cbpz_chunk + 4]);
+         cbpz_chunk += CHUNK_PREAMBLE_SIZE;
+ 
++        if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
++            av_log(s->avctx, AV_LOG_ERROR, "cbpz chunk too large (0x%X bytes)\n", chunk_size);
++            return AVERROR_INVALIDDATA;
++        }
++
+         /* accumulate partial codebook */
+         memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
+             &s->buf[cbpz_chunk], chunk_size);
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
new file mode 100644
index 0000000..c8bafd5
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
@@ -0,0 +1,68 @@
+From 6043c431c97d55173f339fafbd033d3c0642e2e9 Mon Sep 17 00:00:00 2001
+From: Michael Niedermayer <michaelni@gmx.at>
+Date: Fri, 3 Oct 2014 01:50:27 +0200
+Subject: [PATCH 2/2] avcodec/mjpegdec: check bits per pixel for changes
+ similar to dimensions
+
+Upstream-Status: Backport
+
+Fixes out of array accesses
+Fixes: asan_heap-oob_16668e9_2_asan_heap-oob_16668e9_346_miss_congeniality_pegasus_mjpg.avi
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+
+Conflicts:
+	libavcodec/mjpegdec.c
+---
+ libavcodec/mjpegdec.c | 15 ++++++++-------
+ 1 file changed, 8 insertions(+), 7 deletions(-)
+
+diff --git a/gst-libs/ext/libav/libavcodec/mjpegdec.c b/gst-libs/ext/libav/libavcodec/mjpegdec.c
+index 84343c0..c0137d8 100644
+--- a/gst-libs/ext/libav/libavcodec/mjpegdec.c
++++ b/gst-libs/ext/libav/libavcodec/mjpegdec.c
+@@ -210,16 +210,16 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
+ 
+ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
+ {
+-    int len, nb_components, i, width, height, pix_fmt_id;
++    int len, nb_components, i, bits, width, height, pix_fmt_id;
+ 
+     /* XXX: verify len field validity */
+     len = get_bits(&s->gb, 16);
+-    s->bits= get_bits(&s->gb, 8);
++    bits= get_bits(&s->gb, 8);
+ 
+-    if(s->pegasus_rct) s->bits=9;
+-    if(s->bits==9 && !s->pegasus_rct) s->rct=1;    //FIXME ugly
++    if(s->pegasus_rct) bits=9;
++    if(bits==9 && !s->pegasus_rct) s->rct=1;    //FIXME ugly
+ 
+-    if (s->bits != 8 && !s->lossless){
++    if (bits != 8 && !s->lossless){
+         av_log(s->avctx, AV_LOG_ERROR, "only 8 bits/component accepted\n");
+         return -1;
+     }
+@@ -239,7 +239,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
+     if (nb_components <= 0 ||
+         nb_components > MAX_COMPONENTS)
+         return -1;
+-    if (s->ls && !(s->bits <= 8 || nb_components == 1)){
++    if (s->ls && !(bits <= 8 || nb_components == 1)){
+         av_log(s->avctx, AV_LOG_ERROR, "only <= 8 bits/component or 16-bit gray accepted for JPEG-LS\n");
+         return -1;
+     }
+@@ -272,10 +272,11 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
+ 
+     /* if different size, realloc/alloc picture */
+     /* XXX: also check h_count and v_count */
+-    if (width != s->width || height != s->height) {
++    if (width != s->width || height != s->height || bits != s->bits) {
+         av_freep(&s->qscale_table);
+ 
+         s->width = width;
++        s->bits= bits;
+         s->height = height;
+         s->interlaced = 0;
+ 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/configure-fix.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/configure-fix.patch
new file mode 100644
index 0000000..9ef6f7c
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/configure-fix.patch
@@ -0,0 +1,22 @@
+Disable yasm for libav when --disable-yasm
+
+Upstream-Status: Inappropriate [configuration]
+
+Signed-off-by: Shane Wang <shane.wang@intel.com>
+
+diff -r f2f8f74c6e30 configure.ac
+--- a/configure.ac	Thu Dec 22 23:56:09 2011 +0800
++++ b/configure.ac	Thu Dec 22 23:57:37 2011 +0800
+@@ -325,6 +325,12 @@
+         --enable-gpl"
+   fi
+ 
++ AC_ARG_ENABLE(yasm,
++              [AC_HELP_STRING([--disable-yasm], [disable use of yasm assembler])])
++  if test "x$enable_yasm" = "xno"; then
++    embffmpeg_configure_args="$embffmpeg_configure_args --disable-yasm"
++  fi
++
+   # if we are cross-compiling, tell ffmpeg so
+   target_os=`echo $host_os | sed 's/-gnu//'`
+   if test "x$cross_compiling" = xyes; then
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
new file mode 100644
index 0000000..3c8d8e3
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
@@ -0,0 +1,100 @@
+gst-ffmpeg: Security Advisory - ffmpeg - CVE-2013-0855
+
+Upstream-Status: Backport 
+
+Signed-off-by: Yue Tao <yue.tao@windriver.com>
+
+diff --git a/gst-libs/ext/libav/libavcodec/alac.c.old b/gst-libs/ext/libav/libavcodec/alac.c
+index 2a0df8c..bcbd56d 100644
+--- a/gst-libs/ext/libav/libavcodec/alac.c.old
++++ b/gst-libs/ext/libav/libavcodec/alac.c
+@@ -87,18 +87,44 @@ typedef struct {
+     int wasted_bits;
+ } ALACContext;
+ 
+-static void allocate_buffers(ALACContext *alac)
++static av_cold int alac_decode_close(AVCodecContext *avctx)
++{
++    ALACContext *alac = avctx->priv_data;
++
++    int chan;
++    for (chan = 0; chan < MAX_CHANNELS; chan++) {
++        av_freep(&alac->predicterror_buffer[chan]);
++        av_freep(&alac->outputsamples_buffer[chan]);
++        av_freep(&alac->wasted_bits_buffer[chan]);
++    }
++
++    return 0;
++}
++
++static int allocate_buffers(ALACContext *alac)
+ {
+     int chan;
++    int buf_size;
++
++    if (alac->setinfo_max_samples_per_frame > INT_MAX / sizeof(int32_t))
++        goto buf_alloc_fail;
++    buf_size = alac->setinfo_max_samples_per_frame * sizeof(int32_t);
++
+     for (chan = 0; chan < MAX_CHANNELS; chan++) {
+-        alac->predicterror_buffer[chan] =
+-            av_malloc(alac->setinfo_max_samples_per_frame * 4);
+ 
+-        alac->outputsamples_buffer[chan] =
+-            av_malloc(alac->setinfo_max_samples_per_frame * 4);
++        FF_ALLOC_OR_GOTO(alac->avctx, alac->predicterror_buffer[chan],
++                         buf_size, buf_alloc_fail);
+ 
+-        alac->wasted_bits_buffer[chan] = av_malloc(alac->setinfo_max_samples_per_frame * 4);
++        FF_ALLOC_OR_GOTO(alac->avctx, alac->outputsamples_buffer[chan],
++                         buf_size, buf_alloc_fail);
++
++        FF_ALLOC_OR_GOTO(alac->avctx, alac->wasted_bits_buffer[chan],
++                         buf_size, buf_alloc_fail);
+     }
++    return 0;
++buf_alloc_fail:
++    alac_decode_close(alac->avctx);
++    return AVERROR(ENOMEM);
+ }
+ 
+ static int alac_set_info(ALACContext *alac)
+@@ -131,8 +157,6 @@ static int alac_set_info(ALACContext *alac)
+     bytestream_get_be32(&ptr);      /* bitrate ? */
+     bytestream_get_be32(&ptr);      /* samplerate */
+ 
+-    allocate_buffers(alac);
+-
+     return 0;
+ }
+ 
+@@ -659,6 +683,7 @@ static int alac_decode_frame(AVCodecContext *avctx,
+ 
+ static av_cold int alac_decode_init(AVCodecContext * avctx)
+ {
++    int ret;
+     ALACContext *alac = avctx->priv_data;
+     alac->avctx = avctx;
+     alac->numchannels = alac->avctx->channels;
+@@ -674,18 +699,9 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
+         return -1;
+     }
+ 
+-    return 0;
+-}
+-
+-static av_cold int alac_decode_close(AVCodecContext *avctx)
+-{
+-    ALACContext *alac = avctx->priv_data;
+-
+-    int chan;
+-    for (chan = 0; chan < MAX_CHANNELS; chan++) {
+-        av_freep(&alac->predicterror_buffer[chan]);
+-        av_freep(&alac->outputsamples_buffer[chan]);
+-        av_freep(&alac->wasted_bits_buffer[chan]);
++    if ((ret = allocate_buffers(alac)) < 0) {
++        av_log(avctx, AV_LOG_ERROR, "Error allocating buffers\n");
++        return ret;
+     }
+ 
+     return 0;
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
new file mode 100644
index 0000000..aa385f5
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
@@ -0,0 +1,26 @@
+avcodec/cdgraphics: check buffer size before use
+
+Fixes out of array accesses
+
+Backported from:http://git.videolan.org/?p=ffmpeg.git;a=commit;h=ad002e1a13a8df934bd6cb2c84175a4780ab8942
+
+Upstream-Status: Backport
+
+Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
+Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
+Signed-off-by: Ming Liu <ming.liu@windriver.com>
+
+diff -urpN a/gst-libs/ext/libav/libavcodec/cdgraphics.c b/gst-libs/ext/libav/libavcodec/cdgraphics.c
+--- a/gst-libs/ext/libav/libavcodec/cdgraphics.c	2013-07-18 13:17:08.399876575 +0800
++++ b/gst-libs/ext/libav/libavcodec/cdgraphics.c	2013-07-18 13:18:05.880502267 +0800
+@@ -291,7 +291,9 @@ static int cdg_decode_frame(AVCodecConte
+     inst    = bytestream_get_byte(&buf);
+     inst    &= CDG_MASK;
+     buf += 2;  /// skipping 2 unneeded bytes
+-    bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
++
++    if (buf_size > CDG_HEADER_SIZE)
++        bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
+ 
+     if ((command & CDG_MASK) == CDG_COMMAND) {
+         switch (inst) {
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
new file mode 100644
index 0000000..ade24dc
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
@@ -0,0 +1,57 @@
+Backport http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=5f654897e325349dacf2546674e0510bb72ecb50;hp=250cebeb3b348c3da71f9972eb500d6005dc01f1
+
+Fixes these errors on x86
+
+libavcodec/x86/h264_qpel_mmx.c: Assembler messages:
+libavcodec/x86/h264_qpel_mmx.c:1294: Error: operand type mismatch for `cmp'
+libavcodec/x86/h264_qpel_mmx.c:1294: Error: operand type mismatch for `cmp'
+libavcodec/x86/h264_qpel_mmx.c:1298: Error: operand type mismatch for `cmp'
+libavcodec/x86/h264_qpel_mmx.c:1298: Error: operand type mismatch for `cmp'
+libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
+libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
+libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
+make[5]: *** [libavcodec/x86/dsputil_mmx.o] Error 1
+
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Upstream-Status: Backport
+Index: gst-ffmpeg-0.10.13/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c
+===================================================================
+--- gst-ffmpeg-0.10.13.orig/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c	2012-03-30 11:39:41.324522051 -0700
++++ gst-ffmpeg-0.10.13/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c	2012-03-30 11:54:08.152564075 -0700
+@@ -398,7 +398,7 @@
+             "2:                         \n\t"\
+             \
+             : "+a"(src), "+c"(dst)\
+-            : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\
++            : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "rm"(h)\
+             : "memory"\
+         );\
+         src += 4-(h+5)*srcStride;\
+@@ -446,7 +446,7 @@
+             QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 15*48)\
+             "2:                     \n\t"\
+             : "+a"(src)\
+-            : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)\
++            : "c"(tmp), "S"((x86_reg)srcStride), "rm"(size)\
+             : "memory"\
+             );\
+         tmp += 4;\
+@@ -823,7 +823,7 @@
+         "2:                          \n\t"\
+         \
+         : "+a"(src), "+c"(dst)\
+-        : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\
++        : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "rm"(h)\
+         : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
+                        "%xmm4", "%xmm5", "%xmm6", "%xmm7",)\
+           "memory"\
+@@ -878,7 +878,7 @@
+             QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 15*48)
+             "2:                         \n\t"
+             : "+a"(src)
+-            : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)
++            : "c"(tmp), "S"((x86_reg)srcStride), "rm"(size)
+             : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3",
+                            "%xmm4", "%xmm5", "%xmm6", "%xmm7",)
+               "memory"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav-9.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav-9.patch
new file mode 100644
index 0000000..1860752
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav-9.patch
@@ -0,0 +1,9304 @@
+Taken from gentoo patchset:
+http://dev.gentoo.org/~tetromino/distfiles/gst-plugins-ffmpeg/gst-ffmpeg-0.10.13_p2012.11-libav-9-patches.tar.xz
+
+Upstream-Status: Pending
+
+Contains following changes, rebased to apply on top of our changes
+0002-Fix-includes-for-systemwide-build.patch
+0003-libav-Switch-to-non-deprecated-symbols.patch
+0005-av-Update-for-some-constant-changes.patch
+0006-av-Remove-palette-support-for-now.patch
+0007-av-Port-remaining-simple-bits.patch
+0008-av-Use-av_codec_is_-en-de-coder-API-instead-of-priva.patch
+0009-avprotocol-Port-from-the-URL-protocol-handler-to-san.patch
+0010-avdec-don-t-wait-for-keyframe.patch
+
+Following changes were skipped:
+0001-Partially-revert-commit-0300801b.patch
+0004-av-update-to-use-AVOption-variants.patch
+0011-av_get_bits_per_sample_format-was-removed-in-libav-9.patch
+
+Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
+
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.c	2011-10-31 11:14:03.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.c	2014-08-08 15:26:07.872857555 +0200
+@@ -151,9 +151,6 @@
+ #endif
+   gst_ffmpegaudioresample_register (plugin);
+ 
+-  av_register_protocol2 (&gstreamer_protocol, sizeof (URLProtocol));
+-  av_register_protocol2 (&gstpipe_protocol, sizeof (URLProtocol));
+-
+   /* Now we can return the pointer to the newly created Plugin object. */
+   return TRUE;
+ }
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.h gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.h
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.h	2011-05-17 10:53:16.000000000 +0200
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.h	2014-08-08 15:26:07.872857555 +0200
+@@ -58,10 +58,13 @@
+ int gst_ffmpeg_avcodec_close (AVCodecContext *avctx);
+ int gst_ffmpeg_av_find_stream_info(AVFormatContext *ic);
+ 
+-G_END_DECLS
++int gst_ffmpegdata_open (GstPad * pad, int flags, AVIOContext ** context);
++int gst_ffmpegdata_close (AVIOContext * h);
++typedef struct _GstFFMpegPipe GstFFMpegPipe;
++int gst_ffmpeg_pipe_open (GstFFMpegPipe *ffpipe, int flags, AVIOContext ** context);
++int gst_ffmpeg_pipe_close (AVIOContext * h);
+ 
+-extern URLProtocol gstreamer_protocol;
+-extern URLProtocol gstpipe_protocol;
++G_END_DECLS
+ 
+ /* use GST_FFMPEG URL_STREAMHEADER with URL_WRONLY if the first
+  * buffer should be used as streamheader property on the pad's caps. */
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcfg.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcfg.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcfg.c	2011-07-12 16:35:27.000000000 +0200
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcfg.c	2014-08-08 15:24:17.899853612 +0200
+@@ -147,7 +147,6 @@
+       {FF_DCT_FASTINT, "Fast Integer", "fastint"},
+       {FF_DCT_INT, "Accurate Integer", "int"},
+       {FF_DCT_MMX, "MMX", "mmx"},
+-      {FF_DCT_MLIB, "MLIB", "mlib"},
+       {FF_DCT_ALTIVEC, "ALTIVEC", "altivec"},
+       {FF_DCT_FAAN, "FAAN", "faan"},
+       {0, NULL, NULL},
+@@ -173,8 +172,6 @@
+       {FF_IDCT_SIMPLE, "Simple", "simple"},
+       {FF_IDCT_SIMPLEMMX, "Simple MMX", "simplemmx"},
+       {FF_IDCT_LIBMPEG2MMX, "LIBMPEG2MMX", "libmpeg2mmx"},
+-      {FF_IDCT_PS2, "PS2", "ps2"},
+-      {FF_IDCT_MLIB, "MLIB", "mlib"},
+       {FF_IDCT_ARM, "ARM", "arm"},
+       {FF_IDCT_ALTIVEC, "ALTIVEC", "altivec"},
+       {FF_IDCT_SH4, "SH4", "sh4"},
+@@ -263,16 +260,11 @@
+ 
+   if (!ffmpeg_flags_type) {
+     static const GFlagsValue ffmpeg_flags[] = {
+-      {CODEC_FLAG_OBMC, "Use overlapped block motion compensation (h263+)",
+-          "obmc"},
+       {CODEC_FLAG_QSCALE, "Use fixed qscale", "qscale"},
+       {CODEC_FLAG_4MV, "Allow 4 MV per MB", "4mv"},
+-      {CODEC_FLAG_H263P_AIV, "H.263 alternative inter VLC", "aiv"},
+       {CODEC_FLAG_QPEL, "Quartel Pel Motion Compensation", "qpel"},
+       {CODEC_FLAG_GMC, "GMC", "gmc"},
+       {CODEC_FLAG_MV0, "Always try a MB with MV (0,0)", "mv0"},
+-      {CODEC_FLAG_PART,
+-          "Store MV, DC and AC coefficients in seperate partitions", "part"},
+       {CODEC_FLAG_LOOP_FILTER, "Loop filter", "loop-filter"},
+       {CODEC_FLAG_GRAY, "Only decode/encode grayscale", "gray"},
+       {CODEC_FLAG_NORMALIZE_AQP,
+@@ -282,13 +274,9 @@
+           "global-headers"},
+       {CODEC_FLAG_AC_PRED, "H263 Advanced Intra Coding / MPEG4 AC prediction",
+           "aic"},
+-      {CODEC_FLAG_H263P_UMV, "Unlimited Motion Vector", "umv"},
+       {CODEC_FLAG_CBP_RD, "Rate Distoration Optimization for CBP", "cbp-rd"},
+       {CODEC_FLAG_QP_RD, "Rate Distoration Optimization for QP selection",
+           "qp-rd"},
+-      {CODEC_FLAG_H263P_SLICE_STRUCT, "H263 slice struct", "ss"},
+-      {CODEC_FLAG_SVCD_SCAN_OFFSET,
+-          "Reserve space for SVCD scan offset user data", "scanoffset"},
+       {CODEC_FLAG_CLOSED_GOP, "Closed GOP", "closedgop"},
+       {0, NULL, NULL},
+     };
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c	2011-10-31 11:14:03.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c	2014-08-08 15:31:30.968869139 +0200
+@@ -25,8 +25,10 @@
+ #include <gst/gst.h>
+ #ifdef HAVE_FFMPEG_UNINSTALLED
+ #include <avcodec.h>
++#include <channel_layout.h>
+ #else
+ #include <libavcodec/avcodec.h>
++#include <libavutil/channel_layout.h>
+ #endif
+ #include <string.h>
+ 
+@@ -35,43 +37,6 @@
+ 
+ #include <gst/pbutils/codec-utils.h>
+ 
+-/*
+- * Read a palette from a caps.
+- */
+-
+-static void
+-gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
+-{
+-  GstStructure *str = gst_caps_get_structure (caps, 0);
+-  const GValue *palette_v;
+-  const GstBuffer *palette;
+-
+-  /* do we have a palette? */
+-  if ((palette_v = gst_structure_get_value (str, "palette_data")) && context) {
+-    palette = gst_value_get_buffer (palette_v);
+-    if (GST_BUFFER_SIZE (palette) >= AVPALETTE_SIZE) {
+-      if (context->palctrl)
+-        av_free (context->palctrl);
+-      context->palctrl = av_malloc (sizeof (AVPaletteControl));
+-      context->palctrl->palette_changed = 1;
+-      memcpy (context->palctrl->palette, GST_BUFFER_DATA (palette),
+-          AVPALETTE_SIZE);
+-    }
+-  }
+-}
+-
+-static void
+-gst_ffmpeg_set_palette (GstCaps * caps, AVCodecContext * context)
+-{
+-  if (context->palctrl) {
+-    GstBuffer *palette = gst_buffer_new_and_alloc (AVPALETTE_SIZE);
+-
+-    memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
+-        AVPALETTE_SIZE);
+-    gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, palette, NULL);
+-  }
+-}
+-
+ /* IMPORTANT: Keep this sorted by the ffmpeg channel masks */
+ static const struct
+ {
+@@ -79,26 +44,26 @@
+   GstAudioChannelPosition gst;
+ } _ff_to_gst_layout[] = {
+   {
+-  CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
+-  CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
+-  CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
+-  CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
+-  CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
+-  CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
+-  CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
+-  CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
+-  CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
+-  CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
+-  CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
+-  CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+-  CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+-  CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+-  CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+-  CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+-  CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+-  CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
+-  CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
+-  CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
++  AV_CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
++  AV_CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
++  AV_CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
++  AV_CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
++  AV_CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
++  AV_CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
++  AV_CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
++  AV_CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
++  AV_CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
++  AV_CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
++  AV_CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
++  AV_CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
++  AV_CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
+ };
+ 
+ static GstAudioChannelPosition *
+@@ -342,8 +307,8 @@
+ 
+     if (channel_layout == 0) {
+       const guint64 default_channel_set[] = {
+-        0, 0, CH_LAYOUT_SURROUND, CH_LAYOUT_QUAD, CH_LAYOUT_5POINT0,
+-        CH_LAYOUT_5POINT1, 0, CH_LAYOUT_7POINT1
++        0, 0, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_5POINT0,
++        AV_CH_LAYOUT_5POINT1, 0, AV_CH_LAYOUT_7POINT1
+       };
+ 
+       switch (codec_id) {
+@@ -1267,8 +1232,6 @@
+     case CODEC_ID_FLIC:
+     case CODEC_ID_VMDVIDEO:
+     case CODEC_ID_VMDAUDIO:
+-    case CODEC_ID_SONIC:
+-    case CODEC_ID_SONIC_LS:
+     case CODEC_ID_SNOW:
+     case CODEC_ID_VIXL:
+     case CODEC_ID_QPEG:
+@@ -1689,11 +1652,6 @@
+       gst_buffer_unref (data);
+     }
+ 
+-    /* palette */
+-    if (context) {
+-      gst_ffmpeg_set_palette (caps, context);
+-    }
+-
+     GST_LOG ("caps for codec_id=%d: %" GST_PTR_FORMAT, codec_id, caps);
+ 
+   } else {
+@@ -1830,9 +1788,6 @@
+             "bpp", G_TYPE_INT, bpp,
+             "depth", G_TYPE_INT, depth,
+             "endianness", G_TYPE_INT, endianness, NULL);
+-        if (caps && context) {
+-          gst_ffmpeg_set_palette (caps, context);
+-        }
+       }
+     } else if (fmt) {
+       caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-yuv",
+@@ -1857,7 +1812,7 @@
+  */
+ 
+ static GstCaps *
+-gst_ffmpeg_smpfmt_to_caps (enum SampleFormat sample_fmt,
++gst_ffmpeg_smpfmt_to_caps (enum AVSampleFormat sample_fmt,
+     AVCodecContext * context, enum CodecID codec_id)
+ {
+   GstCaps *caps = NULL;
+@@ -1867,22 +1822,22 @@
+   gboolean signedness = FALSE;
+ 
+   switch (sample_fmt) {
+-    case SAMPLE_FMT_S16:
++    case AV_SAMPLE_FMT_S16:
+       signedness = TRUE;
+       bpp = 16;
+       break;
+ 
+-    case SAMPLE_FMT_S32:
++    case AV_SAMPLE_FMT_S32:
+       signedness = TRUE;
+       bpp = 32;
+       break;
+ 
+-    case SAMPLE_FMT_FLT:
++    case AV_SAMPLE_FMT_FLT:
+       integer = FALSE;
+       bpp = 32;
+       break;
+ 
+-    case SAMPLE_FMT_DBL:
++    case AV_SAMPLE_FMT_DBL:
+       integer = FALSE;
+       bpp = 64;
+       break;
+@@ -1941,12 +1896,12 @@
+     }
+   } else {
+     GstCaps *temp;
+-    enum SampleFormat i;
++    enum AVSampleFormat i;
+     AVCodecContext ctx = { 0, };
+ 
+     ctx.channels = -1;
+     caps = gst_caps_new_empty ();
+-    for (i = 0; i <= SAMPLE_FMT_DBL; i++) {
++    for (i = 0; i <= AV_SAMPLE_FMT_DBL; i++) {
+       temp = gst_ffmpeg_smpfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
+       if (temp != NULL) {
+         gst_caps_append (caps, temp);
+@@ -2049,9 +2004,9 @@
+         gst_structure_get_int (structure, "endianness", &endianness)) {
+       if (endianness == G_BYTE_ORDER) {
+         if (width == 32)
+-          context->sample_fmt = SAMPLE_FMT_FLT;
++          context->sample_fmt = AV_SAMPLE_FMT_FLT;
+         else if (width == 64)
+-          context->sample_fmt = SAMPLE_FMT_DBL;
++          context->sample_fmt = AV_SAMPLE_FMT_DBL;
+       }
+     }
+   } else {
+@@ -2062,9 +2017,9 @@
+         gst_structure_get_int (structure, "endianness", &endianness)) {
+       if ((endianness == G_BYTE_ORDER) && (signedness == TRUE)) {
+         if ((width == 16) && (depth == 16))
+-          context->sample_fmt = SAMPLE_FMT_S16;
++          context->sample_fmt = AV_SAMPLE_FMT_S16;
+         else if ((width == 32) && (depth == 32))
+-          context->sample_fmt = SAMPLE_FMT_S32;
++          context->sample_fmt = AV_SAMPLE_FMT_S32;
+       }
+     }
+   }
+@@ -2190,7 +2145,6 @@
+       } else {
+         if (bpp == 8) {
+           context->pix_fmt = PIX_FMT_PAL8;
+-          gst_ffmpeg_get_palette (caps, context);
+         }
+       }
+     }
+@@ -2576,7 +2530,6 @@
+   switch (codec_type) {
+     case AVMEDIA_TYPE_VIDEO:
+       gst_ffmpeg_caps_to_pixfmt (caps, context, codec_id == CODEC_ID_RAWVIDEO);
+-      gst_ffmpeg_get_palette (caps, context);
+       break;
+     case AVMEDIA_TYPE_AUDIO:
+       gst_ffmpeg_caps_to_smpfmt (caps, context, FALSE);
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.orig
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.orig	1970-01-01 01:00:00.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.orig	2014-08-08 15:30:34.006867097 +0200
+@@ -0,0 +1,3447 @@
++/* GStreamer
++ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
++ * This file:
++ * Copyright (c) 2002-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 <gst/gst.h>
++#ifdef HAVE_FFMPEG_UNINSTALLED
++#include <avcodec.h>
++#include <channel_layout.h>>
++#else
++#include <libavcodec/avcodec.h>
++#include <libavutil/channel_layout.h>
++#endif
++#include <string.h>
++
++#include "gstffmpeg.h"
++#include "gstffmpegcodecmap.h"
++
++#include <gst/pbutils/codec-utils.h>
++
++/*
++ * Read a palette from a caps.
++ */
++
++static void
++gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
++{
++  GstStructure *str = gst_caps_get_structure (caps, 0);
++  const GValue *palette_v;
++  const GstBuffer *palette;
++
++  /* do we have a palette? */
++  if ((palette_v = gst_structure_get_value (str, "palette_data")) && context) {
++    palette = gst_value_get_buffer (palette_v);
++    if (GST_BUFFER_SIZE (palette) >= AVPALETTE_SIZE) {
++      if (context->palctrl)
++        av_free (context->palctrl);
++      context->palctrl = av_malloc (sizeof (AVPaletteControl));
++      context->palctrl->palette_changed = 1;
++      memcpy (context->palctrl->palette, GST_BUFFER_DATA (palette),
++          AVPALETTE_SIZE);
++    }
++  }
++}
++
++static void
++gst_ffmpeg_set_palette (GstCaps * caps, AVCodecContext * context)
++{
++  if (context->palctrl) {
++    GstBuffer *palette = gst_buffer_new_and_alloc (AVPALETTE_SIZE);
++
++    memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
++        AVPALETTE_SIZE);
++    gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, palette, NULL);
++  }
++}
++
++/* IMPORTANT: Keep this sorted by the ffmpeg channel masks */
++static const struct
++{
++  guint64 ff;
++  GstAudioChannelPosition gst;
++} _ff_to_gst_layout[] = {
++  {
++  AV_CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
++  AV_CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
++  AV_CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
++  AV_CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
++  AV_CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
++  AV_CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
++  AV_CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
++  AV_CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
++  AV_CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
++  AV_CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
++  AV_CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
++  AV_CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
++  AV_CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
++  AV_CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
++};
++
++static GstAudioChannelPosition *
++gst_ff_channel_layout_to_gst (guint64 channel_layout, guint channels)
++{
++  guint nchannels = 0, i, j;
++  GstAudioChannelPosition *pos = NULL;
++  gboolean none_layout = FALSE;
++
++  for (i = 0; i < 64; i++) {
++    if ((channel_layout & (G_GUINT64_CONSTANT (1) << i)) != 0) {
++      nchannels++;
++    }
++  }
++
++  if (channel_layout == 0) {
++    nchannels = channels;
++    none_layout = TRUE;
++  }
++
++  if (nchannels != channels) {
++    GST_ERROR ("Number of channels is different (%u != %u)", channels,
++        nchannels);
++    return NULL;
++  }
++
++  pos = g_new (GstAudioChannelPosition, nchannels);
++
++  for (i = 0, j = 0; i < G_N_ELEMENTS (_ff_to_gst_layout); i++) {
++    if ((channel_layout & _ff_to_gst_layout[i].ff) != 0) {
++      pos[j++] = _ff_to_gst_layout[i].gst;
++
++      if (_ff_to_gst_layout[i].gst == GST_AUDIO_CHANNEL_POSITION_NONE)
++        none_layout = TRUE;
++    }
++  }
++
++  if (j != nchannels) {
++    GST_WARNING ("Unknown channels in channel layout - assuming NONE layout");
++    none_layout = TRUE;
++  }
++
++  if (!none_layout && !gst_audio_check_channel_positions (pos, nchannels)) {
++    GST_ERROR ("Invalid channel layout %" G_GUINT64_FORMAT
++        " - assuming NONE layout", channel_layout);
++    none_layout = TRUE;
++  }
++
++  if (none_layout) {
++    if (nchannels == 1) {
++      pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_MONO;
++    } else if (nchannels == 2) {
++      pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
++      pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
++    } else if (channel_layout == 0) {
++      g_free (pos);
++      pos = NULL;
++    } else {
++      for (i = 0; i < nchannels; i++)
++        pos[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
++    }
++  }
++
++  if (nchannels == 1 && pos[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER) {
++    GST_DEBUG ("mono common case; won't set channel positions");
++    g_free (pos);
++    pos = NULL;
++  } else if (nchannels == 2 && pos[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT
++      && pos[1] == GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT) {
++    GST_DEBUG ("stereo common case; won't set channel positions");
++    g_free (pos);
++    pos = NULL;
++  }
++
++  return pos;
++}
++
++/* this macro makes a caps width fixed or unfixed width/height
++ * properties depending on whether we've got a context.
++ *
++ * See below for why we use this.
++ *
++ * We should actually do this stuff at the end, like in riff-media.c,
++ * but I'm too lazy today. Maybe later.
++ */
++static GstCaps *
++gst_ff_vid_caps_new (AVCodecContext * context, enum CodecID codec_id,
++    const char *mimetype, const char *fieldname, ...)
++{
++  GstStructure *structure = NULL;
++  GstCaps *caps = NULL;
++  va_list var_args;
++  gint i;
++
++  GST_LOG ("context:%p, codec_id:%d, mimetype:%s", context, codec_id, mimetype);
++
++  /* fixed, non probing context */
++  if (context != NULL && context->width != -1) {
++    gint num, denom;
++
++    caps = gst_caps_new_simple (mimetype,
++        "width", G_TYPE_INT, context->width,
++        "height", G_TYPE_INT, context->height, NULL);
++
++    num = context->time_base.den / context->ticks_per_frame;
++    denom = context->time_base.num;
++
++    if (!denom) {
++      GST_LOG ("invalid framerate: %d/0, -> %d/1", num, num);
++      denom = 1;
++    }
++    if (gst_util_fraction_compare (num, denom, 1000, 1) > 0) {
++      GST_LOG ("excessive framerate: %d/%d, -> 0/1", num, denom);
++      num = 0;
++      denom = 1;
++    }
++    GST_LOG ("setting framerate: %d/%d", num, denom);
++    gst_caps_set_simple (caps,
++        "framerate", GST_TYPE_FRACTION, num, denom, NULL);
++  } else {
++    /* so we are after restricted caps in this case */
++    switch (codec_id) {
++      case CODEC_ID_H261:
++      {
++        caps = gst_caps_new_simple (mimetype,
++            "width", G_TYPE_INT, 352,
++            "height", G_TYPE_INT, 288,
++            "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
++        gst_caps_append (caps, gst_caps_new_simple (mimetype,
++                "width", G_TYPE_INT, 176,
++                "height", G_TYPE_INT, 144,
++                "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL));
++        break;
++      }
++      case CODEC_ID_H263:
++      {
++        /* 128x96, 176x144, 352x288, 704x576, and 1408x1152. slightly reordered
++         * because we want automatic negotiation to go as close to 320x240 as
++         * possible. */
++        const static gint widths[] = { 352, 704, 176, 1408, 128 };
++        const static gint heights[] = { 288, 576, 144, 1152, 96 };
++        GstCaps *temp;
++        gint n_sizes = G_N_ELEMENTS (widths);
++
++        caps = gst_caps_new_empty ();
++        for (i = 0; i < n_sizes; i++) {
++          temp = gst_caps_new_simple (mimetype,
++              "width", G_TYPE_INT, widths[i],
++              "height", G_TYPE_INT, heights[i],
++              "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
++
++          gst_caps_append (caps, temp);
++        }
++        break;
++      }
++      case CODEC_ID_DVVIDEO:
++      {
++        static struct
++        {
++          guint32 csp;
++          gint width, height;
++          gint par_n, par_d;
++          gint framerate_n, framerate_d;
++        } profiles[] = {
++          {
++          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 480, 10, 11, 30000, 1001}, {
++          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 480, 40, 33, 30000, 1001}, {
++          GST_MAKE_FOURCC ('I', '4', '2', '0'), 720, 576, 59, 54, 25, 1}, {
++          GST_MAKE_FOURCC ('I', '4', '2', '0'), 720, 576, 118, 81, 25, 1}, {
++          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 576, 59, 54, 25, 1}, {
++          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 576, 118, 81, 25, 1}
++        };
++        GstCaps *temp;
++        gint n_sizes = G_N_ELEMENTS (profiles);
++
++        caps = gst_caps_new_empty ();
++        for (i = 0; i < n_sizes; i++) {
++          temp = gst_caps_new_simple (mimetype,
++              "width", G_TYPE_INT, profiles[i].width,
++              "height", G_TYPE_INT, profiles[i].height,
++              "framerate", GST_TYPE_FRACTION, profiles[i].framerate_n,
++              profiles[i].framerate_d, "pixel-aspect-ratio", GST_TYPE_FRACTION,
++              profiles[i].par_n, profiles[i].par_d, NULL);
++
++          gst_caps_append (caps, temp);
++        }
++        break;
++      }
++      case CODEC_ID_DNXHD:
++      {
++        caps = gst_caps_new_simple (mimetype,
++            "width", G_TYPE_INT, 1920,
++            "height", G_TYPE_INT, 1080,
++            "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
++        gst_caps_append (caps, gst_caps_new_simple (mimetype,
++                "width", G_TYPE_INT, 1280,
++                "height", G_TYPE_INT, 720,
++                "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL));
++        break;
++      }
++      default:
++        break;
++    }
++  }
++
++  /* no fixed caps or special restrictions applied;
++   * default unfixed setting */
++  if (!caps) {
++    GST_DEBUG ("Creating default caps");
++    caps = gst_caps_new_simple (mimetype,
++        "width", GST_TYPE_INT_RANGE, 16, 4096,
++        "height", GST_TYPE_INT_RANGE, 16, 4096,
++        "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
++  }
++
++  for (i = 0; i < gst_caps_get_size (caps); i++) {
++    va_start (var_args, fieldname);
++    structure = gst_caps_get_structure (caps, i);
++    gst_structure_set_valist (structure, fieldname, var_args);
++    va_end (var_args);
++  }
++
++  return caps;
++}
++
++/* same for audio - now with channels/sample rate
++ */
++static GstCaps *
++gst_ff_aud_caps_new (AVCodecContext * context, enum CodecID codec_id,
++    const char *mimetype, const char *fieldname, ...)
++{
++  GstCaps *caps = NULL;
++  GstStructure *structure = NULL;
++  gint i;
++  va_list var_args;
++
++  /* fixed, non-probing context */
++  if (context != NULL && context->channels != -1) {
++    GstAudioChannelPosition *pos;
++    guint64 channel_layout = context->channel_layout;
++
++    if (channel_layout == 0) {
++      const guint64 default_channel_set[] = {
++        0, 0, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_5POINT0,
++        AV_CH_LAYOUT_5POINT1, 0, AV_CH_LAYOUT_7POINT1
++      };
++
++      switch (codec_id) {
++        case CODEC_ID_EAC3:
++        case CODEC_ID_AC3:
++        case CODEC_ID_DTS:
++          if (context->channels > 0
++              && context->channels < G_N_ELEMENTS (default_channel_set))
++            channel_layout = default_channel_set[context->channels - 1];
++          break;
++        default:
++          break;
++      }
++    }
++
++    caps = gst_caps_new_simple (mimetype,
++        "rate", G_TYPE_INT, context->sample_rate,
++        "channels", G_TYPE_INT, context->channels, NULL);
++
++    pos = gst_ff_channel_layout_to_gst (channel_layout, context->channels);
++    if (pos != NULL) {
++      gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
++      g_free (pos);
++    }
++  } else {
++    gint maxchannels = 2;
++    const gint *rates = NULL;
++    gint n_rates = 0;
++
++    /* so we must be after restricted caps in this case */
++    switch (codec_id) {
++      case CODEC_ID_AAC:
++      case CODEC_ID_AAC_LATM:
++      case CODEC_ID_DTS:
++        maxchannels = 6;
++        break;
++      case CODEC_ID_MP2:
++      {
++        const static gint l_rates[] =
++            { 48000, 44100, 32000, 24000, 22050, 16000 };
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        break;
++      }
++      case CODEC_ID_EAC3:
++      case CODEC_ID_AC3:
++      {
++        const static gint l_rates[] = { 48000, 44100, 32000 };
++        maxchannels = 6;
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        break;
++      }
++      case CODEC_ID_ADPCM_G722:
++      {
++        const static gint l_rates[] = { 16000 };
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        maxchannels = 1;
++        break;
++      }
++      case CODEC_ID_ADPCM_G726:
++      {
++        const static gint l_rates[] = { 8000 };
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        maxchannels = 1;
++        break;
++      }
++      case CODEC_ID_ADPCM_SWF:
++      {
++        const static gint l_rates[] = { 11025, 22050, 44100 };
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        break;
++      }
++      case CODEC_ID_ROQ_DPCM:
++      {
++        const static gint l_rates[] = { 22050 };
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        break;
++      }
++      case CODEC_ID_AMR_NB:
++      {
++        const static gint l_rates[] = { 8000 };
++        maxchannels = 1;
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        break;
++      }
++      case CODEC_ID_AMR_WB:
++      {
++        const static gint l_rates[] = { 16000 };
++        maxchannels = 1;
++        n_rates = G_N_ELEMENTS (l_rates);
++        rates = l_rates;
++        break;
++      }
++      default:
++        break;
++    }
++
++    /* TODO: handle context->channel_layouts here to set
++     * the list of channel layouts supported by the encoder.
++     * Unfortunately no encoder uses this yet....
++     */
++    /* regardless of encode/decode, open up channels if applicable */
++    /* Until decoders/encoders expose the maximum number of channels
++     * they support, we whitelist them here. */
++    switch (codec_id) {
++      case CODEC_ID_WMAPRO:
++      case CODEC_ID_TRUEHD:
++        maxchannels = 8;
++        break;
++      default:
++        break;
++    }
++
++    if (maxchannels == 1)
++      caps = gst_caps_new_simple (mimetype,
++          "channels", G_TYPE_INT, maxchannels, NULL);
++    else
++      caps = gst_caps_new_simple (mimetype,
++          "channels", GST_TYPE_INT_RANGE, 1, maxchannels, NULL);
++    if (n_rates) {
++      GValue list = { 0, };
++      GstStructure *structure;
++
++      g_value_init (&list, GST_TYPE_LIST);
++      for (i = 0; i < n_rates; i++) {
++        GValue v = { 0, };
++
++        g_value_init (&v, G_TYPE_INT);
++        g_value_set_int (&v, rates[i]);
++        gst_value_list_append_value (&list, &v);
++        g_value_unset (&v);
++      }
++      structure = gst_caps_get_structure (caps, 0);
++      gst_structure_set_value (structure, "rate", &list);
++      g_value_unset (&list);
++    } else
++      gst_caps_set_simple (caps, "rate", GST_TYPE_INT_RANGE, 4000, 96000, NULL);
++  }
++
++  for (i = 0; i < gst_caps_get_size (caps); i++) {
++    va_start (var_args, fieldname);
++    structure = gst_caps_get_structure (caps, i);
++    gst_structure_set_valist (structure, fieldname, var_args);
++    va_end (var_args);
++  }
++
++  return caps;
++}
++
++/* Convert a FFMPEG codec ID and optional AVCodecContext
++ * to a GstCaps. If the context is ommitted, no fixed values
++ * for video/audio size will be included in the GstCaps
++ *
++ * CodecID is primarily meant for compressed data GstCaps!
++ *
++ * encode is a special parameter. gstffmpegdec will say
++ * FALSE, gstffmpegenc will say TRUE. The output caps
++ * depends on this, in such a way that it will be very
++ * specific, defined, fixed and correct caps for encoders,
++ * yet very wide, "forgiving" caps for decoders. Example
++ * for mp3: decode: audio/mpeg,mpegversion=1,layer=[1-3]
++ * but encode: audio/mpeg,mpegversion=1,layer=3,bitrate=x,
++ * rate=x,channels=x.
++ */
++
++GstCaps *
++gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
++    AVCodecContext * context, gboolean encode)
++{
++  GstCaps *caps = NULL;
++  gboolean buildcaps = FALSE;
++
++  GST_LOG ("codec_id:%d, context:%p, encode:%d", codec_id, context, encode);
++
++  switch (codec_id) {
++    case CODEC_ID_MPEG1VIDEO:
++      /* FIXME: bitrate */
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
++          "mpegversion", G_TYPE_INT, 1,
++          "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
++      break;
++
++    case CODEC_ID_MPEG2VIDEO:
++      if (encode) {
++        /* FIXME: bitrate */
++        caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
++            "mpegversion", G_TYPE_INT, 2,
++            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
++      } else {
++        /* decode both MPEG-1 and MPEG-2; width/height/fps are all in
++         * the MPEG video stream headers, so may be omitted from caps. */
++        caps = gst_caps_new_simple ("video/mpeg",
++            "mpegversion", GST_TYPE_INT_RANGE, 1, 2,
++            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
++      }
++      break;
++
++    case CODEC_ID_MPEG2VIDEO_XVMC:
++      /* this is a special ID - don't need it in GStreamer, I think */
++      break;
++
++    case CODEC_ID_H263:
++      if (encode) {
++        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h263",
++            "variant", G_TYPE_STRING, "itu",
++            "h263version", G_TYPE_STRING, "h263", NULL);
++      } else {
++        /* don't pass codec_id, we can decode other variants with the H263
++         * decoder that don't have specific size requirements
++         */
++        caps = gst_ff_vid_caps_new (context, CODEC_ID_NONE, "video/x-h263",
++            "variant", G_TYPE_STRING, "itu", NULL);
++      }
++      break;
++
++    case CODEC_ID_H263P:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h263",
++          "variant", G_TYPE_STRING, "itu",
++          "h263version", G_TYPE_STRING, "h263p", NULL);
++      if (encode && context) {
++
++        gst_caps_set_simple (caps,
++            "annex-f", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_4MV,
++            "annex-j", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_LOOP_FILTER,
++            "annex-i", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_AC_PRED,
++            "annex-t", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_AC_PRED,
++            NULL);
++      }
++      break;
++
++    case CODEC_ID_H263I:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-intel-h263",
++          "variant", G_TYPE_STRING, "intel", NULL);
++      break;
++
++    case CODEC_ID_H261:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h261", NULL);
++      break;
++
++    case CODEC_ID_RV10:
++    case CODEC_ID_RV20:
++    case CODEC_ID_RV30:
++    case CODEC_ID_RV40:
++    {
++      gint version;
++
++      switch (codec_id) {
++        case CODEC_ID_RV40:
++          version = 4;
++          break;
++        case CODEC_ID_RV30:
++          version = 3;
++          break;
++        case CODEC_ID_RV20:
++          version = 2;
++          break;
++        default:
++          version = 1;
++          break;
++      }
++
++      /* FIXME: context->sub_id must be filled in during decoding */
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-pn-realvideo",
++          "systemstream", G_TYPE_BOOLEAN, FALSE,
++          "rmversion", G_TYPE_INT, version, NULL);
++      if (context) {
++        gst_caps_set_simple (caps, "format", G_TYPE_INT, context->sub_id, NULL);
++        if (context->extradata_size >= 8) {
++          gst_caps_set_simple (caps,
++              "subformat", G_TYPE_INT, GST_READ_UINT32_BE (context->extradata),
++              NULL);
++        }
++      }
++    }
++      break;
++
++    case CODEC_ID_MP1:
++      /* FIXME: bitrate */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
++          "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 1, NULL);
++      break;
++
++    case CODEC_ID_MP2:
++      /* FIXME: bitrate */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
++          "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 2, NULL);
++      break;
++
++    case CODEC_ID_MP3:
++      if (encode) {
++        /* FIXME: bitrate */
++        caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
++            "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
++      } else {
++        /* Decodes MPEG-1 layer 1/2/3. Samplerate, channels et al are
++         * in the MPEG audio header, so may be omitted from caps. */
++        caps = gst_caps_new_simple ("audio/mpeg",
++            "mpegversion", G_TYPE_INT, 1,
++            "layer", GST_TYPE_INT_RANGE, 1, 3, NULL);
++      }
++      break;
++
++    case CODEC_ID_MUSEPACK7:
++      caps =
++          gst_ff_aud_caps_new (context, codec_id,
++          "audio/x-ffmpeg-parsed-musepack", "streamversion", G_TYPE_INT, 7,
++          NULL);
++      break;
++
++    case CODEC_ID_MUSEPACK8:
++      caps =
++          gst_ff_aud_caps_new (context, codec_id,
++          "audio/x-ffmpeg-parsed-musepack", "streamversion", G_TYPE_INT, 8,
++          NULL);
++      break;
++
++    case CODEC_ID_AC3:
++      /* FIXME: bitrate */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-ac3", NULL);
++      break;
++
++    case CODEC_ID_EAC3:
++      /* FIXME: bitrate */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-eac3", NULL);
++      break;
++
++    case CODEC_ID_TRUEHD:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-true-hd", NULL);
++      break;
++
++    case CODEC_ID_ATRAC1:
++      caps =
++          gst_ff_aud_caps_new (context, codec_id, "audio/x-vnd.sony.atrac1",
++          NULL);
++      break;
++
++    case CODEC_ID_ATRAC3:
++      caps =
++          gst_ff_aud_caps_new (context, codec_id, "audio/x-vnd.sony.atrac3",
++          NULL);
++      break;
++
++    case CODEC_ID_DTS:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dts", NULL);
++      break;
++
++    case CODEC_ID_APE:
++      caps =
++          gst_ff_aud_caps_new (context, codec_id, "audio/x-ffmpeg-parsed-ape",
++          NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "depth", G_TYPE_INT, context->bits_per_coded_sample, NULL);
++      }
++      break;
++
++    case CODEC_ID_MLP:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mlp", NULL);
++      break;
++
++    case CODEC_ID_IMC:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-imc", NULL);
++      break;
++
++      /* MJPEG is normal JPEG, Motion-JPEG and Quicktime MJPEG-A. MJPEGB
++       * is Quicktime's MJPEG-B. LJPEG is lossless JPEG. I don't know what
++       * sp5x is, but it's apparently something JPEG... We don't separate
++       * between those in GStreamer. Should we (at least between MJPEG,
++       * MJPEG-B and sp5x decoding...)? */
++    case CODEC_ID_MJPEG:
++    case CODEC_ID_LJPEG:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/jpeg", NULL);
++      break;
++
++    case CODEC_ID_SP5X:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/sp5x", NULL);
++      break;
++
++    case CODEC_ID_MJPEGB:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mjpeg-b", NULL);
++      break;
++
++    case CODEC_ID_MPEG4:
++      if (encode && context != NULL) {
++        /* I'm not exactly sure what ffmpeg outputs... ffmpeg itself uses
++         * the AVI fourcc 'DIVX', but 'mp4v' for Quicktime... */
++        switch (context->codec_tag) {
++          case GST_MAKE_FOURCC ('D', 'I', 'V', 'X'):
++            caps = gst_ff_vid_caps_new (context, codec_id, "video/x-divx",
++                "divxversion", G_TYPE_INT, 5, NULL);
++            break;
++          case GST_MAKE_FOURCC ('m', 'p', '4', 'v'):
++          default:
++            /* FIXME: bitrate */
++            caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
++                "systemstream", G_TYPE_BOOLEAN, FALSE,
++                "mpegversion", G_TYPE_INT, 4, NULL);
++            break;
++        }
++      } else {
++        /* The trick here is to separate xvid, divx, mpeg4, 3ivx et al */
++        caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
++            "mpegversion", G_TYPE_INT, 4,
++            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
++        if (encode) {
++          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
++                  "video/x-divx", "divxversion", G_TYPE_INT, 5, NULL));
++        } else {
++          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
++                  "video/x-divx", "divxversion", GST_TYPE_INT_RANGE, 4, 5,
++                  NULL));
++          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
++                  "video/x-xvid", NULL));
++          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
++                  "video/x-3ivx", NULL));
++        }
++      }
++      break;
++
++    case CODEC_ID_RAWVIDEO:
++      caps =
++          gst_ffmpeg_codectype_to_caps (AVMEDIA_TYPE_VIDEO, context, codec_id,
++          encode);
++      break;
++
++    case CODEC_ID_MSMPEG4V1:
++    case CODEC_ID_MSMPEG4V2:
++    case CODEC_ID_MSMPEG4V3:
++    {
++      gint version = 41 + codec_id - CODEC_ID_MSMPEG4V1;
++
++      /* encode-FIXME: bitrate */
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-msmpeg",
++          "msmpegversion", G_TYPE_INT, version, NULL);
++      if (!encode && codec_id == CODEC_ID_MSMPEG4V3) {
++        gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
++                "video/x-divx", "divxversion", G_TYPE_INT, 3, NULL));
++      }
++    }
++      break;
++
++    case CODEC_ID_WMV1:
++    case CODEC_ID_WMV2:
++    {
++      gint version = (codec_id == CODEC_ID_WMV1) ? 1 : 2;
++
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
++          "wmvversion", G_TYPE_INT, version, NULL);
++    }
++      break;
++
++    case CODEC_ID_FLV1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-flash-video",
++          "flvversion", G_TYPE_INT, 1, NULL);
++      break;
++
++    case CODEC_ID_SVQ1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-svq",
++          "svqversion", G_TYPE_INT, 1, NULL);
++      break;
++
++    case CODEC_ID_SVQ3:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-svq",
++          "svqversion", G_TYPE_INT, 3, NULL);
++      break;
++
++    case CODEC_ID_DVAUDIO:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dv", NULL);
++      break;
++
++    case CODEC_ID_DVVIDEO:
++    {
++      if (encode && context) {
++        guint32 fourcc;
++
++        switch (context->pix_fmt) {
++          case PIX_FMT_YUYV422:
++            fourcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
++            break;
++          case PIX_FMT_YUV420P:
++            fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
++            break;
++          case PIX_FMT_YUVA420P:
++            fourcc = GST_MAKE_FOURCC ('A', '4', '2', '0');
++            break;
++          case PIX_FMT_YUV411P:
++            fourcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
++            break;
++          case PIX_FMT_YUV422P:
++            fourcc = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
++            break;
++          case PIX_FMT_YUV410P:
++            fourcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
++            break;
++          default:
++            GST_WARNING
++                ("Couldnt' find fourcc for pixfmt %d, defaulting to I420",
++                context->pix_fmt);
++            fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
++            break;
++        }
++        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dv",
++            "systemstream", G_TYPE_BOOLEAN, FALSE,
++            "format", GST_TYPE_FOURCC, fourcc, NULL);
++      } else {
++        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dv",
++            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
++      }
++    }
++      break;
++
++    case CODEC_ID_WMAV1:
++    case CODEC_ID_WMAV2:
++    {
++      gint version = (codec_id == CODEC_ID_WMAV1) ? 1 : 2;
++
++      if (context) {
++        caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
++            "wmaversion", G_TYPE_INT, version,
++            "block_align", G_TYPE_INT, context->block_align,
++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++      } else {
++        caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
++            "wmaversion", G_TYPE_INT, version,
++            "block_align", GST_TYPE_INT_RANGE, 0, G_MAXINT,
++            "bitrate", GST_TYPE_INT_RANGE, 0, G_MAXINT, NULL);
++      }
++    }
++      break;
++    case CODEC_ID_WMAPRO:
++    {
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
++          "wmaversion", G_TYPE_INT, 3, NULL);
++      break;
++    }
++
++    case CODEC_ID_WMAVOICE:
++    {
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wms", NULL);
++      break;
++    }
++
++    case CODEC_ID_MACE3:
++    case CODEC_ID_MACE6:
++    {
++      gint version = (codec_id == CODEC_ID_MACE3) ? 3 : 6;
++
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mace",
++          "maceversion", G_TYPE_INT, version, NULL);
++    }
++      break;
++
++    case CODEC_ID_HUFFYUV:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-huffyuv", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "bpp", G_TYPE_INT, context->bits_per_coded_sample, NULL);
++      }
++      break;
++
++    case CODEC_ID_CYUV:
++      caps =
++          gst_ff_vid_caps_new (context, codec_id, "video/x-compressed-yuv",
++          NULL);
++      break;
++
++    case CODEC_ID_H264:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h264", NULL);
++      break;
++
++    case CODEC_ID_INDEO5:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
++          "indeoversion", G_TYPE_INT, 5, NULL);
++      break;
++
++    case CODEC_ID_INDEO3:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
++          "indeoversion", G_TYPE_INT, 3, NULL);
++      break;
++
++    case CODEC_ID_INDEO2:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
++          "indeoversion", G_TYPE_INT, 2, NULL);
++      break;
++
++    case CODEC_ID_FLASHSV:
++      caps =
++          gst_ff_vid_caps_new (context, codec_id, "video/x-flash-screen", NULL);
++      break;
++
++    case CODEC_ID_VP3:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp3", NULL);
++      break;
++
++    case CODEC_ID_VP5:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp5", NULL);
++      break;
++
++    case CODEC_ID_VP6:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6", NULL);
++      break;
++
++    case CODEC_ID_VP6F:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6-flash", NULL);
++      break;
++
++    case CODEC_ID_VP6A:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6-alpha", NULL);
++      break;
++
++    case CODEC_ID_VP8:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp8", NULL);
++      break;
++
++    case CODEC_ID_THEORA:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-theora", NULL);
++      break;
++
++    case CODEC_ID_AAC:
++    {
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg", NULL);
++
++      if (!encode) {
++        GValue arr = { 0, };
++        GValue item = { 0, };
++
++        g_value_init (&arr, GST_TYPE_LIST);
++        g_value_init (&item, G_TYPE_INT);
++        g_value_set_int (&item, 2);
++        gst_value_list_append_value (&arr, &item);
++        g_value_set_int (&item, 4);
++        gst_value_list_append_value (&arr, &item);
++        g_value_unset (&item);
++
++        gst_caps_set_value (caps, "mpegversion", &arr);
++        g_value_unset (&arr);
++
++        g_value_init (&arr, GST_TYPE_LIST);
++        g_value_init (&item, G_TYPE_STRING);
++        g_value_set_string (&item, "raw");
++        gst_value_list_append_value (&arr, &item);
++        g_value_set_string (&item, "adts");
++        gst_value_list_append_value (&arr, &item);
++        g_value_set_string (&item, "adif");
++        gst_value_list_append_value (&arr, &item);
++        g_value_unset (&item);
++
++        gst_caps_set_value (caps, "stream-format", &arr);
++        g_value_unset (&arr);
++      } else {
++        gst_caps_set_simple (caps, "mpegversion", G_TYPE_INT, 4,
++            "stream-format", G_TYPE_STRING, "raw",
++            "base-profile", G_TYPE_STRING, "lc", NULL);
++
++        if (context && context->extradata_size > 0)
++          gst_codec_utils_aac_caps_set_level_and_profile (caps,
++              context->extradata, context->extradata_size);
++      }
++
++      break;
++    }
++    case CODEC_ID_AAC_LATM:    /* LATM/LOAS AAC syntax */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
++          "mpegversion", G_TYPE_INT, 4, "stream-format", G_TYPE_STRING, "loas",
++          NULL);
++      break;
++
++    case CODEC_ID_ASV1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-asus",
++          "asusversion", G_TYPE_INT, 1, NULL);
++      break;
++    case CODEC_ID_ASV2:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-asus",
++          "asusversion", G_TYPE_INT, 2, NULL);
++      break;
++
++    case CODEC_ID_FFV1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ffv",
++          "ffvversion", G_TYPE_INT, 1, NULL);
++      break;
++
++    case CODEC_ID_4XM:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-4xm", NULL);
++      break;
++
++    case CODEC_ID_XAN_WC3:
++    case CODEC_ID_XAN_WC4:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-xan",
++          "wcversion", G_TYPE_INT, 3 - CODEC_ID_XAN_WC3 + codec_id, NULL);
++      break;
++
++    case CODEC_ID_CLJR:
++      caps =
++          gst_ff_vid_caps_new (context, codec_id,
++          "video/x-cirrus-logic-accupak", NULL);
++      break;
++
++    case CODEC_ID_FRAPS:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-fraps", NULL);
++      break;
++
++    case CODEC_ID_MDEC:
++    case CODEC_ID_ROQ:
++    case CODEC_ID_INTERPLAY_VIDEO:
++      buildcaps = TRUE;
++      break;
++
++    case CODEC_ID_VCR1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ati-vcr",
++          "vcrversion", G_TYPE_INT, 1, NULL);
++      break;
++
++    case CODEC_ID_RPZA:
++      caps =
++          gst_ff_vid_caps_new (context, codec_id, "video/x-apple-video", NULL);
++      break;
++
++    case CODEC_ID_CINEPAK:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-cinepak", NULL);
++      break;
++
++      /* WS_VQA belogns here (order) */
++
++    case CODEC_ID_MSRLE:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-rle",
++          "layout", G_TYPE_STRING, "microsoft", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
++      } else {
++        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 1, 64, NULL);
++      }
++      break;
++
++    case CODEC_ID_QTRLE:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-rle",
++          "layout", G_TYPE_STRING, "quicktime", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
++      } else {
++        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 1, 64, NULL);
++      }
++      break;
++
++    case CODEC_ID_MSVIDEO1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-msvideocodec",
++          "msvideoversion", G_TYPE_INT, 1, NULL);
++      break;
++
++    case CODEC_ID_WMV3:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
++          "wmvversion", G_TYPE_INT, 3, NULL);
++      break;
++    case CODEC_ID_VC1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
++          "wmvversion", G_TYPE_INT, 3, "format", GST_TYPE_FOURCC,
++          GST_MAKE_FOURCC ('W', 'V', 'C', '1'), NULL);
++      break;
++    case CODEC_ID_QDM2:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-qdm2", NULL);
++      break;
++
++    case CODEC_ID_MSZH:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mszh", NULL);
++      break;
++
++    case CODEC_ID_ZLIB:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-zlib", NULL);
++      break;
++
++    case CODEC_ID_TRUEMOTION1:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-truemotion",
++          "trueversion", G_TYPE_INT, 1, NULL);
++      break;
++    case CODEC_ID_TRUEMOTION2:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-truemotion",
++          "trueversion", G_TYPE_INT, 2, NULL);
++      break;
++
++    case CODEC_ID_ULTI:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ultimotion",
++          NULL);
++      break;
++
++    case CODEC_ID_TSCC:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-camtasia", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
++      } else {
++        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 8, 32, NULL);
++      }
++      break;
++
++    case CODEC_ID_KMVC:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-kmvc", NULL);
++      break;
++
++    case CODEC_ID_NUV:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-nuv", NULL);
++      break;
++
++    case CODEC_ID_GIF:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/gif", NULL);
++      break;
++
++    case CODEC_ID_PNG:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/png", NULL);
++      break;
++
++    case CODEC_ID_PPM:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/ppm", NULL);
++      break;
++
++    case CODEC_ID_PBM:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/pbm", NULL);
++      break;
++
++    case CODEC_ID_PAM:
++      caps =
++          gst_ff_vid_caps_new (context, codec_id, "image/x-portable-anymap",
++          NULL);
++      break;
++
++    case CODEC_ID_PGM:
++      caps =
++          gst_ff_vid_caps_new (context, codec_id, "image/x-portable-graymap",
++          NULL);
++      break;
++
++    case CODEC_ID_PCX:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-pcx", NULL);
++      break;
++
++    case CODEC_ID_SGI:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-sgi", NULL);
++      break;
++
++    case CODEC_ID_TARGA:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-tga", NULL);
++      break;
++
++    case CODEC_ID_TIFF:
++      caps = gst_ff_vid_caps_new (context, codec_id, "image/tiff", NULL);
++      break;
++
++    case CODEC_ID_SUNRAST:
++      caps =
++          gst_ff_vid_caps_new (context, codec_id, "image/x-sun-raster", NULL);
++      break;
++
++    case CODEC_ID_SMC:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-smc", NULL);
++      break;
++
++    case CODEC_ID_QDRAW:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-qdrw", NULL);
++      break;
++
++    case CODEC_ID_DNXHD:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dnxhd", NULL);
++      break;
++
++    case CODEC_ID_MIMIC:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mimic", NULL);
++      break;
++
++    case CODEC_ID_VMNC:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vmnc", NULL);
++      break;
++
++    case CODEC_ID_TRUESPEECH:
++      caps =
++          gst_ff_aud_caps_new (context, codec_id, "audio/x-truespeech", NULL);
++      break;
++
++    case CODEC_ID_QCELP:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/qcelp", NULL);
++      break;
++
++    case CODEC_ID_AMV:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-amv", NULL);
++      break;
++
++    case CODEC_ID_AASC:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-aasc", NULL);
++      break;
++
++    case CODEC_ID_LOCO:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-loco", NULL);
++      break;
++
++    case CODEC_ID_ZMBV:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-zmbv", NULL);
++      break;
++
++    case CODEC_ID_LAGARITH:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-lagarith", NULL);
++      break;
++
++    case CODEC_ID_CSCD:
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-camstudio", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
++      } else {
++        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 8, 32, NULL);
++      }
++      break;
++
++    case CODEC_ID_WS_VQA:
++    case CODEC_ID_IDCIN:
++    case CODEC_ID_8BPS:
++    case CODEC_ID_FLIC:
++    case CODEC_ID_VMDVIDEO:
++    case CODEC_ID_VMDAUDIO:
++    case CODEC_ID_SNOW:
++    case CODEC_ID_VIXL:
++    case CODEC_ID_QPEG:
++    case CODEC_ID_PGMYUV:
++    case CODEC_ID_FFVHUFF:
++    case CODEC_ID_WNV1:
++    case CODEC_ID_MP3ADU:
++    case CODEC_ID_MP3ON4:
++    case CODEC_ID_WESTWOOD_SND1:
++    case CODEC_ID_MMVIDEO:
++    case CODEC_ID_AVS:
++    case CODEC_ID_CAVS:
++      buildcaps = TRUE;
++      break;
++
++      /* weird quasi-codecs for the demuxers only */
++    case CODEC_ID_PCM_S16LE:
++    case CODEC_ID_PCM_S16BE:
++    case CODEC_ID_PCM_U16LE:
++    case CODEC_ID_PCM_U16BE:
++    case CODEC_ID_PCM_S8:
++    case CODEC_ID_PCM_U8:
++    {
++      gint width = 0, depth = 0, endianness = 0;
++      gboolean signedness = FALSE;      /* blabla */
++
++      switch (codec_id) {
++        case CODEC_ID_PCM_S16LE:
++          width = 16;
++          depth = 16;
++          endianness = G_LITTLE_ENDIAN;
++          signedness = TRUE;
++          break;
++        case CODEC_ID_PCM_S16BE:
++          width = 16;
++          depth = 16;
++          endianness = G_BIG_ENDIAN;
++          signedness = TRUE;
++          break;
++        case CODEC_ID_PCM_U16LE:
++          width = 16;
++          depth = 16;
++          endianness = G_LITTLE_ENDIAN;
++          signedness = FALSE;
++          break;
++        case CODEC_ID_PCM_U16BE:
++          width = 16;
++          depth = 16;
++          endianness = G_BIG_ENDIAN;
++          signedness = FALSE;
++          break;
++        case CODEC_ID_PCM_S8:
++          width = 8;
++          depth = 8;
++          endianness = G_BYTE_ORDER;
++          signedness = TRUE;
++          break;
++        case CODEC_ID_PCM_U8:
++          width = 8;
++          depth = 8;
++          endianness = G_BYTE_ORDER;
++          signedness = FALSE;
++          break;
++        default:
++          g_assert (0);         /* don't worry, we never get here */
++          break;
++      }
++
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-int",
++          "width", G_TYPE_INT, width,
++          "depth", G_TYPE_INT, depth,
++          "endianness", G_TYPE_INT, endianness,
++          "signed", G_TYPE_BOOLEAN, signedness, NULL);
++    }
++      break;
++
++    case CODEC_ID_PCM_MULAW:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mulaw", NULL);
++      break;
++
++    case CODEC_ID_PCM_ALAW:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-alaw", NULL);
++      break;
++
++    case CODEC_ID_ADPCM_G722:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/G722", NULL);
++      if (context)
++        gst_caps_set_simple (caps,
++            "block_align", G_TYPE_INT, context->block_align,
++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++      break;
++
++    case CODEC_ID_ADPCM_G726:
++    {
++      /* the G726 decoder can also handle G721 */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-adpcm",
++          "layout", G_TYPE_STRING, "g726", NULL);
++      if (context)
++        gst_caps_set_simple (caps,
++            "block_align", G_TYPE_INT, context->block_align,
++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++
++      if (!encode) {
++        gst_caps_append (caps, gst_caps_new_simple ("audio/x-adpcm",
++                "layout", G_TYPE_STRING, "g721",
++                "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL));
++      }
++      break;
++    }
++    case CODEC_ID_ADPCM_IMA_QT:
++    case CODEC_ID_ADPCM_IMA_WAV:
++    case CODEC_ID_ADPCM_IMA_DK3:
++    case CODEC_ID_ADPCM_IMA_DK4:
++    case CODEC_ID_ADPCM_IMA_WS:
++    case CODEC_ID_ADPCM_IMA_SMJPEG:
++    case CODEC_ID_ADPCM_IMA_AMV:
++    case CODEC_ID_ADPCM_IMA_ISS:
++    case CODEC_ID_ADPCM_IMA_EA_EACS:
++    case CODEC_ID_ADPCM_IMA_EA_SEAD:
++    case CODEC_ID_ADPCM_MS:
++    case CODEC_ID_ADPCM_4XM:
++    case CODEC_ID_ADPCM_XA:
++    case CODEC_ID_ADPCM_ADX:
++    case CODEC_ID_ADPCM_EA:
++    case CODEC_ID_ADPCM_CT:
++    case CODEC_ID_ADPCM_SWF:
++    case CODEC_ID_ADPCM_YAMAHA:
++    case CODEC_ID_ADPCM_SBPRO_2:
++    case CODEC_ID_ADPCM_SBPRO_3:
++    case CODEC_ID_ADPCM_SBPRO_4:
++    case CODEC_ID_ADPCM_EA_R1:
++    case CODEC_ID_ADPCM_EA_R2:
++    case CODEC_ID_ADPCM_EA_R3:
++    case CODEC_ID_ADPCM_EA_MAXIS_XA:
++    case CODEC_ID_ADPCM_EA_XAS:
++    case CODEC_ID_ADPCM_THP:
++    {
++      const gchar *layout = NULL;
++
++      switch (codec_id) {
++        case CODEC_ID_ADPCM_IMA_QT:
++          layout = "quicktime";
++          break;
++        case CODEC_ID_ADPCM_IMA_WAV:
++          layout = "dvi";
++          break;
++        case CODEC_ID_ADPCM_IMA_DK3:
++          layout = "dk3";
++          break;
++        case CODEC_ID_ADPCM_IMA_DK4:
++          layout = "dk4";
++          break;
++        case CODEC_ID_ADPCM_IMA_WS:
++          layout = "westwood";
++          break;
++        case CODEC_ID_ADPCM_IMA_SMJPEG:
++          layout = "smjpeg";
++          break;
++        case CODEC_ID_ADPCM_IMA_AMV:
++          layout = "amv";
++          break;
++        case CODEC_ID_ADPCM_IMA_ISS:
++          layout = "iss";
++          break;
++        case CODEC_ID_ADPCM_IMA_EA_EACS:
++          layout = "ea-eacs";
++          break;
++        case CODEC_ID_ADPCM_IMA_EA_SEAD:
++          layout = "ea-sead";
++          break;
++        case CODEC_ID_ADPCM_MS:
++          layout = "microsoft";
++          break;
++        case CODEC_ID_ADPCM_4XM:
++          layout = "4xm";
++          break;
++        case CODEC_ID_ADPCM_XA:
++          layout = "xa";
++          break;
++        case CODEC_ID_ADPCM_ADX:
++          layout = "adx";
++          break;
++        case CODEC_ID_ADPCM_EA:
++          layout = "ea";
++          break;
++        case CODEC_ID_ADPCM_CT:
++          layout = "ct";
++          break;
++        case CODEC_ID_ADPCM_SWF:
++          layout = "swf";
++          break;
++        case CODEC_ID_ADPCM_YAMAHA:
++          layout = "yamaha";
++          break;
++        case CODEC_ID_ADPCM_SBPRO_2:
++          layout = "sbpro2";
++          break;
++        case CODEC_ID_ADPCM_SBPRO_3:
++          layout = "sbpro3";
++          break;
++        case CODEC_ID_ADPCM_SBPRO_4:
++          layout = "sbpro4";
++          break;
++        case CODEC_ID_ADPCM_EA_R1:
++          layout = "ea-r1";
++          break;
++        case CODEC_ID_ADPCM_EA_R2:
++          layout = "ea-r3";
++          break;
++        case CODEC_ID_ADPCM_EA_R3:
++          layout = "ea-r3";
++          break;
++        case CODEC_ID_ADPCM_EA_MAXIS_XA:
++          layout = "ea-maxis-xa";
++          break;
++        case CODEC_ID_ADPCM_EA_XAS:
++          layout = "ea-xas";
++          break;
++        case CODEC_ID_ADPCM_THP:
++          layout = "thp";
++          break;
++        default:
++          g_assert (0);         /* don't worry, we never get here */
++          break;
++      }
++
++      /* FIXME: someone please check whether we need additional properties
++       * in this caps definition. */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-adpcm",
++          "layout", G_TYPE_STRING, layout, NULL);
++      if (context)
++        gst_caps_set_simple (caps,
++            "block_align", G_TYPE_INT, context->block_align,
++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++    }
++      break;
++
++    case CODEC_ID_AMR_NB:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/AMR", NULL);
++      break;
++
++    case CODEC_ID_AMR_WB:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/AMR-WB", NULL);
++      break;
++
++    case CODEC_ID_GSM:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-gsm", NULL);
++      break;
++
++    case CODEC_ID_GSM_MS:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/ms-gsm", NULL);
++      break;
++
++    case CODEC_ID_NELLYMOSER:
++      caps =
++          gst_ff_aud_caps_new (context, codec_id, "audio/x-nellymoser", NULL);
++      break;
++
++    case CODEC_ID_SIPR:
++    {
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-sipro", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "leaf_size", G_TYPE_INT, context->block_align,
++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++      }
++    }
++      break;
++
++    case CODEC_ID_RA_144:
++    case CODEC_ID_RA_288:
++    case CODEC_ID_COOK:
++    {
++      gint version = 0;
++
++      switch (codec_id) {
++        case CODEC_ID_RA_144:
++          version = 1;
++          break;
++        case CODEC_ID_RA_288:
++          version = 2;
++          break;
++        case CODEC_ID_COOK:
++          version = 8;
++          break;
++        default:
++          break;
++      }
++
++      /* FIXME: properties? */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-pn-realaudio",
++          "raversion", G_TYPE_INT, version, NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "leaf_size", G_TYPE_INT, context->block_align,
++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++      }
++    }
++      break;
++
++    case CODEC_ID_ROQ_DPCM:
++    case CODEC_ID_INTERPLAY_DPCM:
++    case CODEC_ID_XAN_DPCM:
++    case CODEC_ID_SOL_DPCM:
++    {
++      const gchar *layout = NULL;
++
++      switch (codec_id) {
++        case CODEC_ID_ROQ_DPCM:
++          layout = "roq";
++          break;
++        case CODEC_ID_INTERPLAY_DPCM:
++          layout = "interplay";
++          break;
++        case CODEC_ID_XAN_DPCM:
++          layout = "xan";
++          break;
++        case CODEC_ID_SOL_DPCM:
++          layout = "sol";
++          break;
++        default:
++          g_assert (0);         /* don't worry, we never get here */
++          break;
++      }
++
++      /* FIXME: someone please check whether we need additional properties
++       * in this caps definition. */
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dpcm",
++          "layout", G_TYPE_STRING, layout, NULL);
++      if (context)
++        gst_caps_set_simple (caps,
++            "block_align", G_TYPE_INT, context->block_align,
++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++    }
++      break;
++
++    case CODEC_ID_SHORTEN:
++      caps = gst_caps_new_simple ("audio/x-shorten", NULL);
++      break;
++
++    case CODEC_ID_ALAC:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-alac", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "samplesize", G_TYPE_INT, context->bits_per_coded_sample, NULL);
++      }
++      break;
++
++    case CODEC_ID_FLAC:
++      /* Note that ffmpeg has no encoder yet, but just for safety. In the
++       * encoder case, we want to add things like samplerate, channels... */
++      if (!encode) {
++        caps = gst_caps_new_simple ("audio/x-flac", NULL);
++      }
++      break;
++
++    case CODEC_ID_DVD_SUBTITLE:
++    case CODEC_ID_DVB_SUBTITLE:
++      caps = NULL;
++      break;
++    case CODEC_ID_BMP:
++      caps = gst_caps_new_simple ("image/bmp", NULL);
++      break;
++    case CODEC_ID_TTA:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-tta", NULL);
++      if (context) {
++        gst_caps_set_simple (caps,
++            "samplesize", G_TYPE_INT, context->bits_per_coded_sample, NULL);
++      }
++      break;
++    case CODEC_ID_TWINVQ:
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-twin-vq", NULL);
++      break;
++    default:
++      GST_DEBUG ("Unknown codec ID %d, please add mapping here", codec_id);
++      break;
++  }
++
++  if (buildcaps) {
++    AVCodec *codec;
++
++    if ((codec = avcodec_find_decoder (codec_id)) ||
++        (codec = avcodec_find_encoder (codec_id))) {
++      gchar *mime = NULL;
++
++      GST_LOG ("Could not create stream format caps for %s", codec->name);
++
++      switch (codec->type) {
++        case AVMEDIA_TYPE_VIDEO:
++          mime = g_strdup_printf ("video/x-gst_ff-%s", codec->name);
++          caps = gst_ff_vid_caps_new (context, codec_id, mime, NULL);
++          g_free (mime);
++          break;
++        case AVMEDIA_TYPE_AUDIO:
++          mime = g_strdup_printf ("audio/x-gst_ff-%s", codec->name);
++          caps = gst_ff_aud_caps_new (context, codec_id, mime, NULL);
++          if (context)
++            gst_caps_set_simple (caps,
++                "block_align", G_TYPE_INT, context->block_align,
++                "bitrate", G_TYPE_INT, context->bit_rate, NULL);
++          g_free (mime);
++          break;
++        default:
++          break;
++      }
++    }
++  }
++
++  if (caps != NULL) {
++
++    /* set private data */
++    if (context && context->extradata_size > 0) {
++      GstBuffer *data = gst_buffer_new_and_alloc (context->extradata_size);
++
++      memcpy (GST_BUFFER_DATA (data), context->extradata,
++          context->extradata_size);
++      gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, data, NULL);
++      gst_buffer_unref (data);
++    }
++
++    /* palette */
++    if (context) {
++      gst_ffmpeg_set_palette (caps, context);
++    }
++
++    GST_LOG ("caps for codec_id=%d: %" GST_PTR_FORMAT, codec_id, caps);
++
++  } else {
++    GST_LOG ("No caps found for codec_id=%d", codec_id);
++  }
++
++  return caps;
++}
++
++/* Convert a FFMPEG Pixel Format and optional AVCodecContext
++ * to a GstCaps. If the context is ommitted, no fixed values
++ * for video/audio size will be included in the GstCaps
++ *
++ * See below for usefullness
++ */
++
++GstCaps *
++gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context,
++    enum CodecID codec_id)
++{
++  GstCaps *caps = NULL;
++
++  int bpp = 0, depth = 0, endianness = 0;
++  gulong g_mask = 0, r_mask = 0, b_mask = 0, a_mask = 0;
++  guint32 fmt = 0;
++
++  switch (pix_fmt) {
++    case PIX_FMT_YUVJ420P:
++    case PIX_FMT_YUV420P:
++      fmt = GST_MAKE_FOURCC ('I', '4', '2', '0');
++      break;
++    case PIX_FMT_YUVA420P:
++      fmt = GST_MAKE_FOURCC ('A', '4', '2', '0');
++      break;
++    case PIX_FMT_YUYV422:
++      fmt = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
++      break;
++    case PIX_FMT_RGB24:
++      bpp = depth = 24;
++      endianness = G_BIG_ENDIAN;
++      r_mask = 0xff0000;
++      g_mask = 0x00ff00;
++      b_mask = 0x0000ff;
++      break;
++    case PIX_FMT_BGR24:
++      bpp = depth = 24;
++      endianness = G_BIG_ENDIAN;
++      r_mask = 0x0000ff;
++      g_mask = 0x00ff00;
++      b_mask = 0xff0000;
++      break;
++    case PIX_FMT_YUVJ422P:
++    case PIX_FMT_YUV422P:
++      fmt = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
++      break;
++    case PIX_FMT_YUVJ444P:
++    case PIX_FMT_YUV444P:
++      fmt = GST_MAKE_FOURCC ('Y', '4', '4', '4');
++      break;
++    case PIX_FMT_RGB32:
++      bpp = 32;
++      depth = 32;
++      endianness = G_BIG_ENDIAN;
++#if (G_BYTE_ORDER == G_BIG_ENDIAN)
++      r_mask = 0x00ff0000;
++      g_mask = 0x0000ff00;
++      b_mask = 0x000000ff;
++      a_mask = 0xff000000;
++#else
++      r_mask = 0x0000ff00;
++      g_mask = 0x00ff0000;
++      b_mask = 0xff000000;
++      a_mask = 0x000000ff;
++#endif
++      break;
++    case PIX_FMT_YUV410P:
++      fmt = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
++      break;
++    case PIX_FMT_YUV411P:
++      fmt = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
++      break;
++    case PIX_FMT_RGB565:
++      bpp = depth = 16;
++      endianness = G_BYTE_ORDER;
++      r_mask = 0xf800;
++      g_mask = 0x07e0;
++      b_mask = 0x001f;
++      break;
++    case PIX_FMT_RGB555:
++      bpp = 16;
++      depth = 15;
++      endianness = G_BYTE_ORDER;
++      r_mask = 0x7c00;
++      g_mask = 0x03e0;
++      b_mask = 0x001f;
++      break;
++    case PIX_FMT_PAL8:
++      bpp = depth = 8;
++      endianness = G_BYTE_ORDER;
++      break;
++    case PIX_FMT_GRAY8:
++      bpp = depth = 8;
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-gray",
++          "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, NULL);
++      break;
++    default:
++      /* give up ... */
++      break;
++  }
++
++  if (caps == NULL) {
++    if (bpp != 0) {
++      if (r_mask != 0) {
++        if (a_mask) {
++          caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
++              "bpp", G_TYPE_INT, bpp,
++              "depth", G_TYPE_INT, depth,
++              "red_mask", G_TYPE_INT, r_mask,
++              "green_mask", G_TYPE_INT, g_mask,
++              "blue_mask", G_TYPE_INT, b_mask,
++              "alpha_mask", G_TYPE_INT, a_mask,
++              "endianness", G_TYPE_INT, endianness, NULL);
++        } else {
++          caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
++              "bpp", G_TYPE_INT, bpp,
++              "depth", G_TYPE_INT, depth,
++              "red_mask", G_TYPE_INT, r_mask,
++              "green_mask", G_TYPE_INT, g_mask,
++              "blue_mask", G_TYPE_INT, b_mask,
++              "endianness", G_TYPE_INT, endianness, NULL);
++        }
++      } else {
++        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
++            "bpp", G_TYPE_INT, bpp,
++            "depth", G_TYPE_INT, depth,
++            "endianness", G_TYPE_INT, endianness, NULL);
++        if (caps && context) {
++          gst_ffmpeg_set_palette (caps, context);
++        }
++      }
++    } else if (fmt) {
++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-yuv",
++          "format", GST_TYPE_FOURCC, fmt, NULL);
++    }
++  }
++
++  if (caps != NULL) {
++    GST_DEBUG ("caps for pix_fmt=%d: %" GST_PTR_FORMAT, pix_fmt, caps);
++  } else {
++    GST_LOG ("No caps found for pix_fmt=%d", pix_fmt);
++  }
++
++  return caps;
++}
++
++/* Convert a FFMPEG Sample Format and optional AVCodecContext
++ * to a GstCaps. If the context is ommitted, no fixed values
++ * for video/audio size will be included in the GstCaps
++ *
++ * See below for usefullness
++ */
++
++static GstCaps *
++gst_ffmpeg_smpfmt_to_caps (enum AVSampleFormat sample_fmt,
++    AVCodecContext * context, enum CodecID codec_id)
++{
++  GstCaps *caps = NULL;
++
++  int bpp = 0;
++  gboolean integer = TRUE;
++  gboolean signedness = FALSE;
++
++  switch (sample_fmt) {
++    case AV_SAMPLE_FMT_S16:
++      signedness = TRUE;
++      bpp = 16;
++      break;
++
++    case AV_SAMPLE_FMT_S32:
++      signedness = TRUE;
++      bpp = 32;
++      break;
++
++    case AV_SAMPLE_FMT_FLT:
++      integer = FALSE;
++      bpp = 32;
++      break;
++
++    case AV_SAMPLE_FMT_DBL:
++      integer = FALSE;
++      bpp = 64;
++      break;
++    default:
++      /* .. */
++      break;
++  }
++
++  if (bpp) {
++    if (integer) {
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-int",
++          "signed", G_TYPE_BOOLEAN, signedness,
++          "endianness", G_TYPE_INT, G_BYTE_ORDER,
++          "width", G_TYPE_INT, bpp, "depth", G_TYPE_INT, bpp, NULL);
++    } else {
++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-float",
++          "endianness", G_TYPE_INT, G_BYTE_ORDER,
++          "width", G_TYPE_INT, bpp, NULL);
++    }
++  }
++
++  if (caps != NULL) {
++    GST_LOG ("caps for sample_fmt=%d: %" GST_PTR_FORMAT, sample_fmt, caps);
++  } else {
++    GST_LOG ("No caps found for sample_fmt=%d", sample_fmt);
++  }
++
++  return caps;
++}
++
++GstCaps *
++gst_ffmpeg_codectype_to_audio_caps (AVCodecContext * context,
++    enum CodecID codec_id, gboolean encode, AVCodec * codec)
++{
++  GstCaps *caps = NULL;
++
++  GST_DEBUG ("context:%p, codec_id:%d, encode:%d, codec:%p",
++      context, codec_id, encode, codec);
++  if (codec)
++    GST_DEBUG ("sample_fmts:%p, samplerates:%p",
++        codec->sample_fmts, codec->supported_samplerates);
++
++  if (context) {
++    /* Specific codec context */
++    caps = gst_ffmpeg_smpfmt_to_caps (context->sample_fmt, context, codec_id);
++  } else if (codec && codec->sample_fmts) {
++    GstCaps *temp;
++    int i;
++
++    caps = gst_caps_new_empty ();
++    for (i = 0; codec->sample_fmts[i] != -1; i++) {
++      temp =
++          gst_ffmpeg_smpfmt_to_caps (codec->sample_fmts[i], context, codec_id);
++      if (temp != NULL)
++        gst_caps_append (caps, temp);
++    }
++  } else {
++    GstCaps *temp;
++    enum AVSampleFormat i;
++    AVCodecContext ctx = { 0, };
++
++    ctx.channels = -1;
++    caps = gst_caps_new_empty ();
++    for (i = 0; i <= AV_SAMPLE_FMT_DBL; i++) {
++      temp = gst_ffmpeg_smpfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
++      if (temp != NULL) {
++        gst_caps_append (caps, temp);
++      }
++    }
++  }
++  return caps;
++}
++
++GstCaps *
++gst_ffmpeg_codectype_to_video_caps (AVCodecContext * context,
++    enum CodecID codec_id, gboolean encode, AVCodec * codec)
++{
++  GstCaps *caps;
++
++  GST_LOG ("context:%p, codec_id:%d, encode:%d, codec:%p",
++      context, codec_id, encode, codec);
++
++  if (context) {
++    caps = gst_ffmpeg_pixfmt_to_caps (context->pix_fmt, context, codec_id);
++  } else {
++    GstCaps *temp;
++    enum PixelFormat i;
++    AVCodecContext ctx = { 0, };
++
++    caps = gst_caps_new_empty ();
++    for (i = 0; i < PIX_FMT_NB; i++) {
++      ctx.width = -1;
++      ctx.pix_fmt = i;
++      temp = gst_ffmpeg_pixfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
++      if (temp != NULL) {
++        gst_caps_append (caps, temp);
++      }
++    }
++  }
++  return caps;
++}
++
++/* Convert a FFMPEG codec Type and optional AVCodecContext
++ * to a GstCaps. If the context is ommitted, no fixed values
++ * for video/audio size will be included in the GstCaps
++ *
++ * AVMediaType is primarily meant for uncompressed data GstCaps!
++ */
++
++GstCaps *
++gst_ffmpeg_codectype_to_caps (enum AVMediaType codec_type,
++    AVCodecContext * context, enum CodecID codec_id, gboolean encode)
++{
++  GstCaps *caps;
++
++  switch (codec_type) {
++    case AVMEDIA_TYPE_VIDEO:
++      caps =
++          gst_ffmpeg_codectype_to_video_caps (context, codec_id, encode, NULL);
++      break;
++    case AVMEDIA_TYPE_AUDIO:
++      caps =
++          gst_ffmpeg_codectype_to_audio_caps (context, codec_id, encode, NULL);
++      break;
++    default:
++      caps = NULL;
++      break;
++  }
++
++  return caps;
++}
++
++/* Convert a GstCaps (audio/raw) to a FFMPEG SampleFmt
++ * and other audio properties in a AVCodecContext.
++ *
++ * For usefullness, see below
++ */
++
++static void
++gst_ffmpeg_caps_to_smpfmt (const GstCaps * caps,
++    AVCodecContext * context, gboolean raw)
++{
++  GstStructure *structure;
++  gint depth = 0, width = 0, endianness = 0;
++  gboolean signedness = FALSE;
++  const gchar *name;
++
++  g_return_if_fail (gst_caps_get_size (caps) == 1);
++  structure = gst_caps_get_structure (caps, 0);
++
++  gst_structure_get_int (structure, "channels", &context->channels);
++  gst_structure_get_int (structure, "rate", &context->sample_rate);
++  gst_structure_get_int (structure, "block_align", &context->block_align);
++  gst_structure_get_int (structure, "bitrate", &context->bit_rate);
++
++  if (!raw)
++    return;
++
++  name = gst_structure_get_name (structure);
++
++  if (!strcmp (name, "audio/x-raw-float")) {
++    /* FLOAT */
++    if (gst_structure_get_int (structure, "width", &width) &&
++        gst_structure_get_int (structure, "endianness", &endianness)) {
++      if (endianness == G_BYTE_ORDER) {
++        if (width == 32)
++          context->sample_fmt = AV_SAMPLE_FMT_FLT;
++        else if (width == 64)
++          context->sample_fmt = AV_SAMPLE_FMT_DBL;
++      }
++    }
++  } else {
++    /* INT */
++    if (gst_structure_get_int (structure, "width", &width) &&
++        gst_structure_get_int (structure, "depth", &depth) &&
++        gst_structure_get_boolean (structure, "signed", &signedness) &&
++        gst_structure_get_int (structure, "endianness", &endianness)) {
++      if ((endianness == G_BYTE_ORDER) && (signedness == TRUE)) {
++        if ((width == 16) && (depth == 16))
++          context->sample_fmt = AV_SAMPLE_FMT_S16;
++        else if ((width == 32) && (depth == 32))
++          context->sample_fmt = AV_SAMPLE_FMT_S32;
++      }
++    }
++  }
++}
++
++
++/* Convert a GstCaps (video/raw) to a FFMPEG PixFmt
++ * and other video properties in a AVCodecContext.
++ *
++ * For usefullness, see below
++ */
++
++static void
++gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
++    AVCodecContext * context, gboolean raw)
++{
++  GstStructure *structure;
++  const GValue *fps;
++  const GValue *par = NULL;
++
++  GST_DEBUG ("converting caps %" GST_PTR_FORMAT, caps);
++  g_return_if_fail (gst_caps_get_size (caps) == 1);
++  structure = gst_caps_get_structure (caps, 0);
++
++  gst_structure_get_int (structure, "width", &context->width);
++  gst_structure_get_int (structure, "height", &context->height);
++  gst_structure_get_int (structure, "bpp", &context->bits_per_coded_sample);
++
++  fps = gst_structure_get_value (structure, "framerate");
++  if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
++
++    /* somehow these seem mixed up.. */
++    context->time_base.den = gst_value_get_fraction_numerator (fps);
++    context->time_base.num = gst_value_get_fraction_denominator (fps);
++    context->ticks_per_frame = 1;
++
++    GST_DEBUG ("setting framerate %d/%d = %lf",
++        context->time_base.den, context->time_base.num,
++        1. * context->time_base.den / context->time_base.num);
++  }
++
++  par = gst_structure_get_value (structure, "pixel-aspect-ratio");
++  if (par && GST_VALUE_HOLDS_FRACTION (par)) {
++
++    context->sample_aspect_ratio.num = gst_value_get_fraction_numerator (par);
++    context->sample_aspect_ratio.den = gst_value_get_fraction_denominator (par);
++
++    GST_DEBUG ("setting pixel-aspect-ratio %d/%d = %lf",
++        context->sample_aspect_ratio.den, context->sample_aspect_ratio.num,
++        1. * context->sample_aspect_ratio.den /
++        context->sample_aspect_ratio.num);
++  }
++
++  if (!raw)
++    return;
++
++  g_return_if_fail (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps));
++
++  if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
++    guint32 fourcc;
++
++    if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
++      switch (fourcc) {
++        case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
++          context->pix_fmt = PIX_FMT_YUYV422;
++          break;
++        case GST_MAKE_FOURCC ('I', '4', '2', '0'):
++          context->pix_fmt = PIX_FMT_YUV420P;
++          break;
++        case GST_MAKE_FOURCC ('A', '4', '2', '0'):
++          context->pix_fmt = PIX_FMT_YUVA420P;
++          break;
++        case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
++          context->pix_fmt = PIX_FMT_YUV411P;
++          break;
++        case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
++          context->pix_fmt = PIX_FMT_YUV422P;
++          break;
++        case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
++          context->pix_fmt = PIX_FMT_YUV410P;
++          break;
++#if 0
++        case FIXME:
++          context->pix_fmt = PIX_FMT_YUV444P;
++          break;
++#endif
++      }
++    }
++  } else if (strcmp (gst_structure_get_name (structure),
++          "video/x-raw-rgb") == 0) {
++    gint bpp = 0, rmask = 0, endianness = 0;
++
++    if (gst_structure_get_int (structure, "bpp", &bpp) &&
++        gst_structure_get_int (structure, "endianness", &endianness)) {
++      if (gst_structure_get_int (structure, "red_mask", &rmask)) {
++        switch (bpp) {
++          case 32:
++#if (G_BYTE_ORDER == G_BIG_ENDIAN)
++            if (rmask == 0x00ff0000)
++#else
++            if (rmask == 0x0000ff00)
++#endif
++              context->pix_fmt = PIX_FMT_RGB32;
++            break;
++          case 24:
++            if (rmask == 0x0000FF)
++              context->pix_fmt = PIX_FMT_BGR24;
++            else
++              context->pix_fmt = PIX_FMT_RGB24;
++            break;
++          case 16:
++            if (endianness == G_BYTE_ORDER)
++              context->pix_fmt = PIX_FMT_RGB565;
++            break;
++          case 15:
++            if (endianness == G_BYTE_ORDER)
++              context->pix_fmt = PIX_FMT_RGB555;
++            break;
++          default:
++            /* nothing */
++            break;
++        }
++      } else {
++        if (bpp == 8) {
++          context->pix_fmt = PIX_FMT_PAL8;
++          gst_ffmpeg_get_palette (caps, context);
++        }
++      }
++    }
++  } else if (strcmp (gst_structure_get_name (structure),
++          "video/x-raw-gray") == 0) {
++    gint bpp = 0;
++
++    if (gst_structure_get_int (structure, "bpp", &bpp)) {
++      switch (bpp) {
++        case 8:
++          context->pix_fmt = PIX_FMT_GRAY8;
++          break;
++      }
++    }
++  }
++}
++
++/* Convert a GstCaps and a FFMPEG codec Type to a
++ * AVCodecContext. If the context is ommitted, no fixed values
++ * for video/audio size will be included in the context
++ *
++ * AVMediaType is primarily meant for uncompressed data GstCaps!
++ */
++
++void
++gst_ffmpeg_caps_with_codectype (enum AVMediaType type,
++    const GstCaps * caps, AVCodecContext * context)
++{
++  if (context == NULL)
++    return;
++
++  switch (type) {
++    case AVMEDIA_TYPE_VIDEO:
++      gst_ffmpeg_caps_to_pixfmt (caps, context, TRUE);
++      break;
++
++    case AVMEDIA_TYPE_AUDIO:
++      gst_ffmpeg_caps_to_smpfmt (caps, context, TRUE);
++      break;
++
++    default:
++      /* unknown */
++      break;
++  }
++}
++
++#if 0
++static void
++nal_escape (guint8 * dst, guint8 * src, guint size, guint * destsize)
++{
++  guint8 *dstp = dst;
++  guint8 *srcp = src;
++  guint8 *end = src + size;
++  gint count = 0;
++
++  while (srcp < end) {
++    if (count == 2 && *srcp <= 0x03) {
++      GST_DEBUG ("added escape code");
++      *dstp++ = 0x03;
++      count = 0;
++    }
++    if (*srcp == 0)
++      count++;
++    else
++      count = 0;
++
++    GST_DEBUG ("copy %02x, count %d", *srcp, count);
++    *dstp++ = *srcp++;
++  }
++  *destsize = dstp - dst;
++}
++
++/* copy the config, escaping NAL units as we iterate them, if something fails we
++ * copy everything and hope for the best. */
++static void
++copy_config (guint8 * dst, guint8 * src, guint size, guint * destsize)
++{
++  guint8 *dstp = dst;
++  guint8 *srcp = src;
++  gint cnt, i;
++  guint nalsize, esize;
++
++  /* check size */
++  if (size < 7)
++    goto full_copy;
++
++  /* check version */
++  if (*srcp != 1)
++    goto full_copy;
++
++  cnt = *(srcp + 5) & 0x1f;     /* Number of sps */
++
++  GST_DEBUG ("num SPS %d", cnt);
++
++  memcpy (dstp, srcp, 6);
++  srcp += 6;
++  dstp += 6;
++
++  for (i = 0; i < cnt; i++) {
++    GST_DEBUG ("copy SPS %d", i);
++    nalsize = (srcp[0] << 8) | srcp[1];
++    nal_escape (dstp + 2, srcp + 2, nalsize, &esize);
++    dstp[0] = esize >> 8;
++    dstp[1] = esize & 0xff;
++    dstp += esize + 2;
++    srcp += nalsize + 2;
++  }
++
++  cnt = *(dstp++) = *(srcp++);  /* Number of pps */
++
++  GST_DEBUG ("num PPS %d", cnt);
++
++  for (i = 0; i < cnt; i++) {
++    GST_DEBUG ("copy PPS %d", i);
++    nalsize = (srcp[0] << 8) | srcp[1];
++    nal_escape (dstp + 2, srcp + 2, nalsize, &esize);
++    dstp[0] = esize >> 8;
++    dstp[1] = esize & 0xff;
++    dstp += esize + 2;
++    srcp += nalsize + 2;
++  }
++  *destsize = dstp - dst;
++
++  return;
++
++full_copy:
++  {
++    GST_DEBUG ("something unexpected, doing full copy");
++    memcpy (dst, src, size);
++    *destsize = size;
++    return;
++  }
++}
++#endif
++
++/*
++ * caps_with_codecid () transforms a GstCaps for a known codec
++ * ID into a filled-in context.
++ * codec_data from caps will override possible extradata already in the context
++ */
++
++void
++gst_ffmpeg_caps_with_codecid (enum CodecID codec_id,
++    enum AVMediaType codec_type, const GstCaps * caps, AVCodecContext * context)
++{
++  GstStructure *str;
++  const GValue *value;
++  const GstBuffer *buf;
++
++  GST_LOG ("codec_id:%d, codec_type:%d, caps:%" GST_PTR_FORMAT " context:%p",
++      codec_id, codec_type, caps, context);
++
++  if (!context || !gst_caps_get_size (caps))
++    return;
++
++  str = gst_caps_get_structure (caps, 0);
++
++  /* extradata parsing (esds [mpeg4], wma/wmv, msmpeg4v1/2/3, etc.) */
++  if ((value = gst_structure_get_value (str, "codec_data"))) {
++    guint size;
++    guint8 *data;
++
++    buf = GST_BUFFER_CAST (gst_value_get_mini_object (value));
++    size = GST_BUFFER_SIZE (buf);
++    data = GST_BUFFER_DATA (buf);
++
++    /* free the old one if it is there */
++    if (context->extradata)
++      av_free (context->extradata);
++
++#if 0
++    if (codec_id == CODEC_ID_H264) {
++      guint extrasize;
++
++      GST_DEBUG ("copy, escaping codec_data %d", size);
++      /* ffmpeg h264 expects the codec_data to be escaped, there is no real
++       * reason for this but let's just escape it for now. Start by allocating
++       * enough space, x2 is more than enough.
++       *
++       * FIXME, we disabled escaping because some file already contain escaped
++       * codec_data and then we escape twice and fail. It's better to leave it
++       * as is, as that is what most players do. */
++      context->extradata =
++          av_mallocz (GST_ROUND_UP_16 (size * 2 +
++              FF_INPUT_BUFFER_PADDING_SIZE));
++      copy_config (context->extradata, data, size, &extrasize);
++      GST_DEBUG ("escaped size: %d", extrasize);
++      context->extradata_size = extrasize;
++    } else
++#endif
++    {
++      /* allocate with enough padding */
++      GST_DEBUG ("copy codec_data");
++      context->extradata =
++          av_mallocz (GST_ROUND_UP_16 (size + FF_INPUT_BUFFER_PADDING_SIZE));
++      memcpy (context->extradata, data, size);
++      context->extradata_size = size;
++    }
++
++    /* Hack for VC1. Sometimes the first (length) byte is 0 for some files */
++    if (codec_id == CODEC_ID_VC1 && size > 0 && data[0] == 0) {
++      context->extradata[0] = (guint8) size;
++    }
++
++    GST_DEBUG ("have codec data of size %d", size);
++  } else if (context->extradata == NULL && codec_id != CODEC_ID_AAC_LATM &&
++      codec_id != CODEC_ID_FLAC) {
++    /* no extradata, alloc dummy with 0 sized, some codecs insist on reading
++     * extradata anyway which makes then segfault. */
++    context->extradata =
++        av_mallocz (GST_ROUND_UP_16 (FF_INPUT_BUFFER_PADDING_SIZE));
++    context->extradata_size = 0;
++    GST_DEBUG ("no codec data");
++  }
++
++  switch (codec_id) {
++    case CODEC_ID_MPEG4:
++    {
++      const gchar *mime = gst_structure_get_name (str);
++
++      if (!strcmp (mime, "video/x-divx"))
++        context->codec_tag = GST_MAKE_FOURCC ('D', 'I', 'V', 'X');
++      else if (!strcmp (mime, "video/x-xvid"))
++        context->codec_tag = GST_MAKE_FOURCC ('X', 'V', 'I', 'D');
++      else if (!strcmp (mime, "video/x-3ivx"))
++        context->codec_tag = GST_MAKE_FOURCC ('3', 'I', 'V', '1');
++      else if (!strcmp (mime, "video/mpeg"))
++        context->codec_tag = GST_MAKE_FOURCC ('m', 'p', '4', 'v');
++    }
++      break;
++
++    case CODEC_ID_SVQ3:
++      /* FIXME: this is a workaround for older gst-plugins releases
++       * (<= 0.8.9). This should be removed at some point, because
++       * it causes wrong decoded frame order. */
++      if (!context->extradata) {
++        gint halfpel_flag, thirdpel_flag, low_delay, unknown_svq3_flag;
++        guint16 flags;
++
++        if (gst_structure_get_int (str, "halfpel_flag", &halfpel_flag) ||
++            gst_structure_get_int (str, "thirdpel_flag", &thirdpel_flag) ||
++            gst_structure_get_int (str, "low_delay", &low_delay) ||
++            gst_structure_get_int (str, "unknown_svq3_flag",
++                &unknown_svq3_flag)) {
++          context->extradata = (guint8 *) av_mallocz (0x64);
++          g_stpcpy ((gchar *) context->extradata, "SVQ3");
++          flags = 1 << 3;
++          flags |= low_delay;
++          flags = flags << 2;
++          flags |= unknown_svq3_flag;
++          flags = flags << 6;
++          flags |= halfpel_flag;
++          flags = flags << 1;
++          flags |= thirdpel_flag;
++          flags = flags << 3;
++
++          flags = GUINT16_FROM_LE (flags);
++
++          memcpy ((gchar *) context->extradata + 0x62, &flags, 2);
++          context->extradata_size = 0x64;
++        }
++      }
++      break;
++
++    case CODEC_ID_MSRLE:
++    case CODEC_ID_QTRLE:
++    case CODEC_ID_TSCC:
++    case CODEC_ID_CSCD:
++    case CODEC_ID_APE:
++    {
++      gint depth;
++
++      if (gst_structure_get_int (str, "depth", &depth)) {
++        context->bits_per_coded_sample = depth;
++      } else {
++        GST_WARNING ("No depth field in caps %" GST_PTR_FORMAT, caps);
++      }
++
++    }
++      break;
++
++    case CODEC_ID_RV10:
++    case CODEC_ID_RV20:
++    case CODEC_ID_RV30:
++    case CODEC_ID_RV40:
++    {
++      gint format;
++
++      if (gst_structure_get_int (str, "format", &format))
++        context->sub_id = format;
++
++      break;
++    }
++    case CODEC_ID_COOK:
++    case CODEC_ID_RA_288:
++    case CODEC_ID_RA_144:
++    case CODEC_ID_SIPR:
++    {
++      gint leaf_size;
++      gint bitrate;
++
++      if (gst_structure_get_int (str, "leaf_size", &leaf_size))
++        context->block_align = leaf_size;
++      if (gst_structure_get_int (str, "bitrate", &bitrate))
++        context->bit_rate = bitrate;
++    }
++    case CODEC_ID_ALAC:
++      gst_structure_get_int (str, "samplesize",
++          &context->bits_per_coded_sample);
++      break;
++
++    case CODEC_ID_DVVIDEO:
++    {
++      guint32 fourcc;
++
++      if (gst_structure_get_fourcc (str, "format", &fourcc))
++        switch (fourcc) {
++          case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
++            context->pix_fmt = PIX_FMT_YUYV422;
++            break;
++          case GST_MAKE_FOURCC ('I', '4', '2', '0'):
++            context->pix_fmt = PIX_FMT_YUV420P;
++            break;
++          case GST_MAKE_FOURCC ('A', '4', '2', '0'):
++            context->pix_fmt = PIX_FMT_YUVA420P;
++            break;
++          case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
++            context->pix_fmt = PIX_FMT_YUV411P;
++            break;
++          case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
++            context->pix_fmt = PIX_FMT_YUV422P;
++            break;
++          case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
++            context->pix_fmt = PIX_FMT_YUV410P;
++            break;
++          default:
++            GST_WARNING ("couldn't convert fourcc %" GST_FOURCC_FORMAT
++                " to a pixel format", GST_FOURCC_ARGS (fourcc));
++            break;
++        }
++      break;
++    }
++    case CODEC_ID_H263P:
++    {
++      gboolean val;
++
++      if (!gst_structure_get_boolean (str, "annex-f", &val) || val)
++        context->flags |= CODEC_FLAG_4MV;
++      else
++        context->flags &= ~CODEC_FLAG_4MV;
++      if ((!gst_structure_get_boolean (str, "annex-i", &val) || val) &&
++          (!gst_structure_get_boolean (str, "annex-t", &val) || val))
++        context->flags |= CODEC_FLAG_AC_PRED;
++      else
++        context->flags &= ~CODEC_FLAG_AC_PRED;
++      if (!gst_structure_get_boolean (str, "annex-j", &val) || val)
++        context->flags |= CODEC_FLAG_LOOP_FILTER;
++      else
++        context->flags &= ~CODEC_FLAG_LOOP_FILTER;
++      break;
++    }
++    case CODEC_ID_ADPCM_G726:
++    {
++      const gchar *layout;
++
++      if ((layout = gst_structure_get_string (str, "layout"))) {
++        if (!strcmp (layout, "g721")) {
++          context->sample_rate = 8000;
++          context->channels = 1;
++          context->bit_rate = 32000;
++        }
++      }
++      break;
++    }
++    default:
++      break;
++  }
++
++  if (!gst_caps_is_fixed (caps))
++    return;
++
++  /* common properties (width, height, fps) */
++  switch (codec_type) {
++    case AVMEDIA_TYPE_VIDEO:
++      gst_ffmpeg_caps_to_pixfmt (caps, context, codec_id == CODEC_ID_RAWVIDEO);
++      gst_ffmpeg_get_palette (caps, context);
++      break;
++    case AVMEDIA_TYPE_AUDIO:
++      gst_ffmpeg_caps_to_smpfmt (caps, context, FALSE);
++      break;
++    default:
++      break;
++  }
++
++  /* fixup of default settings */
++  switch (codec_id) {
++    case CODEC_ID_QCELP:
++      /* QCELP is always mono, no matter what the caps say */
++      context->channels = 1;
++      break;
++    default:
++      break;
++  }
++}
++
++/* _formatid_to_caps () is meant for muxers/demuxers, it
++ * transforms a name (ffmpeg way of ID'ing these, why don't
++ * they have unique numerical IDs?) to the corresponding
++ * caps belonging to that mux-format
++ *
++ * Note: we don't need any additional info because the caps
++ * isn't supposed to contain any useful info besides the
++ * media type anyway
++ */
++
++GstCaps *
++gst_ffmpeg_formatid_to_caps (const gchar * format_name)
++{
++  GstCaps *caps = NULL;
++
++  if (!strcmp (format_name, "mpeg")) {
++    caps = gst_caps_new_simple ("video/mpeg",
++        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
++  } else if (!strcmp (format_name, "mpegts")) {
++    caps = gst_caps_new_simple ("video/mpegts",
++        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
++  } else if (!strcmp (format_name, "rm")) {
++    caps = gst_caps_new_simple ("application/x-pn-realmedia",
++        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
++  } else if (!strcmp (format_name, "asf")) {
++    caps = gst_caps_new_simple ("video/x-ms-asf", NULL);
++  } else if (!strcmp (format_name, "avi")) {
++    caps = gst_caps_new_simple ("video/x-msvideo", NULL);
++  } else if (!strcmp (format_name, "wav")) {
++    caps = gst_caps_new_simple ("audio/x-wav", NULL);
++  } else if (!strcmp (format_name, "ape")) {
++    caps = gst_caps_new_simple ("application/x-ape", NULL);
++  } else if (!strcmp (format_name, "swf")) {
++    caps = gst_caps_new_simple ("application/x-shockwave-flash", NULL);
++  } else if (!strcmp (format_name, "au")) {
++    caps = gst_caps_new_simple ("audio/x-au", NULL);
++  } else if (!strcmp (format_name, "dv")) {
++    caps = gst_caps_new_simple ("video/x-dv",
++        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
++  } else if (!strcmp (format_name, "4xm")) {
++    caps = gst_caps_new_simple ("video/x-4xm", NULL);
++  } else if (!strcmp (format_name, "matroska")) {
++    caps = gst_caps_new_simple ("video/x-matroska", NULL);
++  } else if (!strcmp (format_name, "mp3")) {
++    caps = gst_caps_new_simple ("application/x-id3", NULL);
++  } else if (!strcmp (format_name, "flic")) {
++    caps = gst_caps_new_simple ("video/x-fli", NULL);
++  } else if (!strcmp (format_name, "flv")) {
++    caps = gst_caps_new_simple ("video/x-flv", NULL);
++  } else if (!strcmp (format_name, "tta")) {
++    caps = gst_caps_new_simple ("audio/x-ttafile", NULL);
++  } else if (!strcmp (format_name, "aiff")) {
++    caps = gst_caps_new_simple ("audio/x-aiff", NULL);
++  } else if (!strcmp (format_name, "mov_mp4_m4a_3gp_3g2")) {
++    caps =
++        gst_caps_from_string
++        ("application/x-3gp; video/quicktime; audio/x-m4a");
++  } else if (!strcmp (format_name, "mov")) {
++    caps = gst_caps_from_string ("video/quicktime,variant=(string)apple");
++  } else if (!strcmp (format_name, "mp4")) {
++    caps = gst_caps_from_string ("video/quicktime,variant=(string)iso");
++  } else if (!strcmp (format_name, "3gp")) {
++    caps = gst_caps_from_string ("video/quicktime,variant=(string)3gpp");
++  } else if (!strcmp (format_name, "3g2")) {
++    caps = gst_caps_from_string ("video/quicktime,variant=(string)3g2");
++  } else if (!strcmp (format_name, "psp")) {
++    caps = gst_caps_from_string ("video/quicktime,variant=(string)psp");
++  } else if (!strcmp (format_name, "ipod")) {
++    caps = gst_caps_from_string ("video/quicktime,variant=(string)ipod");
++  } else if (!strcmp (format_name, "aac")) {
++    caps = gst_caps_new_simple ("audio/mpeg",
++        "mpegversion", G_TYPE_INT, 4, NULL);
++  } else if (!strcmp (format_name, "gif")) {
++    caps = gst_caps_from_string ("image/gif");
++  } else if (!strcmp (format_name, "ogg")) {
++    caps = gst_caps_from_string ("application/ogg");
++  } else if (!strcmp (format_name, "mxf") || !strcmp (format_name, "mxf_d10")) {
++    caps = gst_caps_from_string ("application/mxf");
++  } else if (!strcmp (format_name, "gxf")) {
++    caps = gst_caps_from_string ("application/gxf");
++  } else if (!strcmp (format_name, "yuv4mpegpipe")) {
++    caps = gst_caps_new_simple ("application/x-yuv4mpeg",
++        "y4mversion", G_TYPE_INT, 2, NULL);
++  } else if (!strcmp (format_name, "mpc")) {
++    caps = gst_caps_from_string ("audio/x-musepack, streamversion = (int) 7");
++  } else if (!strcmp (format_name, "vqf")) {
++    caps = gst_caps_from_string ("audio/x-vqf");
++  } else if (!strcmp (format_name, "nsv")) {
++    caps = gst_caps_from_string ("video/x-nsv");
++  } else if (!strcmp (format_name, "amr")) {
++    caps = gst_caps_from_string ("audio/x-amr-nb-sh");
++  } else if (!strcmp (format_name, "webm")) {
++    caps = gst_caps_from_string ("video/webm");
++  } else {
++    gchar *name;
++
++    GST_LOG ("Could not create stream format caps for %s", format_name);
++    name = g_strdup_printf ("application/x-gst_ff-%s", format_name);
++    caps = gst_caps_new_simple (name, NULL);
++    g_free (name);
++  }
++
++  return caps;
++}
++
++gboolean
++gst_ffmpeg_formatid_get_codecids (const gchar * format_name,
++    enum CodecID ** video_codec_list, enum CodecID ** audio_codec_list,
++    AVOutputFormat * plugin)
++{
++  static enum CodecID tmp_vlist[] = {
++    CODEC_ID_NONE,
++    CODEC_ID_NONE
++  };
++  static enum CodecID tmp_alist[] = {
++    CODEC_ID_NONE,
++    CODEC_ID_NONE
++  };
++
++  GST_LOG ("format_name : %s", format_name);
++
++  if (!strcmp (format_name, "mp4")) {
++    static enum CodecID mp4_video_list[] = {
++      CODEC_ID_MPEG4, CODEC_ID_H264,
++      CODEC_ID_MJPEG,
++      CODEC_ID_NONE
++    };
++    static enum CodecID mp4_audio_list[] = {
++      CODEC_ID_AAC, CODEC_ID_MP3,
++      CODEC_ID_NONE
++    };
++
++    *video_codec_list = mp4_video_list;
++    *audio_codec_list = mp4_audio_list;
++  } else if (!strcmp (format_name, "mpeg")) {
++    static enum CodecID mpeg_video_list[] = { CODEC_ID_MPEG1VIDEO,
++      CODEC_ID_MPEG2VIDEO,
++      CODEC_ID_H264,
++      CODEC_ID_NONE
++    };
++    static enum CodecID mpeg_audio_list[] = { CODEC_ID_MP1,
++      CODEC_ID_MP2,
++      CODEC_ID_MP3,
++      CODEC_ID_NONE
++    };
++
++    *video_codec_list = mpeg_video_list;
++    *audio_codec_list = mpeg_audio_list;
++  } else if (!strcmp (format_name, "dvd")) {
++    static enum CodecID mpeg_video_list[] = { CODEC_ID_MPEG2VIDEO,
++      CODEC_ID_NONE
++    };
++    static enum CodecID mpeg_audio_list[] = { CODEC_ID_MP2,
++      CODEC_ID_AC3,
++      CODEC_ID_DTS,
++      CODEC_ID_PCM_S16BE,
++      CODEC_ID_NONE
++    };
++
++    *video_codec_list = mpeg_video_list;
++    *audio_codec_list = mpeg_audio_list;
++  } else if (!strcmp (format_name, "mpegts")) {
++    static enum CodecID mpegts_video_list[] = { CODEC_ID_MPEG1VIDEO,
++      CODEC_ID_MPEG2VIDEO,
++      CODEC_ID_H264,
++      CODEC_ID_NONE
++    };
++    static enum CodecID mpegts_audio_list[] = { CODEC_ID_MP2,
++      CODEC_ID_MP3,
++      CODEC_ID_AC3,
++      CODEC_ID_DTS,
++      CODEC_ID_AAC,
++      CODEC_ID_NONE
++    };
++
++    *video_codec_list = mpegts_video_list;
++    *audio_codec_list = mpegts_audio_list;
++  } else if (!strcmp (format_name, "vob")) {
++    static enum CodecID vob_video_list[] =
++        { CODEC_ID_MPEG2VIDEO, CODEC_ID_NONE };
++    static enum CodecID vob_audio_list[] = { CODEC_ID_MP2, CODEC_ID_AC3,
++      CODEC_ID_DTS, CODEC_ID_NONE
++    };
++
++    *video_codec_list = vob_video_list;
++    *audio_codec_list = vob_audio_list;
++  } else if (!strcmp (format_name, "flv")) {
++    static enum CodecID flv_video_list[] = { CODEC_ID_FLV1, CODEC_ID_NONE };
++    static enum CodecID flv_audio_list[] = { CODEC_ID_MP3, CODEC_ID_NONE };
++
++    *video_codec_list = flv_video_list;
++    *audio_codec_list = flv_audio_list;
++  } else if (!strcmp (format_name, "asf")) {
++    static enum CodecID asf_video_list[] =
++        { CODEC_ID_WMV1, CODEC_ID_WMV2, CODEC_ID_MSMPEG4V3, CODEC_ID_NONE };
++    static enum CodecID asf_audio_list[] =
++        { CODEC_ID_WMAV1, CODEC_ID_WMAV2, CODEC_ID_MP3, CODEC_ID_NONE };
++
++    *video_codec_list = asf_video_list;
++    *audio_codec_list = asf_audio_list;
++  } else if (!strcmp (format_name, "dv")) {
++    static enum CodecID dv_video_list[] = { CODEC_ID_DVVIDEO, CODEC_ID_NONE };
++    static enum CodecID dv_audio_list[] = { CODEC_ID_PCM_S16LE, CODEC_ID_NONE };
++
++    *video_codec_list = dv_video_list;
++    *audio_codec_list = dv_audio_list;
++  } else if (!strcmp (format_name, "mov")) {
++    static enum CodecID mov_video_list[] = {
++      CODEC_ID_SVQ1, CODEC_ID_SVQ3, CODEC_ID_MPEG4,
++      CODEC_ID_H263, CODEC_ID_H263P,
++      CODEC_ID_H264, CODEC_ID_DVVIDEO,
++      CODEC_ID_MJPEG,
++      CODEC_ID_NONE
++    };
++    static enum CodecID mov_audio_list[] = {
++      CODEC_ID_PCM_MULAW, CODEC_ID_PCM_ALAW, CODEC_ID_ADPCM_IMA_QT,
++      CODEC_ID_MACE3, CODEC_ID_MACE6, CODEC_ID_AAC,
++      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
++      CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE,
++      CODEC_ID_MP3, CODEC_ID_NONE
++    };
++
++    *video_codec_list = mov_video_list;
++    *audio_codec_list = mov_audio_list;
++  } else if ((!strcmp (format_name, "3gp") || !strcmp (format_name, "3g2"))) {
++    static enum CodecID tgp_video_list[] = {
++      CODEC_ID_MPEG4, CODEC_ID_H263, CODEC_ID_H263P, CODEC_ID_H264,
++      CODEC_ID_NONE
++    };
++    static enum CodecID tgp_audio_list[] = {
++      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
++      CODEC_ID_AAC,
++      CODEC_ID_NONE
++    };
++
++    *video_codec_list = tgp_video_list;
++    *audio_codec_list = tgp_audio_list;
++  } else if (!strcmp (format_name, "mmf")) {
++    static enum CodecID mmf_audio_list[] = {
++      CODEC_ID_ADPCM_YAMAHA, CODEC_ID_NONE
++    };
++    *video_codec_list = NULL;
++    *audio_codec_list = mmf_audio_list;
++  } else if (!strcmp (format_name, "amr")) {
++    static enum CodecID amr_audio_list[] = {
++      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
++      CODEC_ID_NONE
++    };
++    *video_codec_list = NULL;
++    *audio_codec_list = amr_audio_list;
++  } else if (!strcmp (format_name, "gif")) {
++    static enum CodecID gif_image_list[] = {
++      CODEC_ID_RAWVIDEO, CODEC_ID_NONE
++    };
++    *video_codec_list = gif_image_list;
++    *audio_codec_list = NULL;
++  } else if ((plugin->audio_codec != CODEC_ID_NONE) ||
++      (plugin->video_codec != CODEC_ID_NONE)) {
++    tmp_vlist[0] = plugin->video_codec;
++    tmp_alist[0] = plugin->audio_codec;
++
++    *video_codec_list = tmp_vlist;
++    *audio_codec_list = tmp_alist;
++  } else {
++    GST_LOG ("Format %s not found", format_name);
++    return FALSE;
++  }
++
++  return TRUE;
++}
++
++/* Convert a GstCaps to a FFMPEG codec ID. Size et all
++ * are omitted, that can be queried by the user itself,
++ * we're not eating the GstCaps or anything
++ * A pointer to an allocated context is also needed for
++ * optional extra info
++ */
++
++enum CodecID
++gst_ffmpeg_caps_to_codecid (const GstCaps * caps, AVCodecContext * context)
++{
++  enum CodecID id = CODEC_ID_NONE;
++  const gchar *mimetype;
++  const GstStructure *structure;
++  gboolean video = FALSE, audio = FALSE;        /* we want to be sure! */
++
++  g_return_val_if_fail (caps != NULL, CODEC_ID_NONE);
++  g_return_val_if_fail (gst_caps_get_size (caps) == 1, CODEC_ID_NONE);
++  structure = gst_caps_get_structure (caps, 0);
++
++  mimetype = gst_structure_get_name (structure);
++
++  if (!strcmp (mimetype, "video/x-raw-rgb") ||
++      !strcmp (mimetype, "video/x-raw-yuv")) {
++    id = CODEC_ID_RAWVIDEO;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-raw-int")) {
++    gint depth, width, endianness;
++    gboolean signedness;
++
++    if (gst_structure_get_int (structure, "endianness", &endianness) &&
++        gst_structure_get_boolean (structure, "signed", &signedness) &&
++        gst_structure_get_int (structure, "width", &width) &&
++        gst_structure_get_int (structure, "depth", &depth) && depth == width) {
++      switch (depth) {
++        case 8:
++          if (signedness) {
++            id = CODEC_ID_PCM_S8;
++          } else {
++            id = CODEC_ID_PCM_U8;
++          }
++          break;
++        case 16:
++          switch (endianness) {
++            case G_BIG_ENDIAN:
++              if (signedness) {
++                id = CODEC_ID_PCM_S16BE;
++              } else {
++                id = CODEC_ID_PCM_U16BE;
++              }
++              break;
++            case G_LITTLE_ENDIAN:
++              if (signedness) {
++                id = CODEC_ID_PCM_S16LE;
++              } else {
++                id = CODEC_ID_PCM_U16LE;
++              }
++              break;
++          }
++          break;
++      }
++      if (id != CODEC_ID_NONE)
++        audio = TRUE;
++    }
++  } else if (!strcmp (mimetype, "audio/x-mulaw")) {
++    id = CODEC_ID_PCM_MULAW;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-alaw")) {
++    id = CODEC_ID_PCM_ALAW;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-dv")) {
++    gboolean sys_strm;
++
++    if (gst_structure_get_boolean (structure, "systemstream", &sys_strm) &&
++        !sys_strm) {
++      id = CODEC_ID_DVVIDEO;
++      video = TRUE;
++    }
++  } else if (!strcmp (mimetype, "audio/x-dv")) {        /* ??? */
++    id = CODEC_ID_DVAUDIO;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-h263")) {
++    const gchar *h263version =
++        gst_structure_get_string (structure, "h263version");
++    if (h263version && !strcmp (h263version, "h263p"))
++      id = CODEC_ID_H263P;
++    else
++      id = CODEC_ID_H263;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-intel-h263")) {
++    id = CODEC_ID_H263I;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-h261")) {
++    id = CODEC_ID_H261;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/mpeg")) {
++    gboolean sys_strm;
++    gint mpegversion;
++
++    if (gst_structure_get_boolean (structure, "systemstream", &sys_strm) &&
++        gst_structure_get_int (structure, "mpegversion", &mpegversion) &&
++        !sys_strm) {
++      switch (mpegversion) {
++        case 1:
++          id = CODEC_ID_MPEG1VIDEO;
++          break;
++        case 2:
++          id = CODEC_ID_MPEG2VIDEO;
++          break;
++        case 4:
++          id = CODEC_ID_MPEG4;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      video = TRUE;
++  } else if (!strcmp (mimetype, "image/jpeg")) {
++    id = CODEC_ID_MJPEG;        /* A... B... */
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-jpeg-b")) {
++    id = CODEC_ID_MJPEGB;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-wmv")) {
++    gint wmvversion = 0;
++
++    if (gst_structure_get_int (structure, "wmvversion", &wmvversion)) {
++      switch (wmvversion) {
++        case 1:
++          id = CODEC_ID_WMV1;
++          break;
++        case 2:
++          id = CODEC_ID_WMV2;
++          break;
++        case 3:
++        {
++          guint32 fourcc;
++
++          /* WMV3 unless the fourcc exists and says otherwise */
++          id = CODEC_ID_WMV3;
++
++          if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
++            if ((fourcc == GST_MAKE_FOURCC ('W', 'V', 'C', '1')) ||
++                (fourcc == GST_MAKE_FOURCC ('W', 'M', 'V', 'A'))) {
++              id = CODEC_ID_VC1;
++            }
++          }
++        }
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      video = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-vorbis")) {
++    id = CODEC_ID_VORBIS;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-qdm2")) {
++    id = CODEC_ID_QDM2;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/mpeg")) {
++    gint layer = 0;
++    gint mpegversion = 0;
++
++    if (gst_structure_get_int (structure, "mpegversion", &mpegversion)) {
++      switch (mpegversion) {
++        case 2:                /* ffmpeg uses faad for both... */
++        case 4:
++          id = CODEC_ID_AAC;
++          break;
++        case 1:
++          if (gst_structure_get_int (structure, "layer", &layer)) {
++            switch (layer) {
++              case 1:
++                id = CODEC_ID_MP1;
++                break;
++              case 2:
++                id = CODEC_ID_MP2;
++                break;
++              case 3:
++                id = CODEC_ID_MP3;
++                break;
++            }
++          }
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-musepack")) {
++    gint streamversion = -1;
++
++    if (gst_structure_get_int (structure, "streamversion", &streamversion)) {
++      if (streamversion == 7)
++        id = CODEC_ID_MUSEPACK7;
++    } else {
++      id = CODEC_ID_MUSEPACK7;
++    }
++  } else if (!strcmp (mimetype, "audio/x-wma")) {
++    gint wmaversion = 0;
++
++    if (gst_structure_get_int (structure, "wmaversion", &wmaversion)) {
++      switch (wmaversion) {
++        case 1:
++          id = CODEC_ID_WMAV1;
++          break;
++        case 2:
++          id = CODEC_ID_WMAV2;
++          break;
++        case 3:
++          id = CODEC_ID_WMAPRO;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-wms")) {
++    id = CODEC_ID_WMAVOICE;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-ac3")) {
++    id = CODEC_ID_AC3;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-eac3")) {
++    id = CODEC_ID_EAC3;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-vnd.sony.atrac3") ||
++      !strcmp (mimetype, "audio/atrac3")) {
++    id = CODEC_ID_ATRAC3;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-dts")) {
++    id = CODEC_ID_DTS;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "application/x-ape")) {
++    id = CODEC_ID_APE;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-msmpeg")) {
++    gint msmpegversion = 0;
++
++    if (gst_structure_get_int (structure, "msmpegversion", &msmpegversion)) {
++      switch (msmpegversion) {
++        case 41:
++          id = CODEC_ID_MSMPEG4V1;
++          break;
++        case 42:
++          id = CODEC_ID_MSMPEG4V2;
++          break;
++        case 43:
++          id = CODEC_ID_MSMPEG4V3;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-svq")) {
++    gint svqversion = 0;
++
++    if (gst_structure_get_int (structure, "svqversion", &svqversion)) {
++      switch (svqversion) {
++        case 1:
++          id = CODEC_ID_SVQ1;
++          break;
++        case 3:
++          id = CODEC_ID_SVQ3;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-huffyuv")) {
++    id = CODEC_ID_HUFFYUV;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-mace")) {
++    gint maceversion = 0;
++
++    if (gst_structure_get_int (structure, "maceversion", &maceversion)) {
++      switch (maceversion) {
++        case 3:
++          id = CODEC_ID_MACE3;
++          break;
++        case 6:
++          id = CODEC_ID_MACE6;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-theora")) {
++    id = CODEC_ID_THEORA;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-vp3")) {
++    id = CODEC_ID_VP3;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-vp5")) {
++    id = CODEC_ID_VP5;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-vp6")) {
++    id = CODEC_ID_VP6;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-vp6-flash")) {
++    id = CODEC_ID_VP6F;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-vp6-alpha")) {
++    id = CODEC_ID_VP6A;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-vp8")) {
++    id = CODEC_ID_VP8;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-flash-screen")) {
++    id = CODEC_ID_FLASHSV;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-indeo")) {
++    gint indeoversion = 0;
++
++    if (gst_structure_get_int (structure, "indeoversion", &indeoversion)) {
++      switch (indeoversion) {
++        case 5:
++          id = CODEC_ID_INDEO5;
++          break;
++        case 3:
++          id = CODEC_ID_INDEO3;
++          break;
++        case 2:
++          id = CODEC_ID_INDEO2;
++          break;
++      }
++      if (id != CODEC_ID_NONE)
++        video = TRUE;
++    }
++  } else if (!strcmp (mimetype, "video/x-divx")) {
++    gint divxversion = 0;
++
++    if (gst_structure_get_int (structure, "divxversion", &divxversion)) {
++      switch (divxversion) {
++        case 3:
++          id = CODEC_ID_MSMPEG4V3;
++          break;
++        case 4:
++        case 5:
++          id = CODEC_ID_MPEG4;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-3ivx")) {
++    id = CODEC_ID_MPEG4;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-xvid")) {
++    id = CODEC_ID_MPEG4;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-ffv")) {
++    gint ffvversion = 0;
++
++    if (gst_structure_get_int (structure, "ffvversion", &ffvversion) &&
++        ffvversion == 1) {
++      id = CODEC_ID_FFV1;
++      video = TRUE;
++    }
++  } else if (!strcmp (mimetype, "audio/x-adpcm")) {
++    const gchar *layout;
++
++    layout = gst_structure_get_string (structure, "layout");
++    if (layout == NULL) {
++      /* break */
++    } else if (!strcmp (layout, "quicktime")) {
++      id = CODEC_ID_ADPCM_IMA_QT;
++    } else if (!strcmp (layout, "microsoft")) {
++      id = CODEC_ID_ADPCM_MS;
++    } else if (!strcmp (layout, "dvi")) {
++      id = CODEC_ID_ADPCM_IMA_WAV;
++    } else if (!strcmp (layout, "4xm")) {
++      id = CODEC_ID_ADPCM_4XM;
++    } else if (!strcmp (layout, "smjpeg")) {
++      id = CODEC_ID_ADPCM_IMA_SMJPEG;
++    } else if (!strcmp (layout, "dk3")) {
++      id = CODEC_ID_ADPCM_IMA_DK3;
++    } else if (!strcmp (layout, "dk4")) {
++      id = CODEC_ID_ADPCM_IMA_DK4;
++    } else if (!strcmp (layout, "westwood")) {
++      id = CODEC_ID_ADPCM_IMA_WS;
++    } else if (!strcmp (layout, "iss")) {
++      id = CODEC_ID_ADPCM_IMA_ISS;
++    } else if (!strcmp (layout, "xa")) {
++      id = CODEC_ID_ADPCM_XA;
++    } else if (!strcmp (layout, "adx")) {
++      id = CODEC_ID_ADPCM_ADX;
++    } else if (!strcmp (layout, "ea")) {
++      id = CODEC_ID_ADPCM_EA;
++    } else if (!strcmp (layout, "g726")) {
++      id = CODEC_ID_ADPCM_G726;
++    } else if (!strcmp (layout, "g721")) {
++      id = CODEC_ID_ADPCM_G726;
++    } else if (!strcmp (layout, "ct")) {
++      id = CODEC_ID_ADPCM_CT;
++    } else if (!strcmp (layout, "swf")) {
++      id = CODEC_ID_ADPCM_SWF;
++    } else if (!strcmp (layout, "yamaha")) {
++      id = CODEC_ID_ADPCM_YAMAHA;
++    } else if (!strcmp (layout, "sbpro2")) {
++      id = CODEC_ID_ADPCM_SBPRO_2;
++    } else if (!strcmp (layout, "sbpro3")) {
++      id = CODEC_ID_ADPCM_SBPRO_3;
++    } else if (!strcmp (layout, "sbpro4")) {
++      id = CODEC_ID_ADPCM_SBPRO_4;
++    }
++    if (id != CODEC_ID_NONE)
++      audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-4xm")) {
++    id = CODEC_ID_4XM;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-dpcm")) {
++    const gchar *layout;
++
++    layout = gst_structure_get_string (structure, "layout");
++    if (!layout) {
++      /* .. */
++    } else if (!strcmp (layout, "roq")) {
++      id = CODEC_ID_ROQ_DPCM;
++    } else if (!strcmp (layout, "interplay")) {
++      id = CODEC_ID_INTERPLAY_DPCM;
++    } else if (!strcmp (layout, "xan")) {
++      id = CODEC_ID_XAN_DPCM;
++    } else if (!strcmp (layout, "sol")) {
++      id = CODEC_ID_SOL_DPCM;
++    }
++    if (id != CODEC_ID_NONE)
++      audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-flac")) {
++    id = CODEC_ID_FLAC;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-shorten")) {
++    id = CODEC_ID_SHORTEN;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-alac")) {
++    id = CODEC_ID_ALAC;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-cinepak")) {
++    id = CODEC_ID_CINEPAK;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-pn-realvideo")) {
++    gint rmversion;
++
++    if (gst_structure_get_int (structure, "rmversion", &rmversion)) {
++      switch (rmversion) {
++        case 1:
++          id = CODEC_ID_RV10;
++          break;
++        case 2:
++          id = CODEC_ID_RV20;
++          break;
++        case 3:
++          id = CODEC_ID_RV30;
++          break;
++        case 4:
++          id = CODEC_ID_RV40;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      video = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-sipro")) {
++    id = CODEC_ID_SIPR;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/x-pn-realaudio")) {
++    gint raversion;
++
++    if (gst_structure_get_int (structure, "raversion", &raversion)) {
++      switch (raversion) {
++        case 1:
++          id = CODEC_ID_RA_144;
++          break;
++        case 2:
++          id = CODEC_ID_RA_288;
++          break;
++        case 8:
++          id = CODEC_ID_COOK;
++          break;
++      }
++    }
++    if (id != CODEC_ID_NONE)
++      audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-rle")) {
++    const gchar *layout;
++
++    if ((layout = gst_structure_get_string (structure, "layout"))) {
++      if (!strcmp (layout, "microsoft")) {
++        id = CODEC_ID_MSRLE;
++        video = TRUE;
++      }
++    }
++  } else if (!strcmp (mimetype, "video/x-xan")) {
++    gint wcversion = 0;
++
++    if ((gst_structure_get_int (structure, "wcversion", &wcversion))) {
++      switch (wcversion) {
++        case 3:
++          id = CODEC_ID_XAN_WC3;
++          video = TRUE;
++          break;
++        case 4:
++          id = CODEC_ID_XAN_WC4;
++          video = TRUE;
++          break;
++        default:
++          break;
++      }
++    }
++  } else if (!strcmp (mimetype, "audio/AMR")) {
++    audio = TRUE;
++    id = CODEC_ID_AMR_NB;
++  } else if (!strcmp (mimetype, "audio/AMR-WB")) {
++    id = CODEC_ID_AMR_WB;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "audio/qcelp")) {
++    id = CODEC_ID_QCELP;
++    audio = TRUE;
++  } else if (!strcmp (mimetype, "video/x-h264")) {
++    id = CODEC_ID_H264;
++    video = TRUE;
++  } else if (!strcmp (mimetype, "video/x-flash-video")) {
++    gint flvversion = 0;
++
++    if ((gst_structure_get_int (structure, "flvversion", &flvversion))) {
++      switch (flvversion) {
++        case 1:
++          id = CODEC_ID_FLV1;
++          video = TRUE;
++          break;
++        default:
++          break;
++      }
++    }
++
++  } else if (!strcmp (mimetype, "audio/x-nellymoser")) {
++    id = CODEC_ID_NELLYMOSER;
++    audio = TRUE;
++  } else if (!strncmp (mimetype, "audio/x-gst_ff-", 15)) {
++    gchar ext[16];
++    AVCodec *codec;
++
++    if (strlen (mimetype) <= 30 &&
++        sscanf (mimetype, "audio/x-gst_ff-%s", ext) == 1) {
++      if ((codec = avcodec_find_decoder_by_name (ext)) ||
++          (codec = avcodec_find_encoder_by_name (ext))) {
++        id = codec->id;
++        audio = TRUE;
++      }
++    }
++  } else if (!strncmp (mimetype, "video/x-gst_ff-", 15)) {
++    gchar ext[16];
++    AVCodec *codec;
++
++    if (strlen (mimetype) <= 30 &&
++        sscanf (mimetype, "video/x-gst_ff-%s", ext) == 1) {
++      if ((codec = avcodec_find_decoder_by_name (ext)) ||
++          (codec = avcodec_find_encoder_by_name (ext))) {
++        id = codec->id;
++        video = TRUE;
++      }
++    }
++  }
++
++  if (context != NULL) {
++    if (video == TRUE) {
++      context->codec_type = AVMEDIA_TYPE_VIDEO;
++    } else if (audio == TRUE) {
++      context->codec_type = AVMEDIA_TYPE_AUDIO;
++    } else {
++      context->codec_type = AVMEDIA_TYPE_UNKNOWN;
++    }
++    context->codec_id = id;
++    gst_ffmpeg_caps_with_codecid (id, context->codec_type, caps, context);
++  }
++
++  if (id != CODEC_ID_NONE) {
++    GST_DEBUG ("The id=%d belongs to the caps %" GST_PTR_FORMAT, id, caps);
++  } else {
++    GST_WARNING ("Couldn't figure out the id for caps %" GST_PTR_FORMAT, caps);
++  }
++
++  return id;
++}
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.rej gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.rej
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.rej	1970-01-01 01:00:00.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.rej	2014-08-08 15:31:06.055868246 +0200
+@@ -0,0 +1,12 @@
++--- ext/ffmpeg/gstffmpegcodecmap.c
+++++ ext/ffmpeg/gstffmpegcodecmap.c
++@@ -1884,9 +1842,6 @@
++             gst_ff_vid_caps_new (context, codec_id, encode, "video/x-raw-rgb",
++             "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, "endianness",
++             G_TYPE_INT, endianness, NULL);
++-        if (caps && context) {
++-          gst_ffmpeg_set_palette (caps, context);
++-        }
++       }
++     } else if (fmt) {
++       caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-raw-yuv",
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c	2014-08-08 14:46:31.462772351 +0200
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c	2014-08-08 15:32:18.608870847 +0200
+@@ -88,7 +88,6 @@
+       gint depth;
+     } audio;
+   } format;
+-  gboolean waiting_for_key;
+   gboolean discont;
+   gboolean clear_ts;
+ 
+@@ -438,7 +437,6 @@
+   ffmpegdec->pcache = NULL;
+   ffmpegdec->par = NULL;
+   ffmpegdec->opened = FALSE;
+-  ffmpegdec->waiting_for_key = TRUE;
+   ffmpegdec->skip_frame = ffmpegdec->lowres = 0;
+   ffmpegdec->direct_rendering = DEFAULT_DIRECT_RENDERING;
+   ffmpegdec->do_padding = DEFAULT_DO_PADDING;
+@@ -608,11 +606,6 @@
+     gst_ffmpeg_avcodec_close (ffmpegdec->context);
+   ffmpegdec->opened = FALSE;
+ 
+-  if (ffmpegdec->context->palctrl) {
+-    av_free (ffmpegdec->context->palctrl);
+-    ffmpegdec->context->palctrl = NULL;
+-  }
+-
+   if (ffmpegdec->context->extradata) {
+     av_free (ffmpegdec->context->extradata);
+     ffmpegdec->context->extradata = NULL;
+@@ -864,7 +857,7 @@
+ 
+   /* workaround encoder bugs */
+   ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
+-  ffmpegdec->context->error_recognition = 1;
++  ffmpegdec->context->err_recognition = 1;
+ 
+   /* for slow cpus */
+   ffmpegdec->context->lowres = ffmpegdec->lowres;
+@@ -944,7 +937,7 @@
+   fsize = gst_ffmpeg_avpicture_get_size (ffmpegdec->context->pix_fmt,
+       width, height);
+ 
+-  if (!ffmpegdec->context->palctrl && ffmpegdec->can_allocate_aligned) {
++  if (ffmpegdec->can_allocate_aligned) {
+     GST_LOG_OBJECT (ffmpegdec, "calling pad_alloc");
+     /* no pallete, we can use the buffer size to alloc */
+     ret = gst_pad_alloc_buffer_and_set_caps (ffmpegdec->srcpad,
+@@ -1083,7 +1076,6 @@
+   /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to
+    * the opaque data. */
+   picture->type = FF_BUFFER_TYPE_USER;
+-  picture->age = 256 * 256 * 256 * 64;
+   picture->opaque = buf;
+ 
+ #ifdef EXTRA_REF
+@@ -1414,10 +1406,6 @@
+   } else {
+     if (diff >= 0) {
+       /* we're too slow, try to speed up */
+-      if (ffmpegdec->waiting_for_key) {
+-        /* we were waiting for a keyframe, that's ok */
+-        goto skipping;
+-      }
+       /* switch to skip_frame mode */
+       goto skip_frame;
+     }
+@@ -1427,11 +1415,6 @@
+   ffmpegdec->processed++;
+   return TRUE;
+ 
+-skipping:
+-  {
+-    res = FALSE;
+-    goto drop_qos;
+-  }
+ normal_mode:
+   {
+     if (ffmpegdec->context->skip_frame != AVDISCARD_DEFAULT) {
+@@ -1528,43 +1511,6 @@
+ }
+ 
+ 
+-/* figure out if the current picture is a keyframe, return TRUE if that is
+- * the case. */
+-static gboolean
+-check_keyframe (GstFFMpegDec * ffmpegdec)
+-{
+-  GstFFMpegDecClass *oclass;
+-  gboolean is_itype = FALSE;
+-  gboolean is_reference = FALSE;
+-  gboolean iskeyframe;
+-
+-  /* figure out if we are dealing with a keyframe */
+-  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+-
+-  /* remember that we have B frames, we need this for the DTS -> PTS conversion
+-   * code */
+-  if (!ffmpegdec->has_b_frames && ffmpegdec->picture->pict_type == FF_B_TYPE) {
+-    GST_DEBUG_OBJECT (ffmpegdec, "we have B frames");
+-    ffmpegdec->has_b_frames = TRUE;
+-  }
+-
+-  is_itype = (ffmpegdec->picture->pict_type == FF_I_TYPE);
+-  is_reference = (ffmpegdec->picture->reference == 1);
+-
+-  iskeyframe = (is_itype || is_reference || ffmpegdec->picture->key_frame)
+-      || (oclass->in_plugin->id == CODEC_ID_INDEO3)
+-      || (oclass->in_plugin->id == CODEC_ID_MSZH)
+-      || (oclass->in_plugin->id == CODEC_ID_ZLIB)
+-      || (oclass->in_plugin->id == CODEC_ID_VP3)
+-      || (oclass->in_plugin->id == CODEC_ID_HUFFYUV);
+-
+-  GST_LOG_OBJECT (ffmpegdec,
+-      "current picture: type: %d, is_keyframe:%d, is_itype:%d, is_reference:%d",
+-      ffmpegdec->picture->pict_type, iskeyframe, is_itype, is_reference);
+-
+-  return iskeyframe;
+-}
+-
+ /* get an outbuf buffer with the current picture */
+ static GstFlowReturn
+ get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
+@@ -1694,7 +1640,6 @@
+ {
+   gint len = -1;
+   gint have_data;
+-  gboolean iskeyframe;
+   gboolean mode_switch;
+   gboolean decode;
+   gint skip_frame = AVDISCARD_DEFAULT;
+@@ -1809,7 +1754,6 @@
+     gst_ffmpegdec_negotiate (ffmpegdec, TRUE);
+   }
+ 
+-
+   /* Whether a frame is interlaced or not is unknown at the time of
+      buffer allocation, so caps on the buffer in opaque will have
+      the previous frame's interlaced flag set. So if interlacedness
+@@ -1831,10 +1775,6 @@
+     }
+   }
+ 
+-  /* check if we are dealing with a keyframe here, this will also check if we
+-   * are dealing with B frames. */
+-  iskeyframe = check_keyframe (ffmpegdec);
+-
+   /* check that the timestamps go upwards */
+   if (ffmpegdec->last_out != -1 && ffmpegdec->last_out > out_pts) {
+     /* timestamps go backwards, this means frames were reordered and we must
+@@ -1865,7 +1805,7 @@
+    * timestamps */
+   if (!ffmpegdec->reordered_in && ffmpegdec->reordered_out) {
+     /* PTS and DTS are the same for keyframes */
+-    if (!iskeyframe && ffmpegdec->next_out != -1) {
++    if (ffmpegdec->next_out != -1) {
+       /* interpolate all timestamps except for keyframes, FIXME, this is
+        * wrong when QoS is active. */
+       GST_DEBUG_OBJECT (ffmpegdec, "interpolate timestamps");
+@@ -1874,16 +1814,6 @@
+     }
+   }
+ 
+-  /* when we're waiting for a keyframe, see if we have one or drop the current
+-   * non-keyframe */
+-  if (G_UNLIKELY (ffmpegdec->waiting_for_key)) {
+-    if (G_LIKELY (!iskeyframe))
+-      goto drop_non_keyframe;
+-
+-    /* we have a keyframe, we can stop waiting for one */
+-    ffmpegdec->waiting_for_key = FALSE;
+-  }
+-
+   /* get a handle to the output buffer */
+   *ret = get_output_buffer (ffmpegdec, outbuf);
+   if (G_UNLIKELY (*ret != GST_FLOW_OK))
+@@ -2000,20 +1930,11 @@
+   else
+     ffmpegdec->next_out = -1;
+ 
+-  /* palette is not part of raw video frame in gst and the size
+-   * of the outgoing buffer needs to be adjusted accordingly */
+-  if (ffmpegdec->context->palctrl != NULL)
+-    GST_BUFFER_SIZE (*outbuf) -= AVPALETTE_SIZE;
+-
+   /* now see if we need to clip the buffer against the segment boundaries. */
+   if (G_UNLIKELY (!clip_video_buffer (ffmpegdec, *outbuf, out_timestamp,
+               out_duration)))
+     goto clipped;
+ 
+-  /* mark as keyframe or delta unit */
+-  if (!iskeyframe)
+-    GST_BUFFER_FLAG_SET (*outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
+-
+   if (ffmpegdec->picture->top_field_first)
+     GST_BUFFER_FLAG_SET (*outbuf, GST_VIDEO_BUFFER_TFF);
+ 
+@@ -2024,11 +1945,6 @@
+   return len;
+ 
+   /* special cases */
+-drop_non_keyframe:
+-  {
+-    GST_WARNING_OBJECT (ffmpegdec, "Dropping non-keyframe (seek/init)");
+-    goto beach;
+-  }
+ no_output:
+   {
+     GST_DEBUG_OBJECT (ffmpegdec, "no output buffer");
+@@ -2422,7 +2338,6 @@
+       gst_ffmpegdec_reset_ts (ffmpegdec);
+       gst_ffmpegdec_reset_qos (ffmpegdec);
+       gst_ffmpegdec_flush_pcache (ffmpegdec);
+-      ffmpegdec->waiting_for_key = TRUE;
+       gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
+       clear_queued (ffmpegdec);
+       break;
+@@ -2560,17 +2475,6 @@
+ 
+   oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+ 
+-  /* do early keyframe check pretty bad to rely on the keyframe flag in the
+-   * source for this as it might not even be parsed (UDP/file/..).  */
+-  if (G_UNLIKELY (ffmpegdec->waiting_for_key)) {
+-    GST_DEBUG_OBJECT (ffmpegdec, "waiting for keyframe");
+-    if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_DELTA_UNIT) &&
+-        oclass->in_plugin->type != AVMEDIA_TYPE_AUDIO)
+-      goto skip_keyframe;
+-
+-    GST_DEBUG_OBJECT (ffmpegdec, "got keyframe");
+-    ffmpegdec->waiting_for_key = FALSE;
+-  }
+   /* parse cache joining. If there is cached data */
+   if (ffmpegdec->pcache) {
+     /* join with previous data */
+@@ -2805,12 +2709,6 @@
+     gst_buffer_unref (inbuf);
+     return GST_FLOW_NOT_NEGOTIATED;
+   }
+-skip_keyframe:
+-  {
+-    GST_DEBUG_OBJECT (ffmpegdec, "skipping non keyframe");
+-    gst_buffer_unref (inbuf);
+-    return GST_FLOW_OK;
+-  }
+ }
+ 
+ static GstStateChangeReturn
+@@ -2936,7 +2834,7 @@
+     gchar *plugin_name;
+ 
+     /* only decoders */
+-    if (!in_plugin->decode) {
++    if (!av_codec_is_decoder (in_plugin)) {
+       goto next;
+     }
+ 
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.orig
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.orig	1970-01-01 01:00:00.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.orig	2014-08-08 15:31:06.057868246 +0200
+@@ -0,0 +1,2973 @@
++/* 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 <assert.h>
++#include <string.h>
++
++#ifdef HAVE_FFMPEG_UNINSTALLED
++#include <avcodec.h>
++#else
++#include <libavcodec/avcodec.h>
++#endif
++
++#include <gst/gst.h>
++#include <gst/video/video.h>
++
++#include "gstffmpeg.h"
++#include "gstffmpegcodecmap.h"
++#include "gstffmpegutils.h"
++
++/* define to enable alternative buffer refcounting algorithm */
++#undef EXTRA_REF
++
++typedef struct _GstFFMpegDec GstFFMpegDec;
++
++#define MAX_TS_MASK 0xff
++
++/* for each incomming buffer we keep all timing info in a structure like this.
++ * We keep a circular array of these structures around to store the timing info.
++ * The index in the array is what we pass as opaque data (to pictures) and
++ * pts (to parsers) so that ffmpeg can remember them for us. */
++typedef struct
++{
++  gint idx;
++  GstClockTime timestamp;
++  GstClockTime duration;
++  gint64 offset;
++} GstTSInfo;
++
++struct _GstFFMpegDec
++{
++  GstElement element;
++
++  /* We need to keep track of our pads, so we do so here. */
++  GstPad *srcpad;
++  GstPad *sinkpad;
++
++  /* decoding */
++  AVCodecContext *context;
++  AVFrame *picture;
++  gboolean opened;
++  union
++  {
++    struct
++    {
++      gint width, height;
++      gint clip_width, clip_height;
++      gint par_n, par_d;
++      gint fps_n, fps_d;
++      gint old_fps_n, old_fps_d;
++      gboolean interlaced;
++
++      enum PixelFormat pix_fmt;
++    } video;
++    struct
++    {
++      gint channels;
++      gint samplerate;
++      gint depth;
++    } audio;
++  } format;
++  gboolean discont;
++  gboolean clear_ts;
++
++  /* for tracking DTS/PTS */
++  gboolean has_b_frames;
++  gboolean reordered_in;
++  GstClockTime last_in;
++  GstClockTime last_diff;
++  guint last_frames;
++  gboolean reordered_out;
++  GstClockTime last_out;
++  GstClockTime next_out;
++
++  /* parsing */
++  gboolean turnoff_parser;      /* used for turning off aac raw parsing
++                                 * See bug #566250 */
++  AVCodecParserContext *pctx;
++  GstBuffer *pcache;
++  guint8 *padded;
++  guint padded_size;
++
++  GValue *par;                  /* pixel aspect ratio of incoming data */
++  gboolean current_dr;          /* if direct rendering is enabled */
++  gboolean extra_ref;           /* keep extra ref around in get/release */
++
++  /* some properties */
++  enum AVDiscard skip_frame;
++  gint lowres;
++  gboolean direct_rendering;
++  gboolean do_padding;
++  gboolean debug_mv;
++  gboolean crop;
++  int max_threads;
++
++  /* QoS stuff *//* with LOCK */
++  gdouble proportion;
++  GstClockTime earliest_time;
++  gint64 processed;
++  gint64 dropped;
++
++  /* clipping segment */
++  GstSegment segment;
++
++  gboolean is_realvideo;
++
++  GstTSInfo ts_info[MAX_TS_MASK + 1];
++  gint ts_idx;
++
++  /* reverse playback queue */
++  GList *queued;
++
++  /* Can downstream allocate 16bytes aligned data. */
++  gboolean can_allocate_aligned;
++};
++
++typedef struct _GstFFMpegDecClass GstFFMpegDecClass;
++
++struct _GstFFMpegDecClass
++{
++  GstElementClass parent_class;
++
++  AVCodec *in_plugin;
++  GstPadTemplate *srctempl, *sinktempl;
++};
++
++#define GST_TS_INFO_NONE &ts_info_none
++static const GstTSInfo ts_info_none = { -1, -1, -1, -1 };
++
++static const GstTSInfo *
++gst_ts_info_store (GstFFMpegDec * dec, GstClockTime timestamp,
++    GstClockTime duration, gint64 offset)
++{
++  gint idx = dec->ts_idx;
++  dec->ts_info[idx].idx = idx;
++  dec->ts_info[idx].timestamp = timestamp;
++  dec->ts_info[idx].duration = duration;
++  dec->ts_info[idx].offset = offset;
++  dec->ts_idx = (idx + 1) & MAX_TS_MASK;
++
++  return &dec->ts_info[idx];
++}
++
++static const GstTSInfo *
++gst_ts_info_get (GstFFMpegDec * dec, gint idx)
++{
++  if (G_UNLIKELY (idx < 0 || idx > MAX_TS_MASK))
++    return GST_TS_INFO_NONE;
++
++  return &dec->ts_info[idx];
++}
++
++#define GST_TYPE_FFMPEGDEC \
++  (gst_ffmpegdec_get_type())
++#define GST_FFMPEGDEC(obj) \
++  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGDEC,GstFFMpegDec))
++#define GST_FFMPEGDEC_CLASS(klass) \
++  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGDEC,GstFFMpegDecClass))
++#define GST_IS_FFMPEGDEC(obj) \
++  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGDEC))
++#define GST_IS_FFMPEGDEC_CLASS(klass) \
++  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGDEC))
++
++#define DEFAULT_LOWRES			0
++#define DEFAULT_SKIPFRAME		0
++#define DEFAULT_DIRECT_RENDERING	TRUE
++#define DEFAULT_DO_PADDING		TRUE
++#define DEFAULT_DEBUG_MV		FALSE
++#define DEFAULT_CROP			TRUE
++#define DEFAULT_MAX_THREADS		1
++
++enum
++{
++  PROP_0,
++  PROP_LOWRES,
++  PROP_SKIPFRAME,
++  PROP_DIRECT_RENDERING,
++  PROP_DO_PADDING,
++  PROP_DEBUG_MV,
++  PROP_CROP,
++  PROP_MAX_THREADS,
++  PROP_LAST
++};
++
++/* A number of function prototypes are given so we can refer to them later. */
++static void gst_ffmpegdec_base_init (GstFFMpegDecClass * klass);
++static void gst_ffmpegdec_class_init (GstFFMpegDecClass * klass);
++static void gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec);
++static void gst_ffmpegdec_finalize (GObject * object);
++
++static gboolean gst_ffmpegdec_query (GstPad * pad, GstQuery * query);
++static gboolean gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event);
++
++static gboolean gst_ffmpegdec_setcaps (GstPad * pad, GstCaps * caps);
++static gboolean gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event);
++static GstFlowReturn gst_ffmpegdec_chain (GstPad * pad, GstBuffer * buf);
++
++static GstStateChangeReturn gst_ffmpegdec_change_state (GstElement * element,
++    GstStateChange transition);
++
++static void gst_ffmpegdec_set_property (GObject * object,
++    guint prop_id, const GValue * value, GParamSpec * pspec);
++static void gst_ffmpegdec_get_property (GObject * object,
++    guint prop_id, GValue * value, GParamSpec * pspec);
++
++static gboolean gst_ffmpegdec_negotiate (GstFFMpegDec * ffmpegdec,
++    gboolean force);
++
++/* some sort of bufferpool handling, but different */
++static int gst_ffmpegdec_get_buffer (AVCodecContext * context,
++    AVFrame * picture);
++static void gst_ffmpegdec_release_buffer (AVCodecContext * context,
++    AVFrame * picture);
++
++static void gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec);
++
++#define GST_FFDEC_PARAMS_QDATA g_quark_from_static_string("ffdec-params")
++
++static GstElementClass *parent_class = NULL;
++
++#define GST_FFMPEGDEC_TYPE_LOWRES (gst_ffmpegdec_lowres_get_type())
++static GType
++gst_ffmpegdec_lowres_get_type (void)
++{
++  static GType ffmpegdec_lowres_type = 0;
++
++  if (!ffmpegdec_lowres_type) {
++    static const GEnumValue ffmpegdec_lowres[] = {
++      {0, "0", "full"},
++      {1, "1", "1/2-size"},
++      {2, "2", "1/4-size"},
++      {0, NULL, NULL},
++    };
++
++    ffmpegdec_lowres_type =
++        g_enum_register_static ("GstFFMpegDecLowres", ffmpegdec_lowres);
++  }
++
++  return ffmpegdec_lowres_type;
++}
++
++#define GST_FFMPEGDEC_TYPE_SKIPFRAME (gst_ffmpegdec_skipframe_get_type())
++static GType
++gst_ffmpegdec_skipframe_get_type (void)
++{
++  static GType ffmpegdec_skipframe_type = 0;
++
++  if (!ffmpegdec_skipframe_type) {
++    static const GEnumValue ffmpegdec_skipframe[] = {
++      {0, "0", "Skip nothing"},
++      {1, "1", "Skip B-frames"},
++      {2, "2", "Skip IDCT/Dequantization"},
++      {5, "5", "Skip everything"},
++      {0, NULL, NULL},
++    };
++
++    ffmpegdec_skipframe_type =
++        g_enum_register_static ("GstFFMpegDecSkipFrame", ffmpegdec_skipframe);
++  }
++
++  return ffmpegdec_skipframe_type;
++}
++
++static void
++gst_ffmpegdec_base_init (GstFFMpegDecClass * klass)
++{
++  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
++  GstPadTemplate *sinktempl, *srctempl;
++  GstCaps *sinkcaps, *srccaps;
++  AVCodec *in_plugin;
++  gchar *longname, *classification, *description;
++
++  in_plugin =
++      (AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
++      GST_FFDEC_PARAMS_QDATA);
++  g_assert (in_plugin != NULL);
++
++  /* construct the element details struct */
++  longname = g_strdup_printf ("FFmpeg %s decoder", in_plugin->long_name);
++  classification = g_strdup_printf ("Codec/Decoder/%s",
++      (in_plugin->type == AVMEDIA_TYPE_VIDEO) ? "Video" : "Audio");
++  description = g_strdup_printf ("FFmpeg %s decoder", in_plugin->name);
++  gst_element_class_set_details_simple (element_class, longname, classification,
++      description,
++      "Wim Taymans <wim.taymans@gmail.com>, "
++      "Ronald Bultje <rbultje@ronald.bitfreak.net>, "
++      "Edward Hervey <bilboed@bilboed.com>");
++  g_free (longname);
++  g_free (classification);
++  g_free (description);
++
++  /* get the caps */
++  sinkcaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, FALSE);
++  if (!sinkcaps) {
++    GST_DEBUG ("Couldn't get sink caps for decoder '%s'", in_plugin->name);
++    sinkcaps = gst_caps_from_string ("unknown/unknown");
++  }
++  if (in_plugin->type == AVMEDIA_TYPE_VIDEO) {
++    srccaps = gst_caps_from_string ("video/x-raw-rgb; video/x-raw-yuv");
++  } else {
++    srccaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
++        in_plugin->id, FALSE, in_plugin);
++  }
++  if (!srccaps) {
++    GST_DEBUG ("Couldn't get source caps for decoder '%s'", in_plugin->name);
++    srccaps = gst_caps_from_string ("unknown/unknown");
++  }
++
++  /* pad templates */
++  sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
++      GST_PAD_ALWAYS, sinkcaps);
++  srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
++
++  gst_element_class_add_pad_template (element_class, srctempl);
++  gst_element_class_add_pad_template (element_class, sinktempl);
++
++  klass->in_plugin = in_plugin;
++  klass->srctempl = srctempl;
++  klass->sinktempl = sinktempl;
++}
++
++static void
++gst_ffmpegdec_class_init (GstFFMpegDecClass * klass)
++{
++  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
++  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
++
++  parent_class = g_type_class_peek_parent (klass);
++
++  gobject_class->finalize = gst_ffmpegdec_finalize;
++
++  gobject_class->set_property = gst_ffmpegdec_set_property;
++  gobject_class->get_property = gst_ffmpegdec_get_property;
++
++  if (klass->in_plugin->type == AVMEDIA_TYPE_VIDEO) {
++    int caps;
++
++    g_object_class_install_property (gobject_class, PROP_SKIPFRAME,
++        g_param_spec_enum ("skip-frame", "Skip frames",
++            "Which types of frames to skip during decoding",
++            GST_FFMPEGDEC_TYPE_SKIPFRAME, 0,
++            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++    g_object_class_install_property (gobject_class, PROP_LOWRES,
++        g_param_spec_enum ("lowres", "Low resolution",
++            "At which resolution to decode images", GST_FFMPEGDEC_TYPE_LOWRES,
++            0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++    g_object_class_install_property (gobject_class, PROP_DIRECT_RENDERING,
++        g_param_spec_boolean ("direct-rendering", "Direct Rendering",
++            "Enable direct rendering", DEFAULT_DIRECT_RENDERING,
++            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++    g_object_class_install_property (gobject_class, PROP_DO_PADDING,
++        g_param_spec_boolean ("do-padding", "Do Padding",
++            "Add 0 padding before decoding data", DEFAULT_DO_PADDING,
++            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++    g_object_class_install_property (gobject_class, PROP_DEBUG_MV,
++        g_param_spec_boolean ("debug-mv", "Debug motion vectors",
++            "Whether ffmpeg should print motion vectors on top of the image",
++            DEFAULT_DEBUG_MV, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++#if 0
++    g_object_class_install_property (gobject_class, PROP_CROP,
++        g_param_spec_boolean ("crop", "Crop",
++            "Crop images to the display region",
++            DEFAULT_CROP, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++#endif
++
++    caps = klass->in_plugin->capabilities;
++    if (caps & (CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS)) {
++      g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_THREADS,
++          g_param_spec_int ("max-threads", "Maximum decode threads",
++              "Maximum number of worker threads to spawn. (0 = auto)",
++              0, G_MAXINT, DEFAULT_MAX_THREADS,
++              G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++    }
++  }
++
++  gstelement_class->change_state = gst_ffmpegdec_change_state;
++}
++
++static void
++gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec)
++{
++  GstFFMpegDecClass *oclass;
++
++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++
++  /* setup pads */
++  ffmpegdec->sinkpad = gst_pad_new_from_template (oclass->sinktempl, "sink");
++  gst_pad_set_setcaps_function (ffmpegdec->sinkpad,
++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_setcaps));
++  gst_pad_set_event_function (ffmpegdec->sinkpad,
++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_sink_event));
++  gst_pad_set_chain_function (ffmpegdec->sinkpad,
++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_chain));
++  gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->sinkpad);
++
++  ffmpegdec->srcpad = gst_pad_new_from_template (oclass->srctempl, "src");
++  gst_pad_use_fixed_caps (ffmpegdec->srcpad);
++  gst_pad_set_event_function (ffmpegdec->srcpad,
++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_src_event));
++  gst_pad_set_query_function (ffmpegdec->srcpad,
++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_query));
++  gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->srcpad);
++
++  /* some ffmpeg data */
++  ffmpegdec->context = avcodec_alloc_context ();
++  ffmpegdec->picture = avcodec_alloc_frame ();
++  ffmpegdec->pctx = NULL;
++  ffmpegdec->pcache = NULL;
++  ffmpegdec->par = NULL;
++  ffmpegdec->opened = FALSE;
++  ffmpegdec->skip_frame = ffmpegdec->lowres = 0;
++  ffmpegdec->direct_rendering = DEFAULT_DIRECT_RENDERING;
++  ffmpegdec->do_padding = DEFAULT_DO_PADDING;
++  ffmpegdec->debug_mv = DEFAULT_DEBUG_MV;
++  ffmpegdec->crop = DEFAULT_CROP;
++  ffmpegdec->max_threads = DEFAULT_MAX_THREADS;
++
++  ffmpegdec->format.video.par_n = -1;
++  ffmpegdec->format.video.fps_n = -1;
++  ffmpegdec->format.video.old_fps_n = -1;
++  gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
++
++  /* We initially assume downstream can allocate 16 bytes aligned buffers */
++  ffmpegdec->can_allocate_aligned = TRUE;
++}
++
++static void
++gst_ffmpegdec_finalize (GObject * object)
++{
++  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
++
++  if (ffmpegdec->context != NULL) {
++    av_free (ffmpegdec->context);
++    ffmpegdec->context = NULL;
++  }
++
++  if (ffmpegdec->picture != NULL) {
++    av_free (ffmpegdec->picture);
++    ffmpegdec->picture = NULL;
++  }
++
++  G_OBJECT_CLASS (parent_class)->finalize (object);
++}
++
++static gboolean
++gst_ffmpegdec_query (GstPad * pad, GstQuery * query)
++{
++  GstFFMpegDec *ffmpegdec;
++  GstPad *peer;
++  gboolean res;
++
++  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
++
++  res = FALSE;
++
++  if ((peer = gst_pad_get_peer (ffmpegdec->sinkpad))) {
++    /* just forward to peer */
++    res = gst_pad_query (peer, query);
++    gst_object_unref (peer);
++  }
++#if 0
++  {
++    GstFormat bfmt;
++
++    bfmt = GST_FORMAT_BYTES;
++
++    /* ok, do bitrate calc... */
++    if ((type != GST_QUERY_POSITION && type != GST_QUERY_TOTAL) ||
++        *fmt != GST_FORMAT_TIME || ffmpegdec->context->bit_rate == 0 ||
++        !gst_pad_query (peer, type, &bfmt, value))
++      return FALSE;
++
++    if (ffmpegdec->pcache && type == GST_QUERY_POSITION)
++      *value -= GST_BUFFER_SIZE (ffmpegdec->pcache);
++    *value *= GST_SECOND / ffmpegdec->context->bit_rate;
++  }
++#endif
++
++  gst_object_unref (ffmpegdec);
++
++  return res;
++}
++
++static void
++gst_ffmpegdec_reset_ts (GstFFMpegDec * ffmpegdec)
++{
++  ffmpegdec->last_in = GST_CLOCK_TIME_NONE;
++  ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
++  ffmpegdec->last_frames = 0;
++  ffmpegdec->last_out = GST_CLOCK_TIME_NONE;
++  ffmpegdec->next_out = GST_CLOCK_TIME_NONE;
++  ffmpegdec->reordered_in = FALSE;
++  ffmpegdec->reordered_out = FALSE;
++}
++
++static void
++gst_ffmpegdec_update_qos (GstFFMpegDec * ffmpegdec, gdouble proportion,
++    GstClockTime timestamp)
++{
++  GST_LOG_OBJECT (ffmpegdec, "update QOS: %f, %" GST_TIME_FORMAT,
++      proportion, GST_TIME_ARGS (timestamp));
++
++  GST_OBJECT_LOCK (ffmpegdec);
++  ffmpegdec->proportion = proportion;
++  ffmpegdec->earliest_time = timestamp;
++  GST_OBJECT_UNLOCK (ffmpegdec);
++}
++
++static void
++gst_ffmpegdec_reset_qos (GstFFMpegDec * ffmpegdec)
++{
++  gst_ffmpegdec_update_qos (ffmpegdec, 0.5, GST_CLOCK_TIME_NONE);
++  ffmpegdec->processed = 0;
++  ffmpegdec->dropped = 0;
++}
++
++static void
++gst_ffmpegdec_read_qos (GstFFMpegDec * ffmpegdec, gdouble * proportion,
++    GstClockTime * timestamp)
++{
++  GST_OBJECT_LOCK (ffmpegdec);
++  *proportion = ffmpegdec->proportion;
++  *timestamp = ffmpegdec->earliest_time;
++  GST_OBJECT_UNLOCK (ffmpegdec);
++}
++
++static gboolean
++gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event)
++{
++  GstFFMpegDec *ffmpegdec;
++  gboolean res;
++
++  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
++
++  switch (GST_EVENT_TYPE (event)) {
++    case GST_EVENT_QOS:
++    {
++      gdouble proportion;
++      GstClockTimeDiff diff;
++      GstClockTime timestamp;
++
++      gst_event_parse_qos (event, &proportion, &diff, &timestamp);
++
++      /* update our QoS values */
++      gst_ffmpegdec_update_qos (ffmpegdec, proportion, timestamp + diff);
++
++      /* forward upstream */
++      res = gst_pad_push_event (ffmpegdec->sinkpad, event);
++      break;
++    }
++    default:
++      /* forward upstream */
++      res = gst_pad_push_event (ffmpegdec->sinkpad, event);
++      break;
++  }
++
++  gst_object_unref (ffmpegdec);
++
++  return res;
++}
++
++/* with LOCK */
++static void
++gst_ffmpegdec_close (GstFFMpegDec * ffmpegdec)
++{
++  if (!ffmpegdec->opened)
++    return;
++
++  GST_LOG_OBJECT (ffmpegdec, "closing ffmpeg codec");
++
++  if (ffmpegdec->par) {
++    g_free (ffmpegdec->par);
++    ffmpegdec->par = NULL;
++  }
++
++  if (ffmpegdec->context->priv_data)
++    gst_ffmpeg_avcodec_close (ffmpegdec->context);
++  ffmpegdec->opened = FALSE;
++
++  if (ffmpegdec->context->extradata) {
++    av_free (ffmpegdec->context->extradata);
++    ffmpegdec->context->extradata = NULL;
++  }
++
++  if (ffmpegdec->pctx) {
++    if (ffmpegdec->pcache) {
++      gst_buffer_unref (ffmpegdec->pcache);
++      ffmpegdec->pcache = NULL;
++    }
++    av_parser_close (ffmpegdec->pctx);
++    ffmpegdec->pctx = NULL;
++  }
++
++  ffmpegdec->format.video.par_n = -1;
++  ffmpegdec->format.video.fps_n = -1;
++  ffmpegdec->format.video.old_fps_n = -1;
++  ffmpegdec->format.video.interlaced = FALSE;
++}
++
++/* with LOCK */
++static gboolean
++gst_ffmpegdec_open (GstFFMpegDec * ffmpegdec)
++{
++  GstFFMpegDecClass *oclass;
++
++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++
++  if (gst_ffmpeg_avcodec_open (ffmpegdec->context, oclass->in_plugin) < 0)
++    goto could_not_open;
++
++  ffmpegdec->opened = TRUE;
++  ffmpegdec->is_realvideo = FALSE;
++
++  GST_LOG_OBJECT (ffmpegdec, "Opened ffmpeg codec %s, id %d",
++      oclass->in_plugin->name, oclass->in_plugin->id);
++
++  /* open a parser if we can */
++  switch (oclass->in_plugin->id) {
++    case CODEC_ID_MPEG4:
++    case CODEC_ID_MJPEG:
++    case CODEC_ID_VC1:
++      GST_LOG_OBJECT (ffmpegdec, "not using parser, blacklisted codec");
++      ffmpegdec->pctx = NULL;
++      break;
++    case CODEC_ID_H264:
++      /* For H264, only use a parser if there is no context data, if there is, 
++       * we're talking AVC */
++      if (ffmpegdec->context->extradata_size == 0) {
++        GST_LOG_OBJECT (ffmpegdec, "H264 with no extradata, creating parser");
++        ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
++      } else {
++        GST_LOG_OBJECT (ffmpegdec,
++            "H264 with extradata implies framed data - not using parser");
++        ffmpegdec->pctx = NULL;
++      }
++      break;
++    case CODEC_ID_RV10:
++    case CODEC_ID_RV30:
++    case CODEC_ID_RV20:
++    case CODEC_ID_RV40:
++      ffmpegdec->is_realvideo = TRUE;
++      break;
++    default:
++      if (!ffmpegdec->turnoff_parser) {
++        ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
++        if (ffmpegdec->pctx)
++          GST_LOG_OBJECT (ffmpegdec, "Using parser %p", ffmpegdec->pctx);
++        else
++          GST_LOG_OBJECT (ffmpegdec, "No parser for codec");
++      } else {
++        GST_LOG_OBJECT (ffmpegdec, "Parser deactivated for format");
++      }
++      break;
++  }
++
++  switch (oclass->in_plugin->type) {
++    case AVMEDIA_TYPE_VIDEO:
++      ffmpegdec->format.video.width = 0;
++      ffmpegdec->format.video.height = 0;
++      ffmpegdec->format.video.clip_width = -1;
++      ffmpegdec->format.video.clip_height = -1;
++      ffmpegdec->format.video.pix_fmt = PIX_FMT_NB;
++      ffmpegdec->format.video.interlaced = FALSE;
++      break;
++    case AVMEDIA_TYPE_AUDIO:
++      ffmpegdec->format.audio.samplerate = 0;
++      ffmpegdec->format.audio.channels = 0;
++      ffmpegdec->format.audio.depth = 0;
++      break;
++    default:
++      break;
++  }
++
++  gst_ffmpegdec_reset_ts (ffmpegdec);
++  /* FIXME, reset_qos holds the LOCK */
++  ffmpegdec->proportion = 0.0;
++  ffmpegdec->earliest_time = -1;
++
++  return TRUE;
++
++  /* ERRORS */
++could_not_open:
++  {
++    gst_ffmpegdec_close (ffmpegdec);
++    GST_DEBUG_OBJECT (ffmpegdec, "ffdec_%s: Failed to open FFMPEG codec",
++        oclass->in_plugin->name);
++    return FALSE;
++  }
++}
++
++static gboolean
++gst_ffmpegdec_setcaps (GstPad * pad, GstCaps * caps)
++{
++  GstFFMpegDec *ffmpegdec;
++  GstFFMpegDecClass *oclass;
++  GstStructure *structure;
++  const GValue *par;
++  const GValue *fps;
++  gboolean ret = TRUE;
++
++  ffmpegdec = (GstFFMpegDec *) (gst_pad_get_parent (pad));
++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++
++  GST_DEBUG_OBJECT (pad, "setcaps called");
++
++  GST_OBJECT_LOCK (ffmpegdec);
++
++  /* stupid check for VC1 */
++  if ((oclass->in_plugin->id == CODEC_ID_WMV3) ||
++      (oclass->in_plugin->id == CODEC_ID_VC1))
++    oclass->in_plugin->id = gst_ffmpeg_caps_to_codecid (caps, NULL);
++
++  /* close old session */
++  if (ffmpegdec->opened) {
++    GST_OBJECT_UNLOCK (ffmpegdec);
++    gst_ffmpegdec_drain (ffmpegdec);
++    GST_OBJECT_LOCK (ffmpegdec);
++    gst_ffmpegdec_close (ffmpegdec);
++
++    /* and reset the defaults that were set when a context is created */
++    avcodec_get_context_defaults (ffmpegdec->context);
++  }
++
++  /* set buffer functions */
++  ffmpegdec->context->get_buffer = gst_ffmpegdec_get_buffer;
++  ffmpegdec->context->release_buffer = gst_ffmpegdec_release_buffer;
++  ffmpegdec->context->draw_horiz_band = NULL;
++
++  /* default is to let format decide if it needs a parser */
++  ffmpegdec->turnoff_parser = FALSE;
++
++  ffmpegdec->has_b_frames = FALSE;
++
++  GST_LOG_OBJECT (ffmpegdec, "size %dx%d", ffmpegdec->context->width,
++      ffmpegdec->context->height);
++
++  /* get size and so */
++  gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
++      oclass->in_plugin->type, caps, ffmpegdec->context);
++
++  GST_LOG_OBJECT (ffmpegdec, "size after %dx%d", ffmpegdec->context->width,
++      ffmpegdec->context->height);
++
++  if (!ffmpegdec->context->time_base.den || !ffmpegdec->context->time_base.num) {
++    GST_DEBUG_OBJECT (ffmpegdec, "forcing 25/1 framerate");
++    ffmpegdec->context->time_base.num = 1;
++    ffmpegdec->context->time_base.den = 25;
++  }
++
++  /* get pixel aspect ratio if it's set */
++  structure = gst_caps_get_structure (caps, 0);
++
++  par = gst_structure_get_value (structure, "pixel-aspect-ratio");
++  if (par) {
++    GST_DEBUG_OBJECT (ffmpegdec, "sink caps have pixel-aspect-ratio of %d:%d",
++        gst_value_get_fraction_numerator (par),
++        gst_value_get_fraction_denominator (par));
++    /* should be NULL */
++    if (ffmpegdec->par)
++      g_free (ffmpegdec->par);
++    ffmpegdec->par = g_new0 (GValue, 1);
++    gst_value_init_and_copy (ffmpegdec->par, par);
++  }
++
++  /* get the framerate from incoming caps. fps_n is set to -1 when
++   * there is no valid framerate */
++  fps = gst_structure_get_value (structure, "framerate");
++  if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
++    ffmpegdec->format.video.fps_n = gst_value_get_fraction_numerator (fps);
++    ffmpegdec->format.video.fps_d = gst_value_get_fraction_denominator (fps);
++    GST_DEBUG_OBJECT (ffmpegdec, "Using framerate %d/%d from incoming caps",
++        ffmpegdec->format.video.fps_n, ffmpegdec->format.video.fps_d);
++  } else {
++    ffmpegdec->format.video.fps_n = -1;
++    GST_DEBUG_OBJECT (ffmpegdec, "Using framerate from codec");
++  }
++
++  /* figure out if we can use direct rendering */
++  ffmpegdec->current_dr = FALSE;
++  ffmpegdec->extra_ref = FALSE;
++  if (ffmpegdec->direct_rendering) {
++    GST_DEBUG_OBJECT (ffmpegdec, "trying to enable direct rendering");
++    if (oclass->in_plugin->capabilities & CODEC_CAP_DR1) {
++      if (oclass->in_plugin->id == CODEC_ID_H264) {
++        GST_DEBUG_OBJECT (ffmpegdec, "disable direct rendering setup for H264");
++        /* does not work, many stuff reads outside of the planes */
++        ffmpegdec->current_dr = FALSE;
++        ffmpegdec->extra_ref = TRUE;
++      } else if ((oclass->in_plugin->id == CODEC_ID_SVQ1) ||
++          (oclass->in_plugin->id == CODEC_ID_VP5) ||
++          (oclass->in_plugin->id == CODEC_ID_VP6) ||
++          (oclass->in_plugin->id == CODEC_ID_VP6F) ||
++          (oclass->in_plugin->id == CODEC_ID_VP6A)) {
++        GST_DEBUG_OBJECT (ffmpegdec,
++            "disable direct rendering setup for broken stride support");
++        /* does not work, uses a incompatible stride. See #610613 */
++        ffmpegdec->current_dr = FALSE;
++        ffmpegdec->extra_ref = TRUE;
++      } else {
++        GST_DEBUG_OBJECT (ffmpegdec, "enabled direct rendering");
++        ffmpegdec->current_dr = TRUE;
++      }
++    } else {
++      GST_DEBUG_OBJECT (ffmpegdec, "direct rendering not supported");
++    }
++  }
++  if (ffmpegdec->current_dr) {
++    /* do *not* draw edges when in direct rendering, for some reason it draws
++     * outside of the memory. */
++    ffmpegdec->context->flags |= CODEC_FLAG_EMU_EDGE;
++  }
++
++  /* for AAC we only use av_parse if not on stream-format==raw or ==loas */
++  if (oclass->in_plugin->id == CODEC_ID_AAC
++      || oclass->in_plugin->id == CODEC_ID_AAC_LATM) {
++    const gchar *format = gst_structure_get_string (structure, "stream-format");
++
++    if (format == NULL || strcmp (format, "raw") == 0) {
++      ffmpegdec->turnoff_parser = TRUE;
++    }
++  }
++
++  /* for FLAC, don't parse if it's already parsed */
++  if (oclass->in_plugin->id == CODEC_ID_FLAC) {
++    if (gst_structure_has_field (structure, "streamheader"))
++      ffmpegdec->turnoff_parser = TRUE;
++  }
++
++  /* workaround encoder bugs */
++  ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
++  ffmpegdec->context->err_recognition = 1;
++
++  /* for slow cpus */
++  ffmpegdec->context->lowres = ffmpegdec->lowres;
++  ffmpegdec->context->skip_frame = ffmpegdec->skip_frame;
++
++  /* ffmpeg can draw motion vectors on top of the image (not every decoder
++   * supports it) */
++  ffmpegdec->context->debug_mv = ffmpegdec->debug_mv;
++
++  if (ffmpegdec->max_threads == 0)
++    ffmpegdec->context->thread_count = gst_ffmpeg_auto_max_threads ();
++  else
++    ffmpegdec->context->thread_count = ffmpegdec->max_threads;
++
++  /* open codec - we don't select an output pix_fmt yet,
++   * simply because we don't know! We only get it
++   * during playback... */
++  if (!gst_ffmpegdec_open (ffmpegdec))
++    goto open_failed;
++
++  /* clipping region */
++  gst_structure_get_int (structure, "width",
++      &ffmpegdec->format.video.clip_width);
++  gst_structure_get_int (structure, "height",
++      &ffmpegdec->format.video.clip_height);
++
++  GST_DEBUG_OBJECT (pad, "clipping to %dx%d",
++      ffmpegdec->format.video.clip_width, ffmpegdec->format.video.clip_height);
++
++  /* take into account the lowres property */
++  if (ffmpegdec->format.video.clip_width != -1)
++    ffmpegdec->format.video.clip_width >>= ffmpegdec->lowres;
++  if (ffmpegdec->format.video.clip_height != -1)
++    ffmpegdec->format.video.clip_height >>= ffmpegdec->lowres;
++
++  GST_DEBUG_OBJECT (pad, "final clipping to %dx%d",
++      ffmpegdec->format.video.clip_width, ffmpegdec->format.video.clip_height);
++
++done:
++  GST_OBJECT_UNLOCK (ffmpegdec);
++
++  gst_object_unref (ffmpegdec);
++
++  return ret;
++
++  /* ERRORS */
++open_failed:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec, "Failed to open");
++    if (ffmpegdec->par) {
++      g_free (ffmpegdec->par);
++      ffmpegdec->par = NULL;
++    }
++    ret = FALSE;
++    goto done;
++  }
++}
++
++static GstFlowReturn
++alloc_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf,
++    gint width, gint height)
++{
++  GstFlowReturn ret;
++  gint fsize;
++
++  ret = GST_FLOW_ERROR;
++  *outbuf = NULL;
++
++  GST_LOG_OBJECT (ffmpegdec, "alloc output buffer");
++
++  /* see if we need renegotiation */
++  if (G_UNLIKELY (!gst_ffmpegdec_negotiate (ffmpegdec, FALSE)))
++    goto negotiate_failed;
++
++  /* get the size of the gstreamer output buffer given a
++   * width/height/format */
++  fsize = gst_ffmpeg_avpicture_get_size (ffmpegdec->context->pix_fmt,
++      width, height);
++
++  if (ffmpegdec->can_allocate_aligned) {
++    GST_LOG_OBJECT (ffmpegdec, "calling pad_alloc");
++    /* no pallete, we can use the buffer size to alloc */
++    ret = gst_pad_alloc_buffer_and_set_caps (ffmpegdec->srcpad,
++        GST_BUFFER_OFFSET_NONE, fsize,
++        GST_PAD_CAPS (ffmpegdec->srcpad), outbuf);
++    if (G_UNLIKELY (ret != GST_FLOW_OK))
++      goto alloc_failed;
++
++    /* If buffer isn't 128-bit aligned, create a memaligned one ourselves */
++    if (((uintptr_t) GST_BUFFER_DATA (*outbuf)) % 16) {
++      GST_DEBUG_OBJECT (ffmpegdec,
++          "Downstream can't allocate aligned buffers.");
++      ffmpegdec->can_allocate_aligned = FALSE;
++      gst_buffer_unref (*outbuf);
++      *outbuf = new_aligned_buffer (fsize, GST_PAD_CAPS (ffmpegdec->srcpad));
++    }
++  } else {
++    GST_LOG_OBJECT (ffmpegdec,
++        "not calling pad_alloc, we have a pallete or downstream can't give 16 byte aligned buffers.");
++    /* for paletted data we can't use pad_alloc_buffer(), because
++     * fsize contains the size of the palette, so the overall size
++     * is bigger than ffmpegcolorspace's unit size, which will
++     * prompt GstBaseTransform to complain endlessly ... */
++    *outbuf = new_aligned_buffer (fsize, GST_PAD_CAPS (ffmpegdec->srcpad));
++    ret = GST_FLOW_OK;
++  }
++  /* set caps, we do this here because the buffer is still writable here and we
++   * are sure to be negotiated */
++  gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (ffmpegdec->srcpad));
++
++  return ret;
++
++  /* special cases */
++negotiate_failed:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec, "negotiate failed");
++    return GST_FLOW_NOT_NEGOTIATED;
++  }
++alloc_failed:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec, "pad_alloc failed %d (%s)", ret,
++        gst_flow_get_name (ret));
++    return ret;
++  }
++}
++
++static int
++gst_ffmpegdec_get_buffer (AVCodecContext * context, AVFrame * picture)
++{
++  GstBuffer *buf = NULL;
++  GstFFMpegDec *ffmpegdec;
++  gint width, height;
++  gint coded_width, coded_height;
++  gint res;
++
++  ffmpegdec = (GstFFMpegDec *) context->opaque;
++
++  GST_DEBUG_OBJECT (ffmpegdec, "getting buffer");
++
++  /* apply the last info we have seen to this picture, when we get the
++   * picture back from ffmpeg we can use this to correctly timestamp the output
++   * buffer */
++  picture->reordered_opaque = context->reordered_opaque;
++  /* make sure we don't free the buffer when it's not ours */
++  picture->opaque = NULL;
++
++  /* take width and height before clipping */
++  width = context->width;
++  height = context->height;
++  coded_width = context->coded_width;
++  coded_height = context->coded_height;
++
++  GST_LOG_OBJECT (ffmpegdec, "dimension %dx%d, coded %dx%d", width, height,
++      coded_width, coded_height);
++  if (!ffmpegdec->current_dr) {
++    GST_LOG_OBJECT (ffmpegdec, "direct rendering disabled, fallback alloc");
++    res = avcodec_default_get_buffer (context, picture);
++
++    GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", picture->linesize[0],
++        picture->linesize[1], picture->linesize[2]);
++    GST_LOG_OBJECT (ffmpegdec, "data %u %u %u", 0,
++        (guint) (picture->data[1] - picture->data[0]),
++        (guint) (picture->data[2] - picture->data[0]));
++    return res;
++  }
++
++  switch (context->codec_type) {
++    case AVMEDIA_TYPE_VIDEO:
++      /* some ffmpeg video plugins don't see the point in setting codec_type ... */
++    case AVMEDIA_TYPE_UNKNOWN:
++    {
++      GstFlowReturn ret;
++      gint clip_width, clip_height;
++
++      /* take final clipped output size */
++      if ((clip_width = ffmpegdec->format.video.clip_width) == -1)
++        clip_width = width;
++      if ((clip_height = ffmpegdec->format.video.clip_height) == -1)
++        clip_height = height;
++
++      GST_LOG_OBJECT (ffmpegdec, "raw outsize %d/%d", width, height);
++
++      /* this is the size ffmpeg needs for the buffer */
++      avcodec_align_dimensions (context, &width, &height);
++
++      GST_LOG_OBJECT (ffmpegdec, "aligned outsize %d/%d, clip %d/%d",
++          width, height, clip_width, clip_height);
++
++      if (width != clip_width || height != clip_height) {
++        /* We can't alloc if we need to clip the output buffer later */
++        GST_LOG_OBJECT (ffmpegdec, "we need clipping, fallback alloc");
++        return avcodec_default_get_buffer (context, picture);
++      }
++
++      /* alloc with aligned dimensions for ffmpeg */
++      ret = alloc_output_buffer (ffmpegdec, &buf, width, height);
++      if (G_UNLIKELY (ret != GST_FLOW_OK)) {
++        /* alloc default buffer when we can't get one from downstream */
++        GST_LOG_OBJECT (ffmpegdec, "alloc failed, fallback alloc");
++        return avcodec_default_get_buffer (context, picture);
++      }
++
++      /* copy the right pointers and strides in the picture object */
++      gst_ffmpeg_avpicture_fill ((AVPicture *) picture,
++          GST_BUFFER_DATA (buf), context->pix_fmt, width, height);
++      break;
++    }
++    case AVMEDIA_TYPE_AUDIO:
++    default:
++      GST_ERROR_OBJECT (ffmpegdec,
++          "_get_buffer() should never get called for non-video buffers !");
++      g_assert_not_reached ();
++      break;
++  }
++
++  /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to
++   * the opaque data. */
++  picture->type = FF_BUFFER_TYPE_USER;
++  picture->opaque = buf;
++
++#ifdef EXTRA_REF
++  if (picture->reference != 0 || ffmpegdec->extra_ref) {
++    GST_DEBUG_OBJECT (ffmpegdec, "adding extra ref");
++    gst_buffer_ref (buf);
++  }
++#endif
++
++  GST_LOG_OBJECT (ffmpegdec, "returned buffer %p", buf);
++
++  return 0;
++}
++
++static void
++gst_ffmpegdec_release_buffer (AVCodecContext * context, AVFrame * picture)
++{
++  gint i;
++  GstBuffer *buf;
++  GstFFMpegDec *ffmpegdec;
++
++  ffmpegdec = (GstFFMpegDec *) context->opaque;
++
++  /* check if it was our buffer */
++  if (picture->opaque == NULL) {
++    GST_DEBUG_OBJECT (ffmpegdec, "default release buffer");
++    avcodec_default_release_buffer (context, picture);
++    return;
++  }
++
++  /* we remove the opaque data now */
++  buf = GST_BUFFER_CAST (picture->opaque);
++  GST_DEBUG_OBJECT (ffmpegdec, "release buffer %p", buf);
++  picture->opaque = NULL;
++
++#ifdef EXTRA_REF
++  if (picture->reference != 0 || ffmpegdec->extra_ref) {
++    GST_DEBUG_OBJECT (ffmpegdec, "remove extra ref");
++    gst_buffer_unref (buf);
++  }
++#else
++  gst_buffer_unref (buf);
++#endif
++
++  /* zero out the reference in ffmpeg */
++  for (i = 0; i < 4; i++) {
++    picture->data[i] = NULL;
++    picture->linesize[i] = 0;
++  }
++}
++
++static void
++gst_ffmpegdec_add_pixel_aspect_ratio (GstFFMpegDec * ffmpegdec,
++    GstStructure * s)
++{
++  gboolean demuxer_par_set = FALSE;
++  gboolean decoder_par_set = FALSE;
++  gint demuxer_num = 1, demuxer_denom = 1;
++  gint decoder_num = 1, decoder_denom = 1;
++
++  GST_OBJECT_LOCK (ffmpegdec);
++
++  if (ffmpegdec->par) {
++    demuxer_num = gst_value_get_fraction_numerator (ffmpegdec->par);
++    demuxer_denom = gst_value_get_fraction_denominator (ffmpegdec->par);
++    demuxer_par_set = TRUE;
++    GST_DEBUG_OBJECT (ffmpegdec, "Demuxer PAR: %d:%d", demuxer_num,
++        demuxer_denom);
++  }
++
++  if (ffmpegdec->context->sample_aspect_ratio.num &&
++      ffmpegdec->context->sample_aspect_ratio.den) {
++    decoder_num = ffmpegdec->context->sample_aspect_ratio.num;
++    decoder_denom = ffmpegdec->context->sample_aspect_ratio.den;
++    decoder_par_set = TRUE;
++    GST_DEBUG_OBJECT (ffmpegdec, "Decoder PAR: %d:%d", decoder_num,
++        decoder_denom);
++  }
++
++  GST_OBJECT_UNLOCK (ffmpegdec);
++
++  if (!demuxer_par_set && !decoder_par_set)
++    goto no_par;
++
++  if (demuxer_par_set && !decoder_par_set)
++    goto use_demuxer_par;
++
++  if (decoder_par_set && !demuxer_par_set)
++    goto use_decoder_par;
++
++  /* Both the demuxer and the decoder provide a PAR. If one of
++   * the two PARs is 1:1 and the other one is not, use the one
++   * that is not 1:1. */
++  if (demuxer_num == demuxer_denom && decoder_num != decoder_denom)
++    goto use_decoder_par;
++
++  if (decoder_num == decoder_denom && demuxer_num != demuxer_denom)
++    goto use_demuxer_par;
++
++  /* Both PARs are non-1:1, so use the PAR provided by the demuxer */
++  goto use_demuxer_par;
++
++use_decoder_par:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec,
++        "Setting decoder provided pixel-aspect-ratio of %u:%u", decoder_num,
++        decoder_denom);
++    gst_structure_set (s, "pixel-aspect-ratio", GST_TYPE_FRACTION, decoder_num,
++        decoder_denom, NULL);
++    return;
++  }
++
++use_demuxer_par:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec,
++        "Setting demuxer provided pixel-aspect-ratio of %u:%u", demuxer_num,
++        demuxer_denom);
++    gst_structure_set (s, "pixel-aspect-ratio", GST_TYPE_FRACTION, demuxer_num,
++        demuxer_denom, NULL);
++    return;
++  }
++no_par:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec,
++        "Neither demuxer nor codec provide a pixel-aspect-ratio");
++    return;
++  }
++}
++
++static gboolean
++gst_ffmpegdec_negotiate (GstFFMpegDec * ffmpegdec, gboolean force)
++{
++  GstFFMpegDecClass *oclass;
++  GstCaps *caps;
++
++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++
++  switch (oclass->in_plugin->type) {
++    case AVMEDIA_TYPE_VIDEO:
++      if (!force && ffmpegdec->format.video.width == ffmpegdec->context->width
++          && ffmpegdec->format.video.height == ffmpegdec->context->height
++          && ffmpegdec->format.video.fps_n == ffmpegdec->format.video.old_fps_n
++          && ffmpegdec->format.video.fps_d == ffmpegdec->format.video.old_fps_d
++          && ffmpegdec->format.video.pix_fmt == ffmpegdec->context->pix_fmt
++          && ffmpegdec->format.video.par_n ==
++          ffmpegdec->context->sample_aspect_ratio.num
++          && ffmpegdec->format.video.par_d ==
++          ffmpegdec->context->sample_aspect_ratio.den)
++        return TRUE;
++      GST_DEBUG_OBJECT (ffmpegdec,
++          "Renegotiating video from %dx%d@ %d:%d PAR %d/%d fps to %dx%d@ %d:%d PAR %d/%d fps",
++          ffmpegdec->format.video.width, ffmpegdec->format.video.height,
++          ffmpegdec->format.video.par_n, ffmpegdec->format.video.par_d,
++          ffmpegdec->format.video.old_fps_n, ffmpegdec->format.video.old_fps_n,
++          ffmpegdec->context->width, ffmpegdec->context->height,
++          ffmpegdec->context->sample_aspect_ratio.num,
++          ffmpegdec->context->sample_aspect_ratio.den,
++          ffmpegdec->format.video.fps_n, ffmpegdec->format.video.fps_d);
++      ffmpegdec->format.video.width = ffmpegdec->context->width;
++      ffmpegdec->format.video.height = ffmpegdec->context->height;
++      ffmpegdec->format.video.old_fps_n = ffmpegdec->format.video.fps_n;
++      ffmpegdec->format.video.old_fps_d = ffmpegdec->format.video.fps_d;
++      ffmpegdec->format.video.pix_fmt = ffmpegdec->context->pix_fmt;
++      ffmpegdec->format.video.par_n =
++          ffmpegdec->context->sample_aspect_ratio.num;
++      ffmpegdec->format.video.par_d =
++          ffmpegdec->context->sample_aspect_ratio.den;
++      break;
++    case AVMEDIA_TYPE_AUDIO:
++    {
++      gint depth = av_smp_format_depth (ffmpegdec->context->sample_fmt);
++      if (!force && ffmpegdec->format.audio.samplerate ==
++          ffmpegdec->context->sample_rate &&
++          ffmpegdec->format.audio.channels == ffmpegdec->context->channels &&
++          ffmpegdec->format.audio.depth == depth)
++        return TRUE;
++      GST_DEBUG_OBJECT (ffmpegdec,
++          "Renegotiating audio from %dHz@%dchannels (%d) to %dHz@%dchannels (%d)",
++          ffmpegdec->format.audio.samplerate, ffmpegdec->format.audio.channels,
++          ffmpegdec->format.audio.depth,
++          ffmpegdec->context->sample_rate, ffmpegdec->context->channels, depth);
++      ffmpegdec->format.audio.samplerate = ffmpegdec->context->sample_rate;
++      ffmpegdec->format.audio.channels = ffmpegdec->context->channels;
++      ffmpegdec->format.audio.depth = depth;
++    }
++      break;
++    default:
++      break;
++  }
++
++  caps = gst_ffmpeg_codectype_to_caps (oclass->in_plugin->type,
++      ffmpegdec->context, oclass->in_plugin->id, FALSE);
++
++  if (caps == NULL)
++    goto no_caps;
++
++  switch (oclass->in_plugin->type) {
++    case AVMEDIA_TYPE_VIDEO:
++    {
++      gint width, height;
++      gboolean interlaced;
++
++      width = ffmpegdec->format.video.clip_width;
++      height = ffmpegdec->format.video.clip_height;
++      interlaced = ffmpegdec->format.video.interlaced;
++
++      if (width != -1 && height != -1) {
++        /* overwrite the output size with the dimension of the
++         * clipping region but only if they are smaller. */
++        if (width < ffmpegdec->context->width)
++          gst_caps_set_simple (caps, "width", G_TYPE_INT, width, NULL);
++        if (height < ffmpegdec->context->height)
++          gst_caps_set_simple (caps, "height", G_TYPE_INT, height, NULL);
++      }
++      gst_caps_set_simple (caps, "interlaced", G_TYPE_BOOLEAN, interlaced,
++          NULL);
++
++      /* If a demuxer provided a framerate then use it (#313970) */
++      if (ffmpegdec->format.video.fps_n != -1) {
++        gst_caps_set_simple (caps, "framerate",
++            GST_TYPE_FRACTION, ffmpegdec->format.video.fps_n,
++            ffmpegdec->format.video.fps_d, NULL);
++      }
++      gst_ffmpegdec_add_pixel_aspect_ratio (ffmpegdec,
++          gst_caps_get_structure (caps, 0));
++      break;
++    }
++    case AVMEDIA_TYPE_AUDIO:
++    {
++      break;
++    }
++    default:
++      break;
++  }
++
++  if (!gst_pad_set_caps (ffmpegdec->srcpad, caps))
++    goto caps_failed;
++
++  gst_caps_unref (caps);
++
++  return TRUE;
++
++  /* ERRORS */
++no_caps:
++  {
++#ifdef HAVE_FFMPEG_UNINSTALLED
++    /* using internal ffmpeg snapshot */
++    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
++        ("Could not find GStreamer caps mapping for FFmpeg codec '%s'.",
++            oclass->in_plugin->name), (NULL));
++#else
++    /* using external ffmpeg */
++    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
++        ("Could not find GStreamer caps mapping for FFmpeg codec '%s', and "
++            "you are using an external libavcodec. This is most likely due to "
++            "a packaging problem and/or libavcodec having been upgraded to a "
++            "version that is not compatible with this version of "
++            "gstreamer-ffmpeg. Make sure your gstreamer-ffmpeg and libavcodec "
++            "packages come from the same source/repository.",
++            oclass->in_plugin->name), (NULL));
++#endif
++    return FALSE;
++  }
++caps_failed:
++  {
++    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
++        ("Could not set caps for ffmpeg decoder (%s), not fixed?",
++            oclass->in_plugin->name));
++    gst_caps_unref (caps);
++
++    return FALSE;
++  }
++}
++
++/* perform qos calculations before decoding the next frame.
++ *
++ * Sets the skip_frame flag and if things are really bad, skips to the next
++ * keyframe.
++ * 
++ * Returns TRUE if the frame should be decoded, FALSE if the frame can be dropped
++ * entirely.
++ */
++static gboolean
++gst_ffmpegdec_do_qos (GstFFMpegDec * ffmpegdec, GstClockTime timestamp,
++    gboolean * mode_switch)
++{
++  GstClockTimeDiff diff;
++  gdouble proportion;
++  GstClockTime qostime, earliest_time;
++  gboolean res = TRUE;
++
++  *mode_switch = FALSE;
++
++  /* no timestamp, can't do QoS */
++  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (timestamp)))
++    goto no_qos;
++
++  /* get latest QoS observation values */
++  gst_ffmpegdec_read_qos (ffmpegdec, &proportion, &earliest_time);
++
++  /* skip qos if we have no observation (yet) */
++  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (earliest_time))) {
++    /* no skip_frame initialy */
++    ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
++    goto no_qos;
++  }
++
++  /* qos is done on running time of the timestamp */
++  qostime = gst_segment_to_running_time (&ffmpegdec->segment, GST_FORMAT_TIME,
++      timestamp);
++
++  /* timestamp can be out of segment, then we don't do QoS */
++  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (qostime)))
++    goto no_qos;
++
++  /* see how our next timestamp relates to the latest qos timestamp. negative
++   * values mean we are early, positive values mean we are too late. */
++  diff = GST_CLOCK_DIFF (qostime, earliest_time);
++
++  GST_DEBUG_OBJECT (ffmpegdec, "QOS: qostime %" GST_TIME_FORMAT
++      ", earliest %" GST_TIME_FORMAT, GST_TIME_ARGS (qostime),
++      GST_TIME_ARGS (earliest_time));
++
++  /* if we using less than 40% of the available time, we can try to
++   * speed up again when we were slow. */
++  if (proportion < 0.4 && diff < 0) {
++    goto normal_mode;
++  } else {
++    if (diff >= 0) {
++      /* we're too slow, try to speed up */
++      /* switch to skip_frame mode */
++      goto skip_frame;
++    }
++  }
++
++no_qos:
++  ffmpegdec->processed++;
++  return TRUE;
++
++normal_mode:
++  {
++    if (ffmpegdec->context->skip_frame != AVDISCARD_DEFAULT) {
++      ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
++      *mode_switch = TRUE;
++      GST_DEBUG_OBJECT (ffmpegdec, "QOS: normal mode %g < 0.4", proportion);
++    }
++    ffmpegdec->processed++;
++    return TRUE;
++  }
++skip_frame:
++  {
++    if (ffmpegdec->context->skip_frame != AVDISCARD_NONREF) {
++      ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
++      *mode_switch = TRUE;
++      GST_DEBUG_OBJECT (ffmpegdec,
++          "QOS: hurry up, diff %" G_GINT64_FORMAT " >= 0", diff);
++    }
++    goto drop_qos;
++  }
++drop_qos:
++  {
++    GstClockTime stream_time, jitter;
++    GstMessage *qos_msg;
++
++    ffmpegdec->dropped++;
++    stream_time =
++        gst_segment_to_stream_time (&ffmpegdec->segment, GST_FORMAT_TIME,
++        timestamp);
++    jitter = GST_CLOCK_DIFF (qostime, earliest_time);
++    qos_msg =
++        gst_message_new_qos (GST_OBJECT_CAST (ffmpegdec), FALSE, qostime,
++        stream_time, timestamp, GST_CLOCK_TIME_NONE);
++    gst_message_set_qos_values (qos_msg, jitter, proportion, 1000000);
++    gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
++        ffmpegdec->processed, ffmpegdec->dropped);
++    gst_element_post_message (GST_ELEMENT_CAST (ffmpegdec), qos_msg);
++
++    return res;
++  }
++}
++
++/* returns TRUE if buffer is within segment, else FALSE.
++ * if Buffer is on segment border, it's timestamp and duration will be clipped */
++static gboolean
++clip_video_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
++    GstClockTime in_dur)
++{
++  gboolean res = TRUE;
++  gint64 cstart, cstop;
++  GstClockTime stop;
++
++  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 (G_UNLIKELY (dec->segment.format != GST_FORMAT_TIME))
++    goto beach;
++
++  /* we need a start time */
++  if (G_UNLIKELY (!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 */
++  res =
++      gst_segment_clip (&dec->segment, GST_FORMAT_TIME, in_ts, stop, &cstart,
++      &cstop);
++  if (G_UNLIKELY (!res))
++    goto beach;
++
++  /* we're pretty sure the duration of this buffer is not till the end of this
++   * segment (which _clip will assume when the stop is -1) */
++  if (stop == GST_CLOCK_TIME_NONE)
++    cstop = GST_CLOCK_TIME_NONE;
++
++  /* 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;
++
++  GST_LOG_OBJECT (dec,
++      "clipped timestamp:%" GST_TIME_FORMAT " , duration:%" GST_TIME_FORMAT,
++      GST_TIME_ARGS (cstart), GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
++
++beach:
++  GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
++  return res;
++}
++
++
++/* get an outbuf buffer with the current picture */
++static GstFlowReturn
++get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
++{
++  GstFlowReturn ret;
++
++  ret = GST_FLOW_OK;
++  *outbuf = NULL;
++
++  if (ffmpegdec->picture->opaque != NULL) {
++    /* we allocated a picture already for ffmpeg to decode into, let's pick it
++     * up and use it now. */
++    *outbuf = (GstBuffer *) ffmpegdec->picture->opaque;
++    GST_LOG_OBJECT (ffmpegdec, "using opaque buffer %p", *outbuf);
++#ifndef EXTRA_REF
++    gst_buffer_ref (*outbuf);
++#endif
++  } else {
++    AVPicture pic, *outpic;
++    gint width, height;
++
++    GST_LOG_OBJECT (ffmpegdec, "get output buffer");
++
++    /* figure out size of output buffer, this is the clipped output size because
++     * we will copy the picture into it but only when the clipping region is
++     * smaller than the actual picture size. */
++    if ((width = ffmpegdec->format.video.clip_width) == -1)
++      width = ffmpegdec->context->width;
++    else if (width > ffmpegdec->context->width)
++      width = ffmpegdec->context->width;
++
++    if ((height = ffmpegdec->format.video.clip_height) == -1)
++      height = ffmpegdec->context->height;
++    else if (height > ffmpegdec->context->height)
++      height = ffmpegdec->context->height;
++
++    GST_LOG_OBJECT (ffmpegdec, "clip width %d/height %d", width, height);
++
++    ret = alloc_output_buffer (ffmpegdec, outbuf, width, height);
++    if (G_UNLIKELY (ret != GST_FLOW_OK))
++      goto alloc_failed;
++
++    /* original ffmpeg code does not handle odd sizes correctly.
++     * This patched up version does */
++    gst_ffmpeg_avpicture_fill (&pic, GST_BUFFER_DATA (*outbuf),
++        ffmpegdec->context->pix_fmt, width, height);
++
++    outpic = (AVPicture *) ffmpegdec->picture;
++
++    GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", outpic->linesize[0],
++        outpic->linesize[1], outpic->linesize[2]);
++    GST_LOG_OBJECT (ffmpegdec, "data %u %u %u", 0,
++        (guint) (outpic->data[1] - outpic->data[0]),
++        (guint) (outpic->data[2] - outpic->data[0]));
++
++    av_picture_copy (&pic, outpic, ffmpegdec->context->pix_fmt, width, height);
++  }
++  ffmpegdec->picture->reordered_opaque = -1;
++
++  return ret;
++
++  /* special cases */
++alloc_failed:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec, "pad_alloc failed");
++    return ret;
++  }
++}
++
++static void
++clear_queued (GstFFMpegDec * ffmpegdec)
++{
++  g_list_foreach (ffmpegdec->queued, (GFunc) gst_mini_object_unref, NULL);
++  g_list_free (ffmpegdec->queued);
++  ffmpegdec->queued = NULL;
++}
++
++static GstFlowReturn
++flush_queued (GstFFMpegDec * ffmpegdec)
++{
++  GstFlowReturn res = GST_FLOW_OK;
++
++  while (ffmpegdec->queued) {
++    GstBuffer *buf = GST_BUFFER_CAST (ffmpegdec->queued->data);
++
++    GST_LOG_OBJECT (ffmpegdec, "pushing buffer %p, offset %"
++        G_GUINT64_FORMAT ", timestamp %"
++        GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT, buf,
++        GST_BUFFER_OFFSET (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 (ffmpegdec->srcpad, buf);
++
++    ffmpegdec->queued =
++        g_list_delete_link (ffmpegdec->queued, ffmpegdec->queued);
++  }
++  return res;
++}
++
++static void
++gst_avpacket_init (AVPacket * packet, guint8 * data, guint size)
++{
++  memset (packet, 0, sizeof (AVPacket));
++  packet->data = data;
++  packet->size = size;
++}
++
++/* gst_ffmpegdec_[video|audio]_frame:
++ * ffmpegdec:
++ * data: pointer to the data to decode
++ * size: size of data in bytes
++ * in_timestamp: incoming timestamp.
++ * in_duration: incoming duration.
++ * in_offset: incoming offset (frame number).
++ * outbuf: outgoing buffer. Different from NULL ONLY if it contains decoded data.
++ * ret: Return flow.
++ *
++ * Returns: number of bytes used in decoding. The check for successful decode is
++ *   outbuf being non-NULL.
++ */
++static gint
++gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
++    guint8 * data, guint size,
++    const GstTSInfo * dec_info, GstBuffer ** outbuf, GstFlowReturn * ret)
++{
++  gint len = -1;
++  gint have_data;
++  gboolean mode_switch;
++  gboolean decode;
++  gint skip_frame = AVDISCARD_DEFAULT;
++  GstClockTime out_timestamp, out_duration, out_pts;
++  gint64 out_offset;
++  const GstTSInfo *out_info;
++  AVPacket packet;
++
++  *ret = GST_FLOW_OK;
++  *outbuf = NULL;
++
++  ffmpegdec->context->opaque = ffmpegdec;
++
++  /* in case we skip frames */
++  ffmpegdec->picture->pict_type = -1;
++
++  /* run QoS code, we don't stop decoding the frame when we are late because
++   * else we might skip a reference frame */
++  decode = gst_ffmpegdec_do_qos (ffmpegdec, dec_info->timestamp, &mode_switch);
++
++  if (ffmpegdec->is_realvideo && data != NULL) {
++    gint slice_count;
++    gint i;
++
++    /* setup the slice table for realvideo */
++    if (ffmpegdec->context->slice_offset == NULL)
++      ffmpegdec->context->slice_offset = g_malloc (sizeof (guint32) * 1000);
++
++    slice_count = (*data++) + 1;
++    ffmpegdec->context->slice_count = slice_count;
++
++    for (i = 0; i < slice_count; i++) {
++      data += 4;
++      ffmpegdec->context->slice_offset[i] = GST_READ_UINT32_LE (data);
++      data += 4;
++    }
++  }
++
++  if (!decode) {
++    /* no decoding needed, save previous skip_frame value and brutely skip
++     * decoding everything */
++    skip_frame = ffmpegdec->context->skip_frame;
++    ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
++  }
++
++  /* save reference to the timing info */
++  ffmpegdec->context->reordered_opaque = (gint64) dec_info->idx;
++  ffmpegdec->picture->reordered_opaque = (gint64) dec_info->idx;
++
++  GST_DEBUG_OBJECT (ffmpegdec, "stored opaque values idx %d", dec_info->idx);
++
++  /* now decode the frame */
++  gst_avpacket_init (&packet, data, size);
++  len = avcodec_decode_video2 (ffmpegdec->context,
++      ffmpegdec->picture, &have_data, &packet);
++
++  /* restore previous state */
++  if (!decode)
++    ffmpegdec->context->skip_frame = skip_frame;
++
++  GST_DEBUG_OBJECT (ffmpegdec, "after decode: len %d, have_data %d",
++      len, have_data);
++
++  /* when we are in skip_frame mode, don't complain when ffmpeg returned
++   * no data because we told it to skip stuff. */
++  if (len < 0 && (mode_switch || ffmpegdec->context->skip_frame))
++    len = 0;
++
++  if (len > 0 && have_data <= 0 && (mode_switch
++          || ffmpegdec->context->skip_frame)) {
++    /* we consumed some bytes but nothing decoded and we are skipping frames,
++     * disable the interpollation of DTS timestamps */
++    ffmpegdec->last_out = -1;
++  }
++
++  /* no data, we're done */
++  if (len < 0 || have_data <= 0)
++    goto beach;
++
++  /* get the output picture timing info again */
++  out_info = gst_ts_info_get (ffmpegdec, ffmpegdec->picture->reordered_opaque);
++  out_pts = out_info->timestamp;
++  out_duration = out_info->duration;
++  out_offset = out_info->offset;
++
++  GST_DEBUG_OBJECT (ffmpegdec,
++      "pts %" G_GUINT64_FORMAT " duration %" G_GUINT64_FORMAT " offset %"
++      G_GINT64_FORMAT, out_pts, out_duration, out_offset);
++  GST_DEBUG_OBJECT (ffmpegdec, "picture: pts %" G_GUINT64_FORMAT,
++      (guint64) ffmpegdec->picture->pts);
++  GST_DEBUG_OBJECT (ffmpegdec, "picture: num %d",
++      ffmpegdec->picture->coded_picture_number);
++  GST_DEBUG_OBJECT (ffmpegdec, "picture: ref %d",
++      ffmpegdec->picture->reference);
++  GST_DEBUG_OBJECT (ffmpegdec, "picture: display %d",
++      ffmpegdec->picture->display_picture_number);
++  GST_DEBUG_OBJECT (ffmpegdec, "picture: opaque %p",
++      ffmpegdec->picture->opaque);
++  GST_DEBUG_OBJECT (ffmpegdec, "picture: reordered opaque %" G_GUINT64_FORMAT,
++      (guint64) ffmpegdec->picture->reordered_opaque);
++  GST_DEBUG_OBJECT (ffmpegdec, "repeat_pict:%d",
++      ffmpegdec->picture->repeat_pict);
++  GST_DEBUG_OBJECT (ffmpegdec, "interlaced_frame:%d",
++      ffmpegdec->picture->interlaced_frame);
++
++  if (G_UNLIKELY (ffmpegdec->picture->interlaced_frame !=
++          ffmpegdec->format.video.interlaced)) {
++    GST_WARNING ("Change in interlacing ! picture:%d, recorded:%d",
++        ffmpegdec->picture->interlaced_frame,
++        ffmpegdec->format.video.interlaced);
++    ffmpegdec->format.video.interlaced = ffmpegdec->picture->interlaced_frame;
++    gst_ffmpegdec_negotiate (ffmpegdec, TRUE);
++  }
++
++  /* Whether a frame is interlaced or not is unknown at the time of
++     buffer allocation, so caps on the buffer in opaque will have
++     the previous frame's interlaced flag set. So if interlacedness
++     has changed since allocation, we update the buffer (if any)
++     caps now with the correct interlaced flag. */
++  if (ffmpegdec->picture->opaque != NULL) {
++    GstBuffer *buffer = ffmpegdec->picture->opaque;
++    if (GST_BUFFER_CAPS (buffer) && GST_PAD_CAPS (ffmpegdec->srcpad)) {
++      GstStructure *s = gst_caps_get_structure (GST_BUFFER_CAPS (buffer), 0);
++      gboolean interlaced;
++      gboolean found = gst_structure_get_boolean (s, "interlaced", &interlaced);
++      if (!found || (!!interlaced != !!ffmpegdec->format.video.interlaced)) {
++        GST_DEBUG_OBJECT (ffmpegdec,
++            "Buffer interlacing does not match pad, updating");
++        buffer = gst_buffer_make_metadata_writable (buffer);
++        gst_buffer_set_caps (buffer, GST_PAD_CAPS (ffmpegdec->srcpad));
++        ffmpegdec->picture->opaque = buffer;
++      }
++    }
++  }
++
++  /* check that the timestamps go upwards */
++  if (ffmpegdec->last_out != -1 && ffmpegdec->last_out > out_pts) {
++    /* timestamps go backwards, this means frames were reordered and we must
++     * be dealing with DTS as the buffer timestamps */
++    if (!ffmpegdec->reordered_out) {
++      GST_DEBUG_OBJECT (ffmpegdec, "detected reordered out timestamps");
++      ffmpegdec->reordered_out = TRUE;
++    }
++    if (ffmpegdec->reordered_in) {
++      /* we reset the input reordering here because we want to recover from an
++       * occasionally wrong reordered input timestamp */
++      GST_DEBUG_OBJECT (ffmpegdec, "assuming DTS input timestamps");
++      ffmpegdec->reordered_in = FALSE;
++    }
++  }
++
++  if (out_pts == 0 && out_pts == ffmpegdec->last_out) {
++    GST_LOG_OBJECT (ffmpegdec, "ffmpeg returns 0 timestamps, ignoring");
++    /* some codecs only output 0 timestamps, when that happens, make us select an
++     * output timestamp based on the input timestamp. We do this by making the
++     * ffmpeg timestamp and the interpollated next timestamp invalid. */
++    out_pts = -1;
++    ffmpegdec->next_out = -1;
++  } else
++    ffmpegdec->last_out = out_pts;
++
++  /* we assume DTS as input timestamps unless we see reordered input
++   * timestamps */
++  if (!ffmpegdec->reordered_in && ffmpegdec->reordered_out) {
++    /* PTS and DTS are the same for keyframes */
++    if (ffmpegdec->next_out != -1) {
++      /* interpolate all timestamps except for keyframes, FIXME, this is
++       * wrong when QoS is active. */
++      GST_DEBUG_OBJECT (ffmpegdec, "interpolate timestamps");
++      out_pts = -1;
++      out_offset = -1;
++    }
++  }
++
++  /* get a handle to the output buffer */
++  *ret = get_output_buffer (ffmpegdec, outbuf);
++  if (G_UNLIKELY (*ret != GST_FLOW_OK))
++    goto no_output;
++
++  /*
++   * Timestamps:
++   *
++   *  1) Copy picture timestamp if valid
++   *  2) else interpolate from previous output timestamp
++   *  3) else copy input timestamp
++   */
++  out_timestamp = -1;
++  if (out_pts != -1) {
++    /* Get (interpolated) timestamp from FFMPEG */
++    out_timestamp = (GstClockTime) out_pts;
++    GST_LOG_OBJECT (ffmpegdec, "using timestamp %" GST_TIME_FORMAT
++        " returned by ffmpeg", GST_TIME_ARGS (out_timestamp));
++  }
++  if (!GST_CLOCK_TIME_IS_VALID (out_timestamp) && ffmpegdec->next_out != -1) {
++    out_timestamp = ffmpegdec->next_out;
++    GST_LOG_OBJECT (ffmpegdec, "using next timestamp %" GST_TIME_FORMAT,
++        GST_TIME_ARGS (out_timestamp));
++  }
++  if (!GST_CLOCK_TIME_IS_VALID (out_timestamp)) {
++    out_timestamp = dec_info->timestamp;
++    GST_LOG_OBJECT (ffmpegdec, "using in timestamp %" GST_TIME_FORMAT,
++        GST_TIME_ARGS (out_timestamp));
++  }
++  GST_BUFFER_TIMESTAMP (*outbuf) = out_timestamp;
++
++  /*
++   * Offset:
++   *  0) Use stored input offset (from opaque)
++   *  1) Use value converted from timestamp if valid
++   *  2) Use input offset if valid
++   */
++  if (out_offset != GST_BUFFER_OFFSET_NONE) {
++    /* out_offset already contains the offset from ts_info */
++    GST_LOG_OBJECT (ffmpegdec, "Using offset returned by ffmpeg");
++  } else if (out_timestamp != GST_CLOCK_TIME_NONE) {
++    GstFormat out_fmt = GST_FORMAT_DEFAULT;
++    GST_LOG_OBJECT (ffmpegdec, "Using offset converted from timestamp");
++    /* FIXME, we should really remove this as it's not nice at all to do
++     * upstream queries for each frame to get the frame offset. We also can't
++     * really remove this because it is the only way of setting frame offsets
++     * on outgoing buffers. We should have metadata so that the upstream peer
++     * can set a frame number on the encoded data. */
++    gst_pad_query_peer_convert (ffmpegdec->sinkpad,
++        GST_FORMAT_TIME, out_timestamp, &out_fmt, &out_offset);
++  } else if (dec_info->offset != GST_BUFFER_OFFSET_NONE) {
++    /* FIXME, the input offset is input media specific and might not
++     * be the same for the output media. (byte offset as input, frame number
++     * as output, for example) */
++    GST_LOG_OBJECT (ffmpegdec, "using in_offset %" G_GINT64_FORMAT,
++        dec_info->offset);
++    out_offset = dec_info->offset;
++  } else {
++    GST_LOG_OBJECT (ffmpegdec, "no valid offset found");
++    out_offset = GST_BUFFER_OFFSET_NONE;
++  }
++  GST_BUFFER_OFFSET (*outbuf) = out_offset;
++
++  /*
++   * Duration:
++   *
++   *  1) Use reordered input duration if valid
++   *  2) Else use input duration
++   *  3) else use input framerate
++   *  4) else use ffmpeg framerate
++   */
++  if (GST_CLOCK_TIME_IS_VALID (out_duration)) {
++    /* We have a valid (reordered) duration */
++    GST_LOG_OBJECT (ffmpegdec, "Using duration returned by ffmpeg");
++  } else if (GST_CLOCK_TIME_IS_VALID (dec_info->duration)) {
++    GST_LOG_OBJECT (ffmpegdec, "using in_duration");
++    out_duration = dec_info->duration;
++  } else if (GST_CLOCK_TIME_IS_VALID (ffmpegdec->last_diff)) {
++    GST_LOG_OBJECT (ffmpegdec, "using last-diff");
++    out_duration = ffmpegdec->last_diff;
++  } else {
++    /* if we have an input framerate, use that */
++    if (ffmpegdec->format.video.fps_n != -1 &&
++        (ffmpegdec->format.video.fps_n != 1000 &&
++            ffmpegdec->format.video.fps_d != 1)) {
++      GST_LOG_OBJECT (ffmpegdec, "using input framerate for duration");
++      out_duration = gst_util_uint64_scale_int (GST_SECOND,
++          ffmpegdec->format.video.fps_d, ffmpegdec->format.video.fps_n);
++    } else {
++      /* don't try to use the decoder's framerate when it seems a bit abnormal,
++       * which we assume when den >= 1000... */
++      if (ffmpegdec->context->time_base.num != 0 &&
++          (ffmpegdec->context->time_base.den > 0 &&
++              ffmpegdec->context->time_base.den < 1000)) {
++        GST_LOG_OBJECT (ffmpegdec, "using decoder's framerate for duration");
++        out_duration = gst_util_uint64_scale_int (GST_SECOND,
++            ffmpegdec->context->time_base.num *
++            ffmpegdec->context->ticks_per_frame,
++            ffmpegdec->context->time_base.den);
++      } else {
++        GST_LOG_OBJECT (ffmpegdec, "no valid duration found");
++      }
++    }
++  }
++
++  /* Take repeat_pict into account */
++  if (GST_CLOCK_TIME_IS_VALID (out_duration)) {
++    out_duration += out_duration * ffmpegdec->picture->repeat_pict / 2;
++  }
++  GST_BUFFER_DURATION (*outbuf) = out_duration;
++
++  if (out_timestamp != -1 && out_duration != -1 && out_duration != 0)
++    ffmpegdec->next_out = out_timestamp + out_duration;
++  else
++    ffmpegdec->next_out = -1;
++
++  /* now see if we need to clip the buffer against the segment boundaries. */
++  if (G_UNLIKELY (!clip_video_buffer (ffmpegdec, *outbuf, out_timestamp,
++              out_duration)))
++    goto clipped;
++
++  if (ffmpegdec->picture->top_field_first)
++    GST_BUFFER_FLAG_SET (*outbuf, GST_VIDEO_BUFFER_TFF);
++
++
++beach:
++  GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
++      *ret, *outbuf, len);
++  return len;
++
++  /* special cases */
++no_output:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec, "no output buffer");
++    len = -1;
++    goto beach;
++  }
++clipped:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec, "buffer clipped");
++    gst_buffer_unref (*outbuf);
++    *outbuf = NULL;
++    goto beach;
++  }
++}
++
++/* returns TRUE if buffer is within segment, else FALSE.
++ * if Buffer is on segment border, it's timestamp and duration will be clipped */
++static gboolean
++clip_audio_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
++    GstClockTime in_dur)
++{
++  GstClockTime stop;
++  gint64 diff, ctime, cstop;
++  gboolean res = TRUE;
++
++  GST_LOG_OBJECT (dec,
++      "timestamp:%" GST_TIME_FORMAT ", duration:%" GST_TIME_FORMAT
++      ", size %u", GST_TIME_ARGS (in_ts), GST_TIME_ARGS (in_dur),
++      GST_BUFFER_SIZE (buf));
++
++  /* can't clip without TIME segment */
++  if (G_UNLIKELY (dec->segment.format != GST_FORMAT_TIME))
++    goto beach;
++
++  /* we need a start time */
++  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (in_ts)))
++    goto beach;
++
++  /* trust duration */
++  stop = in_ts + in_dur;
++
++  res = gst_segment_clip (&dec->segment, GST_FORMAT_TIME, in_ts, stop, &ctime,
++      &cstop);
++  if (G_UNLIKELY (!res))
++    goto out_of_segment;
++
++  /* see if some clipping happened */
++  if (G_UNLIKELY ((diff = ctime - in_ts) > 0)) {
++    /* bring clipped time to bytes */
++    diff =
++        gst_util_uint64_scale_int (diff, dec->format.audio.samplerate,
++        GST_SECOND) * (dec->format.audio.depth * dec->format.audio.channels);
++
++    GST_DEBUG_OBJECT (dec, "clipping start to %" GST_TIME_FORMAT " %"
++        G_GINT64_FORMAT " bytes", GST_TIME_ARGS (ctime), diff);
++
++    GST_BUFFER_SIZE (buf) -= diff;
++    GST_BUFFER_DATA (buf) += diff;
++  }
++  if (G_UNLIKELY ((diff = stop - cstop) > 0)) {
++    /* bring clipped time to bytes */
++    diff =
++        gst_util_uint64_scale_int (diff, dec->format.audio.samplerate,
++        GST_SECOND) * (dec->format.audio.depth * dec->format.audio.channels);
++
++    GST_DEBUG_OBJECT (dec, "clipping stop to %" GST_TIME_FORMAT " %"
++        G_GINT64_FORMAT " bytes", GST_TIME_ARGS (cstop), diff);
++
++    GST_BUFFER_SIZE (buf) -= diff;
++  }
++  GST_BUFFER_TIMESTAMP (buf) = ctime;
++  GST_BUFFER_DURATION (buf) = cstop - ctime;
++
++beach:
++  GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
++  return res;
++
++  /* ERRORS */
++out_of_segment:
++  {
++    GST_LOG_OBJECT (dec, "out of segment");
++    goto beach;
++  }
++}
++
++static gint
++gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec,
++    AVCodec * in_plugin, guint8 * data, guint size,
++    const GstTSInfo * dec_info, GstBuffer ** outbuf, GstFlowReturn * ret)
++{
++  gint len = -1;
++  gint have_data = AVCODEC_MAX_AUDIO_FRAME_SIZE;
++  GstClockTime out_timestamp, out_duration;
++  gint64 out_offset;
++  AVPacket packet;
++
++  GST_DEBUG_OBJECT (ffmpegdec,
++      "size:%d, offset:%" G_GINT64_FORMAT ", ts:%" GST_TIME_FORMAT ", dur:%"
++      GST_TIME_FORMAT ", ffmpegdec->next_out:%" GST_TIME_FORMAT, size,
++      dec_info->offset, GST_TIME_ARGS (dec_info->timestamp),
++      GST_TIME_ARGS (dec_info->duration), GST_TIME_ARGS (ffmpegdec->next_out));
++
++  *outbuf =
++      new_aligned_buffer (AVCODEC_MAX_AUDIO_FRAME_SIZE,
++      GST_PAD_CAPS (ffmpegdec->srcpad));
++
++  gst_avpacket_init (&packet, data, size);
++  len = avcodec_decode_audio3 (ffmpegdec->context,
++      (int16_t *) GST_BUFFER_DATA (*outbuf), &have_data, &packet);
++  GST_DEBUG_OBJECT (ffmpegdec,
++      "Decode audio: len=%d, have_data=%d", len, have_data);
++
++  if (len >= 0 && have_data > 0) {
++    GST_DEBUG_OBJECT (ffmpegdec, "Creating output buffer");
++    if (!gst_ffmpegdec_negotiate (ffmpegdec, FALSE)) {
++      gst_buffer_unref (*outbuf);
++      *outbuf = NULL;
++      len = -1;
++      goto beach;
++    }
++
++    /* Buffer size */
++    GST_BUFFER_SIZE (*outbuf) = have_data;
++
++    /*
++     * Timestamps:
++     *
++     *  1) Copy input timestamp if valid
++     *  2) else interpolate from previous input timestamp
++     */
++    /* always take timestamps from the input buffer if any */
++    if (GST_CLOCK_TIME_IS_VALID (dec_info->timestamp)) {
++      out_timestamp = dec_info->timestamp;
++    } else {
++      out_timestamp = ffmpegdec->next_out;
++    }
++
++    /*
++     * Duration:
++     *
++     *  1) calculate based on number of samples
++     */
++    out_duration = gst_util_uint64_scale (have_data, GST_SECOND,
++        ffmpegdec->format.audio.depth * ffmpegdec->format.audio.channels *
++        ffmpegdec->format.audio.samplerate);
++
++    /* offset:
++     *
++     * Just copy
++     */
++    out_offset = dec_info->offset;
++
++    GST_DEBUG_OBJECT (ffmpegdec,
++        "Buffer created. Size:%d , timestamp:%" GST_TIME_FORMAT " , duration:%"
++        GST_TIME_FORMAT, have_data,
++        GST_TIME_ARGS (out_timestamp), GST_TIME_ARGS (out_duration));
++
++    GST_BUFFER_TIMESTAMP (*outbuf) = out_timestamp;
++    GST_BUFFER_DURATION (*outbuf) = out_duration;
++    GST_BUFFER_OFFSET (*outbuf) = out_offset;
++    gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (ffmpegdec->srcpad));
++
++    /* the next timestamp we'll use when interpolating */
++    if (GST_CLOCK_TIME_IS_VALID (out_timestamp))
++      ffmpegdec->next_out = out_timestamp + out_duration;
++
++    /* now see if we need to clip the buffer against the segment boundaries. */
++    if (G_UNLIKELY (!clip_audio_buffer (ffmpegdec, *outbuf, out_timestamp,
++                out_duration)))
++      goto clipped;
++
++  } else {
++    gst_buffer_unref (*outbuf);
++    *outbuf = NULL;
++  }
++
++  /* If we don't error out after the first failed read with the AAC decoder,
++   * we must *not* carry on pushing data, else we'll cause segfaults... */
++  if (len == -1 && (in_plugin->id == CODEC_ID_AAC
++          || in_plugin->id == CODEC_ID_AAC_LATM)) {
++    GST_ELEMENT_ERROR (ffmpegdec, STREAM, DECODE, (NULL),
++        ("Decoding of AAC stream by FFMPEG failed."));
++    *ret = GST_FLOW_ERROR;
++  }
++
++beach:
++  GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
++      *ret, *outbuf, len);
++  return len;
++
++  /* ERRORS */
++clipped:
++  {
++    GST_DEBUG_OBJECT (ffmpegdec, "buffer clipped");
++    gst_buffer_unref (*outbuf);
++    *outbuf = NULL;
++    goto beach;
++  }
++}
++
++/* gst_ffmpegdec_frame:
++ * ffmpegdec:
++ * data: pointer to the data to decode
++ * size: size of data in bytes
++ * got_data: 0 if no data was decoded, != 0 otherwise.
++ * in_time: timestamp of data
++ * in_duration: duration of data
++ * ret: GstFlowReturn to return in the chain function
++ *
++ * Decode the given frame and pushes it downstream.
++ *
++ * Returns: Number of bytes used in decoding, -1 on error/failure.
++ */
++
++static gint
++gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec,
++    guint8 * data, guint size, gint * got_data, const GstTSInfo * dec_info,
++    GstFlowReturn * ret)
++{
++  GstFFMpegDecClass *oclass;
++  GstBuffer *outbuf = NULL;
++  gint have_data = 0, len = 0;
++
++  if (G_UNLIKELY (ffmpegdec->context->codec == NULL))
++    goto no_codec;
++
++  GST_LOG_OBJECT (ffmpegdec, "data:%p, size:%d, id:%d", data, size,
++      dec_info->idx);
++
++  *ret = GST_FLOW_OK;
++  ffmpegdec->context->frame_number++;
++
++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++
++  switch (oclass->in_plugin->type) {
++    case AVMEDIA_TYPE_VIDEO:
++      len =
++          gst_ffmpegdec_video_frame (ffmpegdec, data, size, dec_info, &outbuf,
++          ret);
++      break;
++    case AVMEDIA_TYPE_AUDIO:
++      len =
++          gst_ffmpegdec_audio_frame (ffmpegdec, oclass->in_plugin, data, size,
++          dec_info, &outbuf, ret);
++
++      /* if we did not get an output buffer and we have a pending discont, don't
++       * clear the input timestamps, we will put them on the next buffer because
++       * else we might create the first buffer with a very big timestamp gap. */
++      if (outbuf == NULL && ffmpegdec->discont) {
++        GST_DEBUG_OBJECT (ffmpegdec, "no buffer but keeping timestamp");
++        ffmpegdec->clear_ts = FALSE;
++      }
++      break;
++    default:
++      GST_ERROR_OBJECT (ffmpegdec, "Asked to decode non-audio/video frame !");
++      g_assert_not_reached ();
++      break;
++  }
++
++  if (outbuf)
++    have_data = 1;
++
++  if (len < 0 || have_data < 0) {
++    GST_WARNING_OBJECT (ffmpegdec,
++        "ffdec_%s: decoding error (len: %d, have_data: %d)",
++        oclass->in_plugin->name, len, have_data);
++    *got_data = 0;
++    goto beach;
++  } else if (len == 0 && have_data == 0) {
++    *got_data = 0;
++    goto beach;
++  } else {
++    /* this is where I lost my last clue on ffmpeg... */
++    *got_data = 1;
++  }
++
++  if (outbuf) {
++    GST_LOG_OBJECT (ffmpegdec,
++        "Decoded data, now pushing buffer %p with offset %" G_GINT64_FORMAT
++        ", timestamp %" GST_TIME_FORMAT " and duration %" GST_TIME_FORMAT,
++        outbuf, GST_BUFFER_OFFSET (outbuf),
++        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
++        GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)));
++
++    /* mark pending discont */
++    if (ffmpegdec->discont) {
++      GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
++      ffmpegdec->discont = FALSE;
++    }
++
++    if (ffmpegdec->segment.rate > 0.0) {
++      /* and off we go */
++      *ret = gst_pad_push (ffmpegdec->srcpad, outbuf);
++    } else {
++      /* reverse playback, queue frame till later when we get a discont. */
++      GST_DEBUG_OBJECT (ffmpegdec, "queued frame");
++      ffmpegdec->queued = g_list_prepend (ffmpegdec->queued, outbuf);
++      *ret = GST_FLOW_OK;
++    }
++  } else {
++    GST_DEBUG_OBJECT (ffmpegdec, "We didn't get a decoded buffer");
++  }
++
++beach:
++  return len;
++
++  /* ERRORS */
++no_codec:
++  {
++    GST_ERROR_OBJECT (ffmpegdec, "no codec context");
++    return -1;
++  }
++}
++
++static void
++gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec)
++{
++  GstFFMpegDecClass *oclass;
++
++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++
++  if (oclass->in_plugin->capabilities & CODEC_CAP_DELAY) {
++    gint have_data, len, try = 0;
++
++    GST_LOG_OBJECT (ffmpegdec,
++        "codec has delay capabilities, calling until ffmpeg has drained everything");
++
++    do {
++      GstFlowReturn ret;
++
++      len =
++          gst_ffmpegdec_frame (ffmpegdec, NULL, 0, &have_data, &ts_info_none,
++          &ret);
++      if (len < 0 || have_data == 0)
++        break;
++    } while (try++ < 10);
++  }
++  if (ffmpegdec->segment.rate < 0.0) {
++    /* if we have some queued frames for reverse playback, flush them now */
++    flush_queued (ffmpegdec);
++  }
++}
++
++static void
++gst_ffmpegdec_flush_pcache (GstFFMpegDec * ffmpegdec)
++{
++  if (ffmpegdec->pctx) {
++    gint size, bsize;
++    guint8 *data;
++    guint8 bdata[FF_INPUT_BUFFER_PADDING_SIZE];
++
++    bsize = FF_INPUT_BUFFER_PADDING_SIZE;
++    memset (bdata, 0, bsize);
++
++    /* parse some dummy data to work around some ffmpeg weirdness where it keeps
++     * the previous pts around */
++    av_parser_parse2 (ffmpegdec->pctx, ffmpegdec->context,
++        &data, &size, bdata, bsize, -1, -1, -1);
++    ffmpegdec->pctx->pts = -1;
++    ffmpegdec->pctx->dts = -1;
++  }
++
++  if (ffmpegdec->pcache) {
++    gst_buffer_unref (ffmpegdec->pcache);
++    ffmpegdec->pcache = NULL;
++  }
++}
++
++static gboolean
++gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event)
++{
++  GstFFMpegDec *ffmpegdec;
++  gboolean ret = FALSE;
++
++  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
++
++  GST_DEBUG_OBJECT (ffmpegdec, "Handling %s event",
++      GST_EVENT_TYPE_NAME (event));
++
++  switch (GST_EVENT_TYPE (event)) {
++    case GST_EVENT_EOS:
++    {
++      gst_ffmpegdec_drain (ffmpegdec);
++      break;
++    }
++    case GST_EVENT_FLUSH_STOP:
++    {
++      if (ffmpegdec->opened) {
++        avcodec_flush_buffers (ffmpegdec->context);
++      }
++      gst_ffmpegdec_reset_ts (ffmpegdec);
++      gst_ffmpegdec_reset_qos (ffmpegdec);
++      gst_ffmpegdec_flush_pcache (ffmpegdec);
++      gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
++      clear_queued (ffmpegdec);
++      break;
++    }
++    case GST_EVENT_NEWSEGMENT:
++    {
++      gboolean update;
++      GstFormat fmt;
++      gint64 start, stop, time;
++      gdouble rate, arate;
++
++      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &fmt,
++          &start, &stop, &time);
++
++      switch (fmt) {
++        case GST_FORMAT_TIME:
++          /* fine, our native segment format */
++          break;
++        case GST_FORMAT_BYTES:
++        {
++          gint bit_rate;
++
++          bit_rate = ffmpegdec->context->bit_rate;
++
++          /* convert to time or fail */
++          if (!bit_rate)
++            goto no_bitrate;
++
++          GST_DEBUG_OBJECT (ffmpegdec, "bitrate: %d", bit_rate);
++
++          /* convert values to TIME */
++          if (start != -1)
++            start = gst_util_uint64_scale_int (start, GST_SECOND, bit_rate);
++          if (stop != -1)
++            stop = gst_util_uint64_scale_int (stop, GST_SECOND, bit_rate);
++          if (time != -1)
++            time = gst_util_uint64_scale_int (time, GST_SECOND, bit_rate);
++
++          /* unref old event */
++          gst_event_unref (event);
++
++          /* create new converted time segment */
++          fmt = GST_FORMAT_TIME;
++          /* FIXME, bitrate is not good enough too find a good stop, let's
++           * hope start and time were 0... meh. */
++          stop = -1;
++          event = gst_event_new_new_segment (update, rate, fmt,
++              start, stop, time);
++          break;
++        }
++        default:
++          /* invalid format */
++          goto invalid_format;
++      }
++
++      /* drain pending frames before trying to use the new segment, queued
++       * buffers belonged to the previous segment. */
++      if (ffmpegdec->context->codec)
++        gst_ffmpegdec_drain (ffmpegdec);
++
++      GST_DEBUG_OBJECT (ffmpegdec,
++          "NEWSEGMENT in time start %" GST_TIME_FORMAT " -- stop %"
++          GST_TIME_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
++
++      /* and store the values */
++      gst_segment_set_newsegment_full (&ffmpegdec->segment, update,
++          rate, arate, fmt, start, stop, time);
++      break;
++    }
++    default:
++      break;
++  }
++
++  /* and push segment downstream */
++  ret = gst_pad_push_event (ffmpegdec->srcpad, event);
++
++done:
++  gst_object_unref (ffmpegdec);
++
++  return ret;
++
++  /* ERRORS */
++no_bitrate:
++  {
++    GST_WARNING_OBJECT (ffmpegdec, "no bitrate to convert BYTES to TIME");
++    gst_event_unref (event);
++    goto done;
++  }
++invalid_format:
++  {
++    GST_WARNING_OBJECT (ffmpegdec, "unknown format received in NEWSEGMENT");
++    gst_event_unref (event);
++    goto done;
++  }
++}
++
++static GstFlowReturn
++gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
++{
++  GstFFMpegDec *ffmpegdec;
++  GstFFMpegDecClass *oclass;
++  guint8 *data, *bdata;
++  gint size, bsize, len, have_data;
++  GstFlowReturn ret = GST_FLOW_OK;
++  GstClockTime in_timestamp;
++  GstClockTime in_duration;
++  gboolean discont;
++  gint64 in_offset;
++  const GstTSInfo *in_info;
++  const GstTSInfo *dec_info;
++
++  ffmpegdec = (GstFFMpegDec *) (GST_PAD_PARENT (pad));
++
++  if (G_UNLIKELY (!ffmpegdec->opened))
++    goto not_negotiated;
++
++  discont = GST_BUFFER_IS_DISCONT (inbuf);
++
++  /* The discont flags marks a buffer that is not continuous with the previous
++   * buffer. This means we need to clear whatever data we currently have. We
++   * currently also wait for a new keyframe, which might be suboptimal in the
++   * case of a network error, better show the errors than to drop all data.. */
++  if (G_UNLIKELY (discont)) {
++    GST_DEBUG_OBJECT (ffmpegdec, "received DISCONT");
++    /* drain what we have queued */
++    gst_ffmpegdec_drain (ffmpegdec);
++    gst_ffmpegdec_flush_pcache (ffmpegdec);
++    avcodec_flush_buffers (ffmpegdec->context);
++    ffmpegdec->discont = TRUE;
++    gst_ffmpegdec_reset_ts (ffmpegdec);
++  }
++  /* by default we clear the input timestamp after decoding each frame so that
++   * interpollation can work. */
++  ffmpegdec->clear_ts = TRUE;
++
++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++
++  /* parse cache joining. If there is cached data */
++  if (ffmpegdec->pcache) {
++    /* join with previous data */
++    GST_LOG_OBJECT (ffmpegdec, "join parse cache");
++    inbuf = gst_buffer_join (ffmpegdec->pcache, inbuf);
++    /* no more cached data, we assume we can consume the complete cache */
++    ffmpegdec->pcache = NULL;
++  }
++
++  in_timestamp = GST_BUFFER_TIMESTAMP (inbuf);
++  in_duration = GST_BUFFER_DURATION (inbuf);
++  in_offset = GST_BUFFER_OFFSET (inbuf);
++
++  /* get handle to timestamp info, we can pass this around to ffmpeg */
++  in_info = gst_ts_info_store (ffmpegdec, in_timestamp, in_duration, in_offset);
++
++  if (in_timestamp != -1) {
++    /* check for increasing timestamps if they are jumping backwards, we
++     * probably are dealing with PTS as timestamps */
++    if (!ffmpegdec->reordered_in && ffmpegdec->last_in != -1) {
++      if (in_timestamp < ffmpegdec->last_in) {
++        GST_LOG_OBJECT (ffmpegdec, "detected reordered input timestamps");
++        ffmpegdec->reordered_in = TRUE;
++        ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
++      } else if (in_timestamp > ffmpegdec->last_in) {
++        GstClockTime diff;
++        /* keep track of timestamp diff to estimate duration */
++        diff = in_timestamp - ffmpegdec->last_in;
++        /* need to scale with amount of frames in the interval */
++        if (ffmpegdec->last_frames)
++          diff /= ffmpegdec->last_frames;
++
++        GST_LOG_OBJECT (ffmpegdec, "estimated duration %" GST_TIME_FORMAT " %u",
++            GST_TIME_ARGS (diff), ffmpegdec->last_frames);
++
++        ffmpegdec->last_diff = diff;
++      }
++    }
++    ffmpegdec->last_in = in_timestamp;
++    ffmpegdec->last_frames = 0;
++  }
++
++  GST_LOG_OBJECT (ffmpegdec,
++      "Received new data of size %u, offset:%" G_GUINT64_FORMAT ", ts:%"
++      GST_TIME_FORMAT ", dur:%" GST_TIME_FORMAT ", info %d",
++      GST_BUFFER_SIZE (inbuf), GST_BUFFER_OFFSET (inbuf),
++      GST_TIME_ARGS (in_timestamp), GST_TIME_ARGS (in_duration), in_info->idx);
++
++  /* workarounds, functions write to buffers:
++   *  libavcodec/svq1.c:svq1_decode_frame writes to the given buffer.
++   *  libavcodec/svq3.c:svq3_decode_slice_header too.
++   * ffmpeg devs know about it and will fix it (they said). */
++  if (oclass->in_plugin->id == CODEC_ID_SVQ1 ||
++      oclass->in_plugin->id == CODEC_ID_SVQ3) {
++    inbuf = gst_buffer_make_writable (inbuf);
++  }
++
++  bdata = GST_BUFFER_DATA (inbuf);
++  bsize = GST_BUFFER_SIZE (inbuf);
++
++  if (ffmpegdec->do_padding) {
++    /* add padding */
++    if (ffmpegdec->padded_size < bsize + FF_INPUT_BUFFER_PADDING_SIZE) {
++      ffmpegdec->padded_size = bsize + FF_INPUT_BUFFER_PADDING_SIZE;
++      ffmpegdec->padded = g_realloc (ffmpegdec->padded, ffmpegdec->padded_size);
++      GST_LOG_OBJECT (ffmpegdec, "resized padding buffer to %d",
++          ffmpegdec->padded_size);
++    }
++    memcpy (ffmpegdec->padded, bdata, bsize);
++    memset (ffmpegdec->padded + bsize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
++
++    bdata = ffmpegdec->padded;
++  }
++
++  do {
++    guint8 tmp_padding[FF_INPUT_BUFFER_PADDING_SIZE];
++
++    /* parse, if at all possible */
++    if (ffmpegdec->pctx) {
++      gint res;
++
++      GST_LOG_OBJECT (ffmpegdec,
++          "Calling av_parser_parse2 with offset %" G_GINT64_FORMAT ", ts:%"
++          GST_TIME_FORMAT " size %d", in_offset, GST_TIME_ARGS (in_timestamp),
++          bsize);
++
++      /* feed the parser. We pass the timestamp info so that we can recover all
++       * info again later */
++      res = av_parser_parse2 (ffmpegdec->pctx, ffmpegdec->context,
++          &data, &size, bdata, bsize, in_info->idx, in_info->idx, in_offset);
++
++      GST_LOG_OBJECT (ffmpegdec,
++          "parser returned res %d and size %d, id %" G_GINT64_FORMAT, res, size,
++          ffmpegdec->pctx->pts);
++
++      /* store pts for decoding */
++      if (ffmpegdec->pctx->pts != AV_NOPTS_VALUE && ffmpegdec->pctx->pts != -1)
++        dec_info = gst_ts_info_get (ffmpegdec, ffmpegdec->pctx->pts);
++      else {
++        /* ffmpeg sometimes loses track after a flush, help it by feeding a
++         * valid start time */
++        ffmpegdec->pctx->pts = in_info->idx;
++        ffmpegdec->pctx->dts = in_info->idx;
++        dec_info = in_info;
++      }
++
++      GST_LOG_OBJECT (ffmpegdec, "consuming %d bytes. id %d", size,
++          dec_info->idx);
++
++      if (res) {
++        /* there is output, set pointers for next round. */
++        bsize -= res;
++        bdata += res;
++      } else {
++        /* Parser did not consume any data, make sure we don't clear the
++         * timestamp for the next round */
++        ffmpegdec->clear_ts = FALSE;
++      }
++
++      /* if there is no output, we must break and wait for more data. also the
++       * timestamp in the context is not updated. */
++      if (size == 0) {
++        if (bsize > 0)
++          continue;
++        else
++          break;
++      }
++    } else {
++      data = bdata;
++      size = bsize;
++
++      dec_info = in_info;
++    }
++
++    if (ffmpegdec->do_padding) {
++      /* add temporary padding */
++      memcpy (tmp_padding, data + size, FF_INPUT_BUFFER_PADDING_SIZE);
++      memset (data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
++    }
++
++    /* decode a frame of audio/video now */
++    len =
++        gst_ffmpegdec_frame (ffmpegdec, data, size, &have_data, dec_info, &ret);
++
++    if (ffmpegdec->do_padding) {
++      memcpy (data + size, tmp_padding, FF_INPUT_BUFFER_PADDING_SIZE);
++    }
++
++    if (ret != GST_FLOW_OK) {
++      GST_LOG_OBJECT (ffmpegdec, "breaking because of flow ret %s",
++          gst_flow_get_name (ret));
++      /* bad flow retun, make sure we discard all data and exit */
++      bsize = 0;
++      break;
++    }
++    if (!ffmpegdec->pctx) {
++      if (len == 0 && !have_data) {
++        /* nothing was decoded, this could be because no data was available or
++         * because we were skipping frames.
++         * If we have no context we must exit and wait for more data, we keep the
++         * data we tried. */
++        GST_LOG_OBJECT (ffmpegdec, "Decoding didn't return any data, breaking");
++        break;
++      } else if (len < 0) {
++        /* a decoding error happened, we must break and try again with next data. */
++        GST_LOG_OBJECT (ffmpegdec, "Decoding error, breaking");
++        bsize = 0;
++        break;
++      }
++      /* prepare for the next round, for codecs with a context we did this
++       * already when using the parser. */
++      bsize -= len;
++      bdata += len;
++    } else {
++      if (len == 0) {
++        /* nothing was decoded, this could be because no data was available or
++         * because we were skipping frames. Since we have a parser we can
++         * continue with the next frame */
++        GST_LOG_OBJECT (ffmpegdec,
++            "Decoding didn't return any data, trying next");
++      } else if (len < 0) {
++        /* we have a context that will bring us to the next frame */
++        GST_LOG_OBJECT (ffmpegdec, "Decoding error, trying next");
++      }
++    }
++
++    /* make sure we don't use the same old timestamp for the next frame and let
++     * the interpollation take care of it. */
++    if (ffmpegdec->clear_ts) {
++      in_timestamp = GST_CLOCK_TIME_NONE;
++      in_duration = GST_CLOCK_TIME_NONE;
++      in_offset = GST_BUFFER_OFFSET_NONE;
++      in_info = GST_TS_INFO_NONE;
++    } else {
++      ffmpegdec->clear_ts = TRUE;
++    }
++    ffmpegdec->last_frames++;
++
++    GST_LOG_OBJECT (ffmpegdec, "Before (while bsize>0).  bsize:%d , bdata:%p",
++        bsize, bdata);
++  } while (bsize > 0);
++
++  /* keep left-over */
++  if (ffmpegdec->pctx && bsize > 0) {
++    in_timestamp = GST_BUFFER_TIMESTAMP (inbuf);
++    in_offset = GST_BUFFER_OFFSET (inbuf);
++
++    GST_LOG_OBJECT (ffmpegdec,
++        "Keeping %d bytes of data with offset %" G_GINT64_FORMAT ", timestamp %"
++        GST_TIME_FORMAT, bsize, in_offset, GST_TIME_ARGS (in_timestamp));
++
++    ffmpegdec->pcache = gst_buffer_create_sub (inbuf,
++        GST_BUFFER_SIZE (inbuf) - bsize, bsize);
++    /* we keep timestamp, even though all we really know is that the correct
++     * timestamp is not below the one from inbuf */
++    GST_BUFFER_TIMESTAMP (ffmpegdec->pcache) = in_timestamp;
++    GST_BUFFER_OFFSET (ffmpegdec->pcache) = in_offset;
++  } else if (bsize > 0) {
++    GST_DEBUG_OBJECT (ffmpegdec, "Dropping %d bytes of data", bsize);
++  }
++  gst_buffer_unref (inbuf);
++
++  return ret;
++
++  /* ERRORS */
++not_negotiated:
++  {
++    oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
++    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
++        ("ffdec_%s: input format was not set before data start",
++            oclass->in_plugin->name));
++    gst_buffer_unref (inbuf);
++    return GST_FLOW_NOT_NEGOTIATED;
++  }
++}
++
++static GstStateChangeReturn
++gst_ffmpegdec_change_state (GstElement * element, GstStateChange transition)
++{
++  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) element;
++  GstStateChangeReturn ret;
++
++  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
++
++  switch (transition) {
++    case GST_STATE_CHANGE_PAUSED_TO_READY:
++      GST_OBJECT_LOCK (ffmpegdec);
++      gst_ffmpegdec_close (ffmpegdec);
++      GST_OBJECT_UNLOCK (ffmpegdec);
++      clear_queued (ffmpegdec);
++      g_free (ffmpegdec->padded);
++      ffmpegdec->padded = NULL;
++      ffmpegdec->padded_size = 0;
++      ffmpegdec->can_allocate_aligned = TRUE;
++      break;
++    default:
++      break;
++  }
++
++  return ret;
++}
++
++static void
++gst_ffmpegdec_set_property (GObject * object,
++    guint prop_id, const GValue * value, GParamSpec * pspec)
++{
++  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
++
++  switch (prop_id) {
++    case PROP_LOWRES:
++      ffmpegdec->lowres = ffmpegdec->context->lowres = g_value_get_enum (value);
++      break;
++    case PROP_SKIPFRAME:
++      ffmpegdec->skip_frame = ffmpegdec->context->skip_frame =
++          g_value_get_enum (value);
++      break;
++    case PROP_DIRECT_RENDERING:
++      ffmpegdec->direct_rendering = g_value_get_boolean (value);
++      break;
++    case PROP_DO_PADDING:
++      ffmpegdec->do_padding = g_value_get_boolean (value);
++      break;
++    case PROP_DEBUG_MV:
++      ffmpegdec->debug_mv = ffmpegdec->context->debug_mv =
++          g_value_get_boolean (value);
++      break;
++    case PROP_CROP:
++      ffmpegdec->crop = g_value_get_boolean (value);
++      break;
++    case PROP_MAX_THREADS:
++      ffmpegdec->max_threads = g_value_get_int (value);
++      break;
++    default:
++      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
++      break;
++  }
++}
++
++static void
++gst_ffmpegdec_get_property (GObject * object,
++    guint prop_id, GValue * value, GParamSpec * pspec)
++{
++  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
++
++  switch (prop_id) {
++    case PROP_LOWRES:
++      g_value_set_enum (value, ffmpegdec->context->lowres);
++      break;
++    case PROP_SKIPFRAME:
++      g_value_set_enum (value, ffmpegdec->context->skip_frame);
++      break;
++    case PROP_DIRECT_RENDERING:
++      g_value_set_boolean (value, ffmpegdec->direct_rendering);
++      break;
++    case PROP_DO_PADDING:
++      g_value_set_boolean (value, ffmpegdec->do_padding);
++      break;
++    case PROP_DEBUG_MV:
++      g_value_set_boolean (value, ffmpegdec->context->debug_mv);
++      break;
++    case PROP_CROP:
++      g_value_set_boolean (value, ffmpegdec->crop);
++      break;
++    case PROP_MAX_THREADS:
++      g_value_set_int (value, ffmpegdec->max_threads);
++      break;
++    default:
++      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
++      break;
++  }
++}
++
++gboolean
++gst_ffmpegdec_register (GstPlugin * plugin)
++{
++  GTypeInfo typeinfo = {
++    sizeof (GstFFMpegDecClass),
++    (GBaseInitFunc) gst_ffmpegdec_base_init,
++    NULL,
++    (GClassInitFunc) gst_ffmpegdec_class_init,
++    NULL,
++    NULL,
++    sizeof (GstFFMpegDec),
++    0,
++    (GInstanceInitFunc) gst_ffmpegdec_init,
++  };
++  GType type;
++  AVCodec *in_plugin;
++  gint rank;
++
++  in_plugin = av_codec_next (NULL);
++
++  GST_LOG ("Registering decoders");
++
++  while (in_plugin) {
++    gchar *type_name;
++    gchar *plugin_name;
++
++    /* only decoders */
++    if (!in_plugin->decode) {
++      goto next;
++    }
++
++    /* no quasi-codecs, please */
++    if (in_plugin->id == CODEC_ID_RAWVIDEO ||
++        in_plugin->id == CODEC_ID_V210 ||
++        in_plugin->id == CODEC_ID_V210X ||
++        in_plugin->id == CODEC_ID_R210 ||
++        (in_plugin->id >= CODEC_ID_PCM_S16LE &&
++            in_plugin->id <= CODEC_ID_PCM_BLURAY)) {
++      goto next;
++    }
++
++    /* No decoders depending on external libraries (we don't build them, but
++     * people who build against an external ffmpeg might have them.
++     * We have native gstreamer plugins for all of those libraries anyway. */
++    if (!strncmp (in_plugin->name, "lib", 3)) {
++      GST_DEBUG
++          ("Not using external library decoder %s. Use the gstreamer-native ones instead.",
++          in_plugin->name);
++      goto next;
++    }
++
++    /* No vdpau plugins until we can figure out how to properly use them
++     * outside of ffmpeg. */
++    if (g_str_has_suffix (in_plugin->name, "_vdpau")) {
++      GST_DEBUG
++          ("Ignoring VDPAU decoder %s. We can't handle this outside of ffmpeg",
++          in_plugin->name);
++      goto next;
++    }
++
++    if (g_str_has_suffix (in_plugin->name, "_xvmc")) {
++      GST_DEBUG
++          ("Ignoring XVMC decoder %s. We can't handle this outside of ffmpeg",
++          in_plugin->name);
++      goto next;
++    }
++
++    GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name);
++
++    /* no codecs for which we're GUARANTEED to have better alternatives */
++    /* MPEG1VIDEO : the mpeg2video decoder is preferred */
++    /* MP1 : Use MP3 for decoding */
++    /* MP2 : Use MP3 for decoding */
++    /* Theora: Use libtheora based theoradec */
++    if (!strcmp (in_plugin->name, "gif") ||
++        !strcmp (in_plugin->name, "vorbis") ||
++        !strcmp (in_plugin->name, "theora") ||
++        !strcmp (in_plugin->name, "mpeg1video") ||
++        !strcmp (in_plugin->name, "wavpack") ||
++        !strcmp (in_plugin->name, "mp1") ||
++        !strcmp (in_plugin->name, "mp2") ||
++        !strcmp (in_plugin->name, "libfaad") ||
++        !strcmp (in_plugin->name, "mpeg4aac") ||
++        !strcmp (in_plugin->name, "ass") ||
++        !strcmp (in_plugin->name, "srt") ||
++        !strcmp (in_plugin->name, "pgssub") ||
++        !strcmp (in_plugin->name, "dvdsub") ||
++        !strcmp (in_plugin->name, "dvbsub")) {
++      GST_LOG ("Ignoring decoder %s", in_plugin->name);
++      goto next;
++    }
++
++    /* construct the type */
++    plugin_name = g_strdup ((gchar *) in_plugin->name);
++    g_strdelimit (plugin_name, NULL, '_');
++    type_name = g_strdup_printf ("ffdec_%s", plugin_name);
++    g_free (plugin_name);
++
++    type = g_type_from_name (type_name);
++
++    if (!type) {
++      /* create the gtype now */
++      type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
++      g_type_set_qdata (type, GST_FFDEC_PARAMS_QDATA, (gpointer) in_plugin);
++    }
++
++    /* (Ronald) MPEG-4 gets a higher priority because it has been well-
++     * tested and by far outperforms divxdec/xviddec - so we prefer it.
++     * msmpeg4v3 same, as it outperforms divxdec for divx3 playback.
++     * VC1/WMV3 are not working and thus unpreferred for now. */
++    switch (in_plugin->id) {
++      case CODEC_ID_MPEG4:
++      case CODEC_ID_MSMPEG4V3:
++      case CODEC_ID_H264:
++      case CODEC_ID_RA_144:
++      case CODEC_ID_RA_288:
++      case CODEC_ID_RV10:
++      case CODEC_ID_RV20:
++      case CODEC_ID_RV30:
++      case CODEC_ID_RV40:
++      case CODEC_ID_COOK:
++        rank = GST_RANK_SECONDARY;
++        break;
++        /* DVVIDEO: we have a good dv decoder, fast on both ppc as well as x86.
++         * They say libdv's quality is better though. leave as secondary.
++         * note: if you change this, see the code in gstdv.c in good/ext/dv.
++         *
++         * SIPR: decoder should have a higher rank than realaudiodec.
++         */
++      case CODEC_ID_DVVIDEO:
++      case CODEC_ID_SIPR:
++        rank = GST_RANK_SECONDARY;
++        break;
++      case CODEC_ID_MP3:
++        rank = GST_RANK_NONE;
++        break;
++        /* TEMPORARILY DISABLING AC3/EAC3/DTS for 0.10.12 release
++         * due to downmixing failure.
++         * See Bug #608892 for more details */
++      case CODEC_ID_EAC3:
++      case CODEC_ID_AC3:
++      case CODEC_ID_DTS:
++        rank = GST_RANK_NONE;
++        break;
++      default:
++        rank = GST_RANK_MARGINAL;
++        break;
++    }
++    if (!gst_element_register (plugin, type_name, rank, type)) {
++      g_warning ("Failed to register %s", type_name);
++      g_free (type_name);
++      return FALSE;
++    }
++
++    g_free (type_name);
++
++  next:
++    in_plugin = av_codec_next (in_plugin);
++  }
++
++  GST_LOG ("Finished Registering decoders");
++
++  return TRUE;
++}
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.rej gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.rej
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.rej	1970-01-01 01:00:00.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.rej	2014-08-08 15:26:38.471858652 +0200
+@@ -0,0 +1,11 @@
++--- ext/ffmpeg/gstffmpegdec.c
+++++ ext/ffmpeg/gstffmpegdec.c
++@@ -1565,7 +1564,7 @@
++         gst_message_new_latency (GST_OBJECT_CAST (ffmpegdec)));
++   }
++ 
++-  is_itype = (ffmpegdec->picture->pict_type == FF_I_TYPE);
+++  is_itype = (ffmpegdec->picture->pict_type == AV_PICTURE_TYPE_I);
++   is_reference = (ffmpegdec->picture->reference == 1);
++ 
++   iskeyframe = (is_itype || is_reference || ffmpegdec->picture->key_frame)
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdemux.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdemux.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdemux.c	2011-07-13 11:07:28.000000000 +0200
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdemux.c	2014-08-08 15:26:07.874857555 +0200
+@@ -343,8 +343,11 @@
+   demux->audiopads = 0;
+ 
+   /* close demuxer context from ffmpeg */
+-  av_close_input_file (demux->context);
+-  demux->context = NULL;
++  if (demux->seekable)
++    gst_ffmpegdata_close (demux->context->pb);
++  else
++    gst_ffmpeg_pipe_close (demux->context->pb);
++  avformat_close_input (&demux->context);
+ 
+   GST_OBJECT_LOCK (demux);
+   demux->opened = FALSE;
+@@ -1146,9 +1149,9 @@
+ static gboolean
+ gst_ffmpegdemux_open (GstFFMpegDemux * demux)
+ {
++  AVIOContext *iocontext = NULL;
+   GstFFMpegDemuxClass *oclass =
+       (GstFFMpegDemuxClass *) G_OBJECT_GET_CLASS (demux);
+-  gchar *location;
+   gint res, n_streams, i;
+ #if 0
+   /* Re-enable once converted to new AVMetaData API
+@@ -1164,15 +1167,14 @@
+ 
+   /* open via our input protocol hack */
+   if (demux->seekable)
+-    location = g_strdup_printf ("gstreamer://%p", demux->sinkpad);
++    res = gst_ffmpegdata_open (demux->sinkpad, AVIO_FLAG_READ, &iocontext);
+   else
+-    location = g_strdup_printf ("gstpipe://%p", &demux->ffpipe);
+-  GST_DEBUG_OBJECT (demux, "about to call av_open_input_file %s", location);
++    res = gst_ffmpeg_pipe_open (&demux->ffpipe, AVIO_FLAG_READ, &iocontext);
+ 
+-  res = av_open_input_file (&demux->context, location,
+-      oclass->in_plugin, 0, NULL);
++  demux->context = avformat_alloc_context ();
++  demux->context->pb = iocontext;
++  res = avformat_open_input (&demux->context, NULL, oclass->in_plugin, NULL);
+ 
+-  g_free (location);
+   GST_DEBUG_OBJECT (demux, "av_open_input returned %d", res);
+   if (res < 0)
+     goto open_failed;
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegenc.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegenc.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegenc.c	2011-10-31 11:14:03.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegenc.c	2014-08-08 15:32:18.608870847 +0200
+@@ -770,7 +770,7 @@
+   GST_OBJECT_UNLOCK (ffmpegenc);
+ 
+   if (force_keyframe)
+-    ffmpegenc->picture->pict_type = FF_I_TYPE;
++    ffmpegenc->picture->pict_type = AV_PICTURE_TYPE_I;
+ 
+   frame_size = gst_ffmpeg_avpicture_fill ((AVPicture *) ffmpegenc->picture,
+       GST_BUFFER_DATA (inbuf),
+@@ -1136,7 +1136,7 @@
+       const GstStructure *s;
+       s = gst_event_get_structure (event);
+       if (gst_structure_has_name (s, "GstForceKeyUnit")) {
+-        ffmpegenc->picture->pict_type = FF_I_TYPE;
++        ffmpegenc->picture->pict_type = AV_PICTURE_TYPE_I;
+       }
+       break;
+     }
+@@ -1339,7 +1339,7 @@
+     }
+ 
+     /* only encoders */
+-    if (!in_plugin->encode) {
++    if (!av_codec_is_encoder (in_plugin)) {
+       goto next;
+     }
+ 
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c	2011-07-13 11:07:28.000000000 +0200
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c	2014-08-08 15:26:07.874857555 +0200
+@@ -24,8 +24,10 @@
+ #include <string.h>
+ #ifdef HAVE_FFMPEG_UNINSTALLED
+ #include <avformat.h>
++#include <opt.h>
+ #else
+ #include <libavformat/avformat.h>
++#include <libavutil/opt.h>
+ #endif
+ 
+ #include <gst/gst.h>
+@@ -336,9 +338,6 @@
+   ffmpegmux->context = g_new0 (AVFormatContext, 1);
+   ffmpegmux->context->oformat = oclass->in_plugin;
+   ffmpegmux->context->nb_streams = 0;
+-  g_snprintf (ffmpegmux->context->filename,
+-      sizeof (ffmpegmux->context->filename),
+-      "gstreamer://%p", ffmpegmux->srcpad);
+   ffmpegmux->opened = FALSE;
+ 
+   ffmpegmux->videopads = 0;
+@@ -450,10 +449,10 @@
+   gst_element_add_pad (element, pad);
+ 
+   /* AVStream needs to be created */
+-  st = av_new_stream (ffmpegmux->context, collect_pad->padnum);
++  st = avformat_new_stream (ffmpegmux->context, NULL);
++  st->id = collect_pad->padnum;
+   st->codec->codec_type = type;
+   st->codec->codec_id = CODEC_ID_NONE;  /* this is a check afterwards */
+-  st->stream_copy = 1;          /* we're not the actual encoder */
+   st->codec->bit_rate = bitrate;
+   st->codec->frame_size = framesize;
+   /* we fill in codec during capsnego */
+@@ -485,7 +484,7 @@
+   collect_pad = (GstFFMpegMuxPad *) gst_pad_get_element_private (pad);
+ 
+   st = ffmpegmux->context->streams[collect_pad->padnum];
+-  ffmpegmux->context->preload = ffmpegmux->preload;
++  av_opt_set_int (&ffmpegmux->context, "preload", ffmpegmux->preload, 0);
+   ffmpegmux->context->max_delay = ffmpegmux->max_delay;
+ 
+   /* for the format-specific guesses, we'll go to
+@@ -552,7 +551,7 @@
+ 
+   /* open "file" (gstreamer protocol to next element) */
+   if (!ffmpegmux->opened) {
+-    int open_flags = URL_WRONLY;
++    int open_flags = AVIO_FLAG_WRITE;
+ 
+     /* we do need all streams to have started capsnego,
+      * or things will go horribly wrong */
+@@ -646,19 +645,13 @@
+       open_flags |= GST_FFMPEG_URL_STREAMHEADER;
+     }
+ 
+-    if (url_fopen (&ffmpegmux->context->pb,
+-            ffmpegmux->context->filename, open_flags) < 0) {
++    if (gst_ffmpegdata_open (ffmpegmux->srcpad, open_flags,
++            &ffmpegmux->context->pb) < 0) {
+       GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, TOO_LAZY, (NULL),
+           ("Failed to open stream context in ffmux"));
+       return GST_FLOW_ERROR;
+     }
+ 
+-    if (av_set_parameters (ffmpegmux->context, NULL) < 0) {
+-      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, INIT, (NULL),
+-          ("Failed to initialize muxer"));
+-      return GST_FLOW_ERROR;
+-    }
+-
+     /* now open the mux format */
+     if (av_write_header (ffmpegmux->context) < 0) {
+       GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, SETTINGS, (NULL),
+@@ -670,7 +663,7 @@
+     ffmpegmux->opened = TRUE;
+ 
+     /* flush the header so it will be used as streamheader */
+-    put_flush_packet (ffmpegmux->context->pb);
++    avio_flush (ffmpegmux->context->pb);
+   }
+ 
+   /* take the one with earliest timestamp,
+@@ -770,8 +763,8 @@
+     /* close down */
+     av_write_trailer (ffmpegmux->context);
+     ffmpegmux->opened = FALSE;
+-    put_flush_packet (ffmpegmux->context->pb);
+-    url_fclose (ffmpegmux->context->pb);
++    avio_flush (ffmpegmux->context->pb);
++    gst_ffmpegdata_close (ffmpegmux->context->pb);
+     gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_eos ());
+     return GST_FLOW_UNEXPECTED;
+   }
+@@ -795,6 +788,10 @@
+       break;
+     case GST_STATE_CHANGE_PAUSED_TO_READY:
+       gst_collect_pads_stop (ffmpegmux->collect);
++      if (ffmpegmux->opened) {
++        ffmpegmux->opened = FALSE;
++        gst_ffmpegdata_close (ffmpegmux->context->pb);
++      }
+       break;
+     default:
+       break;
+@@ -809,7 +806,7 @@
+       gst_tag_setter_reset_tags (GST_TAG_SETTER (ffmpegmux));
+       if (ffmpegmux->opened) {
+         ffmpegmux->opened = FALSE;
+-        url_fclose (ffmpegmux->context->pb);
++        avio_close (ffmpegmux->context->pb);
+       }
+       break;
+     case GST_STATE_CHANGE_READY_TO_NULL:
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c.orig
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c.orig	1970-01-01 01:00:00.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c.orig	2011-07-13 11:07:28.000000000 +0200
+@@ -0,0 +1,970 @@
++/* 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>
++#ifdef HAVE_FFMPEG_UNINSTALLED
++#include <avformat.h>
++#else
++#include <libavformat/avformat.h>
++#endif
++
++#include <gst/gst.h>
++#include <gst/base/gstcollectpads.h>
++
++#include "gstffmpeg.h"
++#include "gstffmpegcodecmap.h"
++#include "gstffmpegutils.h"
++
++typedef struct _GstFFMpegMux GstFFMpegMux;
++typedef struct _GstFFMpegMuxPad GstFFMpegMuxPad;
++
++struct _GstFFMpegMuxPad
++{
++  GstCollectData collect;       /* we extend the CollectData */
++
++  gint padnum;
++};
++
++struct _GstFFMpegMux
++{
++  GstElement element;
++
++  GstCollectPads *collect;
++  /* We need to keep track of our pads, so we do so here. */
++  GstPad *srcpad;
++
++  AVFormatContext *context;
++  gboolean opened;
++
++  gint videopads, audiopads;
++
++  /*< private > */
++  /* event_function is the collectpads default eventfunction */
++  GstPadEventFunction event_function;
++  int preload;
++  int max_delay;
++};
++
++typedef struct _GstFFMpegMuxClass GstFFMpegMuxClass;
++
++struct _GstFFMpegMuxClass
++{
++  GstElementClass parent_class;
++
++  AVOutputFormat *in_plugin;
++};
++
++#define GST_TYPE_FFMPEGMUX \
++  (gst_ffmpegdec_get_type())
++#define GST_FFMPEGMUX(obj) \
++  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGMUX,GstFFMpegMux))
++#define GST_FFMPEGMUX_CLASS(klass) \
++  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGMUX,GstFFMpegMuxClass))
++#define GST_IS_FFMPEGMUX(obj) \
++  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGMUX))
++#define GST_IS_FFMPEGMUX_CLASS(klass) \
++  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGMUX))
++
++enum
++{
++  /* FILL ME */
++  LAST_SIGNAL
++};
++
++enum
++{
++  ARG_0,
++  /* FILL ME */
++};
++
++enum
++{
++  PROP_0,
++  PROP_PRELOAD,
++  PROP_MAXDELAY
++};
++
++/* A number of function prototypes are given so we can refer to them later. */
++static void gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass);
++static void gst_ffmpegmux_base_init (gpointer g_class);
++static void gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux,
++    GstFFMpegMuxClass * g_class);
++static void gst_ffmpegmux_finalize (GObject * object);
++
++static gboolean gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps);
++static GstPad *gst_ffmpegmux_request_new_pad (GstElement * element,
++    GstPadTemplate * templ, const gchar * name);
++static GstFlowReturn gst_ffmpegmux_collected (GstCollectPads * pads,
++    gpointer user_data);
++
++static gboolean gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event);
++
++static GstStateChangeReturn gst_ffmpegmux_change_state (GstElement * element,
++    GstStateChange transition);
++
++static void gst_ffmpegmux_set_property (GObject * object, guint prop_id,
++    const GValue * value, GParamSpec * pspec);
++static void gst_ffmpegmux_get_property (GObject * object, guint prop_id,
++    GValue * value, GParamSpec * pspec);
++
++static GstCaps *gst_ffmpegmux_get_id_caps (enum CodecID *id_list);
++static void gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * caps,
++    const gchar * field, guint num, const gint * values);
++
++#define GST_FFMUX_PARAMS_QDATA g_quark_from_static_string("ffmux-params")
++
++static GstElementClass *parent_class = NULL;
++
++/*static guint gst_ffmpegmux_signals[LAST_SIGNAL] = { 0 }; */
++
++typedef struct
++{
++  const char *name;
++  const char *replacement;
++} GstFFMpegMuxReplacement;
++
++static const char *
++gst_ffmpegmux_get_replacement (const char *name)
++{
++  static const GstFFMpegMuxReplacement blacklist[] = {
++    {"avi", "avimux"},
++    {"matroska", "matroskamux"},
++    {"mov", "qtmux"},
++    {"mpegts", "mpegtsmux"},
++    {"mp4", "mp4mux"},
++    {"mpjpeg", "multipartmux"},
++    {"ogg", "oggmux"},
++    {"wav", "wavenc"},
++    {"webm", "webmmux"},
++    {"mxf", "mxfmux"},
++    {"3gp", "gppmux"},
++    {"yuv4mpegpipe", "y4menc"},
++    {"aiff", "aiffmux"},
++    {"adts", "aacparse"},
++    {"asf", "asfmux"},
++    {"asf_stream", "asfmux"},
++    {"flv", "flvmux"},
++    {"mp3", "id3v2mux"},
++    {"mp2", "id3v2mux"}
++  };
++  int i;
++
++  for (i = 0; i < sizeof (blacklist) / sizeof (blacklist[0]); i++) {
++    if (strcmp (blacklist[i].name, name) == 0) {
++      return blacklist[i].replacement;
++    }
++  }
++
++  return NULL;
++}
++
++static gboolean
++gst_ffmpegmux_is_formatter (const char *name)
++{
++  static const char *replace[] = {
++    "mp2", "mp3", NULL
++  };
++  int i;
++
++  for (i = 0; replace[i]; i++)
++    if (strcmp (replace[i], name) == 0)
++      return TRUE;
++  return FALSE;
++}
++
++static void
++gst_ffmpegmux_base_init (gpointer g_class)
++{
++  GstFFMpegMuxClass *klass = (GstFFMpegMuxClass *) g_class;
++  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
++  GstPadTemplate *videosinktempl, *audiosinktempl, *srctempl;
++  AVOutputFormat *in_plugin;
++  GstCaps *srccaps, *audiosinkcaps, *videosinkcaps;
++  enum CodecID *video_ids = NULL, *audio_ids = NULL;
++  gchar *longname, *description;
++  const char *replacement;
++  gboolean is_formatter;
++
++  in_plugin =
++      (AVOutputFormat *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
++      GST_FFMUX_PARAMS_QDATA);
++  g_assert (in_plugin != NULL);
++
++  /* construct the element details struct */
++  replacement = gst_ffmpegmux_get_replacement (in_plugin->name);
++  is_formatter = gst_ffmpegmux_is_formatter (in_plugin->name);
++  if (replacement != NULL) {
++    longname =
++        g_strdup_printf ("FFmpeg %s %s (not recommended, use %s instead)",
++        in_plugin->long_name, is_formatter ? "formatter" : "muxer",
++        replacement);
++    description =
++        g_strdup_printf ("FFmpeg %s %s (not recommended, use %s instead)",
++        in_plugin->long_name, is_formatter ? "formatter" : "muxer",
++        replacement);
++  } else {
++    longname = g_strdup_printf ("FFmpeg %s %s", in_plugin->long_name,
++        is_formatter ? "formatter" : "muxer");
++    description = g_strdup_printf ("FFmpeg %s %s", in_plugin->long_name,
++        is_formatter ? "formatter" : "muxer");
++  }
++  gst_element_class_set_details_simple (element_class, longname,
++      is_formatter ? "Formatter/Metadata" : "Codec/Muxer", description,
++      "Wim Taymans <wim.taymans@chello.be>, "
++      "Ronald Bultje <rbultje@ronald.bitfreak.net>");
++  g_free (longname);
++  g_free (description);
++
++  /* Try to find the caps that belongs here */
++  srccaps = gst_ffmpeg_formatid_to_caps (in_plugin->name);
++  if (!srccaps) {
++    GST_DEBUG ("Couldn't get source caps for muxer '%s', skipping format",
++        in_plugin->name);
++    goto beach;
++  }
++
++  if (!gst_ffmpeg_formatid_get_codecids (in_plugin->name,
++          &video_ids, &audio_ids, in_plugin)) {
++    gst_caps_unref (srccaps);
++    GST_DEBUG
++        ("Couldn't get sink caps for muxer '%s'. Most likely because no input format mapping exists.",
++        in_plugin->name);
++    goto beach;
++  }
++
++  videosinkcaps = video_ids ? gst_ffmpegmux_get_id_caps (video_ids) : NULL;
++  audiosinkcaps = audio_ids ? gst_ffmpegmux_get_id_caps (audio_ids) : NULL;
++
++  /* fix up allowed caps for some muxers */
++  /* FIXME : This should be in gstffmpegcodecmap.c ! */
++  if (strcmp (in_plugin->name, "flv") == 0) {
++    const gint rates[] = { 44100, 22050, 11025 };
++
++    gst_ffmpeg_mux_simple_caps_set_int_list (audiosinkcaps, "rate", 3, rates);
++  } else if (strcmp (in_plugin->name, "gif") == 0) {
++    if (videosinkcaps)
++      gst_caps_unref (videosinkcaps);
++
++    videosinkcaps =
++        gst_caps_from_string ("video/x-raw-rgb, bpp=(int)24, depth=(int)24");
++  }
++
++  /* pad templates */
++  srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
++  gst_element_class_add_pad_template (element_class, srctempl);
++
++  if (audiosinkcaps) {
++    audiosinktempl = gst_pad_template_new ("audio_%d",
++        GST_PAD_SINK, GST_PAD_REQUEST, audiosinkcaps);
++    gst_element_class_add_pad_template (element_class, audiosinktempl);
++  }
++
++  if (videosinkcaps) {
++    videosinktempl = gst_pad_template_new ("video_%d",
++        GST_PAD_SINK, GST_PAD_REQUEST, videosinkcaps);
++    gst_element_class_add_pad_template (element_class, videosinktempl);
++  }
++
++beach:
++  klass->in_plugin = in_plugin;
++}
++
++static void
++gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass)
++{
++  GObjectClass *gobject_class;
++  GstElementClass *gstelement_class;
++
++  gobject_class = (GObjectClass *) klass;
++  gstelement_class = (GstElementClass *) klass;
++
++  parent_class = g_type_class_peek_parent (klass);
++
++  gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_ffmpegmux_set_property);
++  gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_ffmpegmux_get_property);
++
++  g_object_class_install_property (gobject_class, PROP_PRELOAD,
++      g_param_spec_int ("preload", "preload",
++          "Set the initial demux-decode delay (in microseconds)", 0, G_MAXINT,
++          0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++
++  g_object_class_install_property (gobject_class, PROP_MAXDELAY,
++      g_param_spec_int ("maxdelay", "maxdelay",
++          "Set the maximum demux-decode delay (in microseconds)", 0, G_MAXINT,
++          0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
++
++  gstelement_class->request_new_pad = gst_ffmpegmux_request_new_pad;
++  gstelement_class->change_state = gst_ffmpegmux_change_state;
++  gobject_class->finalize = gst_ffmpegmux_finalize;
++}
++
++static void
++gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux, GstFFMpegMuxClass * g_class)
++{
++  GstElementClass *klass = GST_ELEMENT_CLASS (g_class);
++  GstFFMpegMuxClass *oclass = (GstFFMpegMuxClass *) klass;
++  GstPadTemplate *templ = gst_element_class_get_pad_template (klass, "src");
++
++  ffmpegmux->srcpad = gst_pad_new_from_template (templ, "src");
++  gst_pad_set_caps (ffmpegmux->srcpad, gst_pad_template_get_caps (templ));
++  gst_element_add_pad (GST_ELEMENT (ffmpegmux), ffmpegmux->srcpad);
++
++  ffmpegmux->collect = gst_collect_pads_new ();
++  gst_collect_pads_set_function (ffmpegmux->collect,
++      (GstCollectPadsFunction) gst_ffmpegmux_collected, ffmpegmux);
++
++  ffmpegmux->context = g_new0 (AVFormatContext, 1);
++  ffmpegmux->context->oformat = oclass->in_plugin;
++  ffmpegmux->context->nb_streams = 0;
++  g_snprintf (ffmpegmux->context->filename,
++      sizeof (ffmpegmux->context->filename),
++      "gstreamer://%p", ffmpegmux->srcpad);
++  ffmpegmux->opened = FALSE;
++
++  ffmpegmux->videopads = 0;
++  ffmpegmux->audiopads = 0;
++  ffmpegmux->preload = 0;
++  ffmpegmux->max_delay = 0;
++}
++
++static void
++gst_ffmpegmux_set_property (GObject * object, guint prop_id,
++    const GValue * value, GParamSpec * pspec)
++{
++  GstFFMpegMux *src;
++
++  src = (GstFFMpegMux *) object;
++
++  switch (prop_id) {
++    case PROP_PRELOAD:
++      src->preload = g_value_get_int (value);
++      break;
++    case PROP_MAXDELAY:
++      src->max_delay = g_value_get_int (value);
++      break;
++    default:
++      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
++      break;
++  }
++}
++
++static void
++gst_ffmpegmux_get_property (GObject * object, guint prop_id, GValue * value,
++    GParamSpec * pspec)
++{
++  GstFFMpegMux *src;
++
++  src = (GstFFMpegMux *) object;
++
++  switch (prop_id) {
++    case PROP_PRELOAD:
++      g_value_set_int (value, src->preload);
++      break;
++    case PROP_MAXDELAY:
++      g_value_set_int (value, src->max_delay);
++      break;
++    default:
++      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
++      break;
++  }
++}
++
++
++static void
++gst_ffmpegmux_finalize (GObject * object)
++{
++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) object;
++
++  g_free (ffmpegmux->context);
++  gst_object_unref (ffmpegmux->collect);
++
++  if (G_OBJECT_CLASS (parent_class)->finalize)
++    G_OBJECT_CLASS (parent_class)->finalize (object);
++}
++
++static GstPad *
++gst_ffmpegmux_request_new_pad (GstElement * element,
++    GstPadTemplate * templ, const gchar * name)
++{
++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) element;
++  GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
++  GstFFMpegMuxPad *collect_pad;
++  gchar *padname;
++  GstPad *pad;
++  AVStream *st;
++  enum AVMediaType type;
++  gint bitrate = 0, framesize = 0;
++
++  g_return_val_if_fail (templ != NULL, NULL);
++  g_return_val_if_fail (templ->direction == GST_PAD_SINK, NULL);
++  g_return_val_if_fail (ffmpegmux->opened == FALSE, NULL);
++
++  /* figure out a name that *we* like */
++  if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
++    padname = g_strdup_printf ("video_%d", ffmpegmux->videopads++);
++    type = AVMEDIA_TYPE_VIDEO;
++    bitrate = 64 * 1024;
++    framesize = 1152;
++  } else if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
++    padname = g_strdup_printf ("audio_%d", ffmpegmux->audiopads++);
++    type = AVMEDIA_TYPE_AUDIO;
++    bitrate = 285 * 1024;
++  } else {
++    g_warning ("ffmux: unknown pad template!");
++    return NULL;
++  }
++
++  /* create pad */
++  pad = gst_pad_new_from_template (templ, padname);
++  collect_pad = (GstFFMpegMuxPad *)
++      gst_collect_pads_add_pad (ffmpegmux->collect, pad,
++      sizeof (GstFFMpegMuxPad));
++  collect_pad->padnum = ffmpegmux->context->nb_streams;
++
++  /* small hack to put our own event pad function and chain up to collect pad */
++  ffmpegmux->event_function = GST_PAD_EVENTFUNC (pad);
++  gst_pad_set_event_function (pad,
++      GST_DEBUG_FUNCPTR (gst_ffmpegmux_sink_event));
++
++  gst_pad_set_setcaps_function (pad, GST_DEBUG_FUNCPTR (gst_ffmpegmux_setcaps));
++  gst_element_add_pad (element, pad);
++
++  /* AVStream needs to be created */
++  st = av_new_stream (ffmpegmux->context, collect_pad->padnum);
++  st->codec->codec_type = type;
++  st->codec->codec_id = CODEC_ID_NONE;  /* this is a check afterwards */
++  st->stream_copy = 1;          /* we're not the actual encoder */
++  st->codec->bit_rate = bitrate;
++  st->codec->frame_size = framesize;
++  /* we fill in codec during capsnego */
++
++  /* we love debug output (c) (tm) (r) */
++  GST_DEBUG ("Created %s pad for ffmux_%s element",
++      padname, ((GstFFMpegMuxClass *) klass)->in_plugin->name);
++  g_free (padname);
++
++  return pad;
++}
++
++/**
++ * gst_ffmpegmux_setcaps
++ * @pad: #GstPad
++ * @caps: New caps.
++ *
++ * Set caps to pad.
++ *
++ * Returns: #TRUE on success.
++ */
++static gboolean
++gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps)
++{
++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (gst_pad_get_parent (pad));
++  GstFFMpegMuxPad *collect_pad;
++  AVStream *st;
++
++  collect_pad = (GstFFMpegMuxPad *) gst_pad_get_element_private (pad);
++
++  st = ffmpegmux->context->streams[collect_pad->padnum];
++  ffmpegmux->context->preload = ffmpegmux->preload;
++  ffmpegmux->context->max_delay = ffmpegmux->max_delay;
++
++  /* for the format-specific guesses, we'll go to
++   * our famous codec mapper */
++  if (gst_ffmpeg_caps_to_codecid (caps, st->codec) == CODEC_ID_NONE)
++    goto not_accepted;
++
++  /* copy over the aspect ratios, ffmpeg expects the stream aspect to match the
++   * codec aspect. */
++  st->sample_aspect_ratio = st->codec->sample_aspect_ratio;
++
++  GST_LOG_OBJECT (pad, "accepted caps %" GST_PTR_FORMAT, caps);
++  return TRUE;
++
++  /* ERRORS */
++not_accepted:
++  {
++    GST_LOG_OBJECT (pad, "rejecting caps %" GST_PTR_FORMAT, caps);
++    return FALSE;
++  }
++}
++
++
++static gboolean
++gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event)
++{
++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) gst_pad_get_parent (pad);
++  gboolean res = TRUE;
++
++  switch (GST_EVENT_TYPE (event)) {
++    case GST_EVENT_TAG:{
++      GstTagList *taglist;
++      GstTagSetter *setter = GST_TAG_SETTER (ffmpegmux);
++      const GstTagMergeMode mode = gst_tag_setter_get_tag_merge_mode (setter);
++
++      gst_event_parse_tag (event, &taglist);
++      gst_tag_setter_merge_tags (setter, taglist, mode);
++      break;
++    }
++    default:
++      break;
++  }
++
++  /* chaining up to collectpads default event function */
++  res = ffmpegmux->event_function (pad, event);
++
++  gst_object_unref (ffmpegmux);
++  return res;
++}
++
++static GstFlowReturn
++gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
++{
++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) user_data;
++  GSList *collected;
++  GstFFMpegMuxPad *best_pad;
++  GstClockTime best_time;
++#if 0
++  /* Re-enable once converted to new AVMetaData API
++   * See #566605
++   */
++  const GstTagList *tags;
++#endif
++
++  /* open "file" (gstreamer protocol to next element) */
++  if (!ffmpegmux->opened) {
++    int open_flags = URL_WRONLY;
++
++    /* we do need all streams to have started capsnego,
++     * or things will go horribly wrong */
++    for (collected = ffmpegmux->collect->data; collected;
++        collected = g_slist_next (collected)) {
++      GstFFMpegMuxPad *collect_pad = (GstFFMpegMuxPad *) collected->data;
++      AVStream *st = ffmpegmux->context->streams[collect_pad->padnum];
++
++      /* check whether the pad has successfully completed capsnego */
++      if (st->codec->codec_id == CODEC_ID_NONE) {
++        GST_ELEMENT_ERROR (ffmpegmux, CORE, NEGOTIATION, (NULL),
++            ("no caps set on stream %d (%s)", collect_pad->padnum,
++                (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ?
++                "video" : "audio"));
++        return GST_FLOW_ERROR;
++      }
++      /* set framerate for audio */
++      if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
++        switch (st->codec->codec_id) {
++          case CODEC_ID_PCM_S16LE:
++          case CODEC_ID_PCM_S16BE:
++          case CODEC_ID_PCM_U16LE:
++          case CODEC_ID_PCM_U16BE:
++          case CODEC_ID_PCM_S8:
++          case CODEC_ID_PCM_U8:
++            st->codec->frame_size = 1;
++            break;
++          default:
++          {
++            GstBuffer *buffer;
++
++            /* FIXME : This doesn't work for RAW AUDIO...
++             * in fact I'm wondering if it even works for any kind of audio... */
++            buffer = gst_collect_pads_peek (ffmpegmux->collect,
++                (GstCollectData *) collect_pad);
++            if (buffer) {
++              st->codec->frame_size =
++                  st->codec->sample_rate *
++                  GST_BUFFER_DURATION (buffer) / GST_SECOND;
++              gst_buffer_unref (buffer);
++            }
++          }
++        }
++      }
++    }
++
++#if 0
++    /* Re-enable once converted to new AVMetaData API
++     * See #566605
++     */
++
++    /* tags */
++    tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (ffmpegmux));
++    if (tags) {
++      gint i;
++      gchar *s;
++
++      /* get the interesting ones */
++      if (gst_tag_list_get_string (tags, GST_TAG_TITLE, &s)) {
++        strncpy (ffmpegmux->context->title, s,
++            sizeof (ffmpegmux->context->title));
++      }
++      if (gst_tag_list_get_string (tags, GST_TAG_ARTIST, &s)) {
++        strncpy (ffmpegmux->context->author, s,
++            sizeof (ffmpegmux->context->author));
++      }
++      if (gst_tag_list_get_string (tags, GST_TAG_COPYRIGHT, &s)) {
++        strncpy (ffmpegmux->context->copyright, s,
++            sizeof (ffmpegmux->context->copyright));
++      }
++      if (gst_tag_list_get_string (tags, GST_TAG_COMMENT, &s)) {
++        strncpy (ffmpegmux->context->comment, s,
++            sizeof (ffmpegmux->context->comment));
++      }
++      if (gst_tag_list_get_string (tags, GST_TAG_ALBUM, &s)) {
++        strncpy (ffmpegmux->context->album, s,
++            sizeof (ffmpegmux->context->album));
++      }
++      if (gst_tag_list_get_string (tags, GST_TAG_GENRE, &s)) {
++        strncpy (ffmpegmux->context->genre, s,
++            sizeof (ffmpegmux->context->genre));
++      }
++      if (gst_tag_list_get_int (tags, GST_TAG_TRACK_NUMBER, &i)) {
++        ffmpegmux->context->track = i;
++      }
++    }
++#endif
++
++    /* set the streamheader flag for gstffmpegprotocol if codec supports it */
++    if (!strcmp (ffmpegmux->context->oformat->name, "flv")) {
++      open_flags |= GST_FFMPEG_URL_STREAMHEADER;
++    }
++
++    if (url_fopen (&ffmpegmux->context->pb,
++            ffmpegmux->context->filename, open_flags) < 0) {
++      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, TOO_LAZY, (NULL),
++          ("Failed to open stream context in ffmux"));
++      return GST_FLOW_ERROR;
++    }
++
++    if (av_set_parameters (ffmpegmux->context, NULL) < 0) {
++      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, INIT, (NULL),
++          ("Failed to initialize muxer"));
++      return GST_FLOW_ERROR;
++    }
++
++    /* now open the mux format */
++    if (av_write_header (ffmpegmux->context) < 0) {
++      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, SETTINGS, (NULL),
++          ("Failed to write file header - check codec settings"));
++      return GST_FLOW_ERROR;
++    }
++
++    /* we're now opened */
++    ffmpegmux->opened = TRUE;
++
++    /* flush the header so it will be used as streamheader */
++    put_flush_packet (ffmpegmux->context->pb);
++  }
++
++  /* take the one with earliest timestamp,
++   * and push it forward */
++  best_pad = NULL;
++  best_time = GST_CLOCK_TIME_NONE;
++  for (collected = ffmpegmux->collect->data; collected;
++      collected = g_slist_next (collected)) {
++    GstFFMpegMuxPad *collect_pad = (GstFFMpegMuxPad *) collected->data;
++    GstBuffer *buffer = gst_collect_pads_peek (ffmpegmux->collect,
++        (GstCollectData *) collect_pad);
++
++    /* if there's no buffer, just continue */
++    if (buffer == NULL) {
++      continue;
++    }
++
++    /* if we have no buffer yet, just use the first one */
++    if (best_pad == NULL) {
++      best_pad = collect_pad;
++      best_time = GST_BUFFER_TIMESTAMP (buffer);
++      goto next_pad;
++    }
++
++    /* if we do have one, only use this one if it's older */
++    if (GST_BUFFER_TIMESTAMP (buffer) < best_time) {
++      best_time = GST_BUFFER_TIMESTAMP (buffer);
++      best_pad = collect_pad;
++    }
++
++  next_pad:
++    gst_buffer_unref (buffer);
++
++    /* Mux buffers with invalid timestamp first */
++    if (!GST_CLOCK_TIME_IS_VALID (best_time))
++      break;
++  }
++
++  /* now handle the buffer, or signal EOS if we have
++   * no buffers left */
++  if (best_pad != NULL) {
++    GstBuffer *buf;
++    AVPacket pkt;
++    gboolean need_free = FALSE;
++
++    /* push out current buffer */
++    buf = gst_collect_pads_pop (ffmpegmux->collect,
++        (GstCollectData *) best_pad);
++
++    ffmpegmux->context->streams[best_pad->padnum]->codec->frame_number++;
++
++    /* set time */
++    pkt.pts = gst_ffmpeg_time_gst_to_ff (GST_BUFFER_TIMESTAMP (buf),
++        ffmpegmux->context->streams[best_pad->padnum]->time_base);
++    pkt.dts = pkt.pts;
++
++    if (strcmp (ffmpegmux->context->oformat->name, "gif") == 0) {
++      AVStream *st = ffmpegmux->context->streams[best_pad->padnum];
++      AVPicture src, dst;
++
++      need_free = TRUE;
++      pkt.size = st->codec->width * st->codec->height * 3;
++      pkt.data = g_malloc (pkt.size);
++
++      dst.data[0] = pkt.data;
++      dst.data[1] = NULL;
++      dst.data[2] = NULL;
++      dst.linesize[0] = st->codec->width * 3;
++
++      gst_ffmpeg_avpicture_fill (&src, GST_BUFFER_DATA (buf),
++          PIX_FMT_RGB24, st->codec->width, st->codec->height);
++
++      av_picture_copy (&dst, &src, PIX_FMT_RGB24,
++          st->codec->width, st->codec->height);
++    } else {
++      pkt.data = GST_BUFFER_DATA (buf);
++      pkt.size = GST_BUFFER_SIZE (buf);
++    }
++
++    pkt.stream_index = best_pad->padnum;
++    pkt.flags = 0;
++
++    if (!GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT))
++      pkt.flags |= AV_PKT_FLAG_KEY;
++
++    if (GST_BUFFER_DURATION_IS_VALID (buf))
++      pkt.duration =
++          gst_ffmpeg_time_gst_to_ff (GST_BUFFER_DURATION (buf),
++          ffmpegmux->context->streams[best_pad->padnum]->time_base);
++    else
++      pkt.duration = 0;
++    av_write_frame (ffmpegmux->context, &pkt);
++    gst_buffer_unref (buf);
++    if (need_free)
++      g_free (pkt.data);
++  } else {
++    /* close down */
++    av_write_trailer (ffmpegmux->context);
++    ffmpegmux->opened = FALSE;
++    put_flush_packet (ffmpegmux->context->pb);
++    url_fclose (ffmpegmux->context->pb);
++    gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_eos ());
++    return GST_FLOW_UNEXPECTED;
++  }
++
++  return GST_FLOW_OK;
++}
++
++static GstStateChangeReturn
++gst_ffmpegmux_change_state (GstElement * element, GstStateChange transition)
++{
++  GstFlowReturn ret;
++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (element);
++
++  switch (transition) {
++    case GST_STATE_CHANGE_NULL_TO_READY:
++      break;
++    case GST_STATE_CHANGE_READY_TO_PAUSED:
++      gst_collect_pads_start (ffmpegmux->collect);
++      break;
++    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
++      break;
++    case GST_STATE_CHANGE_PAUSED_TO_READY:
++      gst_collect_pads_stop (ffmpegmux->collect);
++      break;
++    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_tag_setter_reset_tags (GST_TAG_SETTER (ffmpegmux));
++      if (ffmpegmux->opened) {
++        ffmpegmux->opened = FALSE;
++        url_fclose (ffmpegmux->context->pb);
++      }
++      break;
++    case GST_STATE_CHANGE_READY_TO_NULL:
++      break;
++    default:
++      break;
++  }
++
++  return ret;
++}
++
++static GstCaps *
++gst_ffmpegmux_get_id_caps (enum CodecID *id_list)
++{
++  GstCaps *caps, *t;
++  gint i;
++
++  caps = gst_caps_new_empty ();
++  for (i = 0; id_list[i] != CODEC_ID_NONE; i++) {
++    if ((t = gst_ffmpeg_codecid_to_caps (id_list[i], NULL, TRUE)))
++      gst_caps_append (caps, t);
++  }
++  if (gst_caps_is_empty (caps)) {
++    gst_caps_unref (caps);
++    return NULL;
++  }
++
++  return caps;
++}
++
++/* set a list of integer values on the caps, e.g. for sample rates */
++static void
++gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * caps, const gchar * field,
++    guint num, const gint * values)
++{
++  GValue list = { 0, };
++  GValue val = { 0, };
++  gint i;
++
++  g_return_if_fail (GST_CAPS_IS_SIMPLE (caps));
++
++  g_value_init (&list, GST_TYPE_LIST);
++  g_value_init (&val, G_TYPE_INT);
++
++  for (i = 0; i < num; ++i) {
++    g_value_set_int (&val, values[i]);
++    gst_value_list_append_value (&list, &val);
++  }
++
++  gst_structure_set_value (gst_caps_get_structure (caps, 0), field, &list);
++
++  g_value_unset (&val);
++  g_value_unset (&list);
++}
++
++gboolean
++gst_ffmpegmux_register (GstPlugin * plugin)
++{
++  GTypeInfo typeinfo = {
++    sizeof (GstFFMpegMuxClass),
++    (GBaseInitFunc) gst_ffmpegmux_base_init,
++    NULL,
++    (GClassInitFunc) gst_ffmpegmux_class_init,
++    NULL,
++    NULL,
++    sizeof (GstFFMpegMux),
++    0,
++    (GInstanceInitFunc) gst_ffmpegmux_init,
++  };
++  static const GInterfaceInfo tag_setter_info = {
++    NULL, NULL, NULL
++  };
++  GType type;
++  AVOutputFormat *in_plugin;
++
++  in_plugin = av_oformat_next (NULL);
++
++  GST_LOG ("Registering muxers");
++
++  while (in_plugin) {
++    gchar *type_name;
++    gchar *p;
++    GstRank rank = GST_RANK_MARGINAL;
++
++    if ((!strncmp (in_plugin->name, "u16", 3)) ||
++        (!strncmp (in_plugin->name, "s16", 3)) ||
++        (!strncmp (in_plugin->name, "u24", 3)) ||
++        (!strncmp (in_plugin->name, "s24", 3)) ||
++        (!strncmp (in_plugin->name, "u8", 2)) ||
++        (!strncmp (in_plugin->name, "s8", 2)) ||
++        (!strncmp (in_plugin->name, "u32", 3)) ||
++        (!strncmp (in_plugin->name, "s32", 3)) ||
++        (!strncmp (in_plugin->name, "f32", 3)) ||
++        (!strncmp (in_plugin->name, "f64", 3)) ||
++        (!strncmp (in_plugin->name, "raw", 3)) ||
++        (!strncmp (in_plugin->name, "crc", 3)) ||
++        (!strncmp (in_plugin->name, "null", 4)) ||
++        (!strncmp (in_plugin->name, "gif", 3)) ||
++        (!strncmp (in_plugin->name, "frame", 5)) ||
++        (!strncmp (in_plugin->name, "image", 5)) ||
++        (!strncmp (in_plugin->name, "mulaw", 5)) ||
++        (!strncmp (in_plugin->name, "alaw", 4)) ||
++        (!strncmp (in_plugin->name, "h26", 3)) ||
++        (!strncmp (in_plugin->name, "rtp", 3)) ||
++        (!strncmp (in_plugin->name, "ass", 3)) ||
++        (!strncmp (in_plugin->name, "ffmetadata", 10)) ||
++        (!strncmp (in_plugin->name, "srt", 3))
++        ) {
++      GST_LOG ("Ignoring muxer %s", in_plugin->name);
++      goto next;
++    }
++
++    if ((!strncmp (in_plugin->long_name, "raw ", 4))) {
++      GST_LOG ("Ignoring raw muxer %s", in_plugin->name);
++      goto next;
++    }
++
++    if (gst_ffmpegmux_get_replacement (in_plugin->name))
++      rank = GST_RANK_NONE;
++
++    /* FIXME : We need a fast way to know whether we have mappings for this
++     * muxer type. */
++
++    /* construct the type */
++    type_name = g_strdup_printf ("ffmux_%s", in_plugin->name);
++
++    p = type_name;
++
++    while (*p) {
++      if (*p == '.')
++        *p = '_';
++      p++;
++    }
++
++    type = g_type_from_name (type_name);
++
++    if (!type) {
++      /* create the type now */
++      type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
++      g_type_set_qdata (type, GST_FFMUX_PARAMS_QDATA, (gpointer) in_plugin);
++      g_type_add_interface_static (type, GST_TYPE_TAG_SETTER, &tag_setter_info);
++    }
++
++    if (!gst_element_register (plugin, type_name, rank, type)) {
++      g_free (type_name);
++      return FALSE;
++    }
++
++    g_free (type_name);
++
++  next:
++    in_plugin = av_oformat_next (in_plugin);
++  }
++
++  GST_LOG ("Finished registering muxers");
++
++  return TRUE;
++}
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegprotocol.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegprotocol.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegprotocol.c	2011-07-12 16:35:28.000000000 +0200
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegprotocol.c	2014-08-08 15:26:07.875857555 +0200
+@@ -46,63 +46,14 @@
+ };
+ 
+ static int
+-gst_ffmpegdata_open (URLContext * h, const char *filename, int flags)
+-{
+-  GstProtocolInfo *info;
+-  GstPad *pad;
+-
+-  GST_LOG ("Opening %s", filename);
+-
+-  info = g_new0 (GstProtocolInfo, 1);
+-
+-  info->set_streamheader = flags & GST_FFMPEG_URL_STREAMHEADER;
+-  flags &= ~GST_FFMPEG_URL_STREAMHEADER;
+-  h->flags &= ~GST_FFMPEG_URL_STREAMHEADER;
+-
+-  /* we don't support R/W together */
+-  if (flags != URL_RDONLY && flags != URL_WRONLY) {
+-    GST_WARNING ("Only read-only or write-only are supported");
+-    return -EINVAL;
+-  }
+-
+-  if (sscanf (&filename[12], "%p", &pad) != 1) {
+-    GST_WARNING ("could not decode pad from %s", filename);
+-    return -EIO;
+-  }
+-
+-  /* make sure we're a pad and that we're of the right type */
+-  g_return_val_if_fail (GST_IS_PAD (pad), -EINVAL);
+-
+-  switch (flags) {
+-    case URL_RDONLY:
+-      g_return_val_if_fail (GST_PAD_IS_SINK (pad), -EINVAL);
+-      break;
+-    case URL_WRONLY:
+-      g_return_val_if_fail (GST_PAD_IS_SRC (pad), -EINVAL);
+-      break;
+-  }
+-
+-  info->eos = FALSE;
+-  info->pad = pad;
+-  info->offset = 0;
+-
+-  h->priv_data = (void *) info;
+-  h->is_streamed = FALSE;
+-  h->max_packet_size = 0;
+-
+-  return 0;
+-}
+-
+-static int
+-gst_ffmpegdata_peek (URLContext * h, unsigned char *buf, int size)
++gst_ffmpegdata_peek (void *priv_data, unsigned char *buf, int size)
+ {
+   GstProtocolInfo *info;
+   GstBuffer *inbuf = NULL;
+   GstFlowReturn ret;
+   int total = 0;
+ 
+-  g_return_val_if_fail (h->flags == URL_RDONLY, AVERROR (EIO));
+-  info = (GstProtocolInfo *) h->priv_data;
++  info = (GstProtocolInfo *) priv_data;
+ 
+   GST_DEBUG ("Pulling %d bytes at position %" G_GUINT64_FORMAT, size,
+       info->offset);
+@@ -134,17 +85,17 @@
+ }
+ 
+ static int
+-gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size)
++gst_ffmpegdata_read (void *priv_data, unsigned char *buf, int size)
+ {
+   gint res;
+   GstProtocolInfo *info;
+ 
+-  info = (GstProtocolInfo *) h->priv_data;
++  info = (GstProtocolInfo *) priv_data;
+ 
+   GST_DEBUG ("Reading %d bytes of data at position %" G_GUINT64_FORMAT, size,
+       info->offset);
+ 
+-  res = gst_ffmpegdata_peek (h, buf, size);
++  res = gst_ffmpegdata_peek (priv_data, buf, size);
+   if (res >= 0)
+     info->offset += res;
+ 
+@@ -154,15 +105,13 @@
+ }
+ 
+ static int
+-gst_ffmpegdata_write (URLContext * h, const unsigned char *buf, int size)
++gst_ffmpegdata_write (void *priv_data, const unsigned char *buf, int size)
+ {
+   GstProtocolInfo *info;
+   GstBuffer *outbuf;
+ 
+   GST_DEBUG ("Writing %d bytes", size);
+-  info = (GstProtocolInfo *) h->priv_data;
+-
+-  g_return_val_if_fail (h->flags != URL_RDONLY, -EIO);
++  info = (GstProtocolInfo *) priv_data;
+ 
+   /* create buffer and push data further */
+   if (gst_pad_alloc_buffer_and_set_caps (info->pad,
+@@ -179,7 +128,7 @@
+ }
+ 
+ static int64_t
+-gst_ffmpegdata_seek (URLContext * h, int64_t pos, int whence)
++gst_ffmpegdata_seek (void *priv_data, int64_t pos, int whence)
+ {
+   GstProtocolInfo *info;
+   guint64 newpos = 0;
+@@ -187,70 +136,62 @@
+   GST_DEBUG ("Seeking to %" G_GINT64_FORMAT ", whence=%d",
+       (gint64) pos, whence);
+ 
+-  info = (GstProtocolInfo *) h->priv_data;
++  info = (GstProtocolInfo *) priv_data;
+ 
+   /* TODO : if we are push-based, we need to return sensible info */
+ 
+-  switch (h->flags) {
+-    case URL_RDONLY:
+-    {
+-      /* sinkpad */
+-      switch (whence) {
+-        case SEEK_SET:
+-          newpos = (guint64) pos;
+-          break;
+-        case SEEK_CUR:
+-          newpos = info->offset + pos;
+-          break;
+-        case SEEK_END:
+-        case AVSEEK_SIZE:
+-          /* ffmpeg wants to know the current end position in bytes ! */
+-        {
+-          GstFormat format = GST_FORMAT_BYTES;
+-          gint64 duration;
+-
+-          GST_DEBUG ("Seek end");
+-
+-          if (gst_pad_is_linked (info->pad))
+-            if (gst_pad_query_duration (GST_PAD_PEER (info->pad), &format,
+-                    &duration))
+-              newpos = ((guint64) duration) + pos;
+-        }
+-          break;
+-        default:
+-          g_assert (0);
+-          break;
++  if (GST_PAD_IS_SINK (info->pad)) {
++    /* sinkpad */
++    switch (whence) {
++      case SEEK_SET:
++        newpos = (guint64) pos;
++        break;
++      case SEEK_CUR:
++        newpos = info->offset + pos;
++        break;
++      case SEEK_END:
++      case AVSEEK_SIZE:
++        /* ffmpeg wants to know the current end position in bytes ! */
++      {
++        GstFormat format = GST_FORMAT_BYTES;
++        gint64 duration;
++
++        GST_DEBUG ("Seek end");
++
++        if (gst_pad_is_linked (info->pad))
++          if (gst_pad_query_duration (GST_PAD_PEER (info->pad), &format,
++                  &duration))
++            newpos = ((guint64) duration) + pos;
+       }
+-      /* FIXME : implement case for push-based behaviour */
+-      if (whence != AVSEEK_SIZE)
+-        info->offset = newpos;
++        break;
++      default:
++        g_assert (0);
++        break;
+     }
+-      break;
+-    case URL_WRONLY:
+-    {
+-      /* srcpad */
+-      switch (whence) {
+-        case SEEK_SET:
+-          info->offset = (guint64) pos;
+-          gst_pad_push_event (info->pad, gst_event_new_new_segment
+-              (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
+-                  GST_CLOCK_TIME_NONE, info->offset));
+-          break;
+-        case SEEK_CUR:
+-          info->offset += pos;
+-          gst_pad_push_event (info->pad, gst_event_new_new_segment
+-              (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
+-                  GST_CLOCK_TIME_NONE, info->offset));
+-          break;
+-        default:
+-          break;
+-      }
+-      newpos = info->offset;
++    /* FIXME : implement case for push-based behaviour */
++    if (whence != AVSEEK_SIZE)
++      info->offset = newpos;
++  } else if (GST_PAD_IS_SRC (info->pad)) {
++    /* srcpad */
++    switch (whence) {
++      case SEEK_SET:
++        info->offset = (guint64) pos;
++        gst_pad_push_event (info->pad, gst_event_new_new_segment
++            (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
++                GST_CLOCK_TIME_NONE, info->offset));
++        break;
++      case SEEK_CUR:
++        info->offset += pos;
++        gst_pad_push_event (info->pad, gst_event_new_new_segment
++            (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
++                GST_CLOCK_TIME_NONE, info->offset));
++        break;
++      default:
++        break;
+     }
+-      break;
+-    default:
+-      g_assert (0);
+-      break;
++    newpos = info->offset;
++  } else {
++    g_assert_not_reached ();
+   }
+ 
+   GST_DEBUG ("Now at offset %" G_GUINT64_FORMAT " (returning %" G_GUINT64_FORMAT
+@@ -258,85 +199,91 @@
+   return newpos;
+ }
+ 
+-static int
+-gst_ffmpegdata_close (URLContext * h)
++int
++gst_ffmpegdata_close (AVIOContext * h)
+ {
+   GstProtocolInfo *info;
+ 
+-  info = (GstProtocolInfo *) h->priv_data;
++  info = (GstProtocolInfo *) h->opaque;
+   if (info == NULL)
+     return 0;
+ 
+   GST_LOG ("Closing file");
+ 
+-  switch (h->flags) {
+-    case URL_WRONLY:
+-    {
+-      /* send EOS - that closes down the stream */
+-      gst_pad_push_event (info->pad, gst_event_new_eos ());
+-      break;
+-    }
+-    default:
+-      break;
++  if (GST_PAD_IS_SRC (info->pad)) {
++    /* send EOS - that closes down the stream */
++    gst_pad_push_event (info->pad, gst_event_new_eos ());
+   }
+ 
+   /* clean up data */
+   g_free (info);
+-  h->priv_data = NULL;
++  h->opaque = NULL;
++
++  av_freep (&h->buffer);
++  av_free (h);
+ 
+   return 0;
+ }
+ 
++int
++gst_ffmpegdata_open (GstPad * pad, int flags, AVIOContext ** context)
++{
++  GstProtocolInfo *info;
++  static const int buffer_size = 4096;
++  unsigned char *buffer = NULL;
+ 
+-URLProtocol gstreamer_protocol = {
+-  /*.name = */ "gstreamer",
+-  /*.url_open = */ gst_ffmpegdata_open,
+-  /*.url_read = */ gst_ffmpegdata_read,
+-  /*.url_write = */ gst_ffmpegdata_write,
+-  /*.url_seek = */ gst_ffmpegdata_seek,
+-  /*.url_close = */ gst_ffmpegdata_close,
+-};
++  info = g_new0 (GstProtocolInfo, 1);
+ 
++  info->set_streamheader = flags & GST_FFMPEG_URL_STREAMHEADER;
++  flags &= ~GST_FFMPEG_URL_STREAMHEADER;
+ 
+-/* specialized protocol for cross-thread pushing,
+- * based on ffmpeg's pipe protocol */
++  /* we don't support R/W together */
++  if ((flags & AVIO_FLAG_WRITE) && (flags & AVIO_FLAG_READ)) {
++    GST_WARNING ("Only read-only or write-only are supported");
++    return -EINVAL;
++  }
+ 
+-static int
+-gst_ffmpeg_pipe_open (URLContext * h, const char *filename, int flags)
+-{
+-  GstFFMpegPipe *ffpipe;
++  /* make sure we're a pad and that we're of the right type */
++  g_return_val_if_fail (GST_IS_PAD (pad), -EINVAL);
+ 
+-  GST_LOG ("Opening %s", filename);
++  if ((flags & AVIO_FLAG_READ))
++    g_return_val_if_fail (GST_PAD_IS_SINK (pad), -EINVAL);
++  if ((flags & AVIO_FLAG_WRITE))
++    g_return_val_if_fail (GST_PAD_IS_SRC (pad), -EINVAL);
+ 
+-  /* we don't support W together */
+-  if (flags != URL_RDONLY) {
+-    GST_WARNING ("Only read-only is supported");
+-    return -EINVAL;
+-  }
++  info->eos = FALSE;
++  info->pad = pad;
++  info->offset = 0;
+ 
+-  if (sscanf (&filename[10], "%p", &ffpipe) != 1) {
+-    GST_WARNING ("could not decode pipe info from %s", filename);
+-    return -EIO;
++  buffer = av_malloc (buffer_size);
++  if (buffer == NULL) {
++    GST_WARNING ("Failed to allocate buffer");
++    return -ENOMEM;
+   }
+ 
+-  /* sanity check */
+-  g_return_val_if_fail (GST_IS_ADAPTER (ffpipe->adapter), -EINVAL);
+-
+-  h->priv_data = (void *) ffpipe;
+-  h->is_streamed = TRUE;
+-  h->max_packet_size = 0;
++  *context =
++      avio_alloc_context (buffer, buffer_size, flags, (void *) info,
++      gst_ffmpegdata_read, gst_ffmpegdata_write, gst_ffmpegdata_seek);
++  (*context)->seekable = AVIO_SEEKABLE_NORMAL;
++  if (!(flags & AVIO_FLAG_WRITE)) {
++    (*context)->buf_ptr = (*context)->buf_end;
++    (*context)->write_flag = 0;
++  }
+ 
+   return 0;
+ }
+ 
++/* specialized protocol for cross-thread pushing,
++ * based on ffmpeg's pipe protocol */
++
+ static int
+-gst_ffmpeg_pipe_read (URLContext * h, unsigned char *buf, int size)
++gst_ffmpeg_pipe_read (void *priv_data, unsigned char *buf, int size)
+ {
+   GstFFMpegPipe *ffpipe;
+   const guint8 *data;
+   guint available;
+ 
+-  ffpipe = (GstFFMpegPipe *) h->priv_data;
++  ffpipe = (GstFFMpegPipe *) priv_data;
+ 
+   GST_LOG ("requested size %d", size);
+ 
+@@ -367,21 +314,38 @@
+   return size;
+ }
+ 
+-static int
+-gst_ffmpeg_pipe_close (URLContext * h)
++int
++gst_ffmpeg_pipe_close (AVIOContext * h)
+ {
+   GST_LOG ("Closing pipe");
+ 
+-  h->priv_data = NULL;
++  h->opaque = NULL;
++  av_freep (&h->buffer);
++  av_free (h);
+ 
+   return 0;
+ }
+ 
+-URLProtocol gstpipe_protocol = {
+-  "gstpipe",
+-  gst_ffmpeg_pipe_open,
+-  gst_ffmpeg_pipe_read,
+-  NULL,
+-  NULL,
+-  gst_ffmpeg_pipe_close,
+-};
++int
++gst_ffmpeg_pipe_open (GstFFMpegPipe * ffpipe, int flags, AVIOContext ** context)
++{
++  static const int buffer_size = 4096;
++  unsigned char *buffer = NULL;
++
++  /* sanity check */
++  g_return_val_if_fail (GST_IS_ADAPTER (ffpipe->adapter), -EINVAL);
++
++  buffer = av_malloc (buffer_size);
++  if (buffer == NULL) {
++    GST_WARNING ("Failed to allocate buffer");
++    return -ENOMEM;
++  }
++
++  *context =
++      avio_alloc_context (buffer, buffer_size, 0, (void *) ffpipe,
++      gst_ffmpeg_pipe_read, NULL, NULL);
++  (*context)->seekable = 0;
++  (*context)->buf_ptr = (*context)->buf_end;
++
++  return 0;
++}
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c	2011-07-13 11:07:28.000000000 +0200
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c	2014-08-08 15:34:04.007874626 +0200
+@@ -25,6 +25,11 @@
+ #ifdef __APPLE__
+ #include <sys/sysctl.h>
+ #endif
++#ifdef HAVE_FFMPEG_UNINSTALLED
++#include <avformat.h>
++#else
++#include <libavformat/avformat.h>
++#endif
+ 
+ G_CONST_RETURN gchar *
+ gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
+@@ -39,21 +44,21 @@
+ }
+ 
+ gint
+-av_smp_format_depth (enum SampleFormat smp_fmt)
++av_smp_format_depth (enum AVSampleFormat smp_fmt)
+ {
+   gint depth = -1;
+   switch (smp_fmt) {
+-    case SAMPLE_FMT_U8:
++    case AV_SAMPLE_FMT_U8:
+       depth = 1;
+       break;
+-    case SAMPLE_FMT_S16:
++    case AV_SAMPLE_FMT_S16:
+       depth = 2;
+       break;
+-    case SAMPLE_FMT_S32:
+-    case SAMPLE_FMT_FLT:
++    case AV_SAMPLE_FMT_S32:
++    case AV_SAMPLE_FMT_FLT:
+       depth = 4;
+       break;
+-    case SAMPLE_FMT_DBL:
++    case AV_SAMPLE_FMT_DBL:
+       depth = 8;
+       break;
+     default:
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c.orig
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c.orig	1970-01-01 01:00:00.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c.orig	2011-07-13 11:07:28.000000000 +0200
+@@ -0,0 +1,483 @@
++/* GStreamer
++ * Copyright (c) 2009 Edward Hervey <bilboed@bilboed.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.
++ */
++
++#ifdef HAVE_CONFIG_H
++#include "config.h"
++#endif
++#include "gstffmpegutils.h"
++#include <unistd.h>
++#ifdef __APPLE__
++#include <sys/sysctl.h>
++#endif
++
++G_CONST_RETURN gchar *
++gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
++{
++  AVCodec *codec;
++  /* Let's use what ffmpeg can provide us */
++
++  if ((codec = avcodec_find_decoder (codec_id)) ||
++      (codec = avcodec_find_encoder (codec_id)))
++    return codec->long_name;
++  return NULL;
++}
++
++gint
++av_smp_format_depth (enum SampleFormat smp_fmt)
++{
++  gint depth = -1;
++  switch (smp_fmt) {
++    case SAMPLE_FMT_U8:
++      depth = 1;
++      break;
++    case SAMPLE_FMT_S16:
++      depth = 2;
++      break;
++    case SAMPLE_FMT_S32:
++    case SAMPLE_FMT_FLT:
++      depth = 4;
++      break;
++    case SAMPLE_FMT_DBL:
++      depth = 8;
++      break;
++    default:
++      GST_ERROR ("UNHANDLED SAMPLE FORMAT !");
++      break;
++  }
++  return depth;
++}
++
++
++/*
++ * Fill in pointers to memory in a AVPicture, where
++ * everything is aligned by 4 (as required by X).
++ * This is mostly a copy from imgconvert.c with some
++ * small changes.
++ */
++
++#define FF_COLOR_RGB      0     /* RGB color space */
++#define FF_COLOR_GRAY     1     /* gray color space */
++#define FF_COLOR_YUV      2     /* YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */
++#define FF_COLOR_YUV_JPEG 3     /* YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */
++
++#define FF_PIXEL_PLANAR   0     /* each channel has one component in AVPicture */
++#define FF_PIXEL_PACKED   1     /* only one components containing all the channels */
++#define FF_PIXEL_PALETTE  2     /* one components containing indexes for a palette */
++
++typedef struct PixFmtInfo
++{
++  const char *name;
++  uint8_t nb_channels;          /* number of channels (including alpha) */
++  uint8_t color_type;           /* color type (see FF_COLOR_xxx constants) */
++  uint8_t pixel_type;           /* pixel storage type (see FF_PIXEL_xxx constants) */
++  uint8_t is_alpha:1;           /* true if alpha can be specified */
++  uint8_t x_chroma_shift;       /* X chroma subsampling factor is 2 ^ shift */
++  uint8_t y_chroma_shift;       /* Y chroma subsampling factor is 2 ^ shift */
++  uint8_t depth;                /* bit depth of the color components */
++} PixFmtInfo;
++
++
++/* this table gives more information about formats */
++static PixFmtInfo pix_fmt_info[PIX_FMT_NB];
++void
++gst_ffmpeg_init_pix_fmt_info (void)
++{
++  /* YUV formats */
++  pix_fmt_info[PIX_FMT_YUV420P].name = g_strdup ("yuv420p");
++  pix_fmt_info[PIX_FMT_YUV420P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUV420P].color_type = FF_COLOR_YUV;
++  pix_fmt_info[PIX_FMT_YUV420P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUV420P].depth = 8,
++      pix_fmt_info[PIX_FMT_YUV420P].x_chroma_shift = 1,
++      pix_fmt_info[PIX_FMT_YUV420P].y_chroma_shift = 1;
++
++  pix_fmt_info[PIX_FMT_YUV422P].name = g_strdup ("yuv422p");
++  pix_fmt_info[PIX_FMT_YUV422P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUV422P].color_type = FF_COLOR_YUV;
++  pix_fmt_info[PIX_FMT_YUV422P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUV422P].depth = 8;
++  pix_fmt_info[PIX_FMT_YUV422P].x_chroma_shift = 1;
++  pix_fmt_info[PIX_FMT_YUV422P].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_YUV444P].name = g_strdup ("yuv444p");
++  pix_fmt_info[PIX_FMT_YUV444P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUV444P].color_type = FF_COLOR_YUV;
++  pix_fmt_info[PIX_FMT_YUV444P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUV444P].depth = 8;
++  pix_fmt_info[PIX_FMT_YUV444P].x_chroma_shift = 0;
++  pix_fmt_info[PIX_FMT_YUV444P].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_YUYV422].name = g_strdup ("yuv422");
++  pix_fmt_info[PIX_FMT_YUYV422].nb_channels = 1;
++  pix_fmt_info[PIX_FMT_YUYV422].color_type = FF_COLOR_YUV;
++  pix_fmt_info[PIX_FMT_YUYV422].pixel_type = FF_PIXEL_PACKED;
++  pix_fmt_info[PIX_FMT_YUYV422].depth = 8;
++  pix_fmt_info[PIX_FMT_YUYV422].x_chroma_shift = 1;
++  pix_fmt_info[PIX_FMT_YUYV422].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_YUV410P].name = g_strdup ("yuv410p");
++  pix_fmt_info[PIX_FMT_YUV410P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUV410P].color_type = FF_COLOR_YUV;
++  pix_fmt_info[PIX_FMT_YUV410P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUV410P].depth = 8;
++  pix_fmt_info[PIX_FMT_YUV410P].x_chroma_shift = 2;
++  pix_fmt_info[PIX_FMT_YUV410P].y_chroma_shift = 2;
++
++  pix_fmt_info[PIX_FMT_YUV411P].name = g_strdup ("yuv411p");
++  pix_fmt_info[PIX_FMT_YUV411P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUV411P].color_type = FF_COLOR_YUV;
++  pix_fmt_info[PIX_FMT_YUV411P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUV411P].depth = 8;
++  pix_fmt_info[PIX_FMT_YUV411P].x_chroma_shift = 2;
++  pix_fmt_info[PIX_FMT_YUV411P].y_chroma_shift = 0;
++
++  /* JPEG YUV */
++  pix_fmt_info[PIX_FMT_YUVJ420P].name = g_strdup ("yuvj420p");
++  pix_fmt_info[PIX_FMT_YUVJ420P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUVJ420P].color_type = FF_COLOR_YUV_JPEG;
++  pix_fmt_info[PIX_FMT_YUVJ420P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUVJ420P].depth = 8;
++  pix_fmt_info[PIX_FMT_YUVJ420P].x_chroma_shift = 1;
++  pix_fmt_info[PIX_FMT_YUVJ420P].y_chroma_shift = 1;
++
++  pix_fmt_info[PIX_FMT_YUVJ422P].name = g_strdup ("yuvj422p");
++  pix_fmt_info[PIX_FMT_YUVJ422P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUVJ422P].color_type = FF_COLOR_YUV_JPEG;
++  pix_fmt_info[PIX_FMT_YUVJ422P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUVJ422P].depth = 8;
++  pix_fmt_info[PIX_FMT_YUVJ422P].x_chroma_shift = 1;
++  pix_fmt_info[PIX_FMT_YUVJ422P].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_YUVJ444P].name = g_strdup ("yuvj444p");
++  pix_fmt_info[PIX_FMT_YUVJ444P].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_YUVJ444P].color_type = FF_COLOR_YUV_JPEG;
++  pix_fmt_info[PIX_FMT_YUVJ444P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUVJ444P].depth = 8;
++  pix_fmt_info[PIX_FMT_YUVJ444P].x_chroma_shift = 0;
++  pix_fmt_info[PIX_FMT_YUVJ444P].y_chroma_shift = 0;
++
++  /* RGB formats */
++  pix_fmt_info[PIX_FMT_RGB24].name = g_strdup ("rgb24");
++  pix_fmt_info[PIX_FMT_RGB24].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_RGB24].color_type = FF_COLOR_RGB;
++  pix_fmt_info[PIX_FMT_RGB24].pixel_type = FF_PIXEL_PACKED;
++  pix_fmt_info[PIX_FMT_RGB24].depth = 8;
++  pix_fmt_info[PIX_FMT_RGB24].x_chroma_shift = 0;
++  pix_fmt_info[PIX_FMT_RGB24].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_BGR24].name = g_strdup ("bgr24");
++  pix_fmt_info[PIX_FMT_BGR24].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_BGR24].color_type = FF_COLOR_RGB;
++  pix_fmt_info[PIX_FMT_BGR24].pixel_type = FF_PIXEL_PACKED;
++  pix_fmt_info[PIX_FMT_BGR24].depth = 8;
++  pix_fmt_info[PIX_FMT_BGR24].x_chroma_shift = 0;
++  pix_fmt_info[PIX_FMT_BGR24].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_RGB32].name = g_strdup ("rgba32");
++  pix_fmt_info[PIX_FMT_RGB32].nb_channels = 4;
++  pix_fmt_info[PIX_FMT_RGB32].is_alpha = 1;
++  pix_fmt_info[PIX_FMT_RGB32].color_type = FF_COLOR_RGB;
++  pix_fmt_info[PIX_FMT_RGB32].pixel_type = FF_PIXEL_PACKED;
++  pix_fmt_info[PIX_FMT_RGB32].depth = 8;
++  pix_fmt_info[PIX_FMT_RGB32].x_chroma_shift = 0;
++  pix_fmt_info[PIX_FMT_RGB32].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_RGB565].name = g_strdup ("rgb565");
++  pix_fmt_info[PIX_FMT_RGB565].nb_channels = 3;
++  pix_fmt_info[PIX_FMT_RGB565].color_type = FF_COLOR_RGB;
++  pix_fmt_info[PIX_FMT_RGB565].pixel_type = FF_PIXEL_PACKED;
++  pix_fmt_info[PIX_FMT_RGB565].depth = 5;
++  pix_fmt_info[PIX_FMT_RGB565].x_chroma_shift = 0;
++  pix_fmt_info[PIX_FMT_RGB565].y_chroma_shift = 0;
++
++  pix_fmt_info[PIX_FMT_RGB555].name = g_strdup ("rgb555");
++  pix_fmt_info[PIX_FMT_RGB555].nb_channels = 4;
++  pix_fmt_info[PIX_FMT_RGB555].is_alpha = 1;
++  pix_fmt_info[PIX_FMT_RGB555].color_type = FF_COLOR_RGB;
++  pix_fmt_info[PIX_FMT_RGB555].pixel_type = FF_PIXEL_PACKED;
++  pix_fmt_info[PIX_FMT_RGB555].depth = 5;
++  pix_fmt_info[PIX_FMT_RGB555].x_chroma_shift = 0;
++  pix_fmt_info[PIX_FMT_RGB555].y_chroma_shift = 0;
++
++  /* gray / mono formats */
++  pix_fmt_info[PIX_FMT_GRAY8].name = g_strdup ("gray");
++  pix_fmt_info[PIX_FMT_GRAY8].nb_channels = 1;
++  pix_fmt_info[PIX_FMT_GRAY8].color_type = FF_COLOR_GRAY;
++  pix_fmt_info[PIX_FMT_GRAY8].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_GRAY8].depth = 8;
++
++  pix_fmt_info[PIX_FMT_MONOWHITE].name = g_strdup ("monow");
++  pix_fmt_info[PIX_FMT_MONOWHITE].nb_channels = 1;
++  pix_fmt_info[PIX_FMT_MONOWHITE].color_type = FF_COLOR_GRAY;
++  pix_fmt_info[PIX_FMT_MONOWHITE].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_MONOWHITE].depth = 1;
++
++  pix_fmt_info[PIX_FMT_MONOBLACK].name = g_strdup ("monob");
++  pix_fmt_info[PIX_FMT_MONOBLACK].nb_channels = 1;
++  pix_fmt_info[PIX_FMT_MONOBLACK].color_type = FF_COLOR_GRAY;
++  pix_fmt_info[PIX_FMT_MONOBLACK].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_MONOBLACK].depth = 1;
++
++  /* paletted formats */
++  pix_fmt_info[PIX_FMT_PAL8].name = g_strdup ("pal8");
++  pix_fmt_info[PIX_FMT_PAL8].nb_channels = 4;
++  pix_fmt_info[PIX_FMT_PAL8].is_alpha = 1;
++  pix_fmt_info[PIX_FMT_PAL8].color_type = FF_COLOR_RGB;
++  pix_fmt_info[PIX_FMT_PAL8].pixel_type = FF_PIXEL_PALETTE;
++  pix_fmt_info[PIX_FMT_PAL8].depth = 8;
++
++  pix_fmt_info[PIX_FMT_YUVA420P].name = g_strdup ("yuva420p");
++  pix_fmt_info[PIX_FMT_YUVA420P].nb_channels = 4;
++  pix_fmt_info[PIX_FMT_YUVA420P].is_alpha = 1;
++  pix_fmt_info[PIX_FMT_YUVA420P].color_type = FF_COLOR_YUV;
++  pix_fmt_info[PIX_FMT_YUVA420P].pixel_type = FF_PIXEL_PLANAR;
++  pix_fmt_info[PIX_FMT_YUVA420P].depth = 8,
++      pix_fmt_info[PIX_FMT_YUVA420P].x_chroma_shift = 1,
++      pix_fmt_info[PIX_FMT_YUVA420P].y_chroma_shift = 1;
++};
++
++int
++gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height)
++{
++  AVPicture dummy_pict;
++
++  return gst_ffmpeg_avpicture_fill (&dummy_pict, NULL, pix_fmt, width, height);
++}
++
++#define GEN_MASK(x) ((1<<(x))-1)
++#define ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) & ~GEN_MASK(x))
++#define ROUND_UP_2(x) ROUND_UP_X (x, 1)
++#define ROUND_UP_4(x) ROUND_UP_X (x, 2)
++#define ROUND_UP_8(x) ROUND_UP_X (x, 3)
++#define DIV_ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) >> (x))
++
++int
++gst_ffmpeg_avpicture_fill (AVPicture * picture,
++    uint8_t * ptr, enum PixelFormat pix_fmt, int width, int height)
++{
++  int size, w2, h2, size2;
++  int stride, stride2;
++  PixFmtInfo *pinfo;
++
++  pinfo = &pix_fmt_info[pix_fmt];
++
++  switch (pix_fmt) {
++    case PIX_FMT_YUV420P:
++    case PIX_FMT_YUV422P:
++    case PIX_FMT_YUV444P:
++    case PIX_FMT_YUV410P:
++    case PIX_FMT_YUV411P:
++    case PIX_FMT_YUVJ420P:
++    case PIX_FMT_YUVJ422P:
++    case PIX_FMT_YUVJ444P:
++      stride = ROUND_UP_4 (width);
++      h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
++      size = stride * h2;
++      w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
++      stride2 = ROUND_UP_4 (w2);
++      h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift);
++      size2 = stride2 * h2;
++      picture->data[0] = ptr;
++      picture->data[1] = picture->data[0] + size;
++      picture->data[2] = picture->data[1] + size2;
++      picture->data[3] = NULL;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = stride2;
++      picture->linesize[2] = stride2;
++      picture->linesize[3] = 0;
++      GST_DEBUG ("planes %d %d %d", 0, size, size + size2);
++      GST_DEBUG ("strides %d %d %d", stride, stride2, stride2);
++      return size + 2 * size2;
++    case PIX_FMT_YUVA420P:
++      stride = ROUND_UP_4 (width);
++      h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
++      size = stride * h2;
++      w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
++      stride2 = ROUND_UP_4 (w2);
++      h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift);
++      size2 = stride2 * h2;
++      picture->data[0] = ptr;
++      picture->data[1] = picture->data[0] + size;
++      picture->data[2] = picture->data[1] + size2;
++      picture->data[3] = picture->data[2] + size2;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = stride2;
++      picture->linesize[2] = stride2;
++      picture->linesize[3] = stride;
++      GST_DEBUG ("planes %d %d %d %d", 0, size, size + size2, size + 2 * size2);
++      GST_DEBUG ("strides %d %d %d %d", stride, stride2, stride2, stride);
++      return 2 * size + 2 * size2;
++    case PIX_FMT_RGB24:
++    case PIX_FMT_BGR24:
++      stride = ROUND_UP_4 (width * 3);
++      size = stride * height;
++      picture->data[0] = ptr;
++      picture->data[1] = NULL;
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = 0;
++      picture->linesize[2] = 0;
++      picture->linesize[3] = 0;
++      return size;
++      /*case PIX_FMT_AYUV4444:
++         case PIX_FMT_BGR32:
++         case PIX_FMT_BGRA32:
++         case PIX_FMT_RGB32: */
++    case PIX_FMT_RGB32:
++      stride = width * 4;
++      size = stride * height;
++      picture->data[0] = ptr;
++      picture->data[1] = NULL;
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = 0;
++      picture->linesize[2] = 0;
++      picture->linesize[3] = 0;
++      return size;
++    case PIX_FMT_RGB555:
++    case PIX_FMT_RGB565:
++    case PIX_FMT_YUYV422:
++    case PIX_FMT_UYVY422:
++      stride = ROUND_UP_4 (width * 2);
++      size = stride * height;
++      picture->data[0] = ptr;
++      picture->data[1] = NULL;
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = 0;
++      picture->linesize[2] = 0;
++      picture->linesize[3] = 0;
++      return size;
++    case PIX_FMT_UYYVYY411:
++      /* FIXME, probably not the right stride */
++      stride = ROUND_UP_4 (width);
++      size = stride * height;
++      picture->data[0] = ptr;
++      picture->data[1] = NULL;
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      picture->linesize[0] = width + width / 2;
++      picture->linesize[1] = 0;
++      picture->linesize[2] = 0;
++      picture->linesize[3] = 0;
++      return size + size / 2;
++    case PIX_FMT_GRAY8:
++      stride = ROUND_UP_4 (width);
++      size = stride * height;
++      picture->data[0] = ptr;
++      picture->data[1] = NULL;
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = 0;
++      picture->linesize[2] = 0;
++      picture->linesize[3] = 0;
++      return size;
++    case PIX_FMT_MONOWHITE:
++    case PIX_FMT_MONOBLACK:
++      stride = ROUND_UP_4 ((width + 7) >> 3);
++      size = stride * height;
++      picture->data[0] = ptr;
++      picture->data[1] = NULL;
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = 0;
++      picture->linesize[2] = 0;
++      picture->linesize[3] = 0;
++      return size;
++    case PIX_FMT_PAL8:
++      /* already forced to be with stride, so same result as other function */
++      stride = ROUND_UP_4 (width);
++      size = stride * height;
++      picture->data[0] = ptr;
++      picture->data[1] = ptr + size;    /* palette is stored here as 256 32 bit words */
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      picture->linesize[0] = stride;
++      picture->linesize[1] = 4;
++      picture->linesize[2] = 0;
++      picture->linesize[3] = 0;
++      return size + 256 * 4;
++    default:
++      picture->data[0] = NULL;
++      picture->data[1] = NULL;
++      picture->data[2] = NULL;
++      picture->data[3] = NULL;
++      return -1;
++  }
++
++  return 0;
++}
++
++/* Create a GstBuffer of the requested size and caps.
++ * The memory will be allocated by ffmpeg, making sure it's properly aligned
++ * for any processing. */
++
++GstBuffer *
++new_aligned_buffer (gint size, GstCaps * caps)
++{
++  GstBuffer *buf;
++
++  buf = gst_buffer_new ();
++  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = av_malloc (size);
++  GST_BUFFER_SIZE (buf) = size;
++  GST_BUFFER_FREE_FUNC (buf) = av_free;
++  if (caps)
++    gst_buffer_set_caps (buf, caps);
++
++  return buf;
++}
++
++int
++gst_ffmpeg_auto_max_threads (void)
++{
++  static gsize n_threads = 0;
++  if (g_once_init_enter (&n_threads)) {
++    int n = 1;
++#if defined(_WIN32)
++    {
++      const char *s = getenv ("NUMBER_OF_PROCESSORS");
++      if (s) {
++        n = atoi (s);
++      }
++    }
++#elif defined(__APPLE__)
++    {
++      int mib[] = { CTL_HW, HW_NCPU };
++      size_t dataSize = sizeof (int);
++
++      if (sysctl (mib, 2, &n_threads, &dataSize, NULL, 0)) {
++        n = 1;
++      }
++    }
++#else
++    n = sysconf (_SC_NPROCESSORS_CONF);
++#endif
++    if (n < 1)
++      n = 1;
++
++    g_once_init_leave (&n_threads, n);
++  }
++
++  return (int) (n_threads);
++}
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h	2011-11-02 14:04:05.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h	2014-08-08 15:34:04.007874626 +0200
+@@ -23,6 +23,7 @@
+ #ifdef HAVE_FFMPEG_UNINSTALLED
+ #include <avcodec.h>
+ #else
++#include <libavutil/mathematics.h>
+ #include <libavcodec/avcodec.h>
+ #endif
+ #include <gst/gst.h>
+@@ -87,7 +88,7 @@
+ gst_ffmpeg_get_codecid_longname (enum CodecID codec_id);
+ 
+ gint
+-av_smp_format_depth(enum SampleFormat smp_fmt);
++av_smp_format_depth(enum AVSampleFormat smp_fmt);
+ 
+ GstBuffer *
+ new_aligned_buffer (gint size, GstCaps * caps);
+diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h.orig
+--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h.orig	1970-01-01 01:00:00.000000000 +0100
++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h.orig	2014-08-08 15:26:38.473858652 +0200
+@@ -0,0 +1,95 @@
++/* GStreamer
++ * Copyright (C) <2009> Edward Hervey <bilboed@bilboed.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.
++ */
++
++#ifndef __GST_FFMPEG_UTILS_H__
++#define __GST_FFMPEG_UTILS_H__
++
++#ifdef HAVE_FFMPEG_UNINSTALLED
++#include <avcodec.h>
++#else
++#include <libavcodec/avcodec.h>
++#endif
++#include <gst/gst.h>
++
++/*
++ *Get the size of an picture
++ */
++int
++gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height);
++
++/*
++ * Fill in pointers in an AVPicture, aligned by 4 (required by X).
++ */
++
++int
++gst_ffmpeg_avpicture_fill (AVPicture * picture,
++                           uint8_t *   ptr,
++                           enum PixelFormat pix_fmt,
++                           int         width,
++                           int         height);
++
++/*
++ * Convert from/to a GStreamer <-> FFMpeg timestamp.
++ */
++static inline guint64
++gst_ffmpeg_time_ff_to_gst (gint64 pts, AVRational base)
++{
++  guint64 out;
++
++  if (pts == AV_NOPTS_VALUE){
++    out = GST_CLOCK_TIME_NONE;
++  } else {
++    AVRational bq = { 1, GST_SECOND };
++    out = av_rescale_q (pts, base, bq);
++  }
++
++  return out;
++}
++
++static inline gint64
++gst_ffmpeg_time_gst_to_ff (guint64 time, AVRational base)
++{
++  gint64 out;
++
++  if (!GST_CLOCK_TIME_IS_VALID (time) || base.num == 0) {
++    out = AV_NOPTS_VALUE;
++  } else {
++    AVRational bq = { 1, GST_SECOND };
++    out = av_rescale_q (time, bq, base);
++  }
++
++  return out;
++}
++
++void 
++gst_ffmpeg_init_pix_fmt_info(void);
++
++int
++gst_ffmpeg_auto_max_threads(void);
++
++G_CONST_RETURN gchar *
++gst_ffmpeg_get_codecid_longname (enum CodecID codec_id);
++
++gint
++av_smp_format_depth(enum AVSampleFormat smp_fmt);
++
++GstBuffer *
++new_aligned_buffer (gint size, GstCaps * caps);
++
++#endif /* __GST_FFMPEG_UTILS_H__ */
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e500mc.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e500mc.patch
new file mode 100644
index 0000000..eba4988
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e500mc.patch
@@ -0,0 +1,21 @@
+diff --git a/gst-libs/ext/libav/configure b/gst-libs/ext/libav/configure
+index 8473069..4f74952 100755
+--- a/gst-libs/ext/libav/configure
++++ b/gst-libs/ext/libav/configure
+Fix gst-ffmpeg build issues for libav on e500mc (fsl-p4080)
+
+Upstream-Status: Backport
+
+Signed-off-by: Yao Zhao <yao.zhao@windriver.com>
+
+@@ -2210,6 +2210,10 @@ elif enabled ppc; then
+             cpuflags="-mcpu=cell"
+             enable ldbrx
+         ;;
++        e500mc)
++            cpuflags="-mcpu=e500mc"
++            disable altivec
++        ;;
+         e500v2)
+             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
+             disable altivec
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e5500.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e5500.patch
new file mode 100644
index 0000000..d9ea2c2
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e5500.patch
@@ -0,0 +1,19 @@
+libav: Add configs for ppc e5500
+
+Upstream-Status: Pending
+
+Signed-off-by: Jesse Zhang <sen.zhang@windriver.com>
+
+--- gst-ffmpeg-0.10.13/gst-libs/ext/libav/configure	2013-06-20 05:18:36.073104964 -0400
++++ gst-ffmpeg-0.10.13/gst-libs/ext/libav/configure	2013-06-20 05:18:38.269104150 -0400
+@@ -2222,6 +2222,10 @@
+             cpuflags="-mcpu=8540 -mhard-float"
+             disable altivec
+         ;;
++        e5500)
++            cpuflags="-mcpu=e5500 -mhard-float"
++            disable altivec
++        ;;
+     esac
+ 
+ elif enabled x86; then
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/lower-rank.diff b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/lower-rank.diff
new file mode 100644
index 0000000..5f08afe
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/lower-rank.diff
@@ -0,0 +1,16 @@
+Lower the rank of ffmpeg plugin so codecs that hook into accelerated pieces (e.g. dsp or hw engines) can get picked over this
+Derived from OE by Dongxiao Xu <dongxiao.xu@intel.com>
+
+Upstream-Status: Inappropriate [embedded specific]
+
+--- /tmp/gstffmpegdec.c	2009-03-05 09:31:15.000000000 +0100
++++ gst-ffmpeg-0.10.6/ext/ffmpeg/gstffmpegdec.c	2009-03-05 09:33:09.000000000 +0100
+@@ -2588,7 +2588,7 @@
+       case CODEC_ID_MSMPEG4V3:
+       case CODEC_ID_H264:
+       case CODEC_ID_COOK:
+-        rank = GST_RANK_PRIMARY;
++        rank = GST_RANK_SECONDARY;
+         break;
+       case CODEC_ID_DVVIDEO:
+         /* we have a good dv decoder, fast on both ppc as well as x86. they say
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg_0.10.13.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg_0.10.13.bb
new file mode 100644
index 0000000..b5c838f
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg_0.10.13.bb
@@ -0,0 +1,90 @@
+SUMMARY = "FFmpeg-based GStreamer plug-in"
+SECTION = "multimedia"
+LICENSE = "GPLv2+ & LGPLv2+ & ( (GPLv2+ & LGPLv2.1+) | (GPLv3+ & LGPLv3+) )"
+LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
+                    file://ext/libpostproc/gstpostproc.c;beginline=1;endline=18;md5=5896e445e41681324381f5869ee33d38 \
+                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
+                    file://ext/ffmpeg/gstffmpeg.h;beginline=1;endline=18;md5=ff65467b0c53cdfa98d0684c1bc240a9 \
+                    file://gst-libs/ext/libav/LICENSE;md5=abc3b8cb02856aa7823bbbd162d16232 \
+                    file://gst-libs/ext/libav/COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
+                    file://gst-libs/ext/libav/COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \
+                    file://gst-libs/ext/libav/COPYING.LGPLv2.1;md5=e344c8fa836c3a41c4cbd79d7bd3a379 \
+                    file://gst-libs/ext/libav/COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02"
+LICENSE_FLAGS = "commercial"
+HOMEPAGE = "http://www.gstreamer.net/"
+DEPENDS = "gstreamer gst-plugins-base zlib bzip2 yasm-native libpostproc"
+
+inherit autotools-brokensep pkgconfig
+
+SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2 \
+           file://lower-rank.diff \
+           file://configure-fix.patch \
+           file://h264_qpel_mmx.patch \
+           file://libav_e500mc.patch \
+           file://libav_e5500.patch \
+           file://gst-ffmpeg-CVE-2013-3674.patch \
+           file://0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch \
+           file://0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch \
+           file://0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch \
+           file://0001-huffyuvdec-Skip-len-0-cases.patch \
+           file://0001-huffyuvdec-Check-init_vlc-return-codes.patch \
+           file://0001-alsdec-check-block-length.patch \
+           file://0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch \
+           file://0001-atrac3dec-Check-coding-mode-against-channels.patch \
+           file://0001-eamad-fix-out-of-array-accesses.patch \
+           file://0001-mjpegdec-check-SE.patch \
+           file://0001-alac-fix-nb_samples-order-case.patch \
+           file://0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch \
+           file://0001-roqvideodec-check-dimensions-validity.patch \
+           file://0001-aacdec-check-channel-count.patch \
+           file://0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch \
+           file://0001-error_concealment-Check-that-the-picture-is-not-in-a.patch \
+           file://0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch \
+           file://0001-vp3-Copy-all-3-frames-for-thread-updates.patch \
+           file://0001-h264_sei-Fix-infinite-loop.patch \
+           file://0001-avcodec-parser-reset-indexes-on-realloc-failure.patch \
+           file://0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch \
+           file://gst-ffmpeg-CVE-2013-0855.patch \
+           file://0001-qdm2dec-fix-buffer-overflow.patch \
+           file://0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch \
+           file://0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch \
+           file://0001-error-concealment-initialize-block-index.patch \
+           file://0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch \
+           file://0001-lavf-compute-probe-buffer-size-more-reliably.patch \
+           file://0001-ffserver-set-oformat.patch \
+           file://0001-h264-set-parameters-from-SPS-whenever-it-changes.patch \
+           file://0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch \
+           file://0001-avcodec-smc-fix-off-by-1-error.patch \
+           file://0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch \
+           file://libav-9.patch \
+"
+
+SRC_URI[md5sum] = "7f5beacaf1312db2db30a026b36888c4"
+SRC_URI[sha256sum] = "76fca05b08e00134e3cb92fa347507f42cbd48ddb08ed3343a912def187fbb62"
+
+PR = "r8"
+
+GSTREAMER_DEBUG ?= "--disable-debug"
+
+FFMPEG_EXTRA_CONFIGURE = "--with-ffmpeg-extra-configure"
+# pass --cpu for powerpc. get cpu name by stripping "ppc" or "ppc64"
+# from DEFAULTTUNE
+FFMPEG_CPU_powerpc = "--cpu=${@d.getVar('DEFAULTTUNE')[3:]}"
+FFMPEG_CPU_powerpc64 = "--cpu=${@d.getVar('DEFAULTTUNE')[5:]}"
+FFMPEG_EXTRA_CONFIGURE_COMMON_ARG = "--target-os=linux ${FFMPEG_CPU} \
+  --cc='${CC}' --as='${CC}' --ld='${CC}' --nm='${NM}' --ar='${AR}' \
+  --ranlib='${RANLIB}' \
+  ${GSTREAMER_DEBUG}"
+FFMPEG_EXTRA_CONFIGURE_COMMON = \
+'${FFMPEG_EXTRA_CONFIGURE}="${FFMPEG_EXTRA_CONFIGURE_COMMON_ARG}"'
+
+EXTRA_OECONF = "${FFMPEG_EXTRA_CONFIGURE_COMMON}"
+
+PACKAGECONFIG ??= "external-libav"
+PACKAGECONFIG[external-libav] = "--with-system-ffmpeg,,libav"
+PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
+
+FILES_${PN} += "${libdir}/gstreamer-0.10/*.so"
+FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug"
+FILES_${PN}-dev += "${libdir}/gstreamer-0.10/*.la"
+FILES_${PN}-staticdev += "${libdir}/gstreamer-0.10/*.a"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb
new file mode 100644
index 0000000..1e2cd2a
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb
@@ -0,0 +1,14 @@
+require gst-fluendo.inc
+
+SUMMARY = "Fluendo closed-format mp3 GStreamer plug-in"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://COPYING;md5=259a43dd1c9854b71fc396f74699f4d2"
+LICENSE_FLAGS = "commercial"
+
+GSTREAMER_DEBUG ?= "--disable-debug"
+EXTRA_OECONF += "${GSTREAMER_DEBUG} --with-gstreamer-api=0.10"
+
+acpaths = "-I ${S}/common/m4 -I ${S}/m4"
+
+SRC_URI[md5sum] = "adf0390f3416bb72f91c358528be0c38"
+SRC_URI[sha256sum] = "dae0d0559a4e159c0dd92b7e18de059a5783f8d038904c7de4ca6393f7d55c7d"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mpegdemux_0.10.85.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mpegdemux_0.10.85.bb
new file mode 100644
index 0000000..7bba41a
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mpegdemux_0.10.85.bb
@@ -0,0 +1,12 @@
+require gst-fluendo.inc
+
+SUMMARY = "Fluendo MPEG Transport Stream and Program Stream demuxer for GStreamer"
+LICENSE = "MPLv1.1"
+LIC_FILES_CHKSUM = "file://COPYING;md5=be282f1c3cc9a98cc0dc5c2b25dfc510 \
+                    file://src/gstmpegdemux.h;beginline=1;endline=19;md5=a9e90033f59897b91664d9f2a2ff01dd"
+LICENSE_FLAGS = "commercial"
+
+acpaths = "-I ${S}/common/m4 -I ${S}/m4"
+
+SRC_URI[md5sum] = "7c4fb993f80b9ae631b11897733f0970"
+SRC_URI[sha256sum] = "df04c91cc8e5d9a892c2492ed989974b4547beaa2a3647649e85113317897424"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo.inc b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo.inc
new file mode 100644
index 0000000..7a77d62
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo.inc
@@ -0,0 +1,14 @@
+SUMMARY = "Fluendo closed-format GStreamer plug-in"
+SECTION = "multimedia"
+HOMEPAGE = "https://core.fluendo.com/gstreamer/trac/wiki"
+DEPENDS = "gstreamer gst-plugins-base zlib"
+
+inherit autotools pkgconfig
+
+SRC_URI = "http://core.fluendo.com/gstreamer/src/${BPN}/${BPN}-${PV}.tar.bz2"
+
+FILES_${PN} += "${libdir}/gstreamer-0.10/*.so"
+FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug"
+FILES_${PN}-dev += "${libdir}/gstreamer-0.10/*.la ${libdir}/gstreamer-0.10/*.a"
+
+EXTRA_OECONF = "--disable-valgrind"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-meta-base_0.10.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-meta-base_0.10.bb
new file mode 100644
index 0000000..039abe1
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-meta-base_0.10.bb
@@ -0,0 +1,73 @@
+SUMMARY = "GStreamer package groups"
+LICENSE = "MIT"
+
+COMMERCIAL_PLUGINS = "${COMMERCIAL_AUDIO_PLUGINS} ${COMMERCIAL_VIDEO_PLUGINS}"
+DEPENDS_UGLY="${@'gst-plugins-ugly' if 'ugly' in COMMERCIAL_PLUGINS.split('-') else ''}"
+DEPENDS_BAD="${@'gst-plugins-bad' if 'bad' in COMMERCIAL_PLUGINS.split('-') else ''}"
+DEPENDS = "gstreamer gst-plugins-base gst-plugins-good ${DEPENDS_UGLY} ${DEPENDS_BAD}"
+
+LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
+                    file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+
+
+PR = "r13"
+
+PACKAGES = "\
+    gst-meta-base \
+    gst-meta-x11-base \
+    gst-meta-audio \
+    gst-meta-debug \
+    gst-meta-video"
+
+ALLOW_EMPTY_gst-meta-base = "1"
+ALLOW_EMPTY_gst-meta-x11-base = "1"
+ALLOW_EMPTY_gst-meta-audio = "1"
+ALLOW_EMPTY_gst-meta-debug = "1"
+ALLOW_EMPTY_gst-meta-video = "1"
+
+RDEPENDS_gst-meta-base = "\
+    ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'gst-meta-x11-base', '', d)} \
+    gstreamer \
+    gst-plugins-base-playbin \
+    gst-plugins-base-decodebin \
+    gst-plugins-base-decodebin2 \
+    gst-plugins-base-gio \
+    gst-plugins-base-alsa \
+    gst-plugins-base-volume \
+    gst-plugins-base-audioconvert \
+    gst-plugins-base-audioresample \
+    gst-plugins-base-typefindfunctions \
+    gst-plugins-base-videoscale \
+    gst-plugins-base-ffmpegcolorspace \
+    gst-plugins-good-autodetect \
+    gst-plugins-good-souphttpsrc"
+
+RRECOMMENDS_gst-meta-x11-base = "\
+    gst-plugins-base-ximagesink \
+    gst-plugins-base-xvimagesink"
+
+RDEPENDS_gst-meta-audio = "\
+    gst-meta-base \
+    gst-plugins-base-vorbis \
+    gst-plugins-base-ogg \
+    gst-plugins-good-wavparse \
+    gst-plugins-good-flac \
+    ${COMMERCIAL_AUDIO_PLUGINS}"
+
+
+RDEPENDS_gst-meta-debug = "\
+    gst-meta-base \
+    gst-plugins-good-debug \
+    gst-plugins-base-audiotestsrc \
+    gst-plugins-base-videotestsrc"
+
+
+RDEPENDS_gst-meta-video = "\
+    gst-meta-base \
+    gst-plugins-good-avi \
+    gst-plugins-good-matroska \
+    gst-plugins-base-theora \
+    ${COMMERCIAL_VIDEO_PLUGINS}"
+
+RRECOMMENDS_gst-meta-video = "\
+    gst-meta-audio"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/gcc_4.6.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/gcc_4.6.patch
new file mode 100644
index 0000000..57a63b5
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/gcc_4.6.patch
@@ -0,0 +1,18 @@
+Upstream-Status: Pending
+
+Signed-off-by: Saul Wold <sgw@linux.intel.com>
+
+Index: gst-openmax-0.10.1/omx/gstomx.c
+===================================================================
+--- gst-openmax-0.10.1.orig/omx/gstomx.c	2010-09-30 18:00:24.000000000 -0700
++++ gst-openmax-0.10.1/omx/gstomx.c	2011-05-17 23:08:08.794535872 -0700
+@@ -238,7 +238,8 @@
+     const gchar *element_name = gst_structure_nth_field_name (element_table, i);
+     GstStructure *element = get_element_entry (element_name);
+     const gchar *type_name, *parent_type_name;
+-    const gchar *component_name, *component_role, *library_name;
++    const gchar *component_name, *library_name;
++    const gchar __attribute__((__unused__)) *component_role;
+     GType type;
+     gint rank;
+ 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/ptr-array.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/ptr-array.patch
new file mode 100644
index 0000000..5965bba
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/ptr-array.patch
@@ -0,0 +1,46 @@
+Rename static functions that use GLib naming conventions as one of them
+(g_ptr_array_insert) has now been added to GLib.
+
+Upstream-Status: Pending
+Signed-off-by: Ross Burton <ross.burton@intel.com>
+
+diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
+index 423e441..579dbf5 100644
+--- a/omx/gstomx_util.c
++++ b/omx/gstomx_util.c
+@@ -85,7 +85,7 @@ static gboolean initialized;
+  */
+ 
+ static void
+-g_ptr_array_clear (GPtrArray * array)
++omx_g_ptr_array_clear (GPtrArray * array)
+ {
+   guint index;
+   for (index = 0; index < array->len; index++)
+@@ -93,7 +93,7 @@ g_ptr_array_clear (GPtrArray * array)
+ }
+ 
+ static void
+-g_ptr_array_insert (GPtrArray * array, guint index, gpointer data)
++omx_g_ptr_array_insert (GPtrArray * array, guint index, gpointer data)
+ {
+   if (index + 1 > array->len) {
+     g_ptr_array_set_size (array, index + 1);
+@@ -394,7 +394,7 @@ g_omx_core_unload (GOmxCore * core)
+   }
+ 
+   core_for_each_port (core, g_omx_port_free);
+-  g_ptr_array_clear (core->ports);
++  omx_g_ptr_array_clear (core->ports);
+ }
+ 
+ static inline GOmxPort *
+@@ -418,7 +418,7 @@ g_omx_core_new_port (GOmxCore * core, guint index)
+   }
+ 
+   port = g_omx_port_new (core, index);
+-  g_ptr_array_insert (core->ports, index, port);
++  omx_g_ptr_array_insert (core->ports, index, port);
+ 
+   return port;
+ }
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax_0.10.1.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax_0.10.1.bb
new file mode 100644
index 0000000..2e01579
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax_0.10.1.bb
@@ -0,0 +1,35 @@
+SUMMARY = "GStreamer plug-in for communication with OpenMAX IL components"
+DESCRIPTION = "GstOpenMAX is a GStreamer plug-in that allows \
+communication with OpenMAX Integration Layer (IL) components. OpenMAX \
+IL is an industry standard that provides an abstraction layer for \
+computer graphics, video, and sound routines."
+HOMEPAGE = "http://freedesktop.org/wiki/GstOpenMAX"
+DEPENDS = "gstreamer"
+RDEPENDS_${PN} = "libomxil"
+LICENSE = "LGPLv2.1"
+LICENSE_FLAGS = "commercial"
+LIC_FILES_CHKSUM = "file://COPYING;md5=fbc093901857fcd118f065f900982c24 \
+                    file://util/sem.h;beginline=1;endline=20;md5=accce5550d5583b839b441a0623f09fc"
+
+SRC_URI = "http://gstreamer.freedesktop.org/src/gst-openmax/gst-openmax-${PV}.tar.bz2 \
+           file://gcc_4.6.patch \
+           file://ptr-array.patch \
+           "
+
+inherit autotools pkgconfig
+
+# Tell configure that this isn't a development snapshot so we don't want
+# -Werror (hopefully fixed in 0.10.2)
+export GST_CVS="no"
+
+EXTRA_OECONF += "--disable-valgrind"
+
+PR = "r4"
+
+FILES_${PN} += "${libdir}/gstreamer-0.10/libgstomx.so"
+FILES_${PN}-dev += "${libdir}/gstreamer-0.10/libgstomx.la"
+FILES_${PN}-staticdev += "${libdir}/gstreamer-0.10/libgstomx.a"
+FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug/"
+
+SRC_URI[md5sum] = "4d0370bfe99dea20918c84347abadb4e"
+SRC_URI[sha256sum] = "9074d5a0591995133d19cfb15144f19664f902c1623f996595695cf2c2070e1f"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-bad_0.10.23.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-bad_0.10.23.bb
new file mode 100644
index 0000000..0f64871
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-bad_0.10.23.bb
@@ -0,0 +1,50 @@
+require gst-plugins.inc
+
+LICENSE = "GPLv2+ & LGPLv2+ & LGPLv2.1+ "
+LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
+                    file://gst/tta/filters.h;beginline=12;endline=29;md5=629b0c7a665d155a6677778f4460ec06 \
+                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
+                    file://gst/tta/crc32.h;beginline=12;endline=29;md5=71a904d99ce7ae0c1cf129891b98145c"
+
+DEPENDS += "gst-plugins-base"
+
+PR = "r4"
+
+inherit gettext gsettings
+
+EXTRA_OECONF += "--disable-experimental \
+                 --disable-sdl --disable-cdaudio --disable-directfb \
+                 --disable-vdpau --disable-apexsink"
+
+PACKAGECONFIG ??= "bzip curl \
+                   ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'rsvg', '', d)}"
+
+PACKAGECONFIG[bzip] = "--enable-bz2,--disable-bz2,bzip2"
+PACKAGECONFIG[curl] = "--enable-curl,--disable-curl,curl"
+PACKAGECONFIG[rsvg] = "--enable-rsvg,--disable-rsvg,librsvg,"
+PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
+PACKAGECONFIG[neon] = "--enable-neon,--disable-neon,neon"
+PACKAGECONFIG[mms] = "--enable-libmms,--disable-libmms,libmms"
+PACKAGECONFIG[cog] = "--enable-cog,--disable-cog,libpng"
+PACKAGECONFIG[faad] = "--enable-faad,--disable-faad,faad2"
+PACKAGECONFIG[jp2k] = "--enable-jp2k,--disable-jp2k,jasper"
+PACKAGECONFIG[modplug] = "--enable-modplug,--disable-modplug,libmodplug"
+PACKAGECONFIG[opus] = "--enable-opus,--disable-opus,libopus"
+PACKAGECONFIG[sndfile] = "--enable-sndfile,--disable-sndfile,libsndfile1"
+PACKAGECONFIG[vp8] = "--enable-vp8,--disable-vp8,libvpx"
+PACKAGECONFIG[ass] = "--enable-assrender,--disable-assrender,libass"
+PACKAGECONFIG[openal] = "--enable-openal,--disable-openal,openal-soft"
+PACKAGECONFIG[schro] = "--enable-schro,--disable-schro,schroedinger"
+PACKAGECONFIG[dc1394] = "--enable-dc1394,--disable-dc1394,libdc1394"
+PACKAGECONFIG[faac] = "--enable-faac,--disable-faac,faac"
+PACKAGECONFIG[rtmp] = "--enable-rtmp,--disable-rtmp,rtmpdump"
+
+ARM_INSTRUCTION_SET = "arm"
+
+do_configure_prepend() {
+	# This m4 file contains nastiness which conflicts with libtool 2.2.2
+	rm ${S}/m4/lib-link.m4 || true
+}
+
+SRC_URI[md5sum] = "fcb09798114461955260e4d940db5987"
+SRC_URI[sha256sum] = "0eae7d1a1357ae8377fded6a1b42e663887beabe0e6cc336e2ef9ada42e11491"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
new file mode 100644
index 0000000..5214256
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
@@ -0,0 +1,37 @@
+audioresample: Fix build on x86 if emmintrin.h is available but can't be used
+
+On x86, EMMINTRIN is defined but not usable without SSE so check for
+__SSE__ and __SSE2__ as well.
+
+https://bugzilla.gnome.org/show_bug.cgi?id=670690
+
+Upstream-Status: Backport
+
+Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
+---
+ gst/audioresample/resample.c |    4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/gst/audioresample/resample.c b/gst/audioresample/resample.c
+index 98d006c..481fa01 100644
+--- a/gst/audioresample/resample.c
++++ b/gst/audioresample/resample.c
+@@ -77,13 +77,13 @@
+ #define EXPORT G_GNUC_INTERNAL
+ 
+ #ifdef _USE_SSE
+-#ifndef HAVE_XMMINTRIN_H
++#if !defined(__SSE__) || !defined(HAVE_XMMINTRIN_H)
+ #undef _USE_SSE
+ #endif
+ #endif
+ 
+ #ifdef _USE_SSE2
+-#ifndef HAVE_EMMINTRIN_H
++#if !defined(__SSE2__) || !defined(HAVE_EMMINTRIN_H)
+ #undef _USE_SSE2
+ #endif
+ #endif
+-- 
+1.7.1
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
new file mode 100644
index 0000000..b8602c8
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
@@ -0,0 +1,27 @@
+Upstream-Status: Submitted [similar patch by other author, bugzilla]
+Bugtracker-URL: https://bugzilla.gnome.org/show_bug.cgi?id=663600
+
+Prepend PKG_CONFIG_SYSROOT to includedir, so configure doesn't
+search for gstconfig.h in /usr/include.
+
+Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
+---
+ configure.ac |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 1901bcf..460fb0a 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -435,7 +435,7 @@ AG_GST_CHECK_PLUGIN(volume)
+ dnl check for gstreamer core features (subsystems)
+ dnl FIXME: this assumes srcdir == builddir for uninstalled setups
+ GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-0.10`"/gst/gstconfig.h"
+-AG_GST_PARSE_SUBSYSTEM_DISABLES($GST_CONFIGPATH)
++AG_GST_PARSE_SUBSYSTEM_DISABLES($PKG_CONFIG_SYSROOT_DIR$GST_CONFIGPATH)
+ AM_CONDITIONAL(USE_XML, test $GST_DISABLE_XML != "1")
+ 
+ dnl disable plug-ins that require libxml2's HTML support if it is not available
+-- 
+1.7.5.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
new file mode 100644
index 0000000..99dbc9d
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
@@ -0,0 +1,20 @@
+Remove -DTREMOR option since Tremor has dropped its internal
+libogg2, and gst-plugins-base has dependency on that.
+
+Upstream-Status: Inappropriate [configuration]
+
+Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
+Signed-off-by: Shane Wang <shane.wang@intel.com>
+
+diff -r 70065fb4e085 ext/vorbis/Makefile.am
+--- a/ext/vorbis/Makefile.am	Tue Mar 13 16:36:56 2012 +0800
++++ b/ext/vorbis/Makefile.am	Tue Mar 13 16:38:53 2012 +0800
+@@ -30,7 +30,7 @@
+ 	gstvorbisdec.c gstvorbisdeclib.c gstvorbiscommon.c
+ libgstivorbisdec_la_CFLAGS = \
+ 	$(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \
+-	-DTREMOR $(IVORBIS_CFLAGS)
++	$(IVORBIS_CFLAGS)
+ libgstivorbisdec_la_LIBADD = \
+ 	$(top_builddir)/gst-libs/gst/tag/libgsttag-@GST_MAJORMINOR@.la \
+ 	$(top_builddir)/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la \
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base_0.10.36.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base_0.10.36.bb
new file mode 100644
index 0000000..c8a9499
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base_0.10.36.bb
@@ -0,0 +1,39 @@
+require gst-plugins.inc
+
+LICENSE = "GPLv2+ & LGPLv2+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
+                    file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=622921ffad8cb18ab906c56052788a3f \
+                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
+                    file://gst/ffmpegcolorspace/utils.c;beginline=1;endline=20;md5=9c83a200b8e597b26ca29df20fc6ecd0"
+
+DEPENDS += "alsa-lib liboil libogg libvorbis libtheora util-linux tremor glib-2.0-native"
+
+SRC_URI += "file://gst-plugins-base-tremor.patch \
+            file://configure.ac-fix-subparse-plugin.patch \
+            file://audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch \
+"
+
+SRC_URI[md5sum] = "776c73883e567f67b9c4a2847d8d041a"
+SRC_URI[sha256sum] = "2cd3b0fa8e9b595db8f514ef7c2bdbcd639a0d63d154c00f8c9b609321f49976"
+
+PR = "r8"
+
+inherit gettext
+
+EXTRA_OECONF += "--disable-freetypetest"
+
+PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}"
+
+PACKAGECONFIG[gnomevfs] = "--enable-gnome_vfs,--disable-gnome_vfs,gnome-vfs"
+PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
+PACKAGECONFIG[pango] = "--enable-pango,--disable-pango,pango"
+PACKAGECONFIG[x11] = "--enable-x --enable-xvideo,--disable-x --disable-xvideo,virtual/libx11 libxv libsm libice"
+
+do_configure_prepend() {
+	# This m4 file contains nastiness which conflicts with libtool 2.2.2
+	rm -f ${S}/m4/lib-link.m4
+}
+
+FILES_${PN} += "${datadir}/${BPN}"
+
+CACHED_CONFIGUREVARS_append_i586 = " ac_cv_header_emmintrin_h=no ac_cv_header_xmmintrin_h=no"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
new file mode 100644
index 0000000..bc2f88b
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
@@ -0,0 +1,35 @@
+From 14d51cbefef19737e7ab2b6818ee1d3bdb248d12 Mon Sep 17 00:00:00 2001
+From: Jeremy Stashluk <jstashluk@dekaresearch.com>
+Date: Wed, 6 Feb 2013 09:59:48 -0500
+Subject: [PATCH] conditional gl framebuffer undefined use
+
+The OpenGL extension GL_ARB_framebuffer_object defines the macro
+GL_FRAMEBUFFER_UNDEFINED. The macro will only need to map to an error
+string if the extension provides functions that might return the macro.
+
+Upstream-Status: Pending
+
+Signed-off-by: Jeremy Stashluk <jstashluk@dekaresearch.com>
+---
+ gst-libs/gst/gl/gstgldisplay.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c
+index 3ed0b71..64c6c2c 100644
+--- a/gst-libs/gst/gl/gstgldisplay.c
++++ b/gst-libs/gst/gl/gstgldisplay.c
+@@ -2177,9 +2177,11 @@ gst_gl_display_check_framebuffer_status (void)
+       GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
+       break;
+ 
++#if defined(GL_ARB_framebuffer_object)
+     case GL_FRAMEBUFFER_UNDEFINED:
+       GST_ERROR ("GL_FRAMEBUFFER_UNDEFINED");
+       break;
++#endif
+ 
+     default:
+       GST_ERROR ("General FBO error");
+-- 
+1.7.9.5
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl_0.10.3.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl_0.10.3.bb
new file mode 100644
index 0000000..90efbcc
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl_0.10.3.bb
@@ -0,0 +1,25 @@
+require recipes-multimedia/gstreamer/gst-plugins.inc
+
+LICENSE = "GPLv2+ & LGPLv2+ & LGPLv2.1+ "
+LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605"
+
+SRC_URI[md5sum] = "ac70ede13f79978d56eaed8abaa3c938"
+SRC_URI[sha256sum] = "48340b6a4b8abce16344a7bc33e74a94fdcce4f57ef6342cdf2f941c429bf210"
+
+SRC_URI += " file://0001-conditional-gl-framebuffer-undefined-use.patch"
+
+DEPENDS += "gst-plugins-base virtual/libgles2 virtual/egl jpeg libpng glew"
+
+PR = "r4"
+
+inherit gettext
+
+# This package doesn't have a configure switch for EGL or GL, so forcibly tell
+# configure that it can't find gl.h so it always uses EGL.  If/when we have some
+# way for machines to specify their preferred GL flavour this can be
+# automatically adapted.
+EXTRA_OECONF += "ac_cv_header_GL_gl_h=no"
+
+ALLOW_EMPTY_${PN} = "1"
+ALLOW_EMPTY_${PN}-apps = "1"
+ALLOW_EMPTY_${PN}-glib = "1"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
new file mode 100644
index 0000000..6456d3c
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
@@ -0,0 +1,33 @@
+From 12d18fe4e98e7c232d59b56d529a0521f293fe6d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com>
+Date: Wed, 5 Sep 2012 18:54:42 +0200
+Subject: [PATCH] v4l2: fix build with recent kernels, the v4l2_buffer input
+ field was removed
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Upstream-Status: Backport
+
+[1] http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=9f2aa8d47f835ea155aaf635f618c0fc1ca87012
+
+Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
+---
+ sys/v4l2/gstv4l2bufferpool.c |    1 -
+ 1 files changed, 0 insertions(+), 1 deletions(-)
+
+diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c
+index b81c6a4..51cc0ce 100644
+--- a/sys/v4l2/gstv4l2bufferpool.c
++++ b/sys/v4l2/gstv4l2bufferpool.c
+@@ -181,7 +181,6 @@ gst_v4l2_buffer_new (GstV4l2BufferPool * pool, guint index, GstCaps * caps)
+     GST_LOG_OBJECT (pool->v4l2elem, "  MMAP offset:  %u",
+         ret->vbuffer.m.offset);
+   GST_LOG_OBJECT (pool->v4l2elem, "  length:    %u", ret->vbuffer.length);
+-  GST_LOG_OBJECT (pool->v4l2elem, "  input:     %u", ret->vbuffer.input);
+ 
+   data = (guint8 *) v4l2_mmap (0, ret->vbuffer.length,
+       PROT_READ | PROT_WRITE, MAP_SHARED, pool->video_fd,
+-- 
+1.7.6.5
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
new file mode 100644
index 0000000..bd0de58
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
@@ -0,0 +1,45 @@
+From ccb01de8096a32d86d47b0d92ec3416c57ee4d25 Mon Sep 17 00:00:00 2001
+From: Bruce Ashfield <bruce.ashfield@windriver.com>
+Date: Thu, 22 Aug 2013 12:15:54 -0400
+Subject: [PATCH] v4l2_calls: define V4L2_CID_HCENTER and V4L2_CID_VCENTER
+
+kernel commit 24b9f5017 [[media] V4L: Remove deprecated image centering controls]
+removed the definitions of V4L2_CID_HCENTER and V4L2_CID_VCENTER after three
+years of depreciation.
+
+The ioctl values are still free, and the case statement which processess them
+in v4l2 userspace falls through to the proper replacement. So in the short
+term, we can explicitly define them using the old absolute values, and everything
+will work.
+
+Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
+---
+ sys/v4l2/v4l2_calls.c |    9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c
+index 309bfb6..3c64544 100644
+--- a/sys/v4l2/v4l2_calls.c
++++ b/sys/v4l2/v4l2_calls.c
+@@ -54,11 +54,16 @@
+ #include "gst/gst-i18n-plugin.h"
+ 
+ /* Those are ioctl calls */
++
++/* V4L2_CID_HCENTER has been removed from the mainline kernel, but
++   the ioctl space is still present. Since these values fall through
++   to their replacement, it is safe (in the short term) to re-use the
++    old values explictily */
+ #ifndef V4L2_CID_HCENTER
+-#define V4L2_CID_HCENTER V4L2_CID_HCENTER_DEPRECATED
++#define V4L2_CID_HCENTER V4L2_CID_BASE+22
+ #endif
+ #ifndef V4L2_CID_VCENTER
+-#define V4L2_CID_VCENTER V4L2_CID_VCENTER_DEPRECATED
++#define V4L2_CID_VCENTER V4L2_CID_BASE+23
+ #endif
+ 
+ GST_DEBUG_CATEGORY_EXTERN (v4l2_debug);
+-- 
+1.7.10.4
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
new file mode 100644
index 0000000..48b8e98
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
@@ -0,0 +1,47 @@
+From ce94b2c2b91b6db190c121860e12a6afafce7ae1 Mon Sep 17 00:00:00 2001
+From: Roland Krikava <rkrikava@gmail.com>
+Date: Fri, 2 Nov 2012 12:38:44 -0400
+Subject: [PATCH 407/440] mulawdec: fix integer overrun
+
+There might be more than 65535 samples in a chunk of data.
+
+https://bugzilla.gnome.org/show_bug.cgi?id=687469
+
+Commit - 3be45f70220310ec1c60d819f90b5f2ae03b5d83 in 0.10 branch
+
+Upstream Status:  Backported
+
+Signed-off-by: Roland Krikava <rkrikava@gmail.com>
+---
+ gst/law/mulaw-conversion.c |    6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/gst/law/mulaw-conversion.c b/gst/law/mulaw-conversion.c
+index 8afae80..190a9f5 100644
+--- a/gst/law/mulaw-conversion.c
++++ b/gst/law/mulaw-conversion.c
+@@ -51,9 +51,10 @@ mulaw_encode (gint16 * in, guint8 * out, gint numsamples)
+     7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+     7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
+   };
+-  gint16 sign, exponent, mantissa, i;
++  gint16 sign, exponent, mantissa;
+   gint16 sample;
+   guint8 ulawbyte;
++  gint i;
+ 
+   for (i = 0; i < numsamples; i++) {
+     sample = in[i];
+@@ -102,7 +103,8 @@ mulaw_decode (guint8 * in, gint16 * out, gint numsamples)
+   static gint16 exp_lut[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 };
+   gint16 sign, exponent, mantissa;
+   guint8 ulawbyte;
+-  gint16 linear, i;
++  gint16 linear;
++  gint i;
+ 
+   for (i = 0; i < numsamples; i++) {
+     ulawbyte = in[i];
+-- 
+1.7.9.5
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good_0.10.31.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good_0.10.31.bb
new file mode 100644
index 0000000..af18281
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good_0.10.31.bb
@@ -0,0 +1,47 @@
+require gst-plugins.inc
+
+LICENSE = "GPLv2+ & LGPLv2.1+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
+                    file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=622921ffad8cb18ab906c56052788a3f \
+                    file://gst/replaygain/rganalysis.c;beginline=1;endline=23;md5=b60ebefd5b2f5a8e0cab6bfee391a5fe"
+
+PR = "r8"
+
+PACKAGECONFIG ?= "jpeg v4l \
+    ${@bb.utils.contains('DISTRO_FEATURES', 'pulseaudio', 'pulseaudio', '', d)} \
+    ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)} \
+"
+PACKAGECONFIG[pulseaudio] = "--enable-pulse,--disable-pulse,pulseaudio"
+PACKAGECONFIG[jack] = "--enable-jack,--disable-jack,jack"
+PACKAGECONFIG[jpeg] = "--enable-jpeg,--disable-jpeg,jpeg"
+PACKAGECONFIG[wavpack] = "--enable-wavpack,--disable-wavpack,wavpack"
+PACKAGECONFIG[gdkpixbuf] = "--enable-gdk_pixbuf,--disable-gdk_pixbuf,gdk-pixbuf"
+PACKAGECONFIG[v4l] = "--enable-gst_v4l2 --with-gudev,--disable-gst_v4l2 --without-gudev,udev"
+# sub-feature of v4l, but control separately since libv4l is not part of oe-core
+PACKAGECONFIG[libv4l] = "--with-libv4l2,--without-libv4l2,libv4l"
+PACKAGECONFIG[bzip2] = "--enable-bz2,--disable-bz2,bzip2"
+PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
+PACKAGECONFIG[x11] = "--enable-x,--disable-x,virtual/libx11 libxfixes libxdamage"
+
+DEPENDS += "gst-plugins-base gconf cairo libpng zlib libid3tag flac \
+            speex libsoup-2.4 libcap"
+
+inherit gettext gconf
+
+SRC_URI += "file://0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch \
+            file://0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch \
+            file://0407-mulawdec-fix-integer-overrun.patch \
+"
+EXTRA_OECONF += "--disable-aalib --disable-esd --disable-shout2 --disable-libcaca --disable-hal \
+                 --disable-examples --disable-taglib"
+
+do_configure_prepend() {
+	# This m4 file contains nastiness which conflicts with libtool 2.2.2
+	rm ${S}/m4/lib-link.m4 || true
+}
+
+SRC_URI[md5sum] = "24f98a294a2b521e1b29412bdadae2e6"
+SRC_URI[sha256sum] = "7e27840e40a7932ef2dc032d7201f9f41afcaf0b437daf5d1d44dc96d9e35ac6"
+
+FILES_${PN}-gconfelements += "${sysconfdir}/gconf/schemas/gstreamer-0.10.schemas"
+FILES_${PN}-equalizer += "${datadir}/gstreamer-0.10/presets/*.prs"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-ugly_0.10.19.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-ugly_0.10.19.bb
new file mode 100644
index 0000000..2fdf03f
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-ugly_0.10.19.bb
@@ -0,0 +1,29 @@
+require gst-plugins.inc
+
+LICENSE = "GPLv2+ & LGPLv2.1+ & LGPLv2+"
+LICENSE_FLAGS = "commercial"
+LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
+                    file://gst/synaesthesia/synaescope.h;beginline=1;endline=20;md5=99f301df7b80490c6ff8305fcc712838 \
+                    file://tests/check/elements/xingmux.c;beginline=1;endline=21;md5=4c771b8af188724855cb99cadd390068 \
+                    file://gst/mpegstream/gstmpegparse.h;beginline=1;endline=18;md5=ff65467b0c53cdfa98d0684c1bc240a9"
+
+DEPENDS += "gst-plugins-base libid3tag libmad mpeg2dec liba52 lame"
+PR = "r3"
+
+inherit gettext
+
+EXTRA_OECONF += "--with-plugins=a52dec,lame,id3tag,mad,mpeg2dec,mpegstream,mpegaudioparse,asfdemux,realmedia \
+                 --disable-orc"
+
+PACKAGECONFIG ??= ""
+PACKAGECONFIG[x264] = "--enable-x264,--disable-x264,x264"
+PACKAGECONFIG[cdio] = "--enable-cdio,--disable-cdio,libcdio"
+PACKAGECONFIG[dvdread] = "--enable-dvdread,--disable-dvdread,libdvdread"
+
+do_configure_prepend() {
+	# This m4 file contains nastiness which conflicts with libtool 2.2.2
+	rm ${S}/m4/lib-link.m4 || true
+}
+
+SRC_URI[md5sum] = "1d81c593e22a6cdf0f2b4f57eae93df2"
+SRC_URI[sha256sum] = "1ca90059275c0f5dca71d4d1601a8f429b7852baed0723e820703b977e2c8df0"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins.inc b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins.inc
new file mode 100644
index 0000000..c852c53
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins.inc
@@ -0,0 +1,28 @@
+SUMMARY = "Plugins for the GStreamer multimedia framework"
+HOMEPAGE = "http://gstreamer.freedesktop.org/"
+BUGTRACKER = "https://bugzilla.gnome.org/enter_bug.cgi?product=Gstreamer"
+SECTION = "multimedia"
+DEPENDS = "gstreamer"
+
+inherit autotools pkgconfig
+
+SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2"
+
+GSTREAMER_DEBUG ?= "--disable-debug"
+EXTRA_OECONF = "--disable-valgrind ${GSTREAMER_DEBUG} --disable-examples "
+
+acpaths = "-I ${S}/common/m4 -I ${S}/m4"
+
+LIBV = "0.10"
+require gst-plugins-package.inc
+
+PACKAGES_DYNAMIC += "^${PN}-.*"
+
+# apply gstreamer hack after Makefile.in.in in source is replaced by our version from
+# ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in, but before configure is executed
+# http://lists.linuxtogo.org/pipermail/openembedded-core/2012-November/032233.html
+oe_runconf_prepend() {
+	if [ -e ${S}/po/Makefile.in.in ]; then
+		sed -i -e "1a\\" -e 'GETTEXT_PACKAGE = @GETTEXT_PACKAGE@' ${S}/po/Makefile.in.in
+	fi
+}
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
new file mode 100644
index 0000000..3afca4e
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
@@ -0,0 +1,34 @@
+index gst-rtsp_0.10.8/bindings/python/Makefile.am
+--- gst-rtsp_0.10.8.orig/bindings/python/Makefile.am
++++ gst-rtsp_0.10.8/bindings/python/Makefile.am
+@@ -14,7 +14,7 @@ defs_DATA = $(DEFS)
+ defsdir = $(pkgdatadir)/$(GST_MAJORMINOR)/defs
+ OVERRIDES = rtspserver.override
+
+-INCLUDES = -I$(top_srcdir) -I$(srcdir) $(PYTHON_INCLUDES)
++AM_CPPFLAGS = -I$(top_srcdir) -I$(srcdir) $(PYTHON_INCLUDES)
+
+ rtspserver_la_CFLAGS = -I$(top_srcdir)/src \
+         $(PYGOBJECT_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
+index gst-rtsp_0.10.8/examples/Makefile.am
+--- gst-rtsp_0.10.8.orig/examples/Makefile.am
++++ gst-rtsp_0.10.8/examples/Makefile.am
+@@ -1,6 +1,6 @@
+ noinst_PROGRAMS = test-video test-ogg test-mp4 test-readme test-launch test-sdp test-uri test-auth
+
+-INCLUDES = -I$(top_srcdir) -I$(srcdir)
++AM_CPPFLAGS = -I$(top_srcdir) -I$(srcdir)
+
+ AM_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
+ AM_LDFLAGS = \
+index gst-rtsp_0.10.8/tests/Makefile.am
+--- gst-rtsp_0.10.8.orig/tests/Makefile.am
++++ gst-rtsp_0.10.8/tests/Makefile.am
+@@ -1,6 +1,6 @@
+ noinst_PROGRAMS = test-cleanup
+
+-INCLUDES = -I$(top_srcdir) -I$(srcdir)
++AM_CPPFLAGS = -I$(top_srcdir) -I$(srcdir)
+
+ AM_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
+ AM_LDFLAGS = \
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp_0.10.8.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp_0.10.8.bb
new file mode 100644
index 0000000..9318656
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp_0.10.8.bb
@@ -0,0 +1,16 @@
+SUMMARY = "GStreamer RTSP server"
+LICENSE = "LGPLv2+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605"
+
+SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2 \
+           file://0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch"
+SRC_URI[md5sum] = "b511af07000595f63c3a705946221643"
+SRC_URI[sha256sum] = "9915887cf8515bda87462c69738646afb715b597613edc7340477ccab63a6617"
+
+DEPENDS = "gst-plugins-base gstreamer"
+
+# Configure always checks for Python so inherit pythonnative. Better solution
+# would be to disable the checks entirely.
+inherit autotools pythonnative gettext
+
+FILES_${PN}-dev += "${datadir}/vala/vapi/"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
new file mode 100644
index 0000000..d077496
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
@@ -0,0 +1,32 @@
+From ed7f4802222234eef192aa3f74bc92268f338f97 Mon Sep 17 00:00:00 2001
+From: Sebastian Droege <sebastian.droege@collabora.co.uk>
+Date: Tue, 6 Mar 2012 12:28:02 +0100
+Subject: [PATCH] baseparse: Fix 'self-comparison always evaluates to true'
+
+This was really a bug.
+
+Commit is ed7f4802222234eef192aa3f74bc92268f338f97 in 0.10 branch
+
+Upstream Status:  Backported
+
+Signed-off-by: Sebastian Droege <sebastian.droege@collabora.co.uk>
+---
+ libs/gst/base/gstbaseparse.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c
+index 851ec1d..108ee89 100644
+--- a/libs/gst/base/gstbaseparse.c
++++ b/libs/gst/base/gstbaseparse.c
+@@ -3899,7 +3899,7 @@ gst_base_parse_handle_seek (GstBaseParse * parse, GstEvent * event)
+        seek event (in bytes) to upstream. Segment / flush handling happens
+        in corresponding src event handlers */
+     GST_DEBUG_OBJECT (parse, "seek in PUSH mode");
+-    if (seekstop >= 0 && seekpos <= seekpos)
++    if (seekstop >= 0 && seekstop <= seekpos)
+       seekstop = seekpos;
+     new_event = gst_event_new_seek (rate, GST_FORMAT_BYTES, flags,
+         GST_SEEK_TYPE_SET, seekpos, stop_type, seekstop);
+-- 
+1.7.9.5
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/check_fix.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/check_fix.patch
new file mode 100644
index 0000000..5d8bb13
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/check_fix.patch
@@ -0,0 +1,19 @@
+# gstreamer: Fix a problem with configure if check has already been built
+# Richard Purdie <rpurdie@linux.intel.com>
+
+Upstream-Status: Inappropriate [configuration]
+
+diff -urN gstreamer-0.10.29-orig/configure.ac gstreamer-0.10.29/configure.ac
+--- gstreamer-0.10.29-orig/configure.ac	2010-06-26 12:49:27.774930773 +0800
++++ gstreamer-0.10.29/configure.ac	2010-06-26 12:51:12.899200233 +0800
+@@ -543,8 +543,10 @@
+       *) BUILD_CHECK=yes ;;
+     esac
+ ])
++
+ dnl bit of a misnomer, but keep the conditional named like this so we don't
+ dnl have to change too much elsewhere
++HAVE_CHECK=no
+ AM_CONDITIONAL(HAVE_CHECK, test "x$BUILD_CHECK" = "xyes")
+ 
+ dnl configure the desired buffer alignment
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gst-inspect-check-error.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gst-inspect-check-error.patch
new file mode 100644
index 0000000..30be85f
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gst-inspect-check-error.patch
@@ -0,0 +1,16 @@
+# Fix crash with gst-inspect
+# Chris Lord <chris@openedhand.com>
+
+Upstream-Status: Pending
+
+--- gstreamer-0.10.9/tools/gst-inspect.c.old	2006-09-12 11:56:53.000000000 +0100
++++ gstreamer-0.10.9/tools/gst-inspect.c	2006-09-12 11:57:27.000000000 +0100
+@@ -1123,7 +1123,7 @@
+   g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
+   g_option_context_add_group (ctx, gst_init_get_option_group ());
+   if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
+-    g_print ("Error initializing: %s\n", err->message);
++    g_print ("Error initializing: %s\n", err ? err->message : "(null)");
+     exit (1);
+   }
+   g_option_context_free (ctx);
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
new file mode 100644
index 0000000..bf93cb2
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
@@ -0,0 +1,33 @@
+gstreamer: change priv_gst_parse_yylex arguments
+
+Change priv_gst_parse_yylex to fit new bison version, else we will
+get following error:
+
+| grammar.tab.c: In function 'priv_gst_parse_yyparse':
+| grammar.tab.c:67:25: error: too few arguments to function 'priv_gst_parse_yylex'
+|  #define yylex           priv_gst_parse_yylex
+|                          ^
+
+Upstream-Status: Pending
+
+Signed-off-by: Chong Lu <Chong.Lu@windriver.com>
+---
+ gst/parse/grammar.y | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/gst/parse/grammar.y b/gst/parse/grammar.y
+index 24fc87b..24fe906 100644
+--- a/gst/parse/grammar.y
++++ b/gst/parse/grammar.y
+@@ -36,7 +36,7 @@
+ 
+ typedef void* yyscan_t;
+ 
+-int priv_gst_parse_yylex (void * yylval_param , yyscan_t yyscanner);
++int priv_gst_parse_yylex (yyscan_t yyscanner);
+ int priv_gst_parse_yylex_init (yyscan_t scanner);
+ int priv_gst_parse_yylex_destroy (yyscan_t scanner);
+ struct yy_buffer_state * priv_gst_parse_yy_scan_string (char* , yyscan_t);
+-- 
+1.9.1
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.c b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.c
new file mode 100644
index 0000000..c1f3e71
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.c
@@ -0,0 +1,487 @@
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ *                    2000 Wim Taymans <wtay@chello.be>
+ *                    2005 David A. Schleef <ds@schleef.org>
+ *
+ * gstregistryxml.c: GstRegistry object, support routines
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it ulnder 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.
+ */
+
+
+#include <gst/gstregistrybinary.h>
+
+/*
+** Simple handy function to write a memory location to the registry cache file
+*/
+inline static gboolean
+gst_registry_binary_write(GstRegistry *registry, const void *mem, const ssize_t size)
+{
+  if (write(registry->cache_file, mem, size) != size)
+    {
+      GST_ERROR("Failed to write binary registry element: ptr=%p size=%u error=%s\n",
+		mem, size, strerror(errno));
+      return FALSE;
+    }
+  return TRUE;
+}
+
+/*
+** Save features GstBinary style
+*/
+static gboolean 
+gst_registry_binary_fill_feature(GList **list, GstPluginFeature *orig, GstBinaryPluginFeature *dest, const char *name)
+{
+  GstBinaryChunck *chk;
+
+  if ((chk = calloc(1, sizeof (GstBinaryChunck))) == NULL)
+    return FALSE;
+
+  chk->data = dest;
+  chk->size = sizeof (GstBinaryPluginFeature);
+
+  *list = g_list_append(*list, chk);
+
+  dest->rank = orig->rank;
+  if (!strncpy(dest->typename, name, GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN) ||
+      !strncpy(dest->name, orig->name, GST_BINARY_REGISTRY_TYPENAME_NAME_LEN))
+    {
+      GST_ERROR("Failed to write binary registry feature");
+      goto fail;
+    }
+  
+  if (GST_IS_ELEMENT_FACTORY(orig))
+    {
+      GstElementFactory *factory = GST_ELEMENT_FACTORY(orig);
+      
+      if (!strncpy(dest->longname, factory->details.longname, GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN) ||
+	  !strncpy(dest->class, factory->details.klass, GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN) ||
+	  !strncpy(dest->description, factory->details.description, GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN) ||
+	  !strncpy(dest->author, factory->details.author, GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN))
+	{
+	  GST_ERROR("Failed to write binary registry feature");
+	  goto fail;
+	}
+    }
+  
+  dest->npadtemplates = dest->ninterfaces = dest->nuritypes = 0;
+  return TRUE;
+
+ fail:
+  free(chk);
+  return FALSE;
+}
+
+
+/*
+** Initialize the GstBinaryRegistryMagic, setting both our magic number and gstreamer major/minor version
+*/
+inline static gboolean
+gst_registry_binary_initialize_magic(GstBinaryRegistryMagic *m)
+{
+  if (!strncpy(m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) ||
+      !strncpy(m->version, GST_MAJORMINOR, GST_BINARY_REGISTRY_VERSION_LEN))
+    {
+      GST_ERROR("Failed to write magic to the registry magic structure");
+      return FALSE;
+    }
+  return TRUE;
+}
+
+/*
+** Check GstBinaryRegistryMagic validity.
+** Return a pointer pointing right after the magic structure
+*/
+static gchar *
+gst_registry_binary_check_magic(gchar *in)
+{
+  GstBinaryRegistryMagic *m = (GstBinaryRegistryMagic *) in;
+
+  if (m == NULL || m->magic == NULL || m->version == NULL)
+    {
+      GST_ERROR("Binary registry magic structure is broken");
+      return NULL;
+    }
+  if (strncmp(m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) != 0)
+    {
+      GST_ERROR("Binary registry magic is different : %02x%02x%02x%02x != %02x%02x%02x%02x",
+		GST_MAGIC_BINARY_REGISTRY_STR[0] & 0xff, GST_MAGIC_BINARY_REGISTRY_STR[1] & 0xff,
+		GST_MAGIC_BINARY_REGISTRY_STR[2] & 0xff, GST_MAGIC_BINARY_REGISTRY_STR[3] & 0xff,
+		m->magic[0] & 0xff, m->magic[1] & 0xff, m->magic[2] & 0xff, m->magic[3] & 0xff);
+      return NULL;
+    }
+  if (strncmp(m->version, GST_MAJORMINOR, GST_BINARY_REGISTRY_VERSION_LEN))
+    {
+      GST_ERROR("Binary registry magic version is different : %s != %s",
+		GST_MAJORMINOR, m->version);
+      return NULL;
+    }
+  return (in + sizeof (GstBinaryRegistryMagic));
+}
+
+/*
+** Adapt a GstPlugin to our GstBinaryPluginElement structure, and write it to the 
+** registry file.
+*/   
+static gboolean
+gst_registry_binary_save_plugin(GList **list, GstRegistry *registry, GstPlugin *plugin)
+{
+  GstBinaryPluginElement *e;
+  GstBinaryChunck *chk;
+  GList *walk;
+
+  if ((e = calloc(1, sizeof (GstBinaryPluginElement))) == NULL ||
+      (chk = calloc(1, sizeof (GstBinaryChunck))) == NULL)
+    return FALSE;
+
+  chk->data = e;
+  chk->size = sizeof (GstBinaryPluginElement);
+  *list = g_list_append(*list, chk);
+
+  if (!strncpy(e->name, plugin->desc.name, GST_BINARY_REGISTRY_NAME_LEN)		       	||
+      !strncpy(e->description, plugin->desc.description, GST_BINARY_REGISTRY_DESCRIPTION_LEN)	||
+      !strncpy(e->filename, plugin->filename, _POSIX_PATH_MAX)					||
+      !strncpy(e->version, plugin->desc.version, GST_BINARY_REGISTRY_VERSION_LEN)		||
+      !strncpy(e->license, plugin->desc.license, GST_BINARY_REGISTRY_LICENSE_LEN)		||
+      !strncpy(e->source, plugin->desc.source, GST_BINARY_REGISTRY_SOURCE_LEN)			||
+      !strncpy(e->package, plugin->desc.package, GST_BINARY_REGISTRY_PACKAGE_LEN)		||
+      !strncpy(e->origin, plugin->desc.origin, GST_BINARY_REGISTRY_ORIGIN_LEN))
+    {
+      GST_DEBUG("Can't adapt GstPlugin to GstBinaryPluginElement");
+      goto fail;
+    }
+
+  e->size = plugin->file_size;
+  e->m32p = plugin->file_mtime;
+  
+  GList *ft_list = gst_registry_get_feature_list_by_plugin(registry, plugin->desc.name);
+
+  for (walk = ft_list; walk; walk = g_list_next(walk), e->nfeatures++)
+    {
+      GstPluginFeature *curfeat = GST_PLUGIN_FEATURE (walk->data);
+      GstBinaryPluginFeature *newfeat;
+      const char *feat_name = g_type_name(G_OBJECT_TYPE(curfeat));
+      
+      if ((newfeat = calloc(1, sizeof (GstBinaryPluginFeature))) == NULL)
+	  goto fail;
+
+      if (!feat_name || !gst_registry_binary_fill_feature(list, curfeat, newfeat, feat_name))
+	{
+	  GST_ERROR("Can't fill plugin feature, aborting.");
+	  goto fail;
+	}
+    }
+
+  GST_DEBUG("Found %d features in plugin \"%s\"\n", e->nfeatures, e->name);
+  return TRUE;
+
+ fail:
+  free(chk);
+  free(e);
+  return FALSE;
+}
+
+/*
+** Write the cache to file. Part of the code was taken from gstregistryxml.c
+*/
+gboolean 
+gst_registry_binary_write_cache(GstRegistry *registry, const char *location)
+{
+  GList *walk;
+  char *tmp_location;
+  GstBinaryRegistryMagic *magic;
+  GstBinaryChunck *magic_chunck;
+  GList *to_write = NULL;
+ 
+  GST_INFO("Writing binary registry cache");
+
+  g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
+  tmp_location = g_strconcat (location, ".tmpXXXXXX", NULL);
+  registry->cache_file = g_mkstemp (tmp_location);
+  if (registry->cache_file == -1)
+    {
+      char *dir;
+
+      /* oops, I bet the directory doesn't exist */
+      dir = g_path_get_dirname (location);
+      g_mkdir_with_parents (dir, 0777);
+      g_free (dir);
+      
+      registry->cache_file = g_mkstemp (tmp_location);
+    }
+
+  if (registry->cache_file == -1)
+    goto fail;
+
+  if ((magic = calloc(1, sizeof (GstBinaryRegistryMagic))) == NULL ||
+      !gst_registry_binary_initialize_magic(magic))
+    goto fail;
+
+  if ((magic_chunck = calloc(1, sizeof (GstBinaryChunck))) == NULL)
+    goto fail;
+
+  magic_chunck->data = magic;
+  magic_chunck->size = sizeof (GstBinaryRegistryMagic);
+  to_write = g_list_append(to_write, magic_chunck); 
+
+  /* Iterate trough the list of plugins in the GstRegistry and adapt them to our structures */
+  for (walk = g_list_last(registry->plugins); walk; walk = g_list_previous(walk))
+    {
+      GstPlugin *plugin = GST_PLUGIN(walk->data);
+      
+      if (!plugin->filename)
+	continue;
+	  
+      if (plugin->flags & GST_PLUGIN_FLAG_CACHED)
+	{
+	  int ret;
+	  struct stat statbuf;
+	  
+	  ret = g_stat (plugin->filename, &statbuf);
+	  if ((ret = g_stat (plugin->filename, &statbuf)) < 0 	||
+	      plugin->file_mtime != statbuf.st_mtime		||
+	      plugin->file_size != statbuf.st_size)
+	    continue;
+	}
+
+      if (!gst_registry_binary_save_plugin(&to_write, registry, plugin))
+	{
+	  GST_ERROR("Can't write binary plugin information for \"%s\"", plugin->filename);
+	  continue; /* Try anyway */
+	}
+    }
+
+  for (walk = g_list_first(to_write); walk; walk = g_list_next(walk))
+    {
+      GstBinaryChunck *cur = walk->data;
+
+      if (!gst_registry_binary_write(registry, cur->data, cur->size))
+	{
+	  free(cur->data);
+	  free(cur);
+	  g_list_free(to_write);
+	  goto fail;
+	}
+      free(cur->data);
+      free(cur);
+    }
+  g_list_free(to_write);
+
+  if (close(registry->cache_file) < 0)
+    {
+      GST_DEBUG("Can't close registry file : %s", strerror(errno));
+      goto fail;
+    }
+  
+  if (g_file_test (tmp_location, G_FILE_TEST_EXISTS)) {
+#ifdef WIN32
+    remove (location);
+#endif
+    rename (tmp_location, location);
+  }
+
+  g_free (tmp_location);
+  return TRUE;
+
+ fail:
+  g_free(tmp_location);
+  return FALSE;
+}
+
+static GstPluginFeature*
+gst_registry_binary_load_feature(GstBinaryPluginFeature *in)
+{
+  GstPluginFeature *feature;
+  GType type;
+
+  if (!in->typename || !*(in->typename))
+    return NULL;
+
+  /*  GST_INFO("Plugin feature typename : %s", in->typename);*/
+
+  if (!(type = g_type_from_name(in->typename)))
+    {
+      GST_ERROR("Unknown type from typename");
+      return NULL;
+    }
+  feature = g_object_new (type, NULL);
+
+  if (!feature) {
+    GST_ERROR("Can't create feature from type");
+    return NULL;
+  }
+
+  if (!GST_IS_PLUGIN_FEATURE (feature)) {
+    /* don't really know what it is */
+    if (GST_IS_OBJECT (feature))
+      gst_object_unref (feature);
+    else
+      g_object_unref (feature);
+    return NULL;
+  }
+
+  feature->name = g_strdup(in->name);
+  feature->rank = in->rank;
+
+  if (GST_IS_ELEMENT_FACTORY(feature))
+    {
+      GstElementFactory *factory = GST_ELEMENT_FACTORY(feature);
+
+      factory->details.longname = g_strdup(in->longname);
+      factory->details.klass = g_strdup(in->class);
+      factory->details.description = g_strdup(in->description);
+      factory->details.author = g_strdup(in->author);
+
+      /*      GST_INFO("Element factory : %s", factory->details.longname); */
+    }
+
+  GST_DEBUG("Added feature %p with name %s", feature, feature->name);
+  return feature;
+}
+
+/*
+** Make a new plugin from current GstBinaryPluginElement structure
+** and save it to the GstRegistry. Return an offset to the next
+** GstBinaryPluginElement structure.
+*/
+static unsigned long
+gst_registry_binary_get_binary_plugin(GstRegistry *registry, gchar *in)
+{
+  GstBinaryPluginElement *p = (GstBinaryPluginElement *) in;
+  GstPlugin *plugin = NULL;
+  GList *plugin_features = NULL;
+  GstBinaryPluginFeature *feat;
+  unsigned int i;
+  unsigned long offset;
+
+  plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
+
+  plugin->flags |= GST_PLUGIN_FLAG_CACHED;
+
+  plugin->desc.name = g_strdup(p->name);
+  plugin->desc.description= g_strdup(p->description);
+  plugin->filename = g_strdup(p->filename);
+  plugin->desc.version = g_strdup(p->version);
+  plugin->desc.license = g_strdup(p->license);
+  plugin->desc.source = g_strdup(p->source);
+  plugin->desc.package = g_strdup(p->package);
+  plugin->desc.origin = g_strdup(p->origin);
+  plugin->file_mtime = p->m32p;
+  plugin->file_size = p->size;
+  plugin->basename = g_path_get_basename (plugin->filename);
+
+  if (plugin->file_mtime < 0 || plugin->file_size < 0)
+    {
+      GST_ERROR("Plugin time or file size is not valid !");
+      g_free(plugin);
+      return -1;
+    }
+
+  if (p->nfeatures < 0)
+    {
+      GST_ERROR("The number of feature structure is not valid !");
+      gst_object_unref(plugin);
+      return -1;
+    }
+
+  for (feat = (GstBinaryPluginFeature *) (in + sizeof (GstBinaryPluginElement)), i = 0; 
+       i < p->nfeatures; i++, feat++)
+    {
+      GstPluginFeature *gstfeat;
+
+      if ((gstfeat = gst_registry_binary_load_feature(feat)) == NULL)
+	{
+	  g_list_free(plugin_features);
+	  g_free(plugin);
+	  GST_ERROR("Error while loading binary feature");
+	  return -1;
+	}
+      gstfeat->plugin_name = g_strdup(plugin->desc.name);
+      plugin_features = g_list_prepend(plugin_features, gstfeat);
+    }
+  
+  GST_DEBUG("Added plugin \"%s\" to global registry from binary registry", plugin->desc.name); 
+  GList *g;
+
+  gst_registry_add_plugin (registry, plugin);
+  for (g = plugin_features; g; g = g_list_next (g))
+    gst_registry_add_feature (registry, GST_PLUGIN_FEATURE (g->data));
+  /*  g_list_free(plugin_features); */
+
+  offset = sizeof (GstBinaryPluginElement) + p->nfeatures * sizeof (GstBinaryPluginFeature);
+  return offset;
+}
+
+
+/*
+** Read the cache and adapt it to fill GstRegistry
+*/ 
+gboolean 
+gst_registry_binary_read_cache(GstRegistry *registry, const char *location)
+{
+  GMappedFile *mapped = NULL;
+  GTimer *timer = NULL;
+  gchar *contents = NULL;
+  gdouble seconds;
+  unsigned long offset, inc;
+  gsize size;
+
+  /* make sure these types exist */
+  GST_TYPE_ELEMENT_FACTORY;
+  GST_TYPE_TYPE_FIND_FACTORY;
+  GST_TYPE_INDEX_FACTORY;
+
+  timer = g_timer_new ();
+
+  if ((mapped = g_mapped_file_new(location, FALSE, NULL)) == NULL ||
+      (contents = g_mapped_file_get_contents(mapped)) == NULL)
+    {
+      GST_ERROR("Can't load file : %s", strerror(errno));
+      return FALSE;
+    }
+  if ((contents = gst_registry_binary_check_magic(contents)) == NULL)
+    {
+      GST_ERROR("Binary registry type not recognized (invalid magic)");
+      g_mapped_file_free(mapped);
+      return FALSE;
+    }
+
+  if ((size = g_mapped_file_get_length(mapped)) < sizeof (GstBinaryPluginElement))
+    {
+      GST_INFO("No binary plugins structure to read");
+      return TRUE; /* This is not really an error */
+    }
+
+  for (offset = inc = 0; (offset + sizeof (GstBinaryPluginElement)) < size &&
+	 (inc = gst_registry_binary_get_binary_plugin(registry, contents + offset)) > 0;
+       offset += inc)
+    ; /* May want in the future to do something here */
+  if (inc < 0)
+    {
+      GST_DEBUG("Problem while reading binary registry");
+      return FALSE;
+    }
+
+  g_timer_stop (timer);
+  seconds = g_timer_elapsed (timer, NULL);
+  g_timer_destroy (timer);
+
+  GST_INFO ("loaded %s in %f seconds", location, seconds);
+
+  if (mapped)
+    g_mapped_file_free (mapped);
+  return TRUE;
+}
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.h b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.h
new file mode 100644
index 0000000..2ef24d7
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.h
@@ -0,0 +1,194 @@
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ *                    2000 Wim Taymans <wim.taymans@chello.be>
+ *
+ * gstregistry.h: Header for registry handling
+ *
+ * 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.
+ */
+
+/* SUGGESTIONS AND TODO :
+** ====================
+** - Use a compressed registry, but would induce performance loss
+** - Encrypt the registry, for security purpose, but would also reduce performances
+** - Also have a non-mmap based cache reading (work with file descriptors)
+*/
+
+#ifndef __GST_REGISTRYBINARY_H__
+#define __GST_REGISTRYBINARY_H__
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <gst/gst_private.h>
+#include <gst/gstelement.h>
+#include <gst/gsttypefind.h>
+#include <gst/gsttypefindfactory.h>
+#include <gst/gsturi.h>
+#include <gst/gstinfo.h>
+#include <gst/gstenumtypes.h>
+#include <gst/gstregistry.h>
+#include <gst/gstpadtemplate.h>
+
+#include "glib-compat-private.h"
+#include <glib/gstdio.h>
+
+/* A magic, written at the beginning of the file */
+#define GST_MAGIC_BINARY_REGISTRY_STR "\xc0\xde\xf0\x0d"
+#define GST_MAGIC_BINARY_REGISTRY_LEN (4)
+#define GST_MAGIC_BINARY_VERSION_LEN (64)
+
+typedef struct _GstBinaryRegistryMagic
+{
+  char magic[GST_MAGIC_BINARY_REGISTRY_LEN];
+  char version[GST_MAGIC_BINARY_VERSION_LEN];
+} GstBinaryRegistryMagic;
+
+
+/* Used to store pointers to write */
+typedef struct _GstBinaryChunck
+{
+  void *data;
+  unsigned int size;
+} GstBinaryChunck;
+
+
+/* A structure containing (staticely) every information needed for a plugin
+**
+** Notes :
+** "nfeatures" is used to say how many GstBinaryPluginFeature structures we will have 
+** right after the structure itself.
+*/
+
+/* Various lenght defines for our GstBinaryPluginElement structure 
+** Note : We could eventually use smaller size
+*/
+#define GST_BINARY_REGISTRY_NAME_LEN (256)
+#define GST_BINARY_REGISTRY_DESCRIPTION_LEN (1024)
+#define GST_BINARY_REGISTRY_VERSION_LEN (64)
+#define GST_BINARY_REGISTRY_LICENSE_LEN (256)
+#define GST_BINARY_REGISTRY_SOURCE_LEN (256)
+#define GST_BINARY_REGISTRY_PACKAGE_LEN (1024)
+#define GST_BINARY_REGISTRY_ORIGIN_LEN (1024)
+
+typedef struct _GstBinaryPluginElement
+{
+  char name[GST_BINARY_REGISTRY_NAME_LEN];
+  char description[GST_BINARY_REGISTRY_DESCRIPTION_LEN];
+  char filename[_POSIX_PATH_MAX];
+  char version[GST_BINARY_REGISTRY_VERSION_LEN];
+  char license[GST_BINARY_REGISTRY_LICENSE_LEN];
+  char source[GST_BINARY_REGISTRY_SOURCE_LEN];
+  char package[GST_BINARY_REGISTRY_PACKAGE_LEN];
+  char origin[GST_BINARY_REGISTRY_ORIGIN_LEN];
+  unsigned long size;
+  unsigned long m32p;
+  unsigned int nfeatures;
+} GstBinaryPluginElement;
+
+
+/* A structure containing the plugin features
+**
+** Note :
+** "npadtemplates" is used to store the number of GstBinaryPadTemplate structures following the structure itself.
+** "ninterfaces" is used to store the number of GstBinaryInterface structures following the structure itself.
+** "nuritypes" is used to store the number of GstBinaryUriType structures following the structure itself.
+*/
+#define GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN (256)
+#define GST_BINARY_REGISTRY_TYPENAME_NAME_LEN (256)
+#define GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN (1024)
+#define GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN (512)
+#define GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN (1024)
+#define GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN (256)
+
+typedef struct _GstBinaryPluginFeature
+{
+  char typename[GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN];
+  char name[GST_BINARY_REGISTRY_TYPENAME_NAME_LEN];
+  unsigned long rank;
+  char longname[GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN];
+  char class[GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN];
+  char description[GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN];
+  char author[GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN];
+  unsigned int npadtemplates;
+  unsigned int ninterfaces;
+  unsigned int nuritypes;
+} GstBinaryPluginFeature;
+
+
+/* 
+** A structure containing the static pad templates of a plugin feature 
+*/
+#define GST_BINARY_REGISTRY_PADTEMPLATE_NAME_LEN (256)
+#define GST_BINARY_REGISTRY_PADTEMPLATE_CAP_LEN (1024)
+
+typedef struct _GstBinaryPadTemplate
+{
+  char name[GST_BINARY_REGISTRY_PADTEMPLATE_NAME_LEN];
+  char cap[GST_BINARY_REGISTRY_PADTEMPLATE_CAP_LEN];
+  int direction;					/* Either 0:"sink" or 1:"src" */
+  GstPadPresence presence;
+} GstBinaryPadTemplate;
+
+/*
+** A very simple structure defining the plugin feature interface string
+*/
+#define GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN (512)
+typedef struct _GstBinaryInterface
+{
+  char interface[GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN];
+  unsigned long size;
+} GstBinaryInterface;
+
+/* Uri Type */
+typedef struct _GstBinaryUriType
+{
+  GstURIType type;
+  unsigned long nuriprotocols;
+} GstBinaryUriType;
+
+/* 
+** Function prototypes
+*/
+
+/* Local prototypes */
+inline static gboolean gst_registry_binary_write(GstRegistry *registry, const void *mem, const ssize_t size);
+inline static gboolean gst_registry_binary_initialize_magic(GstBinaryRegistryMagic *m);
+static gboolean gst_registry_binary_fill_feature(GList **list, GstPluginFeature *, GstBinaryPluginFeature *, const char *);
+static gboolean gst_registry_binary_save_plugin(GList **list, GstRegistry *registry, GstPlugin *plugin);
+static gchar *gst_registry_binary_check_magic(gchar *in);
+static GstPluginFeature *gst_registry_binary_load_feature(GstBinaryPluginFeature *);
+static unsigned long gst_registry_binary_get_binary_plugin(GstRegistry *registry, gchar *in);
+
+/* Exportable */
+gboolean gst_registry_binary_write_cache(GstRegistry *registry, const char *location);
+gboolean gst_registry_binary_read_cache(GstRegistry *registry, const char *location);
+
+#endif /* !__GST_REGISTRYBINARY_H__ */
+
+
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer_0.10.36.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer_0.10.36.bb
new file mode 100644
index 0000000..5b30603
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer_0.10.36.bb
@@ -0,0 +1,51 @@
+SUMMARY = "GStreamer multimedia framework"
+DESCRIPTION = "GStreamer is a multimedia framework for encoding and decoding video and sound. \
+It supports a wide range of formats including mp3, ogg, avi, mpeg and quicktime."
+HOMEPAGE = "http://gstreamer.freedesktop.org/"
+BUGTRACKER = "https://bugzilla.gnome.org/enter_bug.cgi?product=Gstreamer"
+SECTION = "multimedia"
+LICENSE = "LGPLv2+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605 \
+                    file://gst/gst.h;beginline=1;endline=21;md5=8e5fe5e87d33a04479fde862e238eaa4"
+DEPENDS = "glib-2.0 libxml2 bison-native flex-native"
+
+PR = "r2"
+
+SRC_URI = "http://gstreamer.freedesktop.org/src/gstreamer/gstreamer-${PV}.tar.bz2 \
+           file://check_fix.patch \
+           file://gst-inspect-check-error.patch \
+           file://0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch \
+           file://gstreamer-change-priv_gst_parse_yylex-arguments.patch \
+"
+
+SRC_URI[md5sum] = "a0cf7d6877f694a1a2ad2b4d1ecb890b"
+SRC_URI[sha256sum] = "e556a529e0a8cf1cd0afd0cab2af5488c9524e7c3f409de29b5d82bb41ae7a30"
+
+inherit autotools pkgconfig gettext
+
+GSTREAMER_DEBUG ?= "--disable-debug"
+EXTRA_OECONF = "--disable-docbook --disable-gtk-doc \
+            --disable-dependency-tracking --disable-check \
+            --disable-examples --disable-tests \
+            --disable-valgrind ${GSTREAMER_DEBUG} \
+            "
+
+CACHED_CONFIGUREVARS += "ac_cv_header_valgrind_valgrind_h=no"
+
+# apply gstreamer hack after Makefile.in.in in source is replaced by our version from
+# ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in, but before configure is executed
+# http://lists.linuxtogo.org/pipermail/openembedded-core/2012-November/032233.html
+oe_runconf_prepend() {
+        sed -i -e "1a\\" -e 'GETTEXT_PACKAGE = @GETTEXT_PACKAGE@' ${S}/po/Makefile.in.in
+}
+
+#do_compile_prepend () {
+#	mv ${WORKDIR}/gstregistrybinary.[ch] ${S}/gst/
+#}
+
+RRECOMMENDS_${PN}_qemux86    += "kernel-module-snd-ens1370 kernel-module-snd-rawmidi"
+RRECOMMENDS_${PN}_qemux86-64 += "kernel-module-snd-ens1370 kernel-module-snd-rawmidi"
+
+FILES_${PN} += " ${libdir}/gstreamer-0.10/*.so"
+FILES_${PN}-dev += " ${libdir}/gstreamer-0.10/*.la ${libdir}/gstreamer-0.10/*.a"
+FILES_${PN}-dbg += " ${libdir}/gstreamer-0.10/.debug/ ${libexecdir}/gstreamer-0.10/.debug/"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst/python-path.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst/python-path.patch
new file mode 100644
index 0000000..21b5bbf
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst/python-path.patch
@@ -0,0 +1,28 @@
+Upstream-Status:Pending
+
+Index: gst-python-0.10.19/acinclude.m4
+===================================================================
+--- gst-python-0.10.19.orig/acinclude.m4	2010-04-21 15:23:44.000000000 -0700
++++ gst-python-0.10.19/acinclude.m4	2010-11-15 14:43:00.642994001 -0800
+@@ -43,6 +43,13 @@
+ [AC_REQUIRE([AM_PATH_PYTHON])
+ AC_MSG_CHECKING(for headers required to compile python extensions)
+ dnl deduce PYTHON_INCLUDES
++
++AC_ARG_WITH(python-includes,
++	[  --with-python-includes=DIR  path to Python includes], py_exec_prefix=$withval)
++if test x$py_exec_prefix != x; then
++PYTHON_INCLUDES="-I${py_exec_prefix}/include/python${PYTHON_VERSION}"
++py_prefix="${py_exec_prefix}"
++else
+ py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
+ py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
+ if $PYTHON-config --help 2>/dev/null; then
+@@ -53,6 +60,7 @@
+     PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
+   fi
+ fi
++fi
+ AC_SUBST(PYTHON_INCLUDES)
+ dnl check if the headers exist:
+ save_CPPFLAGS="$CPPFLAGS"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst_0.10.22.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst_0.10.22.bb
new file mode 100644
index 0000000..2a5f2b3
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst_0.10.22.bb
@@ -0,0 +1,29 @@
+SUMMARY = "Python bindings for the GStreamer multimedia framework"
+SECTION = "devel/python"
+LICENSE = "LGPLv2.1"
+DEPENDS = "gstreamer gst-plugins-base python-pygobject"
+RDEPENDS_${PN} += "python-pygtk"
+PR = "r2"
+
+SRC_URI = "http://gstreamer.freedesktop.org/src/gst-python/gst-python-${PV}.tar.bz2 \
+           file://python-path.patch"
+
+SRC_URI[md5sum] = "937152fe896241f827689f4b53e79b22"
+SRC_URI[sha256sum] = "8f26f519a5bccd770864317e098e5e307fc5ad1201eb96329634b6508b253178"
+S = "${WORKDIR}/gst-python-${PV}"
+
+LIC_FILES_CHKSUM = "file://COPYING;md5=39ff67e932b7bdfa9b78bad67151690b"
+
+inherit autotools distutils-base pkgconfig
+
+EXTRA_OECONF += "--with-python-includes=${STAGING_INCDIR}/../"
+
+FILES_${PN} += "${datadir}/gst-python"
+FILES_${PN}-dev += "${datadir}/gst-python/0.10/defs"
+FILES_${PN}-dbg += "${libdir}/${PYTHON_DIR}/site-packages/gst-0.10/gst/.debug/ ${libdir}/gstreamer-0.10/.debug/"
+
+do_configure_prepend() {
+	if [ `find ${STAGING_LIBDIR} -name libpython*.so` ]; then
+		ln -sf ${STAGING_LIBDIR}/libpython*.so `find ${STAGING_LIBDIR} -name libpython*.a -exec dirname {} \;`
+	fi
+}
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
deleted file mode 100644
index 7da0e14..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-gst-ffmpeg: aacdec: check channel count
-
-Prevent out of array accesses
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit 96f452ac647dae33c53c242ef3266b65a9beafb6)
-
-Upstream-Status: Backport 
-
-Signed-off-by: Yue Tao <yue.tao@windriver.com>
----
- libavcodec/aacdec.c |    5 +++++
- 1 files changed, 5 insertions(+), 0 deletions(-)
-
-diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
-index 239153a..6c17c33 100644
---- a/gst-libs/ext/libav/libavcodec/aacdec.c
-+++ b/gst-libs/ext/libav/libavcodec/aacdec.c
-@@ -914,6 +914,11 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
-         }
-     }
- 
-+    if (avctx->channels > MAX_CHANNELS) {
-+        av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
-+        return AVERROR_INVALIDDATA;
-+    }
-+
-     AAC_INIT_VLC_STATIC( 0, 304);
-     AAC_INIT_VLC_STATIC( 1, 270);
-     AAC_INIT_VLC_STATIC( 2, 550);
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
deleted file mode 100644
index 10ce0f3..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From e0884eadf6a15e93142131b695f48776f9a0ac31 Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Sat, 10 Nov 2012 17:14:04 +0100
-Subject: [PATCH] alac: fix nb_samples < order case
-
-Upstream-Status: Backport
-
-Commit e0884eadf6a15e93142131b695f48776f9a0ac31 release/1.0
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit fd4f4923cce6a2cbf4f48640b4ac706e614a1594)
----
- libavcodec/alac.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/libavcodec/alac.c b/libavcodec/alac.c
-index 9cd1737..e8e844a 100644
---- a/gst-libs/ext/libav/libavcodec/alac.c
-+++ b/gst-libs/ext/libav/libavcodec/alac.c
-@@ -278,7 +278,7 @@ static void predictor_decompress_fir_ada
- 
-     /* read warm-up samples */
-     if (predictor_coef_num > 0)
--        for (i = 0; i < predictor_coef_num; i++) {
-+        for (i = 0; i < predictor_coef_num && i < output_size; i++) {
-             int32_t val;
- 
-             val = buffer_out[i] + error_buffer[i+1];
--- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
deleted file mode 100644
index 73980f4..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
+++ /dev/null
@@ -1,61 +0,0 @@
-From 6df0d3e2916c223dbe4262bf1b876dff1cb3f980 Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Wed, 12 Dec 2012 12:28:45 +0100
-Subject: [PATCH] alsdec: check block length
-
-Upstream-Status: Backport
-
-Commit 6df0d3e2916c223dbe4262bf1b876dff1cb3f980 release/1.0
-
-Fix writing over the end
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit 0ceca269b66ec12a23bf0907bd2c220513cdbf16)
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/alsdec.c | 10 ++++++++--
- 1 file changed, 8 insertions(+), 2 deletions(-)
-
-diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
-index 46dd0b4..1095b01 100644
---- a/gst-libs/ext/libav/libavcodec/alsdec.c
-+++ b/gst-libs/ext/libav/libavcodec/alsdec.c
-@@ -552,12 +552,15 @@ static void get_block_sizes(ALSDecContext *ctx, unsigned int *div_blocks,
- 
- /** Read the block data for a constant block
-  */
--static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
-+static int read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
- {
-     ALSSpecificConfig *sconf = &ctx->sconf;
-     AVCodecContext *avctx    = ctx->avctx;
-     GetBitContext *gb        = &ctx->gb;
- 
-+    if (bd->block_length <= 0)
-+        return -1;
-+
-     *bd->raw_samples = 0;
-     *bd->const_block = get_bits1(gb);    // 1 = constant value, 0 = zero block (silence)
-     bd->js_blocks    = get_bits1(gb);
-@@ -572,6 +575,8 @@ static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
- 
-     // ensure constant block decoding by reusing this field
-     *bd->const_block = 1;
-+
-+    return 0;
- }
- 
- 
-@@ -971,7 +976,8 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
-         if (read_var_block_data(ctx, bd))
-             return -1;
-     } else {
--        read_const_block_data(ctx, bd);
-+        if (read_const_block_data(ctx, bd) < 0)
-+            return -1;
-     }
- 
-     return 0;
--- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
deleted file mode 100644
index 42cb5f4..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From 2502914c5f8eb77659d7c0868396862557a63245 Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Fri, 9 Nov 2012 13:26:20 +0100
-Subject: [PATCH] atrac3dec: Check coding mode against channels.
-
-Upstream-Status: Backport
-
-Commit 2502914c5f8eb77659d7c0868396862557a63245 release/1.0
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit 13451f5520ce6b0afde861b2285dda659f8d4fb4)
-
-Conflicts:
-
-	libavcodec/atrac3.c
----
- libavcodec/atrac3.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
-index 7d076be..1da4c78 100644
---- a/gst-libs/ext/libav/libavcodec/atrac3.c
-+++ b/gst-libs/ext/libav/libavcodec/atrac3.c
-@@ -955,6 +955,11 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
-     }
-     /* Check the extradata. */
- 
-+    if (q->codingMode == JOINT_STEREO && avctx->channels < 2) {
-+        av_log(avctx, AV_LOG_ERROR, "Invalid coding mode\n");
-+        return AVERROR_INVALIDDATA;
-+    }
-+
-     if (q->atrac3version != 4) {
-         av_log(avctx,AV_LOG_ERROR,"Version %d != 4.\n",q->atrac3version);
-         return AVERROR_INVALIDDATA;
--- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
deleted file mode 100644
index 31fa51a..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From a99aff4e4bbef8e64b51f267cd1769214e1b4e80 Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Fri, 30 Aug 2013 23:40:47 +0200
-Subject: [PATCH] avcodec/dsputil: fix signedness in sizeof() comparissions
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit 454a11a1c9c686c78aa97954306fb63453299760)
-
-Upstream-Status: Backport
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/dsputil.c |    4 ++--
- 1 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
-index 53dc2eb..6264832 100644
---- a/gst-libs/ext/libav/libavcodec/dsputil.c
-+++ b/gst-libs/ext/libav/libavcodec/dsputil.c
-@@ -1912,7 +1912,7 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
- 
- static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
-     long i;
--    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
-+    for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
-         long a = *(long*)(src+i);
-         long b = *(long*)(dst+i);
-         *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
-@@ -1937,7 +1937,7 @@ static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
-         }
-     }else
- #endif
--    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
-+    for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
-         long a = *(long*)(src1+i);
-         long b = *(long*)(src2+i);
-         *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
deleted file mode 100644
index b0a3fb1..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-From 573d5fdedae72bf59d8c0b0766fdee171063d36f Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Sun, 16 Feb 2014 23:08:52 +0100
-Subject: [PATCH] avcodec/msrle: use av_image_get_linesize() to calculate the
- linesize
-
-Upstream-Status: Backport
-
-Commit 573d5fdedae72bf59d8c0b0766fdee171063d36f release/0.9
-
-Fixes out of array access
-Fixes: 14a74a0a2dc67ede543f0e35d834fbbe-asan_heap-oob_49572c_556_cov_215466444_44_001_engine_room.mov
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit c919e1ca2ecfc47d796382973ba0e48b8f6f92a2)
-
-Conflicts:
-
-	libavcodec/msrle.c
-(cherry picked from commit bc1c8ec5e65098fd2ccd8456f667151dfc9cda42)
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/msrle.c |    3 ++-
- 1 files changed, 2 insertions(+), 1 deletions(-)
-
-diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c
-index 30159bb..c39ae7b 100644
---- a/gst-libs/ext/libav/libavcodec/msrle.c
-+++ b/gst-libs/ext/libav/libavcodec/msrle.c
-@@ -35,6 +35,7 @@
- #include "avcodec.h"
- #include "dsputil.h"
- #include "msrledec.h"
-+#include "libavutil/imgutils.h"
- 
- typedef struct MsrleContext {
-     AVCodecContext *avctx;
-@@ -107,7 +108,7 @@ static int msrle_decode_frame(AVCodecContext *avctx,
- 
-     /* FIXME how to correctly detect RLE ??? */
-     if (avctx->height * istride == avpkt->size) { /* assume uncompressed */
--        int linesize = avctx->width * avctx->bits_per_coded_sample / 8;
-+        int linesize = av_image_get_linesize(avctx->pix_fmt, avctx->width, 0);
-         uint8_t *ptr = s->frame.data[0];
-         uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
-         int i, j;
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
deleted file mode 100644
index 5ff6583..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-gst-ffmpeg: avcodec/parser: reset indexes on realloc failure
-
-Fixes Ticket2982
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit f31011e9abfb2ae75bb32bc44e2c34194c8dc40a)
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-
-Upstream-Status: Backport 
-
-Signed-off-by: Yue Tao <yue.tao@windriver.com>
-
----
- libavcodec/parser.c |   10 +++++++---
- 1 files changed, 7 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/parser.c b/libavcodec/parser.c
-index 2c6de6e..66eca06 100644
---- a/gst-libs/ext/libav/libavcodec/parser.c
-+++ b/gst-libs/ext/libav/libavcodec/parser.c
-@@ -241,8 +241,10 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
-     if(next == END_NOT_FOUND){
-         void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
- 
--        if(!new_buffer)
-+        if(!new_buffer) {
-+            pc->index = 0;
-             return AVERROR(ENOMEM);
-+        }
-         pc->buffer = new_buffer;
-         memcpy(&pc->buffer[pc->index], *buf, *buf_size);
-         pc->index += *buf_size;
-@@ -255,9 +257,11 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
-     /* append to buffer */
-     if(pc->index){
-         void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
--
--        if(!new_buffer)
-+        if(!new_buffer) {
-+            pc->overread_index =
-+            pc->index = 0;
-             return AVERROR(ENOMEM);
-+        }
-         pc->buffer = new_buffer;
-         if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
-             memcpy(&pc->buffer[pc->index], *buf,
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
deleted file mode 100644
index 7f6eb48..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
+++ /dev/null
@@ -1,81 +0,0 @@
-gst-ffmpeg: avcodec/rpza: Perform pointer advance and checks before
- using the pointers
-
-Fixes out of array accesses
-Fixes Ticket2850
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit 3819db745da2ac7fb3faacb116788c32f4753f34)
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-
-Upstream-Status: Backport 
-
-Singed-off-by: Yue Tao <yue.tao@windriver.com>
-
----
- libavcodec/rpza.c |    8 ++++----
- 1 files changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c
-index 635b406..f291a95 100644
---- a/gst-libs/ext/libav/libavcodec/rpza.c
-+++ b/gst-libs/ext/libav/libavcodec/rpza.c
-@@ -83,7 +83,7 @@ static void rpza_decode_stream(RpzaContext *s)
-     unsigned short *pixels = (unsigned short *)s->frame.data[0];
- 
-     int row_ptr = 0;
--    int pixel_ptr = 0;
-+    int pixel_ptr = -4;
-     int block_ptr;
-     int pixel_x, pixel_y;
-     int total_blocks;
-@@ -139,6 +139,7 @@ static void rpza_decode_stream(RpzaContext *s)
-             colorA = AV_RB16 (&s->buf[stream_ptr]);
-             stream_ptr += 2;
-             while (n_blocks--) {
-+                ADVANCE_BLOCK()
-                 block_ptr = row_ptr + pixel_ptr;
-                 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
-                     for (pixel_x = 0; pixel_x < 4; pixel_x++){
-@@ -147,7 +148,6 @@ static void rpza_decode_stream(RpzaContext *s)
-                     }
-                     block_ptr += row_inc;
-                 }
--                ADVANCE_BLOCK();
-             }
-             break;
- 
-@@ -184,6 +184,7 @@ static void rpza_decode_stream(RpzaContext *s)
-             color4[2] |= ((21 * ta + 11 * tb) >> 5);
- 
-             while (n_blocks--) {
-+                ADVANCE_BLOCK();
-                 block_ptr = row_ptr + pixel_ptr;
-                 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
-                     index = s->buf[stream_ptr++];
-@@ -194,12 +195,12 @@ static void rpza_decode_stream(RpzaContext *s)
-                     }
-                     block_ptr += row_inc;
-                 }
--                ADVANCE_BLOCK();
-             }
-             break;
- 
-         /* Fill block with 16 colors */
-         case 0x00:
-+            ADVANCE_BLOCK();
-             block_ptr = row_ptr + pixel_ptr;
-             for (pixel_y = 0; pixel_y < 4; pixel_y++) {
-                 for (pixel_x = 0; pixel_x < 4; pixel_x++){
-@@ -213,7 +214,6 @@ static void rpza_decode_stream(RpzaContext *s)
-                 }
-                 block_ptr += row_inc;
-             }
--            ADVANCE_BLOCK();
-             break;
- 
-         /* Unknown opcode */
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
deleted file mode 100644
index 3ca6fc4..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From c17a0ad1df15a94d0b1239adc2afb593bdf0a153 Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Fri, 3 Oct 2014 22:50:45 +0200
-Subject: [PATCH 1/2] avcodec/smc: fix off by 1 error
-
-Upstream-Status: Backport
-
-Fixes out of array access
-Fixes: asan_heap-oob_1685bf0_5_asan_heap-oob_1f35116_430_smc.mov
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/smc.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/gst-libs/ext/libav/libavcodec/smc.c b/gst-libs/ext/libav/libavcodec/smc.c
-index 3cd5e53..dec9f71 100644
---- a/gst-libs/ext/libav/libavcodec/smc.c
-+++ b/gst-libs/ext/libav/libavcodec/smc.c
-@@ -69,7 +69,7 @@ typedef struct SmcContext {
-         row_ptr += stride * 4; \
-     } \
-     total_blocks--; \
--    if (total_blocks < 0) \
-+    if (total_blocks < 0 + !!n_blocks) \
-     { \
-         av_log(s->avctx, AV_LOG_INFO, "warning: block counter just went negative (this should not happen)\n"); \
-         return; \
--- 
-2.1.0
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
deleted file mode 100644
index 68bb66e..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
+++ /dev/null
@@ -1,69 +0,0 @@
-From 12770701856a05b6b3cd706f708f8e9a4e8a1336 Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Thu, 13 Feb 2014 13:59:51 +0100
-Subject: [PATCH] avformat/mpegtsenc: Check data array size in
- mpegts_write_pmt()
-
-Upstream-Status: Backport
-
-COmmit 12770701856a05b6b3cd706f708f8e9a4e8a1336 release/0.11
-
-Prevents out of array writes
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit 842b6c14bcfc1c5da1a2d288fd65386eb8c158ad)
-
-Conflicts:
-
-	libavformat/mpegtsenc.c
-(cherry picked from commit e87de3f50b765134588d0b048c32ed4b8acc16fb)
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavformat/mpegtsenc.c |    9 +++++++--
- 1 files changed, 7 insertions(+), 2 deletions(-)
-
-diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
-index 793e205..a12d19f 100644
---- a/gst-libs/ext/libav/libavformat/mpegtsenc.c
-+++ b/gst-libs/ext/libav/libavformat/mpegtsenc.c
-@@ -240,7 +240,7 @@ static void mpegts_write_pat(AVFormatContext *s)
-                           data, q - data);
- }
- 
--static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
-+static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
- {
-     //    MpegTSWrite *ts = s->priv_data;
-     uint8_t data[1012], *q, *desc_length_ptr, *program_info_length_ptr;
-@@ -293,6 +293,10 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
-             stream_type = STREAM_TYPE_PRIVATE_DATA;
-             break;
-         }
-+
-+        if (q - data > sizeof(data) - 32)
-+            return AVERROR(EINVAL);
-+
-         *q++ = stream_type;
-         put16(&q, 0xe000 | ts_st->pid);
-         desc_length_ptr = q;
-@@ -324,7 +328,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
-                 len_ptr = q++;
-                 *len_ptr = 0;
- 
--                for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next + 1) {
-+                for (p = lang->value; next && *len_ptr < 255 / 4 * 4 && q - data < sizeof(data) - 4; p = next + 1) {
-                     next = strchr(p, ',');
-                     if (strlen(p) != 3 && (!next || next != p + 3))
-                         continue; /* not a 3-letter code */
-@@ -386,6 +390,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
-     }
-     mpegts_write_section1(&service->pmt, PMT_TID, service->sid, 0, 0, 0,
-                           data, q - data);
-+    return 0;
- }
- 
- /* NOTE: str == NULL is accepted for an empty string */
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
deleted file mode 100644
index f45e3fd..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From 63ac64864c6e0e84355aa3caa5b92208997a9a8d Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Sat, 17 Nov 2012 16:26:55 +0100
-Subject: [PATCH] eamad: fix out of array accesses
-
-Upstream-Status: Backport
-
-Commit 63ac64864c6e0e84355aa3caa5b92208997a9a8d release/1.1
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/eamad.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c
-index 2805195..e38650e 100644
---- a/gst-libs/ext/libav/libavcodec/eamad.c
-+++ b/gst-libs/ext/libav/libavcodec/eamad.c
-@@ -237,7 +237,7 @@ static int decode_frame(AVCodecContext *avctx,
-     int chunk_type;
-     int inter;
- 
--    if (buf_size < 17) {
-+    if (buf_size < 26) {
-         av_log(avctx, AV_LOG_ERROR, "Input buffer too small\n");
-         *data_size = 0;
-         return -1;
--- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
deleted file mode 100644
index e0e4239..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-gst-ffmpeg: error concealment: initialize block index.
-
-Fixes CVE-2011-3941 (out of bounds write)
-
-Upstream-Status: Backport 
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/error_resilience.c |    3 +++
- 1 files changed, 3 insertions(+), 0 deletions(-)
-
-diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
-index 8bb5d0c..d55c000 100644
---- a/gst-libs/ext/libav/libavcodec/error_resilience.c
-+++ b/gst-libs/ext/libav/libavcodec/error_resilience.c
-@@ -45,6 +45,9 @@ static void decode_mb(MpegEncContext *s, int ref){
-     s->dest[1] = s->current_picture.data[1] + (s->mb_y * (16>>s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16>>s->chroma_x_shift);
-     s->dest[2] = s->current_picture.data[2] + (s->mb_y * (16>>s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16>>s->chroma_x_shift);
- 
-+    ff_init_block_index(s);
-+    ff_update_block_index(s);
-+
-     if(CONFIG_H264_DECODER && s->codec_id == CODEC_ID_H264){
-         H264Context *h= (void*)s;
-         h->mb_xy= s->mb_x + s->mb_y*s->mb_stride;
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
deleted file mode 100644
index 8eef6e9..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-gst-ffmpeg: error_concealment: Check that the picture is not in a half
-
-Fixes state becoming inconsistent
-Fixes a null pointer dereference
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit 23318a57358358e7a4dc551e830e4503f0638cfe)
-
-Upstream-Status: Backport 
-
-Signed-off-by: Yue Tao <yue.tao@windriver.com>
-
----
- libavcodec/error_resilience.c |    6 ++++++
- 1 files changed, 6 insertions(+), 0 deletions(-)
-
-diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
-index 01f7424..2b6bc42 100644
---- a/gst-libs/ext/libav/libavcodec/error_resilience.c
-+++ b/gst-libs/ext/libav/libavcodec/error_resilience.c
-@@ -793,6 +793,12 @@ void ff_er_frame_end(MpegEncContext *s){
-        s->picture_structure != PICT_FRAME || // we dont support ER of field pictures yet, though it should not crash if enabled
-        s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return;
- 
-+    if (   s->picture_structure == PICT_FRAME
-+        && s->current_picture.linesize[0] != s->current_picture_ptr->linesize[0]) {
-+        av_log(s->avctx, AV_LOG_ERROR, "Error concealment not possible, frame not fully initialized\n");
-+        return;
-+    }
-+
-     if(s->current_picture.motion_val[0] == NULL){
-         av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
- 
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
deleted file mode 100644
index 80325db..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-gst-ffmpeg: ffserver: set oformat
-
-Fix Ticket1986
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit cbe43e62c9ac7d4aefdc13476f6f691bd626525f)
-
-Upstream-Status: Backport 
-
----
- ffserver.c |    4 +++-
- 1 files changed, 3 insertions(+), 1 deletions(-)
-
-diff --git a/ffserver.c b/ffserver.c
-index 4044d0f..8740140 100644
---- a/gst-libs/ext/libav/ffserver.c
-+++ b/gst-libs/ext/libav/ffserver.c
-@@ -2937,12 +2937,14 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
- {
-     AVFormatContext *avc;
-     AVStream *avs = NULL;
-+    AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
-     int i;
- 
-     avc =  avformat_alloc_context();
--    if (avc == NULL) {
-+    if (avc == NULL || !rtp_format) {
-         return -1;
-     }
-+    avc->oformat = rtp_format;
-     av_dict_set(&avc->metadata, "title",
-                stream->title[0] ? stream->title : "No Title", 0);
-     avc->nb_streams = stream->nb_streams;
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
deleted file mode 100644
index d4f55b2..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From d6c184880ee2e09fd68c0ae217173832cee5afc1 Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Sun, 18 Nov 2012 16:29:04 +0100
-Subject: [PATCH] h264: correct ref count check and limit, fix out of array
- accesses.
-
-Upstream-Status: Backport
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/h264.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/libavcodec/h264.c b/libavcodec/h264.c
-index da43f1e..32cede5 100644
---- a/gst-libs/ext/libav/libavcodec/h264.c
-+++ b/gst-libs/ext/libav/libavcodec/h264.c
-@@ -2870,6 +2870,9 @@ static int decode_slice_header(H264Conte
-             h->ref_count[0]= get_ue_golomb(&s->gb) + 1;
-             if(h->slice_type_nos==AV_PICTURE_TYPE_B)
-                 h->ref_count[1]= get_ue_golomb(&s->gb) + 1;
-+            else
-+                // full range is spec-ok in this case, even for frames
-+                h->ref_count[1] = 1;
- 
-             if(h->ref_count[0]-1 > 32-1 || h->ref_count[1]-1 > 32-1){
-                 av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
--- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
deleted file mode 100644
index 05a9de3..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
+++ /dev/null
@@ -1,145 +0,0 @@
-gst-ffmpeg: h264: set parameters from SPS whenever it changes
-    
-Fixes a crash in the fuzzed sample sample_varPAR.avi_s26638 with
-alternating bit depths.
-
-Upstream-Status: Backport
-
-Signed-off-by: Yue Tao <yue.tao@windriver.com>
-
-diff --git a/gst-libs/ext/libav/libavcodec/h264.c.old b/gst-libs/ext/libav/libavcodec/h264.c
-index 3621f41..718906a 100644
---- a/gst-libs/ext/libav/libavcodec/h264.c.old
-+++ b/gst-libs/ext/libav/libavcodec/h264.c
-@@ -2491,6 +2491,34 @@ int ff_h264_get_profile(SPS *sps)
-     return profile;
- }
- 
-+static int h264_set_parameter_from_sps(H264Context *h)
-+{
-+    MpegEncContext *s = &h->s;
-+    AVCodecContext * avctx= s->avctx;
-+
-+    if (s->flags& CODEC_FLAG_LOW_DELAY ||
-+        (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames))
-+        s->low_delay=1;
-+
-+    if(avctx->has_b_frames < 2)
-+        avctx->has_b_frames= !s->low_delay;
-+
-+    if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
-+        if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
-+            avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
-+            h->pixel_shift = h->sps.bit_depth_luma > 8;
-+
-+            ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
-+            ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
-+            dsputil_init(&s->dsp, s->avctx);
-+        } else {
-+            av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
-+            return -1;
-+        }
-+    }
-+    return 0;
-+}
-+
- /**
-  * decodes a slice header.
-  * This will also call MPV_common_init() and frame_start() as needed.
-@@ -2505,7 +2533,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
-     MpegEncContext * const s0 = &h0->s;
-     unsigned int first_mb_in_slice;
-     unsigned int pps_id;
--    int num_ref_idx_active_override_flag;
-+    int num_ref_idx_active_override_flag, ret;
-     unsigned int slice_type, tmp, i, j;
-     int default_ref_list_done = 0;
-     int last_pic_structure;
-@@ -2569,7 +2597,17 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
-         av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS %u referenced\n", h->pps.sps_id);
-         return -1;
-     }
--    h->sps = *h0->sps_buffers[h->pps.sps_id];
-+
-+    if (h->pps.sps_id != h->current_sps_id ||
-+        h0->sps_buffers[h->pps.sps_id]->new) {
-+        h0->sps_buffers[h->pps.sps_id]->new = 0;
-+
-+        h->current_sps_id = h->pps.sps_id;
-+        h->sps            = *h0->sps_buffers[h->pps.sps_id];
-+
-+        if ((ret = h264_set_parameter_from_sps(h)) < 0)
-+            return ret;
-+    }
- 
-     s->avctx->profile = ff_h264_get_profile(&h->sps);
-     s->avctx->level   = h->sps.level_idc;
-@@ -3811,26 +3811,8 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
-         case NAL_SPS:
-             init_get_bits(&s->gb, ptr, bit_length);
-             ff_h264_decode_seq_parameter_set(h);
--
--            if (s->flags& CODEC_FLAG_LOW_DELAY ||
--                (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames))
--                s->low_delay=1;
--
--            if(avctx->has_b_frames < 2)
--                avctx->has_b_frames= !s->low_delay;
--
--            if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
--                if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
--                    avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
--                    h->pixel_shift = h->sps.bit_depth_luma > 8;
--
--                    ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
--                    ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
--                    dsputil_init(&s->dsp, s->avctx);
--                } else {
--                    av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
--                    return -1;
--                }
-+            if (h264_set_parameter_from_sps(h) < 0) {
-+                return -1;
-             }
-             break;
-         case NAL_PPS:
-diff --git a/gst-libs/ext/libav/libavcodec/h264.h.old b/gst-libs/ext/libav/libavcodec/h264.h
-index e3cc815..b77ad98 100644
---- a/gst-libs/ext/libav/libavcodec/h264.h.old
-+++ b/gst-libs/ext/libav/libavcodec/h264.h
-@@ -202,6 +202,7 @@ typedef struct SPS{
-     int bit_depth_chroma;              ///< bit_depth_chroma_minus8 + 8
-     int residual_color_transform_flag; ///< residual_colour_transform_flag
-     int constraint_set_flags;          ///< constraint_set[0-3]_flag
-+    int new;                              ///< flag to keep track if the decoder context needs re-init due to changed SPS
- }SPS;
- 
- /**
-@@ -333,6 +334,7 @@ typedef struct H264Context{
-     int emu_edge_width;
-     int emu_edge_height;
- 
-+    unsigned current_sps_id; ///< id of the current SPS
-     SPS sps; ///< current sps
- 
-     /**
-diff --git a/gst-libs/ext/libav/libavcodec/h264_ps.c.old b/gst-libs/ext/libav/libavcodec/h264_ps.c
-index 7491807..0929098 100644
---- a/gst-libs/ext/libav/libavcodec/h264_ps.c.old
-+++ b/gst-libs/ext/libav/libavcodec/h264_ps.c
-@@ -438,10 +438,13 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
-                sps->timing_info_present_flag ? sps->time_scale : 0
-                );
-     }
-+    sps->new = 1;
- 
-     av_free(h->sps_buffers[sps_id]);
--    h->sps_buffers[sps_id]= sps;
--    h->sps = *sps;
-+    h->sps_buffers[sps_id] = sps;
-+    h->sps                 = *sps;
-+    h->current_sps_id      = sps_id;
-+
-     return 0;
- fail:
-     av_free(sps);
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
deleted file mode 100644
index 5d45c1a..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-gst-ffmpeg: h264: skip error concealment when SPS and slices are
- mismatching
-
-Fixes out of array accesses
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit 695af8eed642ff0104834495652d1ee784a4c14d)
-
-Upstream-Status: Backport
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-Signed-off-by: Yue Tao <yue.tao@windriver.com>
----
- libavcodec/h264.c |    2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
-
-diff --git a/libavcodec/h264.c b/libavcodec/h264.c
-index da144db..0aab4e7 100644
---- a/gst-libs/ext/libav/libavcodec/h264.c
-+++ b/gst-libs/ext/libav/libavcodec/h264.c
-@@ -2351,7 +2351,7 @@ static int field_end(H264Context *h, int in_setup)
-      * past end by one (callers fault) and resync_mb_y != 0
-      * causes problems for the first MB line, too.
-      */
--    if (!FIELD_PICTURE)
-+    if (!FIELD_PICTURE && h->current_slice && !h->sps.new)
-         ff_er_frame_end(s);
- 
-     ff_MPV_frame_end(s);
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
deleted file mode 100644
index 1e62b50..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-gst-ffmpeg: h264_sei: Fix infinite loop.
-
-Fixsot yet fixed parts of CVE-2011-3946.
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-
-Upstream-Status: Backport 
-
-Signed-off-by: Yue Tao <yue.tao@windriver.com>
-
----
- libavcodec/h264_sei.c |    4 ++++
- 1 files changed, 4 insertions(+), 0 deletions(-)
-
-
-diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
-index 374e53d..80d70e5 100644
---- a/gst-libs/ext/libav/libavcodec/h264_sei.c
-+++ b/gst-libs/ext/libav/libavcodec/h264_sei.c
-@@ -169,11 +169,15 @@ int ff_h264_decode_sei(H264Context *h){
- 
-         type=0;
-         do{
-+            if (get_bits_left(&s->gb) < 8)
-+                return -1;
-             type+= show_bits(&s->gb, 8);
-         }while(get_bits(&s->gb, 8) == 255);
- 
-         size=0;
-         do{
-+            if (get_bits_left(&s->gb) < 8)
-+                return -1;
-             size+= show_bits(&s->gb, 8);
-         }while(get_bits(&s->gb, 8) == 255);
- 
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
deleted file mode 100644
index e859e44..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
+++ /dev/null
@@ -1,87 +0,0 @@
-From b666debffec1fcbb19ef377635a53b9a58bca8a4 Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Tue, 29 Jan 2013 18:29:41 +0100
-Subject: [PATCH] huffyuvdec: Check init_vlc() return codes.
-
-Upstream-Status: Backport
-
-Commit b666debffec1fcbb19ef377635a53b9a58bca8a4 release/1.0
-
-Prevents out of array writes
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit f67a0d115254461649470452058fa3c28c0df294)
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/huffyuv.c | 14 ++++++++++----
- 1 file changed, 10 insertions(+), 4 deletions(-)
-
-diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
-index 58da789..993e524 100644
---- a/gst-libs/ext/libav/libavcodec/huffyuv.c
-+++ b/gst-libs/ext/libav/libavcodec/huffyuv.c
-@@ -33,6 +33,7 @@
- #include "put_bits.h"
- #include "dsputil.h"
- #include "thread.h"
-+#include "libavutil/avassert.h"
- 
- #define VLC_BITS 11
- 
-@@ -287,6 +287,7 @@ static void generate_joint_tables(HYuvCo
-                     int len1 = s->len[p][u];
-                     if (len1 > limit || !len1)
-                         continue;
-+                    av_assert0(i < (1 << VLC_BITS));
-                     len[i] = len0 + len1;
-                     bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
-                     symbols[i] = (y<<8) + u;
-@@ -320,6 +321,7 @@ static void generate_joint_tables(HYuvCo
-                     int len2 = s->len[2][r&255];
-                     if (len2 > limit1 || !len2)
-                         continue;
-+                    av_assert0(i < (1 << VLC_BITS));
-                     len[i] = len0 + len1 + len2;
-                     bits[i] = (code << len2) + s->bits[2][r&255];
-                     if(s->decorrelate){
-@@ -343,6 +345,7 @@ static void generate_joint_tables(HYuvCo
- static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length){
-     GetBitContext gb;
-     int i;
-+    int ret;
- 
-     init_get_bits(&gb, src, length*8);
- 
-@@ -353,7 +356,9 @@ static int read_huffman_tables(HYuvConte
-             return -1;
-         }
-         free_vlc(&s->vlc[i]);
--        init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
-+        if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
-+                           s->bits[i], 4, 4, 0)) < 0)
-+            return ret;
-     }
- 
-     generate_joint_tables(s);
-@@ -365,6 +370,7 @@ static int read_old_huffman_tables(HYuvC
- #if 1
-     GetBitContext gb;
-     int i;
-+    int ret;
- 
-     init_get_bits(&gb, classic_shift_luma, sizeof(classic_shift_luma)*8);
-     if(read_len_table(s->len[0], &gb)<0)
-@@ -385,7 +391,9 @@ static int read_old_huffman_tables(HYuvC
- 
-     for(i=0; i<3; i++){
-         free_vlc(&s->vlc[i]);
--        init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
-+        if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
-+                            s->bits[i], 4, 4, 0)) < 0)
-+            return ret;
-     }
- 
-     generate_joint_tables(s);
--- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
deleted file mode 100644
index 94bf4b6..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
+++ /dev/null
@@ -1,61 +0,0 @@
-From db0f7f7394e1f994ed38db043f78ed0f10bde0da Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Tue, 29 Jan 2013 19:22:33 +0100
-Subject: [PATCH] huffyuvdec: Skip len==0 cases
-
-Upstream-Status: Backport
-
-Commit db0f7f7394e1f994ed38db043f78ed0f10bde0da release/1.0
-
-Fixes vlc decoding for hypothetical files that would contain such cases.
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit 0dfc01c2bbf4b71bb56201bc4a393321e15d1b31)
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/huffyuv.c | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
-index 993e524..72ed351 100644
---- a/gst-libs/ext/libav/libavcodec/huffyuv.c
-+++ b/gst-libs/ext/libav/libavcodec/huffyuv.c
-@@ -281,11 +281,11 @@ static void generate_joint_tables(HYuvCo
-             for(i=y=0; y<256; y++){
-                 int len0 = s->len[0][y];
-                 int limit = VLC_BITS - len0;
--                if(limit <= 0)
-+                if(limit <= 0 || !len0)
-                     continue;
-                 for(u=0; u<256; u++){
-                     int len1 = s->len[p][u];
--                    if(len1 > limit)
-+                    if (len1 > limit || !len1)
-                         continue;
-                     len[i] = len0 + len1;
-                     bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
-@@ -308,17 +308,17 @@ static void generate_joint_tables(HYuvCo
-         for(i=0, g=-16; g<16; g++){
-             int len0 = s->len[p0][g&255];
-             int limit0 = VLC_BITS - len0;
--            if(limit0 < 2)
-+            if (limit0 < 2 || !len0)
-                 continue;
-             for(b=-16; b<16; b++){
-                 int len1 = s->len[p1][b&255];
-                 int limit1 = limit0 - len1;
--                if(limit1 < 1)
-+                if (limit1 < 1 || !len1)
-                     continue;
-                 code = (s->bits[p0][g&255] << len1) + s->bits[p1][b&255];
-                 for(r=-16; r<16; r++){
-                     int len2 = s->len[2][r&255];
--                    if(len2 > limit1)
-+                    if (len2 > limit1 || !len2)
-                         continue;
-                     len[i] = len0 + len1 + len2;
-                     bits[i] = (code << len2) + s->bits[2][r&255];
--- 
-1.8.5.2.233.g932f7e4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
deleted file mode 100644
index ea4aa22..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-gst-ffmpeg: lavf: compute probe buffer size more reliably.
-
-The previous code computes the offset by reversing the growth
-of the allocated buffer size: it is complex and did lead to
-inconsistencies when the size limit is reached.
-
-Fix trac ticket #1991.
-(cherry picked from commit 03847eb8259291b4ff1bd840bd779d0699d71f96)
-
-Conflicts:
-	libavformat/utils.c
-
-Upstream-Status: Backport
-
-Signed-off-by: Yue Tao <yue.tao@windriver.com>
-
----
- libavformat/utils.c |    4 ++--
- 1 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/libavformat/utils.c b/libavformat/utils.c
-index 7940037..be73c4a 100644
---- a/gst-libs/ext/libav/libavformat/utils.c
-+++ b/gst-libs/ext/libav/libavformat/utils.c
-@@ -459,7 +459,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
- {
-     AVProbeData pd = { filename ? filename : "", NULL, -offset };
-     unsigned char *buf = NULL;
--    int ret = 0, probe_size;
-+    int ret = 0, probe_size, buf_offset = 0;
- 
-     if (!max_probe_size) {
-         max_probe_size = PROBE_BUF_MAX;
-@@ -499,7 +499,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
-             score = 0;
-             ret = 0;            /* error was end of file, nothing read */
-         }
--        pd.buf_size += ret;
-+        pd.buf_size = buf_offset += ret;
-         pd.buf = &buf[offset];
- 
-         memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
deleted file mode 100644
index d90bafa..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From 1f41cffe1e3e79620f587545bdfcbd7e6e68ed29 Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Sun, 11 Nov 2012 00:01:24 +0100
-Subject: [PATCH] mjpegdec: check SE.
-
-Upstream-Status: Backport
-
-Commit 1f41cffe1e3e79620f587545bdfcbd7e6e68ed29 release/1.1
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/mjpegdec.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
-index 6b5266d..0a71a6f 100644
---- a/gst-libs/ext/libav/libavcodec/mjpegdec.c
-+++ b/gst-libs/ext/libav/libavcodec/mjpegdec.c
-@@ -905,6 +905,11 @@ static int mjpeg_decode_scan_progressive
-     int16_t *quant_matrix = s->quant_matrixes[ s->quant_index[c] ];
-     GetBitContext mb_bitmask_gb;
- 
-+    if (se > 63) {
-+        av_log(s->avctx, AV_LOG_ERROR, "SE %d is too large\n", se);
-+        return AVERROR_INVALIDDATA;
-+    }
-+
-     if (mb_bitmask) {
-         init_get_bits(&mb_bitmask_gb, mb_bitmask, s->mb_width*s->mb_height);
-     }
--- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
deleted file mode 100644
index 1041347..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From 28bf685bfc6d0c744369cdf367f61a78d80d0b01 Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Thu, 15 Nov 2012 16:41:28 +0100
-Subject: [PATCH] pgssubdec: check RLE size before copying. Fix out of array
- accesses
-
-Upstream-Status: Backport
-
-Commit 28bf685bfc6d0c744369cdf367f61a78d80d0b01 release/1.1
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit c0d68be555f5858703383040e04fcd6529777061)
----
- libavcodec/pgssubdec.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
-index 728f178..26a3c2a 100644
---- a/gst-libs/ext/libav/libavcodec/pgssubdec.c
-+++ b/gst-libs/ext/libav/libavcodec/pgssubdec.c
-@@ -202,6 +202,11 @@ static int parse_picture_segment(AVCodec
-         return -1;
-     }
- 
-+    if (buf_size > rle_bitmap_len) {
-+        av_log(avctx, AV_LOG_ERROR, "too much RLE data\n");
-+        return AVERROR_INVALIDDATA;
-+    }
-+
-     ctx->picture.w = width;
-     ctx->picture.h = height;
- 
--- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
deleted file mode 100644
index 1e5fb7d..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-gst-ffmpeg: pngdec/filter: dont access out of array elements at the end
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-
-Upstream-Status: Backport 
-
-Signed-off-by: Yue Tao <yue.tao@windriver.com>
----
- libavcodec/pngdec.c |   12 ++++--------
- 1 files changed, 4 insertions(+), 8 deletions(-)
-
-diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
-index 97c0ad1..193e35e 100644
---- a/gst-libs/ext/libav/libavcodec/pngdec.c
-+++ b/gst-libs/ext/libav/libavcodec/pngdec.c
-@@ -190,7 +190,7 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w
-     if(bpp >= 2) g = dst[1];\
-     if(bpp >= 3) b = dst[2];\
-     if(bpp >= 4) a = dst[3];\
--    for(; i < size; i+=bpp) {\
-+    for(; i <= size - bpp; i+=bpp) {\
-         dst[i+0] = r = op(r, src[i+0], last[i+0]);\
-         if(bpp == 1) continue;\
-         dst[i+1] = g = op(g, src[i+1], last[i+1]);\
-@@ -206,13 +206,9 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w
-     else if(bpp == 2) UNROLL1(2, op)\
-     else if(bpp == 3) UNROLL1(3, op)\
-     else if(bpp == 4) UNROLL1(4, op)\
--    else {\
--        for (; i < size; i += bpp) {\
--            int j;\
--            for (j = 0; j < bpp; j++)\
--                dst[i+j] = op(dst[i+j-bpp], src[i+j], last[i+j]);\
--        }\
--    }
-+    for (; i < size; i++) {\
-+        dst[i] = op(dst[i-bpp], src[i], last[i]);\
-+    }\
- 
- /* NOTE: 'dst' can be equal to 'last' */
- static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
deleted file mode 100644
index 8c94232..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-gst-ffmpeg: qdm2: check array index before use, fix out of array
- accesses
-
-Upstream-Status: Backport 
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/qdm2.c |    5 +++++
- 1 files changed, 5 insertions(+), 0 deletions(-)
-
-diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
-index 4cf4b2f..1dfb8d5 100644
---- a/gst-libs/ext/libav/libavcodec/qdm2.c
-+++ b/gst-libs/ext/libav/libavcodec/qdm2.c
-@@ -1257,6 +1257,11 @@ static void qdm2_decode_super_block (QDM2Context *q)
-     for (i = 0; packet_bytes > 0; i++) {
-         int j;
- 
-+        if (i>=FF_ARRAY_ELEMS(q->sub_packet_list_A)) {
-+            SAMPLES_NEEDED_2("too many packet bytes");
-+            return;
-+        }
-+
-         q->sub_packet_list_A[i].next = NULL;
- 
-         if (i > 0) {
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
deleted file mode 100644
index 43ffc03..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-gst-ffmpeg: qdm2dec: fix buffer overflow. Fixes NGS00144
-
-This also adds a few lines of code from master that are needed for this fix.
-
-Thanks to Phillip for suggestions to improve the patch.
-Found-by: Phillip Langlois
-
-Upstream-Status: Backport 
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/qdm2.c |    9 +++++++--
- 1 files changed, 7 insertions(+), 2 deletions(-)
-
-diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
-index 3aa9e5b..e000df8 100644
---- a/gst-libs/ext/libav/libavcodec/qdm2.c
-+++ b/gst-libs/ext/libav/libavcodec/qdm2.c
-@@ -76,6 +76,7 @@ do { \
- #define SAMPLES_NEEDED_2(why) \
-      av_log (NULL,AV_LOG_INFO,"This file triggers some missing code. Please contact the developers.\nPosition: %s\n",why);
- 
-+#define QDM2_MAX_FRAME_SIZE 512
- 
- typedef int8_t sb_int8_array[2][30][64];
- 
-@@ -168,7 +169,7 @@ typedef struct {
-     /// I/O data
-     const uint8_t *compressed_data;
-     int compressed_size;
--    float output_buffer[1024];
-+    float output_buffer[QDM2_MAX_FRAME_SIZE * MPA_MAX_CHANNELS * 2];
- 
-     /// Synthesis filter
-     MPADSPContext mpadsp;
-@@ -1819,6 +1820,9 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
-     s->group_order = av_log2(s->group_size) + 1;
-     s->frame_size = s->group_size / 16; // 16 iterations per super block
- 
-+    if (s->frame_size > QDM2_MAX_FRAME_SIZE)
-+        return AVERROR_INVALIDDATA;
-+
-     s->sub_sampling = s->fft_order - 7;
-     s->frequency_range = 255 / (1 << (2 - s->sub_sampling));
- 
-@@ -1887,6 +1891,9 @@ static int qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
-     int ch, i;
-     const int frame_size = (q->frame_size * q->channels);
- 
-+    if((unsigned)frame_size > FF_ARRAY_ELEMS(q->output_buffer)/2)
-+        return -1;
-+
-     /* select input buffer */
-     q->compressed_data = in;
-     q->compressed_size = q->checksum_size;
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
deleted file mode 100644
index 7e58afc..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From 391e0fc6c90ced6656b74f50f3a487b6dc76ea63 Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Thu, 29 Nov 2012 15:18:17 +0100
-Subject: [PATCH] roqvideodec: check dimensions validity
-
-Upstream-Status: Backport
-
-Commit 391e0fc6c90ced6656b74f50f3a487b6dc76ea63 release/0.7
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit 3ae610451170cd5a28b33950006ff0bd23036845)
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/roqvideodec.c | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c
-index f0977f6..4e34231 100644
---- a/gst-libs/ext/libav/libavcodec/roqvideodec.c
-+++ b/gst-libs/ext/libav/libavcodec/roqvideodec.c
-@@ -157,6 +157,12 @@ static av_cold int roq_decode_init(AVCodecContext *avctx)
-     RoqContext *s = avctx->priv_data;
- 
-     s->avctx = avctx;
-+
-+    if (avctx->width%16 || avctx->height%16) {
-+         av_log_ask_for_sample(avctx, "dimensions not being a multiple of 16 are unsupported\n");
-+         return AVERROR_PATCHWELCOME;
-+    }
-+
-     s->width = avctx->width;
-     s->height = avctx->height;
-     avcodec_get_frame_defaults(&s->frames[0]);
--- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
deleted file mode 100644
index 15b1614..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-gst-ffmpeg: smackerdec: Check that the last indexes are within the
- table.
-
-Fixes CVE-2011-3944
-
-Upstream-Status: Backport 
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/smacker.c |    5 +++++
- 1 files changed, 5 insertions(+), 0 deletions(-)
-
-diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
-index 30f99b4..2a8bae8 100644
---- a/gst-libs/ext/libav/libavcodec/smacker.c
-+++ b/gst-libs/ext/libav/libavcodec/smacker.c
-@@ -259,6 +259,11 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
-     if(ctx.last[0] == -1) ctx.last[0] = huff.current++;
-     if(ctx.last[1] == -1) ctx.last[1] = huff.current++;
-     if(ctx.last[2] == -1) ctx.last[2] = huff.current++;
-+    if(huff.current > huff.length){
-+        ctx.last[0] = ctx.last[1] = ctx.last[2] = 1;
-+        av_log(smk->avctx, AV_LOG_ERROR, "bigtree damaged\n");
-+        return -1;
-+    }
- 
-     *recodes = huff.values;
- 
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
deleted file mode 100644
index a1989cf..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-gst-ffmpeg: vp3: Copy all 3 frames for thread updates.
-
-This fixes a double release of the current frame on deinit.
-Fixes CVE-2011-3934
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-
-Upstream-Status: Backport
-
-Signed-off-by: Yue.Tao <yue.tao@windriver.com>
-
----
- libavcodec/vp3.c |    2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
-
-diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
-index 738ae9f..b5daafc 100644
---- a/gst-libs/ext/libav/libavcodec/vp3.c
-+++ b/gst-libs/ext/libav/libavcodec/vp3.c
-@@ -1859,7 +1859,7 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
-         ||s->width != s1->width
-         ||s->height!= s1->height) {
-         if (s != s1)
--            copy_fields(s, s1, golden_frame, current_frame);
-+            copy_fields(s, s1, golden_frame, keyframe);
-         return -1;
-     }
- 
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
deleted file mode 100644
index e83d8f4..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
+++ /dev/null
@@ -1,183 +0,0 @@
-gst-ffmpeg: vp3: fix oob read for negative tokens and memleaks on error.
-
-Upstream-Status: Backport 
-
-Signed-off-by: Yue.Tao <yue.tao@windriver.com>
-
----
- libavcodec/vp3.c |   59 +++++++++++++++++++++++++++++++++++++++++------------
- 1 files changed, 45 insertions(+), 14 deletions(-)
-
-diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
-index 36715bb..ce14e63 100644
---- a/gst-libs/ext/libav/libavcodec/vp3.c
-+++ b/gst-libs/ext/libav/libavcodec/vp3.c
-@@ -45,6 +45,7 @@
- #define FRAGMENT_PIXELS 8
- 
- static av_cold int vp3_decode_end(AVCodecContext *avctx);
-+static void vp3_decode_flush(AVCodecContext *avctx);
- 
- //FIXME split things out into their own arrays
- typedef struct Vp3Fragment {
-@@ -890,7 +891,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
-             /* decode a VLC into a token */
-             token = get_vlc2(gb, vlc_table, 11, 3);
-             /* use the token to get a zero run, a coefficient, and an eob run */
--            if (token <= 6) {
-+            if ((unsigned) token <= 6U) {
-                 eob_run = eob_run_base[token];
-                 if (eob_run_get_bits[token])
-                     eob_run += get_bits(gb, eob_run_get_bits[token]);
-@@ -908,7 +909,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
-                     coeff_i        += eob_run;
-                     eob_run = 0;
-                 }
--            } else {
-+            } else if (token >= 0) {
-                 bits_to_get = coeff_get_bits[token];
-                 if (bits_to_get)
-                     bits_to_get = get_bits(gb, bits_to_get);
-@@ -942,6 +943,10 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
-                 for (i = coeff_index+1; i <= coeff_index+zero_run; i++)
-                     s->num_coded_frags[plane][i]--;
-                 coeff_i++;
-+            } else {
-+                av_log(s->avctx, AV_LOG_ERROR,
-+                       "Invalid token %d\n", token);
-+                return -1;
-             }
-     }
- 
-@@ -991,6 +996,8 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
-     /* unpack the Y plane DC coefficients */
-     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0,
-         0, residual_eob_run);
-+    if (residual_eob_run < 0)
-+        return residual_eob_run;
- 
-     /* reverse prediction of the Y-plane DC coefficients */
-     reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]);
-@@ -998,8 +1005,12 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
-     /* unpack the C plane DC coefficients */
-     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
-         1, residual_eob_run);
-+    if (residual_eob_run < 0)
-+        return residual_eob_run;
-     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
-         2, residual_eob_run);
-+    if (residual_eob_run < 0)
-+        return residual_eob_run;
- 
-     /* reverse prediction of the C-plane DC coefficients */
-     if (!(s->avctx->flags & CODEC_FLAG_GRAY))
-@@ -1036,11 +1047,17 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
-     for (i = 1; i <= 63; i++) {
-             residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i,
-                 0, residual_eob_run);
-+            if (residual_eob_run < 0)
-+                return residual_eob_run;
- 
-             residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
-                 1, residual_eob_run);
-+            if (residual_eob_run < 0)
-+                return residual_eob_run;
-             residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
-                 2, residual_eob_run);
-+            if (residual_eob_run < 0)
-+                return residual_eob_run;
-     }
- 
-     return 0;
-@@ -1777,10 +1794,15 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
-     Vp3DecodeContext *s = dst->priv_data, *s1 = src->priv_data;
-     int qps_changed = 0, i, err;
- 
-+#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
-+
-     if (!s1->current_frame.data[0]
-         ||s->width != s1->width
--        ||s->height!= s1->height)
-+        ||s->height!= s1->height) {
-+        if (s != s1)
-+            copy_fields(s, s1, golden_frame, current_frame);
-         return -1;
-+    }
- 
-     if (s != s1) {
-         // init tables if the first frame hasn't been decoded
-@@ -1796,8 +1818,6 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
-             memcpy(s->motion_val[1], s1->motion_val[1], c_fragment_count * sizeof(*s->motion_val[1]));
-         }
- 
--#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
--
-         // copy previous frame data
-         copy_fields(s, s1, golden_frame, dsp);
- 
-@@ -1987,9 +2007,6 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
-     Vp3DecodeContext *s = avctx->priv_data;
-     int i;
- 
--    if (avctx->is_copy && !s->current_frame.data[0])
--        return 0;
--
-     av_free(s->superblock_coding);
-     av_free(s->all_fragments);
-     av_free(s->coded_fragment_list[0]);
-@@ -2016,12 +2033,7 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
-     free_vlc(&s->motion_vector_vlc);
- 
-     /* release all frames */
--    if (s->golden_frame.data[0])
--        ff_thread_release_buffer(avctx, &s->golden_frame);
--    if (s->last_frame.data[0] && s->last_frame.type != FF_BUFFER_TYPE_COPY)
--        ff_thread_release_buffer(avctx, &s->last_frame);
--    /* no need to release the current_frame since it will always be pointing
--     * to the same frame as either the golden or last frame */
-+    vp3_decode_flush(avctx);
- 
-     return 0;
- }
-@@ -2341,6 +2353,23 @@ static void vp3_decode_flush(AVCodecContext *avctx)
-         ff_thread_release_buffer(avctx, &s->current_frame);
- }
- 
-+static int vp3_init_thread_copy(AVCodecContext *avctx)
-+{
-+    Vp3DecodeContext *s = avctx->priv_data;
-+
-+    s->superblock_coding      = NULL;
-+    s->all_fragments          = NULL;
-+    s->coded_fragment_list[0] = NULL;
-+    s->dct_tokens_base        = NULL;
-+    s->superblock_fragments   = NULL;
-+    s->macroblock_coding      = NULL;
-+    s->motion_val[0]          = NULL;
-+    s->motion_val[1]          = NULL;
-+    s->edge_emu_buffer        = NULL;
-+
-+    return 0;
-+}
-+
- AVCodec ff_theora_decoder = {
-     .name           = "theora",
-     .type           = AVMEDIA_TYPE_VIDEO,
-@@ -2352,6 +2381,7 @@ AVCodec ff_theora_decoder = {
-     .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
-     .flush = vp3_decode_flush,
-     .long_name = NULL_IF_CONFIG_SMALL("Theora"),
-+    .init_thread_copy      = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
-     .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
- };
- #endif
-@@ -2367,5 +2397,6 @@ AVCodec ff_vp3_decoder = {
-     .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
-     .flush = vp3_decode_flush,
-     .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"),
-+    .init_thread_copy      = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
-     .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
- };
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
deleted file mode 100644
index 7e4f682..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
+++ /dev/null
@@ -1,51 +0,0 @@
-From 2cac35086c9e103fa98960c546d5017e7363803a Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Fri, 25 Jan 2013 06:11:59 +0100
-Subject: [PATCH] vqavideo: check chunk sizes before reading chunks
-
-Upstream-Status: Backport
-
-Commit 2cac35086c9e103fa98960c546d5017e7363803a release/0.7
-
-Fixes out of array writes
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-(cherry picked from commit ab6c9332bfa1e20127a16392a0b85a4aa4840889)
-
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
----
- libavcodec/vqavideo.c |   10 ++++++++++
- 1 files changed, 10 insertions(+), 0 deletions(-)
-
-diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
-index d1eab5b..6e1ce6c 100644
---- a/gst-libs/ext/libav/libavcodec/vqavideo.c
-+++ b/gst-libs/ext/libav/libavcodec/vqavideo.c
-@@ -527,6 +527,11 @@ static void vqa_decode_chunk(VqaContext *s)
-         chunk_size = AV_RB32(&s->buf[cbp0_chunk + 4]);
-         cbp0_chunk += CHUNK_PREAMBLE_SIZE;
- 
-+        if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
-+            av_log(s->avctx, AV_LOG_ERROR, "cbp0 chunk too large (0x%X bytes)\n", chunk_size);
-+            return AVERROR_INVALIDDATA;
-+        }
-+
-         /* accumulate partial codebook */
-         memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
-             &s->buf[cbp0_chunk], chunk_size);
-@@ -550,6 +555,11 @@ static void vqa_decode_chunk(VqaContext *s)
-         chunk_size = AV_RB32(&s->buf[cbpz_chunk + 4]);
-         cbpz_chunk += CHUNK_PREAMBLE_SIZE;
- 
-+        if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
-+            av_log(s->avctx, AV_LOG_ERROR, "cbpz chunk too large (0x%X bytes)\n", chunk_size);
-+            return AVERROR_INVALIDDATA;
-+        }
-+
-         /* accumulate partial codebook */
-         memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
-             &s->buf[cbpz_chunk], chunk_size);
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
deleted file mode 100644
index c8bafd5..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-From 6043c431c97d55173f339fafbd033d3c0642e2e9 Mon Sep 17 00:00:00 2001
-From: Michael Niedermayer <michaelni@gmx.at>
-Date: Fri, 3 Oct 2014 01:50:27 +0200
-Subject: [PATCH 2/2] avcodec/mjpegdec: check bits per pixel for changes
- similar to dimensions
-
-Upstream-Status: Backport
-
-Fixes out of array accesses
-Fixes: asan_heap-oob_16668e9_2_asan_heap-oob_16668e9_346_miss_congeniality_pegasus_mjpg.avi
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-
-Conflicts:
-	libavcodec/mjpegdec.c
----
- libavcodec/mjpegdec.c | 15 ++++++++-------
- 1 file changed, 8 insertions(+), 7 deletions(-)
-
-diff --git a/gst-libs/ext/libav/libavcodec/mjpegdec.c b/gst-libs/ext/libav/libavcodec/mjpegdec.c
-index 84343c0..c0137d8 100644
---- a/gst-libs/ext/libav/libavcodec/mjpegdec.c
-+++ b/gst-libs/ext/libav/libavcodec/mjpegdec.c
-@@ -210,16 +210,16 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
- 
- int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
- {
--    int len, nb_components, i, width, height, pix_fmt_id;
-+    int len, nb_components, i, bits, width, height, pix_fmt_id;
- 
-     /* XXX: verify len field validity */
-     len = get_bits(&s->gb, 16);
--    s->bits= get_bits(&s->gb, 8);
-+    bits= get_bits(&s->gb, 8);
- 
--    if(s->pegasus_rct) s->bits=9;
--    if(s->bits==9 && !s->pegasus_rct) s->rct=1;    //FIXME ugly
-+    if(s->pegasus_rct) bits=9;
-+    if(bits==9 && !s->pegasus_rct) s->rct=1;    //FIXME ugly
- 
--    if (s->bits != 8 && !s->lossless){
-+    if (bits != 8 && !s->lossless){
-         av_log(s->avctx, AV_LOG_ERROR, "only 8 bits/component accepted\n");
-         return -1;
-     }
-@@ -239,7 +239,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
-     if (nb_components <= 0 ||
-         nb_components > MAX_COMPONENTS)
-         return -1;
--    if (s->ls && !(s->bits <= 8 || nb_components == 1)){
-+    if (s->ls && !(bits <= 8 || nb_components == 1)){
-         av_log(s->avctx, AV_LOG_ERROR, "only <= 8 bits/component or 16-bit gray accepted for JPEG-LS\n");
-         return -1;
-     }
-@@ -272,10 +272,11 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
- 
-     /* if different size, realloc/alloc picture */
-     /* XXX: also check h_count and v_count */
--    if (width != s->width || height != s->height) {
-+    if (width != s->width || height != s->height || bits != s->bits) {
-         av_freep(&s->qscale_table);
- 
-         s->width = width;
-+        s->bits= bits;
-         s->height = height;
-         s->interlaced = 0;
- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch
deleted file mode 100644
index 9ef6f7c..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-Disable yasm for libav when --disable-yasm
-
-Upstream-Status: Inappropriate [configuration]
-
-Signed-off-by: Shane Wang <shane.wang@intel.com>
-
-diff -r f2f8f74c6e30 configure.ac
---- a/configure.ac	Thu Dec 22 23:56:09 2011 +0800
-+++ b/configure.ac	Thu Dec 22 23:57:37 2011 +0800
-@@ -325,6 +325,12 @@
-         --enable-gpl"
-   fi
- 
-+ AC_ARG_ENABLE(yasm,
-+              [AC_HELP_STRING([--disable-yasm], [disable use of yasm assembler])])
-+  if test "x$enable_yasm" = "xno"; then
-+    embffmpeg_configure_args="$embffmpeg_configure_args --disable-yasm"
-+  fi
-+
-   # if we are cross-compiling, tell ffmpeg so
-   target_os=`echo $host_os | sed 's/-gnu//'`
-   if test "x$cross_compiling" = xyes; then
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
deleted file mode 100644
index 3c8d8e3..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-gst-ffmpeg: Security Advisory - ffmpeg - CVE-2013-0855
-
-Upstream-Status: Backport 
-
-Signed-off-by: Yue Tao <yue.tao@windriver.com>
-
-diff --git a/gst-libs/ext/libav/libavcodec/alac.c.old b/gst-libs/ext/libav/libavcodec/alac.c
-index 2a0df8c..bcbd56d 100644
---- a/gst-libs/ext/libav/libavcodec/alac.c.old
-+++ b/gst-libs/ext/libav/libavcodec/alac.c
-@@ -87,18 +87,44 @@ typedef struct {
-     int wasted_bits;
- } ALACContext;
- 
--static void allocate_buffers(ALACContext *alac)
-+static av_cold int alac_decode_close(AVCodecContext *avctx)
-+{
-+    ALACContext *alac = avctx->priv_data;
-+
-+    int chan;
-+    for (chan = 0; chan < MAX_CHANNELS; chan++) {
-+        av_freep(&alac->predicterror_buffer[chan]);
-+        av_freep(&alac->outputsamples_buffer[chan]);
-+        av_freep(&alac->wasted_bits_buffer[chan]);
-+    }
-+
-+    return 0;
-+}
-+
-+static int allocate_buffers(ALACContext *alac)
- {
-     int chan;
-+    int buf_size;
-+
-+    if (alac->setinfo_max_samples_per_frame > INT_MAX / sizeof(int32_t))
-+        goto buf_alloc_fail;
-+    buf_size = alac->setinfo_max_samples_per_frame * sizeof(int32_t);
-+
-     for (chan = 0; chan < MAX_CHANNELS; chan++) {
--        alac->predicterror_buffer[chan] =
--            av_malloc(alac->setinfo_max_samples_per_frame * 4);
- 
--        alac->outputsamples_buffer[chan] =
--            av_malloc(alac->setinfo_max_samples_per_frame * 4);
-+        FF_ALLOC_OR_GOTO(alac->avctx, alac->predicterror_buffer[chan],
-+                         buf_size, buf_alloc_fail);
- 
--        alac->wasted_bits_buffer[chan] = av_malloc(alac->setinfo_max_samples_per_frame * 4);
-+        FF_ALLOC_OR_GOTO(alac->avctx, alac->outputsamples_buffer[chan],
-+                         buf_size, buf_alloc_fail);
-+
-+        FF_ALLOC_OR_GOTO(alac->avctx, alac->wasted_bits_buffer[chan],
-+                         buf_size, buf_alloc_fail);
-     }
-+    return 0;
-+buf_alloc_fail:
-+    alac_decode_close(alac->avctx);
-+    return AVERROR(ENOMEM);
- }
- 
- static int alac_set_info(ALACContext *alac)
-@@ -131,8 +157,6 @@ static int alac_set_info(ALACContext *alac)
-     bytestream_get_be32(&ptr);      /* bitrate ? */
-     bytestream_get_be32(&ptr);      /* samplerate */
- 
--    allocate_buffers(alac);
--
-     return 0;
- }
- 
-@@ -659,6 +683,7 @@ static int alac_decode_frame(AVCodecContext *avctx,
- 
- static av_cold int alac_decode_init(AVCodecContext * avctx)
- {
-+    int ret;
-     ALACContext *alac = avctx->priv_data;
-     alac->avctx = avctx;
-     alac->numchannels = alac->avctx->channels;
-@@ -674,18 +699,9 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
-         return -1;
-     }
- 
--    return 0;
--}
--
--static av_cold int alac_decode_close(AVCodecContext *avctx)
--{
--    ALACContext *alac = avctx->priv_data;
--
--    int chan;
--    for (chan = 0; chan < MAX_CHANNELS; chan++) {
--        av_freep(&alac->predicterror_buffer[chan]);
--        av_freep(&alac->outputsamples_buffer[chan]);
--        av_freep(&alac->wasted_bits_buffer[chan]);
-+    if ((ret = allocate_buffers(alac)) < 0) {
-+        av_log(avctx, AV_LOG_ERROR, "Error allocating buffers\n");
-+        return ret;
-     }
- 
-     return 0;
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
deleted file mode 100644
index aa385f5..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-avcodec/cdgraphics: check buffer size before use
-
-Fixes out of array accesses
-
-Backported from:http://git.videolan.org/?p=ffmpeg.git;a=commit;h=ad002e1a13a8df934bd6cb2c84175a4780ab8942
-
-Upstream-Status: Backport
-
-Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
-Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-Signed-off-by: Ming Liu <ming.liu@windriver.com>
-
-diff -urpN a/gst-libs/ext/libav/libavcodec/cdgraphics.c b/gst-libs/ext/libav/libavcodec/cdgraphics.c
---- a/gst-libs/ext/libav/libavcodec/cdgraphics.c	2013-07-18 13:17:08.399876575 +0800
-+++ b/gst-libs/ext/libav/libavcodec/cdgraphics.c	2013-07-18 13:18:05.880502267 +0800
-@@ -291,7 +291,9 @@ static int cdg_decode_frame(AVCodecConte
-     inst    = bytestream_get_byte(&buf);
-     inst    &= CDG_MASK;
-     buf += 2;  /// skipping 2 unneeded bytes
--    bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
-+
-+    if (buf_size > CDG_HEADER_SIZE)
-+        bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
- 
-     if ((command & CDG_MASK) == CDG_COMMAND) {
-         switch (inst) {
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
deleted file mode 100644
index ade24dc..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-Backport http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=5f654897e325349dacf2546674e0510bb72ecb50;hp=250cebeb3b348c3da71f9972eb500d6005dc01f1
-
-Fixes these errors on x86
-
-libavcodec/x86/h264_qpel_mmx.c: Assembler messages:
-libavcodec/x86/h264_qpel_mmx.c:1294: Error: operand type mismatch for `cmp'
-libavcodec/x86/h264_qpel_mmx.c:1294: Error: operand type mismatch for `cmp'
-libavcodec/x86/h264_qpel_mmx.c:1298: Error: operand type mismatch for `cmp'
-libavcodec/x86/h264_qpel_mmx.c:1298: Error: operand type mismatch for `cmp'
-libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
-libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
-libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
-make[5]: *** [libavcodec/x86/dsputil_mmx.o] Error 1
-
-
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
-Upstream-Status: Backport
-Index: gst-ffmpeg-0.10.13/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c
-===================================================================
---- gst-ffmpeg-0.10.13.orig/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c	2012-03-30 11:39:41.324522051 -0700
-+++ gst-ffmpeg-0.10.13/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c	2012-03-30 11:54:08.152564075 -0700
-@@ -398,7 +398,7 @@
-             "2:                         \n\t"\
-             \
-             : "+a"(src), "+c"(dst)\
--            : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\
-+            : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "rm"(h)\
-             : "memory"\
-         );\
-         src += 4-(h+5)*srcStride;\
-@@ -446,7 +446,7 @@
-             QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 15*48)\
-             "2:                     \n\t"\
-             : "+a"(src)\
--            : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)\
-+            : "c"(tmp), "S"((x86_reg)srcStride), "rm"(size)\
-             : "memory"\
-             );\
-         tmp += 4;\
-@@ -823,7 +823,7 @@
-         "2:                          \n\t"\
-         \
-         : "+a"(src), "+c"(dst)\
--        : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\
-+        : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "rm"(h)\
-         : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
-                        "%xmm4", "%xmm5", "%xmm6", "%xmm7",)\
-           "memory"\
-@@ -878,7 +878,7 @@
-             QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 15*48)
-             "2:                         \n\t"
-             : "+a"(src)
--            : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)
-+            : "c"(tmp), "S"((x86_reg)srcStride), "rm"(size)
-             : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3",
-                            "%xmm4", "%xmm5", "%xmm6", "%xmm7",)
-               "memory"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch
deleted file mode 100644
index 1860752..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch
+++ /dev/null
@@ -1,9304 +0,0 @@
-Taken from gentoo patchset:
-http://dev.gentoo.org/~tetromino/distfiles/gst-plugins-ffmpeg/gst-ffmpeg-0.10.13_p2012.11-libav-9-patches.tar.xz
-
-Upstream-Status: Pending
-
-Contains following changes, rebased to apply on top of our changes
-0002-Fix-includes-for-systemwide-build.patch
-0003-libav-Switch-to-non-deprecated-symbols.patch
-0005-av-Update-for-some-constant-changes.patch
-0006-av-Remove-palette-support-for-now.patch
-0007-av-Port-remaining-simple-bits.patch
-0008-av-Use-av_codec_is_-en-de-coder-API-instead-of-priva.patch
-0009-avprotocol-Port-from-the-URL-protocol-handler-to-san.patch
-0010-avdec-don-t-wait-for-keyframe.patch
-
-Following changes were skipped:
-0001-Partially-revert-commit-0300801b.patch
-0004-av-update-to-use-AVOption-variants.patch
-0011-av_get_bits_per_sample_format-was-removed-in-libav-9.patch
-
-Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
-
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.c
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.c	2011-10-31 11:14:03.000000000 +0100
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.c	2014-08-08 15:26:07.872857555 +0200
-@@ -151,9 +151,6 @@
- #endif
-   gst_ffmpegaudioresample_register (plugin);
- 
--  av_register_protocol2 (&gstreamer_protocol, sizeof (URLProtocol));
--  av_register_protocol2 (&gstpipe_protocol, sizeof (URLProtocol));
--
-   /* Now we can return the pointer to the newly created Plugin object. */
-   return TRUE;
- }
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.h gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.h
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.h	2011-05-17 10:53:16.000000000 +0200
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.h	2014-08-08 15:26:07.872857555 +0200
-@@ -58,10 +58,13 @@
- int gst_ffmpeg_avcodec_close (AVCodecContext *avctx);
- int gst_ffmpeg_av_find_stream_info(AVFormatContext *ic);
- 
--G_END_DECLS
-+int gst_ffmpegdata_open (GstPad * pad, int flags, AVIOContext ** context);
-+int gst_ffmpegdata_close (AVIOContext * h);
-+typedef struct _GstFFMpegPipe GstFFMpegPipe;
-+int gst_ffmpeg_pipe_open (GstFFMpegPipe *ffpipe, int flags, AVIOContext ** context);
-+int gst_ffmpeg_pipe_close (AVIOContext * h);
- 
--extern URLProtocol gstreamer_protocol;
--extern URLProtocol gstpipe_protocol;
-+G_END_DECLS
- 
- /* use GST_FFMPEG URL_STREAMHEADER with URL_WRONLY if the first
-  * buffer should be used as streamheader property on the pad's caps. */
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcfg.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcfg.c
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcfg.c	2011-07-12 16:35:27.000000000 +0200
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcfg.c	2014-08-08 15:24:17.899853612 +0200
-@@ -147,7 +147,6 @@
-       {FF_DCT_FASTINT, "Fast Integer", "fastint"},
-       {FF_DCT_INT, "Accurate Integer", "int"},
-       {FF_DCT_MMX, "MMX", "mmx"},
--      {FF_DCT_MLIB, "MLIB", "mlib"},
-       {FF_DCT_ALTIVEC, "ALTIVEC", "altivec"},
-       {FF_DCT_FAAN, "FAAN", "faan"},
-       {0, NULL, NULL},
-@@ -173,8 +172,6 @@
-       {FF_IDCT_SIMPLE, "Simple", "simple"},
-       {FF_IDCT_SIMPLEMMX, "Simple MMX", "simplemmx"},
-       {FF_IDCT_LIBMPEG2MMX, "LIBMPEG2MMX", "libmpeg2mmx"},
--      {FF_IDCT_PS2, "PS2", "ps2"},
--      {FF_IDCT_MLIB, "MLIB", "mlib"},
-       {FF_IDCT_ARM, "ARM", "arm"},
-       {FF_IDCT_ALTIVEC, "ALTIVEC", "altivec"},
-       {FF_IDCT_SH4, "SH4", "sh4"},
-@@ -263,16 +260,11 @@
- 
-   if (!ffmpeg_flags_type) {
-     static const GFlagsValue ffmpeg_flags[] = {
--      {CODEC_FLAG_OBMC, "Use overlapped block motion compensation (h263+)",
--          "obmc"},
-       {CODEC_FLAG_QSCALE, "Use fixed qscale", "qscale"},
-       {CODEC_FLAG_4MV, "Allow 4 MV per MB", "4mv"},
--      {CODEC_FLAG_H263P_AIV, "H.263 alternative inter VLC", "aiv"},
-       {CODEC_FLAG_QPEL, "Quartel Pel Motion Compensation", "qpel"},
-       {CODEC_FLAG_GMC, "GMC", "gmc"},
-       {CODEC_FLAG_MV0, "Always try a MB with MV (0,0)", "mv0"},
--      {CODEC_FLAG_PART,
--          "Store MV, DC and AC coefficients in seperate partitions", "part"},
-       {CODEC_FLAG_LOOP_FILTER, "Loop filter", "loop-filter"},
-       {CODEC_FLAG_GRAY, "Only decode/encode grayscale", "gray"},
-       {CODEC_FLAG_NORMALIZE_AQP,
-@@ -282,13 +274,9 @@
-           "global-headers"},
-       {CODEC_FLAG_AC_PRED, "H263 Advanced Intra Coding / MPEG4 AC prediction",
-           "aic"},
--      {CODEC_FLAG_H263P_UMV, "Unlimited Motion Vector", "umv"},
-       {CODEC_FLAG_CBP_RD, "Rate Distoration Optimization for CBP", "cbp-rd"},
-       {CODEC_FLAG_QP_RD, "Rate Distoration Optimization for QP selection",
-           "qp-rd"},
--      {CODEC_FLAG_H263P_SLICE_STRUCT, "H263 slice struct", "ss"},
--      {CODEC_FLAG_SVCD_SCAN_OFFSET,
--          "Reserve space for SVCD scan offset user data", "scanoffset"},
-       {CODEC_FLAG_CLOSED_GOP, "Closed GOP", "closedgop"},
-       {0, NULL, NULL},
-     };
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c	2011-10-31 11:14:03.000000000 +0100
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c	2014-08-08 15:31:30.968869139 +0200
-@@ -25,8 +25,10 @@
- #include <gst/gst.h>
- #ifdef HAVE_FFMPEG_UNINSTALLED
- #include <avcodec.h>
-+#include <channel_layout.h>
- #else
- #include <libavcodec/avcodec.h>
-+#include <libavutil/channel_layout.h>
- #endif
- #include <string.h>
- 
-@@ -35,43 +37,6 @@
- 
- #include <gst/pbutils/codec-utils.h>
- 
--/*
-- * Read a palette from a caps.
-- */
--
--static void
--gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
--{
--  GstStructure *str = gst_caps_get_structure (caps, 0);
--  const GValue *palette_v;
--  const GstBuffer *palette;
--
--  /* do we have a palette? */
--  if ((palette_v = gst_structure_get_value (str, "palette_data")) && context) {
--    palette = gst_value_get_buffer (palette_v);
--    if (GST_BUFFER_SIZE (palette) >= AVPALETTE_SIZE) {
--      if (context->palctrl)
--        av_free (context->palctrl);
--      context->palctrl = av_malloc (sizeof (AVPaletteControl));
--      context->palctrl->palette_changed = 1;
--      memcpy (context->palctrl->palette, GST_BUFFER_DATA (palette),
--          AVPALETTE_SIZE);
--    }
--  }
--}
--
--static void
--gst_ffmpeg_set_palette (GstCaps * caps, AVCodecContext * context)
--{
--  if (context->palctrl) {
--    GstBuffer *palette = gst_buffer_new_and_alloc (AVPALETTE_SIZE);
--
--    memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
--        AVPALETTE_SIZE);
--    gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, palette, NULL);
--  }
--}
--
- /* IMPORTANT: Keep this sorted by the ffmpeg channel masks */
- static const struct
- {
-@@ -79,26 +44,26 @@
-   GstAudioChannelPosition gst;
- } _ff_to_gst_layout[] = {
-   {
--  CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
--  CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
--  CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
--  CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
--  CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
--  CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
--  CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
--  CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
--  CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
--  CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
--  CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
--  CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
--  CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
--  CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
--  CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
--  CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
--  CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
--  CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
--  CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
--  CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
-+  AV_CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
-+  AV_CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
-+  AV_CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
-+  AV_CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
-+  AV_CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
-+  AV_CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
-+  AV_CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
-+  AV_CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
-+  AV_CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
-+  AV_CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
-+  AV_CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
-+  AV_CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
-+  AV_CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
-+  AV_CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
-+  AV_CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
-+  AV_CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
-+  AV_CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
-+  AV_CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
-+  AV_CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
-+  AV_CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
- };
- 
- static GstAudioChannelPosition *
-@@ -342,8 +307,8 @@
- 
-     if (channel_layout == 0) {
-       const guint64 default_channel_set[] = {
--        0, 0, CH_LAYOUT_SURROUND, CH_LAYOUT_QUAD, CH_LAYOUT_5POINT0,
--        CH_LAYOUT_5POINT1, 0, CH_LAYOUT_7POINT1
-+        0, 0, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_5POINT0,
-+        AV_CH_LAYOUT_5POINT1, 0, AV_CH_LAYOUT_7POINT1
-       };
- 
-       switch (codec_id) {
-@@ -1267,8 +1232,6 @@
-     case CODEC_ID_FLIC:
-     case CODEC_ID_VMDVIDEO:
-     case CODEC_ID_VMDAUDIO:
--    case CODEC_ID_SONIC:
--    case CODEC_ID_SONIC_LS:
-     case CODEC_ID_SNOW:
-     case CODEC_ID_VIXL:
-     case CODEC_ID_QPEG:
-@@ -1689,11 +1652,6 @@
-       gst_buffer_unref (data);
-     }
- 
--    /* palette */
--    if (context) {
--      gst_ffmpeg_set_palette (caps, context);
--    }
--
-     GST_LOG ("caps for codec_id=%d: %" GST_PTR_FORMAT, codec_id, caps);
- 
-   } else {
-@@ -1830,9 +1788,6 @@
-             "bpp", G_TYPE_INT, bpp,
-             "depth", G_TYPE_INT, depth,
-             "endianness", G_TYPE_INT, endianness, NULL);
--        if (caps && context) {
--          gst_ffmpeg_set_palette (caps, context);
--        }
-       }
-     } else if (fmt) {
-       caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-yuv",
-@@ -1857,7 +1812,7 @@
-  */
- 
- static GstCaps *
--gst_ffmpeg_smpfmt_to_caps (enum SampleFormat sample_fmt,
-+gst_ffmpeg_smpfmt_to_caps (enum AVSampleFormat sample_fmt,
-     AVCodecContext * context, enum CodecID codec_id)
- {
-   GstCaps *caps = NULL;
-@@ -1867,22 +1822,22 @@
-   gboolean signedness = FALSE;
- 
-   switch (sample_fmt) {
--    case SAMPLE_FMT_S16:
-+    case AV_SAMPLE_FMT_S16:
-       signedness = TRUE;
-       bpp = 16;
-       break;
- 
--    case SAMPLE_FMT_S32:
-+    case AV_SAMPLE_FMT_S32:
-       signedness = TRUE;
-       bpp = 32;
-       break;
- 
--    case SAMPLE_FMT_FLT:
-+    case AV_SAMPLE_FMT_FLT:
-       integer = FALSE;
-       bpp = 32;
-       break;
- 
--    case SAMPLE_FMT_DBL:
-+    case AV_SAMPLE_FMT_DBL:
-       integer = FALSE;
-       bpp = 64;
-       break;
-@@ -1941,12 +1896,12 @@
-     }
-   } else {
-     GstCaps *temp;
--    enum SampleFormat i;
-+    enum AVSampleFormat i;
-     AVCodecContext ctx = { 0, };
- 
-     ctx.channels = -1;
-     caps = gst_caps_new_empty ();
--    for (i = 0; i <= SAMPLE_FMT_DBL; i++) {
-+    for (i = 0; i <= AV_SAMPLE_FMT_DBL; i++) {
-       temp = gst_ffmpeg_smpfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
-       if (temp != NULL) {
-         gst_caps_append (caps, temp);
-@@ -2049,9 +2004,9 @@
-         gst_structure_get_int (structure, "endianness", &endianness)) {
-       if (endianness == G_BYTE_ORDER) {
-         if (width == 32)
--          context->sample_fmt = SAMPLE_FMT_FLT;
-+          context->sample_fmt = AV_SAMPLE_FMT_FLT;
-         else if (width == 64)
--          context->sample_fmt = SAMPLE_FMT_DBL;
-+          context->sample_fmt = AV_SAMPLE_FMT_DBL;
-       }
-     }
-   } else {
-@@ -2062,9 +2017,9 @@
-         gst_structure_get_int (structure, "endianness", &endianness)) {
-       if ((endianness == G_BYTE_ORDER) && (signedness == TRUE)) {
-         if ((width == 16) && (depth == 16))
--          context->sample_fmt = SAMPLE_FMT_S16;
-+          context->sample_fmt = AV_SAMPLE_FMT_S16;
-         else if ((width == 32) && (depth == 32))
--          context->sample_fmt = SAMPLE_FMT_S32;
-+          context->sample_fmt = AV_SAMPLE_FMT_S32;
-       }
-     }
-   }
-@@ -2190,7 +2145,6 @@
-       } else {
-         if (bpp == 8) {
-           context->pix_fmt = PIX_FMT_PAL8;
--          gst_ffmpeg_get_palette (caps, context);
-         }
-       }
-     }
-@@ -2576,7 +2530,6 @@
-   switch (codec_type) {
-     case AVMEDIA_TYPE_VIDEO:
-       gst_ffmpeg_caps_to_pixfmt (caps, context, codec_id == CODEC_ID_RAWVIDEO);
--      gst_ffmpeg_get_palette (caps, context);
-       break;
-     case AVMEDIA_TYPE_AUDIO:
-       gst_ffmpeg_caps_to_smpfmt (caps, context, FALSE);
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.orig
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.orig	1970-01-01 01:00:00.000000000 +0100
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.orig	2014-08-08 15:30:34.006867097 +0200
-@@ -0,0 +1,3447 @@
-+/* GStreamer
-+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
-+ * This file:
-+ * Copyright (c) 2002-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 <gst/gst.h>
-+#ifdef HAVE_FFMPEG_UNINSTALLED
-+#include <avcodec.h>
-+#include <channel_layout.h>>
-+#else
-+#include <libavcodec/avcodec.h>
-+#include <libavutil/channel_layout.h>
-+#endif
-+#include <string.h>
-+
-+#include "gstffmpeg.h"
-+#include "gstffmpegcodecmap.h"
-+
-+#include <gst/pbutils/codec-utils.h>
-+
-+/*
-+ * Read a palette from a caps.
-+ */
-+
-+static void
-+gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
-+{
-+  GstStructure *str = gst_caps_get_structure (caps, 0);
-+  const GValue *palette_v;
-+  const GstBuffer *palette;
-+
-+  /* do we have a palette? */
-+  if ((palette_v = gst_structure_get_value (str, "palette_data")) && context) {
-+    palette = gst_value_get_buffer (palette_v);
-+    if (GST_BUFFER_SIZE (palette) >= AVPALETTE_SIZE) {
-+      if (context->palctrl)
-+        av_free (context->palctrl);
-+      context->palctrl = av_malloc (sizeof (AVPaletteControl));
-+      context->palctrl->palette_changed = 1;
-+      memcpy (context->palctrl->palette, GST_BUFFER_DATA (palette),
-+          AVPALETTE_SIZE);
-+    }
-+  }
-+}
-+
-+static void
-+gst_ffmpeg_set_palette (GstCaps * caps, AVCodecContext * context)
-+{
-+  if (context->palctrl) {
-+    GstBuffer *palette = gst_buffer_new_and_alloc (AVPALETTE_SIZE);
-+
-+    memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
-+        AVPALETTE_SIZE);
-+    gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, palette, NULL);
-+  }
-+}
-+
-+/* IMPORTANT: Keep this sorted by the ffmpeg channel masks */
-+static const struct
-+{
-+  guint64 ff;
-+  GstAudioChannelPosition gst;
-+} _ff_to_gst_layout[] = {
-+  {
-+  AV_CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
-+  AV_CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
-+  AV_CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
-+  AV_CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
-+  AV_CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
-+  AV_CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
-+  AV_CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
-+  AV_CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
-+  AV_CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
-+  AV_CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
-+  AV_CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
-+  AV_CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
-+  AV_CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
-+  AV_CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
-+  AV_CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
-+  AV_CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
-+  AV_CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
-+  AV_CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
-+  AV_CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
-+  AV_CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
-+};
-+
-+static GstAudioChannelPosition *
-+gst_ff_channel_layout_to_gst (guint64 channel_layout, guint channels)
-+{
-+  guint nchannels = 0, i, j;
-+  GstAudioChannelPosition *pos = NULL;
-+  gboolean none_layout = FALSE;
-+
-+  for (i = 0; i < 64; i++) {
-+    if ((channel_layout & (G_GUINT64_CONSTANT (1) << i)) != 0) {
-+      nchannels++;
-+    }
-+  }
-+
-+  if (channel_layout == 0) {
-+    nchannels = channels;
-+    none_layout = TRUE;
-+  }
-+
-+  if (nchannels != channels) {
-+    GST_ERROR ("Number of channels is different (%u != %u)", channels,
-+        nchannels);
-+    return NULL;
-+  }
-+
-+  pos = g_new (GstAudioChannelPosition, nchannels);
-+
-+  for (i = 0, j = 0; i < G_N_ELEMENTS (_ff_to_gst_layout); i++) {
-+    if ((channel_layout & _ff_to_gst_layout[i].ff) != 0) {
-+      pos[j++] = _ff_to_gst_layout[i].gst;
-+
-+      if (_ff_to_gst_layout[i].gst == GST_AUDIO_CHANNEL_POSITION_NONE)
-+        none_layout = TRUE;
-+    }
-+  }
-+
-+  if (j != nchannels) {
-+    GST_WARNING ("Unknown channels in channel layout - assuming NONE layout");
-+    none_layout = TRUE;
-+  }
-+
-+  if (!none_layout && !gst_audio_check_channel_positions (pos, nchannels)) {
-+    GST_ERROR ("Invalid channel layout %" G_GUINT64_FORMAT
-+        " - assuming NONE layout", channel_layout);
-+    none_layout = TRUE;
-+  }
-+
-+  if (none_layout) {
-+    if (nchannels == 1) {
-+      pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_MONO;
-+    } else if (nchannels == 2) {
-+      pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
-+      pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
-+    } else if (channel_layout == 0) {
-+      g_free (pos);
-+      pos = NULL;
-+    } else {
-+      for (i = 0; i < nchannels; i++)
-+        pos[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
-+    }
-+  }
-+
-+  if (nchannels == 1 && pos[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER) {
-+    GST_DEBUG ("mono common case; won't set channel positions");
-+    g_free (pos);
-+    pos = NULL;
-+  } else if (nchannels == 2 && pos[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT
-+      && pos[1] == GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT) {
-+    GST_DEBUG ("stereo common case; won't set channel positions");
-+    g_free (pos);
-+    pos = NULL;
-+  }
-+
-+  return pos;
-+}
-+
-+/* this macro makes a caps width fixed or unfixed width/height
-+ * properties depending on whether we've got a context.
-+ *
-+ * See below for why we use this.
-+ *
-+ * We should actually do this stuff at the end, like in riff-media.c,
-+ * but I'm too lazy today. Maybe later.
-+ */
-+static GstCaps *
-+gst_ff_vid_caps_new (AVCodecContext * context, enum CodecID codec_id,
-+    const char *mimetype, const char *fieldname, ...)
-+{
-+  GstStructure *structure = NULL;
-+  GstCaps *caps = NULL;
-+  va_list var_args;
-+  gint i;
-+
-+  GST_LOG ("context:%p, codec_id:%d, mimetype:%s", context, codec_id, mimetype);
-+
-+  /* fixed, non probing context */
-+  if (context != NULL && context->width != -1) {
-+    gint num, denom;
-+
-+    caps = gst_caps_new_simple (mimetype,
-+        "width", G_TYPE_INT, context->width,
-+        "height", G_TYPE_INT, context->height, NULL);
-+
-+    num = context->time_base.den / context->ticks_per_frame;
-+    denom = context->time_base.num;
-+
-+    if (!denom) {
-+      GST_LOG ("invalid framerate: %d/0, -> %d/1", num, num);
-+      denom = 1;
-+    }
-+    if (gst_util_fraction_compare (num, denom, 1000, 1) > 0) {
-+      GST_LOG ("excessive framerate: %d/%d, -> 0/1", num, denom);
-+      num = 0;
-+      denom = 1;
-+    }
-+    GST_LOG ("setting framerate: %d/%d", num, denom);
-+    gst_caps_set_simple (caps,
-+        "framerate", GST_TYPE_FRACTION, num, denom, NULL);
-+  } else {
-+    /* so we are after restricted caps in this case */
-+    switch (codec_id) {
-+      case CODEC_ID_H261:
-+      {
-+        caps = gst_caps_new_simple (mimetype,
-+            "width", G_TYPE_INT, 352,
-+            "height", G_TYPE_INT, 288,
-+            "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
-+        gst_caps_append (caps, gst_caps_new_simple (mimetype,
-+                "width", G_TYPE_INT, 176,
-+                "height", G_TYPE_INT, 144,
-+                "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL));
-+        break;
-+      }
-+      case CODEC_ID_H263:
-+      {
-+        /* 128x96, 176x144, 352x288, 704x576, and 1408x1152. slightly reordered
-+         * because we want automatic negotiation to go as close to 320x240 as
-+         * possible. */
-+        const static gint widths[] = { 352, 704, 176, 1408, 128 };
-+        const static gint heights[] = { 288, 576, 144, 1152, 96 };
-+        GstCaps *temp;
-+        gint n_sizes = G_N_ELEMENTS (widths);
-+
-+        caps = gst_caps_new_empty ();
-+        for (i = 0; i < n_sizes; i++) {
-+          temp = gst_caps_new_simple (mimetype,
-+              "width", G_TYPE_INT, widths[i],
-+              "height", G_TYPE_INT, heights[i],
-+              "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
-+
-+          gst_caps_append (caps, temp);
-+        }
-+        break;
-+      }
-+      case CODEC_ID_DVVIDEO:
-+      {
-+        static struct
-+        {
-+          guint32 csp;
-+          gint width, height;
-+          gint par_n, par_d;
-+          gint framerate_n, framerate_d;
-+        } profiles[] = {
-+          {
-+          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 480, 10, 11, 30000, 1001}, {
-+          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 480, 40, 33, 30000, 1001}, {
-+          GST_MAKE_FOURCC ('I', '4', '2', '0'), 720, 576, 59, 54, 25, 1}, {
-+          GST_MAKE_FOURCC ('I', '4', '2', '0'), 720, 576, 118, 81, 25, 1}, {
-+          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 576, 59, 54, 25, 1}, {
-+          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 576, 118, 81, 25, 1}
-+        };
-+        GstCaps *temp;
-+        gint n_sizes = G_N_ELEMENTS (profiles);
-+
-+        caps = gst_caps_new_empty ();
-+        for (i = 0; i < n_sizes; i++) {
-+          temp = gst_caps_new_simple (mimetype,
-+              "width", G_TYPE_INT, profiles[i].width,
-+              "height", G_TYPE_INT, profiles[i].height,
-+              "framerate", GST_TYPE_FRACTION, profiles[i].framerate_n,
-+              profiles[i].framerate_d, "pixel-aspect-ratio", GST_TYPE_FRACTION,
-+              profiles[i].par_n, profiles[i].par_d, NULL);
-+
-+          gst_caps_append (caps, temp);
-+        }
-+        break;
-+      }
-+      case CODEC_ID_DNXHD:
-+      {
-+        caps = gst_caps_new_simple (mimetype,
-+            "width", G_TYPE_INT, 1920,
-+            "height", G_TYPE_INT, 1080,
-+            "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
-+        gst_caps_append (caps, gst_caps_new_simple (mimetype,
-+                "width", G_TYPE_INT, 1280,
-+                "height", G_TYPE_INT, 720,
-+                "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL));
-+        break;
-+      }
-+      default:
-+        break;
-+    }
-+  }
-+
-+  /* no fixed caps or special restrictions applied;
-+   * default unfixed setting */
-+  if (!caps) {
-+    GST_DEBUG ("Creating default caps");
-+    caps = gst_caps_new_simple (mimetype,
-+        "width", GST_TYPE_INT_RANGE, 16, 4096,
-+        "height", GST_TYPE_INT_RANGE, 16, 4096,
-+        "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
-+  }
-+
-+  for (i = 0; i < gst_caps_get_size (caps); i++) {
-+    va_start (var_args, fieldname);
-+    structure = gst_caps_get_structure (caps, i);
-+    gst_structure_set_valist (structure, fieldname, var_args);
-+    va_end (var_args);
-+  }
-+
-+  return caps;
-+}
-+
-+/* same for audio - now with channels/sample rate
-+ */
-+static GstCaps *
-+gst_ff_aud_caps_new (AVCodecContext * context, enum CodecID codec_id,
-+    const char *mimetype, const char *fieldname, ...)
-+{
-+  GstCaps *caps = NULL;
-+  GstStructure *structure = NULL;
-+  gint i;
-+  va_list var_args;
-+
-+  /* fixed, non-probing context */
-+  if (context != NULL && context->channels != -1) {
-+    GstAudioChannelPosition *pos;
-+    guint64 channel_layout = context->channel_layout;
-+
-+    if (channel_layout == 0) {
-+      const guint64 default_channel_set[] = {
-+        0, 0, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_5POINT0,
-+        AV_CH_LAYOUT_5POINT1, 0, AV_CH_LAYOUT_7POINT1
-+      };
-+
-+      switch (codec_id) {
-+        case CODEC_ID_EAC3:
-+        case CODEC_ID_AC3:
-+        case CODEC_ID_DTS:
-+          if (context->channels > 0
-+              && context->channels < G_N_ELEMENTS (default_channel_set))
-+            channel_layout = default_channel_set[context->channels - 1];
-+          break;
-+        default:
-+          break;
-+      }
-+    }
-+
-+    caps = gst_caps_new_simple (mimetype,
-+        "rate", G_TYPE_INT, context->sample_rate,
-+        "channels", G_TYPE_INT, context->channels, NULL);
-+
-+    pos = gst_ff_channel_layout_to_gst (channel_layout, context->channels);
-+    if (pos != NULL) {
-+      gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
-+      g_free (pos);
-+    }
-+  } else {
-+    gint maxchannels = 2;
-+    const gint *rates = NULL;
-+    gint n_rates = 0;
-+
-+    /* so we must be after restricted caps in this case */
-+    switch (codec_id) {
-+      case CODEC_ID_AAC:
-+      case CODEC_ID_AAC_LATM:
-+      case CODEC_ID_DTS:
-+        maxchannels = 6;
-+        break;
-+      case CODEC_ID_MP2:
-+      {
-+        const static gint l_rates[] =
-+            { 48000, 44100, 32000, 24000, 22050, 16000 };
-+        n_rates = G_N_ELEMENTS (l_rates);
-+        rates = l_rates;
-+        break;
-+      }
-+      case CODEC_ID_EAC3:
-+      case CODEC_ID_AC3:
-+      {
-+        const static gint l_rates[] = { 48000, 44100, 32000 };
-+        maxchannels = 6;
-+        n_rates = G_N_ELEMENTS (l_rates);
-+        rates = l_rates;
-+        break;
-+      }
-+      case CODEC_ID_ADPCM_G722:
-+      {
-+        const static gint l_rates[] = { 16000 };
-+        n_rates = G_N_ELEMENTS (l_rates);
-+        rates = l_rates;
-+        maxchannels = 1;
-+        break;
-+      }
-+      case CODEC_ID_ADPCM_G726:
-+      {
-+        const static gint l_rates[] = { 8000 };
-+        n_rates = G_N_ELEMENTS (l_rates);
-+        rates = l_rates;
-+        maxchannels = 1;
-+        break;
-+      }
-+      case CODEC_ID_ADPCM_SWF:
-+      {
-+        const static gint l_rates[] = { 11025, 22050, 44100 };
-+        n_rates = G_N_ELEMENTS (l_rates);
-+        rates = l_rates;
-+        break;
-+      }
-+      case CODEC_ID_ROQ_DPCM:
-+      {
-+        const static gint l_rates[] = { 22050 };
-+        n_rates = G_N_ELEMENTS (l_rates);
-+        rates = l_rates;
-+        break;
-+      }
-+      case CODEC_ID_AMR_NB:
-+      {
-+        const static gint l_rates[] = { 8000 };
-+        maxchannels = 1;
-+        n_rates = G_N_ELEMENTS (l_rates);
-+        rates = l_rates;
-+        break;
-+      }
-+      case CODEC_ID_AMR_WB:
-+      {
-+        const static gint l_rates[] = { 16000 };
-+        maxchannels = 1;
-+        n_rates = G_N_ELEMENTS (l_rates);
-+        rates = l_rates;
-+        break;
-+      }
-+      default:
-+        break;
-+    }
-+
-+    /* TODO: handle context->channel_layouts here to set
-+     * the list of channel layouts supported by the encoder.
-+     * Unfortunately no encoder uses this yet....
-+     */
-+    /* regardless of encode/decode, open up channels if applicable */
-+    /* Until decoders/encoders expose the maximum number of channels
-+     * they support, we whitelist them here. */
-+    switch (codec_id) {
-+      case CODEC_ID_WMAPRO:
-+      case CODEC_ID_TRUEHD:
-+        maxchannels = 8;
-+        break;
-+      default:
-+        break;
-+    }
-+
-+    if (maxchannels == 1)
-+      caps = gst_caps_new_simple (mimetype,
-+          "channels", G_TYPE_INT, maxchannels, NULL);
-+    else
-+      caps = gst_caps_new_simple (mimetype,
-+          "channels", GST_TYPE_INT_RANGE, 1, maxchannels, NULL);
-+    if (n_rates) {
-+      GValue list = { 0, };
-+      GstStructure *structure;
-+
-+      g_value_init (&list, GST_TYPE_LIST);
-+      for (i = 0; i < n_rates; i++) {
-+        GValue v = { 0, };
-+
-+        g_value_init (&v, G_TYPE_INT);
-+        g_value_set_int (&v, rates[i]);
-+        gst_value_list_append_value (&list, &v);
-+        g_value_unset (&v);
-+      }
-+      structure = gst_caps_get_structure (caps, 0);
-+      gst_structure_set_value (structure, "rate", &list);
-+      g_value_unset (&list);
-+    } else
-+      gst_caps_set_simple (caps, "rate", GST_TYPE_INT_RANGE, 4000, 96000, NULL);
-+  }
-+
-+  for (i = 0; i < gst_caps_get_size (caps); i++) {
-+    va_start (var_args, fieldname);
-+    structure = gst_caps_get_structure (caps, i);
-+    gst_structure_set_valist (structure, fieldname, var_args);
-+    va_end (var_args);
-+  }
-+
-+  return caps;
-+}
-+
-+/* Convert a FFMPEG codec ID and optional AVCodecContext
-+ * to a GstCaps. If the context is ommitted, no fixed values
-+ * for video/audio size will be included in the GstCaps
-+ *
-+ * CodecID is primarily meant for compressed data GstCaps!
-+ *
-+ * encode is a special parameter. gstffmpegdec will say
-+ * FALSE, gstffmpegenc will say TRUE. The output caps
-+ * depends on this, in such a way that it will be very
-+ * specific, defined, fixed and correct caps for encoders,
-+ * yet very wide, "forgiving" caps for decoders. Example
-+ * for mp3: decode: audio/mpeg,mpegversion=1,layer=[1-3]
-+ * but encode: audio/mpeg,mpegversion=1,layer=3,bitrate=x,
-+ * rate=x,channels=x.
-+ */
-+
-+GstCaps *
-+gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
-+    AVCodecContext * context, gboolean encode)
-+{
-+  GstCaps *caps = NULL;
-+  gboolean buildcaps = FALSE;
-+
-+  GST_LOG ("codec_id:%d, context:%p, encode:%d", codec_id, context, encode);
-+
-+  switch (codec_id) {
-+    case CODEC_ID_MPEG1VIDEO:
-+      /* FIXME: bitrate */
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
-+          "mpegversion", G_TYPE_INT, 1,
-+          "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
-+      break;
-+
-+    case CODEC_ID_MPEG2VIDEO:
-+      if (encode) {
-+        /* FIXME: bitrate */
-+        caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
-+            "mpegversion", G_TYPE_INT, 2,
-+            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
-+      } else {
-+        /* decode both MPEG-1 and MPEG-2; width/height/fps are all in
-+         * the MPEG video stream headers, so may be omitted from caps. */
-+        caps = gst_caps_new_simple ("video/mpeg",
-+            "mpegversion", GST_TYPE_INT_RANGE, 1, 2,
-+            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
-+      }
-+      break;
-+
-+    case CODEC_ID_MPEG2VIDEO_XVMC:
-+      /* this is a special ID - don't need it in GStreamer, I think */
-+      break;
-+
-+    case CODEC_ID_H263:
-+      if (encode) {
-+        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h263",
-+            "variant", G_TYPE_STRING, "itu",
-+            "h263version", G_TYPE_STRING, "h263", NULL);
-+      } else {
-+        /* don't pass codec_id, we can decode other variants with the H263
-+         * decoder that don't have specific size requirements
-+         */
-+        caps = gst_ff_vid_caps_new (context, CODEC_ID_NONE, "video/x-h263",
-+            "variant", G_TYPE_STRING, "itu", NULL);
-+      }
-+      break;
-+
-+    case CODEC_ID_H263P:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h263",
-+          "variant", G_TYPE_STRING, "itu",
-+          "h263version", G_TYPE_STRING, "h263p", NULL);
-+      if (encode && context) {
-+
-+        gst_caps_set_simple (caps,
-+            "annex-f", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_4MV,
-+            "annex-j", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_LOOP_FILTER,
-+            "annex-i", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_AC_PRED,
-+            "annex-t", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_AC_PRED,
-+            NULL);
-+      }
-+      break;
-+
-+    case CODEC_ID_H263I:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-intel-h263",
-+          "variant", G_TYPE_STRING, "intel", NULL);
-+      break;
-+
-+    case CODEC_ID_H261:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h261", NULL);
-+      break;
-+
-+    case CODEC_ID_RV10:
-+    case CODEC_ID_RV20:
-+    case CODEC_ID_RV30:
-+    case CODEC_ID_RV40:
-+    {
-+      gint version;
-+
-+      switch (codec_id) {
-+        case CODEC_ID_RV40:
-+          version = 4;
-+          break;
-+        case CODEC_ID_RV30:
-+          version = 3;
-+          break;
-+        case CODEC_ID_RV20:
-+          version = 2;
-+          break;
-+        default:
-+          version = 1;
-+          break;
-+      }
-+
-+      /* FIXME: context->sub_id must be filled in during decoding */
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-pn-realvideo",
-+          "systemstream", G_TYPE_BOOLEAN, FALSE,
-+          "rmversion", G_TYPE_INT, version, NULL);
-+      if (context) {
-+        gst_caps_set_simple (caps, "format", G_TYPE_INT, context->sub_id, NULL);
-+        if (context->extradata_size >= 8) {
-+          gst_caps_set_simple (caps,
-+              "subformat", G_TYPE_INT, GST_READ_UINT32_BE (context->extradata),
-+              NULL);
-+        }
-+      }
-+    }
-+      break;
-+
-+    case CODEC_ID_MP1:
-+      /* FIXME: bitrate */
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
-+          "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 1, NULL);
-+      break;
-+
-+    case CODEC_ID_MP2:
-+      /* FIXME: bitrate */
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
-+          "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 2, NULL);
-+      break;
-+
-+    case CODEC_ID_MP3:
-+      if (encode) {
-+        /* FIXME: bitrate */
-+        caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
-+            "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
-+      } else {
-+        /* Decodes MPEG-1 layer 1/2/3. Samplerate, channels et al are
-+         * in the MPEG audio header, so may be omitted from caps. */
-+        caps = gst_caps_new_simple ("audio/mpeg",
-+            "mpegversion", G_TYPE_INT, 1,
-+            "layer", GST_TYPE_INT_RANGE, 1, 3, NULL);
-+      }
-+      break;
-+
-+    case CODEC_ID_MUSEPACK7:
-+      caps =
-+          gst_ff_aud_caps_new (context, codec_id,
-+          "audio/x-ffmpeg-parsed-musepack", "streamversion", G_TYPE_INT, 7,
-+          NULL);
-+      break;
-+
-+    case CODEC_ID_MUSEPACK8:
-+      caps =
-+          gst_ff_aud_caps_new (context, codec_id,
-+          "audio/x-ffmpeg-parsed-musepack", "streamversion", G_TYPE_INT, 8,
-+          NULL);
-+      break;
-+
-+    case CODEC_ID_AC3:
-+      /* FIXME: bitrate */
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-ac3", NULL);
-+      break;
-+
-+    case CODEC_ID_EAC3:
-+      /* FIXME: bitrate */
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-eac3", NULL);
-+      break;
-+
-+    case CODEC_ID_TRUEHD:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-true-hd", NULL);
-+      break;
-+
-+    case CODEC_ID_ATRAC1:
-+      caps =
-+          gst_ff_aud_caps_new (context, codec_id, "audio/x-vnd.sony.atrac1",
-+          NULL);
-+      break;
-+
-+    case CODEC_ID_ATRAC3:
-+      caps =
-+          gst_ff_aud_caps_new (context, codec_id, "audio/x-vnd.sony.atrac3",
-+          NULL);
-+      break;
-+
-+    case CODEC_ID_DTS:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dts", NULL);
-+      break;
-+
-+    case CODEC_ID_APE:
-+      caps =
-+          gst_ff_aud_caps_new (context, codec_id, "audio/x-ffmpeg-parsed-ape",
-+          NULL);
-+      if (context) {
-+        gst_caps_set_simple (caps,
-+            "depth", G_TYPE_INT, context->bits_per_coded_sample, NULL);
-+      }
-+      break;
-+
-+    case CODEC_ID_MLP:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mlp", NULL);
-+      break;
-+
-+    case CODEC_ID_IMC:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-imc", NULL);
-+      break;
-+
-+      /* MJPEG is normal JPEG, Motion-JPEG and Quicktime MJPEG-A. MJPEGB
-+       * is Quicktime's MJPEG-B. LJPEG is lossless JPEG. I don't know what
-+       * sp5x is, but it's apparently something JPEG... We don't separate
-+       * between those in GStreamer. Should we (at least between MJPEG,
-+       * MJPEG-B and sp5x decoding...)? */
-+    case CODEC_ID_MJPEG:
-+    case CODEC_ID_LJPEG:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "image/jpeg", NULL);
-+      break;
-+
-+    case CODEC_ID_SP5X:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/sp5x", NULL);
-+      break;
-+
-+    case CODEC_ID_MJPEGB:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mjpeg-b", NULL);
-+      break;
-+
-+    case CODEC_ID_MPEG4:
-+      if (encode && context != NULL) {
-+        /* I'm not exactly sure what ffmpeg outputs... ffmpeg itself uses
-+         * the AVI fourcc 'DIVX', but 'mp4v' for Quicktime... */
-+        switch (context->codec_tag) {
-+          case GST_MAKE_FOURCC ('D', 'I', 'V', 'X'):
-+            caps = gst_ff_vid_caps_new (context, codec_id, "video/x-divx",
-+                "divxversion", G_TYPE_INT, 5, NULL);
-+            break;
-+          case GST_MAKE_FOURCC ('m', 'p', '4', 'v'):
-+          default:
-+            /* FIXME: bitrate */
-+            caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
-+                "systemstream", G_TYPE_BOOLEAN, FALSE,
-+                "mpegversion", G_TYPE_INT, 4, NULL);
-+            break;
-+        }
-+      } else {
-+        /* The trick here is to separate xvid, divx, mpeg4, 3ivx et al */
-+        caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
-+            "mpegversion", G_TYPE_INT, 4,
-+            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
-+        if (encode) {
-+          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
-+                  "video/x-divx", "divxversion", G_TYPE_INT, 5, NULL));
-+        } else {
-+          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
-+                  "video/x-divx", "divxversion", GST_TYPE_INT_RANGE, 4, 5,
-+                  NULL));
-+          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
-+                  "video/x-xvid", NULL));
-+          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
-+                  "video/x-3ivx", NULL));
-+        }
-+      }
-+      break;
-+
-+    case CODEC_ID_RAWVIDEO:
-+      caps =
-+          gst_ffmpeg_codectype_to_caps (AVMEDIA_TYPE_VIDEO, context, codec_id,
-+          encode);
-+      break;
-+
-+    case CODEC_ID_MSMPEG4V1:
-+    case CODEC_ID_MSMPEG4V2:
-+    case CODEC_ID_MSMPEG4V3:
-+    {
-+      gint version = 41 + codec_id - CODEC_ID_MSMPEG4V1;
-+
-+      /* encode-FIXME: bitrate */
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-msmpeg",
-+          "msmpegversion", G_TYPE_INT, version, NULL);
-+      if (!encode && codec_id == CODEC_ID_MSMPEG4V3) {
-+        gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
-+                "video/x-divx", "divxversion", G_TYPE_INT, 3, NULL));
-+      }
-+    }
-+      break;
-+
-+    case CODEC_ID_WMV1:
-+    case CODEC_ID_WMV2:
-+    {
-+      gint version = (codec_id == CODEC_ID_WMV1) ? 1 : 2;
-+
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
-+          "wmvversion", G_TYPE_INT, version, NULL);
-+    }
-+      break;
-+
-+    case CODEC_ID_FLV1:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-flash-video",
-+          "flvversion", G_TYPE_INT, 1, NULL);
-+      break;
-+
-+    case CODEC_ID_SVQ1:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-svq",
-+          "svqversion", G_TYPE_INT, 1, NULL);
-+      break;
-+
-+    case CODEC_ID_SVQ3:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-svq",
-+          "svqversion", G_TYPE_INT, 3, NULL);
-+      break;
-+
-+    case CODEC_ID_DVAUDIO:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dv", NULL);
-+      break;
-+
-+    case CODEC_ID_DVVIDEO:
-+    {
-+      if (encode && context) {
-+        guint32 fourcc;
-+
-+        switch (context->pix_fmt) {
-+          case PIX_FMT_YUYV422:
-+            fourcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
-+            break;
-+          case PIX_FMT_YUV420P:
-+            fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
-+            break;
-+          case PIX_FMT_YUVA420P:
-+            fourcc = GST_MAKE_FOURCC ('A', '4', '2', '0');
-+            break;
-+          case PIX_FMT_YUV411P:
-+            fourcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
-+            break;
-+          case PIX_FMT_YUV422P:
-+            fourcc = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
-+            break;
-+          case PIX_FMT_YUV410P:
-+            fourcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
-+            break;
-+          default:
-+            GST_WARNING
-+                ("Couldnt' find fourcc for pixfmt %d, defaulting to I420",
-+                context->pix_fmt);
-+            fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
-+            break;
-+        }
-+        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dv",
-+            "systemstream", G_TYPE_BOOLEAN, FALSE,
-+            "format", GST_TYPE_FOURCC, fourcc, NULL);
-+      } else {
-+        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dv",
-+            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
-+      }
-+    }
-+      break;
-+
-+    case CODEC_ID_WMAV1:
-+    case CODEC_ID_WMAV2:
-+    {
-+      gint version = (codec_id == CODEC_ID_WMAV1) ? 1 : 2;
-+
-+      if (context) {
-+        caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
-+            "wmaversion", G_TYPE_INT, version,
-+            "block_align", G_TYPE_INT, context->block_align,
-+            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
-+      } else {
-+        caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
-+            "wmaversion", G_TYPE_INT, version,
-+            "block_align", GST_TYPE_INT_RANGE, 0, G_MAXINT,
-+            "bitrate", GST_TYPE_INT_RANGE, 0, G_MAXINT, NULL);
-+      }
-+    }
-+      break;
-+    case CODEC_ID_WMAPRO:
-+    {
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
-+          "wmaversion", G_TYPE_INT, 3, NULL);
-+      break;
-+    }
-+
-+    case CODEC_ID_WMAVOICE:
-+    {
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wms", NULL);
-+      break;
-+    }
-+
-+    case CODEC_ID_MACE3:
-+    case CODEC_ID_MACE6:
-+    {
-+      gint version = (codec_id == CODEC_ID_MACE3) ? 3 : 6;
-+
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mace",
-+          "maceversion", G_TYPE_INT, version, NULL);
-+    }
-+      break;
-+
-+    case CODEC_ID_HUFFYUV:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-huffyuv", NULL);
-+      if (context) {
-+        gst_caps_set_simple (caps,
-+            "bpp", G_TYPE_INT, context->bits_per_coded_sample, NULL);
-+      }
-+      break;
-+
-+    case CODEC_ID_CYUV:
-+      caps =
-+          gst_ff_vid_caps_new (context, codec_id, "video/x-compressed-yuv",
-+          NULL);
-+      break;
-+
-+    case CODEC_ID_H264:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h264", NULL);
-+      break;
-+
-+    case CODEC_ID_INDEO5:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
-+          "indeoversion", G_TYPE_INT, 5, NULL);
-+      break;
-+
-+    case CODEC_ID_INDEO3:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
-+          "indeoversion", G_TYPE_INT, 3, NULL);
-+      break;
-+
-+    case CODEC_ID_INDEO2:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
-+          "indeoversion", G_TYPE_INT, 2, NULL);
-+      break;
-+
-+    case CODEC_ID_FLASHSV:
-+      caps =
-+          gst_ff_vid_caps_new (context, codec_id, "video/x-flash-screen", NULL);
-+      break;
-+
-+    case CODEC_ID_VP3:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp3", NULL);
-+      break;
-+
-+    case CODEC_ID_VP5:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp5", NULL);
-+      break;
-+
-+    case CODEC_ID_VP6:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6", NULL);
-+      break;
-+
-+    case CODEC_ID_VP6F:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6-flash", NULL);
-+      break;
-+
-+    case CODEC_ID_VP6A:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6-alpha", NULL);
-+      break;
-+
-+    case CODEC_ID_VP8:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp8", NULL);
-+      break;
-+
-+    case CODEC_ID_THEORA:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-theora", NULL);
-+      break;
-+
-+    case CODEC_ID_AAC:
-+    {
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg", NULL);
-+
-+      if (!encode) {
-+        GValue arr = { 0, };
-+        GValue item = { 0, };
-+
-+        g_value_init (&arr, GST_TYPE_LIST);
-+        g_value_init (&item, G_TYPE_INT);
-+        g_value_set_int (&item, 2);
-+        gst_value_list_append_value (&arr, &item);
-+        g_value_set_int (&item, 4);
-+        gst_value_list_append_value (&arr, &item);
-+        g_value_unset (&item);
-+
-+        gst_caps_set_value (caps, "mpegversion", &arr);
-+        g_value_unset (&arr);
-+
-+        g_value_init (&arr, GST_TYPE_LIST);
-+        g_value_init (&item, G_TYPE_STRING);
-+        g_value_set_string (&item, "raw");
-+        gst_value_list_append_value (&arr, &item);
-+        g_value_set_string (&item, "adts");
-+        gst_value_list_append_value (&arr, &item);
-+        g_value_set_string (&item, "adif");
-+        gst_value_list_append_value (&arr, &item);
-+        g_value_unset (&item);
-+
-+        gst_caps_set_value (caps, "stream-format", &arr);
-+        g_value_unset (&arr);
-+      } else {
-+        gst_caps_set_simple (caps, "mpegversion", G_TYPE_INT, 4,
-+            "stream-format", G_TYPE_STRING, "raw",
-+            "base-profile", G_TYPE_STRING, "lc", NULL);
-+
-+        if (context && context->extradata_size > 0)
-+          gst_codec_utils_aac_caps_set_level_and_profile (caps,
-+              context->extradata, context->extradata_size);
-+      }
-+
-+      break;
-+    }
-+    case CODEC_ID_AAC_LATM:    /* LATM/LOAS AAC syntax */
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
-+          "mpegversion", G_TYPE_INT, 4, "stream-format", G_TYPE_STRING, "loas",
-+          NULL);
-+      break;
-+
-+    case CODEC_ID_ASV1:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-asus",
-+          "asusversion", G_TYPE_INT, 1, NULL);
-+      break;
-+    case CODEC_ID_ASV2:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-asus",
-+          "asusversion", G_TYPE_INT, 2, NULL);
-+      break;
-+
-+    case CODEC_ID_FFV1:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ffv",
-+          "ffvversion", G_TYPE_INT, 1, NULL);
-+      break;
-+
-+    case CODEC_ID_4XM:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-4xm", NULL);
-+      break;
-+
-+    case CODEC_ID_XAN_WC3:
-+    case CODEC_ID_XAN_WC4:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-xan",
-+          "wcversion", G_TYPE_INT, 3 - CODEC_ID_XAN_WC3 + codec_id, NULL);
-+      break;
-+
-+    case CODEC_ID_CLJR:
-+      caps =
-+          gst_ff_vid_caps_new (context, codec_id,
-+          "video/x-cirrus-logic-accupak", NULL);
-+      break;
-+
-+    case CODEC_ID_FRAPS:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-fraps", NULL);
-+      break;
-+
-+    case CODEC_ID_MDEC:
-+    case CODEC_ID_ROQ:
-+    case CODEC_ID_INTERPLAY_VIDEO:
-+      buildcaps = TRUE;
-+      break;
-+
-+    case CODEC_ID_VCR1:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ati-vcr",
-+          "vcrversion", G_TYPE_INT, 1, NULL);
-+      break;
-+
-+    case CODEC_ID_RPZA:
-+      caps =
-+          gst_ff_vid_caps_new (context, codec_id, "video/x-apple-video", NULL);
-+      break;
-+
-+    case CODEC_ID_CINEPAK:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-cinepak", NULL);
-+      break;
-+
-+      /* WS_VQA belogns here (order) */
-+
-+    case CODEC_ID_MSRLE:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-rle",
-+          "layout", G_TYPE_STRING, "microsoft", NULL);
-+      if (context) {
-+        gst_caps_set_simple (caps,
-+            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
-+      } else {
-+        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 1, 64, NULL);
-+      }
-+      break;
-+
-+    case CODEC_ID_QTRLE:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-rle",
-+          "layout", G_TYPE_STRING, "quicktime", NULL);
-+      if (context) {
-+        gst_caps_set_simple (caps,
-+            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
-+      } else {
-+        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 1, 64, NULL);
-+      }
-+      break;
-+
-+    case CODEC_ID_MSVIDEO1:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-msvideocodec",
-+          "msvideoversion", G_TYPE_INT, 1, NULL);
-+      break;
-+
-+    case CODEC_ID_WMV3:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
-+          "wmvversion", G_TYPE_INT, 3, NULL);
-+      break;
-+    case CODEC_ID_VC1:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
-+          "wmvversion", G_TYPE_INT, 3, "format", GST_TYPE_FOURCC,
-+          GST_MAKE_FOURCC ('W', 'V', 'C', '1'), NULL);
-+      break;
-+    case CODEC_ID_QDM2:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-qdm2", NULL);
-+      break;
-+
-+    case CODEC_ID_MSZH:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mszh", NULL);
-+      break;
-+
-+    case CODEC_ID_ZLIB:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-zlib", NULL);
-+      break;
-+
-+    case CODEC_ID_TRUEMOTION1:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-truemotion",
-+          "trueversion", G_TYPE_INT, 1, NULL);
-+      break;
-+    case CODEC_ID_TRUEMOTION2:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-truemotion",
-+          "trueversion", G_TYPE_INT, 2, NULL);
-+      break;
-+
-+    case CODEC_ID_ULTI:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ultimotion",
-+          NULL);
-+      break;
-+
-+    case CODEC_ID_TSCC:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-camtasia", NULL);
-+      if (context) {
-+        gst_caps_set_simple (caps,
-+            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
-+      } else {
-+        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 8, 32, NULL);
-+      }
-+      break;
-+
-+    case CODEC_ID_KMVC:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-kmvc", NULL);
-+      break;
-+
-+    case CODEC_ID_NUV:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-nuv", NULL);
-+      break;
-+
-+    case CODEC_ID_GIF:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "image/gif", NULL);
-+      break;
-+
-+    case CODEC_ID_PNG:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "image/png", NULL);
-+      break;
-+
-+    case CODEC_ID_PPM:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "image/ppm", NULL);
-+      break;
-+
-+    case CODEC_ID_PBM:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "image/pbm", NULL);
-+      break;
-+
-+    case CODEC_ID_PAM:
-+      caps =
-+          gst_ff_vid_caps_new (context, codec_id, "image/x-portable-anymap",
-+          NULL);
-+      break;
-+
-+    case CODEC_ID_PGM:
-+      caps =
-+          gst_ff_vid_caps_new (context, codec_id, "image/x-portable-graymap",
-+          NULL);
-+      break;
-+
-+    case CODEC_ID_PCX:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-pcx", NULL);
-+      break;
-+
-+    case CODEC_ID_SGI:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-sgi", NULL);
-+      break;
-+
-+    case CODEC_ID_TARGA:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-tga", NULL);
-+      break;
-+
-+    case CODEC_ID_TIFF:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "image/tiff", NULL);
-+      break;
-+
-+    case CODEC_ID_SUNRAST:
-+      caps =
-+          gst_ff_vid_caps_new (context, codec_id, "image/x-sun-raster", NULL);
-+      break;
-+
-+    case CODEC_ID_SMC:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-smc", NULL);
-+      break;
-+
-+    case CODEC_ID_QDRAW:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-qdrw", NULL);
-+      break;
-+
-+    case CODEC_ID_DNXHD:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dnxhd", NULL);
-+      break;
-+
-+    case CODEC_ID_MIMIC:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mimic", NULL);
-+      break;
-+
-+    case CODEC_ID_VMNC:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vmnc", NULL);
-+      break;
-+
-+    case CODEC_ID_TRUESPEECH:
-+      caps =
-+          gst_ff_aud_caps_new (context, codec_id, "audio/x-truespeech", NULL);
-+      break;
-+
-+    case CODEC_ID_QCELP:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/qcelp", NULL);
-+      break;
-+
-+    case CODEC_ID_AMV:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-amv", NULL);
-+      break;
-+
-+    case CODEC_ID_AASC:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-aasc", NULL);
-+      break;
-+
-+    case CODEC_ID_LOCO:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-loco", NULL);
-+      break;
-+
-+    case CODEC_ID_ZMBV:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-zmbv", NULL);
-+      break;
-+
-+    case CODEC_ID_LAGARITH:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-lagarith", NULL);
-+      break;
-+
-+    case CODEC_ID_CSCD:
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-camstudio", NULL);
-+      if (context) {
-+        gst_caps_set_simple (caps,
-+            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
-+      } else {
-+        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 8, 32, NULL);
-+      }
-+      break;
-+
-+    case CODEC_ID_WS_VQA:
-+    case CODEC_ID_IDCIN:
-+    case CODEC_ID_8BPS:
-+    case CODEC_ID_FLIC:
-+    case CODEC_ID_VMDVIDEO:
-+    case CODEC_ID_VMDAUDIO:
-+    case CODEC_ID_SNOW:
-+    case CODEC_ID_VIXL:
-+    case CODEC_ID_QPEG:
-+    case CODEC_ID_PGMYUV:
-+    case CODEC_ID_FFVHUFF:
-+    case CODEC_ID_WNV1:
-+    case CODEC_ID_MP3ADU:
-+    case CODEC_ID_MP3ON4:
-+    case CODEC_ID_WESTWOOD_SND1:
-+    case CODEC_ID_MMVIDEO:
-+    case CODEC_ID_AVS:
-+    case CODEC_ID_CAVS:
-+      buildcaps = TRUE;
-+      break;
-+
-+      /* weird quasi-codecs for the demuxers only */
-+    case CODEC_ID_PCM_S16LE:
-+    case CODEC_ID_PCM_S16BE:
-+    case CODEC_ID_PCM_U16LE:
-+    case CODEC_ID_PCM_U16BE:
-+    case CODEC_ID_PCM_S8:
-+    case CODEC_ID_PCM_U8:
-+    {
-+      gint width = 0, depth = 0, endianness = 0;
-+      gboolean signedness = FALSE;      /* blabla */
-+
-+      switch (codec_id) {
-+        case CODEC_ID_PCM_S16LE:
-+          width = 16;
-+          depth = 16;
-+          endianness = G_LITTLE_ENDIAN;
-+          signedness = TRUE;
-+          break;
-+        case CODEC_ID_PCM_S16BE:
-+          width = 16;
-+          depth = 16;
-+          endianness = G_BIG_ENDIAN;
-+          signedness = TRUE;
-+          break;
-+        case CODEC_ID_PCM_U16LE:
-+          width = 16;
-+          depth = 16;
-+          endianness = G_LITTLE_ENDIAN;
-+          signedness = FALSE;
-+          break;
-+        case CODEC_ID_PCM_U16BE:
-+          width = 16;
-+          depth = 16;
-+          endianness = G_BIG_ENDIAN;
-+          signedness = FALSE;
-+          break;
-+        case CODEC_ID_PCM_S8:
-+          width = 8;
-+          depth = 8;
-+          endianness = G_BYTE_ORDER;
-+          signedness = TRUE;
-+          break;
-+        case CODEC_ID_PCM_U8:
-+          width = 8;
-+          depth = 8;
-+          endianness = G_BYTE_ORDER;
-+          signedness = FALSE;
-+          break;
-+        default:
-+          g_assert (0);         /* don't worry, we never get here */
-+          break;
-+      }
-+
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-int",
-+          "width", G_TYPE_INT, width,
-+          "depth", G_TYPE_INT, depth,
-+          "endianness", G_TYPE_INT, endianness,
-+          "signed", G_TYPE_BOOLEAN, signedness, NULL);
-+    }
-+      break;
-+
-+    case CODEC_ID_PCM_MULAW:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mulaw", NULL);
-+      break;
-+
-+    case CODEC_ID_PCM_ALAW:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-alaw", NULL);
-+      break;
-+
-+    case CODEC_ID_ADPCM_G722:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/G722", NULL);
-+      if (context)
-+        gst_caps_set_simple (caps,
-+            "block_align", G_TYPE_INT, context->block_align,
-+            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
-+      break;
-+
-+    case CODEC_ID_ADPCM_G726:
-+    {
-+      /* the G726 decoder can also handle G721 */
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-adpcm",
-+          "layout", G_TYPE_STRING, "g726", NULL);
-+      if (context)
-+        gst_caps_set_simple (caps,
-+            "block_align", G_TYPE_INT, context->block_align,
-+            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
-+
-+      if (!encode) {
-+        gst_caps_append (caps, gst_caps_new_simple ("audio/x-adpcm",
-+                "layout", G_TYPE_STRING, "g721",
-+                "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL));
-+      }
-+      break;
-+    }
-+    case CODEC_ID_ADPCM_IMA_QT:
-+    case CODEC_ID_ADPCM_IMA_WAV:
-+    case CODEC_ID_ADPCM_IMA_DK3:
-+    case CODEC_ID_ADPCM_IMA_DK4:
-+    case CODEC_ID_ADPCM_IMA_WS:
-+    case CODEC_ID_ADPCM_IMA_SMJPEG:
-+    case CODEC_ID_ADPCM_IMA_AMV:
-+    case CODEC_ID_ADPCM_IMA_ISS:
-+    case CODEC_ID_ADPCM_IMA_EA_EACS:
-+    case CODEC_ID_ADPCM_IMA_EA_SEAD:
-+    case CODEC_ID_ADPCM_MS:
-+    case CODEC_ID_ADPCM_4XM:
-+    case CODEC_ID_ADPCM_XA:
-+    case CODEC_ID_ADPCM_ADX:
-+    case CODEC_ID_ADPCM_EA:
-+    case CODEC_ID_ADPCM_CT:
-+    case CODEC_ID_ADPCM_SWF:
-+    case CODEC_ID_ADPCM_YAMAHA:
-+    case CODEC_ID_ADPCM_SBPRO_2:
-+    case CODEC_ID_ADPCM_SBPRO_3:
-+    case CODEC_ID_ADPCM_SBPRO_4:
-+    case CODEC_ID_ADPCM_EA_R1:
-+    case CODEC_ID_ADPCM_EA_R2:
-+    case CODEC_ID_ADPCM_EA_R3:
-+    case CODEC_ID_ADPCM_EA_MAXIS_XA:
-+    case CODEC_ID_ADPCM_EA_XAS:
-+    case CODEC_ID_ADPCM_THP:
-+    {
-+      const gchar *layout = NULL;
-+
-+      switch (codec_id) {
-+        case CODEC_ID_ADPCM_IMA_QT:
-+          layout = "quicktime";
-+          break;
-+        case CODEC_ID_ADPCM_IMA_WAV:
-+          layout = "dvi";
-+          break;
-+        case CODEC_ID_ADPCM_IMA_DK3:
-+          layout = "dk3";
-+          break;
-+        case CODEC_ID_ADPCM_IMA_DK4:
-+          layout = "dk4";
-+          break;
-+        case CODEC_ID_ADPCM_IMA_WS:
-+          layout = "westwood";
-+          break;
-+        case CODEC_ID_ADPCM_IMA_SMJPEG:
-+          layout = "smjpeg";
-+          break;
-+        case CODEC_ID_ADPCM_IMA_AMV:
-+          layout = "amv";
-+          break;
-+        case CODEC_ID_ADPCM_IMA_ISS:
-+          layout = "iss";
-+          break;
-+        case CODEC_ID_ADPCM_IMA_EA_EACS:
-+          layout = "ea-eacs";
-+          break;
-+        case CODEC_ID_ADPCM_IMA_EA_SEAD:
-+          layout = "ea-sead";
-+          break;
-+        case CODEC_ID_ADPCM_MS:
-+          layout = "microsoft";
-+          break;
-+        case CODEC_ID_ADPCM_4XM:
-+          layout = "4xm";
-+          break;
-+        case CODEC_ID_ADPCM_XA:
-+          layout = "xa";
-+          break;
-+        case CODEC_ID_ADPCM_ADX:
-+          layout = "adx";
-+          break;
-+        case CODEC_ID_ADPCM_EA:
-+          layout = "ea";
-+          break;
-+        case CODEC_ID_ADPCM_CT:
-+          layout = "ct";
-+          break;
-+        case CODEC_ID_ADPCM_SWF:
-+          layout = "swf";
-+          break;
-+        case CODEC_ID_ADPCM_YAMAHA:
-+          layout = "yamaha";
-+          break;
-+        case CODEC_ID_ADPCM_SBPRO_2:
-+          layout = "sbpro2";
-+          break;
-+        case CODEC_ID_ADPCM_SBPRO_3:
-+          layout = "sbpro3";
-+          break;
-+        case CODEC_ID_ADPCM_SBPRO_4:
-+          layout = "sbpro4";
-+          break;
-+        case CODEC_ID_ADPCM_EA_R1:
-+          layout = "ea-r1";
-+          break;
-+        case CODEC_ID_ADPCM_EA_R2:
-+          layout = "ea-r3";
-+          break;
-+        case CODEC_ID_ADPCM_EA_R3:
-+          layout = "ea-r3";
-+          break;
-+        case CODEC_ID_ADPCM_EA_MAXIS_XA:
-+          layout = "ea-maxis-xa";
-+          break;
-+        case CODEC_ID_ADPCM_EA_XAS:
-+          layout = "ea-xas";
-+          break;
-+        case CODEC_ID_ADPCM_THP:
-+          layout = "thp";
-+          break;
-+        default:
-+          g_assert (0);         /* don't worry, we never get here */
-+          break;
-+      }
-+
-+      /* FIXME: someone please check whether we need additional properties
-+       * in this caps definition. */
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-adpcm",
-+          "layout", G_TYPE_STRING, layout, NULL);
-+      if (context)
-+        gst_caps_set_simple (caps,
-+            "block_align", G_TYPE_INT, context->block_align,
-+            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
-+    }
-+      break;
-+
-+    case CODEC_ID_AMR_NB:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/AMR", NULL);
-+      break;
-+
-+    case CODEC_ID_AMR_WB:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/AMR-WB", NULL);
-+      break;
-+
-+    case CODEC_ID_GSM:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-gsm", NULL);
-+      break;
-+
-+    case CODEC_ID_GSM_MS:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/ms-gsm", NULL);
-+      break;
-+
-+    case CODEC_ID_NELLYMOSER:
-+      caps =
-+          gst_ff_aud_caps_new (context, codec_id, "audio/x-nellymoser", NULL);
-+      break;
-+
-+    case CODEC_ID_SIPR:
-+    {
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-sipro", NULL);
-+      if (context) {
-+        gst_caps_set_simple (caps,
-+            "leaf_size", G_TYPE_INT, context->block_align,
-+            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
-+      }
-+    }
-+      break;
-+
-+    case CODEC_ID_RA_144:
-+    case CODEC_ID_RA_288:
-+    case CODEC_ID_COOK:
-+    {
-+      gint version = 0;
-+
-+      switch (codec_id) {
-+        case CODEC_ID_RA_144:
-+          version = 1;
-+          break;
-+        case CODEC_ID_RA_288:
-+          version = 2;
-+          break;
-+        case CODEC_ID_COOK:
-+          version = 8;
-+          break;
-+        default:
-+          break;
-+      }
-+
-+      /* FIXME: properties? */
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-pn-realaudio",
-+          "raversion", G_TYPE_INT, version, NULL);
-+      if (context) {
-+        gst_caps_set_simple (caps,
-+            "leaf_size", G_TYPE_INT, context->block_align,
-+            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
-+      }
-+    }
-+      break;
-+
-+    case CODEC_ID_ROQ_DPCM:
-+    case CODEC_ID_INTERPLAY_DPCM:
-+    case CODEC_ID_XAN_DPCM:
-+    case CODEC_ID_SOL_DPCM:
-+    {
-+      const gchar *layout = NULL;
-+
-+      switch (codec_id) {
-+        case CODEC_ID_ROQ_DPCM:
-+          layout = "roq";
-+          break;
-+        case CODEC_ID_INTERPLAY_DPCM:
-+          layout = "interplay";
-+          break;
-+        case CODEC_ID_XAN_DPCM:
-+          layout = "xan";
-+          break;
-+        case CODEC_ID_SOL_DPCM:
-+          layout = "sol";
-+          break;
-+        default:
-+          g_assert (0);         /* don't worry, we never get here */
-+          break;
-+      }
-+
-+      /* FIXME: someone please check whether we need additional properties
-+       * in this caps definition. */
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dpcm",
-+          "layout", G_TYPE_STRING, layout, NULL);
-+      if (context)
-+        gst_caps_set_simple (caps,
-+            "block_align", G_TYPE_INT, context->block_align,
-+            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
-+    }
-+      break;
-+
-+    case CODEC_ID_SHORTEN:
-+      caps = gst_caps_new_simple ("audio/x-shorten", NULL);
-+      break;
-+
-+    case CODEC_ID_ALAC:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-alac", NULL);
-+      if (context) {
-+        gst_caps_set_simple (caps,
-+            "samplesize", G_TYPE_INT, context->bits_per_coded_sample, NULL);
-+      }
-+      break;
-+
-+    case CODEC_ID_FLAC:
-+      /* Note that ffmpeg has no encoder yet, but just for safety. In the
-+       * encoder case, we want to add things like samplerate, channels... */
-+      if (!encode) {
-+        caps = gst_caps_new_simple ("audio/x-flac", NULL);
-+      }
-+      break;
-+
-+    case CODEC_ID_DVD_SUBTITLE:
-+    case CODEC_ID_DVB_SUBTITLE:
-+      caps = NULL;
-+      break;
-+    case CODEC_ID_BMP:
-+      caps = gst_caps_new_simple ("image/bmp", NULL);
-+      break;
-+    case CODEC_ID_TTA:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-tta", NULL);
-+      if (context) {
-+        gst_caps_set_simple (caps,
-+            "samplesize", G_TYPE_INT, context->bits_per_coded_sample, NULL);
-+      }
-+      break;
-+    case CODEC_ID_TWINVQ:
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-twin-vq", NULL);
-+      break;
-+    default:
-+      GST_DEBUG ("Unknown codec ID %d, please add mapping here", codec_id);
-+      break;
-+  }
-+
-+  if (buildcaps) {
-+    AVCodec *codec;
-+
-+    if ((codec = avcodec_find_decoder (codec_id)) ||
-+        (codec = avcodec_find_encoder (codec_id))) {
-+      gchar *mime = NULL;
-+
-+      GST_LOG ("Could not create stream format caps for %s", codec->name);
-+
-+      switch (codec->type) {
-+        case AVMEDIA_TYPE_VIDEO:
-+          mime = g_strdup_printf ("video/x-gst_ff-%s", codec->name);
-+          caps = gst_ff_vid_caps_new (context, codec_id, mime, NULL);
-+          g_free (mime);
-+          break;
-+        case AVMEDIA_TYPE_AUDIO:
-+          mime = g_strdup_printf ("audio/x-gst_ff-%s", codec->name);
-+          caps = gst_ff_aud_caps_new (context, codec_id, mime, NULL);
-+          if (context)
-+            gst_caps_set_simple (caps,
-+                "block_align", G_TYPE_INT, context->block_align,
-+                "bitrate", G_TYPE_INT, context->bit_rate, NULL);
-+          g_free (mime);
-+          break;
-+        default:
-+          break;
-+      }
-+    }
-+  }
-+
-+  if (caps != NULL) {
-+
-+    /* set private data */
-+    if (context && context->extradata_size > 0) {
-+      GstBuffer *data = gst_buffer_new_and_alloc (context->extradata_size);
-+
-+      memcpy (GST_BUFFER_DATA (data), context->extradata,
-+          context->extradata_size);
-+      gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, data, NULL);
-+      gst_buffer_unref (data);
-+    }
-+
-+    /* palette */
-+    if (context) {
-+      gst_ffmpeg_set_palette (caps, context);
-+    }
-+
-+    GST_LOG ("caps for codec_id=%d: %" GST_PTR_FORMAT, codec_id, caps);
-+
-+  } else {
-+    GST_LOG ("No caps found for codec_id=%d", codec_id);
-+  }
-+
-+  return caps;
-+}
-+
-+/* Convert a FFMPEG Pixel Format and optional AVCodecContext
-+ * to a GstCaps. If the context is ommitted, no fixed values
-+ * for video/audio size will be included in the GstCaps
-+ *
-+ * See below for usefullness
-+ */
-+
-+GstCaps *
-+gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context,
-+    enum CodecID codec_id)
-+{
-+  GstCaps *caps = NULL;
-+
-+  int bpp = 0, depth = 0, endianness = 0;
-+  gulong g_mask = 0, r_mask = 0, b_mask = 0, a_mask = 0;
-+  guint32 fmt = 0;
-+
-+  switch (pix_fmt) {
-+    case PIX_FMT_YUVJ420P:
-+    case PIX_FMT_YUV420P:
-+      fmt = GST_MAKE_FOURCC ('I', '4', '2', '0');
-+      break;
-+    case PIX_FMT_YUVA420P:
-+      fmt = GST_MAKE_FOURCC ('A', '4', '2', '0');
-+      break;
-+    case PIX_FMT_YUYV422:
-+      fmt = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
-+      break;
-+    case PIX_FMT_RGB24:
-+      bpp = depth = 24;
-+      endianness = G_BIG_ENDIAN;
-+      r_mask = 0xff0000;
-+      g_mask = 0x00ff00;
-+      b_mask = 0x0000ff;
-+      break;
-+    case PIX_FMT_BGR24:
-+      bpp = depth = 24;
-+      endianness = G_BIG_ENDIAN;
-+      r_mask = 0x0000ff;
-+      g_mask = 0x00ff00;
-+      b_mask = 0xff0000;
-+      break;
-+    case PIX_FMT_YUVJ422P:
-+    case PIX_FMT_YUV422P:
-+      fmt = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
-+      break;
-+    case PIX_FMT_YUVJ444P:
-+    case PIX_FMT_YUV444P:
-+      fmt = GST_MAKE_FOURCC ('Y', '4', '4', '4');
-+      break;
-+    case PIX_FMT_RGB32:
-+      bpp = 32;
-+      depth = 32;
-+      endianness = G_BIG_ENDIAN;
-+#if (G_BYTE_ORDER == G_BIG_ENDIAN)
-+      r_mask = 0x00ff0000;
-+      g_mask = 0x0000ff00;
-+      b_mask = 0x000000ff;
-+      a_mask = 0xff000000;
-+#else
-+      r_mask = 0x0000ff00;
-+      g_mask = 0x00ff0000;
-+      b_mask = 0xff000000;
-+      a_mask = 0x000000ff;
-+#endif
-+      break;
-+    case PIX_FMT_YUV410P:
-+      fmt = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
-+      break;
-+    case PIX_FMT_YUV411P:
-+      fmt = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
-+      break;
-+    case PIX_FMT_RGB565:
-+      bpp = depth = 16;
-+      endianness = G_BYTE_ORDER;
-+      r_mask = 0xf800;
-+      g_mask = 0x07e0;
-+      b_mask = 0x001f;
-+      break;
-+    case PIX_FMT_RGB555:
-+      bpp = 16;
-+      depth = 15;
-+      endianness = G_BYTE_ORDER;
-+      r_mask = 0x7c00;
-+      g_mask = 0x03e0;
-+      b_mask = 0x001f;
-+      break;
-+    case PIX_FMT_PAL8:
-+      bpp = depth = 8;
-+      endianness = G_BYTE_ORDER;
-+      break;
-+    case PIX_FMT_GRAY8:
-+      bpp = depth = 8;
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-gray",
-+          "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, NULL);
-+      break;
-+    default:
-+      /* give up ... */
-+      break;
-+  }
-+
-+  if (caps == NULL) {
-+    if (bpp != 0) {
-+      if (r_mask != 0) {
-+        if (a_mask) {
-+          caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
-+              "bpp", G_TYPE_INT, bpp,
-+              "depth", G_TYPE_INT, depth,
-+              "red_mask", G_TYPE_INT, r_mask,
-+              "green_mask", G_TYPE_INT, g_mask,
-+              "blue_mask", G_TYPE_INT, b_mask,
-+              "alpha_mask", G_TYPE_INT, a_mask,
-+              "endianness", G_TYPE_INT, endianness, NULL);
-+        } else {
-+          caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
-+              "bpp", G_TYPE_INT, bpp,
-+              "depth", G_TYPE_INT, depth,
-+              "red_mask", G_TYPE_INT, r_mask,
-+              "green_mask", G_TYPE_INT, g_mask,
-+              "blue_mask", G_TYPE_INT, b_mask,
-+              "endianness", G_TYPE_INT, endianness, NULL);
-+        }
-+      } else {
-+        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
-+            "bpp", G_TYPE_INT, bpp,
-+            "depth", G_TYPE_INT, depth,
-+            "endianness", G_TYPE_INT, endianness, NULL);
-+        if (caps && context) {
-+          gst_ffmpeg_set_palette (caps, context);
-+        }
-+      }
-+    } else if (fmt) {
-+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-yuv",
-+          "format", GST_TYPE_FOURCC, fmt, NULL);
-+    }
-+  }
-+
-+  if (caps != NULL) {
-+    GST_DEBUG ("caps for pix_fmt=%d: %" GST_PTR_FORMAT, pix_fmt, caps);
-+  } else {
-+    GST_LOG ("No caps found for pix_fmt=%d", pix_fmt);
-+  }
-+
-+  return caps;
-+}
-+
-+/* Convert a FFMPEG Sample Format and optional AVCodecContext
-+ * to a GstCaps. If the context is ommitted, no fixed values
-+ * for video/audio size will be included in the GstCaps
-+ *
-+ * See below for usefullness
-+ */
-+
-+static GstCaps *
-+gst_ffmpeg_smpfmt_to_caps (enum AVSampleFormat sample_fmt,
-+    AVCodecContext * context, enum CodecID codec_id)
-+{
-+  GstCaps *caps = NULL;
-+
-+  int bpp = 0;
-+  gboolean integer = TRUE;
-+  gboolean signedness = FALSE;
-+
-+  switch (sample_fmt) {
-+    case AV_SAMPLE_FMT_S16:
-+      signedness = TRUE;
-+      bpp = 16;
-+      break;
-+
-+    case AV_SAMPLE_FMT_S32:
-+      signedness = TRUE;
-+      bpp = 32;
-+      break;
-+
-+    case AV_SAMPLE_FMT_FLT:
-+      integer = FALSE;
-+      bpp = 32;
-+      break;
-+
-+    case AV_SAMPLE_FMT_DBL:
-+      integer = FALSE;
-+      bpp = 64;
-+      break;
-+    default:
-+      /* .. */
-+      break;
-+  }
-+
-+  if (bpp) {
-+    if (integer) {
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-int",
-+          "signed", G_TYPE_BOOLEAN, signedness,
-+          "endianness", G_TYPE_INT, G_BYTE_ORDER,
-+          "width", G_TYPE_INT, bpp, "depth", G_TYPE_INT, bpp, NULL);
-+    } else {
-+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-float",
-+          "endianness", G_TYPE_INT, G_BYTE_ORDER,
-+          "width", G_TYPE_INT, bpp, NULL);
-+    }
-+  }
-+
-+  if (caps != NULL) {
-+    GST_LOG ("caps for sample_fmt=%d: %" GST_PTR_FORMAT, sample_fmt, caps);
-+  } else {
-+    GST_LOG ("No caps found for sample_fmt=%d", sample_fmt);
-+  }
-+
-+  return caps;
-+}
-+
-+GstCaps *
-+gst_ffmpeg_codectype_to_audio_caps (AVCodecContext * context,
-+    enum CodecID codec_id, gboolean encode, AVCodec * codec)
-+{
-+  GstCaps *caps = NULL;
-+
-+  GST_DEBUG ("context:%p, codec_id:%d, encode:%d, codec:%p",
-+      context, codec_id, encode, codec);
-+  if (codec)
-+    GST_DEBUG ("sample_fmts:%p, samplerates:%p",
-+        codec->sample_fmts, codec->supported_samplerates);
-+
-+  if (context) {
-+    /* Specific codec context */
-+    caps = gst_ffmpeg_smpfmt_to_caps (context->sample_fmt, context, codec_id);
-+  } else if (codec && codec->sample_fmts) {
-+    GstCaps *temp;
-+    int i;
-+
-+    caps = gst_caps_new_empty ();
-+    for (i = 0; codec->sample_fmts[i] != -1; i++) {
-+      temp =
-+          gst_ffmpeg_smpfmt_to_caps (codec->sample_fmts[i], context, codec_id);
-+      if (temp != NULL)
-+        gst_caps_append (caps, temp);
-+    }
-+  } else {
-+    GstCaps *temp;
-+    enum AVSampleFormat i;
-+    AVCodecContext ctx = { 0, };
-+
-+    ctx.channels = -1;
-+    caps = gst_caps_new_empty ();
-+    for (i = 0; i <= AV_SAMPLE_FMT_DBL; i++) {
-+      temp = gst_ffmpeg_smpfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
-+      if (temp != NULL) {
-+        gst_caps_append (caps, temp);
-+      }
-+    }
-+  }
-+  return caps;
-+}
-+
-+GstCaps *
-+gst_ffmpeg_codectype_to_video_caps (AVCodecContext * context,
-+    enum CodecID codec_id, gboolean encode, AVCodec * codec)
-+{
-+  GstCaps *caps;
-+
-+  GST_LOG ("context:%p, codec_id:%d, encode:%d, codec:%p",
-+      context, codec_id, encode, codec);
-+
-+  if (context) {
-+    caps = gst_ffmpeg_pixfmt_to_caps (context->pix_fmt, context, codec_id);
-+  } else {
-+    GstCaps *temp;
-+    enum PixelFormat i;
-+    AVCodecContext ctx = { 0, };
-+
-+    caps = gst_caps_new_empty ();
-+    for (i = 0; i < PIX_FMT_NB; i++) {
-+      ctx.width = -1;
-+      ctx.pix_fmt = i;
-+      temp = gst_ffmpeg_pixfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
-+      if (temp != NULL) {
-+        gst_caps_append (caps, temp);
-+      }
-+    }
-+  }
-+  return caps;
-+}
-+
-+/* Convert a FFMPEG codec Type and optional AVCodecContext
-+ * to a GstCaps. If the context is ommitted, no fixed values
-+ * for video/audio size will be included in the GstCaps
-+ *
-+ * AVMediaType is primarily meant for uncompressed data GstCaps!
-+ */
-+
-+GstCaps *
-+gst_ffmpeg_codectype_to_caps (enum AVMediaType codec_type,
-+    AVCodecContext * context, enum CodecID codec_id, gboolean encode)
-+{
-+  GstCaps *caps;
-+
-+  switch (codec_type) {
-+    case AVMEDIA_TYPE_VIDEO:
-+      caps =
-+          gst_ffmpeg_codectype_to_video_caps (context, codec_id, encode, NULL);
-+      break;
-+    case AVMEDIA_TYPE_AUDIO:
-+      caps =
-+          gst_ffmpeg_codectype_to_audio_caps (context, codec_id, encode, NULL);
-+      break;
-+    default:
-+      caps = NULL;
-+      break;
-+  }
-+
-+  return caps;
-+}
-+
-+/* Convert a GstCaps (audio/raw) to a FFMPEG SampleFmt
-+ * and other audio properties in a AVCodecContext.
-+ *
-+ * For usefullness, see below
-+ */
-+
-+static void
-+gst_ffmpeg_caps_to_smpfmt (const GstCaps * caps,
-+    AVCodecContext * context, gboolean raw)
-+{
-+  GstStructure *structure;
-+  gint depth = 0, width = 0, endianness = 0;
-+  gboolean signedness = FALSE;
-+  const gchar *name;
-+
-+  g_return_if_fail (gst_caps_get_size (caps) == 1);
-+  structure = gst_caps_get_structure (caps, 0);
-+
-+  gst_structure_get_int (structure, "channels", &context->channels);
-+  gst_structure_get_int (structure, "rate", &context->sample_rate);
-+  gst_structure_get_int (structure, "block_align", &context->block_align);
-+  gst_structure_get_int (structure, "bitrate", &context->bit_rate);
-+
-+  if (!raw)
-+    return;
-+
-+  name = gst_structure_get_name (structure);
-+
-+  if (!strcmp (name, "audio/x-raw-float")) {
-+    /* FLOAT */
-+    if (gst_structure_get_int (structure, "width", &width) &&
-+        gst_structure_get_int (structure, "endianness", &endianness)) {
-+      if (endianness == G_BYTE_ORDER) {
-+        if (width == 32)
-+          context->sample_fmt = AV_SAMPLE_FMT_FLT;
-+        else if (width == 64)
-+          context->sample_fmt = AV_SAMPLE_FMT_DBL;
-+      }
-+    }
-+  } else {
-+    /* INT */
-+    if (gst_structure_get_int (structure, "width", &width) &&
-+        gst_structure_get_int (structure, "depth", &depth) &&
-+        gst_structure_get_boolean (structure, "signed", &signedness) &&
-+        gst_structure_get_int (structure, "endianness", &endianness)) {
-+      if ((endianness == G_BYTE_ORDER) && (signedness == TRUE)) {
-+        if ((width == 16) && (depth == 16))
-+          context->sample_fmt = AV_SAMPLE_FMT_S16;
-+        else if ((width == 32) && (depth == 32))
-+          context->sample_fmt = AV_SAMPLE_FMT_S32;
-+      }
-+    }
-+  }
-+}
-+
-+
-+/* Convert a GstCaps (video/raw) to a FFMPEG PixFmt
-+ * and other video properties in a AVCodecContext.
-+ *
-+ * For usefullness, see below
-+ */
-+
-+static void
-+gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
-+    AVCodecContext * context, gboolean raw)
-+{
-+  GstStructure *structure;
-+  const GValue *fps;
-+  const GValue *par = NULL;
-+
-+  GST_DEBUG ("converting caps %" GST_PTR_FORMAT, caps);
-+  g_return_if_fail (gst_caps_get_size (caps) == 1);
-+  structure = gst_caps_get_structure (caps, 0);
-+
-+  gst_structure_get_int (structure, "width", &context->width);
-+  gst_structure_get_int (structure, "height", &context->height);
-+  gst_structure_get_int (structure, "bpp", &context->bits_per_coded_sample);
-+
-+  fps = gst_structure_get_value (structure, "framerate");
-+  if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
-+
-+    /* somehow these seem mixed up.. */
-+    context->time_base.den = gst_value_get_fraction_numerator (fps);
-+    context->time_base.num = gst_value_get_fraction_denominator (fps);
-+    context->ticks_per_frame = 1;
-+
-+    GST_DEBUG ("setting framerate %d/%d = %lf",
-+        context->time_base.den, context->time_base.num,
-+        1. * context->time_base.den / context->time_base.num);
-+  }
-+
-+  par = gst_structure_get_value (structure, "pixel-aspect-ratio");
-+  if (par && GST_VALUE_HOLDS_FRACTION (par)) {
-+
-+    context->sample_aspect_ratio.num = gst_value_get_fraction_numerator (par);
-+    context->sample_aspect_ratio.den = gst_value_get_fraction_denominator (par);
-+
-+    GST_DEBUG ("setting pixel-aspect-ratio %d/%d = %lf",
-+        context->sample_aspect_ratio.den, context->sample_aspect_ratio.num,
-+        1. * context->sample_aspect_ratio.den /
-+        context->sample_aspect_ratio.num);
-+  }
-+
-+  if (!raw)
-+    return;
-+
-+  g_return_if_fail (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps));
-+
-+  if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
-+    guint32 fourcc;
-+
-+    if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
-+      switch (fourcc) {
-+        case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
-+          context->pix_fmt = PIX_FMT_YUYV422;
-+          break;
-+        case GST_MAKE_FOURCC ('I', '4', '2', '0'):
-+          context->pix_fmt = PIX_FMT_YUV420P;
-+          break;
-+        case GST_MAKE_FOURCC ('A', '4', '2', '0'):
-+          context->pix_fmt = PIX_FMT_YUVA420P;
-+          break;
-+        case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
-+          context->pix_fmt = PIX_FMT_YUV411P;
-+          break;
-+        case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
-+          context->pix_fmt = PIX_FMT_YUV422P;
-+          break;
-+        case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
-+          context->pix_fmt = PIX_FMT_YUV410P;
-+          break;
-+#if 0
-+        case FIXME:
-+          context->pix_fmt = PIX_FMT_YUV444P;
-+          break;
-+#endif
-+      }
-+    }
-+  } else if (strcmp (gst_structure_get_name (structure),
-+          "video/x-raw-rgb") == 0) {
-+    gint bpp = 0, rmask = 0, endianness = 0;
-+
-+    if (gst_structure_get_int (structure, "bpp", &bpp) &&
-+        gst_structure_get_int (structure, "endianness", &endianness)) {
-+      if (gst_structure_get_int (structure, "red_mask", &rmask)) {
-+        switch (bpp) {
-+          case 32:
-+#if (G_BYTE_ORDER == G_BIG_ENDIAN)
-+            if (rmask == 0x00ff0000)
-+#else
-+            if (rmask == 0x0000ff00)
-+#endif
-+              context->pix_fmt = PIX_FMT_RGB32;
-+            break;
-+          case 24:
-+            if (rmask == 0x0000FF)
-+              context->pix_fmt = PIX_FMT_BGR24;
-+            else
-+              context->pix_fmt = PIX_FMT_RGB24;
-+            break;
-+          case 16:
-+            if (endianness == G_BYTE_ORDER)
-+              context->pix_fmt = PIX_FMT_RGB565;
-+            break;
-+          case 15:
-+            if (endianness == G_BYTE_ORDER)
-+              context->pix_fmt = PIX_FMT_RGB555;
-+            break;
-+          default:
-+            /* nothing */
-+            break;
-+        }
-+      } else {
-+        if (bpp == 8) {
-+          context->pix_fmt = PIX_FMT_PAL8;
-+          gst_ffmpeg_get_palette (caps, context);
-+        }
-+      }
-+    }
-+  } else if (strcmp (gst_structure_get_name (structure),
-+          "video/x-raw-gray") == 0) {
-+    gint bpp = 0;
-+
-+    if (gst_structure_get_int (structure, "bpp", &bpp)) {
-+      switch (bpp) {
-+        case 8:
-+          context->pix_fmt = PIX_FMT_GRAY8;
-+          break;
-+      }
-+    }
-+  }
-+}
-+
-+/* Convert a GstCaps and a FFMPEG codec Type to a
-+ * AVCodecContext. If the context is ommitted, no fixed values
-+ * for video/audio size will be included in the context
-+ *
-+ * AVMediaType is primarily meant for uncompressed data GstCaps!
-+ */
-+
-+void
-+gst_ffmpeg_caps_with_codectype (enum AVMediaType type,
-+    const GstCaps * caps, AVCodecContext * context)
-+{
-+  if (context == NULL)
-+    return;
-+
-+  switch (type) {
-+    case AVMEDIA_TYPE_VIDEO:
-+      gst_ffmpeg_caps_to_pixfmt (caps, context, TRUE);
-+      break;
-+
-+    case AVMEDIA_TYPE_AUDIO:
-+      gst_ffmpeg_caps_to_smpfmt (caps, context, TRUE);
-+      break;
-+
-+    default:
-+      /* unknown */
-+      break;
-+  }
-+}
-+
-+#if 0
-+static void
-+nal_escape (guint8 * dst, guint8 * src, guint size, guint * destsize)
-+{
-+  guint8 *dstp = dst;
-+  guint8 *srcp = src;
-+  guint8 *end = src + size;
-+  gint count = 0;
-+
-+  while (srcp < end) {
-+    if (count == 2 && *srcp <= 0x03) {
-+      GST_DEBUG ("added escape code");
-+      *dstp++ = 0x03;
-+      count = 0;
-+    }
-+    if (*srcp == 0)
-+      count++;
-+    else
-+      count = 0;
-+
-+    GST_DEBUG ("copy %02x, count %d", *srcp, count);
-+    *dstp++ = *srcp++;
-+  }
-+  *destsize = dstp - dst;
-+}
-+
-+/* copy the config, escaping NAL units as we iterate them, if something fails we
-+ * copy everything and hope for the best. */
-+static void
-+copy_config (guint8 * dst, guint8 * src, guint size, guint * destsize)
-+{
-+  guint8 *dstp = dst;
-+  guint8 *srcp = src;
-+  gint cnt, i;
-+  guint nalsize, esize;
-+
-+  /* check size */
-+  if (size < 7)
-+    goto full_copy;
-+
-+  /* check version */
-+  if (*srcp != 1)
-+    goto full_copy;
-+
-+  cnt = *(srcp + 5) & 0x1f;     /* Number of sps */
-+
-+  GST_DEBUG ("num SPS %d", cnt);
-+
-+  memcpy (dstp, srcp, 6);
-+  srcp += 6;
-+  dstp += 6;
-+
-+  for (i = 0; i < cnt; i++) {
-+    GST_DEBUG ("copy SPS %d", i);
-+    nalsize = (srcp[0] << 8) | srcp[1];
-+    nal_escape (dstp + 2, srcp + 2, nalsize, &esize);
-+    dstp[0] = esize >> 8;
-+    dstp[1] = esize & 0xff;
-+    dstp += esize + 2;
-+    srcp += nalsize + 2;
-+  }
-+
-+  cnt = *(dstp++) = *(srcp++);  /* Number of pps */
-+
-+  GST_DEBUG ("num PPS %d", cnt);
-+
-+  for (i = 0; i < cnt; i++) {
-+    GST_DEBUG ("copy PPS %d", i);
-+    nalsize = (srcp[0] << 8) | srcp[1];
-+    nal_escape (dstp + 2, srcp + 2, nalsize, &esize);
-+    dstp[0] = esize >> 8;
-+    dstp[1] = esize & 0xff;
-+    dstp += esize + 2;
-+    srcp += nalsize + 2;
-+  }
-+  *destsize = dstp - dst;
-+
-+  return;
-+
-+full_copy:
-+  {
-+    GST_DEBUG ("something unexpected, doing full copy");
-+    memcpy (dst, src, size);
-+    *destsize = size;
-+    return;
-+  }
-+}
-+#endif
-+
-+/*
-+ * caps_with_codecid () transforms a GstCaps for a known codec
-+ * ID into a filled-in context.
-+ * codec_data from caps will override possible extradata already in the context
-+ */
-+
-+void
-+gst_ffmpeg_caps_with_codecid (enum CodecID codec_id,
-+    enum AVMediaType codec_type, const GstCaps * caps, AVCodecContext * context)
-+{
-+  GstStructure *str;
-+  const GValue *value;
-+  const GstBuffer *buf;
-+
-+  GST_LOG ("codec_id:%d, codec_type:%d, caps:%" GST_PTR_FORMAT " context:%p",
-+      codec_id, codec_type, caps, context);
-+
-+  if (!context || !gst_caps_get_size (caps))
-+    return;
-+
-+  str = gst_caps_get_structure (caps, 0);
-+
-+  /* extradata parsing (esds [mpeg4], wma/wmv, msmpeg4v1/2/3, etc.) */
-+  if ((value = gst_structure_get_value (str, "codec_data"))) {
-+    guint size;
-+    guint8 *data;
-+
-+    buf = GST_BUFFER_CAST (gst_value_get_mini_object (value));
-+    size = GST_BUFFER_SIZE (buf);
-+    data = GST_BUFFER_DATA (buf);
-+
-+    /* free the old one if it is there */
-+    if (context->extradata)
-+      av_free (context->extradata);
-+
-+#if 0
-+    if (codec_id == CODEC_ID_H264) {
-+      guint extrasize;
-+
-+      GST_DEBUG ("copy, escaping codec_data %d", size);
-+      /* ffmpeg h264 expects the codec_data to be escaped, there is no real
-+       * reason for this but let's just escape it for now. Start by allocating
-+       * enough space, x2 is more than enough.
-+       *
-+       * FIXME, we disabled escaping because some file already contain escaped
-+       * codec_data and then we escape twice and fail. It's better to leave it
-+       * as is, as that is what most players do. */
-+      context->extradata =
-+          av_mallocz (GST_ROUND_UP_16 (size * 2 +
-+              FF_INPUT_BUFFER_PADDING_SIZE));
-+      copy_config (context->extradata, data, size, &extrasize);
-+      GST_DEBUG ("escaped size: %d", extrasize);
-+      context->extradata_size = extrasize;
-+    } else
-+#endif
-+    {
-+      /* allocate with enough padding */
-+      GST_DEBUG ("copy codec_data");
-+      context->extradata =
-+          av_mallocz (GST_ROUND_UP_16 (size + FF_INPUT_BUFFER_PADDING_SIZE));
-+      memcpy (context->extradata, data, size);
-+      context->extradata_size = size;
-+    }
-+
-+    /* Hack for VC1. Sometimes the first (length) byte is 0 for some files */
-+    if (codec_id == CODEC_ID_VC1 && size > 0 && data[0] == 0) {
-+      context->extradata[0] = (guint8) size;
-+    }
-+
-+    GST_DEBUG ("have codec data of size %d", size);
-+  } else if (context->extradata == NULL && codec_id != CODEC_ID_AAC_LATM &&
-+      codec_id != CODEC_ID_FLAC) {
-+    /* no extradata, alloc dummy with 0 sized, some codecs insist on reading
-+     * extradata anyway which makes then segfault. */
-+    context->extradata =
-+        av_mallocz (GST_ROUND_UP_16 (FF_INPUT_BUFFER_PADDING_SIZE));
-+    context->extradata_size = 0;
-+    GST_DEBUG ("no codec data");
-+  }
-+
-+  switch (codec_id) {
-+    case CODEC_ID_MPEG4:
-+    {
-+      const gchar *mime = gst_structure_get_name (str);
-+
-+      if (!strcmp (mime, "video/x-divx"))
-+        context->codec_tag = GST_MAKE_FOURCC ('D', 'I', 'V', 'X');
-+      else if (!strcmp (mime, "video/x-xvid"))
-+        context->codec_tag = GST_MAKE_FOURCC ('X', 'V', 'I', 'D');
-+      else if (!strcmp (mime, "video/x-3ivx"))
-+        context->codec_tag = GST_MAKE_FOURCC ('3', 'I', 'V', '1');
-+      else if (!strcmp (mime, "video/mpeg"))
-+        context->codec_tag = GST_MAKE_FOURCC ('m', 'p', '4', 'v');
-+    }
-+      break;
-+
-+    case CODEC_ID_SVQ3:
-+      /* FIXME: this is a workaround for older gst-plugins releases
-+       * (<= 0.8.9). This should be removed at some point, because
-+       * it causes wrong decoded frame order. */
-+      if (!context->extradata) {
-+        gint halfpel_flag, thirdpel_flag, low_delay, unknown_svq3_flag;
-+        guint16 flags;
-+
-+        if (gst_structure_get_int (str, "halfpel_flag", &halfpel_flag) ||
-+            gst_structure_get_int (str, "thirdpel_flag", &thirdpel_flag) ||
-+            gst_structure_get_int (str, "low_delay", &low_delay) ||
-+            gst_structure_get_int (str, "unknown_svq3_flag",
-+                &unknown_svq3_flag)) {
-+          context->extradata = (guint8 *) av_mallocz (0x64);
-+          g_stpcpy ((gchar *) context->extradata, "SVQ3");
-+          flags = 1 << 3;
-+          flags |= low_delay;
-+          flags = flags << 2;
-+          flags |= unknown_svq3_flag;
-+          flags = flags << 6;
-+          flags |= halfpel_flag;
-+          flags = flags << 1;
-+          flags |= thirdpel_flag;
-+          flags = flags << 3;
-+
-+          flags = GUINT16_FROM_LE (flags);
-+
-+          memcpy ((gchar *) context->extradata + 0x62, &flags, 2);
-+          context->extradata_size = 0x64;
-+        }
-+      }
-+      break;
-+
-+    case CODEC_ID_MSRLE:
-+    case CODEC_ID_QTRLE:
-+    case CODEC_ID_TSCC:
-+    case CODEC_ID_CSCD:
-+    case CODEC_ID_APE:
-+    {
-+      gint depth;
-+
-+      if (gst_structure_get_int (str, "depth", &depth)) {
-+        context->bits_per_coded_sample = depth;
-+      } else {
-+        GST_WARNING ("No depth field in caps %" GST_PTR_FORMAT, caps);
-+      }
-+
-+    }
-+      break;
-+
-+    case CODEC_ID_RV10:
-+    case CODEC_ID_RV20:
-+    case CODEC_ID_RV30:
-+    case CODEC_ID_RV40:
-+    {
-+      gint format;
-+
-+      if (gst_structure_get_int (str, "format", &format))
-+        context->sub_id = format;
-+
-+      break;
-+    }
-+    case CODEC_ID_COOK:
-+    case CODEC_ID_RA_288:
-+    case CODEC_ID_RA_144:
-+    case CODEC_ID_SIPR:
-+    {
-+      gint leaf_size;
-+      gint bitrate;
-+
-+      if (gst_structure_get_int (str, "leaf_size", &leaf_size))
-+        context->block_align = leaf_size;
-+      if (gst_structure_get_int (str, "bitrate", &bitrate))
-+        context->bit_rate = bitrate;
-+    }
-+    case CODEC_ID_ALAC:
-+      gst_structure_get_int (str, "samplesize",
-+          &context->bits_per_coded_sample);
-+      break;
-+
-+    case CODEC_ID_DVVIDEO:
-+    {
-+      guint32 fourcc;
-+
-+      if (gst_structure_get_fourcc (str, "format", &fourcc))
-+        switch (fourcc) {
-+          case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
-+            context->pix_fmt = PIX_FMT_YUYV422;
-+            break;
-+          case GST_MAKE_FOURCC ('I', '4', '2', '0'):
-+            context->pix_fmt = PIX_FMT_YUV420P;
-+            break;
-+          case GST_MAKE_FOURCC ('A', '4', '2', '0'):
-+            context->pix_fmt = PIX_FMT_YUVA420P;
-+            break;
-+          case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
-+            context->pix_fmt = PIX_FMT_YUV411P;
-+            break;
-+          case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
-+            context->pix_fmt = PIX_FMT_YUV422P;
-+            break;
-+          case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
-+            context->pix_fmt = PIX_FMT_YUV410P;
-+            break;
-+          default:
-+            GST_WARNING ("couldn't convert fourcc %" GST_FOURCC_FORMAT
-+                " to a pixel format", GST_FOURCC_ARGS (fourcc));
-+            break;
-+        }
-+      break;
-+    }
-+    case CODEC_ID_H263P:
-+    {
-+      gboolean val;
-+
-+      if (!gst_structure_get_boolean (str, "annex-f", &val) || val)
-+        context->flags |= CODEC_FLAG_4MV;
-+      else
-+        context->flags &= ~CODEC_FLAG_4MV;
-+      if ((!gst_structure_get_boolean (str, "annex-i", &val) || val) &&
-+          (!gst_structure_get_boolean (str, "annex-t", &val) || val))
-+        context->flags |= CODEC_FLAG_AC_PRED;
-+      else
-+        context->flags &= ~CODEC_FLAG_AC_PRED;
-+      if (!gst_structure_get_boolean (str, "annex-j", &val) || val)
-+        context->flags |= CODEC_FLAG_LOOP_FILTER;
-+      else
-+        context->flags &= ~CODEC_FLAG_LOOP_FILTER;
-+      break;
-+    }
-+    case CODEC_ID_ADPCM_G726:
-+    {
-+      const gchar *layout;
-+
-+      if ((layout = gst_structure_get_string (str, "layout"))) {
-+        if (!strcmp (layout, "g721")) {
-+          context->sample_rate = 8000;
-+          context->channels = 1;
-+          context->bit_rate = 32000;
-+        }
-+      }
-+      break;
-+    }
-+    default:
-+      break;
-+  }
-+
-+  if (!gst_caps_is_fixed (caps))
-+    return;
-+
-+  /* common properties (width, height, fps) */
-+  switch (codec_type) {
-+    case AVMEDIA_TYPE_VIDEO:
-+      gst_ffmpeg_caps_to_pixfmt (caps, context, codec_id == CODEC_ID_RAWVIDEO);
-+      gst_ffmpeg_get_palette (caps, context);
-+      break;
-+    case AVMEDIA_TYPE_AUDIO:
-+      gst_ffmpeg_caps_to_smpfmt (caps, context, FALSE);
-+      break;
-+    default:
-+      break;
-+  }
-+
-+  /* fixup of default settings */
-+  switch (codec_id) {
-+    case CODEC_ID_QCELP:
-+      /* QCELP is always mono, no matter what the caps say */
-+      context->channels = 1;
-+      break;
-+    default:
-+      break;
-+  }
-+}
-+
-+/* _formatid_to_caps () is meant for muxers/demuxers, it
-+ * transforms a name (ffmpeg way of ID'ing these, why don't
-+ * they have unique numerical IDs?) to the corresponding
-+ * caps belonging to that mux-format
-+ *
-+ * Note: we don't need any additional info because the caps
-+ * isn't supposed to contain any useful info besides the
-+ * media type anyway
-+ */
-+
-+GstCaps *
-+gst_ffmpeg_formatid_to_caps (const gchar * format_name)
-+{
-+  GstCaps *caps = NULL;
-+
-+  if (!strcmp (format_name, "mpeg")) {
-+    caps = gst_caps_new_simple ("video/mpeg",
-+        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
-+  } else if (!strcmp (format_name, "mpegts")) {
-+    caps = gst_caps_new_simple ("video/mpegts",
-+        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
-+  } else if (!strcmp (format_name, "rm")) {
-+    caps = gst_caps_new_simple ("application/x-pn-realmedia",
-+        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
-+  } else if (!strcmp (format_name, "asf")) {
-+    caps = gst_caps_new_simple ("video/x-ms-asf", NULL);
-+  } else if (!strcmp (format_name, "avi")) {
-+    caps = gst_caps_new_simple ("video/x-msvideo", NULL);
-+  } else if (!strcmp (format_name, "wav")) {
-+    caps = gst_caps_new_simple ("audio/x-wav", NULL);
-+  } else if (!strcmp (format_name, "ape")) {
-+    caps = gst_caps_new_simple ("application/x-ape", NULL);
-+  } else if (!strcmp (format_name, "swf")) {
-+    caps = gst_caps_new_simple ("application/x-shockwave-flash", NULL);
-+  } else if (!strcmp (format_name, "au")) {
-+    caps = gst_caps_new_simple ("audio/x-au", NULL);
-+  } else if (!strcmp (format_name, "dv")) {
-+    caps = gst_caps_new_simple ("video/x-dv",
-+        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
-+  } else if (!strcmp (format_name, "4xm")) {
-+    caps = gst_caps_new_simple ("video/x-4xm", NULL);
-+  } else if (!strcmp (format_name, "matroska")) {
-+    caps = gst_caps_new_simple ("video/x-matroska", NULL);
-+  } else if (!strcmp (format_name, "mp3")) {
-+    caps = gst_caps_new_simple ("application/x-id3", NULL);
-+  } else if (!strcmp (format_name, "flic")) {
-+    caps = gst_caps_new_simple ("video/x-fli", NULL);
-+  } else if (!strcmp (format_name, "flv")) {
-+    caps = gst_caps_new_simple ("video/x-flv", NULL);
-+  } else if (!strcmp (format_name, "tta")) {
-+    caps = gst_caps_new_simple ("audio/x-ttafile", NULL);
-+  } else if (!strcmp (format_name, "aiff")) {
-+    caps = gst_caps_new_simple ("audio/x-aiff", NULL);
-+  } else if (!strcmp (format_name, "mov_mp4_m4a_3gp_3g2")) {
-+    caps =
-+        gst_caps_from_string
-+        ("application/x-3gp; video/quicktime; audio/x-m4a");
-+  } else if (!strcmp (format_name, "mov")) {
-+    caps = gst_caps_from_string ("video/quicktime,variant=(string)apple");
-+  } else if (!strcmp (format_name, "mp4")) {
-+    caps = gst_caps_from_string ("video/quicktime,variant=(string)iso");
-+  } else if (!strcmp (format_name, "3gp")) {
-+    caps = gst_caps_from_string ("video/quicktime,variant=(string)3gpp");
-+  } else if (!strcmp (format_name, "3g2")) {
-+    caps = gst_caps_from_string ("video/quicktime,variant=(string)3g2");
-+  } else if (!strcmp (format_name, "psp")) {
-+    caps = gst_caps_from_string ("video/quicktime,variant=(string)psp");
-+  } else if (!strcmp (format_name, "ipod")) {
-+    caps = gst_caps_from_string ("video/quicktime,variant=(string)ipod");
-+  } else if (!strcmp (format_name, "aac")) {
-+    caps = gst_caps_new_simple ("audio/mpeg",
-+        "mpegversion", G_TYPE_INT, 4, NULL);
-+  } else if (!strcmp (format_name, "gif")) {
-+    caps = gst_caps_from_string ("image/gif");
-+  } else if (!strcmp (format_name, "ogg")) {
-+    caps = gst_caps_from_string ("application/ogg");
-+  } else if (!strcmp (format_name, "mxf") || !strcmp (format_name, "mxf_d10")) {
-+    caps = gst_caps_from_string ("application/mxf");
-+  } else if (!strcmp (format_name, "gxf")) {
-+    caps = gst_caps_from_string ("application/gxf");
-+  } else if (!strcmp (format_name, "yuv4mpegpipe")) {
-+    caps = gst_caps_new_simple ("application/x-yuv4mpeg",
-+        "y4mversion", G_TYPE_INT, 2, NULL);
-+  } else if (!strcmp (format_name, "mpc")) {
-+    caps = gst_caps_from_string ("audio/x-musepack, streamversion = (int) 7");
-+  } else if (!strcmp (format_name, "vqf")) {
-+    caps = gst_caps_from_string ("audio/x-vqf");
-+  } else if (!strcmp (format_name, "nsv")) {
-+    caps = gst_caps_from_string ("video/x-nsv");
-+  } else if (!strcmp (format_name, "amr")) {
-+    caps = gst_caps_from_string ("audio/x-amr-nb-sh");
-+  } else if (!strcmp (format_name, "webm")) {
-+    caps = gst_caps_from_string ("video/webm");
-+  } else {
-+    gchar *name;
-+
-+    GST_LOG ("Could not create stream format caps for %s", format_name);
-+    name = g_strdup_printf ("application/x-gst_ff-%s", format_name);
-+    caps = gst_caps_new_simple (name, NULL);
-+    g_free (name);
-+  }
-+
-+  return caps;
-+}
-+
-+gboolean
-+gst_ffmpeg_formatid_get_codecids (const gchar * format_name,
-+    enum CodecID ** video_codec_list, enum CodecID ** audio_codec_list,
-+    AVOutputFormat * plugin)
-+{
-+  static enum CodecID tmp_vlist[] = {
-+    CODEC_ID_NONE,
-+    CODEC_ID_NONE
-+  };
-+  static enum CodecID tmp_alist[] = {
-+    CODEC_ID_NONE,
-+    CODEC_ID_NONE
-+  };
-+
-+  GST_LOG ("format_name : %s", format_name);
-+
-+  if (!strcmp (format_name, "mp4")) {
-+    static enum CodecID mp4_video_list[] = {
-+      CODEC_ID_MPEG4, CODEC_ID_H264,
-+      CODEC_ID_MJPEG,
-+      CODEC_ID_NONE
-+    };
-+    static enum CodecID mp4_audio_list[] = {
-+      CODEC_ID_AAC, CODEC_ID_MP3,
-+      CODEC_ID_NONE
-+    };
-+
-+    *video_codec_list = mp4_video_list;
-+    *audio_codec_list = mp4_audio_list;
-+  } else if (!strcmp (format_name, "mpeg")) {
-+    static enum CodecID mpeg_video_list[] = { CODEC_ID_MPEG1VIDEO,
-+      CODEC_ID_MPEG2VIDEO,
-+      CODEC_ID_H264,
-+      CODEC_ID_NONE
-+    };
-+    static enum CodecID mpeg_audio_list[] = { CODEC_ID_MP1,
-+      CODEC_ID_MP2,
-+      CODEC_ID_MP3,
-+      CODEC_ID_NONE
-+    };
-+
-+    *video_codec_list = mpeg_video_list;
-+    *audio_codec_list = mpeg_audio_list;
-+  } else if (!strcmp (format_name, "dvd")) {
-+    static enum CodecID mpeg_video_list[] = { CODEC_ID_MPEG2VIDEO,
-+      CODEC_ID_NONE
-+    };
-+    static enum CodecID mpeg_audio_list[] = { CODEC_ID_MP2,
-+      CODEC_ID_AC3,
-+      CODEC_ID_DTS,
-+      CODEC_ID_PCM_S16BE,
-+      CODEC_ID_NONE
-+    };
-+
-+    *video_codec_list = mpeg_video_list;
-+    *audio_codec_list = mpeg_audio_list;
-+  } else if (!strcmp (format_name, "mpegts")) {
-+    static enum CodecID mpegts_video_list[] = { CODEC_ID_MPEG1VIDEO,
-+      CODEC_ID_MPEG2VIDEO,
-+      CODEC_ID_H264,
-+      CODEC_ID_NONE
-+    };
-+    static enum CodecID mpegts_audio_list[] = { CODEC_ID_MP2,
-+      CODEC_ID_MP3,
-+      CODEC_ID_AC3,
-+      CODEC_ID_DTS,
-+      CODEC_ID_AAC,
-+      CODEC_ID_NONE
-+    };
-+
-+    *video_codec_list = mpegts_video_list;
-+    *audio_codec_list = mpegts_audio_list;
-+  } else if (!strcmp (format_name, "vob")) {
-+    static enum CodecID vob_video_list[] =
-+        { CODEC_ID_MPEG2VIDEO, CODEC_ID_NONE };
-+    static enum CodecID vob_audio_list[] = { CODEC_ID_MP2, CODEC_ID_AC3,
-+      CODEC_ID_DTS, CODEC_ID_NONE
-+    };
-+
-+    *video_codec_list = vob_video_list;
-+    *audio_codec_list = vob_audio_list;
-+  } else if (!strcmp (format_name, "flv")) {
-+    static enum CodecID flv_video_list[] = { CODEC_ID_FLV1, CODEC_ID_NONE };
-+    static enum CodecID flv_audio_list[] = { CODEC_ID_MP3, CODEC_ID_NONE };
-+
-+    *video_codec_list = flv_video_list;
-+    *audio_codec_list = flv_audio_list;
-+  } else if (!strcmp (format_name, "asf")) {
-+    static enum CodecID asf_video_list[] =
-+        { CODEC_ID_WMV1, CODEC_ID_WMV2, CODEC_ID_MSMPEG4V3, CODEC_ID_NONE };
-+    static enum CodecID asf_audio_list[] =
-+        { CODEC_ID_WMAV1, CODEC_ID_WMAV2, CODEC_ID_MP3, CODEC_ID_NONE };
-+
-+    *video_codec_list = asf_video_list;
-+    *audio_codec_list = asf_audio_list;
-+  } else if (!strcmp (format_name, "dv")) {
-+    static enum CodecID dv_video_list[] = { CODEC_ID_DVVIDEO, CODEC_ID_NONE };
-+    static enum CodecID dv_audio_list[] = { CODEC_ID_PCM_S16LE, CODEC_ID_NONE };
-+
-+    *video_codec_list = dv_video_list;
-+    *audio_codec_list = dv_audio_list;
-+  } else if (!strcmp (format_name, "mov")) {
-+    static enum CodecID mov_video_list[] = {
-+      CODEC_ID_SVQ1, CODEC_ID_SVQ3, CODEC_ID_MPEG4,
-+      CODEC_ID_H263, CODEC_ID_H263P,
-+      CODEC_ID_H264, CODEC_ID_DVVIDEO,
-+      CODEC_ID_MJPEG,
-+      CODEC_ID_NONE
-+    };
-+    static enum CodecID mov_audio_list[] = {
-+      CODEC_ID_PCM_MULAW, CODEC_ID_PCM_ALAW, CODEC_ID_ADPCM_IMA_QT,
-+      CODEC_ID_MACE3, CODEC_ID_MACE6, CODEC_ID_AAC,
-+      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
-+      CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE,
-+      CODEC_ID_MP3, CODEC_ID_NONE
-+    };
-+
-+    *video_codec_list = mov_video_list;
-+    *audio_codec_list = mov_audio_list;
-+  } else if ((!strcmp (format_name, "3gp") || !strcmp (format_name, "3g2"))) {
-+    static enum CodecID tgp_video_list[] = {
-+      CODEC_ID_MPEG4, CODEC_ID_H263, CODEC_ID_H263P, CODEC_ID_H264,
-+      CODEC_ID_NONE
-+    };
-+    static enum CodecID tgp_audio_list[] = {
-+      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
-+      CODEC_ID_AAC,
-+      CODEC_ID_NONE
-+    };
-+
-+    *video_codec_list = tgp_video_list;
-+    *audio_codec_list = tgp_audio_list;
-+  } else if (!strcmp (format_name, "mmf")) {
-+    static enum CodecID mmf_audio_list[] = {
-+      CODEC_ID_ADPCM_YAMAHA, CODEC_ID_NONE
-+    };
-+    *video_codec_list = NULL;
-+    *audio_codec_list = mmf_audio_list;
-+  } else if (!strcmp (format_name, "amr")) {
-+    static enum CodecID amr_audio_list[] = {
-+      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
-+      CODEC_ID_NONE
-+    };
-+    *video_codec_list = NULL;
-+    *audio_codec_list = amr_audio_list;
-+  } else if (!strcmp (format_name, "gif")) {
-+    static enum CodecID gif_image_list[] = {
-+      CODEC_ID_RAWVIDEO, CODEC_ID_NONE
-+    };
-+    *video_codec_list = gif_image_list;
-+    *audio_codec_list = NULL;
-+  } else if ((plugin->audio_codec != CODEC_ID_NONE) ||
-+      (plugin->video_codec != CODEC_ID_NONE)) {
-+    tmp_vlist[0] = plugin->video_codec;
-+    tmp_alist[0] = plugin->audio_codec;
-+
-+    *video_codec_list = tmp_vlist;
-+    *audio_codec_list = tmp_alist;
-+  } else {
-+    GST_LOG ("Format %s not found", format_name);
-+    return FALSE;
-+  }
-+
-+  return TRUE;
-+}
-+
-+/* Convert a GstCaps to a FFMPEG codec ID. Size et all
-+ * are omitted, that can be queried by the user itself,
-+ * we're not eating the GstCaps or anything
-+ * A pointer to an allocated context is also needed for
-+ * optional extra info
-+ */
-+
-+enum CodecID
-+gst_ffmpeg_caps_to_codecid (const GstCaps * caps, AVCodecContext * context)
-+{
-+  enum CodecID id = CODEC_ID_NONE;
-+  const gchar *mimetype;
-+  const GstStructure *structure;
-+  gboolean video = FALSE, audio = FALSE;        /* we want to be sure! */
-+
-+  g_return_val_if_fail (caps != NULL, CODEC_ID_NONE);
-+  g_return_val_if_fail (gst_caps_get_size (caps) == 1, CODEC_ID_NONE);
-+  structure = gst_caps_get_structure (caps, 0);
-+
-+  mimetype = gst_structure_get_name (structure);
-+
-+  if (!strcmp (mimetype, "video/x-raw-rgb") ||
-+      !strcmp (mimetype, "video/x-raw-yuv")) {
-+    id = CODEC_ID_RAWVIDEO;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-raw-int")) {
-+    gint depth, width, endianness;
-+    gboolean signedness;
-+
-+    if (gst_structure_get_int (structure, "endianness", &endianness) &&
-+        gst_structure_get_boolean (structure, "signed", &signedness) &&
-+        gst_structure_get_int (structure, "width", &width) &&
-+        gst_structure_get_int (structure, "depth", &depth) && depth == width) {
-+      switch (depth) {
-+        case 8:
-+          if (signedness) {
-+            id = CODEC_ID_PCM_S8;
-+          } else {
-+            id = CODEC_ID_PCM_U8;
-+          }
-+          break;
-+        case 16:
-+          switch (endianness) {
-+            case G_BIG_ENDIAN:
-+              if (signedness) {
-+                id = CODEC_ID_PCM_S16BE;
-+              } else {
-+                id = CODEC_ID_PCM_U16BE;
-+              }
-+              break;
-+            case G_LITTLE_ENDIAN:
-+              if (signedness) {
-+                id = CODEC_ID_PCM_S16LE;
-+              } else {
-+                id = CODEC_ID_PCM_U16LE;
-+              }
-+              break;
-+          }
-+          break;
-+      }
-+      if (id != CODEC_ID_NONE)
-+        audio = TRUE;
-+    }
-+  } else if (!strcmp (mimetype, "audio/x-mulaw")) {
-+    id = CODEC_ID_PCM_MULAW;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-alaw")) {
-+    id = CODEC_ID_PCM_ALAW;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-dv")) {
-+    gboolean sys_strm;
-+
-+    if (gst_structure_get_boolean (structure, "systemstream", &sys_strm) &&
-+        !sys_strm) {
-+      id = CODEC_ID_DVVIDEO;
-+      video = TRUE;
-+    }
-+  } else if (!strcmp (mimetype, "audio/x-dv")) {        /* ??? */
-+    id = CODEC_ID_DVAUDIO;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-h263")) {
-+    const gchar *h263version =
-+        gst_structure_get_string (structure, "h263version");
-+    if (h263version && !strcmp (h263version, "h263p"))
-+      id = CODEC_ID_H263P;
-+    else
-+      id = CODEC_ID_H263;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-intel-h263")) {
-+    id = CODEC_ID_H263I;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-h261")) {
-+    id = CODEC_ID_H261;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/mpeg")) {
-+    gboolean sys_strm;
-+    gint mpegversion;
-+
-+    if (gst_structure_get_boolean (structure, "systemstream", &sys_strm) &&
-+        gst_structure_get_int (structure, "mpegversion", &mpegversion) &&
-+        !sys_strm) {
-+      switch (mpegversion) {
-+        case 1:
-+          id = CODEC_ID_MPEG1VIDEO;
-+          break;
-+        case 2:
-+          id = CODEC_ID_MPEG2VIDEO;
-+          break;
-+        case 4:
-+          id = CODEC_ID_MPEG4;
-+          break;
-+      }
-+    }
-+    if (id != CODEC_ID_NONE)
-+      video = TRUE;
-+  } else if (!strcmp (mimetype, "image/jpeg")) {
-+    id = CODEC_ID_MJPEG;        /* A... B... */
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-jpeg-b")) {
-+    id = CODEC_ID_MJPEGB;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-wmv")) {
-+    gint wmvversion = 0;
-+
-+    if (gst_structure_get_int (structure, "wmvversion", &wmvversion)) {
-+      switch (wmvversion) {
-+        case 1:
-+          id = CODEC_ID_WMV1;
-+          break;
-+        case 2:
-+          id = CODEC_ID_WMV2;
-+          break;
-+        case 3:
-+        {
-+          guint32 fourcc;
-+
-+          /* WMV3 unless the fourcc exists and says otherwise */
-+          id = CODEC_ID_WMV3;
-+
-+          if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
-+            if ((fourcc == GST_MAKE_FOURCC ('W', 'V', 'C', '1')) ||
-+                (fourcc == GST_MAKE_FOURCC ('W', 'M', 'V', 'A'))) {
-+              id = CODEC_ID_VC1;
-+            }
-+          }
-+        }
-+          break;
-+      }
-+    }
-+    if (id != CODEC_ID_NONE)
-+      video = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-vorbis")) {
-+    id = CODEC_ID_VORBIS;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-qdm2")) {
-+    id = CODEC_ID_QDM2;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "audio/mpeg")) {
-+    gint layer = 0;
-+    gint mpegversion = 0;
-+
-+    if (gst_structure_get_int (structure, "mpegversion", &mpegversion)) {
-+      switch (mpegversion) {
-+        case 2:                /* ffmpeg uses faad for both... */
-+        case 4:
-+          id = CODEC_ID_AAC;
-+          break;
-+        case 1:
-+          if (gst_structure_get_int (structure, "layer", &layer)) {
-+            switch (layer) {
-+              case 1:
-+                id = CODEC_ID_MP1;
-+                break;
-+              case 2:
-+                id = CODEC_ID_MP2;
-+                break;
-+              case 3:
-+                id = CODEC_ID_MP3;
-+                break;
-+            }
-+          }
-+      }
-+    }
-+    if (id != CODEC_ID_NONE)
-+      audio = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-musepack")) {
-+    gint streamversion = -1;
-+
-+    if (gst_structure_get_int (structure, "streamversion", &streamversion)) {
-+      if (streamversion == 7)
-+        id = CODEC_ID_MUSEPACK7;
-+    } else {
-+      id = CODEC_ID_MUSEPACK7;
-+    }
-+  } else if (!strcmp (mimetype, "audio/x-wma")) {
-+    gint wmaversion = 0;
-+
-+    if (gst_structure_get_int (structure, "wmaversion", &wmaversion)) {
-+      switch (wmaversion) {
-+        case 1:
-+          id = CODEC_ID_WMAV1;
-+          break;
-+        case 2:
-+          id = CODEC_ID_WMAV2;
-+          break;
-+        case 3:
-+          id = CODEC_ID_WMAPRO;
-+          break;
-+      }
-+    }
-+    if (id != CODEC_ID_NONE)
-+      audio = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-wms")) {
-+    id = CODEC_ID_WMAVOICE;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-ac3")) {
-+    id = CODEC_ID_AC3;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-eac3")) {
-+    id = CODEC_ID_EAC3;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-vnd.sony.atrac3") ||
-+      !strcmp (mimetype, "audio/atrac3")) {
-+    id = CODEC_ID_ATRAC3;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-dts")) {
-+    id = CODEC_ID_DTS;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "application/x-ape")) {
-+    id = CODEC_ID_APE;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-msmpeg")) {
-+    gint msmpegversion = 0;
-+
-+    if (gst_structure_get_int (structure, "msmpegversion", &msmpegversion)) {
-+      switch (msmpegversion) {
-+        case 41:
-+          id = CODEC_ID_MSMPEG4V1;
-+          break;
-+        case 42:
-+          id = CODEC_ID_MSMPEG4V2;
-+          break;
-+        case 43:
-+          id = CODEC_ID_MSMPEG4V3;
-+          break;
-+      }
-+    }
-+    if (id != CODEC_ID_NONE)
-+      video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-svq")) {
-+    gint svqversion = 0;
-+
-+    if (gst_structure_get_int (structure, "svqversion", &svqversion)) {
-+      switch (svqversion) {
-+        case 1:
-+          id = CODEC_ID_SVQ1;
-+          break;
-+        case 3:
-+          id = CODEC_ID_SVQ3;
-+          break;
-+      }
-+    }
-+    if (id != CODEC_ID_NONE)
-+      video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-huffyuv")) {
-+    id = CODEC_ID_HUFFYUV;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-mace")) {
-+    gint maceversion = 0;
-+
-+    if (gst_structure_get_int (structure, "maceversion", &maceversion)) {
-+      switch (maceversion) {
-+        case 3:
-+          id = CODEC_ID_MACE3;
-+          break;
-+        case 6:
-+          id = CODEC_ID_MACE6;
-+          break;
-+      }
-+    }
-+    if (id != CODEC_ID_NONE)
-+      audio = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-theora")) {
-+    id = CODEC_ID_THEORA;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-vp3")) {
-+    id = CODEC_ID_VP3;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-vp5")) {
-+    id = CODEC_ID_VP5;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-vp6")) {
-+    id = CODEC_ID_VP6;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-vp6-flash")) {
-+    id = CODEC_ID_VP6F;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-vp6-alpha")) {
-+    id = CODEC_ID_VP6A;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-vp8")) {
-+    id = CODEC_ID_VP8;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-flash-screen")) {
-+    id = CODEC_ID_FLASHSV;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-indeo")) {
-+    gint indeoversion = 0;
-+
-+    if (gst_structure_get_int (structure, "indeoversion", &indeoversion)) {
-+      switch (indeoversion) {
-+        case 5:
-+          id = CODEC_ID_INDEO5;
-+          break;
-+        case 3:
-+          id = CODEC_ID_INDEO3;
-+          break;
-+        case 2:
-+          id = CODEC_ID_INDEO2;
-+          break;
-+      }
-+      if (id != CODEC_ID_NONE)
-+        video = TRUE;
-+    }
-+  } else if (!strcmp (mimetype, "video/x-divx")) {
-+    gint divxversion = 0;
-+
-+    if (gst_structure_get_int (structure, "divxversion", &divxversion)) {
-+      switch (divxversion) {
-+        case 3:
-+          id = CODEC_ID_MSMPEG4V3;
-+          break;
-+        case 4:
-+        case 5:
-+          id = CODEC_ID_MPEG4;
-+          break;
-+      }
-+    }
-+    if (id != CODEC_ID_NONE)
-+      video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-3ivx")) {
-+    id = CODEC_ID_MPEG4;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-xvid")) {
-+    id = CODEC_ID_MPEG4;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-ffv")) {
-+    gint ffvversion = 0;
-+
-+    if (gst_structure_get_int (structure, "ffvversion", &ffvversion) &&
-+        ffvversion == 1) {
-+      id = CODEC_ID_FFV1;
-+      video = TRUE;
-+    }
-+  } else if (!strcmp (mimetype, "audio/x-adpcm")) {
-+    const gchar *layout;
-+
-+    layout = gst_structure_get_string (structure, "layout");
-+    if (layout == NULL) {
-+      /* break */
-+    } else if (!strcmp (layout, "quicktime")) {
-+      id = CODEC_ID_ADPCM_IMA_QT;
-+    } else if (!strcmp (layout, "microsoft")) {
-+      id = CODEC_ID_ADPCM_MS;
-+    } else if (!strcmp (layout, "dvi")) {
-+      id = CODEC_ID_ADPCM_IMA_WAV;
-+    } else if (!strcmp (layout, "4xm")) {
-+      id = CODEC_ID_ADPCM_4XM;
-+    } else if (!strcmp (layout, "smjpeg")) {
-+      id = CODEC_ID_ADPCM_IMA_SMJPEG;
-+    } else if (!strcmp (layout, "dk3")) {
-+      id = CODEC_ID_ADPCM_IMA_DK3;
-+    } else if (!strcmp (layout, "dk4")) {
-+      id = CODEC_ID_ADPCM_IMA_DK4;
-+    } else if (!strcmp (layout, "westwood")) {
-+      id = CODEC_ID_ADPCM_IMA_WS;
-+    } else if (!strcmp (layout, "iss")) {
-+      id = CODEC_ID_ADPCM_IMA_ISS;
-+    } else if (!strcmp (layout, "xa")) {
-+      id = CODEC_ID_ADPCM_XA;
-+    } else if (!strcmp (layout, "adx")) {
-+      id = CODEC_ID_ADPCM_ADX;
-+    } else if (!strcmp (layout, "ea")) {
-+      id = CODEC_ID_ADPCM_EA;
-+    } else if (!strcmp (layout, "g726")) {
-+      id = CODEC_ID_ADPCM_G726;
-+    } else if (!strcmp (layout, "g721")) {
-+      id = CODEC_ID_ADPCM_G726;
-+    } else if (!strcmp (layout, "ct")) {
-+      id = CODEC_ID_ADPCM_CT;
-+    } else if (!strcmp (layout, "swf")) {
-+      id = CODEC_ID_ADPCM_SWF;
-+    } else if (!strcmp (layout, "yamaha")) {
-+      id = CODEC_ID_ADPCM_YAMAHA;
-+    } else if (!strcmp (layout, "sbpro2")) {
-+      id = CODEC_ID_ADPCM_SBPRO_2;
-+    } else if (!strcmp (layout, "sbpro3")) {
-+      id = CODEC_ID_ADPCM_SBPRO_3;
-+    } else if (!strcmp (layout, "sbpro4")) {
-+      id = CODEC_ID_ADPCM_SBPRO_4;
-+    }
-+    if (id != CODEC_ID_NONE)
-+      audio = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-4xm")) {
-+    id = CODEC_ID_4XM;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-dpcm")) {
-+    const gchar *layout;
-+
-+    layout = gst_structure_get_string (structure, "layout");
-+    if (!layout) {
-+      /* .. */
-+    } else if (!strcmp (layout, "roq")) {
-+      id = CODEC_ID_ROQ_DPCM;
-+    } else if (!strcmp (layout, "interplay")) {
-+      id = CODEC_ID_INTERPLAY_DPCM;
-+    } else if (!strcmp (layout, "xan")) {
-+      id = CODEC_ID_XAN_DPCM;
-+    } else if (!strcmp (layout, "sol")) {
-+      id = CODEC_ID_SOL_DPCM;
-+    }
-+    if (id != CODEC_ID_NONE)
-+      audio = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-flac")) {
-+    id = CODEC_ID_FLAC;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-shorten")) {
-+    id = CODEC_ID_SHORTEN;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-alac")) {
-+    id = CODEC_ID_ALAC;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-cinepak")) {
-+    id = CODEC_ID_CINEPAK;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-pn-realvideo")) {
-+    gint rmversion;
-+
-+    if (gst_structure_get_int (structure, "rmversion", &rmversion)) {
-+      switch (rmversion) {
-+        case 1:
-+          id = CODEC_ID_RV10;
-+          break;
-+        case 2:
-+          id = CODEC_ID_RV20;
-+          break;
-+        case 3:
-+          id = CODEC_ID_RV30;
-+          break;
-+        case 4:
-+          id = CODEC_ID_RV40;
-+          break;
-+      }
-+    }
-+    if (id != CODEC_ID_NONE)
-+      video = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-sipro")) {
-+    id = CODEC_ID_SIPR;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "audio/x-pn-realaudio")) {
-+    gint raversion;
-+
-+    if (gst_structure_get_int (structure, "raversion", &raversion)) {
-+      switch (raversion) {
-+        case 1:
-+          id = CODEC_ID_RA_144;
-+          break;
-+        case 2:
-+          id = CODEC_ID_RA_288;
-+          break;
-+        case 8:
-+          id = CODEC_ID_COOK;
-+          break;
-+      }
-+    }
-+    if (id != CODEC_ID_NONE)
-+      audio = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-rle")) {
-+    const gchar *layout;
-+
-+    if ((layout = gst_structure_get_string (structure, "layout"))) {
-+      if (!strcmp (layout, "microsoft")) {
-+        id = CODEC_ID_MSRLE;
-+        video = TRUE;
-+      }
-+    }
-+  } else if (!strcmp (mimetype, "video/x-xan")) {
-+    gint wcversion = 0;
-+
-+    if ((gst_structure_get_int (structure, "wcversion", &wcversion))) {
-+      switch (wcversion) {
-+        case 3:
-+          id = CODEC_ID_XAN_WC3;
-+          video = TRUE;
-+          break;
-+        case 4:
-+          id = CODEC_ID_XAN_WC4;
-+          video = TRUE;
-+          break;
-+        default:
-+          break;
-+      }
-+    }
-+  } else if (!strcmp (mimetype, "audio/AMR")) {
-+    audio = TRUE;
-+    id = CODEC_ID_AMR_NB;
-+  } else if (!strcmp (mimetype, "audio/AMR-WB")) {
-+    id = CODEC_ID_AMR_WB;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "audio/qcelp")) {
-+    id = CODEC_ID_QCELP;
-+    audio = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-h264")) {
-+    id = CODEC_ID_H264;
-+    video = TRUE;
-+  } else if (!strcmp (mimetype, "video/x-flash-video")) {
-+    gint flvversion = 0;
-+
-+    if ((gst_structure_get_int (structure, "flvversion", &flvversion))) {
-+      switch (flvversion) {
-+        case 1:
-+          id = CODEC_ID_FLV1;
-+          video = TRUE;
-+          break;
-+        default:
-+          break;
-+      }
-+    }
-+
-+  } else if (!strcmp (mimetype, "audio/x-nellymoser")) {
-+    id = CODEC_ID_NELLYMOSER;
-+    audio = TRUE;
-+  } else if (!strncmp (mimetype, "audio/x-gst_ff-", 15)) {
-+    gchar ext[16];
-+    AVCodec *codec;
-+
-+    if (strlen (mimetype) <= 30 &&
-+        sscanf (mimetype, "audio/x-gst_ff-%s", ext) == 1) {
-+      if ((codec = avcodec_find_decoder_by_name (ext)) ||
-+          (codec = avcodec_find_encoder_by_name (ext))) {
-+        id = codec->id;
-+        audio = TRUE;
-+      }
-+    }
-+  } else if (!strncmp (mimetype, "video/x-gst_ff-", 15)) {
-+    gchar ext[16];
-+    AVCodec *codec;
-+
-+    if (strlen (mimetype) <= 30 &&
-+        sscanf (mimetype, "video/x-gst_ff-%s", ext) == 1) {
-+      if ((codec = avcodec_find_decoder_by_name (ext)) ||
-+          (codec = avcodec_find_encoder_by_name (ext))) {
-+        id = codec->id;
-+        video = TRUE;
-+      }
-+    }
-+  }
-+
-+  if (context != NULL) {
-+    if (video == TRUE) {
-+      context->codec_type = AVMEDIA_TYPE_VIDEO;
-+    } else if (audio == TRUE) {
-+      context->codec_type = AVMEDIA_TYPE_AUDIO;
-+    } else {
-+      context->codec_type = AVMEDIA_TYPE_UNKNOWN;
-+    }
-+    context->codec_id = id;
-+    gst_ffmpeg_caps_with_codecid (id, context->codec_type, caps, context);
-+  }
-+
-+  if (id != CODEC_ID_NONE) {
-+    GST_DEBUG ("The id=%d belongs to the caps %" GST_PTR_FORMAT, id, caps);
-+  } else {
-+    GST_WARNING ("Couldn't figure out the id for caps %" GST_PTR_FORMAT, caps);
-+  }
-+
-+  return id;
-+}
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.rej gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.rej
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.rej	1970-01-01 01:00:00.000000000 +0100
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.rej	2014-08-08 15:31:06.055868246 +0200
-@@ -0,0 +1,12 @@
-+--- ext/ffmpeg/gstffmpegcodecmap.c
-++++ ext/ffmpeg/gstffmpegcodecmap.c
-+@@ -1884,9 +1842,6 @@
-+             gst_ff_vid_caps_new (context, codec_id, encode, "video/x-raw-rgb",
-+             "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, "endianness",
-+             G_TYPE_INT, endianness, NULL);
-+-        if (caps && context) {
-+-          gst_ffmpeg_set_palette (caps, context);
-+-        }
-+       }
-+     } else if (fmt) {
-+       caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-raw-yuv",
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c	2014-08-08 14:46:31.462772351 +0200
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c	2014-08-08 15:32:18.608870847 +0200
-@@ -88,7 +88,6 @@
-       gint depth;
-     } audio;
-   } format;
--  gboolean waiting_for_key;
-   gboolean discont;
-   gboolean clear_ts;
- 
-@@ -438,7 +437,6 @@
-   ffmpegdec->pcache = NULL;
-   ffmpegdec->par = NULL;
-   ffmpegdec->opened = FALSE;
--  ffmpegdec->waiting_for_key = TRUE;
-   ffmpegdec->skip_frame = ffmpegdec->lowres = 0;
-   ffmpegdec->direct_rendering = DEFAULT_DIRECT_RENDERING;
-   ffmpegdec->do_padding = DEFAULT_DO_PADDING;
-@@ -608,11 +606,6 @@
-     gst_ffmpeg_avcodec_close (ffmpegdec->context);
-   ffmpegdec->opened = FALSE;
- 
--  if (ffmpegdec->context->palctrl) {
--    av_free (ffmpegdec->context->palctrl);
--    ffmpegdec->context->palctrl = NULL;
--  }
--
-   if (ffmpegdec->context->extradata) {
-     av_free (ffmpegdec->context->extradata);
-     ffmpegdec->context->extradata = NULL;
-@@ -864,7 +857,7 @@
- 
-   /* workaround encoder bugs */
-   ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
--  ffmpegdec->context->error_recognition = 1;
-+  ffmpegdec->context->err_recognition = 1;
- 
-   /* for slow cpus */
-   ffmpegdec->context->lowres = ffmpegdec->lowres;
-@@ -944,7 +937,7 @@
-   fsize = gst_ffmpeg_avpicture_get_size (ffmpegdec->context->pix_fmt,
-       width, height);
- 
--  if (!ffmpegdec->context->palctrl && ffmpegdec->can_allocate_aligned) {
-+  if (ffmpegdec->can_allocate_aligned) {
-     GST_LOG_OBJECT (ffmpegdec, "calling pad_alloc");
-     /* no pallete, we can use the buffer size to alloc */
-     ret = gst_pad_alloc_buffer_and_set_caps (ffmpegdec->srcpad,
-@@ -1083,7 +1076,6 @@
-   /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to
-    * the opaque data. */
-   picture->type = FF_BUFFER_TYPE_USER;
--  picture->age = 256 * 256 * 256 * 64;
-   picture->opaque = buf;
- 
- #ifdef EXTRA_REF
-@@ -1414,10 +1406,6 @@
-   } else {
-     if (diff >= 0) {
-       /* we're too slow, try to speed up */
--      if (ffmpegdec->waiting_for_key) {
--        /* we were waiting for a keyframe, that's ok */
--        goto skipping;
--      }
-       /* switch to skip_frame mode */
-       goto skip_frame;
-     }
-@@ -1427,11 +1415,6 @@
-   ffmpegdec->processed++;
-   return TRUE;
- 
--skipping:
--  {
--    res = FALSE;
--    goto drop_qos;
--  }
- normal_mode:
-   {
-     if (ffmpegdec->context->skip_frame != AVDISCARD_DEFAULT) {
-@@ -1528,43 +1511,6 @@
- }
- 
- 
--/* figure out if the current picture is a keyframe, return TRUE if that is
-- * the case. */
--static gboolean
--check_keyframe (GstFFMpegDec * ffmpegdec)
--{
--  GstFFMpegDecClass *oclass;
--  gboolean is_itype = FALSE;
--  gboolean is_reference = FALSE;
--  gboolean iskeyframe;
--
--  /* figure out if we are dealing with a keyframe */
--  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
--
--  /* remember that we have B frames, we need this for the DTS -> PTS conversion
--   * code */
--  if (!ffmpegdec->has_b_frames && ffmpegdec->picture->pict_type == FF_B_TYPE) {
--    GST_DEBUG_OBJECT (ffmpegdec, "we have B frames");
--    ffmpegdec->has_b_frames = TRUE;
--  }
--
--  is_itype = (ffmpegdec->picture->pict_type == FF_I_TYPE);
--  is_reference = (ffmpegdec->picture->reference == 1);
--
--  iskeyframe = (is_itype || is_reference || ffmpegdec->picture->key_frame)
--      || (oclass->in_plugin->id == CODEC_ID_INDEO3)
--      || (oclass->in_plugin->id == CODEC_ID_MSZH)
--      || (oclass->in_plugin->id == CODEC_ID_ZLIB)
--      || (oclass->in_plugin->id == CODEC_ID_VP3)
--      || (oclass->in_plugin->id == CODEC_ID_HUFFYUV);
--
--  GST_LOG_OBJECT (ffmpegdec,
--      "current picture: type: %d, is_keyframe:%d, is_itype:%d, is_reference:%d",
--      ffmpegdec->picture->pict_type, iskeyframe, is_itype, is_reference);
--
--  return iskeyframe;
--}
--
- /* get an outbuf buffer with the current picture */
- static GstFlowReturn
- get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
-@@ -1694,7 +1640,6 @@
- {
-   gint len = -1;
-   gint have_data;
--  gboolean iskeyframe;
-   gboolean mode_switch;
-   gboolean decode;
-   gint skip_frame = AVDISCARD_DEFAULT;
-@@ -1809,7 +1754,6 @@
-     gst_ffmpegdec_negotiate (ffmpegdec, TRUE);
-   }
- 
--
-   /* Whether a frame is interlaced or not is unknown at the time of
-      buffer allocation, so caps on the buffer in opaque will have
-      the previous frame's interlaced flag set. So if interlacedness
-@@ -1831,10 +1775,6 @@
-     }
-   }
- 
--  /* check if we are dealing with a keyframe here, this will also check if we
--   * are dealing with B frames. */
--  iskeyframe = check_keyframe (ffmpegdec);
--
-   /* check that the timestamps go upwards */
-   if (ffmpegdec->last_out != -1 && ffmpegdec->last_out > out_pts) {
-     /* timestamps go backwards, this means frames were reordered and we must
-@@ -1865,7 +1805,7 @@
-    * timestamps */
-   if (!ffmpegdec->reordered_in && ffmpegdec->reordered_out) {
-     /* PTS and DTS are the same for keyframes */
--    if (!iskeyframe && ffmpegdec->next_out != -1) {
-+    if (ffmpegdec->next_out != -1) {
-       /* interpolate all timestamps except for keyframes, FIXME, this is
-        * wrong when QoS is active. */
-       GST_DEBUG_OBJECT (ffmpegdec, "interpolate timestamps");
-@@ -1874,16 +1814,6 @@
-     }
-   }
- 
--  /* when we're waiting for a keyframe, see if we have one or drop the current
--   * non-keyframe */
--  if (G_UNLIKELY (ffmpegdec->waiting_for_key)) {
--    if (G_LIKELY (!iskeyframe))
--      goto drop_non_keyframe;
--
--    /* we have a keyframe, we can stop waiting for one */
--    ffmpegdec->waiting_for_key = FALSE;
--  }
--
-   /* get a handle to the output buffer */
-   *ret = get_output_buffer (ffmpegdec, outbuf);
-   if (G_UNLIKELY (*ret != GST_FLOW_OK))
-@@ -2000,20 +1930,11 @@
-   else
-     ffmpegdec->next_out = -1;
- 
--  /* palette is not part of raw video frame in gst and the size
--   * of the outgoing buffer needs to be adjusted accordingly */
--  if (ffmpegdec->context->palctrl != NULL)
--    GST_BUFFER_SIZE (*outbuf) -= AVPALETTE_SIZE;
--
-   /* now see if we need to clip the buffer against the segment boundaries. */
-   if (G_UNLIKELY (!clip_video_buffer (ffmpegdec, *outbuf, out_timestamp,
-               out_duration)))
-     goto clipped;
- 
--  /* mark as keyframe or delta unit */
--  if (!iskeyframe)
--    GST_BUFFER_FLAG_SET (*outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
--
-   if (ffmpegdec->picture->top_field_first)
-     GST_BUFFER_FLAG_SET (*outbuf, GST_VIDEO_BUFFER_TFF);
- 
-@@ -2024,11 +1945,6 @@
-   return len;
- 
-   /* special cases */
--drop_non_keyframe:
--  {
--    GST_WARNING_OBJECT (ffmpegdec, "Dropping non-keyframe (seek/init)");
--    goto beach;
--  }
- no_output:
-   {
-     GST_DEBUG_OBJECT (ffmpegdec, "no output buffer");
-@@ -2422,7 +2338,6 @@
-       gst_ffmpegdec_reset_ts (ffmpegdec);
-       gst_ffmpegdec_reset_qos (ffmpegdec);
-       gst_ffmpegdec_flush_pcache (ffmpegdec);
--      ffmpegdec->waiting_for_key = TRUE;
-       gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
-       clear_queued (ffmpegdec);
-       break;
-@@ -2560,17 +2475,6 @@
- 
-   oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
- 
--  /* do early keyframe check pretty bad to rely on the keyframe flag in the
--   * source for this as it might not even be parsed (UDP/file/..).  */
--  if (G_UNLIKELY (ffmpegdec->waiting_for_key)) {
--    GST_DEBUG_OBJECT (ffmpegdec, "waiting for keyframe");
--    if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_DELTA_UNIT) &&
--        oclass->in_plugin->type != AVMEDIA_TYPE_AUDIO)
--      goto skip_keyframe;
--
--    GST_DEBUG_OBJECT (ffmpegdec, "got keyframe");
--    ffmpegdec->waiting_for_key = FALSE;
--  }
-   /* parse cache joining. If there is cached data */
-   if (ffmpegdec->pcache) {
-     /* join with previous data */
-@@ -2805,12 +2709,6 @@
-     gst_buffer_unref (inbuf);
-     return GST_FLOW_NOT_NEGOTIATED;
-   }
--skip_keyframe:
--  {
--    GST_DEBUG_OBJECT (ffmpegdec, "skipping non keyframe");
--    gst_buffer_unref (inbuf);
--    return GST_FLOW_OK;
--  }
- }
- 
- static GstStateChangeReturn
-@@ -2936,7 +2834,7 @@
-     gchar *plugin_name;
- 
-     /* only decoders */
--    if (!in_plugin->decode) {
-+    if (!av_codec_is_decoder (in_plugin)) {
-       goto next;
-     }
- 
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.orig
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.orig	1970-01-01 01:00:00.000000000 +0100
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.orig	2014-08-08 15:31:06.057868246 +0200
-@@ -0,0 +1,2973 @@
-+/* 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 <assert.h>
-+#include <string.h>
-+
-+#ifdef HAVE_FFMPEG_UNINSTALLED
-+#include <avcodec.h>
-+#else
-+#include <libavcodec/avcodec.h>
-+#endif
-+
-+#include <gst/gst.h>
-+#include <gst/video/video.h>
-+
-+#include "gstffmpeg.h"
-+#include "gstffmpegcodecmap.h"
-+#include "gstffmpegutils.h"
-+
-+/* define to enable alternative buffer refcounting algorithm */
-+#undef EXTRA_REF
-+
-+typedef struct _GstFFMpegDec GstFFMpegDec;
-+
-+#define MAX_TS_MASK 0xff
-+
-+/* for each incomming buffer we keep all timing info in a structure like this.
-+ * We keep a circular array of these structures around to store the timing info.
-+ * The index in the array is what we pass as opaque data (to pictures) and
-+ * pts (to parsers) so that ffmpeg can remember them for us. */
-+typedef struct
-+{
-+  gint idx;
-+  GstClockTime timestamp;
-+  GstClockTime duration;
-+  gint64 offset;
-+} GstTSInfo;
-+
-+struct _GstFFMpegDec
-+{
-+  GstElement element;
-+
-+  /* We need to keep track of our pads, so we do so here. */
-+  GstPad *srcpad;
-+  GstPad *sinkpad;
-+
-+  /* decoding */
-+  AVCodecContext *context;
-+  AVFrame *picture;
-+  gboolean opened;
-+  union
-+  {
-+    struct
-+    {
-+      gint width, height;
-+      gint clip_width, clip_height;
-+      gint par_n, par_d;
-+      gint fps_n, fps_d;
-+      gint old_fps_n, old_fps_d;
-+      gboolean interlaced;
-+
-+      enum PixelFormat pix_fmt;
-+    } video;
-+    struct
-+    {
-+      gint channels;
-+      gint samplerate;
-+      gint depth;
-+    } audio;
-+  } format;
-+  gboolean discont;
-+  gboolean clear_ts;
-+
-+  /* for tracking DTS/PTS */
-+  gboolean has_b_frames;
-+  gboolean reordered_in;
-+  GstClockTime last_in;
-+  GstClockTime last_diff;
-+  guint last_frames;
-+  gboolean reordered_out;
-+  GstClockTime last_out;
-+  GstClockTime next_out;
-+
-+  /* parsing */
-+  gboolean turnoff_parser;      /* used for turning off aac raw parsing
-+                                 * See bug #566250 */
-+  AVCodecParserContext *pctx;
-+  GstBuffer *pcache;
-+  guint8 *padded;
-+  guint padded_size;
-+
-+  GValue *par;                  /* pixel aspect ratio of incoming data */
-+  gboolean current_dr;          /* if direct rendering is enabled */
-+  gboolean extra_ref;           /* keep extra ref around in get/release */
-+
-+  /* some properties */
-+  enum AVDiscard skip_frame;
-+  gint lowres;
-+  gboolean direct_rendering;
-+  gboolean do_padding;
-+  gboolean debug_mv;
-+  gboolean crop;
-+  int max_threads;
-+
-+  /* QoS stuff *//* with LOCK */
-+  gdouble proportion;
-+  GstClockTime earliest_time;
-+  gint64 processed;
-+  gint64 dropped;
-+
-+  /* clipping segment */
-+  GstSegment segment;
-+
-+  gboolean is_realvideo;
-+
-+  GstTSInfo ts_info[MAX_TS_MASK + 1];
-+  gint ts_idx;
-+
-+  /* reverse playback queue */
-+  GList *queued;
-+
-+  /* Can downstream allocate 16bytes aligned data. */
-+  gboolean can_allocate_aligned;
-+};
-+
-+typedef struct _GstFFMpegDecClass GstFFMpegDecClass;
-+
-+struct _GstFFMpegDecClass
-+{
-+  GstElementClass parent_class;
-+
-+  AVCodec *in_plugin;
-+  GstPadTemplate *srctempl, *sinktempl;
-+};
-+
-+#define GST_TS_INFO_NONE &ts_info_none
-+static const GstTSInfo ts_info_none = { -1, -1, -1, -1 };
-+
-+static const GstTSInfo *
-+gst_ts_info_store (GstFFMpegDec * dec, GstClockTime timestamp,
-+    GstClockTime duration, gint64 offset)
-+{
-+  gint idx = dec->ts_idx;
-+  dec->ts_info[idx].idx = idx;
-+  dec->ts_info[idx].timestamp = timestamp;
-+  dec->ts_info[idx].duration = duration;
-+  dec->ts_info[idx].offset = offset;
-+  dec->ts_idx = (idx + 1) & MAX_TS_MASK;
-+
-+  return &dec->ts_info[idx];
-+}
-+
-+static const GstTSInfo *
-+gst_ts_info_get (GstFFMpegDec * dec, gint idx)
-+{
-+  if (G_UNLIKELY (idx < 0 || idx > MAX_TS_MASK))
-+    return GST_TS_INFO_NONE;
-+
-+  return &dec->ts_info[idx];
-+}
-+
-+#define GST_TYPE_FFMPEGDEC \
-+  (gst_ffmpegdec_get_type())
-+#define GST_FFMPEGDEC(obj) \
-+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGDEC,GstFFMpegDec))
-+#define GST_FFMPEGDEC_CLASS(klass) \
-+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGDEC,GstFFMpegDecClass))
-+#define GST_IS_FFMPEGDEC(obj) \
-+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGDEC))
-+#define GST_IS_FFMPEGDEC_CLASS(klass) \
-+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGDEC))
-+
-+#define DEFAULT_LOWRES			0
-+#define DEFAULT_SKIPFRAME		0
-+#define DEFAULT_DIRECT_RENDERING	TRUE
-+#define DEFAULT_DO_PADDING		TRUE
-+#define DEFAULT_DEBUG_MV		FALSE
-+#define DEFAULT_CROP			TRUE
-+#define DEFAULT_MAX_THREADS		1
-+
-+enum
-+{
-+  PROP_0,
-+  PROP_LOWRES,
-+  PROP_SKIPFRAME,
-+  PROP_DIRECT_RENDERING,
-+  PROP_DO_PADDING,
-+  PROP_DEBUG_MV,
-+  PROP_CROP,
-+  PROP_MAX_THREADS,
-+  PROP_LAST
-+};
-+
-+/* A number of function prototypes are given so we can refer to them later. */
-+static void gst_ffmpegdec_base_init (GstFFMpegDecClass * klass);
-+static void gst_ffmpegdec_class_init (GstFFMpegDecClass * klass);
-+static void gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec);
-+static void gst_ffmpegdec_finalize (GObject * object);
-+
-+static gboolean gst_ffmpegdec_query (GstPad * pad, GstQuery * query);
-+static gboolean gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event);
-+
-+static gboolean gst_ffmpegdec_setcaps (GstPad * pad, GstCaps * caps);
-+static gboolean gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event);
-+static GstFlowReturn gst_ffmpegdec_chain (GstPad * pad, GstBuffer * buf);
-+
-+static GstStateChangeReturn gst_ffmpegdec_change_state (GstElement * element,
-+    GstStateChange transition);
-+
-+static void gst_ffmpegdec_set_property (GObject * object,
-+    guint prop_id, const GValue * value, GParamSpec * pspec);
-+static void gst_ffmpegdec_get_property (GObject * object,
-+    guint prop_id, GValue * value, GParamSpec * pspec);
-+
-+static gboolean gst_ffmpegdec_negotiate (GstFFMpegDec * ffmpegdec,
-+    gboolean force);
-+
-+/* some sort of bufferpool handling, but different */
-+static int gst_ffmpegdec_get_buffer (AVCodecContext * context,
-+    AVFrame * picture);
-+static void gst_ffmpegdec_release_buffer (AVCodecContext * context,
-+    AVFrame * picture);
-+
-+static void gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec);
-+
-+#define GST_FFDEC_PARAMS_QDATA g_quark_from_static_string("ffdec-params")
-+
-+static GstElementClass *parent_class = NULL;
-+
-+#define GST_FFMPEGDEC_TYPE_LOWRES (gst_ffmpegdec_lowres_get_type())
-+static GType
-+gst_ffmpegdec_lowres_get_type (void)
-+{
-+  static GType ffmpegdec_lowres_type = 0;
-+
-+  if (!ffmpegdec_lowres_type) {
-+    static const GEnumValue ffmpegdec_lowres[] = {
-+      {0, "0", "full"},
-+      {1, "1", "1/2-size"},
-+      {2, "2", "1/4-size"},
-+      {0, NULL, NULL},
-+    };
-+
-+    ffmpegdec_lowres_type =
-+        g_enum_register_static ("GstFFMpegDecLowres", ffmpegdec_lowres);
-+  }
-+
-+  return ffmpegdec_lowres_type;
-+}
-+
-+#define GST_FFMPEGDEC_TYPE_SKIPFRAME (gst_ffmpegdec_skipframe_get_type())
-+static GType
-+gst_ffmpegdec_skipframe_get_type (void)
-+{
-+  static GType ffmpegdec_skipframe_type = 0;
-+
-+  if (!ffmpegdec_skipframe_type) {
-+    static const GEnumValue ffmpegdec_skipframe[] = {
-+      {0, "0", "Skip nothing"},
-+      {1, "1", "Skip B-frames"},
-+      {2, "2", "Skip IDCT/Dequantization"},
-+      {5, "5", "Skip everything"},
-+      {0, NULL, NULL},
-+    };
-+
-+    ffmpegdec_skipframe_type =
-+        g_enum_register_static ("GstFFMpegDecSkipFrame", ffmpegdec_skipframe);
-+  }
-+
-+  return ffmpegdec_skipframe_type;
-+}
-+
-+static void
-+gst_ffmpegdec_base_init (GstFFMpegDecClass * klass)
-+{
-+  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-+  GstPadTemplate *sinktempl, *srctempl;
-+  GstCaps *sinkcaps, *srccaps;
-+  AVCodec *in_plugin;
-+  gchar *longname, *classification, *description;
-+
-+  in_plugin =
-+      (AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
-+      GST_FFDEC_PARAMS_QDATA);
-+  g_assert (in_plugin != NULL);
-+
-+  /* construct the element details struct */
-+  longname = g_strdup_printf ("FFmpeg %s decoder", in_plugin->long_name);
-+  classification = g_strdup_printf ("Codec/Decoder/%s",
-+      (in_plugin->type == AVMEDIA_TYPE_VIDEO) ? "Video" : "Audio");
-+  description = g_strdup_printf ("FFmpeg %s decoder", in_plugin->name);
-+  gst_element_class_set_details_simple (element_class, longname, classification,
-+      description,
-+      "Wim Taymans <wim.taymans@gmail.com>, "
-+      "Ronald Bultje <rbultje@ronald.bitfreak.net>, "
-+      "Edward Hervey <bilboed@bilboed.com>");
-+  g_free (longname);
-+  g_free (classification);
-+  g_free (description);
-+
-+  /* get the caps */
-+  sinkcaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, FALSE);
-+  if (!sinkcaps) {
-+    GST_DEBUG ("Couldn't get sink caps for decoder '%s'", in_plugin->name);
-+    sinkcaps = gst_caps_from_string ("unknown/unknown");
-+  }
-+  if (in_plugin->type == AVMEDIA_TYPE_VIDEO) {
-+    srccaps = gst_caps_from_string ("video/x-raw-rgb; video/x-raw-yuv");
-+  } else {
-+    srccaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
-+        in_plugin->id, FALSE, in_plugin);
-+  }
-+  if (!srccaps) {
-+    GST_DEBUG ("Couldn't get source caps for decoder '%s'", in_plugin->name);
-+    srccaps = gst_caps_from_string ("unknown/unknown");
-+  }
-+
-+  /* pad templates */
-+  sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
-+      GST_PAD_ALWAYS, sinkcaps);
-+  srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
-+
-+  gst_element_class_add_pad_template (element_class, srctempl);
-+  gst_element_class_add_pad_template (element_class, sinktempl);
-+
-+  klass->in_plugin = in_plugin;
-+  klass->srctempl = srctempl;
-+  klass->sinktempl = sinktempl;
-+}
-+
-+static void
-+gst_ffmpegdec_class_init (GstFFMpegDecClass * klass)
-+{
-+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-+  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
-+
-+  parent_class = g_type_class_peek_parent (klass);
-+
-+  gobject_class->finalize = gst_ffmpegdec_finalize;
-+
-+  gobject_class->set_property = gst_ffmpegdec_set_property;
-+  gobject_class->get_property = gst_ffmpegdec_get_property;
-+
-+  if (klass->in_plugin->type == AVMEDIA_TYPE_VIDEO) {
-+    int caps;
-+
-+    g_object_class_install_property (gobject_class, PROP_SKIPFRAME,
-+        g_param_spec_enum ("skip-frame", "Skip frames",
-+            "Which types of frames to skip during decoding",
-+            GST_FFMPEGDEC_TYPE_SKIPFRAME, 0,
-+            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-+    g_object_class_install_property (gobject_class, PROP_LOWRES,
-+        g_param_spec_enum ("lowres", "Low resolution",
-+            "At which resolution to decode images", GST_FFMPEGDEC_TYPE_LOWRES,
-+            0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-+    g_object_class_install_property (gobject_class, PROP_DIRECT_RENDERING,
-+        g_param_spec_boolean ("direct-rendering", "Direct Rendering",
-+            "Enable direct rendering", DEFAULT_DIRECT_RENDERING,
-+            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-+    g_object_class_install_property (gobject_class, PROP_DO_PADDING,
-+        g_param_spec_boolean ("do-padding", "Do Padding",
-+            "Add 0 padding before decoding data", DEFAULT_DO_PADDING,
-+            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-+    g_object_class_install_property (gobject_class, PROP_DEBUG_MV,
-+        g_param_spec_boolean ("debug-mv", "Debug motion vectors",
-+            "Whether ffmpeg should print motion vectors on top of the image",
-+            DEFAULT_DEBUG_MV, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-+#if 0
-+    g_object_class_install_property (gobject_class, PROP_CROP,
-+        g_param_spec_boolean ("crop", "Crop",
-+            "Crop images to the display region",
-+            DEFAULT_CROP, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-+#endif
-+
-+    caps = klass->in_plugin->capabilities;
-+    if (caps & (CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS)) {
-+      g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_THREADS,
-+          g_param_spec_int ("max-threads", "Maximum decode threads",
-+              "Maximum number of worker threads to spawn. (0 = auto)",
-+              0, G_MAXINT, DEFAULT_MAX_THREADS,
-+              G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-+    }
-+  }
-+
-+  gstelement_class->change_state = gst_ffmpegdec_change_state;
-+}
-+
-+static void
-+gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec)
-+{
-+  GstFFMpegDecClass *oclass;
-+
-+  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
-+
-+  /* setup pads */
-+  ffmpegdec->sinkpad = gst_pad_new_from_template (oclass->sinktempl, "sink");
-+  gst_pad_set_setcaps_function (ffmpegdec->sinkpad,
-+      GST_DEBUG_FUNCPTR (gst_ffmpegdec_setcaps));
-+  gst_pad_set_event_function (ffmpegdec->sinkpad,
-+      GST_DEBUG_FUNCPTR (gst_ffmpegdec_sink_event));
-+  gst_pad_set_chain_function (ffmpegdec->sinkpad,
-+      GST_DEBUG_FUNCPTR (gst_ffmpegdec_chain));
-+  gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->sinkpad);
-+
-+  ffmpegdec->srcpad = gst_pad_new_from_template (oclass->srctempl, "src");
-+  gst_pad_use_fixed_caps (ffmpegdec->srcpad);
-+  gst_pad_set_event_function (ffmpegdec->srcpad,
-+      GST_DEBUG_FUNCPTR (gst_ffmpegdec_src_event));
-+  gst_pad_set_query_function (ffmpegdec->srcpad,
-+      GST_DEBUG_FUNCPTR (gst_ffmpegdec_query));
-+  gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->srcpad);
-+
-+  /* some ffmpeg data */
-+  ffmpegdec->context = avcodec_alloc_context ();
-+  ffmpegdec->picture = avcodec_alloc_frame ();
-+  ffmpegdec->pctx = NULL;
-+  ffmpegdec->pcache = NULL;
-+  ffmpegdec->par = NULL;
-+  ffmpegdec->opened = FALSE;
-+  ffmpegdec->skip_frame = ffmpegdec->lowres = 0;
-+  ffmpegdec->direct_rendering = DEFAULT_DIRECT_RENDERING;
-+  ffmpegdec->do_padding = DEFAULT_DO_PADDING;
-+  ffmpegdec->debug_mv = DEFAULT_DEBUG_MV;
-+  ffmpegdec->crop = DEFAULT_CROP;
-+  ffmpegdec->max_threads = DEFAULT_MAX_THREADS;
-+
-+  ffmpegdec->format.video.par_n = -1;
-+  ffmpegdec->format.video.fps_n = -1;
-+  ffmpegdec->format.video.old_fps_n = -1;
-+  gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
-+
-+  /* We initially assume downstream can allocate 16 bytes aligned buffers */
-+  ffmpegdec->can_allocate_aligned = TRUE;
-+}
-+
-+static void
-+gst_ffmpegdec_finalize (GObject * object)
-+{
-+  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
-+
-+  if (ffmpegdec->context != NULL) {
-+    av_free (ffmpegdec->context);
-+    ffmpegdec->context = NULL;
-+  }
-+
-+  if (ffmpegdec->picture != NULL) {
-+    av_free (ffmpegdec->picture);
-+    ffmpegdec->picture = NULL;
-+  }
-+
-+  G_OBJECT_CLASS (parent_class)->finalize (object);
-+}
-+
-+static gboolean
-+gst_ffmpegdec_query (GstPad * pad, GstQuery * query)
-+{
-+  GstFFMpegDec *ffmpegdec;
-+  GstPad *peer;
-+  gboolean res;
-+
-+  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
-+
-+  res = FALSE;
-+
-+  if ((peer = gst_pad_get_peer (ffmpegdec->sinkpad))) {
-+    /* just forward to peer */
-+    res = gst_pad_query (peer, query);
-+    gst_object_unref (peer);
-+  }
-+#if 0
-+  {
-+    GstFormat bfmt;
-+
-+    bfmt = GST_FORMAT_BYTES;
-+
-+    /* ok, do bitrate calc... */
-+    if ((type != GST_QUERY_POSITION && type != GST_QUERY_TOTAL) ||
-+        *fmt != GST_FORMAT_TIME || ffmpegdec->context->bit_rate == 0 ||
-+        !gst_pad_query (peer, type, &bfmt, value))
-+      return FALSE;
-+
-+    if (ffmpegdec->pcache && type == GST_QUERY_POSITION)
-+      *value -= GST_BUFFER_SIZE (ffmpegdec->pcache);
-+    *value *= GST_SECOND / ffmpegdec->context->bit_rate;
-+  }
-+#endif
-+
-+  gst_object_unref (ffmpegdec);
-+
-+  return res;
-+}
-+
-+static void
-+gst_ffmpegdec_reset_ts (GstFFMpegDec * ffmpegdec)
-+{
-+  ffmpegdec->last_in = GST_CLOCK_TIME_NONE;
-+  ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
-+  ffmpegdec->last_frames = 0;
-+  ffmpegdec->last_out = GST_CLOCK_TIME_NONE;
-+  ffmpegdec->next_out = GST_CLOCK_TIME_NONE;
-+  ffmpegdec->reordered_in = FALSE;
-+  ffmpegdec->reordered_out = FALSE;
-+}
-+
-+static void
-+gst_ffmpegdec_update_qos (GstFFMpegDec * ffmpegdec, gdouble proportion,
-+    GstClockTime timestamp)
-+{
-+  GST_LOG_OBJECT (ffmpegdec, "update QOS: %f, %" GST_TIME_FORMAT,
-+      proportion, GST_TIME_ARGS (timestamp));
-+
-+  GST_OBJECT_LOCK (ffmpegdec);
-+  ffmpegdec->proportion = proportion;
-+  ffmpegdec->earliest_time = timestamp;
-+  GST_OBJECT_UNLOCK (ffmpegdec);
-+}
-+
-+static void
-+gst_ffmpegdec_reset_qos (GstFFMpegDec * ffmpegdec)
-+{
-+  gst_ffmpegdec_update_qos (ffmpegdec, 0.5, GST_CLOCK_TIME_NONE);
-+  ffmpegdec->processed = 0;
-+  ffmpegdec->dropped = 0;
-+}
-+
-+static void
-+gst_ffmpegdec_read_qos (GstFFMpegDec * ffmpegdec, gdouble * proportion,
-+    GstClockTime * timestamp)
-+{
-+  GST_OBJECT_LOCK (ffmpegdec);
-+  *proportion = ffmpegdec->proportion;
-+  *timestamp = ffmpegdec->earliest_time;
-+  GST_OBJECT_UNLOCK (ffmpegdec);
-+}
-+
-+static gboolean
-+gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event)
-+{
-+  GstFFMpegDec *ffmpegdec;
-+  gboolean res;
-+
-+  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
-+
-+  switch (GST_EVENT_TYPE (event)) {
-+    case GST_EVENT_QOS:
-+    {
-+      gdouble proportion;
-+      GstClockTimeDiff diff;
-+      GstClockTime timestamp;
-+
-+      gst_event_parse_qos (event, &proportion, &diff, &timestamp);
-+
-+      /* update our QoS values */
-+      gst_ffmpegdec_update_qos (ffmpegdec, proportion, timestamp + diff);
-+
-+      /* forward upstream */
-+      res = gst_pad_push_event (ffmpegdec->sinkpad, event);
-+      break;
-+    }
-+    default:
-+      /* forward upstream */
-+      res = gst_pad_push_event (ffmpegdec->sinkpad, event);
-+      break;
-+  }
-+
-+  gst_object_unref (ffmpegdec);
-+
-+  return res;
-+}
-+
-+/* with LOCK */
-+static void
-+gst_ffmpegdec_close (GstFFMpegDec * ffmpegdec)
-+{
-+  if (!ffmpegdec->opened)
-+    return;
-+
-+  GST_LOG_OBJECT (ffmpegdec, "closing ffmpeg codec");
-+
-+  if (ffmpegdec->par) {
-+    g_free (ffmpegdec->par);
-+    ffmpegdec->par = NULL;
-+  }
-+
-+  if (ffmpegdec->context->priv_data)
-+    gst_ffmpeg_avcodec_close (ffmpegdec->context);
-+  ffmpegdec->opened = FALSE;
-+
-+  if (ffmpegdec->context->extradata) {
-+    av_free (ffmpegdec->context->extradata);
-+    ffmpegdec->context->extradata = NULL;
-+  }
-+
-+  if (ffmpegdec->pctx) {
-+    if (ffmpegdec->pcache) {
-+      gst_buffer_unref (ffmpegdec->pcache);
-+      ffmpegdec->pcache = NULL;
-+    }
-+    av_parser_close (ffmpegdec->pctx);
-+    ffmpegdec->pctx = NULL;
-+  }
-+
-+  ffmpegdec->format.video.par_n = -1;
-+  ffmpegdec->format.video.fps_n = -1;
-+  ffmpegdec->format.video.old_fps_n = -1;
-+  ffmpegdec->format.video.interlaced = FALSE;
-+}
-+
-+/* with LOCK */
-+static gboolean
-+gst_ffmpegdec_open (GstFFMpegDec * ffmpegdec)
-+{
-+  GstFFMpegDecClass *oclass;
-+
-+  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
-+
-+  if (gst_ffmpeg_avcodec_open (ffmpegdec->context, oclass->in_plugin) < 0)
-+    goto could_not_open;
-+
-+  ffmpegdec->opened = TRUE;
-+  ffmpegdec->is_realvideo = FALSE;
-+
-+  GST_LOG_OBJECT (ffmpegdec, "Opened ffmpeg codec %s, id %d",
-+      oclass->in_plugin->name, oclass->in_plugin->id);
-+
-+  /* open a parser if we can */
-+  switch (oclass->in_plugin->id) {
-+    case CODEC_ID_MPEG4:
-+    case CODEC_ID_MJPEG:
-+    case CODEC_ID_VC1:
-+      GST_LOG_OBJECT (ffmpegdec, "not using parser, blacklisted codec");
-+      ffmpegdec->pctx = NULL;
-+      break;
-+    case CODEC_ID_H264:
-+      /* For H264, only use a parser if there is no context data, if there is, 
-+       * we're talking AVC */
-+      if (ffmpegdec->context->extradata_size == 0) {
-+        GST_LOG_OBJECT (ffmpegdec, "H264 with no extradata, creating parser");
-+        ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
-+      } else {
-+        GST_LOG_OBJECT (ffmpegdec,
-+            "H264 with extradata implies framed data - not using parser");
-+        ffmpegdec->pctx = NULL;
-+      }
-+      break;
-+    case CODEC_ID_RV10:
-+    case CODEC_ID_RV30:
-+    case CODEC_ID_RV20:
-+    case CODEC_ID_RV40:
-+      ffmpegdec->is_realvideo = TRUE;
-+      break;
-+    default:
-+      if (!ffmpegdec->turnoff_parser) {
-+        ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
-+        if (ffmpegdec->pctx)
-+          GST_LOG_OBJECT (ffmpegdec, "Using parser %p", ffmpegdec->pctx);
-+        else
-+          GST_LOG_OBJECT (ffmpegdec, "No parser for codec");
-+      } else {
-+        GST_LOG_OBJECT (ffmpegdec, "Parser deactivated for format");
-+      }
-+      break;
-+  }
-+
-+  switch (oclass->in_plugin->type) {
-+    case AVMEDIA_TYPE_VIDEO:
-+      ffmpegdec->format.video.width = 0;
-+      ffmpegdec->format.video.height = 0;
-+      ffmpegdec->format.video.clip_width = -1;
-+      ffmpegdec->format.video.clip_height = -1;
-+      ffmpegdec->format.video.pix_fmt = PIX_FMT_NB;
-+      ffmpegdec->format.video.interlaced = FALSE;
-+      break;
-+    case AVMEDIA_TYPE_AUDIO:
-+      ffmpegdec->format.audio.samplerate = 0;
-+      ffmpegdec->format.audio.channels = 0;
-+      ffmpegdec->format.audio.depth = 0;
-+      break;
-+    default:
-+      break;
-+  }
-+
-+  gst_ffmpegdec_reset_ts (ffmpegdec);
-+  /* FIXME, reset_qos holds the LOCK */
-+  ffmpegdec->proportion = 0.0;
-+  ffmpegdec->earliest_time = -1;
-+
-+  return TRUE;
-+
-+  /* ERRORS */
-+could_not_open:
-+  {
-+    gst_ffmpegdec_close (ffmpegdec);
-+    GST_DEBUG_OBJECT (ffmpegdec, "ffdec_%s: Failed to open FFMPEG codec",
-+        oclass->in_plugin->name);
-+    return FALSE;
-+  }
-+}
-+
-+static gboolean
-+gst_ffmpegdec_setcaps (GstPad * pad, GstCaps * caps)
-+{
-+  GstFFMpegDec *ffmpegdec;
-+  GstFFMpegDecClass *oclass;
-+  GstStructure *structure;
-+  const GValue *par;
-+  const GValue *fps;
-+  gboolean ret = TRUE;
-+
-+  ffmpegdec = (GstFFMpegDec *) (gst_pad_get_parent (pad));
-+  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
-+
-+  GST_DEBUG_OBJECT (pad, "setcaps called");
-+
-+  GST_OBJECT_LOCK (ffmpegdec);
-+
-+  /* stupid check for VC1 */
-+  if ((oclass->in_plugin->id == CODEC_ID_WMV3) ||
-+      (oclass->in_plugin->id == CODEC_ID_VC1))
-+    oclass->in_plugin->id = gst_ffmpeg_caps_to_codecid (caps, NULL);
-+
-+  /* close old session */
-+  if (ffmpegdec->opened) {
-+    GST_OBJECT_UNLOCK (ffmpegdec);
-+    gst_ffmpegdec_drain (ffmpegdec);
-+    GST_OBJECT_LOCK (ffmpegdec);
-+    gst_ffmpegdec_close (ffmpegdec);
-+
-+    /* and reset the defaults that were set when a context is created */
-+    avcodec_get_context_defaults (ffmpegdec->context);
-+  }
-+
-+  /* set buffer functions */
-+  ffmpegdec->context->get_buffer = gst_ffmpegdec_get_buffer;
-+  ffmpegdec->context->release_buffer = gst_ffmpegdec_release_buffer;
-+  ffmpegdec->context->draw_horiz_band = NULL;
-+
-+  /* default is to let format decide if it needs a parser */
-+  ffmpegdec->turnoff_parser = FALSE;
-+
-+  ffmpegdec->has_b_frames = FALSE;
-+
-+  GST_LOG_OBJECT (ffmpegdec, "size %dx%d", ffmpegdec->context->width,
-+      ffmpegdec->context->height);
-+
-+  /* get size and so */
-+  gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
-+      oclass->in_plugin->type, caps, ffmpegdec->context);
-+
-+  GST_LOG_OBJECT (ffmpegdec, "size after %dx%d", ffmpegdec->context->width,
-+      ffmpegdec->context->height);
-+
-+  if (!ffmpegdec->context->time_base.den || !ffmpegdec->context->time_base.num) {
-+    GST_DEBUG_OBJECT (ffmpegdec, "forcing 25/1 framerate");
-+    ffmpegdec->context->time_base.num = 1;
-+    ffmpegdec->context->time_base.den = 25;
-+  }
-+
-+  /* get pixel aspect ratio if it's set */
-+  structure = gst_caps_get_structure (caps, 0);
-+
-+  par = gst_structure_get_value (structure, "pixel-aspect-ratio");
-+  if (par) {
-+    GST_DEBUG_OBJECT (ffmpegdec, "sink caps have pixel-aspect-ratio of %d:%d",
-+        gst_value_get_fraction_numerator (par),
-+        gst_value_get_fraction_denominator (par));
-+    /* should be NULL */
-+    if (ffmpegdec->par)
-+      g_free (ffmpegdec->par);
-+    ffmpegdec->par = g_new0 (GValue, 1);
-+    gst_value_init_and_copy (ffmpegdec->par, par);
-+  }
-+
-+  /* get the framerate from incoming caps. fps_n is set to -1 when
-+   * there is no valid framerate */
-+  fps = gst_structure_get_value (structure, "framerate");
-+  if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
-+    ffmpegdec->format.video.fps_n = gst_value_get_fraction_numerator (fps);
-+    ffmpegdec->format.video.fps_d = gst_value_get_fraction_denominator (fps);
-+    GST_DEBUG_OBJECT (ffmpegdec, "Using framerate %d/%d from incoming caps",
-+        ffmpegdec->format.video.fps_n, ffmpegdec->format.video.fps_d);
-+  } else {
-+    ffmpegdec->format.video.fps_n = -1;
-+    GST_DEBUG_OBJECT (ffmpegdec, "Using framerate from codec");
-+  }
-+
-+  /* figure out if we can use direct rendering */
-+  ffmpegdec->current_dr = FALSE;
-+  ffmpegdec->extra_ref = FALSE;
-+  if (ffmpegdec->direct_rendering) {
-+    GST_DEBUG_OBJECT (ffmpegdec, "trying to enable direct rendering");
-+    if (oclass->in_plugin->capabilities & CODEC_CAP_DR1) {
-+      if (oclass->in_plugin->id == CODEC_ID_H264) {
-+        GST_DEBUG_OBJECT (ffmpegdec, "disable direct rendering setup for H264");
-+        /* does not work, many stuff reads outside of the planes */
-+        ffmpegdec->current_dr = FALSE;
-+        ffmpegdec->extra_ref = TRUE;
-+      } else if ((oclass->in_plugin->id == CODEC_ID_SVQ1) ||
-+          (oclass->in_plugin->id == CODEC_ID_VP5) ||
-+          (oclass->in_plugin->id == CODEC_ID_VP6) ||
-+          (oclass->in_plugin->id == CODEC_ID_VP6F) ||
-+          (oclass->in_plugin->id == CODEC_ID_VP6A)) {
-+        GST_DEBUG_OBJECT (ffmpegdec,
-+            "disable direct rendering setup for broken stride support");
-+        /* does not work, uses a incompatible stride. See #610613 */
-+        ffmpegdec->current_dr = FALSE;
-+        ffmpegdec->extra_ref = TRUE;
-+      } else {
-+        GST_DEBUG_OBJECT (ffmpegdec, "enabled direct rendering");
-+        ffmpegdec->current_dr = TRUE;
-+      }
-+    } else {
-+      GST_DEBUG_OBJECT (ffmpegdec, "direct rendering not supported");
-+    }
-+  }
-+  if (ffmpegdec->current_dr) {
-+    /* do *not* draw edges when in direct rendering, for some reason it draws
-+     * outside of the memory. */
-+    ffmpegdec->context->flags |= CODEC_FLAG_EMU_EDGE;
-+  }
-+
-+  /* for AAC we only use av_parse if not on stream-format==raw or ==loas */
-+  if (oclass->in_plugin->id == CODEC_ID_AAC
-+      || oclass->in_plugin->id == CODEC_ID_AAC_LATM) {
-+    const gchar *format = gst_structure_get_string (structure, "stream-format");
-+
-+    if (format == NULL || strcmp (format, "raw") == 0) {
-+      ffmpegdec->turnoff_parser = TRUE;
-+    }
-+  }
-+
-+  /* for FLAC, don't parse if it's already parsed */
-+  if (oclass->in_plugin->id == CODEC_ID_FLAC) {
-+    if (gst_structure_has_field (structure, "streamheader"))
-+      ffmpegdec->turnoff_parser = TRUE;
-+  }
-+
-+  /* workaround encoder bugs */
-+  ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
-+  ffmpegdec->context->err_recognition = 1;
-+
-+  /* for slow cpus */
-+  ffmpegdec->context->lowres = ffmpegdec->lowres;
-+  ffmpegdec->context->skip_frame = ffmpegdec->skip_frame;
-+
-+  /* ffmpeg can draw motion vectors on top of the image (not every decoder
-+   * supports it) */
-+  ffmpegdec->context->debug_mv = ffmpegdec->debug_mv;
-+
-+  if (ffmpegdec->max_threads == 0)
-+    ffmpegdec->context->thread_count = gst_ffmpeg_auto_max_threads ();
-+  else
-+    ffmpegdec->context->thread_count = ffmpegdec->max_threads;
-+
-+  /* open codec - we don't select an output pix_fmt yet,
-+   * simply because we don't know! We only get it
-+   * during playback... */
-+  if (!gst_ffmpegdec_open (ffmpegdec))
-+    goto open_failed;
-+
-+  /* clipping region */
-+  gst_structure_get_int (structure, "width",
-+      &ffmpegdec->format.video.clip_width);
-+  gst_structure_get_int (structure, "height",
-+      &ffmpegdec->format.video.clip_height);
-+
-+  GST_DEBUG_OBJECT (pad, "clipping to %dx%d",
-+      ffmpegdec->format.video.clip_width, ffmpegdec->format.video.clip_height);
-+
-+  /* take into account the lowres property */
-+  if (ffmpegdec->format.video.clip_width != -1)
-+    ffmpegdec->format.video.clip_width >>= ffmpegdec->lowres;
-+  if (ffmpegdec->format.video.clip_height != -1)
-+    ffmpegdec->format.video.clip_height >>= ffmpegdec->lowres;
-+
-+  GST_DEBUG_OBJECT (pad, "final clipping to %dx%d",
-+      ffmpegdec->format.video.clip_width, ffmpegdec->format.video.clip_height);
-+
-+done:
-+  GST_OBJECT_UNLOCK (ffmpegdec);
-+
-+  gst_object_unref (ffmpegdec);
-+
-+  return ret;
-+
-+  /* ERRORS */
-+open_failed:
-+  {
-+    GST_DEBUG_OBJECT (ffmpegdec, "Failed to open");
-+    if (ffmpegdec->par) {
-+      g_free (ffmpegdec->par);
-+      ffmpegdec->par = NULL;
-+    }
-+    ret = FALSE;
-+    goto done;
-+  }
-+}
-+
-+static GstFlowReturn
-+alloc_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf,
-+    gint width, gint height)
-+{
-+  GstFlowReturn ret;
-+  gint fsize;
-+
-+  ret = GST_FLOW_ERROR;
-+  *outbuf = NULL;
-+
-+  GST_LOG_OBJECT (ffmpegdec, "alloc output buffer");
-+
-+  /* see if we need renegotiation */
-+  if (G_UNLIKELY (!gst_ffmpegdec_negotiate (ffmpegdec, FALSE)))
-+    goto negotiate_failed;
-+
-+  /* get the size of the gstreamer output buffer given a
-+   * width/height/format */
-+  fsize = gst_ffmpeg_avpicture_get_size (ffmpegdec->context->pix_fmt,
-+      width, height);
-+
-+  if (ffmpegdec->can_allocate_aligned) {
-+    GST_LOG_OBJECT (ffmpegdec, "calling pad_alloc");
-+    /* no pallete, we can use the buffer size to alloc */
-+    ret = gst_pad_alloc_buffer_and_set_caps (ffmpegdec->srcpad,
-+        GST_BUFFER_OFFSET_NONE, fsize,
-+        GST_PAD_CAPS (ffmpegdec->srcpad), outbuf);
-+    if (G_UNLIKELY (ret != GST_FLOW_OK))
-+      goto alloc_failed;
-+
-+    /* If buffer isn't 128-bit aligned, create a memaligned one ourselves */
-+    if (((uintptr_t) GST_BUFFER_DATA (*outbuf)) % 16) {
-+      GST_DEBUG_OBJECT (ffmpegdec,
-+          "Downstream can't allocate aligned buffers.");
-+      ffmpegdec->can_allocate_aligned = FALSE;
-+      gst_buffer_unref (*outbuf);
-+      *outbuf = new_aligned_buffer (fsize, GST_PAD_CAPS (ffmpegdec->srcpad));
-+    }
-+  } else {
-+    GST_LOG_OBJECT (ffmpegdec,
-+        "not calling pad_alloc, we have a pallete or downstream can't give 16 byte aligned buffers.");
-+    /* for paletted data we can't use pad_alloc_buffer(), because
-+     * fsize contains the size of the palette, so the overall size
-+     * is bigger than ffmpegcolorspace's unit size, which will
-+     * prompt GstBaseTransform to complain endlessly ... */
-+    *outbuf = new_aligned_buffer (fsize, GST_PAD_CAPS (ffmpegdec->srcpad));
-+    ret = GST_FLOW_OK;
-+  }
-+  /* set caps, we do this here because the buffer is still writable here and we
-+   * are sure to be negotiated */
-+  gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (ffmpegdec->srcpad));
-+
-+  return ret;
-+
-+  /* special cases */
-+negotiate_failed:
-+  {
-+    GST_DEBUG_OBJECT (ffmpegdec, "negotiate failed");
-+    return GST_FLOW_NOT_NEGOTIATED;
-+  }
-+alloc_failed:
-+  {
-+    GST_DEBUG_OBJECT (ffmpegdec, "pad_alloc failed %d (%s)", ret,
-+        gst_flow_get_name (ret));
-+    return ret;
-+  }
-+}
-+
-+static int
-+gst_ffmpegdec_get_buffer (AVCodecContext * context, AVFrame * picture)
-+{
-+  GstBuffer *buf = NULL;
-+  GstFFMpegDec *ffmpegdec;
-+  gint width, height;
-+  gint coded_width, coded_height;
-+  gint res;
-+
-+  ffmpegdec = (GstFFMpegDec *) context->opaque;
-+
-+  GST_DEBUG_OBJECT (ffmpegdec, "getting buffer");
-+
-+  /* apply the last info we have seen to this picture, when we get the
-+   * picture back from ffmpeg we can use this to correctly timestamp the output
-+   * buffer */
-+  picture->reordered_opaque = context->reordered_opaque;
-+  /* make sure we don't free the buffer when it's not ours */
-+  picture->opaque = NULL;
-+
-+  /* take width and height before clipping */
-+  width = context->width;
-+  height = context->height;
-+  coded_width = context->coded_width;
-+  coded_height = context->coded_height;
-+
-+  GST_LOG_OBJECT (ffmpegdec, "dimension %dx%d, coded %dx%d", width, height,
-+      coded_width, coded_height);
-+  if (!ffmpegdec->current_dr) {
-+    GST_LOG_OBJECT (ffmpegdec, "direct rendering disabled, fallback alloc");
-+    res = avcodec_default_get_buffer (context, picture);
-+
-+    GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", picture->linesize[0],
-+        picture->linesize[1], picture->linesize[2]);
-+    GST_LOG_OBJECT (ffmpegdec, "data %u %u %u", 0,
-+        (guint) (picture->data[1] - picture->data[0]),
-+        (guint) (picture->data[2] - picture->data[0]));
-+    return res;
-+  }
-+
-+  switch (context->codec_type) {
-+    case AVMEDIA_TYPE_VIDEO:
-+      /* some ffmpeg video plugins don't see the point in setting codec_type ... */
-+    case AVMEDIA_TYPE_UNKNOWN:
-+    {
-+      GstFlowReturn ret;
-+      gint clip_width, clip_height;
-+
-+      /* take final clipped output size */
-+      if ((clip_width = ffmpegdec->format.video.clip_width) == -1)
-+        clip_width = width;
-+      if ((clip_height = ffmpegdec->format.video.clip_height) == -1)
-+        clip_height = height;
-+
-+      GST_LOG_OBJECT (ffmpegdec, "raw outsize %d/%d", width, height);
-+
-+      /* this is the size ffmpeg needs for the buffer */
-+      avcodec_align_dimensions (context, &width, &height);
-+
-+      GST_LOG_OBJECT (ffmpegdec, "aligned outsize %d/%d, clip %d/%d",
-+          width, height, clip_width, clip_height);
-+
-+      if (width != clip_width || height != clip_height) {
-+        /* We can't alloc if we need to clip the output buffer later */
-+        GST_LOG_OBJECT (ffmpegdec, "we need clipping, fallback alloc");
-+        return avcodec_default_get_buffer (context, picture);
-+      }
-+
-+      /* alloc with aligned dimensions for ffmpeg */
-+      ret = alloc_output_buffer (ffmpegdec, &buf, width, height);
-+      if (G_UNLIKELY (ret != GST_FLOW_OK)) {
-+        /* alloc default buffer when we can't get one from downstream */
-+        GST_LOG_OBJECT (ffmpegdec, "alloc failed, fallback alloc");
-+        return avcodec_default_get_buffer (context, picture);
-+      }
-+
-+      /* copy the right pointers and strides in the picture object */
-+      gst_ffmpeg_avpicture_fill ((AVPicture *) picture,
-+          GST_BUFFER_DATA (buf), context->pix_fmt, width, height);
-+      break;
-+    }
-+    case AVMEDIA_TYPE_AUDIO:
-+    default:
-+      GST_ERROR_OBJECT (ffmpegdec,
-+          "_get_buffer() should never get called for non-video buffers !");
-+      g_assert_not_reached ();
-+      break;
-+  }
-+
-+  /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to
-+   * the opaque data. */
-+  picture->type = FF_BUFFER_TYPE_USER;
-+  picture->opaque = buf;
-+
-+#ifdef EXTRA_REF
-+  if (picture->reference != 0 || ffmpegdec->extra_ref) {
-+    GST_DEBUG_OBJECT (ffmpegdec, "adding extra ref");
-+    gst_buffer_ref (buf);
-+  }
-+#endif
-+
-+  GST_LOG_OBJECT (ffmpegdec, "returned buffer %p", buf);
-+
-+  return 0;
-+}
-+
-+static void
-+gst_ffmpegdec_release_buffer (AVCodecContext * context, AVFrame * picture)
-+{
-+  gint i;
-+  GstBuffer *buf;
-+  GstFFMpegDec *ffmpegdec;
-+
-+  ffmpegdec = (GstFFMpegDec *) context->opaque;
-+
-+  /* check if it was our buffer */
-+  if (picture->opaque == NULL) {
-+    GST_DEBUG_OBJECT (ffmpegdec, "default release buffer");
-+    avcodec_default_release_buffer (context, picture);
-+    return;
-+  }
-+
-+  /* we remove the opaque data now */
-+  buf = GST_BUFFER_CAST (picture->opaque);
-+  GST_DEBUG_OBJECT (ffmpegdec, "release buffer %p", buf);
-+  picture->opaque = NULL;
-+
-+#ifdef EXTRA_REF
-+  if (picture->reference != 0 || ffmpegdec->extra_ref) {
-+    GST_DEBUG_OBJECT (ffmpegdec, "remove extra ref");
-+    gst_buffer_unref (buf);
-+  }
-+#else
-+  gst_buffer_unref (buf);
-+#endif
-+
-+  /* zero out the reference in ffmpeg */
-+  for (i = 0; i < 4; i++) {
-+    picture->data[i] = NULL;
-+    picture->linesize[i] = 0;
-+  }
-+}
-+
-+static void
-+gst_ffmpegdec_add_pixel_aspect_ratio (GstFFMpegDec * ffmpegdec,
-+    GstStructure * s)
-+{
-+  gboolean demuxer_par_set = FALSE;
-+  gboolean decoder_par_set = FALSE;
-+  gint demuxer_num = 1, demuxer_denom = 1;
-+  gint decoder_num = 1, decoder_denom = 1;
-+
-+  GST_OBJECT_LOCK (ffmpegdec);
-+
-+  if (ffmpegdec->par) {
-+    demuxer_num = gst_value_get_fraction_numerator (ffmpegdec->par);
-+    demuxer_denom = gst_value_get_fraction_denominator (ffmpegdec->par);
-+    demuxer_par_set = TRUE;
-+    GST_DEBUG_OBJECT (ffmpegdec, "Demuxer PAR: %d:%d", demuxer_num,
-+        demuxer_denom);
-+  }
-+
-+  if (ffmpegdec->context->sample_aspect_ratio.num &&
-+      ffmpegdec->context->sample_aspect_ratio.den) {
-+    decoder_num = ffmpegdec->context->sample_aspect_ratio.num;
-+    decoder_denom = ffmpegdec->context->sample_aspect_ratio.den;
-+    decoder_par_set = TRUE;
-+    GST_DEBUG_OBJECT (ffmpegdec, "Decoder PAR: %d:%d", decoder_num,
-+        decoder_denom);
-+  }
-+
-+  GST_OBJECT_UNLOCK (ffmpegdec);
-+
-+  if (!demuxer_par_set && !decoder_par_set)
-+    goto no_par;
-+
-+  if (demuxer_par_set && !decoder_par_set)
-+    goto use_demuxer_par;
-+
-+  if (decoder_par_set && !demuxer_par_set)
-+    goto use_decoder_par;
-+
-+  /* Both the demuxer and the decoder provide a PAR. If one of
-+   * the two PARs is 1:1 and the other one is not, use the one
-+   * that is not 1:1. */
-+  if (demuxer_num == demuxer_denom && decoder_num != decoder_denom)
-+    goto use_decoder_par;
-+
-+  if (decoder_num == decoder_denom && demuxer_num != demuxer_denom)
-+    goto use_demuxer_par;
-+
-+  /* Both PARs are non-1:1, so use the PAR provided by the demuxer */
-+  goto use_demuxer_par;
-+
-+use_decoder_par:
-+  {
-+    GST_DEBUG_OBJECT (ffmpegdec,
-+        "Setting decoder provided pixel-aspect-ratio of %u:%u", decoder_num,
-+        decoder_denom);
-+    gst_structure_set (s, "pixel-aspect-ratio", GST_TYPE_FRACTION, decoder_num,
-+        decoder_denom, NULL);
-+    return;
-+  }
-+
-+use_demuxer_par:
-+  {
-+    GST_DEBUG_OBJECT (ffmpegdec,
-+        "Setting demuxer provided pixel-aspect-ratio of %u:%u", demuxer_num,
-+        demuxer_denom);
-+    gst_structure_set (s, "pixel-aspect-ratio", GST_TYPE_FRACTION, demuxer_num,
-+        demuxer_denom, NULL);
-+    return;
-+  }
-+no_par:
-+  {
-+    GST_DEBUG_OBJECT (ffmpegdec,
-+        "Neither demuxer nor codec provide a pixel-aspect-ratio");
-+    return;
-+  }
-+}
-+
-+static gboolean
-+gst_ffmpegdec_negotiate (GstFFMpegDec * ffmpegdec, gboolean force)
-+{
-+  GstFFMpegDecClass *oclass;
-+  GstCaps *caps;
-+
-+  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
-+
-+  switch (oclass->in_plugin->type) {
-+    case AVMEDIA_TYPE_VIDEO:
-+      if (!force && ffmpegdec->format.video.width == ffmpegdec->context->width
-+          && ffmpegdec->format.video.height == ffmpegdec->context->height
-+          && ffmpegdec->format.video.fps_n == ffmpegdec->format.video.old_fps_n
-+          && ffmpegdec->format.video.fps_d == ffmpegdec->format.video.old_fps_d
-+          && ffmpegdec->format.video.pix_fmt == ffmpegdec->context->pix_fmt
-+          && ffmpegdec->format.video.par_n ==
-+          ffmpegdec->context->sample_aspect_ratio.num
-+          && ffmpegdec->format.video.par_d ==
-+          ffmpegdec->context->sample_aspect_ratio.den)
-+        return TRUE;
-+      GST_DEBUG_OBJECT (ffmpegdec,
-+          "Renegotiating video from %dx%d@ %d:%d PAR %d/%d fps to %dx%d@ %d:%d PAR %d/%d fps",
-+          ffmpegdec->format.video.width, ffmpegdec->format.video.height,
-+          ffmpegdec->format.video.par_n, ffmpegdec->format.video.par_d,
-+          ffmpegdec->format.video.old_fps_n, ffmpegdec->format.video.old_fps_n,
-+          ffmpegdec->context->width, ffmpegdec->context->height,
-+          ffmpegdec->context->sample_aspect_ratio.num,
-+          ffmpegdec->context->sample_aspect_ratio.den,
-+          ffmpegdec->format.video.fps_n, ffmpegdec->format.video.fps_d);
-+      ffmpegdec->format.video.width = ffmpegdec->context->width;
-+      ffmpegdec->format.video.height = ffmpegdec->context->height;
-+      ffmpegdec->format.video.old_fps_n = ffmpegdec->format.video.fps_n;
-+      ffmpegdec->format.video.old_fps_d = ffmpegdec->format.video.fps_d;
-+      ffmpegdec->format.video.pix_fmt = ffmpegdec->context->pix_fmt;
-+      ffmpegdec->format.video.par_n =
-+          ffmpegdec->context->sample_aspect_ratio.num;
-+      ffmpegdec->format.video.par_d =
-+          ffmpegdec->context->sample_aspect_ratio.den;
-+      break;
-+    case AVMEDIA_TYPE_AUDIO:
-+    {
-+      gint depth = av_smp_format_depth (ffmpegdec->context->sample_fmt);
-+      if (!force && ffmpegdec->format.audio.samplerate ==
-+          ffmpegdec->context->sample_rate &&
-+          ffmpegdec->format.audio.channels == ffmpegdec->context->channels &&
-+          ffmpegdec->format.audio.depth == depth)
-+        return TRUE;
-+      GST_DEBUG_OBJECT (ffmpegdec,
-+          "Renegotiating audio from %dHz@%dchannels (%d) to %dHz@%dchannels (%d)",
-+          ffmpegdec->format.audio.samplerate, ffmpegdec->format.audio.channels,
-+          ffmpegdec->format.audio.depth,
-+          ffmpegdec->context->sample_rate, ffmpegdec->context->channels, depth);
-+      ffmpegdec->format.audio.samplerate = ffmpegdec->context->sample_rate;
-+      ffmpegdec->format.audio.channels = ffmpegdec->context->channels;
-+      ffmpegdec->format.audio.depth = depth;
-+    }
-+      break;
-+    default:
-+      break;
-+  }
-+
-+  caps = gst_ffmpeg_codectype_to_caps (oclass->in_plugin->type,
-+      ffmpegdec->context, oclass->in_plugin->id, FALSE);
-+
-+  if (caps == NULL)
-+    goto no_caps;
-+
-+  switch (oclass->in_plugin->type) {
-+    case AVMEDIA_TYPE_VIDEO:
-+    {
-+      gint width, height;
-+      gboolean interlaced;
-+
-+      width = ffmpegdec->format.video.clip_width;
-+      height = ffmpegdec->format.video.clip_height;
-+      interlaced = ffmpegdec->format.video.interlaced;
-+
-+      if (width != -1 && height != -1) {
-+        /* overwrite the output size with the dimension of the
-+         * clipping region but only if they are smaller. */
-+        if (width < ffmpegdec->context->width)
-+          gst_caps_set_simple (caps, "width", G_TYPE_INT, width, NULL);
-+        if (height < ffmpegdec->context->height)
-+          gst_caps_set_simple (caps, "height", G_TYPE_INT, height, NULL);
-+      }
-+      gst_caps_set_simple (caps, "interlaced", G_TYPE_BOOLEAN, interlaced,
-+          NULL);
-+
-+      /* If a demuxer provided a framerate then use it (#313970) */
-+      if (ffmpegdec->format.video.fps_n != -1) {
-+        gst_caps_set_simple (caps, "framerate",
-+            GST_TYPE_FRACTION, ffmpegdec->format.video.fps_n,
-+            ffmpegdec->format.video.fps_d, NULL);
-+      }
-+      gst_ffmpegdec_add_pixel_aspect_ratio (ffmpegdec,
-+          gst_caps_get_structure (caps, 0));
-+      break;
-+    }
-+    case AVMEDIA_TYPE_AUDIO:
-+    {
-+      break;
-+    }
-+    default:
-+      break;
-+  }
-+
-+  if (!gst_pad_set_caps (ffmpegdec->srcpad, caps))
-+    goto caps_failed;
-+
-+  gst_caps_unref (caps);
-+
-+  return TRUE;
-+
-+  /* ERRORS */
-+no_caps:
-+  {
-+#ifdef HAVE_FFMPEG_UNINSTALLED
-+    /* using internal ffmpeg snapshot */
-+    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
-+        ("Could not find GStreamer caps mapping for FFmpeg codec '%s'.",
-+            oclass->in_plugin->name), (NULL));
-+#else
-+    /* using external ffmpeg */
-+    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
-+        ("Could not find GStreamer caps mapping for FFmpeg codec '%s', and "
-+            "you are using an external libavcodec. This is most likely due to "
-+            "a packaging problem and/or libavcodec having been upgraded to a "
-+            "version that is not compatible with this version of "
-+            "gstreamer-ffmpeg. Make sure your gstreamer-ffmpeg and libavcodec "
-+            "packages come from the same source/repository.",
-+            oclass->in_plugin->name), (NULL));
-+#endif
-+    return FALSE;
-+  }
-+caps_failed:
-+  {
-+    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
-+        ("Could not set caps for ffmpeg decoder (%s), not fixed?",
-+            oclass->in_plugin->name));
-+    gst_caps_unref (caps);
-+
-+    return FALSE;
-+  }
-+}
-+
-+/* perform qos calculations before decoding the next frame.
-+ *
-+ * Sets the skip_frame flag and if things are really bad, skips to the next
-+ * keyframe.
-+ * 
-+ * Returns TRUE if the frame should be decoded, FALSE if the frame can be dropped
-+ * entirely.
-+ */
-+static gboolean
-+gst_ffmpegdec_do_qos (GstFFMpegDec * ffmpegdec, GstClockTime timestamp,
-+    gboolean * mode_switch)
-+{
-+  GstClockTimeDiff diff;
-+  gdouble proportion;
-+  GstClockTime qostime, earliest_time;
-+  gboolean res = TRUE;
-+
-+  *mode_switch = FALSE;
-+
-+  /* no timestamp, can't do QoS */
-+  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (timestamp)))
-+    goto no_qos;
-+
-+  /* get latest QoS observation values */
-+  gst_ffmpegdec_read_qos (ffmpegdec, &proportion, &earliest_time);
-+
-+  /* skip qos if we have no observation (yet) */
-+  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (earliest_time))) {
-+    /* no skip_frame initialy */
-+    ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
-+    goto no_qos;
-+  }
-+
-+  /* qos is done on running time of the timestamp */
-+  qostime = gst_segment_to_running_time (&ffmpegdec->segment, GST_FORMAT_TIME,
-+      timestamp);
-+
-+  /* timestamp can be out of segment, then we don't do QoS */
-+  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (qostime)))
-+    goto no_qos;
-+
-+  /* see how our next timestamp relates to the latest qos timestamp. negative
-+   * values mean we are early, positive values mean we are too late. */
-+  diff = GST_CLOCK_DIFF (qostime, earliest_time);
-+
-+  GST_DEBUG_OBJECT (ffmpegdec, "QOS: qostime %" GST_TIME_FORMAT
-+      ", earliest %" GST_TIME_FORMAT, GST_TIME_ARGS (qostime),
-+      GST_TIME_ARGS (earliest_time));
-+
-+  /* if we using less than 40% of the available time, we can try to
-+   * speed up again when we were slow. */
-+  if (proportion < 0.4 && diff < 0) {
-+    goto normal_mode;
-+  } else {
-+    if (diff >= 0) {
-+      /* we're too slow, try to speed up */
-+      /* switch to skip_frame mode */
-+      goto skip_frame;
-+    }
-+  }
-+
-+no_qos:
-+  ffmpegdec->processed++;
-+  return TRUE;
-+
-+normal_mode:
-+  {
-+    if (ffmpegdec->context->skip_frame != AVDISCARD_DEFAULT) {
-+      ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
-+      *mode_switch = TRUE;
-+      GST_DEBUG_OBJECT (ffmpegdec, "QOS: normal mode %g < 0.4", proportion);
-+    }
-+    ffmpegdec->processed++;
-+    return TRUE;
-+  }
-+skip_frame:
-+  {
-+    if (ffmpegdec->context->skip_frame != AVDISCARD_NONREF) {
-+      ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
-+      *mode_switch = TRUE;
-+      GST_DEBUG_OBJECT (ffmpegdec,
-+          "QOS: hurry up, diff %" G_GINT64_FORMAT " >= 0", diff);
-+    }
-+    goto drop_qos;
-+  }
-+drop_qos:
-+  {
-+    GstClockTime stream_time, jitter;
-+    GstMessage *qos_msg;
-+
-+    ffmpegdec->dropped++;
-+    stream_time =
-+        gst_segment_to_stream_time (&ffmpegdec->segment, GST_FORMAT_TIME,
-+        timestamp);
-+    jitter = GST_CLOCK_DIFF (qostime, earliest_time);
-+    qos_msg =
-+        gst_message_new_qos (GST_OBJECT_CAST (ffmpegdec), FALSE, qostime,
-+        stream_time, timestamp, GST_CLOCK_TIME_NONE);
-+    gst_message_set_qos_values (qos_msg, jitter, proportion, 1000000);
-+    gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
-+        ffmpegdec->processed, ffmpegdec->dropped);
-+    gst_element_post_message (GST_ELEMENT_CAST (ffmpegdec), qos_msg);
-+
-+    return res;
-+  }
-+}
-+
-+/* returns TRUE if buffer is within segment, else FALSE.
-+ * if Buffer is on segment border, it's timestamp and duration will be clipped */
-+static gboolean
-+clip_video_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
-+    GstClockTime in_dur)
-+{
-+  gboolean res = TRUE;
-+  gint64 cstart, cstop;
-+  GstClockTime stop;
-+
-+  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 (G_UNLIKELY (dec->segment.format != GST_FORMAT_TIME))
-+    goto beach;
-+
-+  /* we need a start time */
-+  if (G_UNLIKELY (!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 */
-+  res =
-+      gst_segment_clip (&dec->segment, GST_FORMAT_TIME, in_ts, stop, &cstart,
-+      &cstop);
-+  if (G_UNLIKELY (!res))
-+    goto beach;
-+
-+  /* we're pretty sure the duration of this buffer is not till the end of this
-+   * segment (which _clip will assume when the stop is -1) */
-+  if (stop == GST_CLOCK_TIME_NONE)
-+    cstop = GST_CLOCK_TIME_NONE;
-+
-+  /* 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;
-+
-+  GST_LOG_OBJECT (dec,
-+      "clipped timestamp:%" GST_TIME_FORMAT " , duration:%" GST_TIME_FORMAT,
-+      GST_TIME_ARGS (cstart), GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
-+
-+beach:
-+  GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
-+  return res;
-+}
-+
-+
-+/* get an outbuf buffer with the current picture */
-+static GstFlowReturn
-+get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
-+{
-+  GstFlowReturn ret;
-+
-+  ret = GST_FLOW_OK;
-+  *outbuf = NULL;
-+
-+  if (ffmpegdec->picture->opaque != NULL) {
-+    /* we allocated a picture already for ffmpeg to decode into, let's pick it
-+     * up and use it now. */
-+    *outbuf = (GstBuffer *) ffmpegdec->picture->opaque;
-+    GST_LOG_OBJECT (ffmpegdec, "using opaque buffer %p", *outbuf);
-+#ifndef EXTRA_REF
-+    gst_buffer_ref (*outbuf);
-+#endif
-+  } else {
-+    AVPicture pic, *outpic;
-+    gint width, height;
-+
-+    GST_LOG_OBJECT (ffmpegdec, "get output buffer");
-+
-+    /* figure out size of output buffer, this is the clipped output size because
-+     * we will copy the picture into it but only when the clipping region is
-+     * smaller than the actual picture size. */
-+    if ((width = ffmpegdec->format.video.clip_width) == -1)
-+      width = ffmpegdec->context->width;
-+    else if (width > ffmpegdec->context->width)
-+      width = ffmpegdec->context->width;
-+
-+    if ((height = ffmpegdec->format.video.clip_height) == -1)
-+      height = ffmpegdec->context->height;
-+    else if (height > ffmpegdec->context->height)
-+      height = ffmpegdec->context->height;
-+
-+    GST_LOG_OBJECT (ffmpegdec, "clip width %d/height %d", width, height);
-+
-+    ret = alloc_output_buffer (ffmpegdec, outbuf, width, height);
-+    if (G_UNLIKELY (ret != GST_FLOW_OK))
-+      goto alloc_failed;
-+
-+    /* original ffmpeg code does not handle odd sizes correctly.
-+     * This patched up version does */
-+    gst_ffmpeg_avpicture_fill (&pic, GST_BUFFER_DATA (*outbuf),
-+        ffmpegdec->context->pix_fmt, width, height);
-+
-+    outpic = (AVPicture *) ffmpegdec->picture;
-+
-+    GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", outpic->linesize[0],
-+        outpic->linesize[1], outpic->linesize[2]);
-+    GST_LOG_OBJECT (ffmpegdec, "data %u %u %u", 0,
-+        (guint) (outpic->data[1] - outpic->data[0]),
-+        (guint) (outpic->data[2] - outpic->data[0]));
-+
-+    av_picture_copy (&pic, outpic, ffmpegdec->context->pix_fmt, width, height);
-+  }
-+  ffmpegdec->picture->reordered_opaque = -1;
-+
-+  return ret;
-+
-+  /* special cases */
-+alloc_failed:
-+  {
-+    GST_DEBUG_OBJECT (ffmpegdec, "pad_alloc failed");
-+    return ret;
-+  }
-+}
-+
-+static void
-+clear_queued (GstFFMpegDec * ffmpegdec)
-+{
-+  g_list_foreach (ffmpegdec->queued, (GFunc) gst_mini_object_unref, NULL);
-+  g_list_free (ffmpegdec->queued);
-+  ffmpegdec->queued = NULL;
-+}
-+
-+static GstFlowReturn
-+flush_queued (GstFFMpegDec * ffmpegdec)
-+{
-+  GstFlowReturn res = GST_FLOW_OK;
-+
-+  while (ffmpegdec->queued) {
-+    GstBuffer *buf = GST_BUFFER_CAST (ffmpegdec->queued->data);
-+
-+    GST_LOG_OBJECT (ffmpegdec, "pushing buffer %p, offset %"
-+        G_GUINT64_FORMAT ", timestamp %"
-+        GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT, buf,
-+        GST_BUFFER_OFFSET (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 (ffmpegdec->srcpad, buf);
-+
-+    ffmpegdec->queued =
-+        g_list_delete_link (ffmpegdec->queued, ffmpegdec->queued);
-+  }
-+  return res;
-+}
-+
-+static void
-+gst_avpacket_init (AVPacket * packet, guint8 * data, guint size)
-+{
-+  memset (packet, 0, sizeof (AVPacket));
-+  packet->data = data;
-+  packet->size = size;
-+}
-+
-+/* gst_ffmpegdec_[video|audio]_frame:
-+ * ffmpegdec:
-+ * data: pointer to the data to decode
-+ * size: size of data in bytes
-+ * in_timestamp: incoming timestamp.
-+ * in_duration: incoming duration.
-+ * in_offset: incoming offset (frame number).
-+ * outbuf: outgoing buffer. Different from NULL ONLY if it contains decoded data.
-+ * ret: Return flow.
-+ *
-+ * Returns: number of bytes used in decoding. The check for successful decode is
-+ *   outbuf being non-NULL.
-+ */
-+static gint
-+gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
-+    guint8 * data, guint size,
-+    const GstTSInfo * dec_info, GstBuffer ** outbuf, GstFlowReturn * ret)
-+{
-+  gint len = -1;
-+  gint have_data;
-+  gboolean mode_switch;
-+  gboolean decode;
-+  gint skip_frame = AVDISCARD_DEFAULT;
-+  GstClockTime out_timestamp, out_duration, out_pts;
-+  gint64 out_offset;
-+  const GstTSInfo *out_info;
-+  AVPacket packet;
-+
-+  *ret = GST_FLOW_OK;
-+  *outbuf = NULL;
-+
-+  ffmpegdec->context->opaque = ffmpegdec;
-+
-+  /* in case we skip frames */
-+  ffmpegdec->picture->pict_type = -1;
-+
-+  /* run QoS code, we don't stop decoding the frame when we are late because
-+   * else we might skip a reference frame */
-+  decode = gst_ffmpegdec_do_qos (ffmpegdec, dec_info->timestamp, &mode_switch);
-+
-+  if (ffmpegdec->is_realvideo && data != NULL) {
-+    gint slice_count;
-+    gint i;
-+
-+    /* setup the slice table for realvideo */
-+    if (ffmpegdec->context->slice_offset == NULL)
-+      ffmpegdec->context->slice_offset = g_malloc (sizeof (guint32) * 1000);
-+
-+    slice_count = (*data++) + 1;
-+    ffmpegdec->context->slice_count = slice_count;
-+
-+    for (i = 0; i < slice_count; i++) {
-+      data += 4;
-+      ffmpegdec->context->slice_offset[i] = GST_READ_UINT32_LE (data);
-+      data += 4;
-+    }
-+  }
-+
-+  if (!decode) {
-+    /* no decoding needed, save previous skip_frame value and brutely skip
-+     * decoding everything */
-+    skip_frame = ffmpegdec->context->skip_frame;
-+    ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
-+  }
-+
-+  /* save reference to the timing info */
-+  ffmpegdec->context->reordered_opaque = (gint64) dec_info->idx;
-+  ffmpegdec->picture->reordered_opaque = (gint64) dec_info->idx;
-+
-+  GST_DEBUG_OBJECT (ffmpegdec, "stored opaque values idx %d", dec_info->idx);
-+
-+  /* now decode the frame */
-+  gst_avpacket_init (&packet, data, size);
-+  len = avcodec_decode_video2 (ffmpegdec->context,
-+      ffmpegdec->picture, &have_data, &packet);
-+
-+  /* restore previous state */
-+  if (!decode)
-+    ffmpegdec->context->skip_frame = skip_frame;
-+
-+  GST_DEBUG_OBJECT (ffmpegdec, "after decode: len %d, have_data %d",
-+      len, have_data);
-+
-+  /* when we are in skip_frame mode, don't complain when ffmpeg returned
-+   * no data because we told it to skip stuff. */
-+  if (len < 0 && (mode_switch || ffmpegdec->context->skip_frame))
-+    len = 0;
-+
-+  if (len > 0 && have_data <= 0 && (mode_switch
-+          || ffmpegdec->context->skip_frame)) {
-+    /* we consumed some bytes but nothing decoded and we are skipping frames,
-+     * disable the interpollation of DTS timestamps */
-+    ffmpegdec->last_out = -1;
-+  }
-+
-+  /* no data, we're done */
-+  if (len < 0 || have_data <= 0)
-+    goto beach;
-+
-+  /* get the output picture timing info again */
-+  out_info = gst_ts_info_get (ffmpegdec, ffmpegdec->picture->reordered_opaque);
-+  out_pts = out_info->timestamp;
-+  out_duration = out_info->duration;
-+  out_offset = out_info->offset;
-+
-+  GST_DEBUG_OBJECT (ffmpegdec,
-+      "pts %" G_GUINT64_FORMAT " duration %" G_GUINT64_FORMAT " offset %"
-+      G_GINT64_FORMAT, out_pts, out_duration, out_offset);
-+  GST_DEBUG_OBJECT (ffmpegdec, "picture: pts %" G_GUINT64_FORMAT,
-+      (guint64) ffmpegdec->picture->pts);
-+  GST_DEBUG_OBJECT (ffmpegdec, "picture: num %d",
-+      ffmpegdec->picture->coded_picture_number);
-+  GST_DEBUG_OBJECT (ffmpegdec, "picture: ref %d",
-+      ffmpegdec->picture->reference);
-+  GST_DEBUG_OBJECT (ffmpegdec, "picture: display %d",
-+      ffmpegdec->picture->display_picture_number);
-+  GST_DEBUG_OBJECT (ffmpegdec, "picture: opaque %p",
-+      ffmpegdec->picture->opaque);
-+  GST_DEBUG_OBJECT (ffmpegdec, "picture: reordered opaque %" G_GUINT64_FORMAT,
-+      (guint64) ffmpegdec->picture->reordered_opaque);
-+  GST_DEBUG_OBJECT (ffmpegdec, "repeat_pict:%d",
-+      ffmpegdec->picture->repeat_pict);
-+  GST_DEBUG_OBJECT (ffmpegdec, "interlaced_frame:%d",
-+      ffmpegdec->picture->interlaced_frame);
-+
-+  if (G_UNLIKELY (ffmpegdec->picture->interlaced_frame !=
-+          ffmpegdec->format.video.interlaced)) {
-+    GST_WARNING ("Change in interlacing ! picture:%d, recorded:%d",
-+        ffmpegdec->picture->interlaced_frame,
-+        ffmpegdec->format.video.interlaced);
-+    ffmpegdec->format.video.interlaced = ffmpegdec->picture->interlaced_frame;
-+    gst_ffmpegdec_negotiate (ffmpegdec, TRUE);
-+  }
-+
-+  /* Whether a frame is interlaced or not is unknown at the time of
-+     buffer allocation, so caps on the buffer in opaque will have
-+     the previous frame's interlaced flag set. So if interlacedness
-+     has changed since allocation, we update the buffer (if any)
-+     caps now with the correct interlaced flag. */
-+  if (ffmpegdec->picture->opaque != NULL) {
-+    GstBuffer *buffer = ffmpegdec->picture->opaque;
-+    if (GST_BUFFER_CAPS (buffer) && GST_PAD_CAPS (ffmpegdec->srcpad)) {
-+      GstStructure *s = gst_caps_get_structure (GST_BUFFER_CAPS (buffer), 0);
-+      gboolean interlaced;
-+      gboolean found = gst_structure_get_boolean (s, "interlaced", &interlaced);
-+      if (!found || (!!interlaced != !!ffmpegdec->format.video.interlaced)) {
-+        GST_DEBUG_OBJECT (ffmpegdec,
-+            "Buffer interlacing does not match pad, updating");
-+        buffer = gst_buffer_make_metadata_writable (buffer);
-+        gst_buffer_set_caps (buffer, GST_PAD_CAPS (ffmpegdec->srcpad));
-+        ffmpegdec->picture->opaque = buffer;
-+      }
-+    }
-+  }
-+
-+  /* check that the timestamps go upwards */
-+  if (ffmpegdec->last_out != -1 && ffmpegdec->last_out > out_pts) {
-+    /* timestamps go backwards, this means frames were reordered and we must
-+     * be dealing with DTS as the buffer timestamps */
-+    if (!ffmpegdec->reordered_out) {
-+      GST_DEBUG_OBJECT (ffmpegdec, "detected reordered out timestamps");
-+      ffmpegdec->reordered_out = TRUE;
-+    }
-+    if (ffmpegdec->reordered_in) {
-+      /* we reset the input reordering here because we want to recover from an
-+       * occasionally wrong reordered input timestamp */
-+      GST_DEBUG_OBJECT (ffmpegdec, "assuming DTS input timestamps");
-+      ffmpegdec->reordered_in = FALSE;
-+    }
-+  }
-+
-+  if (out_pts == 0 && out_pts == ffmpegdec->last_out) {
-+    GST_LOG_OBJECT (ffmpegdec, "ffmpeg returns 0 timestamps, ignoring");
-+    /* some codecs only output 0 timestamps, when that happens, make us select an
-+     * output timestamp based on the input timestamp. We do this by making the
-+     * ffmpeg timestamp and the interpollated next timestamp invalid. */
-+    out_pts = -1;
-+    ffmpegdec->next_out = -1;
-+  } else
-+    ffmpegdec->last_out = out_pts;
-+
-+  /* we assume DTS as input timestamps unless we see reordered input
-+   * timestamps */
-+  if (!ffmpegdec->reordered_in && ffmpegdec->reordered_out) {
-+    /* PTS and DTS are the same for keyframes */
-+    if (ffmpegdec->next_out != -1) {
-+      /* interpolate all timestamps except for keyframes, FIXME, this is
-+       * wrong when QoS is active. */
-+      GST_DEBUG_OBJECT (ffmpegdec, "interpolate timestamps");
-+      out_pts = -1;
-+      out_offset = -1;
-+    }
-+  }
-+
-+  /* get a handle to the output buffer */
-+  *ret = get_output_buffer (ffmpegdec, outbuf);
-+  if (G_UNLIKELY (*ret != GST_FLOW_OK))
-+    goto no_output;
-+
-+  /*
-+   * Timestamps:
-+   *
-+   *  1) Copy picture timestamp if valid
-+   *  2) else interpolate from previous output timestamp
-+   *  3) else copy input timestamp
-+   */
-+  out_timestamp = -1;
-+  if (out_pts != -1) {
-+    /* Get (interpolated) timestamp from FFMPEG */
-+    out_timestamp = (GstClockTime) out_pts;
-+    GST_LOG_OBJECT (ffmpegdec, "using timestamp %" GST_TIME_FORMAT
-+        " returned by ffmpeg", GST_TIME_ARGS (out_timestamp));
-+  }
-+  if (!GST_CLOCK_TIME_IS_VALID (out_timestamp) && ffmpegdec->next_out != -1) {
-+    out_timestamp = ffmpegdec->next_out;
-+    GST_LOG_OBJECT (ffmpegdec, "using next timestamp %" GST_TIME_FORMAT,
-+        GST_TIME_ARGS (out_timestamp));
-+  }
-+  if (!GST_CLOCK_TIME_IS_VALID (out_timestamp)) {
-+    out_timestamp = dec_info->timestamp;
-+    GST_LOG_OBJECT (ffmpegdec, "using in timestamp %" GST_TIME_FORMAT,
-+        GST_TIME_ARGS (out_timestamp));
-+  }
-+  GST_BUFFER_TIMESTAMP (*outbuf) = out_timestamp;
-+
-+  /*
-+   * Offset:
-+   *  0) Use stored input offset (from opaque)
-+   *  1) Use value converted from timestamp if valid
-+   *  2) Use input offset if valid
-+   */
-+  if (out_offset != GST_BUFFER_OFFSET_NONE) {
-+    /* out_offset already contains the offset from ts_info */
-+    GST_LOG_OBJECT (ffmpegdec, "Using offset returned by ffmpeg");
-+  } else if (out_timestamp != GST_CLOCK_TIME_NONE) {
-+    GstFormat out_fmt = GST_FORMAT_DEFAULT;
-+    GST_LOG_OBJECT (ffmpegdec, "Using offset converted from timestamp");
-+    /* FIXME, we should really remove this as it's not nice at all to do
-+     * upstream queries for each frame to get the frame offset. We also can't
-+     * really remove this because it is the only way of setting frame offsets
-+     * on outgoing buffers. We should have metadata so that the upstream peer
-+     * can set a frame number on the encoded data. */
-+    gst_pad_query_peer_convert (ffmpegdec->sinkpad,
-+        GST_FORMAT_TIME, out_timestamp, &out_fmt, &out_offset);
-+  } else if (dec_info->offset != GST_BUFFER_OFFSET_NONE) {
-+    /* FIXME, the input offset is input media specific and might not
-+     * be the same for the output media. (byte offset as input, frame number
-+     * as output, for example) */
-+    GST_LOG_OBJECT (ffmpegdec, "using in_offset %" G_GINT64_FORMAT,
-+        dec_info->offset);
-+    out_offset = dec_info->offset;
-+  } else {
-+    GST_LOG_OBJECT (ffmpegdec, "no valid offset found");
-+    out_offset = GST_BUFFER_OFFSET_NONE;
-+  }
-+  GST_BUFFER_OFFSET (*outbuf) = out_offset;
-+
-+  /*
-+   * Duration:
-+   *
-+   *  1) Use reordered input duration if valid
-+   *  2) Else use input duration
-+   *  3) else use input framerate
-+   *  4) else use ffmpeg framerate
-+   */
-+  if (GST_CLOCK_TIME_IS_VALID (out_duration)) {
-+    /* We have a valid (reordered) duration */
-+    GST_LOG_OBJECT (ffmpegdec, "Using duration returned by ffmpeg");
-+  } else if (GST_CLOCK_TIME_IS_VALID (dec_info->duration)) {
-+    GST_LOG_OBJECT (ffmpegdec, "using in_duration");
-+    out_duration = dec_info->duration;
-+  } else if (GST_CLOCK_TIME_IS_VALID (ffmpegdec->last_diff)) {
-+    GST_LOG_OBJECT (ffmpegdec, "using last-diff");
-+    out_duration = ffmpegdec->last_diff;
-+  } else {
-+    /* if we have an input framerate, use that */
-+    if (ffmpegdec->format.video.fps_n != -1 &&
-+        (ffmpegdec->format.video.fps_n != 1000 &&
-+            ffmpegdec->format.video.fps_d != 1)) {
-+      GST_LOG_OBJECT (ffmpegdec, "using input framerate for duration");
-+      out_duration = gst_util_uint64_scale_int (GST_SECOND,
-+          ffmpegdec->format.video.fps_d, ffmpegdec->format.video.fps_n);
-+    } else {
-+      /* don't try to use the decoder's framerate when it seems a bit abnormal,
-+       * which we assume when den >= 1000... */
-+      if (ffmpegdec->context->time_base.num != 0 &&
-+          (ffmpegdec->context->time_base.den > 0 &&
-+              ffmpegdec->context->time_base.den < 1000)) {
-+        GST_LOG_OBJECT (ffmpegdec, "using decoder's framerate for duration");
-+        out_duration = gst_util_uint64_scale_int (GST_SECOND,
-+            ffmpegdec->context->time_base.num *
-+            ffmpegdec->context->ticks_per_frame,
-+            ffmpegdec->context->time_base.den);
-+      } else {
-+        GST_LOG_OBJECT (ffmpegdec, "no valid duration found");
-+      }
-+    }
-+  }
-+
-+  /* Take repeat_pict into account */
-+  if (GST_CLOCK_TIME_IS_VALID (out_duration)) {
-+    out_duration += out_duration * ffmpegdec->picture->repeat_pict / 2;
-+  }
-+  GST_BUFFER_DURATION (*outbuf) = out_duration;
-+
-+  if (out_timestamp != -1 && out_duration != -1 && out_duration != 0)
-+    ffmpegdec->next_out = out_timestamp + out_duration;
-+  else
-+    ffmpegdec->next_out = -1;
-+
-+  /* now see if we need to clip the buffer against the segment boundaries. */
-+  if (G_UNLIKELY (!clip_video_buffer (ffmpegdec, *outbuf, out_timestamp,
-+              out_duration)))
-+    goto clipped;
-+
-+  if (ffmpegdec->picture->top_field_first)
-+    GST_BUFFER_FLAG_SET (*outbuf, GST_VIDEO_BUFFER_TFF);
-+
-+
-+beach:
-+  GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
-+      *ret, *outbuf, len);
-+  return len;
-+
-+  /* special cases */
-+no_output:
-+  {
-+    GST_DEBUG_OBJECT (ffmpegdec, "no output buffer");
-+    len = -1;
-+    goto beach;
-+  }
-+clipped:
-+  {
-+    GST_DEBUG_OBJECT (ffmpegdec, "buffer clipped");
-+    gst_buffer_unref (*outbuf);
-+    *outbuf = NULL;
-+    goto beach;
-+  }
-+}
-+
-+/* returns TRUE if buffer is within segment, else FALSE.
-+ * if Buffer is on segment border, it's timestamp and duration will be clipped */
-+static gboolean
-+clip_audio_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
-+    GstClockTime in_dur)
-+{
-+  GstClockTime stop;
-+  gint64 diff, ctime, cstop;
-+  gboolean res = TRUE;
-+
-+  GST_LOG_OBJECT (dec,
-+      "timestamp:%" GST_TIME_FORMAT ", duration:%" GST_TIME_FORMAT
-+      ", size %u", GST_TIME_ARGS (in_ts), GST_TIME_ARGS (in_dur),
-+      GST_BUFFER_SIZE (buf));
-+
-+  /* can't clip without TIME segment */
-+  if (G_UNLIKELY (dec->segment.format != GST_FORMAT_TIME))
-+    goto beach;
-+
-+  /* we need a start time */
-+  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (in_ts)))
-+    goto beach;
-+
-+  /* trust duration */
-+  stop = in_ts + in_dur;
-+
-+  res = gst_segment_clip (&dec->segment, GST_FORMAT_TIME, in_ts, stop, &ctime,
-+      &cstop);
-+  if (G_UNLIKELY (!res))
-+    goto out_of_segment;
-+
-+  /* see if some clipping happened */
-+  if (G_UNLIKELY ((diff = ctime - in_ts) > 0)) {
-+    /* bring clipped time to bytes */
-+    diff =
-+        gst_util_uint64_scale_int (diff, dec->format.audio.samplerate,
-+        GST_SECOND) * (dec->format.audio.depth * dec->format.audio.channels);
-+
-+    GST_DEBUG_OBJECT (dec, "clipping start to %" GST_TIME_FORMAT " %"
-+        G_GINT64_FORMAT " bytes", GST_TIME_ARGS (ctime), diff);
-+
-+    GST_BUFFER_SIZE (buf) -= diff;
-+    GST_BUFFER_DATA (buf) += diff;
-+  }
-+  if (G_UNLIKELY ((diff = stop - cstop) > 0)) {
-+    /* bring clipped time to bytes */
-+    diff =
-+        gst_util_uint64_scale_int (diff, dec->format.audio.samplerate,
-+        GST_SECOND) * (dec->format.audio.depth * dec->format.audio.channels);
-+
-+    GST_DEBUG_OBJECT (dec, "clipping stop to %" GST_TIME_FORMAT " %"
-+        G_GINT64_FORMAT " bytes", GST_TIME_ARGS (cstop), diff);
-+
-+    GST_BUFFER_SIZE (buf) -= diff;
-+  }
-+  GST_BUFFER_TIMESTAMP (buf) = ctime;
-+  GST_BUFFER_DURATION (buf) = cstop - ctime;
-+
-+beach:
-+  GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
-+  return res;
-+
-+  /* ERRORS */
-+out_of_segment:
-+  {
-+    GST_LOG_OBJECT (dec, "out of segment");
-+    goto beach;
-+  }
-+}
-+
-+static gint
-+gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec,
-+    AVCodec * in_plugin, guint8 * data, guint size,
-+    const GstTSInfo * dec_info, GstBuffer ** outbuf, GstFlowReturn * ret)
-+{
-+  gint len = -1;
-+  gint have_data = AVCODEC_MAX_AUDIO_FRAME_SIZE;
-+  GstClockTime out_timestamp, out_duration;
-+  gint64 out_offset;
-+  AVPacket packet;
-+
-+  GST_DEBUG_OBJECT (ffmpegdec,
-+      "size:%d, offset:%" G_GINT64_FORMAT ", ts:%" GST_TIME_FORMAT ", dur:%"
-+      GST_TIME_FORMAT ", ffmpegdec->next_out:%" GST_TIME_FORMAT, size,
-+      dec_info->offset, GST_TIME_ARGS (dec_info->timestamp),
-+      GST_TIME_ARGS (dec_info->duration), GST_TIME_ARGS (ffmpegdec->next_out));
-+
-+  *outbuf =
-+      new_aligned_buffer (AVCODEC_MAX_AUDIO_FRAME_SIZE,
-+      GST_PAD_CAPS (ffmpegdec->srcpad));
-+
-+  gst_avpacket_init (&packet, data, size);
-+  len = avcodec_decode_audio3 (ffmpegdec->context,
-+      (int16_t *) GST_BUFFER_DATA (*outbuf), &have_data, &packet);
-+  GST_DEBUG_OBJECT (ffmpegdec,
-+      "Decode audio: len=%d, have_data=%d", len, have_data);
-+
-+  if (len >= 0 && have_data > 0) {
-+    GST_DEBUG_OBJECT (ffmpegdec, "Creating output buffer");
-+    if (!gst_ffmpegdec_negotiate (ffmpegdec, FALSE)) {
-+      gst_buffer_unref (*outbuf);
-+      *outbuf = NULL;
-+      len = -1;
-+      goto beach;
-+    }
-+
-+    /* Buffer size */
-+    GST_BUFFER_SIZE (*outbuf) = have_data;
-+
-+    /*
-+     * Timestamps:
-+     *
-+     *  1) Copy input timestamp if valid
-+     *  2) else interpolate from previous input timestamp
-+     */
-+    /* always take timestamps from the input buffer if any */
-+    if (GST_CLOCK_TIME_IS_VALID (dec_info->timestamp)) {
-+      out_timestamp = dec_info->timestamp;
-+    } else {
-+      out_timestamp = ffmpegdec->next_out;
-+    }
-+
-+    /*
-+     * Duration:
-+     *
-+     *  1) calculate based on number of samples
-+     */
-+    out_duration = gst_util_uint64_scale (have_data, GST_SECOND,
-+        ffmpegdec->format.audio.depth * ffmpegdec->format.audio.channels *
-+        ffmpegdec->format.audio.samplerate);
-+
-+    /* offset:
-+     *
-+     * Just copy
-+     */
-+    out_offset = dec_info->offset;
-+
-+    GST_DEBUG_OBJECT (ffmpegdec,
-+        "Buffer created. Size:%d , timestamp:%" GST_TIME_FORMAT " , duration:%"
-+        GST_TIME_FORMAT, have_data,
-+        GST_TIME_ARGS (out_timestamp), GST_TIME_ARGS (out_duration));
-+
-+    GST_BUFFER_TIMESTAMP (*outbuf) = out_timestamp;
-+    GST_BUFFER_DURATION (*outbuf) = out_duration;
-+    GST_BUFFER_OFFSET (*outbuf) = out_offset;
-+    gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (ffmpegdec->srcpad));
-+
-+    /* the next timestamp we'll use when interpolating */
-+    if (GST_CLOCK_TIME_IS_VALID (out_timestamp))
-+      ffmpegdec->next_out = out_timestamp + out_duration;
-+
-+    /* now see if we need to clip the buffer against the segment boundaries. */
-+    if (G_UNLIKELY (!clip_audio_buffer (ffmpegdec, *outbuf, out_timestamp,
-+                out_duration)))
-+      goto clipped;
-+
-+  } else {
-+    gst_buffer_unref (*outbuf);
-+    *outbuf = NULL;
-+  }
-+
-+  /* If we don't error out after the first failed read with the AAC decoder,
-+   * we must *not* carry on pushing data, else we'll cause segfaults... */
-+  if (len == -1 && (in_plugin->id == CODEC_ID_AAC
-+          || in_plugin->id == CODEC_ID_AAC_LATM)) {
-+    GST_ELEMENT_ERROR (ffmpegdec, STREAM, DECODE, (NULL),
-+        ("Decoding of AAC stream by FFMPEG failed."));
-+    *ret = GST_FLOW_ERROR;
-+  }
-+
-+beach:
-+  GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
-+      *ret, *outbuf, len);
-+  return len;
-+
-+  /* ERRORS */
-+clipped:
-+  {
-+    GST_DEBUG_OBJECT (ffmpegdec, "buffer clipped");
-+    gst_buffer_unref (*outbuf);
-+    *outbuf = NULL;
-+    goto beach;
-+  }
-+}
-+
-+/* gst_ffmpegdec_frame:
-+ * ffmpegdec:
-+ * data: pointer to the data to decode
-+ * size: size of data in bytes
-+ * got_data: 0 if no data was decoded, != 0 otherwise.
-+ * in_time: timestamp of data
-+ * in_duration: duration of data
-+ * ret: GstFlowReturn to return in the chain function
-+ *
-+ * Decode the given frame and pushes it downstream.
-+ *
-+ * Returns: Number of bytes used in decoding, -1 on error/failure.
-+ */
-+
-+static gint
-+gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec,
-+    guint8 * data, guint size, gint * got_data, const GstTSInfo * dec_info,
-+    GstFlowReturn * ret)
-+{
-+  GstFFMpegDecClass *oclass;
-+  GstBuffer *outbuf = NULL;
-+  gint have_data = 0, len = 0;
-+
-+  if (G_UNLIKELY (ffmpegdec->context->codec == NULL))
-+    goto no_codec;
-+
-+  GST_LOG_OBJECT (ffmpegdec, "data:%p, size:%d, id:%d", data, size,
-+      dec_info->idx);
-+
-+  *ret = GST_FLOW_OK;
-+  ffmpegdec->context->frame_number++;
-+
-+  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
-+
-+  switch (oclass->in_plugin->type) {
-+    case AVMEDIA_TYPE_VIDEO:
-+      len =
-+          gst_ffmpegdec_video_frame (ffmpegdec, data, size, dec_info, &outbuf,
-+          ret);
-+      break;
-+    case AVMEDIA_TYPE_AUDIO:
-+      len =
-+          gst_ffmpegdec_audio_frame (ffmpegdec, oclass->in_plugin, data, size,
-+          dec_info, &outbuf, ret);
-+
-+      /* if we did not get an output buffer and we have a pending discont, don't
-+       * clear the input timestamps, we will put them on the next buffer because
-+       * else we might create the first buffer with a very big timestamp gap. */
-+      if (outbuf == NULL && ffmpegdec->discont) {
-+        GST_DEBUG_OBJECT (ffmpegdec, "no buffer but keeping timestamp");
-+        ffmpegdec->clear_ts = FALSE;
-+      }
-+      break;
-+    default:
-+      GST_ERROR_OBJECT (ffmpegdec, "Asked to decode non-audio/video frame !");
-+      g_assert_not_reached ();
-+      break;
-+  }
-+
-+  if (outbuf)
-+    have_data = 1;
-+
-+  if (len < 0 || have_data < 0) {
-+    GST_WARNING_OBJECT (ffmpegdec,
-+        "ffdec_%s: decoding error (len: %d, have_data: %d)",
-+        oclass->in_plugin->name, len, have_data);
-+    *got_data = 0;
-+    goto beach;
-+  } else if (len == 0 && have_data == 0) {
-+    *got_data = 0;
-+    goto beach;
-+  } else {
-+    /* this is where I lost my last clue on ffmpeg... */
-+    *got_data = 1;
-+  }
-+
-+  if (outbuf) {
-+    GST_LOG_OBJECT (ffmpegdec,
-+        "Decoded data, now pushing buffer %p with offset %" G_GINT64_FORMAT
-+        ", timestamp %" GST_TIME_FORMAT " and duration %" GST_TIME_FORMAT,
-+        outbuf, GST_BUFFER_OFFSET (outbuf),
-+        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
-+        GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)));
-+
-+    /* mark pending discont */
-+    if (ffmpegdec->discont) {
-+      GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
-+      ffmpegdec->discont = FALSE;
-+    }
-+
-+    if (ffmpegdec->segment.rate > 0.0) {
-+      /* and off we go */
-+      *ret = gst_pad_push (ffmpegdec->srcpad, outbuf);
-+    } else {
-+      /* reverse playback, queue frame till later when we get a discont. */
-+      GST_DEBUG_OBJECT (ffmpegdec, "queued frame");
-+      ffmpegdec->queued = g_list_prepend (ffmpegdec->queued, outbuf);
-+      *ret = GST_FLOW_OK;
-+    }
-+  } else {
-+    GST_DEBUG_OBJECT (ffmpegdec, "We didn't get a decoded buffer");
-+  }
-+
-+beach:
-+  return len;
-+
-+  /* ERRORS */
-+no_codec:
-+  {
-+    GST_ERROR_OBJECT (ffmpegdec, "no codec context");
-+    return -1;
-+  }
-+}
-+
-+static void
-+gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec)
-+{
-+  GstFFMpegDecClass *oclass;
-+
-+  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
-+
-+  if (oclass->in_plugin->capabilities & CODEC_CAP_DELAY) {
-+    gint have_data, len, try = 0;
-+
-+    GST_LOG_OBJECT (ffmpegdec,
-+        "codec has delay capabilities, calling until ffmpeg has drained everything");
-+
-+    do {
-+      GstFlowReturn ret;
-+
-+      len =
-+          gst_ffmpegdec_frame (ffmpegdec, NULL, 0, &have_data, &ts_info_none,
-+          &ret);
-+      if (len < 0 || have_data == 0)
-+        break;
-+    } while (try++ < 10);
-+  }
-+  if (ffmpegdec->segment.rate < 0.0) {
-+    /* if we have some queued frames for reverse playback, flush them now */
-+    flush_queued (ffmpegdec);
-+  }
-+}
-+
-+static void
-+gst_ffmpegdec_flush_pcache (GstFFMpegDec * ffmpegdec)
-+{
-+  if (ffmpegdec->pctx) {
-+    gint size, bsize;
-+    guint8 *data;
-+    guint8 bdata[FF_INPUT_BUFFER_PADDING_SIZE];
-+
-+    bsize = FF_INPUT_BUFFER_PADDING_SIZE;
-+    memset (bdata, 0, bsize);
-+
-+    /* parse some dummy data to work around some ffmpeg weirdness where it keeps
-+     * the previous pts around */
-+    av_parser_parse2 (ffmpegdec->pctx, ffmpegdec->context,
-+        &data, &size, bdata, bsize, -1, -1, -1);
-+    ffmpegdec->pctx->pts = -1;
-+    ffmpegdec->pctx->dts = -1;
-+  }
-+
-+  if (ffmpegdec->pcache) {
-+    gst_buffer_unref (ffmpegdec->pcache);
-+    ffmpegdec->pcache = NULL;
-+  }
-+}
-+
-+static gboolean
-+gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event)
-+{
-+  GstFFMpegDec *ffmpegdec;
-+  gboolean ret = FALSE;
-+
-+  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
-+
-+  GST_DEBUG_OBJECT (ffmpegdec, "Handling %s event",
-+      GST_EVENT_TYPE_NAME (event));
-+
-+  switch (GST_EVENT_TYPE (event)) {
-+    case GST_EVENT_EOS:
-+    {
-+      gst_ffmpegdec_drain (ffmpegdec);
-+      break;
-+    }
-+    case GST_EVENT_FLUSH_STOP:
-+    {
-+      if (ffmpegdec->opened) {
-+        avcodec_flush_buffers (ffmpegdec->context);
-+      }
-+      gst_ffmpegdec_reset_ts (ffmpegdec);
-+      gst_ffmpegdec_reset_qos (ffmpegdec);
-+      gst_ffmpegdec_flush_pcache (ffmpegdec);
-+      gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
-+      clear_queued (ffmpegdec);
-+      break;
-+    }
-+    case GST_EVENT_NEWSEGMENT:
-+    {
-+      gboolean update;
-+      GstFormat fmt;
-+      gint64 start, stop, time;
-+      gdouble rate, arate;
-+
-+      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &fmt,
-+          &start, &stop, &time);
-+
-+      switch (fmt) {
-+        case GST_FORMAT_TIME:
-+          /* fine, our native segment format */
-+          break;
-+        case GST_FORMAT_BYTES:
-+        {
-+          gint bit_rate;
-+
-+          bit_rate = ffmpegdec->context->bit_rate;
-+
-+          /* convert to time or fail */
-+          if (!bit_rate)
-+            goto no_bitrate;
-+
-+          GST_DEBUG_OBJECT (ffmpegdec, "bitrate: %d", bit_rate);
-+
-+          /* convert values to TIME */
-+          if (start != -1)
-+            start = gst_util_uint64_scale_int (start, GST_SECOND, bit_rate);
-+          if (stop != -1)
-+            stop = gst_util_uint64_scale_int (stop, GST_SECOND, bit_rate);
-+          if (time != -1)
-+            time = gst_util_uint64_scale_int (time, GST_SECOND, bit_rate);
-+
-+          /* unref old event */
-+          gst_event_unref (event);
-+
-+          /* create new converted time segment */
-+          fmt = GST_FORMAT_TIME;
-+          /* FIXME, bitrate is not good enough too find a good stop, let's
-+           * hope start and time were 0... meh. */
-+          stop = -1;
-+          event = gst_event_new_new_segment (update, rate, fmt,
-+              start, stop, time);
-+          break;
-+        }
-+        default:
-+          /* invalid format */
-+          goto invalid_format;
-+      }
-+
-+      /* drain pending frames before trying to use the new segment, queued
-+       * buffers belonged to the previous segment. */
-+      if (ffmpegdec->context->codec)
-+        gst_ffmpegdec_drain (ffmpegdec);
-+
-+      GST_DEBUG_OBJECT (ffmpegdec,
-+          "NEWSEGMENT in time start %" GST_TIME_FORMAT " -- stop %"
-+          GST_TIME_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
-+
-+      /* and store the values */
-+      gst_segment_set_newsegment_full (&ffmpegdec->segment, update,
-+          rate, arate, fmt, start, stop, time);
-+      break;
-+    }
-+    default:
-+      break;
-+  }
-+
-+  /* and push segment downstream */
-+  ret = gst_pad_push_event (ffmpegdec->srcpad, event);
-+
-+done:
-+  gst_object_unref (ffmpegdec);
-+
-+  return ret;
-+
-+  /* ERRORS */
-+no_bitrate:
-+  {
-+    GST_WARNING_OBJECT (ffmpegdec, "no bitrate to convert BYTES to TIME");
-+    gst_event_unref (event);
-+    goto done;
-+  }
-+invalid_format:
-+  {
-+    GST_WARNING_OBJECT (ffmpegdec, "unknown format received in NEWSEGMENT");
-+    gst_event_unref (event);
-+    goto done;
-+  }
-+}
-+
-+static GstFlowReturn
-+gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
-+{
-+  GstFFMpegDec *ffmpegdec;
-+  GstFFMpegDecClass *oclass;
-+  guint8 *data, *bdata;
-+  gint size, bsize, len, have_data;
-+  GstFlowReturn ret = GST_FLOW_OK;
-+  GstClockTime in_timestamp;
-+  GstClockTime in_duration;
-+  gboolean discont;
-+  gint64 in_offset;
-+  const GstTSInfo *in_info;
-+  const GstTSInfo *dec_info;
-+
-+  ffmpegdec = (GstFFMpegDec *) (GST_PAD_PARENT (pad));
-+
-+  if (G_UNLIKELY (!ffmpegdec->opened))
-+    goto not_negotiated;
-+
-+  discont = GST_BUFFER_IS_DISCONT (inbuf);
-+
-+  /* The discont flags marks a buffer that is not continuous with the previous
-+   * buffer. This means we need to clear whatever data we currently have. We
-+   * currently also wait for a new keyframe, which might be suboptimal in the
-+   * case of a network error, better show the errors than to drop all data.. */
-+  if (G_UNLIKELY (discont)) {
-+    GST_DEBUG_OBJECT (ffmpegdec, "received DISCONT");
-+    /* drain what we have queued */
-+    gst_ffmpegdec_drain (ffmpegdec);
-+    gst_ffmpegdec_flush_pcache (ffmpegdec);
-+    avcodec_flush_buffers (ffmpegdec->context);
-+    ffmpegdec->discont = TRUE;
-+    gst_ffmpegdec_reset_ts (ffmpegdec);
-+  }
-+  /* by default we clear the input timestamp after decoding each frame so that
-+   * interpollation can work. */
-+  ffmpegdec->clear_ts = TRUE;
-+
-+  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
-+
-+  /* parse cache joining. If there is cached data */
-+  if (ffmpegdec->pcache) {
-+    /* join with previous data */
-+    GST_LOG_OBJECT (ffmpegdec, "join parse cache");
-+    inbuf = gst_buffer_join (ffmpegdec->pcache, inbuf);
-+    /* no more cached data, we assume we can consume the complete cache */
-+    ffmpegdec->pcache = NULL;
-+  }
-+
-+  in_timestamp = GST_BUFFER_TIMESTAMP (inbuf);
-+  in_duration = GST_BUFFER_DURATION (inbuf);
-+  in_offset = GST_BUFFER_OFFSET (inbuf);
-+
-+  /* get handle to timestamp info, we can pass this around to ffmpeg */
-+  in_info = gst_ts_info_store (ffmpegdec, in_timestamp, in_duration, in_offset);
-+
-+  if (in_timestamp != -1) {
-+    /* check for increasing timestamps if they are jumping backwards, we
-+     * probably are dealing with PTS as timestamps */
-+    if (!ffmpegdec->reordered_in && ffmpegdec->last_in != -1) {
-+      if (in_timestamp < ffmpegdec->last_in) {
-+        GST_LOG_OBJECT (ffmpegdec, "detected reordered input timestamps");
-+        ffmpegdec->reordered_in = TRUE;
-+        ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
-+      } else if (in_timestamp > ffmpegdec->last_in) {
-+        GstClockTime diff;
-+        /* keep track of timestamp diff to estimate duration */
-+        diff = in_timestamp - ffmpegdec->last_in;
-+        /* need to scale with amount of frames in the interval */
-+        if (ffmpegdec->last_frames)
-+          diff /= ffmpegdec->last_frames;
-+
-+        GST_LOG_OBJECT (ffmpegdec, "estimated duration %" GST_TIME_FORMAT " %u",
-+            GST_TIME_ARGS (diff), ffmpegdec->last_frames);
-+
-+        ffmpegdec->last_diff = diff;
-+      }
-+    }
-+    ffmpegdec->last_in = in_timestamp;
-+    ffmpegdec->last_frames = 0;
-+  }
-+
-+  GST_LOG_OBJECT (ffmpegdec,
-+      "Received new data of size %u, offset:%" G_GUINT64_FORMAT ", ts:%"
-+      GST_TIME_FORMAT ", dur:%" GST_TIME_FORMAT ", info %d",
-+      GST_BUFFER_SIZE (inbuf), GST_BUFFER_OFFSET (inbuf),
-+      GST_TIME_ARGS (in_timestamp), GST_TIME_ARGS (in_duration), in_info->idx);
-+
-+  /* workarounds, functions write to buffers:
-+   *  libavcodec/svq1.c:svq1_decode_frame writes to the given buffer.
-+   *  libavcodec/svq3.c:svq3_decode_slice_header too.
-+   * ffmpeg devs know about it and will fix it (they said). */
-+  if (oclass->in_plugin->id == CODEC_ID_SVQ1 ||
-+      oclass->in_plugin->id == CODEC_ID_SVQ3) {
-+    inbuf = gst_buffer_make_writable (inbuf);
-+  }
-+
-+  bdata = GST_BUFFER_DATA (inbuf);
-+  bsize = GST_BUFFER_SIZE (inbuf);
-+
-+  if (ffmpegdec->do_padding) {
-+    /* add padding */
-+    if (ffmpegdec->padded_size < bsize + FF_INPUT_BUFFER_PADDING_SIZE) {
-+      ffmpegdec->padded_size = bsize + FF_INPUT_BUFFER_PADDING_SIZE;
-+      ffmpegdec->padded = g_realloc (ffmpegdec->padded, ffmpegdec->padded_size);
-+      GST_LOG_OBJECT (ffmpegdec, "resized padding buffer to %d",
-+          ffmpegdec->padded_size);
-+    }
-+    memcpy (ffmpegdec->padded, bdata, bsize);
-+    memset (ffmpegdec->padded + bsize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
-+
-+    bdata = ffmpegdec->padded;
-+  }
-+
-+  do {
-+    guint8 tmp_padding[FF_INPUT_BUFFER_PADDING_SIZE];
-+
-+    /* parse, if at all possible */
-+    if (ffmpegdec->pctx) {
-+      gint res;
-+
-+      GST_LOG_OBJECT (ffmpegdec,
-+          "Calling av_parser_parse2 with offset %" G_GINT64_FORMAT ", ts:%"
-+          GST_TIME_FORMAT " size %d", in_offset, GST_TIME_ARGS (in_timestamp),
-+          bsize);
-+
-+      /* feed the parser. We pass the timestamp info so that we can recover all
-+       * info again later */
-+      res = av_parser_parse2 (ffmpegdec->pctx, ffmpegdec->context,
-+          &data, &size, bdata, bsize, in_info->idx, in_info->idx, in_offset);
-+
-+      GST_LOG_OBJECT (ffmpegdec,
-+          "parser returned res %d and size %d, id %" G_GINT64_FORMAT, res, size,
-+          ffmpegdec->pctx->pts);
-+
-+      /* store pts for decoding */
-+      if (ffmpegdec->pctx->pts != AV_NOPTS_VALUE && ffmpegdec->pctx->pts != -1)
-+        dec_info = gst_ts_info_get (ffmpegdec, ffmpegdec->pctx->pts);
-+      else {
-+        /* ffmpeg sometimes loses track after a flush, help it by feeding a
-+         * valid start time */
-+        ffmpegdec->pctx->pts = in_info->idx;
-+        ffmpegdec->pctx->dts = in_info->idx;
-+        dec_info = in_info;
-+      }
-+
-+      GST_LOG_OBJECT (ffmpegdec, "consuming %d bytes. id %d", size,
-+          dec_info->idx);
-+
-+      if (res) {
-+        /* there is output, set pointers for next round. */
-+        bsize -= res;
-+        bdata += res;
-+      } else {
-+        /* Parser did not consume any data, make sure we don't clear the
-+         * timestamp for the next round */
-+        ffmpegdec->clear_ts = FALSE;
-+      }
-+
-+      /* if there is no output, we must break and wait for more data. also the
-+       * timestamp in the context is not updated. */
-+      if (size == 0) {
-+        if (bsize > 0)
-+          continue;
-+        else
-+          break;
-+      }
-+    } else {
-+      data = bdata;
-+      size = bsize;
-+
-+      dec_info = in_info;
-+    }
-+
-+    if (ffmpegdec->do_padding) {
-+      /* add temporary padding */
-+      memcpy (tmp_padding, data + size, FF_INPUT_BUFFER_PADDING_SIZE);
-+      memset (data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
-+    }
-+
-+    /* decode a frame of audio/video now */
-+    len =
-+        gst_ffmpegdec_frame (ffmpegdec, data, size, &have_data, dec_info, &ret);
-+
-+    if (ffmpegdec->do_padding) {
-+      memcpy (data + size, tmp_padding, FF_INPUT_BUFFER_PADDING_SIZE);
-+    }
-+
-+    if (ret != GST_FLOW_OK) {
-+      GST_LOG_OBJECT (ffmpegdec, "breaking because of flow ret %s",
-+          gst_flow_get_name (ret));
-+      /* bad flow retun, make sure we discard all data and exit */
-+      bsize = 0;
-+      break;
-+    }
-+    if (!ffmpegdec->pctx) {
-+      if (len == 0 && !have_data) {
-+        /* nothing was decoded, this could be because no data was available or
-+         * because we were skipping frames.
-+         * If we have no context we must exit and wait for more data, we keep the
-+         * data we tried. */
-+        GST_LOG_OBJECT (ffmpegdec, "Decoding didn't return any data, breaking");
-+        break;
-+      } else if (len < 0) {
-+        /* a decoding error happened, we must break and try again with next data. */
-+        GST_LOG_OBJECT (ffmpegdec, "Decoding error, breaking");
-+        bsize = 0;
-+        break;
-+      }
-+      /* prepare for the next round, for codecs with a context we did this
-+       * already when using the parser. */
-+      bsize -= len;
-+      bdata += len;
-+    } else {
-+      if (len == 0) {
-+        /* nothing was decoded, this could be because no data was available or
-+         * because we were skipping frames. Since we have a parser we can
-+         * continue with the next frame */
-+        GST_LOG_OBJECT (ffmpegdec,
-+            "Decoding didn't return any data, trying next");
-+      } else if (len < 0) {
-+        /* we have a context that will bring us to the next frame */
-+        GST_LOG_OBJECT (ffmpegdec, "Decoding error, trying next");
-+      }
-+    }
-+
-+    /* make sure we don't use the same old timestamp for the next frame and let
-+     * the interpollation take care of it. */
-+    if (ffmpegdec->clear_ts) {
-+      in_timestamp = GST_CLOCK_TIME_NONE;
-+      in_duration = GST_CLOCK_TIME_NONE;
-+      in_offset = GST_BUFFER_OFFSET_NONE;
-+      in_info = GST_TS_INFO_NONE;
-+    } else {
-+      ffmpegdec->clear_ts = TRUE;
-+    }
-+    ffmpegdec->last_frames++;
-+
-+    GST_LOG_OBJECT (ffmpegdec, "Before (while bsize>0).  bsize:%d , bdata:%p",
-+        bsize, bdata);
-+  } while (bsize > 0);
-+
-+  /* keep left-over */
-+  if (ffmpegdec->pctx && bsize > 0) {
-+    in_timestamp = GST_BUFFER_TIMESTAMP (inbuf);
-+    in_offset = GST_BUFFER_OFFSET (inbuf);
-+
-+    GST_LOG_OBJECT (ffmpegdec,
-+        "Keeping %d bytes of data with offset %" G_GINT64_FORMAT ", timestamp %"
-+        GST_TIME_FORMAT, bsize, in_offset, GST_TIME_ARGS (in_timestamp));
-+
-+    ffmpegdec->pcache = gst_buffer_create_sub (inbuf,
-+        GST_BUFFER_SIZE (inbuf) - bsize, bsize);
-+    /* we keep timestamp, even though all we really know is that the correct
-+     * timestamp is not below the one from inbuf */
-+    GST_BUFFER_TIMESTAMP (ffmpegdec->pcache) = in_timestamp;
-+    GST_BUFFER_OFFSET (ffmpegdec->pcache) = in_offset;
-+  } else if (bsize > 0) {
-+    GST_DEBUG_OBJECT (ffmpegdec, "Dropping %d bytes of data", bsize);
-+  }
-+  gst_buffer_unref (inbuf);
-+
-+  return ret;
-+
-+  /* ERRORS */
-+not_negotiated:
-+  {
-+    oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
-+    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
-+        ("ffdec_%s: input format was not set before data start",
-+            oclass->in_plugin->name));
-+    gst_buffer_unref (inbuf);
-+    return GST_FLOW_NOT_NEGOTIATED;
-+  }
-+}
-+
-+static GstStateChangeReturn
-+gst_ffmpegdec_change_state (GstElement * element, GstStateChange transition)
-+{
-+  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) element;
-+  GstStateChangeReturn ret;
-+
-+  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
-+
-+  switch (transition) {
-+    case GST_STATE_CHANGE_PAUSED_TO_READY:
-+      GST_OBJECT_LOCK (ffmpegdec);
-+      gst_ffmpegdec_close (ffmpegdec);
-+      GST_OBJECT_UNLOCK (ffmpegdec);
-+      clear_queued (ffmpegdec);
-+      g_free (ffmpegdec->padded);
-+      ffmpegdec->padded = NULL;
-+      ffmpegdec->padded_size = 0;
-+      ffmpegdec->can_allocate_aligned = TRUE;
-+      break;
-+    default:
-+      break;
-+  }
-+
-+  return ret;
-+}
-+
-+static void
-+gst_ffmpegdec_set_property (GObject * object,
-+    guint prop_id, const GValue * value, GParamSpec * pspec)
-+{
-+  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
-+
-+  switch (prop_id) {
-+    case PROP_LOWRES:
-+      ffmpegdec->lowres = ffmpegdec->context->lowres = g_value_get_enum (value);
-+      break;
-+    case PROP_SKIPFRAME:
-+      ffmpegdec->skip_frame = ffmpegdec->context->skip_frame =
-+          g_value_get_enum (value);
-+      break;
-+    case PROP_DIRECT_RENDERING:
-+      ffmpegdec->direct_rendering = g_value_get_boolean (value);
-+      break;
-+    case PROP_DO_PADDING:
-+      ffmpegdec->do_padding = g_value_get_boolean (value);
-+      break;
-+    case PROP_DEBUG_MV:
-+      ffmpegdec->debug_mv = ffmpegdec->context->debug_mv =
-+          g_value_get_boolean (value);
-+      break;
-+    case PROP_CROP:
-+      ffmpegdec->crop = g_value_get_boolean (value);
-+      break;
-+    case PROP_MAX_THREADS:
-+      ffmpegdec->max_threads = g_value_get_int (value);
-+      break;
-+    default:
-+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-+      break;
-+  }
-+}
-+
-+static void
-+gst_ffmpegdec_get_property (GObject * object,
-+    guint prop_id, GValue * value, GParamSpec * pspec)
-+{
-+  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
-+
-+  switch (prop_id) {
-+    case PROP_LOWRES:
-+      g_value_set_enum (value, ffmpegdec->context->lowres);
-+      break;
-+    case PROP_SKIPFRAME:
-+      g_value_set_enum (value, ffmpegdec->context->skip_frame);
-+      break;
-+    case PROP_DIRECT_RENDERING:
-+      g_value_set_boolean (value, ffmpegdec->direct_rendering);
-+      break;
-+    case PROP_DO_PADDING:
-+      g_value_set_boolean (value, ffmpegdec->do_padding);
-+      break;
-+    case PROP_DEBUG_MV:
-+      g_value_set_boolean (value, ffmpegdec->context->debug_mv);
-+      break;
-+    case PROP_CROP:
-+      g_value_set_boolean (value, ffmpegdec->crop);
-+      break;
-+    case PROP_MAX_THREADS:
-+      g_value_set_int (value, ffmpegdec->max_threads);
-+      break;
-+    default:
-+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-+      break;
-+  }
-+}
-+
-+gboolean
-+gst_ffmpegdec_register (GstPlugin * plugin)
-+{
-+  GTypeInfo typeinfo = {
-+    sizeof (GstFFMpegDecClass),
-+    (GBaseInitFunc) gst_ffmpegdec_base_init,
-+    NULL,
-+    (GClassInitFunc) gst_ffmpegdec_class_init,
-+    NULL,
-+    NULL,
-+    sizeof (GstFFMpegDec),
-+    0,
-+    (GInstanceInitFunc) gst_ffmpegdec_init,
-+  };
-+  GType type;
-+  AVCodec *in_plugin;
-+  gint rank;
-+
-+  in_plugin = av_codec_next (NULL);
-+
-+  GST_LOG ("Registering decoders");
-+
-+  while (in_plugin) {
-+    gchar *type_name;
-+    gchar *plugin_name;
-+
-+    /* only decoders */
-+    if (!in_plugin->decode) {
-+      goto next;
-+    }
-+
-+    /* no quasi-codecs, please */
-+    if (in_plugin->id == CODEC_ID_RAWVIDEO ||
-+        in_plugin->id == CODEC_ID_V210 ||
-+        in_plugin->id == CODEC_ID_V210X ||
-+        in_plugin->id == CODEC_ID_R210 ||
-+        (in_plugin->id >= CODEC_ID_PCM_S16LE &&
-+            in_plugin->id <= CODEC_ID_PCM_BLURAY)) {
-+      goto next;
-+    }
-+
-+    /* No decoders depending on external libraries (we don't build them, but
-+     * people who build against an external ffmpeg might have them.
-+     * We have native gstreamer plugins for all of those libraries anyway. */
-+    if (!strncmp (in_plugin->name, "lib", 3)) {
-+      GST_DEBUG
-+          ("Not using external library decoder %s. Use the gstreamer-native ones instead.",
-+          in_plugin->name);
-+      goto next;
-+    }
-+
-+    /* No vdpau plugins until we can figure out how to properly use them
-+     * outside of ffmpeg. */
-+    if (g_str_has_suffix (in_plugin->name, "_vdpau")) {
-+      GST_DEBUG
-+          ("Ignoring VDPAU decoder %s. We can't handle this outside of ffmpeg",
-+          in_plugin->name);
-+      goto next;
-+    }
-+
-+    if (g_str_has_suffix (in_plugin->name, "_xvmc")) {
-+      GST_DEBUG
-+          ("Ignoring XVMC decoder %s. We can't handle this outside of ffmpeg",
-+          in_plugin->name);
-+      goto next;
-+    }
-+
-+    GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name);
-+
-+    /* no codecs for which we're GUARANTEED to have better alternatives */
-+    /* MPEG1VIDEO : the mpeg2video decoder is preferred */
-+    /* MP1 : Use MP3 for decoding */
-+    /* MP2 : Use MP3 for decoding */
-+    /* Theora: Use libtheora based theoradec */
-+    if (!strcmp (in_plugin->name, "gif") ||
-+        !strcmp (in_plugin->name, "vorbis") ||
-+        !strcmp (in_plugin->name, "theora") ||
-+        !strcmp (in_plugin->name, "mpeg1video") ||
-+        !strcmp (in_plugin->name, "wavpack") ||
-+        !strcmp (in_plugin->name, "mp1") ||
-+        !strcmp (in_plugin->name, "mp2") ||
-+        !strcmp (in_plugin->name, "libfaad") ||
-+        !strcmp (in_plugin->name, "mpeg4aac") ||
-+        !strcmp (in_plugin->name, "ass") ||
-+        !strcmp (in_plugin->name, "srt") ||
-+        !strcmp (in_plugin->name, "pgssub") ||
-+        !strcmp (in_plugin->name, "dvdsub") ||
-+        !strcmp (in_plugin->name, "dvbsub")) {
-+      GST_LOG ("Ignoring decoder %s", in_plugin->name);
-+      goto next;
-+    }
-+
-+    /* construct the type */
-+    plugin_name = g_strdup ((gchar *) in_plugin->name);
-+    g_strdelimit (plugin_name, NULL, '_');
-+    type_name = g_strdup_printf ("ffdec_%s", plugin_name);
-+    g_free (plugin_name);
-+
-+    type = g_type_from_name (type_name);
-+
-+    if (!type) {
-+      /* create the gtype now */
-+      type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
-+      g_type_set_qdata (type, GST_FFDEC_PARAMS_QDATA, (gpointer) in_plugin);
-+    }
-+
-+    /* (Ronald) MPEG-4 gets a higher priority because it has been well-
-+     * tested and by far outperforms divxdec/xviddec - so we prefer it.
-+     * msmpeg4v3 same, as it outperforms divxdec for divx3 playback.
-+     * VC1/WMV3 are not working and thus unpreferred for now. */
-+    switch (in_plugin->id) {
-+      case CODEC_ID_MPEG4:
-+      case CODEC_ID_MSMPEG4V3:
-+      case CODEC_ID_H264:
-+      case CODEC_ID_RA_144:
-+      case CODEC_ID_RA_288:
-+      case CODEC_ID_RV10:
-+      case CODEC_ID_RV20:
-+      case CODEC_ID_RV30:
-+      case CODEC_ID_RV40:
-+      case CODEC_ID_COOK:
-+        rank = GST_RANK_SECONDARY;
-+        break;
-+        /* DVVIDEO: we have a good dv decoder, fast on both ppc as well as x86.
-+         * They say libdv's quality is better though. leave as secondary.
-+         * note: if you change this, see the code in gstdv.c in good/ext/dv.
-+         *
-+         * SIPR: decoder should have a higher rank than realaudiodec.
-+         */
-+      case CODEC_ID_DVVIDEO:
-+      case CODEC_ID_SIPR:
-+        rank = GST_RANK_SECONDARY;
-+        break;
-+      case CODEC_ID_MP3:
-+        rank = GST_RANK_NONE;
-+        break;
-+        /* TEMPORARILY DISABLING AC3/EAC3/DTS for 0.10.12 release
-+         * due to downmixing failure.
-+         * See Bug #608892 for more details */
-+      case CODEC_ID_EAC3:
-+      case CODEC_ID_AC3:
-+      case CODEC_ID_DTS:
-+        rank = GST_RANK_NONE;
-+        break;
-+      default:
-+        rank = GST_RANK_MARGINAL;
-+        break;
-+    }
-+    if (!gst_element_register (plugin, type_name, rank, type)) {
-+      g_warning ("Failed to register %s", type_name);
-+      g_free (type_name);
-+      return FALSE;
-+    }
-+
-+    g_free (type_name);
-+
-+  next:
-+    in_plugin = av_codec_next (in_plugin);
-+  }
-+
-+  GST_LOG ("Finished Registering decoders");
-+
-+  return TRUE;
-+}
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.rej gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.rej
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.rej	1970-01-01 01:00:00.000000000 +0100
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.rej	2014-08-08 15:26:38.471858652 +0200
-@@ -0,0 +1,11 @@
-+--- ext/ffmpeg/gstffmpegdec.c
-++++ ext/ffmpeg/gstffmpegdec.c
-+@@ -1565,7 +1564,7 @@
-+         gst_message_new_latency (GST_OBJECT_CAST (ffmpegdec)));
-+   }
-+ 
-+-  is_itype = (ffmpegdec->picture->pict_type == FF_I_TYPE);
-++  is_itype = (ffmpegdec->picture->pict_type == AV_PICTURE_TYPE_I);
-+   is_reference = (ffmpegdec->picture->reference == 1);
-+ 
-+   iskeyframe = (is_itype || is_reference || ffmpegdec->picture->key_frame)
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdemux.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdemux.c
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdemux.c	2011-07-13 11:07:28.000000000 +0200
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdemux.c	2014-08-08 15:26:07.874857555 +0200
-@@ -343,8 +343,11 @@
-   demux->audiopads = 0;
- 
-   /* close demuxer context from ffmpeg */
--  av_close_input_file (demux->context);
--  demux->context = NULL;
-+  if (demux->seekable)
-+    gst_ffmpegdata_close (demux->context->pb);
-+  else
-+    gst_ffmpeg_pipe_close (demux->context->pb);
-+  avformat_close_input (&demux->context);
- 
-   GST_OBJECT_LOCK (demux);
-   demux->opened = FALSE;
-@@ -1146,9 +1149,9 @@
- static gboolean
- gst_ffmpegdemux_open (GstFFMpegDemux * demux)
- {
-+  AVIOContext *iocontext = NULL;
-   GstFFMpegDemuxClass *oclass =
-       (GstFFMpegDemuxClass *) G_OBJECT_GET_CLASS (demux);
--  gchar *location;
-   gint res, n_streams, i;
- #if 0
-   /* Re-enable once converted to new AVMetaData API
-@@ -1164,15 +1167,14 @@
- 
-   /* open via our input protocol hack */
-   if (demux->seekable)
--    location = g_strdup_printf ("gstreamer://%p", demux->sinkpad);
-+    res = gst_ffmpegdata_open (demux->sinkpad, AVIO_FLAG_READ, &iocontext);
-   else
--    location = g_strdup_printf ("gstpipe://%p", &demux->ffpipe);
--  GST_DEBUG_OBJECT (demux, "about to call av_open_input_file %s", location);
-+    res = gst_ffmpeg_pipe_open (&demux->ffpipe, AVIO_FLAG_READ, &iocontext);
- 
--  res = av_open_input_file (&demux->context, location,
--      oclass->in_plugin, 0, NULL);
-+  demux->context = avformat_alloc_context ();
-+  demux->context->pb = iocontext;
-+  res = avformat_open_input (&demux->context, NULL, oclass->in_plugin, NULL);
- 
--  g_free (location);
-   GST_DEBUG_OBJECT (demux, "av_open_input returned %d", res);
-   if (res < 0)
-     goto open_failed;
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegenc.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegenc.c
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegenc.c	2011-10-31 11:14:03.000000000 +0100
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegenc.c	2014-08-08 15:32:18.608870847 +0200
-@@ -770,7 +770,7 @@
-   GST_OBJECT_UNLOCK (ffmpegenc);
- 
-   if (force_keyframe)
--    ffmpegenc->picture->pict_type = FF_I_TYPE;
-+    ffmpegenc->picture->pict_type = AV_PICTURE_TYPE_I;
- 
-   frame_size = gst_ffmpeg_avpicture_fill ((AVPicture *) ffmpegenc->picture,
-       GST_BUFFER_DATA (inbuf),
-@@ -1136,7 +1136,7 @@
-       const GstStructure *s;
-       s = gst_event_get_structure (event);
-       if (gst_structure_has_name (s, "GstForceKeyUnit")) {
--        ffmpegenc->picture->pict_type = FF_I_TYPE;
-+        ffmpegenc->picture->pict_type = AV_PICTURE_TYPE_I;
-       }
-       break;
-     }
-@@ -1339,7 +1339,7 @@
-     }
- 
-     /* only encoders */
--    if (!in_plugin->encode) {
-+    if (!av_codec_is_encoder (in_plugin)) {
-       goto next;
-     }
- 
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c	2011-07-13 11:07:28.000000000 +0200
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c	2014-08-08 15:26:07.874857555 +0200
-@@ -24,8 +24,10 @@
- #include <string.h>
- #ifdef HAVE_FFMPEG_UNINSTALLED
- #include <avformat.h>
-+#include <opt.h>
- #else
- #include <libavformat/avformat.h>
-+#include <libavutil/opt.h>
- #endif
- 
- #include <gst/gst.h>
-@@ -336,9 +338,6 @@
-   ffmpegmux->context = g_new0 (AVFormatContext, 1);
-   ffmpegmux->context->oformat = oclass->in_plugin;
-   ffmpegmux->context->nb_streams = 0;
--  g_snprintf (ffmpegmux->context->filename,
--      sizeof (ffmpegmux->context->filename),
--      "gstreamer://%p", ffmpegmux->srcpad);
-   ffmpegmux->opened = FALSE;
- 
-   ffmpegmux->videopads = 0;
-@@ -450,10 +449,10 @@
-   gst_element_add_pad (element, pad);
- 
-   /* AVStream needs to be created */
--  st = av_new_stream (ffmpegmux->context, collect_pad->padnum);
-+  st = avformat_new_stream (ffmpegmux->context, NULL);
-+  st->id = collect_pad->padnum;
-   st->codec->codec_type = type;
-   st->codec->codec_id = CODEC_ID_NONE;  /* this is a check afterwards */
--  st->stream_copy = 1;          /* we're not the actual encoder */
-   st->codec->bit_rate = bitrate;
-   st->codec->frame_size = framesize;
-   /* we fill in codec during capsnego */
-@@ -485,7 +484,7 @@
-   collect_pad = (GstFFMpegMuxPad *) gst_pad_get_element_private (pad);
- 
-   st = ffmpegmux->context->streams[collect_pad->padnum];
--  ffmpegmux->context->preload = ffmpegmux->preload;
-+  av_opt_set_int (&ffmpegmux->context, "preload", ffmpegmux->preload, 0);
-   ffmpegmux->context->max_delay = ffmpegmux->max_delay;
- 
-   /* for the format-specific guesses, we'll go to
-@@ -552,7 +551,7 @@
- 
-   /* open "file" (gstreamer protocol to next element) */
-   if (!ffmpegmux->opened) {
--    int open_flags = URL_WRONLY;
-+    int open_flags = AVIO_FLAG_WRITE;
- 
-     /* we do need all streams to have started capsnego,
-      * or things will go horribly wrong */
-@@ -646,19 +645,13 @@
-       open_flags |= GST_FFMPEG_URL_STREAMHEADER;
-     }
- 
--    if (url_fopen (&ffmpegmux->context->pb,
--            ffmpegmux->context->filename, open_flags) < 0) {
-+    if (gst_ffmpegdata_open (ffmpegmux->srcpad, open_flags,
-+            &ffmpegmux->context->pb) < 0) {
-       GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, TOO_LAZY, (NULL),
-           ("Failed to open stream context in ffmux"));
-       return GST_FLOW_ERROR;
-     }
- 
--    if (av_set_parameters (ffmpegmux->context, NULL) < 0) {
--      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, INIT, (NULL),
--          ("Failed to initialize muxer"));
--      return GST_FLOW_ERROR;
--    }
--
-     /* now open the mux format */
-     if (av_write_header (ffmpegmux->context) < 0) {
-       GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, SETTINGS, (NULL),
-@@ -670,7 +663,7 @@
-     ffmpegmux->opened = TRUE;
- 
-     /* flush the header so it will be used as streamheader */
--    put_flush_packet (ffmpegmux->context->pb);
-+    avio_flush (ffmpegmux->context->pb);
-   }
- 
-   /* take the one with earliest timestamp,
-@@ -770,8 +763,8 @@
-     /* close down */
-     av_write_trailer (ffmpegmux->context);
-     ffmpegmux->opened = FALSE;
--    put_flush_packet (ffmpegmux->context->pb);
--    url_fclose (ffmpegmux->context->pb);
-+    avio_flush (ffmpegmux->context->pb);
-+    gst_ffmpegdata_close (ffmpegmux->context->pb);
-     gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_eos ());
-     return GST_FLOW_UNEXPECTED;
-   }
-@@ -795,6 +788,10 @@
-       break;
-     case GST_STATE_CHANGE_PAUSED_TO_READY:
-       gst_collect_pads_stop (ffmpegmux->collect);
-+      if (ffmpegmux->opened) {
-+        ffmpegmux->opened = FALSE;
-+        gst_ffmpegdata_close (ffmpegmux->context->pb);
-+      }
-       break;
-     default:
-       break;
-@@ -809,7 +806,7 @@
-       gst_tag_setter_reset_tags (GST_TAG_SETTER (ffmpegmux));
-       if (ffmpegmux->opened) {
-         ffmpegmux->opened = FALSE;
--        url_fclose (ffmpegmux->context->pb);
-+        avio_close (ffmpegmux->context->pb);
-       }
-       break;
-     case GST_STATE_CHANGE_READY_TO_NULL:
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c.orig
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c.orig	1970-01-01 01:00:00.000000000 +0100
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c.orig	2011-07-13 11:07:28.000000000 +0200
-@@ -0,0 +1,970 @@
-+/* 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>
-+#ifdef HAVE_FFMPEG_UNINSTALLED
-+#include <avformat.h>
-+#else
-+#include <libavformat/avformat.h>
-+#endif
-+
-+#include <gst/gst.h>
-+#include <gst/base/gstcollectpads.h>
-+
-+#include "gstffmpeg.h"
-+#include "gstffmpegcodecmap.h"
-+#include "gstffmpegutils.h"
-+
-+typedef struct _GstFFMpegMux GstFFMpegMux;
-+typedef struct _GstFFMpegMuxPad GstFFMpegMuxPad;
-+
-+struct _GstFFMpegMuxPad
-+{
-+  GstCollectData collect;       /* we extend the CollectData */
-+
-+  gint padnum;
-+};
-+
-+struct _GstFFMpegMux
-+{
-+  GstElement element;
-+
-+  GstCollectPads *collect;
-+  /* We need to keep track of our pads, so we do so here. */
-+  GstPad *srcpad;
-+
-+  AVFormatContext *context;
-+  gboolean opened;
-+
-+  gint videopads, audiopads;
-+
-+  /*< private > */
-+  /* event_function is the collectpads default eventfunction */
-+  GstPadEventFunction event_function;
-+  int preload;
-+  int max_delay;
-+};
-+
-+typedef struct _GstFFMpegMuxClass GstFFMpegMuxClass;
-+
-+struct _GstFFMpegMuxClass
-+{
-+  GstElementClass parent_class;
-+
-+  AVOutputFormat *in_plugin;
-+};
-+
-+#define GST_TYPE_FFMPEGMUX \
-+  (gst_ffmpegdec_get_type())
-+#define GST_FFMPEGMUX(obj) \
-+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGMUX,GstFFMpegMux))
-+#define GST_FFMPEGMUX_CLASS(klass) \
-+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGMUX,GstFFMpegMuxClass))
-+#define GST_IS_FFMPEGMUX(obj) \
-+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGMUX))
-+#define GST_IS_FFMPEGMUX_CLASS(klass) \
-+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGMUX))
-+
-+enum
-+{
-+  /* FILL ME */
-+  LAST_SIGNAL
-+};
-+
-+enum
-+{
-+  ARG_0,
-+  /* FILL ME */
-+};
-+
-+enum
-+{
-+  PROP_0,
-+  PROP_PRELOAD,
-+  PROP_MAXDELAY
-+};
-+
-+/* A number of function prototypes are given so we can refer to them later. */
-+static void gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass);
-+static void gst_ffmpegmux_base_init (gpointer g_class);
-+static void gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux,
-+    GstFFMpegMuxClass * g_class);
-+static void gst_ffmpegmux_finalize (GObject * object);
-+
-+static gboolean gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps);
-+static GstPad *gst_ffmpegmux_request_new_pad (GstElement * element,
-+    GstPadTemplate * templ, const gchar * name);
-+static GstFlowReturn gst_ffmpegmux_collected (GstCollectPads * pads,
-+    gpointer user_data);
-+
-+static gboolean gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event);
-+
-+static GstStateChangeReturn gst_ffmpegmux_change_state (GstElement * element,
-+    GstStateChange transition);
-+
-+static void gst_ffmpegmux_set_property (GObject * object, guint prop_id,
-+    const GValue * value, GParamSpec * pspec);
-+static void gst_ffmpegmux_get_property (GObject * object, guint prop_id,
-+    GValue * value, GParamSpec * pspec);
-+
-+static GstCaps *gst_ffmpegmux_get_id_caps (enum CodecID *id_list);
-+static void gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * caps,
-+    const gchar * field, guint num, const gint * values);
-+
-+#define GST_FFMUX_PARAMS_QDATA g_quark_from_static_string("ffmux-params")
-+
-+static GstElementClass *parent_class = NULL;
-+
-+/*static guint gst_ffmpegmux_signals[LAST_SIGNAL] = { 0 }; */
-+
-+typedef struct
-+{
-+  const char *name;
-+  const char *replacement;
-+} GstFFMpegMuxReplacement;
-+
-+static const char *
-+gst_ffmpegmux_get_replacement (const char *name)
-+{
-+  static const GstFFMpegMuxReplacement blacklist[] = {
-+    {"avi", "avimux"},
-+    {"matroska", "matroskamux"},
-+    {"mov", "qtmux"},
-+    {"mpegts", "mpegtsmux"},
-+    {"mp4", "mp4mux"},
-+    {"mpjpeg", "multipartmux"},
-+    {"ogg", "oggmux"},
-+    {"wav", "wavenc"},
-+    {"webm", "webmmux"},
-+    {"mxf", "mxfmux"},
-+    {"3gp", "gppmux"},
-+    {"yuv4mpegpipe", "y4menc"},
-+    {"aiff", "aiffmux"},
-+    {"adts", "aacparse"},
-+    {"asf", "asfmux"},
-+    {"asf_stream", "asfmux"},
-+    {"flv", "flvmux"},
-+    {"mp3", "id3v2mux"},
-+    {"mp2", "id3v2mux"}
-+  };
-+  int i;
-+
-+  for (i = 0; i < sizeof (blacklist) / sizeof (blacklist[0]); i++) {
-+    if (strcmp (blacklist[i].name, name) == 0) {
-+      return blacklist[i].replacement;
-+    }
-+  }
-+
-+  return NULL;
-+}
-+
-+static gboolean
-+gst_ffmpegmux_is_formatter (const char *name)
-+{
-+  static const char *replace[] = {
-+    "mp2", "mp3", NULL
-+  };
-+  int i;
-+
-+  for (i = 0; replace[i]; i++)
-+    if (strcmp (replace[i], name) == 0)
-+      return TRUE;
-+  return FALSE;
-+}
-+
-+static void
-+gst_ffmpegmux_base_init (gpointer g_class)
-+{
-+  GstFFMpegMuxClass *klass = (GstFFMpegMuxClass *) g_class;
-+  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-+  GstPadTemplate *videosinktempl, *audiosinktempl, *srctempl;
-+  AVOutputFormat *in_plugin;
-+  GstCaps *srccaps, *audiosinkcaps, *videosinkcaps;
-+  enum CodecID *video_ids = NULL, *audio_ids = NULL;
-+  gchar *longname, *description;
-+  const char *replacement;
-+  gboolean is_formatter;
-+
-+  in_plugin =
-+      (AVOutputFormat *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
-+      GST_FFMUX_PARAMS_QDATA);
-+  g_assert (in_plugin != NULL);
-+
-+  /* construct the element details struct */
-+  replacement = gst_ffmpegmux_get_replacement (in_plugin->name);
-+  is_formatter = gst_ffmpegmux_is_formatter (in_plugin->name);
-+  if (replacement != NULL) {
-+    longname =
-+        g_strdup_printf ("FFmpeg %s %s (not recommended, use %s instead)",
-+        in_plugin->long_name, is_formatter ? "formatter" : "muxer",
-+        replacement);
-+    description =
-+        g_strdup_printf ("FFmpeg %s %s (not recommended, use %s instead)",
-+        in_plugin->long_name, is_formatter ? "formatter" : "muxer",
-+        replacement);
-+  } else {
-+    longname = g_strdup_printf ("FFmpeg %s %s", in_plugin->long_name,
-+        is_formatter ? "formatter" : "muxer");
-+    description = g_strdup_printf ("FFmpeg %s %s", in_plugin->long_name,
-+        is_formatter ? "formatter" : "muxer");
-+  }
-+  gst_element_class_set_details_simple (element_class, longname,
-+      is_formatter ? "Formatter/Metadata" : "Codec/Muxer", description,
-+      "Wim Taymans <wim.taymans@chello.be>, "
-+      "Ronald Bultje <rbultje@ronald.bitfreak.net>");
-+  g_free (longname);
-+  g_free (description);
-+
-+  /* Try to find the caps that belongs here */
-+  srccaps = gst_ffmpeg_formatid_to_caps (in_plugin->name);
-+  if (!srccaps) {
-+    GST_DEBUG ("Couldn't get source caps for muxer '%s', skipping format",
-+        in_plugin->name);
-+    goto beach;
-+  }
-+
-+  if (!gst_ffmpeg_formatid_get_codecids (in_plugin->name,
-+          &video_ids, &audio_ids, in_plugin)) {
-+    gst_caps_unref (srccaps);
-+    GST_DEBUG
-+        ("Couldn't get sink caps for muxer '%s'. Most likely because no input format mapping exists.",
-+        in_plugin->name);
-+    goto beach;
-+  }
-+
-+  videosinkcaps = video_ids ? gst_ffmpegmux_get_id_caps (video_ids) : NULL;
-+  audiosinkcaps = audio_ids ? gst_ffmpegmux_get_id_caps (audio_ids) : NULL;
-+
-+  /* fix up allowed caps for some muxers */
-+  /* FIXME : This should be in gstffmpegcodecmap.c ! */
-+  if (strcmp (in_plugin->name, "flv") == 0) {
-+    const gint rates[] = { 44100, 22050, 11025 };
-+
-+    gst_ffmpeg_mux_simple_caps_set_int_list (audiosinkcaps, "rate", 3, rates);
-+  } else if (strcmp (in_plugin->name, "gif") == 0) {
-+    if (videosinkcaps)
-+      gst_caps_unref (videosinkcaps);
-+
-+    videosinkcaps =
-+        gst_caps_from_string ("video/x-raw-rgb, bpp=(int)24, depth=(int)24");
-+  }
-+
-+  /* pad templates */
-+  srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
-+  gst_element_class_add_pad_template (element_class, srctempl);
-+
-+  if (audiosinkcaps) {
-+    audiosinktempl = gst_pad_template_new ("audio_%d",
-+        GST_PAD_SINK, GST_PAD_REQUEST, audiosinkcaps);
-+    gst_element_class_add_pad_template (element_class, audiosinktempl);
-+  }
-+
-+  if (videosinkcaps) {
-+    videosinktempl = gst_pad_template_new ("video_%d",
-+        GST_PAD_SINK, GST_PAD_REQUEST, videosinkcaps);
-+    gst_element_class_add_pad_template (element_class, videosinktempl);
-+  }
-+
-+beach:
-+  klass->in_plugin = in_plugin;
-+}
-+
-+static void
-+gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass)
-+{
-+  GObjectClass *gobject_class;
-+  GstElementClass *gstelement_class;
-+
-+  gobject_class = (GObjectClass *) klass;
-+  gstelement_class = (GstElementClass *) klass;
-+
-+  parent_class = g_type_class_peek_parent (klass);
-+
-+  gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_ffmpegmux_set_property);
-+  gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_ffmpegmux_get_property);
-+
-+  g_object_class_install_property (gobject_class, PROP_PRELOAD,
-+      g_param_spec_int ("preload", "preload",
-+          "Set the initial demux-decode delay (in microseconds)", 0, G_MAXINT,
-+          0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-+
-+  g_object_class_install_property (gobject_class, PROP_MAXDELAY,
-+      g_param_spec_int ("maxdelay", "maxdelay",
-+          "Set the maximum demux-decode delay (in microseconds)", 0, G_MAXINT,
-+          0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-+
-+  gstelement_class->request_new_pad = gst_ffmpegmux_request_new_pad;
-+  gstelement_class->change_state = gst_ffmpegmux_change_state;
-+  gobject_class->finalize = gst_ffmpegmux_finalize;
-+}
-+
-+static void
-+gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux, GstFFMpegMuxClass * g_class)
-+{
-+  GstElementClass *klass = GST_ELEMENT_CLASS (g_class);
-+  GstFFMpegMuxClass *oclass = (GstFFMpegMuxClass *) klass;
-+  GstPadTemplate *templ = gst_element_class_get_pad_template (klass, "src");
-+
-+  ffmpegmux->srcpad = gst_pad_new_from_template (templ, "src");
-+  gst_pad_set_caps (ffmpegmux->srcpad, gst_pad_template_get_caps (templ));
-+  gst_element_add_pad (GST_ELEMENT (ffmpegmux), ffmpegmux->srcpad);
-+
-+  ffmpegmux->collect = gst_collect_pads_new ();
-+  gst_collect_pads_set_function (ffmpegmux->collect,
-+      (GstCollectPadsFunction) gst_ffmpegmux_collected, ffmpegmux);
-+
-+  ffmpegmux->context = g_new0 (AVFormatContext, 1);
-+  ffmpegmux->context->oformat = oclass->in_plugin;
-+  ffmpegmux->context->nb_streams = 0;
-+  g_snprintf (ffmpegmux->context->filename,
-+      sizeof (ffmpegmux->context->filename),
-+      "gstreamer://%p", ffmpegmux->srcpad);
-+  ffmpegmux->opened = FALSE;
-+
-+  ffmpegmux->videopads = 0;
-+  ffmpegmux->audiopads = 0;
-+  ffmpegmux->preload = 0;
-+  ffmpegmux->max_delay = 0;
-+}
-+
-+static void
-+gst_ffmpegmux_set_property (GObject * object, guint prop_id,
-+    const GValue * value, GParamSpec * pspec)
-+{
-+  GstFFMpegMux *src;
-+
-+  src = (GstFFMpegMux *) object;
-+
-+  switch (prop_id) {
-+    case PROP_PRELOAD:
-+      src->preload = g_value_get_int (value);
-+      break;
-+    case PROP_MAXDELAY:
-+      src->max_delay = g_value_get_int (value);
-+      break;
-+    default:
-+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-+      break;
-+  }
-+}
-+
-+static void
-+gst_ffmpegmux_get_property (GObject * object, guint prop_id, GValue * value,
-+    GParamSpec * pspec)
-+{
-+  GstFFMpegMux *src;
-+
-+  src = (GstFFMpegMux *) object;
-+
-+  switch (prop_id) {
-+    case PROP_PRELOAD:
-+      g_value_set_int (value, src->preload);
-+      break;
-+    case PROP_MAXDELAY:
-+      g_value_set_int (value, src->max_delay);
-+      break;
-+    default:
-+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-+      break;
-+  }
-+}
-+
-+
-+static void
-+gst_ffmpegmux_finalize (GObject * object)
-+{
-+  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) object;
-+
-+  g_free (ffmpegmux->context);
-+  gst_object_unref (ffmpegmux->collect);
-+
-+  if (G_OBJECT_CLASS (parent_class)->finalize)
-+    G_OBJECT_CLASS (parent_class)->finalize (object);
-+}
-+
-+static GstPad *
-+gst_ffmpegmux_request_new_pad (GstElement * element,
-+    GstPadTemplate * templ, const gchar * name)
-+{
-+  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) element;
-+  GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
-+  GstFFMpegMuxPad *collect_pad;
-+  gchar *padname;
-+  GstPad *pad;
-+  AVStream *st;
-+  enum AVMediaType type;
-+  gint bitrate = 0, framesize = 0;
-+
-+  g_return_val_if_fail (templ != NULL, NULL);
-+  g_return_val_if_fail (templ->direction == GST_PAD_SINK, NULL);
-+  g_return_val_if_fail (ffmpegmux->opened == FALSE, NULL);
-+
-+  /* figure out a name that *we* like */
-+  if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
-+    padname = g_strdup_printf ("video_%d", ffmpegmux->videopads++);
-+    type = AVMEDIA_TYPE_VIDEO;
-+    bitrate = 64 * 1024;
-+    framesize = 1152;
-+  } else if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
-+    padname = g_strdup_printf ("audio_%d", ffmpegmux->audiopads++);
-+    type = AVMEDIA_TYPE_AUDIO;
-+    bitrate = 285 * 1024;
-+  } else {
-+    g_warning ("ffmux: unknown pad template!");
-+    return NULL;
-+  }
-+
-+  /* create pad */
-+  pad = gst_pad_new_from_template (templ, padname);
-+  collect_pad = (GstFFMpegMuxPad *)
-+      gst_collect_pads_add_pad (ffmpegmux->collect, pad,
-+      sizeof (GstFFMpegMuxPad));
-+  collect_pad->padnum = ffmpegmux->context->nb_streams;
-+
-+  /* small hack to put our own event pad function and chain up to collect pad */
-+  ffmpegmux->event_function = GST_PAD_EVENTFUNC (pad);
-+  gst_pad_set_event_function (pad,
-+      GST_DEBUG_FUNCPTR (gst_ffmpegmux_sink_event));
-+
-+  gst_pad_set_setcaps_function (pad, GST_DEBUG_FUNCPTR (gst_ffmpegmux_setcaps));
-+  gst_element_add_pad (element, pad);
-+
-+  /* AVStream needs to be created */
-+  st = av_new_stream (ffmpegmux->context, collect_pad->padnum);
-+  st->codec->codec_type = type;
-+  st->codec->codec_id = CODEC_ID_NONE;  /* this is a check afterwards */
-+  st->stream_copy = 1;          /* we're not the actual encoder */
-+  st->codec->bit_rate = bitrate;
-+  st->codec->frame_size = framesize;
-+  /* we fill in codec during capsnego */
-+
-+  /* we love debug output (c) (tm) (r) */
-+  GST_DEBUG ("Created %s pad for ffmux_%s element",
-+      padname, ((GstFFMpegMuxClass *) klass)->in_plugin->name);
-+  g_free (padname);
-+
-+  return pad;
-+}
-+
-+/**
-+ * gst_ffmpegmux_setcaps
-+ * @pad: #GstPad
-+ * @caps: New caps.
-+ *
-+ * Set caps to pad.
-+ *
-+ * Returns: #TRUE on success.
-+ */
-+static gboolean
-+gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps)
-+{
-+  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (gst_pad_get_parent (pad));
-+  GstFFMpegMuxPad *collect_pad;
-+  AVStream *st;
-+
-+  collect_pad = (GstFFMpegMuxPad *) gst_pad_get_element_private (pad);
-+
-+  st = ffmpegmux->context->streams[collect_pad->padnum];
-+  ffmpegmux->context->preload = ffmpegmux->preload;
-+  ffmpegmux->context->max_delay = ffmpegmux->max_delay;
-+
-+  /* for the format-specific guesses, we'll go to
-+   * our famous codec mapper */
-+  if (gst_ffmpeg_caps_to_codecid (caps, st->codec) == CODEC_ID_NONE)
-+    goto not_accepted;
-+
-+  /* copy over the aspect ratios, ffmpeg expects the stream aspect to match the
-+   * codec aspect. */
-+  st->sample_aspect_ratio = st->codec->sample_aspect_ratio;
-+
-+  GST_LOG_OBJECT (pad, "accepted caps %" GST_PTR_FORMAT, caps);
-+  return TRUE;
-+
-+  /* ERRORS */
-+not_accepted:
-+  {
-+    GST_LOG_OBJECT (pad, "rejecting caps %" GST_PTR_FORMAT, caps);
-+    return FALSE;
-+  }
-+}
-+
-+
-+static gboolean
-+gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event)
-+{
-+  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) gst_pad_get_parent (pad);
-+  gboolean res = TRUE;
-+
-+  switch (GST_EVENT_TYPE (event)) {
-+    case GST_EVENT_TAG:{
-+      GstTagList *taglist;
-+      GstTagSetter *setter = GST_TAG_SETTER (ffmpegmux);
-+      const GstTagMergeMode mode = gst_tag_setter_get_tag_merge_mode (setter);
-+
-+      gst_event_parse_tag (event, &taglist);
-+      gst_tag_setter_merge_tags (setter, taglist, mode);
-+      break;
-+    }
-+    default:
-+      break;
-+  }
-+
-+  /* chaining up to collectpads default event function */
-+  res = ffmpegmux->event_function (pad, event);
-+
-+  gst_object_unref (ffmpegmux);
-+  return res;
-+}
-+
-+static GstFlowReturn
-+gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
-+{
-+  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) user_data;
-+  GSList *collected;
-+  GstFFMpegMuxPad *best_pad;
-+  GstClockTime best_time;
-+#if 0
-+  /* Re-enable once converted to new AVMetaData API
-+   * See #566605
-+   */
-+  const GstTagList *tags;
-+#endif
-+
-+  /* open "file" (gstreamer protocol to next element) */
-+  if (!ffmpegmux->opened) {
-+    int open_flags = URL_WRONLY;
-+
-+    /* we do need all streams to have started capsnego,
-+     * or things will go horribly wrong */
-+    for (collected = ffmpegmux->collect->data; collected;
-+        collected = g_slist_next (collected)) {
-+      GstFFMpegMuxPad *collect_pad = (GstFFMpegMuxPad *) collected->data;
-+      AVStream *st = ffmpegmux->context->streams[collect_pad->padnum];
-+
-+      /* check whether the pad has successfully completed capsnego */
-+      if (st->codec->codec_id == CODEC_ID_NONE) {
-+        GST_ELEMENT_ERROR (ffmpegmux, CORE, NEGOTIATION, (NULL),
-+            ("no caps set on stream %d (%s)", collect_pad->padnum,
-+                (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ?
-+                "video" : "audio"));
-+        return GST_FLOW_ERROR;
-+      }
-+      /* set framerate for audio */
-+      if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
-+        switch (st->codec->codec_id) {
-+          case CODEC_ID_PCM_S16LE:
-+          case CODEC_ID_PCM_S16BE:
-+          case CODEC_ID_PCM_U16LE:
-+          case CODEC_ID_PCM_U16BE:
-+          case CODEC_ID_PCM_S8:
-+          case CODEC_ID_PCM_U8:
-+            st->codec->frame_size = 1;
-+            break;
-+          default:
-+          {
-+            GstBuffer *buffer;
-+
-+            /* FIXME : This doesn't work for RAW AUDIO...
-+             * in fact I'm wondering if it even works for any kind of audio... */
-+            buffer = gst_collect_pads_peek (ffmpegmux->collect,
-+                (GstCollectData *) collect_pad);
-+            if (buffer) {
-+              st->codec->frame_size =
-+                  st->codec->sample_rate *
-+                  GST_BUFFER_DURATION (buffer) / GST_SECOND;
-+              gst_buffer_unref (buffer);
-+            }
-+          }
-+        }
-+      }
-+    }
-+
-+#if 0
-+    /* Re-enable once converted to new AVMetaData API
-+     * See #566605
-+     */
-+
-+    /* tags */
-+    tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (ffmpegmux));
-+    if (tags) {
-+      gint i;
-+      gchar *s;
-+
-+      /* get the interesting ones */
-+      if (gst_tag_list_get_string (tags, GST_TAG_TITLE, &s)) {
-+        strncpy (ffmpegmux->context->title, s,
-+            sizeof (ffmpegmux->context->title));
-+      }
-+      if (gst_tag_list_get_string (tags, GST_TAG_ARTIST, &s)) {
-+        strncpy (ffmpegmux->context->author, s,
-+            sizeof (ffmpegmux->context->author));
-+      }
-+      if (gst_tag_list_get_string (tags, GST_TAG_COPYRIGHT, &s)) {
-+        strncpy (ffmpegmux->context->copyright, s,
-+            sizeof (ffmpegmux->context->copyright));
-+      }
-+      if (gst_tag_list_get_string (tags, GST_TAG_COMMENT, &s)) {
-+        strncpy (ffmpegmux->context->comment, s,
-+            sizeof (ffmpegmux->context->comment));
-+      }
-+      if (gst_tag_list_get_string (tags, GST_TAG_ALBUM, &s)) {
-+        strncpy (ffmpegmux->context->album, s,
-+            sizeof (ffmpegmux->context->album));
-+      }
-+      if (gst_tag_list_get_string (tags, GST_TAG_GENRE, &s)) {
-+        strncpy (ffmpegmux->context->genre, s,
-+            sizeof (ffmpegmux->context->genre));
-+      }
-+      if (gst_tag_list_get_int (tags, GST_TAG_TRACK_NUMBER, &i)) {
-+        ffmpegmux->context->track = i;
-+      }
-+    }
-+#endif
-+
-+    /* set the streamheader flag for gstffmpegprotocol if codec supports it */
-+    if (!strcmp (ffmpegmux->context->oformat->name, "flv")) {
-+      open_flags |= GST_FFMPEG_URL_STREAMHEADER;
-+    }
-+
-+    if (url_fopen (&ffmpegmux->context->pb,
-+            ffmpegmux->context->filename, open_flags) < 0) {
-+      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, TOO_LAZY, (NULL),
-+          ("Failed to open stream context in ffmux"));
-+      return GST_FLOW_ERROR;
-+    }
-+
-+    if (av_set_parameters (ffmpegmux->context, NULL) < 0) {
-+      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, INIT, (NULL),
-+          ("Failed to initialize muxer"));
-+      return GST_FLOW_ERROR;
-+    }
-+
-+    /* now open the mux format */
-+    if (av_write_header (ffmpegmux->context) < 0) {
-+      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, SETTINGS, (NULL),
-+          ("Failed to write file header - check codec settings"));
-+      return GST_FLOW_ERROR;
-+    }
-+
-+    /* we're now opened */
-+    ffmpegmux->opened = TRUE;
-+
-+    /* flush the header so it will be used as streamheader */
-+    put_flush_packet (ffmpegmux->context->pb);
-+  }
-+
-+  /* take the one with earliest timestamp,
-+   * and push it forward */
-+  best_pad = NULL;
-+  best_time = GST_CLOCK_TIME_NONE;
-+  for (collected = ffmpegmux->collect->data; collected;
-+      collected = g_slist_next (collected)) {
-+    GstFFMpegMuxPad *collect_pad = (GstFFMpegMuxPad *) collected->data;
-+    GstBuffer *buffer = gst_collect_pads_peek (ffmpegmux->collect,
-+        (GstCollectData *) collect_pad);
-+
-+    /* if there's no buffer, just continue */
-+    if (buffer == NULL) {
-+      continue;
-+    }
-+
-+    /* if we have no buffer yet, just use the first one */
-+    if (best_pad == NULL) {
-+      best_pad = collect_pad;
-+      best_time = GST_BUFFER_TIMESTAMP (buffer);
-+      goto next_pad;
-+    }
-+
-+    /* if we do have one, only use this one if it's older */
-+    if (GST_BUFFER_TIMESTAMP (buffer) < best_time) {
-+      best_time = GST_BUFFER_TIMESTAMP (buffer);
-+      best_pad = collect_pad;
-+    }
-+
-+  next_pad:
-+    gst_buffer_unref (buffer);
-+
-+    /* Mux buffers with invalid timestamp first */
-+    if (!GST_CLOCK_TIME_IS_VALID (best_time))
-+      break;
-+  }
-+
-+  /* now handle the buffer, or signal EOS if we have
-+   * no buffers left */
-+  if (best_pad != NULL) {
-+    GstBuffer *buf;
-+    AVPacket pkt;
-+    gboolean need_free = FALSE;
-+
-+    /* push out current buffer */
-+    buf = gst_collect_pads_pop (ffmpegmux->collect,
-+        (GstCollectData *) best_pad);
-+
-+    ffmpegmux->context->streams[best_pad->padnum]->codec->frame_number++;
-+
-+    /* set time */
-+    pkt.pts = gst_ffmpeg_time_gst_to_ff (GST_BUFFER_TIMESTAMP (buf),
-+        ffmpegmux->context->streams[best_pad->padnum]->time_base);
-+    pkt.dts = pkt.pts;
-+
-+    if (strcmp (ffmpegmux->context->oformat->name, "gif") == 0) {
-+      AVStream *st = ffmpegmux->context->streams[best_pad->padnum];
-+      AVPicture src, dst;
-+
-+      need_free = TRUE;
-+      pkt.size = st->codec->width * st->codec->height * 3;
-+      pkt.data = g_malloc (pkt.size);
-+
-+      dst.data[0] = pkt.data;
-+      dst.data[1] = NULL;
-+      dst.data[2] = NULL;
-+      dst.linesize[0] = st->codec->width * 3;
-+
-+      gst_ffmpeg_avpicture_fill (&src, GST_BUFFER_DATA (buf),
-+          PIX_FMT_RGB24, st->codec->width, st->codec->height);
-+
-+      av_picture_copy (&dst, &src, PIX_FMT_RGB24,
-+          st->codec->width, st->codec->height);
-+    } else {
-+      pkt.data = GST_BUFFER_DATA (buf);
-+      pkt.size = GST_BUFFER_SIZE (buf);
-+    }
-+
-+    pkt.stream_index = best_pad->padnum;
-+    pkt.flags = 0;
-+
-+    if (!GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT))
-+      pkt.flags |= AV_PKT_FLAG_KEY;
-+
-+    if (GST_BUFFER_DURATION_IS_VALID (buf))
-+      pkt.duration =
-+          gst_ffmpeg_time_gst_to_ff (GST_BUFFER_DURATION (buf),
-+          ffmpegmux->context->streams[best_pad->padnum]->time_base);
-+    else
-+      pkt.duration = 0;
-+    av_write_frame (ffmpegmux->context, &pkt);
-+    gst_buffer_unref (buf);
-+    if (need_free)
-+      g_free (pkt.data);
-+  } else {
-+    /* close down */
-+    av_write_trailer (ffmpegmux->context);
-+    ffmpegmux->opened = FALSE;
-+    put_flush_packet (ffmpegmux->context->pb);
-+    url_fclose (ffmpegmux->context->pb);
-+    gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_eos ());
-+    return GST_FLOW_UNEXPECTED;
-+  }
-+
-+  return GST_FLOW_OK;
-+}
-+
-+static GstStateChangeReturn
-+gst_ffmpegmux_change_state (GstElement * element, GstStateChange transition)
-+{
-+  GstFlowReturn ret;
-+  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (element);
-+
-+  switch (transition) {
-+    case GST_STATE_CHANGE_NULL_TO_READY:
-+      break;
-+    case GST_STATE_CHANGE_READY_TO_PAUSED:
-+      gst_collect_pads_start (ffmpegmux->collect);
-+      break;
-+    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
-+      break;
-+    case GST_STATE_CHANGE_PAUSED_TO_READY:
-+      gst_collect_pads_stop (ffmpegmux->collect);
-+      break;
-+    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_tag_setter_reset_tags (GST_TAG_SETTER (ffmpegmux));
-+      if (ffmpegmux->opened) {
-+        ffmpegmux->opened = FALSE;
-+        url_fclose (ffmpegmux->context->pb);
-+      }
-+      break;
-+    case GST_STATE_CHANGE_READY_TO_NULL:
-+      break;
-+    default:
-+      break;
-+  }
-+
-+  return ret;
-+}
-+
-+static GstCaps *
-+gst_ffmpegmux_get_id_caps (enum CodecID *id_list)
-+{
-+  GstCaps *caps, *t;
-+  gint i;
-+
-+  caps = gst_caps_new_empty ();
-+  for (i = 0; id_list[i] != CODEC_ID_NONE; i++) {
-+    if ((t = gst_ffmpeg_codecid_to_caps (id_list[i], NULL, TRUE)))
-+      gst_caps_append (caps, t);
-+  }
-+  if (gst_caps_is_empty (caps)) {
-+    gst_caps_unref (caps);
-+    return NULL;
-+  }
-+
-+  return caps;
-+}
-+
-+/* set a list of integer values on the caps, e.g. for sample rates */
-+static void
-+gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * caps, const gchar * field,
-+    guint num, const gint * values)
-+{
-+  GValue list = { 0, };
-+  GValue val = { 0, };
-+  gint i;
-+
-+  g_return_if_fail (GST_CAPS_IS_SIMPLE (caps));
-+
-+  g_value_init (&list, GST_TYPE_LIST);
-+  g_value_init (&val, G_TYPE_INT);
-+
-+  for (i = 0; i < num; ++i) {
-+    g_value_set_int (&val, values[i]);
-+    gst_value_list_append_value (&list, &val);
-+  }
-+
-+  gst_structure_set_value (gst_caps_get_structure (caps, 0), field, &list);
-+
-+  g_value_unset (&val);
-+  g_value_unset (&list);
-+}
-+
-+gboolean
-+gst_ffmpegmux_register (GstPlugin * plugin)
-+{
-+  GTypeInfo typeinfo = {
-+    sizeof (GstFFMpegMuxClass),
-+    (GBaseInitFunc) gst_ffmpegmux_base_init,
-+    NULL,
-+    (GClassInitFunc) gst_ffmpegmux_class_init,
-+    NULL,
-+    NULL,
-+    sizeof (GstFFMpegMux),
-+    0,
-+    (GInstanceInitFunc) gst_ffmpegmux_init,
-+  };
-+  static const GInterfaceInfo tag_setter_info = {
-+    NULL, NULL, NULL
-+  };
-+  GType type;
-+  AVOutputFormat *in_plugin;
-+
-+  in_plugin = av_oformat_next (NULL);
-+
-+  GST_LOG ("Registering muxers");
-+
-+  while (in_plugin) {
-+    gchar *type_name;
-+    gchar *p;
-+    GstRank rank = GST_RANK_MARGINAL;
-+
-+    if ((!strncmp (in_plugin->name, "u16", 3)) ||
-+        (!strncmp (in_plugin->name, "s16", 3)) ||
-+        (!strncmp (in_plugin->name, "u24", 3)) ||
-+        (!strncmp (in_plugin->name, "s24", 3)) ||
-+        (!strncmp (in_plugin->name, "u8", 2)) ||
-+        (!strncmp (in_plugin->name, "s8", 2)) ||
-+        (!strncmp (in_plugin->name, "u32", 3)) ||
-+        (!strncmp (in_plugin->name, "s32", 3)) ||
-+        (!strncmp (in_plugin->name, "f32", 3)) ||
-+        (!strncmp (in_plugin->name, "f64", 3)) ||
-+        (!strncmp (in_plugin->name, "raw", 3)) ||
-+        (!strncmp (in_plugin->name, "crc", 3)) ||
-+        (!strncmp (in_plugin->name, "null", 4)) ||
-+        (!strncmp (in_plugin->name, "gif", 3)) ||
-+        (!strncmp (in_plugin->name, "frame", 5)) ||
-+        (!strncmp (in_plugin->name, "image", 5)) ||
-+        (!strncmp (in_plugin->name, "mulaw", 5)) ||
-+        (!strncmp (in_plugin->name, "alaw", 4)) ||
-+        (!strncmp (in_plugin->name, "h26", 3)) ||
-+        (!strncmp (in_plugin->name, "rtp", 3)) ||
-+        (!strncmp (in_plugin->name, "ass", 3)) ||
-+        (!strncmp (in_plugin->name, "ffmetadata", 10)) ||
-+        (!strncmp (in_plugin->name, "srt", 3))
-+        ) {
-+      GST_LOG ("Ignoring muxer %s", in_plugin->name);
-+      goto next;
-+    }
-+
-+    if ((!strncmp (in_plugin->long_name, "raw ", 4))) {
-+      GST_LOG ("Ignoring raw muxer %s", in_plugin->name);
-+      goto next;
-+    }
-+
-+    if (gst_ffmpegmux_get_replacement (in_plugin->name))
-+      rank = GST_RANK_NONE;
-+
-+    /* FIXME : We need a fast way to know whether we have mappings for this
-+     * muxer type. */
-+
-+    /* construct the type */
-+    type_name = g_strdup_printf ("ffmux_%s", in_plugin->name);
-+
-+    p = type_name;
-+
-+    while (*p) {
-+      if (*p == '.')
-+        *p = '_';
-+      p++;
-+    }
-+
-+    type = g_type_from_name (type_name);
-+
-+    if (!type) {
-+      /* create the type now */
-+      type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
-+      g_type_set_qdata (type, GST_FFMUX_PARAMS_QDATA, (gpointer) in_plugin);
-+      g_type_add_interface_static (type, GST_TYPE_TAG_SETTER, &tag_setter_info);
-+    }
-+
-+    if (!gst_element_register (plugin, type_name, rank, type)) {
-+      g_free (type_name);
-+      return FALSE;
-+    }
-+
-+    g_free (type_name);
-+
-+  next:
-+    in_plugin = av_oformat_next (in_plugin);
-+  }
-+
-+  GST_LOG ("Finished registering muxers");
-+
-+  return TRUE;
-+}
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegprotocol.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegprotocol.c
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegprotocol.c	2011-07-12 16:35:28.000000000 +0200
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegprotocol.c	2014-08-08 15:26:07.875857555 +0200
-@@ -46,63 +46,14 @@
- };
- 
- static int
--gst_ffmpegdata_open (URLContext * h, const char *filename, int flags)
--{
--  GstProtocolInfo *info;
--  GstPad *pad;
--
--  GST_LOG ("Opening %s", filename);
--
--  info = g_new0 (GstProtocolInfo, 1);
--
--  info->set_streamheader = flags & GST_FFMPEG_URL_STREAMHEADER;
--  flags &= ~GST_FFMPEG_URL_STREAMHEADER;
--  h->flags &= ~GST_FFMPEG_URL_STREAMHEADER;
--
--  /* we don't support R/W together */
--  if (flags != URL_RDONLY && flags != URL_WRONLY) {
--    GST_WARNING ("Only read-only or write-only are supported");
--    return -EINVAL;
--  }
--
--  if (sscanf (&filename[12], "%p", &pad) != 1) {
--    GST_WARNING ("could not decode pad from %s", filename);
--    return -EIO;
--  }
--
--  /* make sure we're a pad and that we're of the right type */
--  g_return_val_if_fail (GST_IS_PAD (pad), -EINVAL);
--
--  switch (flags) {
--    case URL_RDONLY:
--      g_return_val_if_fail (GST_PAD_IS_SINK (pad), -EINVAL);
--      break;
--    case URL_WRONLY:
--      g_return_val_if_fail (GST_PAD_IS_SRC (pad), -EINVAL);
--      break;
--  }
--
--  info->eos = FALSE;
--  info->pad = pad;
--  info->offset = 0;
--
--  h->priv_data = (void *) info;
--  h->is_streamed = FALSE;
--  h->max_packet_size = 0;
--
--  return 0;
--}
--
--static int
--gst_ffmpegdata_peek (URLContext * h, unsigned char *buf, int size)
-+gst_ffmpegdata_peek (void *priv_data, unsigned char *buf, int size)
- {
-   GstProtocolInfo *info;
-   GstBuffer *inbuf = NULL;
-   GstFlowReturn ret;
-   int total = 0;
- 
--  g_return_val_if_fail (h->flags == URL_RDONLY, AVERROR (EIO));
--  info = (GstProtocolInfo *) h->priv_data;
-+  info = (GstProtocolInfo *) priv_data;
- 
-   GST_DEBUG ("Pulling %d bytes at position %" G_GUINT64_FORMAT, size,
-       info->offset);
-@@ -134,17 +85,17 @@
- }
- 
- static int
--gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size)
-+gst_ffmpegdata_read (void *priv_data, unsigned char *buf, int size)
- {
-   gint res;
-   GstProtocolInfo *info;
- 
--  info = (GstProtocolInfo *) h->priv_data;
-+  info = (GstProtocolInfo *) priv_data;
- 
-   GST_DEBUG ("Reading %d bytes of data at position %" G_GUINT64_FORMAT, size,
-       info->offset);
- 
--  res = gst_ffmpegdata_peek (h, buf, size);
-+  res = gst_ffmpegdata_peek (priv_data, buf, size);
-   if (res >= 0)
-     info->offset += res;
- 
-@@ -154,15 +105,13 @@
- }
- 
- static int
--gst_ffmpegdata_write (URLContext * h, const unsigned char *buf, int size)
-+gst_ffmpegdata_write (void *priv_data, const unsigned char *buf, int size)
- {
-   GstProtocolInfo *info;
-   GstBuffer *outbuf;
- 
-   GST_DEBUG ("Writing %d bytes", size);
--  info = (GstProtocolInfo *) h->priv_data;
--
--  g_return_val_if_fail (h->flags != URL_RDONLY, -EIO);
-+  info = (GstProtocolInfo *) priv_data;
- 
-   /* create buffer and push data further */
-   if (gst_pad_alloc_buffer_and_set_caps (info->pad,
-@@ -179,7 +128,7 @@
- }
- 
- static int64_t
--gst_ffmpegdata_seek (URLContext * h, int64_t pos, int whence)
-+gst_ffmpegdata_seek (void *priv_data, int64_t pos, int whence)
- {
-   GstProtocolInfo *info;
-   guint64 newpos = 0;
-@@ -187,70 +136,62 @@
-   GST_DEBUG ("Seeking to %" G_GINT64_FORMAT ", whence=%d",
-       (gint64) pos, whence);
- 
--  info = (GstProtocolInfo *) h->priv_data;
-+  info = (GstProtocolInfo *) priv_data;
- 
-   /* TODO : if we are push-based, we need to return sensible info */
- 
--  switch (h->flags) {
--    case URL_RDONLY:
--    {
--      /* sinkpad */
--      switch (whence) {
--        case SEEK_SET:
--          newpos = (guint64) pos;
--          break;
--        case SEEK_CUR:
--          newpos = info->offset + pos;
--          break;
--        case SEEK_END:
--        case AVSEEK_SIZE:
--          /* ffmpeg wants to know the current end position in bytes ! */
--        {
--          GstFormat format = GST_FORMAT_BYTES;
--          gint64 duration;
--
--          GST_DEBUG ("Seek end");
--
--          if (gst_pad_is_linked (info->pad))
--            if (gst_pad_query_duration (GST_PAD_PEER (info->pad), &format,
--                    &duration))
--              newpos = ((guint64) duration) + pos;
--        }
--          break;
--        default:
--          g_assert (0);
--          break;
-+  if (GST_PAD_IS_SINK (info->pad)) {
-+    /* sinkpad */
-+    switch (whence) {
-+      case SEEK_SET:
-+        newpos = (guint64) pos;
-+        break;
-+      case SEEK_CUR:
-+        newpos = info->offset + pos;
-+        break;
-+      case SEEK_END:
-+      case AVSEEK_SIZE:
-+        /* ffmpeg wants to know the current end position in bytes ! */
-+      {
-+        GstFormat format = GST_FORMAT_BYTES;
-+        gint64 duration;
-+
-+        GST_DEBUG ("Seek end");
-+
-+        if (gst_pad_is_linked (info->pad))
-+          if (gst_pad_query_duration (GST_PAD_PEER (info->pad), &format,
-+                  &duration))
-+            newpos = ((guint64) duration) + pos;
-       }
--      /* FIXME : implement case for push-based behaviour */
--      if (whence != AVSEEK_SIZE)
--        info->offset = newpos;
-+        break;
-+      default:
-+        g_assert (0);
-+        break;
-     }
--      break;
--    case URL_WRONLY:
--    {
--      /* srcpad */
--      switch (whence) {
--        case SEEK_SET:
--          info->offset = (guint64) pos;
--          gst_pad_push_event (info->pad, gst_event_new_new_segment
--              (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
--                  GST_CLOCK_TIME_NONE, info->offset));
--          break;
--        case SEEK_CUR:
--          info->offset += pos;
--          gst_pad_push_event (info->pad, gst_event_new_new_segment
--              (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
--                  GST_CLOCK_TIME_NONE, info->offset));
--          break;
--        default:
--          break;
--      }
--      newpos = info->offset;
-+    /* FIXME : implement case for push-based behaviour */
-+    if (whence != AVSEEK_SIZE)
-+      info->offset = newpos;
-+  } else if (GST_PAD_IS_SRC (info->pad)) {
-+    /* srcpad */
-+    switch (whence) {
-+      case SEEK_SET:
-+        info->offset = (guint64) pos;
-+        gst_pad_push_event (info->pad, gst_event_new_new_segment
-+            (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
-+                GST_CLOCK_TIME_NONE, info->offset));
-+        break;
-+      case SEEK_CUR:
-+        info->offset += pos;
-+        gst_pad_push_event (info->pad, gst_event_new_new_segment
-+            (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
-+                GST_CLOCK_TIME_NONE, info->offset));
-+        break;
-+      default:
-+        break;
-     }
--      break;
--    default:
--      g_assert (0);
--      break;
-+    newpos = info->offset;
-+  } else {
-+    g_assert_not_reached ();
-   }
- 
-   GST_DEBUG ("Now at offset %" G_GUINT64_FORMAT " (returning %" G_GUINT64_FORMAT
-@@ -258,85 +199,91 @@
-   return newpos;
- }
- 
--static int
--gst_ffmpegdata_close (URLContext * h)
-+int
-+gst_ffmpegdata_close (AVIOContext * h)
- {
-   GstProtocolInfo *info;
- 
--  info = (GstProtocolInfo *) h->priv_data;
-+  info = (GstProtocolInfo *) h->opaque;
-   if (info == NULL)
-     return 0;
- 
-   GST_LOG ("Closing file");
- 
--  switch (h->flags) {
--    case URL_WRONLY:
--    {
--      /* send EOS - that closes down the stream */
--      gst_pad_push_event (info->pad, gst_event_new_eos ());
--      break;
--    }
--    default:
--      break;
-+  if (GST_PAD_IS_SRC (info->pad)) {
-+    /* send EOS - that closes down the stream */
-+    gst_pad_push_event (info->pad, gst_event_new_eos ());
-   }
- 
-   /* clean up data */
-   g_free (info);
--  h->priv_data = NULL;
-+  h->opaque = NULL;
-+
-+  av_freep (&h->buffer);
-+  av_free (h);
- 
-   return 0;
- }
- 
-+int
-+gst_ffmpegdata_open (GstPad * pad, int flags, AVIOContext ** context)
-+{
-+  GstProtocolInfo *info;
-+  static const int buffer_size = 4096;
-+  unsigned char *buffer = NULL;
- 
--URLProtocol gstreamer_protocol = {
--  /*.name = */ "gstreamer",
--  /*.url_open = */ gst_ffmpegdata_open,
--  /*.url_read = */ gst_ffmpegdata_read,
--  /*.url_write = */ gst_ffmpegdata_write,
--  /*.url_seek = */ gst_ffmpegdata_seek,
--  /*.url_close = */ gst_ffmpegdata_close,
--};
-+  info = g_new0 (GstProtocolInfo, 1);
- 
-+  info->set_streamheader = flags & GST_FFMPEG_URL_STREAMHEADER;
-+  flags &= ~GST_FFMPEG_URL_STREAMHEADER;
- 
--/* specialized protocol for cross-thread pushing,
-- * based on ffmpeg's pipe protocol */
-+  /* we don't support R/W together */
-+  if ((flags & AVIO_FLAG_WRITE) && (flags & AVIO_FLAG_READ)) {
-+    GST_WARNING ("Only read-only or write-only are supported");
-+    return -EINVAL;
-+  }
- 
--static int
--gst_ffmpeg_pipe_open (URLContext * h, const char *filename, int flags)
--{
--  GstFFMpegPipe *ffpipe;
-+  /* make sure we're a pad and that we're of the right type */
-+  g_return_val_if_fail (GST_IS_PAD (pad), -EINVAL);
- 
--  GST_LOG ("Opening %s", filename);
-+  if ((flags & AVIO_FLAG_READ))
-+    g_return_val_if_fail (GST_PAD_IS_SINK (pad), -EINVAL);
-+  if ((flags & AVIO_FLAG_WRITE))
-+    g_return_val_if_fail (GST_PAD_IS_SRC (pad), -EINVAL);
- 
--  /* we don't support W together */
--  if (flags != URL_RDONLY) {
--    GST_WARNING ("Only read-only is supported");
--    return -EINVAL;
--  }
-+  info->eos = FALSE;
-+  info->pad = pad;
-+  info->offset = 0;
- 
--  if (sscanf (&filename[10], "%p", &ffpipe) != 1) {
--    GST_WARNING ("could not decode pipe info from %s", filename);
--    return -EIO;
-+  buffer = av_malloc (buffer_size);
-+  if (buffer == NULL) {
-+    GST_WARNING ("Failed to allocate buffer");
-+    return -ENOMEM;
-   }
- 
--  /* sanity check */
--  g_return_val_if_fail (GST_IS_ADAPTER (ffpipe->adapter), -EINVAL);
--
--  h->priv_data = (void *) ffpipe;
--  h->is_streamed = TRUE;
--  h->max_packet_size = 0;
-+  *context =
-+      avio_alloc_context (buffer, buffer_size, flags, (void *) info,
-+      gst_ffmpegdata_read, gst_ffmpegdata_write, gst_ffmpegdata_seek);
-+  (*context)->seekable = AVIO_SEEKABLE_NORMAL;
-+  if (!(flags & AVIO_FLAG_WRITE)) {
-+    (*context)->buf_ptr = (*context)->buf_end;
-+    (*context)->write_flag = 0;
-+  }
- 
-   return 0;
- }
- 
-+/* specialized protocol for cross-thread pushing,
-+ * based on ffmpeg's pipe protocol */
-+
- static int
--gst_ffmpeg_pipe_read (URLContext * h, unsigned char *buf, int size)
-+gst_ffmpeg_pipe_read (void *priv_data, unsigned char *buf, int size)
- {
-   GstFFMpegPipe *ffpipe;
-   const guint8 *data;
-   guint available;
- 
--  ffpipe = (GstFFMpegPipe *) h->priv_data;
-+  ffpipe = (GstFFMpegPipe *) priv_data;
- 
-   GST_LOG ("requested size %d", size);
- 
-@@ -367,21 +314,38 @@
-   return size;
- }
- 
--static int
--gst_ffmpeg_pipe_close (URLContext * h)
-+int
-+gst_ffmpeg_pipe_close (AVIOContext * h)
- {
-   GST_LOG ("Closing pipe");
- 
--  h->priv_data = NULL;
-+  h->opaque = NULL;
-+  av_freep (&h->buffer);
-+  av_free (h);
- 
-   return 0;
- }
- 
--URLProtocol gstpipe_protocol = {
--  "gstpipe",
--  gst_ffmpeg_pipe_open,
--  gst_ffmpeg_pipe_read,
--  NULL,
--  NULL,
--  gst_ffmpeg_pipe_close,
--};
-+int
-+gst_ffmpeg_pipe_open (GstFFMpegPipe * ffpipe, int flags, AVIOContext ** context)
-+{
-+  static const int buffer_size = 4096;
-+  unsigned char *buffer = NULL;
-+
-+  /* sanity check */
-+  g_return_val_if_fail (GST_IS_ADAPTER (ffpipe->adapter), -EINVAL);
-+
-+  buffer = av_malloc (buffer_size);
-+  if (buffer == NULL) {
-+    GST_WARNING ("Failed to allocate buffer");
-+    return -ENOMEM;
-+  }
-+
-+  *context =
-+      avio_alloc_context (buffer, buffer_size, 0, (void *) ffpipe,
-+      gst_ffmpeg_pipe_read, NULL, NULL);
-+  (*context)->seekable = 0;
-+  (*context)->buf_ptr = (*context)->buf_end;
-+
-+  return 0;
-+}
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c	2011-07-13 11:07:28.000000000 +0200
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c	2014-08-08 15:34:04.007874626 +0200
-@@ -25,6 +25,11 @@
- #ifdef __APPLE__
- #include <sys/sysctl.h>
- #endif
-+#ifdef HAVE_FFMPEG_UNINSTALLED
-+#include <avformat.h>
-+#else
-+#include <libavformat/avformat.h>
-+#endif
- 
- G_CONST_RETURN gchar *
- gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
-@@ -39,21 +44,21 @@
- }
- 
- gint
--av_smp_format_depth (enum SampleFormat smp_fmt)
-+av_smp_format_depth (enum AVSampleFormat smp_fmt)
- {
-   gint depth = -1;
-   switch (smp_fmt) {
--    case SAMPLE_FMT_U8:
-+    case AV_SAMPLE_FMT_U8:
-       depth = 1;
-       break;
--    case SAMPLE_FMT_S16:
-+    case AV_SAMPLE_FMT_S16:
-       depth = 2;
-       break;
--    case SAMPLE_FMT_S32:
--    case SAMPLE_FMT_FLT:
-+    case AV_SAMPLE_FMT_S32:
-+    case AV_SAMPLE_FMT_FLT:
-       depth = 4;
-       break;
--    case SAMPLE_FMT_DBL:
-+    case AV_SAMPLE_FMT_DBL:
-       depth = 8;
-       break;
-     default:
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c.orig
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c.orig	1970-01-01 01:00:00.000000000 +0100
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c.orig	2011-07-13 11:07:28.000000000 +0200
-@@ -0,0 +1,483 @@
-+/* GStreamer
-+ * Copyright (c) 2009 Edward Hervey <bilboed@bilboed.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.
-+ */
-+
-+#ifdef HAVE_CONFIG_H
-+#include "config.h"
-+#endif
-+#include "gstffmpegutils.h"
-+#include <unistd.h>
-+#ifdef __APPLE__
-+#include <sys/sysctl.h>
-+#endif
-+
-+G_CONST_RETURN gchar *
-+gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
-+{
-+  AVCodec *codec;
-+  /* Let's use what ffmpeg can provide us */
-+
-+  if ((codec = avcodec_find_decoder (codec_id)) ||
-+      (codec = avcodec_find_encoder (codec_id)))
-+    return codec->long_name;
-+  return NULL;
-+}
-+
-+gint
-+av_smp_format_depth (enum SampleFormat smp_fmt)
-+{
-+  gint depth = -1;
-+  switch (smp_fmt) {
-+    case SAMPLE_FMT_U8:
-+      depth = 1;
-+      break;
-+    case SAMPLE_FMT_S16:
-+      depth = 2;
-+      break;
-+    case SAMPLE_FMT_S32:
-+    case SAMPLE_FMT_FLT:
-+      depth = 4;
-+      break;
-+    case SAMPLE_FMT_DBL:
-+      depth = 8;
-+      break;
-+    default:
-+      GST_ERROR ("UNHANDLED SAMPLE FORMAT !");
-+      break;
-+  }
-+  return depth;
-+}
-+
-+
-+/*
-+ * Fill in pointers to memory in a AVPicture, where
-+ * everything is aligned by 4 (as required by X).
-+ * This is mostly a copy from imgconvert.c with some
-+ * small changes.
-+ */
-+
-+#define FF_COLOR_RGB      0     /* RGB color space */
-+#define FF_COLOR_GRAY     1     /* gray color space */
-+#define FF_COLOR_YUV      2     /* YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */
-+#define FF_COLOR_YUV_JPEG 3     /* YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */
-+
-+#define FF_PIXEL_PLANAR   0     /* each channel has one component in AVPicture */
-+#define FF_PIXEL_PACKED   1     /* only one components containing all the channels */
-+#define FF_PIXEL_PALETTE  2     /* one components containing indexes for a palette */
-+
-+typedef struct PixFmtInfo
-+{
-+  const char *name;
-+  uint8_t nb_channels;          /* number of channels (including alpha) */
-+  uint8_t color_type;           /* color type (see FF_COLOR_xxx constants) */
-+  uint8_t pixel_type;           /* pixel storage type (see FF_PIXEL_xxx constants) */
-+  uint8_t is_alpha:1;           /* true if alpha can be specified */
-+  uint8_t x_chroma_shift;       /* X chroma subsampling factor is 2 ^ shift */
-+  uint8_t y_chroma_shift;       /* Y chroma subsampling factor is 2 ^ shift */
-+  uint8_t depth;                /* bit depth of the color components */
-+} PixFmtInfo;
-+
-+
-+/* this table gives more information about formats */
-+static PixFmtInfo pix_fmt_info[PIX_FMT_NB];
-+void
-+gst_ffmpeg_init_pix_fmt_info (void)
-+{
-+  /* YUV formats */
-+  pix_fmt_info[PIX_FMT_YUV420P].name = g_strdup ("yuv420p");
-+  pix_fmt_info[PIX_FMT_YUV420P].nb_channels = 3;
-+  pix_fmt_info[PIX_FMT_YUV420P].color_type = FF_COLOR_YUV;
-+  pix_fmt_info[PIX_FMT_YUV420P].pixel_type = FF_PIXEL_PLANAR;
-+  pix_fmt_info[PIX_FMT_YUV420P].depth = 8,
-+      pix_fmt_info[PIX_FMT_YUV420P].x_chroma_shift = 1,
-+      pix_fmt_info[PIX_FMT_YUV420P].y_chroma_shift = 1;
-+
-+  pix_fmt_info[PIX_FMT_YUV422P].name = g_strdup ("yuv422p");
-+  pix_fmt_info[PIX_FMT_YUV422P].nb_channels = 3;
-+  pix_fmt_info[PIX_FMT_YUV422P].color_type = FF_COLOR_YUV;
-+  pix_fmt_info[PIX_FMT_YUV422P].pixel_type = FF_PIXEL_PLANAR;
-+  pix_fmt_info[PIX_FMT_YUV422P].depth = 8;
-+  pix_fmt_info[PIX_FMT_YUV422P].x_chroma_shift = 1;
-+  pix_fmt_info[PIX_FMT_YUV422P].y_chroma_shift = 0;
-+
-+  pix_fmt_info[PIX_FMT_YUV444P].name = g_strdup ("yuv444p");
-+  pix_fmt_info[PIX_FMT_YUV444P].nb_channels = 3;
-+  pix_fmt_info[PIX_FMT_YUV444P].color_type = FF_COLOR_YUV;
-+  pix_fmt_info[PIX_FMT_YUV444P].pixel_type = FF_PIXEL_PLANAR;
-+  pix_fmt_info[PIX_FMT_YUV444P].depth = 8;
-+  pix_fmt_info[PIX_FMT_YUV444P].x_chroma_shift = 0;
-+  pix_fmt_info[PIX_FMT_YUV444P].y_chroma_shift = 0;
-+
-+  pix_fmt_info[PIX_FMT_YUYV422].name = g_strdup ("yuv422");
-+  pix_fmt_info[PIX_FMT_YUYV422].nb_channels = 1;
-+  pix_fmt_info[PIX_FMT_YUYV422].color_type = FF_COLOR_YUV;
-+  pix_fmt_info[PIX_FMT_YUYV422].pixel_type = FF_PIXEL_PACKED;
-+  pix_fmt_info[PIX_FMT_YUYV422].depth = 8;
-+  pix_fmt_info[PIX_FMT_YUYV422].x_chroma_shift = 1;
-+  pix_fmt_info[PIX_FMT_YUYV422].y_chroma_shift = 0;
-+
-+  pix_fmt_info[PIX_FMT_YUV410P].name = g_strdup ("yuv410p");
-+  pix_fmt_info[PIX_FMT_YUV410P].nb_channels = 3;
-+  pix_fmt_info[PIX_FMT_YUV410P].color_type = FF_COLOR_YUV;
-+  pix_fmt_info[PIX_FMT_YUV410P].pixel_type = FF_PIXEL_PLANAR;
-+  pix_fmt_info[PIX_FMT_YUV410P].depth = 8;
-+  pix_fmt_info[PIX_FMT_YUV410P].x_chroma_shift = 2;
-+  pix_fmt_info[PIX_FMT_YUV410P].y_chroma_shift = 2;
-+
-+  pix_fmt_info[PIX_FMT_YUV411P].name = g_strdup ("yuv411p");
-+  pix_fmt_info[PIX_FMT_YUV411P].nb_channels = 3;
-+  pix_fmt_info[PIX_FMT_YUV411P].color_type = FF_COLOR_YUV;
-+  pix_fmt_info[PIX_FMT_YUV411P].pixel_type = FF_PIXEL_PLANAR;
-+  pix_fmt_info[PIX_FMT_YUV411P].depth = 8;
-+  pix_fmt_info[PIX_FMT_YUV411P].x_chroma_shift = 2;
-+  pix_fmt_info[PIX_FMT_YUV411P].y_chroma_shift = 0;
-+
-+  /* JPEG YUV */
-+  pix_fmt_info[PIX_FMT_YUVJ420P].name = g_strdup ("yuvj420p");
-+  pix_fmt_info[PIX_FMT_YUVJ420P].nb_channels = 3;
-+  pix_fmt_info[PIX_FMT_YUVJ420P].color_type = FF_COLOR_YUV_JPEG;
-+  pix_fmt_info[PIX_FMT_YUVJ420P].pixel_type = FF_PIXEL_PLANAR;
-+  pix_fmt_info[PIX_FMT_YUVJ420P].depth = 8;
-+  pix_fmt_info[PIX_FMT_YUVJ420P].x_chroma_shift = 1;
-+  pix_fmt_info[PIX_FMT_YUVJ420P].y_chroma_shift = 1;
-+
-+  pix_fmt_info[PIX_FMT_YUVJ422P].name = g_strdup ("yuvj422p");
-+  pix_fmt_info[PIX_FMT_YUVJ422P].nb_channels = 3;
-+  pix_fmt_info[PIX_FMT_YUVJ422P].color_type = FF_COLOR_YUV_JPEG;
-+  pix_fmt_info[PIX_FMT_YUVJ422P].pixel_type = FF_PIXEL_PLANAR;
-+  pix_fmt_info[PIX_FMT_YUVJ422P].depth = 8;
-+  pix_fmt_info[PIX_FMT_YUVJ422P].x_chroma_shift = 1;
-+  pix_fmt_info[PIX_FMT_YUVJ422P].y_chroma_shift = 0;
-+
-+  pix_fmt_info[PIX_FMT_YUVJ444P].name = g_strdup ("yuvj444p");
-+  pix_fmt_info[PIX_FMT_YUVJ444P].nb_channels = 3;
-+  pix_fmt_info[PIX_FMT_YUVJ444P].color_type = FF_COLOR_YUV_JPEG;
-+  pix_fmt_info[PIX_FMT_YUVJ444P].pixel_type = FF_PIXEL_PLANAR;
-+  pix_fmt_info[PIX_FMT_YUVJ444P].depth = 8;
-+  pix_fmt_info[PIX_FMT_YUVJ444P].x_chroma_shift = 0;
-+  pix_fmt_info[PIX_FMT_YUVJ444P].y_chroma_shift = 0;
-+
-+  /* RGB formats */
-+  pix_fmt_info[PIX_FMT_RGB24].name = g_strdup ("rgb24");
-+  pix_fmt_info[PIX_FMT_RGB24].nb_channels = 3;
-+  pix_fmt_info[PIX_FMT_RGB24].color_type = FF_COLOR_RGB;
-+  pix_fmt_info[PIX_FMT_RGB24].pixel_type = FF_PIXEL_PACKED;
-+  pix_fmt_info[PIX_FMT_RGB24].depth = 8;
-+  pix_fmt_info[PIX_FMT_RGB24].x_chroma_shift = 0;
-+  pix_fmt_info[PIX_FMT_RGB24].y_chroma_shift = 0;
-+
-+  pix_fmt_info[PIX_FMT_BGR24].name = g_strdup ("bgr24");
-+  pix_fmt_info[PIX_FMT_BGR24].nb_channels = 3;
-+  pix_fmt_info[PIX_FMT_BGR24].color_type = FF_COLOR_RGB;
-+  pix_fmt_info[PIX_FMT_BGR24].pixel_type = FF_PIXEL_PACKED;
-+  pix_fmt_info[PIX_FMT_BGR24].depth = 8;
-+  pix_fmt_info[PIX_FMT_BGR24].x_chroma_shift = 0;
-+  pix_fmt_info[PIX_FMT_BGR24].y_chroma_shift = 0;
-+
-+  pix_fmt_info[PIX_FMT_RGB32].name = g_strdup ("rgba32");
-+  pix_fmt_info[PIX_FMT_RGB32].nb_channels = 4;
-+  pix_fmt_info[PIX_FMT_RGB32].is_alpha = 1;
-+  pix_fmt_info[PIX_FMT_RGB32].color_type = FF_COLOR_RGB;
-+  pix_fmt_info[PIX_FMT_RGB32].pixel_type = FF_PIXEL_PACKED;
-+  pix_fmt_info[PIX_FMT_RGB32].depth = 8;
-+  pix_fmt_info[PIX_FMT_RGB32].x_chroma_shift = 0;
-+  pix_fmt_info[PIX_FMT_RGB32].y_chroma_shift = 0;
-+
-+  pix_fmt_info[PIX_FMT_RGB565].name = g_strdup ("rgb565");
-+  pix_fmt_info[PIX_FMT_RGB565].nb_channels = 3;
-+  pix_fmt_info[PIX_FMT_RGB565].color_type = FF_COLOR_RGB;
-+  pix_fmt_info[PIX_FMT_RGB565].pixel_type = FF_PIXEL_PACKED;
-+  pix_fmt_info[PIX_FMT_RGB565].depth = 5;
-+  pix_fmt_info[PIX_FMT_RGB565].x_chroma_shift = 0;
-+  pix_fmt_info[PIX_FMT_RGB565].y_chroma_shift = 0;
-+
-+  pix_fmt_info[PIX_FMT_RGB555].name = g_strdup ("rgb555");
-+  pix_fmt_info[PIX_FMT_RGB555].nb_channels = 4;
-+  pix_fmt_info[PIX_FMT_RGB555].is_alpha = 1;
-+  pix_fmt_info[PIX_FMT_RGB555].color_type = FF_COLOR_RGB;
-+  pix_fmt_info[PIX_FMT_RGB555].pixel_type = FF_PIXEL_PACKED;
-+  pix_fmt_info[PIX_FMT_RGB555].depth = 5;
-+  pix_fmt_info[PIX_FMT_RGB555].x_chroma_shift = 0;
-+  pix_fmt_info[PIX_FMT_RGB555].y_chroma_shift = 0;
-+
-+  /* gray / mono formats */
-+  pix_fmt_info[PIX_FMT_GRAY8].name = g_strdup ("gray");
-+  pix_fmt_info[PIX_FMT_GRAY8].nb_channels = 1;
-+  pix_fmt_info[PIX_FMT_GRAY8].color_type = FF_COLOR_GRAY;
-+  pix_fmt_info[PIX_FMT_GRAY8].pixel_type = FF_PIXEL_PLANAR;
-+  pix_fmt_info[PIX_FMT_GRAY8].depth = 8;
-+
-+  pix_fmt_info[PIX_FMT_MONOWHITE].name = g_strdup ("monow");
-+  pix_fmt_info[PIX_FMT_MONOWHITE].nb_channels = 1;
-+  pix_fmt_info[PIX_FMT_MONOWHITE].color_type = FF_COLOR_GRAY;
-+  pix_fmt_info[PIX_FMT_MONOWHITE].pixel_type = FF_PIXEL_PLANAR;
-+  pix_fmt_info[PIX_FMT_MONOWHITE].depth = 1;
-+
-+  pix_fmt_info[PIX_FMT_MONOBLACK].name = g_strdup ("monob");
-+  pix_fmt_info[PIX_FMT_MONOBLACK].nb_channels = 1;
-+  pix_fmt_info[PIX_FMT_MONOBLACK].color_type = FF_COLOR_GRAY;
-+  pix_fmt_info[PIX_FMT_MONOBLACK].pixel_type = FF_PIXEL_PLANAR;
-+  pix_fmt_info[PIX_FMT_MONOBLACK].depth = 1;
-+
-+  /* paletted formats */
-+  pix_fmt_info[PIX_FMT_PAL8].name = g_strdup ("pal8");
-+  pix_fmt_info[PIX_FMT_PAL8].nb_channels = 4;
-+  pix_fmt_info[PIX_FMT_PAL8].is_alpha = 1;
-+  pix_fmt_info[PIX_FMT_PAL8].color_type = FF_COLOR_RGB;
-+  pix_fmt_info[PIX_FMT_PAL8].pixel_type = FF_PIXEL_PALETTE;
-+  pix_fmt_info[PIX_FMT_PAL8].depth = 8;
-+
-+  pix_fmt_info[PIX_FMT_YUVA420P].name = g_strdup ("yuva420p");
-+  pix_fmt_info[PIX_FMT_YUVA420P].nb_channels = 4;
-+  pix_fmt_info[PIX_FMT_YUVA420P].is_alpha = 1;
-+  pix_fmt_info[PIX_FMT_YUVA420P].color_type = FF_COLOR_YUV;
-+  pix_fmt_info[PIX_FMT_YUVA420P].pixel_type = FF_PIXEL_PLANAR;
-+  pix_fmt_info[PIX_FMT_YUVA420P].depth = 8,
-+      pix_fmt_info[PIX_FMT_YUVA420P].x_chroma_shift = 1,
-+      pix_fmt_info[PIX_FMT_YUVA420P].y_chroma_shift = 1;
-+};
-+
-+int
-+gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height)
-+{
-+  AVPicture dummy_pict;
-+
-+  return gst_ffmpeg_avpicture_fill (&dummy_pict, NULL, pix_fmt, width, height);
-+}
-+
-+#define GEN_MASK(x) ((1<<(x))-1)
-+#define ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) & ~GEN_MASK(x))
-+#define ROUND_UP_2(x) ROUND_UP_X (x, 1)
-+#define ROUND_UP_4(x) ROUND_UP_X (x, 2)
-+#define ROUND_UP_8(x) ROUND_UP_X (x, 3)
-+#define DIV_ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) >> (x))
-+
-+int
-+gst_ffmpeg_avpicture_fill (AVPicture * picture,
-+    uint8_t * ptr, enum PixelFormat pix_fmt, int width, int height)
-+{
-+  int size, w2, h2, size2;
-+  int stride, stride2;
-+  PixFmtInfo *pinfo;
-+
-+  pinfo = &pix_fmt_info[pix_fmt];
-+
-+  switch (pix_fmt) {
-+    case PIX_FMT_YUV420P:
-+    case PIX_FMT_YUV422P:
-+    case PIX_FMT_YUV444P:
-+    case PIX_FMT_YUV410P:
-+    case PIX_FMT_YUV411P:
-+    case PIX_FMT_YUVJ420P:
-+    case PIX_FMT_YUVJ422P:
-+    case PIX_FMT_YUVJ444P:
-+      stride = ROUND_UP_4 (width);
-+      h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
-+      size = stride * h2;
-+      w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
-+      stride2 = ROUND_UP_4 (w2);
-+      h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift);
-+      size2 = stride2 * h2;
-+      picture->data[0] = ptr;
-+      picture->data[1] = picture->data[0] + size;
-+      picture->data[2] = picture->data[1] + size2;
-+      picture->data[3] = NULL;
-+      picture->linesize[0] = stride;
-+      picture->linesize[1] = stride2;
-+      picture->linesize[2] = stride2;
-+      picture->linesize[3] = 0;
-+      GST_DEBUG ("planes %d %d %d", 0, size, size + size2);
-+      GST_DEBUG ("strides %d %d %d", stride, stride2, stride2);
-+      return size + 2 * size2;
-+    case PIX_FMT_YUVA420P:
-+      stride = ROUND_UP_4 (width);
-+      h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
-+      size = stride * h2;
-+      w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
-+      stride2 = ROUND_UP_4 (w2);
-+      h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift);
-+      size2 = stride2 * h2;
-+      picture->data[0] = ptr;
-+      picture->data[1] = picture->data[0] + size;
-+      picture->data[2] = picture->data[1] + size2;
-+      picture->data[3] = picture->data[2] + size2;
-+      picture->linesize[0] = stride;
-+      picture->linesize[1] = stride2;
-+      picture->linesize[2] = stride2;
-+      picture->linesize[3] = stride;
-+      GST_DEBUG ("planes %d %d %d %d", 0, size, size + size2, size + 2 * size2);
-+      GST_DEBUG ("strides %d %d %d %d", stride, stride2, stride2, stride);
-+      return 2 * size + 2 * size2;
-+    case PIX_FMT_RGB24:
-+    case PIX_FMT_BGR24:
-+      stride = ROUND_UP_4 (width * 3);
-+      size = stride * height;
-+      picture->data[0] = ptr;
-+      picture->data[1] = NULL;
-+      picture->data[2] = NULL;
-+      picture->data[3] = NULL;
-+      picture->linesize[0] = stride;
-+      picture->linesize[1] = 0;
-+      picture->linesize[2] = 0;
-+      picture->linesize[3] = 0;
-+      return size;
-+      /*case PIX_FMT_AYUV4444:
-+         case PIX_FMT_BGR32:
-+         case PIX_FMT_BGRA32:
-+         case PIX_FMT_RGB32: */
-+    case PIX_FMT_RGB32:
-+      stride = width * 4;
-+      size = stride * height;
-+      picture->data[0] = ptr;
-+      picture->data[1] = NULL;
-+      picture->data[2] = NULL;
-+      picture->data[3] = NULL;
-+      picture->linesize[0] = stride;
-+      picture->linesize[1] = 0;
-+      picture->linesize[2] = 0;
-+      picture->linesize[3] = 0;
-+      return size;
-+    case PIX_FMT_RGB555:
-+    case PIX_FMT_RGB565:
-+    case PIX_FMT_YUYV422:
-+    case PIX_FMT_UYVY422:
-+      stride = ROUND_UP_4 (width * 2);
-+      size = stride * height;
-+      picture->data[0] = ptr;
-+      picture->data[1] = NULL;
-+      picture->data[2] = NULL;
-+      picture->data[3] = NULL;
-+      picture->linesize[0] = stride;
-+      picture->linesize[1] = 0;
-+      picture->linesize[2] = 0;
-+      picture->linesize[3] = 0;
-+      return size;
-+    case PIX_FMT_UYYVYY411:
-+      /* FIXME, probably not the right stride */
-+      stride = ROUND_UP_4 (width);
-+      size = stride * height;
-+      picture->data[0] = ptr;
-+      picture->data[1] = NULL;
-+      picture->data[2] = NULL;
-+      picture->data[3] = NULL;
-+      picture->linesize[0] = width + width / 2;
-+      picture->linesize[1] = 0;
-+      picture->linesize[2] = 0;
-+      picture->linesize[3] = 0;
-+      return size + size / 2;
-+    case PIX_FMT_GRAY8:
-+      stride = ROUND_UP_4 (width);
-+      size = stride * height;
-+      picture->data[0] = ptr;
-+      picture->data[1] = NULL;
-+      picture->data[2] = NULL;
-+      picture->data[3] = NULL;
-+      picture->linesize[0] = stride;
-+      picture->linesize[1] = 0;
-+      picture->linesize[2] = 0;
-+      picture->linesize[3] = 0;
-+      return size;
-+    case PIX_FMT_MONOWHITE:
-+    case PIX_FMT_MONOBLACK:
-+      stride = ROUND_UP_4 ((width + 7) >> 3);
-+      size = stride * height;
-+      picture->data[0] = ptr;
-+      picture->data[1] = NULL;
-+      picture->data[2] = NULL;
-+      picture->data[3] = NULL;
-+      picture->linesize[0] = stride;
-+      picture->linesize[1] = 0;
-+      picture->linesize[2] = 0;
-+      picture->linesize[3] = 0;
-+      return size;
-+    case PIX_FMT_PAL8:
-+      /* already forced to be with stride, so same result as other function */
-+      stride = ROUND_UP_4 (width);
-+      size = stride * height;
-+      picture->data[0] = ptr;
-+      picture->data[1] = ptr + size;    /* palette is stored here as 256 32 bit words */
-+      picture->data[2] = NULL;
-+      picture->data[3] = NULL;
-+      picture->linesize[0] = stride;
-+      picture->linesize[1] = 4;
-+      picture->linesize[2] = 0;
-+      picture->linesize[3] = 0;
-+      return size + 256 * 4;
-+    default:
-+      picture->data[0] = NULL;
-+      picture->data[1] = NULL;
-+      picture->data[2] = NULL;
-+      picture->data[3] = NULL;
-+      return -1;
-+  }
-+
-+  return 0;
-+}
-+
-+/* Create a GstBuffer of the requested size and caps.
-+ * The memory will be allocated by ffmpeg, making sure it's properly aligned
-+ * for any processing. */
-+
-+GstBuffer *
-+new_aligned_buffer (gint size, GstCaps * caps)
-+{
-+  GstBuffer *buf;
-+
-+  buf = gst_buffer_new ();
-+  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = av_malloc (size);
-+  GST_BUFFER_SIZE (buf) = size;
-+  GST_BUFFER_FREE_FUNC (buf) = av_free;
-+  if (caps)
-+    gst_buffer_set_caps (buf, caps);
-+
-+  return buf;
-+}
-+
-+int
-+gst_ffmpeg_auto_max_threads (void)
-+{
-+  static gsize n_threads = 0;
-+  if (g_once_init_enter (&n_threads)) {
-+    int n = 1;
-+#if defined(_WIN32)
-+    {
-+      const char *s = getenv ("NUMBER_OF_PROCESSORS");
-+      if (s) {
-+        n = atoi (s);
-+      }
-+    }
-+#elif defined(__APPLE__)
-+    {
-+      int mib[] = { CTL_HW, HW_NCPU };
-+      size_t dataSize = sizeof (int);
-+
-+      if (sysctl (mib, 2, &n_threads, &dataSize, NULL, 0)) {
-+        n = 1;
-+      }
-+    }
-+#else
-+    n = sysconf (_SC_NPROCESSORS_CONF);
-+#endif
-+    if (n < 1)
-+      n = 1;
-+
-+    g_once_init_leave (&n_threads, n);
-+  }
-+
-+  return (int) (n_threads);
-+}
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h	2011-11-02 14:04:05.000000000 +0100
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h	2014-08-08 15:34:04.007874626 +0200
-@@ -23,6 +23,7 @@
- #ifdef HAVE_FFMPEG_UNINSTALLED
- #include <avcodec.h>
- #else
-+#include <libavutil/mathematics.h>
- #include <libavcodec/avcodec.h>
- #endif
- #include <gst/gst.h>
-@@ -87,7 +88,7 @@
- gst_ffmpeg_get_codecid_longname (enum CodecID codec_id);
- 
- gint
--av_smp_format_depth(enum SampleFormat smp_fmt);
-+av_smp_format_depth(enum AVSampleFormat smp_fmt);
- 
- GstBuffer *
- new_aligned_buffer (gint size, GstCaps * caps);
-diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h.orig
---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h.orig	1970-01-01 01:00:00.000000000 +0100
-+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h.orig	2014-08-08 15:26:38.473858652 +0200
-@@ -0,0 +1,95 @@
-+/* GStreamer
-+ * Copyright (C) <2009> Edward Hervey <bilboed@bilboed.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.
-+ */
-+
-+#ifndef __GST_FFMPEG_UTILS_H__
-+#define __GST_FFMPEG_UTILS_H__
-+
-+#ifdef HAVE_FFMPEG_UNINSTALLED
-+#include <avcodec.h>
-+#else
-+#include <libavcodec/avcodec.h>
-+#endif
-+#include <gst/gst.h>
-+
-+/*
-+ *Get the size of an picture
-+ */
-+int
-+gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height);
-+
-+/*
-+ * Fill in pointers in an AVPicture, aligned by 4 (required by X).
-+ */
-+
-+int
-+gst_ffmpeg_avpicture_fill (AVPicture * picture,
-+                           uint8_t *   ptr,
-+                           enum PixelFormat pix_fmt,
-+                           int         width,
-+                           int         height);
-+
-+/*
-+ * Convert from/to a GStreamer <-> FFMpeg timestamp.
-+ */
-+static inline guint64
-+gst_ffmpeg_time_ff_to_gst (gint64 pts, AVRational base)
-+{
-+  guint64 out;
-+
-+  if (pts == AV_NOPTS_VALUE){
-+    out = GST_CLOCK_TIME_NONE;
-+  } else {
-+    AVRational bq = { 1, GST_SECOND };
-+    out = av_rescale_q (pts, base, bq);
-+  }
-+
-+  return out;
-+}
-+
-+static inline gint64
-+gst_ffmpeg_time_gst_to_ff (guint64 time, AVRational base)
-+{
-+  gint64 out;
-+
-+  if (!GST_CLOCK_TIME_IS_VALID (time) || base.num == 0) {
-+    out = AV_NOPTS_VALUE;
-+  } else {
-+    AVRational bq = { 1, GST_SECOND };
-+    out = av_rescale_q (time, bq, base);
-+  }
-+
-+  return out;
-+}
-+
-+void 
-+gst_ffmpeg_init_pix_fmt_info(void);
-+
-+int
-+gst_ffmpeg_auto_max_threads(void);
-+
-+G_CONST_RETURN gchar *
-+gst_ffmpeg_get_codecid_longname (enum CodecID codec_id);
-+
-+gint
-+av_smp_format_depth(enum AVSampleFormat smp_fmt);
-+
-+GstBuffer *
-+new_aligned_buffer (gint size, GstCaps * caps);
-+
-+#endif /* __GST_FFMPEG_UTILS_H__ */
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch
deleted file mode 100644
index eba4988..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff --git a/gst-libs/ext/libav/configure b/gst-libs/ext/libav/configure
-index 8473069..4f74952 100755
---- a/gst-libs/ext/libav/configure
-+++ b/gst-libs/ext/libav/configure
-Fix gst-ffmpeg build issues for libav on e500mc (fsl-p4080)
-
-Upstream-Status: Backport
-
-Signed-off-by: Yao Zhao <yao.zhao@windriver.com>
-
-@@ -2210,6 +2210,10 @@ elif enabled ppc; then
-             cpuflags="-mcpu=cell"
-             enable ldbrx
-         ;;
-+        e500mc)
-+            cpuflags="-mcpu=e500mc"
-+            disable altivec
-+        ;;
-         e500v2)
-             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
-             disable altivec
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch
deleted file mode 100644
index d9ea2c2..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-libav: Add configs for ppc e5500
-
-Upstream-Status: Pending
-
-Signed-off-by: Jesse Zhang <sen.zhang@windriver.com>
-
---- gst-ffmpeg-0.10.13/gst-libs/ext/libav/configure	2013-06-20 05:18:36.073104964 -0400
-+++ gst-ffmpeg-0.10.13/gst-libs/ext/libav/configure	2013-06-20 05:18:38.269104150 -0400
-@@ -2222,6 +2222,10 @@
-             cpuflags="-mcpu=8540 -mhard-float"
-             disable altivec
-         ;;
-+        e5500)
-+            cpuflags="-mcpu=e5500 -mhard-float"
-+            disable altivec
-+        ;;
-     esac
- 
- elif enabled x86; then
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff
deleted file mode 100644
index 5f08afe..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff
+++ /dev/null
@@ -1,16 +0,0 @@
-Lower the rank of ffmpeg plugin so codecs that hook into accelerated pieces (e.g. dsp or hw engines) can get picked over this
-Derived from OE by Dongxiao Xu <dongxiao.xu@intel.com>
-
-Upstream-Status: Inappropriate [embedded specific]
-
---- /tmp/gstffmpegdec.c	2009-03-05 09:31:15.000000000 +0100
-+++ gst-ffmpeg-0.10.6/ext/ffmpeg/gstffmpegdec.c	2009-03-05 09:33:09.000000000 +0100
-@@ -2588,7 +2588,7 @@
-       case CODEC_ID_MSMPEG4V3:
-       case CODEC_ID_H264:
-       case CODEC_ID_COOK:
--        rank = GST_RANK_PRIMARY;
-+        rank = GST_RANK_SECONDARY;
-         break;
-       case CODEC_ID_DVVIDEO:
-         /* we have a good dv decoder, fast on both ppc as well as x86. they say
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb
deleted file mode 100644
index b5c838f..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb
+++ /dev/null
@@ -1,90 +0,0 @@
-SUMMARY = "FFmpeg-based GStreamer plug-in"
-SECTION = "multimedia"
-LICENSE = "GPLv2+ & LGPLv2+ & ( (GPLv2+ & LGPLv2.1+) | (GPLv3+ & LGPLv3+) )"
-LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
-                    file://ext/libpostproc/gstpostproc.c;beginline=1;endline=18;md5=5896e445e41681324381f5869ee33d38 \
-                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
-                    file://ext/ffmpeg/gstffmpeg.h;beginline=1;endline=18;md5=ff65467b0c53cdfa98d0684c1bc240a9 \
-                    file://gst-libs/ext/libav/LICENSE;md5=abc3b8cb02856aa7823bbbd162d16232 \
-                    file://gst-libs/ext/libav/COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
-                    file://gst-libs/ext/libav/COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \
-                    file://gst-libs/ext/libav/COPYING.LGPLv2.1;md5=e344c8fa836c3a41c4cbd79d7bd3a379 \
-                    file://gst-libs/ext/libav/COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02"
-LICENSE_FLAGS = "commercial"
-HOMEPAGE = "http://www.gstreamer.net/"
-DEPENDS = "gstreamer gst-plugins-base zlib bzip2 yasm-native libpostproc"
-
-inherit autotools-brokensep pkgconfig
-
-SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2 \
-           file://lower-rank.diff \
-           file://configure-fix.patch \
-           file://h264_qpel_mmx.patch \
-           file://libav_e500mc.patch \
-           file://libav_e5500.patch \
-           file://gst-ffmpeg-CVE-2013-3674.patch \
-           file://0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch \
-           file://0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch \
-           file://0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch \
-           file://0001-huffyuvdec-Skip-len-0-cases.patch \
-           file://0001-huffyuvdec-Check-init_vlc-return-codes.patch \
-           file://0001-alsdec-check-block-length.patch \
-           file://0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch \
-           file://0001-atrac3dec-Check-coding-mode-against-channels.patch \
-           file://0001-eamad-fix-out-of-array-accesses.patch \
-           file://0001-mjpegdec-check-SE.patch \
-           file://0001-alac-fix-nb_samples-order-case.patch \
-           file://0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch \
-           file://0001-roqvideodec-check-dimensions-validity.patch \
-           file://0001-aacdec-check-channel-count.patch \
-           file://0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch \
-           file://0001-error_concealment-Check-that-the-picture-is-not-in-a.patch \
-           file://0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch \
-           file://0001-vp3-Copy-all-3-frames-for-thread-updates.patch \
-           file://0001-h264_sei-Fix-infinite-loop.patch \
-           file://0001-avcodec-parser-reset-indexes-on-realloc-failure.patch \
-           file://0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch \
-           file://gst-ffmpeg-CVE-2013-0855.patch \
-           file://0001-qdm2dec-fix-buffer-overflow.patch \
-           file://0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch \
-           file://0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch \
-           file://0001-error-concealment-initialize-block-index.patch \
-           file://0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch \
-           file://0001-lavf-compute-probe-buffer-size-more-reliably.patch \
-           file://0001-ffserver-set-oformat.patch \
-           file://0001-h264-set-parameters-from-SPS-whenever-it-changes.patch \
-           file://0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch \
-           file://0001-avcodec-smc-fix-off-by-1-error.patch \
-           file://0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch \
-           file://libav-9.patch \
-"
-
-SRC_URI[md5sum] = "7f5beacaf1312db2db30a026b36888c4"
-SRC_URI[sha256sum] = "76fca05b08e00134e3cb92fa347507f42cbd48ddb08ed3343a912def187fbb62"
-
-PR = "r8"
-
-GSTREAMER_DEBUG ?= "--disable-debug"
-
-FFMPEG_EXTRA_CONFIGURE = "--with-ffmpeg-extra-configure"
-# pass --cpu for powerpc. get cpu name by stripping "ppc" or "ppc64"
-# from DEFAULTTUNE
-FFMPEG_CPU_powerpc = "--cpu=${@d.getVar('DEFAULTTUNE')[3:]}"
-FFMPEG_CPU_powerpc64 = "--cpu=${@d.getVar('DEFAULTTUNE')[5:]}"
-FFMPEG_EXTRA_CONFIGURE_COMMON_ARG = "--target-os=linux ${FFMPEG_CPU} \
-  --cc='${CC}' --as='${CC}' --ld='${CC}' --nm='${NM}' --ar='${AR}' \
-  --ranlib='${RANLIB}' \
-  ${GSTREAMER_DEBUG}"
-FFMPEG_EXTRA_CONFIGURE_COMMON = \
-'${FFMPEG_EXTRA_CONFIGURE}="${FFMPEG_EXTRA_CONFIGURE_COMMON_ARG}"'
-
-EXTRA_OECONF = "${FFMPEG_EXTRA_CONFIGURE_COMMON}"
-
-PACKAGECONFIG ??= "external-libav"
-PACKAGECONFIG[external-libav] = "--with-system-ffmpeg,,libav"
-PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
-
-FILES_${PN} += "${libdir}/gstreamer-0.10/*.so"
-FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug"
-FILES_${PN}-dev += "${libdir}/gstreamer-0.10/*.la"
-FILES_${PN}-staticdev += "${libdir}/gstreamer-0.10/*.a"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.31.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.31.bb
deleted file mode 100644
index 1e2cd2a..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.31.bb
+++ /dev/null
@@ -1,14 +0,0 @@
-require gst-fluendo.inc
-
-SUMMARY = "Fluendo closed-format mp3 GStreamer plug-in"
-LICENSE = "MIT"
-LIC_FILES_CHKSUM = "file://COPYING;md5=259a43dd1c9854b71fc396f74699f4d2"
-LICENSE_FLAGS = "commercial"
-
-GSTREAMER_DEBUG ?= "--disable-debug"
-EXTRA_OECONF += "${GSTREAMER_DEBUG} --with-gstreamer-api=0.10"
-
-acpaths = "-I ${S}/common/m4 -I ${S}/m4"
-
-SRC_URI[md5sum] = "adf0390f3416bb72f91c358528be0c38"
-SRC_URI[sha256sum] = "dae0d0559a4e159c0dd92b7e18de059a5783f8d038904c7de4ca6393f7d55c7d"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.85.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.85.bb
deleted file mode 100644
index 7bba41a..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.85.bb
+++ /dev/null
@@ -1,12 +0,0 @@
-require gst-fluendo.inc
-
-SUMMARY = "Fluendo MPEG Transport Stream and Program Stream demuxer for GStreamer"
-LICENSE = "MPLv1.1"
-LIC_FILES_CHKSUM = "file://COPYING;md5=be282f1c3cc9a98cc0dc5c2b25dfc510 \
-                    file://src/gstmpegdemux.h;beginline=1;endline=19;md5=a9e90033f59897b91664d9f2a2ff01dd"
-LICENSE_FLAGS = "commercial"
-
-acpaths = "-I ${S}/common/m4 -I ${S}/m4"
-
-SRC_URI[md5sum] = "7c4fb993f80b9ae631b11897733f0970"
-SRC_URI[sha256sum] = "df04c91cc8e5d9a892c2492ed989974b4547beaa2a3647649e85113317897424"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo.inc b/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo.inc
deleted file mode 100644
index 7a77d62..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo.inc
+++ /dev/null
@@ -1,14 +0,0 @@
-SUMMARY = "Fluendo closed-format GStreamer plug-in"
-SECTION = "multimedia"
-HOMEPAGE = "https://core.fluendo.com/gstreamer/trac/wiki"
-DEPENDS = "gstreamer gst-plugins-base zlib"
-
-inherit autotools pkgconfig
-
-SRC_URI = "http://core.fluendo.com/gstreamer/src/${BPN}/${BPN}-${PV}.tar.bz2"
-
-FILES_${PN} += "${libdir}/gstreamer-0.10/*.so"
-FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug"
-FILES_${PN}-dev += "${libdir}/gstreamer-0.10/*.la ${libdir}/gstreamer-0.10/*.a"
-
-EXTRA_OECONF = "--disable-valgrind"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb
deleted file mode 100644
index 039abe1..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb
+++ /dev/null
@@ -1,73 +0,0 @@
-SUMMARY = "GStreamer package groups"
-LICENSE = "MIT"
-
-COMMERCIAL_PLUGINS = "${COMMERCIAL_AUDIO_PLUGINS} ${COMMERCIAL_VIDEO_PLUGINS}"
-DEPENDS_UGLY="${@'gst-plugins-ugly' if 'ugly' in COMMERCIAL_PLUGINS.split('-') else ''}"
-DEPENDS_BAD="${@'gst-plugins-bad' if 'bad' in COMMERCIAL_PLUGINS.split('-') else ''}"
-DEPENDS = "gstreamer gst-plugins-base gst-plugins-good ${DEPENDS_UGLY} ${DEPENDS_BAD}"
-
-LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
-                    file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
-
-
-PR = "r13"
-
-PACKAGES = "\
-    gst-meta-base \
-    gst-meta-x11-base \
-    gst-meta-audio \
-    gst-meta-debug \
-    gst-meta-video"
-
-ALLOW_EMPTY_gst-meta-base = "1"
-ALLOW_EMPTY_gst-meta-x11-base = "1"
-ALLOW_EMPTY_gst-meta-audio = "1"
-ALLOW_EMPTY_gst-meta-debug = "1"
-ALLOW_EMPTY_gst-meta-video = "1"
-
-RDEPENDS_gst-meta-base = "\
-    ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'gst-meta-x11-base', '', d)} \
-    gstreamer \
-    gst-plugins-base-playbin \
-    gst-plugins-base-decodebin \
-    gst-plugins-base-decodebin2 \
-    gst-plugins-base-gio \
-    gst-plugins-base-alsa \
-    gst-plugins-base-volume \
-    gst-plugins-base-audioconvert \
-    gst-plugins-base-audioresample \
-    gst-plugins-base-typefindfunctions \
-    gst-plugins-base-videoscale \
-    gst-plugins-base-ffmpegcolorspace \
-    gst-plugins-good-autodetect \
-    gst-plugins-good-souphttpsrc"
-
-RRECOMMENDS_gst-meta-x11-base = "\
-    gst-plugins-base-ximagesink \
-    gst-plugins-base-xvimagesink"
-
-RDEPENDS_gst-meta-audio = "\
-    gst-meta-base \
-    gst-plugins-base-vorbis \
-    gst-plugins-base-ogg \
-    gst-plugins-good-wavparse \
-    gst-plugins-good-flac \
-    ${COMMERCIAL_AUDIO_PLUGINS}"
-
-
-RDEPENDS_gst-meta-debug = "\
-    gst-meta-base \
-    gst-plugins-good-debug \
-    gst-plugins-base-audiotestsrc \
-    gst-plugins-base-videotestsrc"
-
-
-RDEPENDS_gst-meta-video = "\
-    gst-meta-base \
-    gst-plugins-good-avi \
-    gst-plugins-good-matroska \
-    gst-plugins-base-theora \
-    ${COMMERCIAL_VIDEO_PLUGINS}"
-
-RRECOMMENDS_gst-meta-video = "\
-    gst-meta-audio"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch
deleted file mode 100644
index 57a63b5..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-Upstream-Status: Pending
-
-Signed-off-by: Saul Wold <sgw@linux.intel.com>
-
-Index: gst-openmax-0.10.1/omx/gstomx.c
-===================================================================
---- gst-openmax-0.10.1.orig/omx/gstomx.c	2010-09-30 18:00:24.000000000 -0700
-+++ gst-openmax-0.10.1/omx/gstomx.c	2011-05-17 23:08:08.794535872 -0700
-@@ -238,7 +238,8 @@
-     const gchar *element_name = gst_structure_nth_field_name (element_table, i);
-     GstStructure *element = get_element_entry (element_name);
-     const gchar *type_name, *parent_type_name;
--    const gchar *component_name, *component_role, *library_name;
-+    const gchar *component_name, *library_name;
-+    const gchar __attribute__((__unused__)) *component_role;
-     GType type;
-     gint rank;
- 
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch
deleted file mode 100644
index 5965bba..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-Rename static functions that use GLib naming conventions as one of them
-(g_ptr_array_insert) has now been added to GLib.
-
-Upstream-Status: Pending
-Signed-off-by: Ross Burton <ross.burton@intel.com>
-
-diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
-index 423e441..579dbf5 100644
---- a/omx/gstomx_util.c
-+++ b/omx/gstomx_util.c
-@@ -85,7 +85,7 @@ static gboolean initialized;
-  */
- 
- static void
--g_ptr_array_clear (GPtrArray * array)
-+omx_g_ptr_array_clear (GPtrArray * array)
- {
-   guint index;
-   for (index = 0; index < array->len; index++)
-@@ -93,7 +93,7 @@ g_ptr_array_clear (GPtrArray * array)
- }
- 
- static void
--g_ptr_array_insert (GPtrArray * array, guint index, gpointer data)
-+omx_g_ptr_array_insert (GPtrArray * array, guint index, gpointer data)
- {
-   if (index + 1 > array->len) {
-     g_ptr_array_set_size (array, index + 1);
-@@ -394,7 +394,7 @@ g_omx_core_unload (GOmxCore * core)
-   }
- 
-   core_for_each_port (core, g_omx_port_free);
--  g_ptr_array_clear (core->ports);
-+  omx_g_ptr_array_clear (core->ports);
- }
- 
- static inline GOmxPort *
-@@ -418,7 +418,7 @@ g_omx_core_new_port (GOmxCore * core, guint index)
-   }
- 
-   port = g_omx_port_new (core, index);
--  g_ptr_array_insert (core->ports, index, port);
-+  omx_g_ptr_array_insert (core->ports, index, port);
- 
-   return port;
- }
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb
deleted file mode 100644
index 2e01579..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb
+++ /dev/null
@@ -1,35 +0,0 @@
-SUMMARY = "GStreamer plug-in for communication with OpenMAX IL components"
-DESCRIPTION = "GstOpenMAX is a GStreamer plug-in that allows \
-communication with OpenMAX Integration Layer (IL) components. OpenMAX \
-IL is an industry standard that provides an abstraction layer for \
-computer graphics, video, and sound routines."
-HOMEPAGE = "http://freedesktop.org/wiki/GstOpenMAX"
-DEPENDS = "gstreamer"
-RDEPENDS_${PN} = "libomxil"
-LICENSE = "LGPLv2.1"
-LICENSE_FLAGS = "commercial"
-LIC_FILES_CHKSUM = "file://COPYING;md5=fbc093901857fcd118f065f900982c24 \
-                    file://util/sem.h;beginline=1;endline=20;md5=accce5550d5583b839b441a0623f09fc"
-
-SRC_URI = "http://gstreamer.freedesktop.org/src/gst-openmax/gst-openmax-${PV}.tar.bz2 \
-           file://gcc_4.6.patch \
-           file://ptr-array.patch \
-           "
-
-inherit autotools pkgconfig
-
-# Tell configure that this isn't a development snapshot so we don't want
-# -Werror (hopefully fixed in 0.10.2)
-export GST_CVS="no"
-
-EXTRA_OECONF += "--disable-valgrind"
-
-PR = "r4"
-
-FILES_${PN} += "${libdir}/gstreamer-0.10/libgstomx.so"
-FILES_${PN}-dev += "${libdir}/gstreamer-0.10/libgstomx.la"
-FILES_${PN}-staticdev += "${libdir}/gstreamer-0.10/libgstomx.a"
-FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug/"
-
-SRC_URI[md5sum] = "4d0370bfe99dea20918c84347abadb4e"
-SRC_URI[sha256sum] = "9074d5a0591995133d19cfb15144f19664f902c1623f996595695cf2c2070e1f"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb
deleted file mode 100644
index 0f64871..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb
+++ /dev/null
@@ -1,50 +0,0 @@
-require gst-plugins.inc
-
-LICENSE = "GPLv2+ & LGPLv2+ & LGPLv2.1+ "
-LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
-                    file://gst/tta/filters.h;beginline=12;endline=29;md5=629b0c7a665d155a6677778f4460ec06 \
-                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
-                    file://gst/tta/crc32.h;beginline=12;endline=29;md5=71a904d99ce7ae0c1cf129891b98145c"
-
-DEPENDS += "gst-plugins-base"
-
-PR = "r4"
-
-inherit gettext gsettings
-
-EXTRA_OECONF += "--disable-experimental \
-                 --disable-sdl --disable-cdaudio --disable-directfb \
-                 --disable-vdpau --disable-apexsink"
-
-PACKAGECONFIG ??= "bzip curl \
-                   ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'rsvg', '', d)}"
-
-PACKAGECONFIG[bzip] = "--enable-bz2,--disable-bz2,bzip2"
-PACKAGECONFIG[curl] = "--enable-curl,--disable-curl,curl"
-PACKAGECONFIG[rsvg] = "--enable-rsvg,--disable-rsvg,librsvg,"
-PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
-PACKAGECONFIG[neon] = "--enable-neon,--disable-neon,neon"
-PACKAGECONFIG[mms] = "--enable-libmms,--disable-libmms,libmms"
-PACKAGECONFIG[cog] = "--enable-cog,--disable-cog,libpng"
-PACKAGECONFIG[faad] = "--enable-faad,--disable-faad,faad2"
-PACKAGECONFIG[jp2k] = "--enable-jp2k,--disable-jp2k,jasper"
-PACKAGECONFIG[modplug] = "--enable-modplug,--disable-modplug,libmodplug"
-PACKAGECONFIG[opus] = "--enable-opus,--disable-opus,libopus"
-PACKAGECONFIG[sndfile] = "--enable-sndfile,--disable-sndfile,libsndfile1"
-PACKAGECONFIG[vp8] = "--enable-vp8,--disable-vp8,libvpx"
-PACKAGECONFIG[ass] = "--enable-assrender,--disable-assrender,libass"
-PACKAGECONFIG[openal] = "--enable-openal,--disable-openal,openal-soft"
-PACKAGECONFIG[schro] = "--enable-schro,--disable-schro,schroedinger"
-PACKAGECONFIG[dc1394] = "--enable-dc1394,--disable-dc1394,libdc1394"
-PACKAGECONFIG[faac] = "--enable-faac,--disable-faac,faac"
-PACKAGECONFIG[rtmp] = "--enable-rtmp,--disable-rtmp,rtmpdump"
-
-ARM_INSTRUCTION_SET = "arm"
-
-do_configure_prepend() {
-	# This m4 file contains nastiness which conflicts with libtool 2.2.2
-	rm ${S}/m4/lib-link.m4 || true
-}
-
-SRC_URI[md5sum] = "fcb09798114461955260e4d940db5987"
-SRC_URI[sha256sum] = "0eae7d1a1357ae8377fded6a1b42e663887beabe0e6cc336e2ef9ada42e11491"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
deleted file mode 100644
index 5214256..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-audioresample: Fix build on x86 if emmintrin.h is available but can't be used
-
-On x86, EMMINTRIN is defined but not usable without SSE so check for
-__SSE__ and __SSE2__ as well.
-
-https://bugzilla.gnome.org/show_bug.cgi?id=670690
-
-Upstream-Status: Backport
-
-Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
----
- gst/audioresample/resample.c |    4 ++--
- 1 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/gst/audioresample/resample.c b/gst/audioresample/resample.c
-index 98d006c..481fa01 100644
---- a/gst/audioresample/resample.c
-+++ b/gst/audioresample/resample.c
-@@ -77,13 +77,13 @@
- #define EXPORT G_GNUC_INTERNAL
- 
- #ifdef _USE_SSE
--#ifndef HAVE_XMMINTRIN_H
-+#if !defined(__SSE__) || !defined(HAVE_XMMINTRIN_H)
- #undef _USE_SSE
- #endif
- #endif
- 
- #ifdef _USE_SSE2
--#ifndef HAVE_EMMINTRIN_H
-+#if !defined(__SSE2__) || !defined(HAVE_EMMINTRIN_H)
- #undef _USE_SSE2
- #endif
- #endif
--- 
-1.7.1
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
deleted file mode 100644
index b8602c8..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-Upstream-Status: Submitted [similar patch by other author, bugzilla]
-Bugtracker-URL: https://bugzilla.gnome.org/show_bug.cgi?id=663600
-
-Prepend PKG_CONFIG_SYSROOT to includedir, so configure doesn't
-search for gstconfig.h in /usr/include.
-
-Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
----
- configure.ac |    2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
-
-diff --git a/configure.ac b/configure.ac
-index 1901bcf..460fb0a 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -435,7 +435,7 @@ AG_GST_CHECK_PLUGIN(volume)
- dnl check for gstreamer core features (subsystems)
- dnl FIXME: this assumes srcdir == builddir for uninstalled setups
- GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-0.10`"/gst/gstconfig.h"
--AG_GST_PARSE_SUBSYSTEM_DISABLES($GST_CONFIGPATH)
-+AG_GST_PARSE_SUBSYSTEM_DISABLES($PKG_CONFIG_SYSROOT_DIR$GST_CONFIGPATH)
- AM_CONDITIONAL(USE_XML, test $GST_DISABLE_XML != "1")
- 
- dnl disable plug-ins that require libxml2's HTML support if it is not available
--- 
-1.7.5.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
deleted file mode 100644
index 99dbc9d..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-Remove -DTREMOR option since Tremor has dropped its internal
-libogg2, and gst-plugins-base has dependency on that.
-
-Upstream-Status: Inappropriate [configuration]
-
-Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
-Signed-off-by: Shane Wang <shane.wang@intel.com>
-
-diff -r 70065fb4e085 ext/vorbis/Makefile.am
---- a/ext/vorbis/Makefile.am	Tue Mar 13 16:36:56 2012 +0800
-+++ b/ext/vorbis/Makefile.am	Tue Mar 13 16:38:53 2012 +0800
-@@ -30,7 +30,7 @@
- 	gstvorbisdec.c gstvorbisdeclib.c gstvorbiscommon.c
- libgstivorbisdec_la_CFLAGS = \
- 	$(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \
--	-DTREMOR $(IVORBIS_CFLAGS)
-+	$(IVORBIS_CFLAGS)
- libgstivorbisdec_la_LIBADD = \
- 	$(top_builddir)/gst-libs/gst/tag/libgsttag-@GST_MAJORMINOR@.la \
- 	$(top_builddir)/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la \
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb
deleted file mode 100644
index c8a9499..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb
+++ /dev/null
@@ -1,39 +0,0 @@
-require gst-plugins.inc
-
-LICENSE = "GPLv2+ & LGPLv2+"
-LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
-                    file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=622921ffad8cb18ab906c56052788a3f \
-                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
-                    file://gst/ffmpegcolorspace/utils.c;beginline=1;endline=20;md5=9c83a200b8e597b26ca29df20fc6ecd0"
-
-DEPENDS += "alsa-lib liboil libogg libvorbis libtheora util-linux tremor glib-2.0-native"
-
-SRC_URI += "file://gst-plugins-base-tremor.patch \
-            file://configure.ac-fix-subparse-plugin.patch \
-            file://audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch \
-"
-
-SRC_URI[md5sum] = "776c73883e567f67b9c4a2847d8d041a"
-SRC_URI[sha256sum] = "2cd3b0fa8e9b595db8f514ef7c2bdbcd639a0d63d154c00f8c9b609321f49976"
-
-PR = "r8"
-
-inherit gettext
-
-EXTRA_OECONF += "--disable-freetypetest"
-
-PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}"
-
-PACKAGECONFIG[gnomevfs] = "--enable-gnome_vfs,--disable-gnome_vfs,gnome-vfs"
-PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
-PACKAGECONFIG[pango] = "--enable-pango,--disable-pango,pango"
-PACKAGECONFIG[x11] = "--enable-x --enable-xvideo,--disable-x --disable-xvideo,virtual/libx11 libxv libsm libice"
-
-do_configure_prepend() {
-	# This m4 file contains nastiness which conflicts with libtool 2.2.2
-	rm -f ${S}/m4/lib-link.m4
-}
-
-FILES_${PN} += "${datadir}/${BPN}"
-
-CACHED_CONFIGUREVARS_append_i586 = " ac_cv_header_emmintrin_h=no ac_cv_header_xmmintrin_h=no"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
deleted file mode 100644
index bc2f88b..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 14d51cbefef19737e7ab2b6818ee1d3bdb248d12 Mon Sep 17 00:00:00 2001
-From: Jeremy Stashluk <jstashluk@dekaresearch.com>
-Date: Wed, 6 Feb 2013 09:59:48 -0500
-Subject: [PATCH] conditional gl framebuffer undefined use
-
-The OpenGL extension GL_ARB_framebuffer_object defines the macro
-GL_FRAMEBUFFER_UNDEFINED. The macro will only need to map to an error
-string if the extension provides functions that might return the macro.
-
-Upstream-Status: Pending
-
-Signed-off-by: Jeremy Stashluk <jstashluk@dekaresearch.com>
----
- gst-libs/gst/gl/gstgldisplay.c |    2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c
-index 3ed0b71..64c6c2c 100644
---- a/gst-libs/gst/gl/gstgldisplay.c
-+++ b/gst-libs/gst/gl/gstgldisplay.c
-@@ -2177,9 +2177,11 @@ gst_gl_display_check_framebuffer_status (void)
-       GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
-       break;
- 
-+#if defined(GL_ARB_framebuffer_object)
-     case GL_FRAMEBUFFER_UNDEFINED:
-       GST_ERROR ("GL_FRAMEBUFFER_UNDEFINED");
-       break;
-+#endif
- 
-     default:
-       GST_ERROR ("General FBO error");
--- 
-1.7.9.5
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb
deleted file mode 100644
index 90efbcc..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb
+++ /dev/null
@@ -1,25 +0,0 @@
-require recipes-multimedia/gstreamer/gst-plugins.inc
-
-LICENSE = "GPLv2+ & LGPLv2+ & LGPLv2.1+ "
-LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605"
-
-SRC_URI[md5sum] = "ac70ede13f79978d56eaed8abaa3c938"
-SRC_URI[sha256sum] = "48340b6a4b8abce16344a7bc33e74a94fdcce4f57ef6342cdf2f941c429bf210"
-
-SRC_URI += " file://0001-conditional-gl-framebuffer-undefined-use.patch"
-
-DEPENDS += "gst-plugins-base virtual/libgles2 virtual/egl jpeg libpng glew"
-
-PR = "r4"
-
-inherit gettext
-
-# This package doesn't have a configure switch for EGL or GL, so forcibly tell
-# configure that it can't find gl.h so it always uses EGL.  If/when we have some
-# way for machines to specify their preferred GL flavour this can be
-# automatically adapted.
-EXTRA_OECONF += "ac_cv_header_GL_gl_h=no"
-
-ALLOW_EMPTY_${PN} = "1"
-ALLOW_EMPTY_${PN}-apps = "1"
-ALLOW_EMPTY_${PN}-glib = "1"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
deleted file mode 100644
index 6456d3c..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 12d18fe4e98e7c232d59b56d529a0521f293fe6d Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com>
-Date: Wed, 5 Sep 2012 18:54:42 +0200
-Subject: [PATCH] v4l2: fix build with recent kernels, the v4l2_buffer input
- field was removed
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Upstream-Status: Backport
-
-[1] http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=9f2aa8d47f835ea155aaf635f618c0fc1ca87012
-
-Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
----
- sys/v4l2/gstv4l2bufferpool.c |    1 -
- 1 files changed, 0 insertions(+), 1 deletions(-)
-
-diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c
-index b81c6a4..51cc0ce 100644
---- a/sys/v4l2/gstv4l2bufferpool.c
-+++ b/sys/v4l2/gstv4l2bufferpool.c
-@@ -181,7 +181,6 @@ gst_v4l2_buffer_new (GstV4l2BufferPool * pool, guint index, GstCaps * caps)
-     GST_LOG_OBJECT (pool->v4l2elem, "  MMAP offset:  %u",
-         ret->vbuffer.m.offset);
-   GST_LOG_OBJECT (pool->v4l2elem, "  length:    %u", ret->vbuffer.length);
--  GST_LOG_OBJECT (pool->v4l2elem, "  input:     %u", ret->vbuffer.input);
- 
-   data = (guint8 *) v4l2_mmap (0, ret->vbuffer.length,
-       PROT_READ | PROT_WRITE, MAP_SHARED, pool->video_fd,
--- 
-1.7.6.5
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
deleted file mode 100644
index bd0de58..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-From ccb01de8096a32d86d47b0d92ec3416c57ee4d25 Mon Sep 17 00:00:00 2001
-From: Bruce Ashfield <bruce.ashfield@windriver.com>
-Date: Thu, 22 Aug 2013 12:15:54 -0400
-Subject: [PATCH] v4l2_calls: define V4L2_CID_HCENTER and V4L2_CID_VCENTER
-
-kernel commit 24b9f5017 [[media] V4L: Remove deprecated image centering controls]
-removed the definitions of V4L2_CID_HCENTER and V4L2_CID_VCENTER after three
-years of depreciation.
-
-The ioctl values are still free, and the case statement which processess them
-in v4l2 userspace falls through to the proper replacement. So in the short
-term, we can explicitly define them using the old absolute values, and everything
-will work.
-
-Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
----
- sys/v4l2/v4l2_calls.c |    9 +++++++--
- 1 file changed, 7 insertions(+), 2 deletions(-)
-
-diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c
-index 309bfb6..3c64544 100644
---- a/sys/v4l2/v4l2_calls.c
-+++ b/sys/v4l2/v4l2_calls.c
-@@ -54,11 +54,16 @@
- #include "gst/gst-i18n-plugin.h"
- 
- /* Those are ioctl calls */
-+
-+/* V4L2_CID_HCENTER has been removed from the mainline kernel, but
-+   the ioctl space is still present. Since these values fall through
-+   to their replacement, it is safe (in the short term) to re-use the
-+    old values explictily */
- #ifndef V4L2_CID_HCENTER
--#define V4L2_CID_HCENTER V4L2_CID_HCENTER_DEPRECATED
-+#define V4L2_CID_HCENTER V4L2_CID_BASE+22
- #endif
- #ifndef V4L2_CID_VCENTER
--#define V4L2_CID_VCENTER V4L2_CID_VCENTER_DEPRECATED
-+#define V4L2_CID_VCENTER V4L2_CID_BASE+23
- #endif
- 
- GST_DEBUG_CATEGORY_EXTERN (v4l2_debug);
--- 
-1.7.10.4
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
deleted file mode 100644
index 48b8e98..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From ce94b2c2b91b6db190c121860e12a6afafce7ae1 Mon Sep 17 00:00:00 2001
-From: Roland Krikava <rkrikava@gmail.com>
-Date: Fri, 2 Nov 2012 12:38:44 -0400
-Subject: [PATCH 407/440] mulawdec: fix integer overrun
-
-There might be more than 65535 samples in a chunk of data.
-
-https://bugzilla.gnome.org/show_bug.cgi?id=687469
-
-Commit - 3be45f70220310ec1c60d819f90b5f2ae03b5d83 in 0.10 branch
-
-Upstream Status:  Backported
-
-Signed-off-by: Roland Krikava <rkrikava@gmail.com>
----
- gst/law/mulaw-conversion.c |    6 ++++--
- 1 file changed, 4 insertions(+), 2 deletions(-)
-
-diff --git a/gst/law/mulaw-conversion.c b/gst/law/mulaw-conversion.c
-index 8afae80..190a9f5 100644
---- a/gst/law/mulaw-conversion.c
-+++ b/gst/law/mulaw-conversion.c
-@@ -51,9 +51,10 @@ mulaw_encode (gint16 * in, guint8 * out, gint numsamples)
-     7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-     7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
-   };
--  gint16 sign, exponent, mantissa, i;
-+  gint16 sign, exponent, mantissa;
-   gint16 sample;
-   guint8 ulawbyte;
-+  gint i;
- 
-   for (i = 0; i < numsamples; i++) {
-     sample = in[i];
-@@ -102,7 +103,8 @@ mulaw_decode (guint8 * in, gint16 * out, gint numsamples)
-   static gint16 exp_lut[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 };
-   gint16 sign, exponent, mantissa;
-   guint8 ulawbyte;
--  gint16 linear, i;
-+  gint16 linear;
-+  gint i;
- 
-   for (i = 0; i < numsamples; i++) {
-     ulawbyte = in[i];
--- 
-1.7.9.5
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb
deleted file mode 100644
index af18281..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb
+++ /dev/null
@@ -1,47 +0,0 @@
-require gst-plugins.inc
-
-LICENSE = "GPLv2+ & LGPLv2.1+"
-LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
-                    file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=622921ffad8cb18ab906c56052788a3f \
-                    file://gst/replaygain/rganalysis.c;beginline=1;endline=23;md5=b60ebefd5b2f5a8e0cab6bfee391a5fe"
-
-PR = "r8"
-
-PACKAGECONFIG ?= "jpeg v4l \
-    ${@bb.utils.contains('DISTRO_FEATURES', 'pulseaudio', 'pulseaudio', '', d)} \
-    ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)} \
-"
-PACKAGECONFIG[pulseaudio] = "--enable-pulse,--disable-pulse,pulseaudio"
-PACKAGECONFIG[jack] = "--enable-jack,--disable-jack,jack"
-PACKAGECONFIG[jpeg] = "--enable-jpeg,--disable-jpeg,jpeg"
-PACKAGECONFIG[wavpack] = "--enable-wavpack,--disable-wavpack,wavpack"
-PACKAGECONFIG[gdkpixbuf] = "--enable-gdk_pixbuf,--disable-gdk_pixbuf,gdk-pixbuf"
-PACKAGECONFIG[v4l] = "--enable-gst_v4l2 --with-gudev,--disable-gst_v4l2 --without-gudev,udev"
-# sub-feature of v4l, but control separately since libv4l is not part of oe-core
-PACKAGECONFIG[libv4l] = "--with-libv4l2,--without-libv4l2,libv4l"
-PACKAGECONFIG[bzip2] = "--enable-bz2,--disable-bz2,bzip2"
-PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
-PACKAGECONFIG[x11] = "--enable-x,--disable-x,virtual/libx11 libxfixes libxdamage"
-
-DEPENDS += "gst-plugins-base gconf cairo libpng zlib libid3tag flac \
-            speex libsoup-2.4 libcap"
-
-inherit gettext gconf
-
-SRC_URI += "file://0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch \
-            file://0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch \
-            file://0407-mulawdec-fix-integer-overrun.patch \
-"
-EXTRA_OECONF += "--disable-aalib --disable-esd --disable-shout2 --disable-libcaca --disable-hal \
-                 --disable-examples --disable-taglib"
-
-do_configure_prepend() {
-	# This m4 file contains nastiness which conflicts with libtool 2.2.2
-	rm ${S}/m4/lib-link.m4 || true
-}
-
-SRC_URI[md5sum] = "24f98a294a2b521e1b29412bdadae2e6"
-SRC_URI[sha256sum] = "7e27840e40a7932ef2dc032d7201f9f41afcaf0b437daf5d1d44dc96d9e35ac6"
-
-FILES_${PN}-gconfelements += "${sysconfdir}/gconf/schemas/gstreamer-0.10.schemas"
-FILES_${PN}-equalizer += "${datadir}/gstreamer-0.10/presets/*.prs"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb
deleted file mode 100644
index 2fdf03f..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb
+++ /dev/null
@@ -1,29 +0,0 @@
-require gst-plugins.inc
-
-LICENSE = "GPLv2+ & LGPLv2.1+ & LGPLv2+"
-LICENSE_FLAGS = "commercial"
-LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
-                    file://gst/synaesthesia/synaescope.h;beginline=1;endline=20;md5=99f301df7b80490c6ff8305fcc712838 \
-                    file://tests/check/elements/xingmux.c;beginline=1;endline=21;md5=4c771b8af188724855cb99cadd390068 \
-                    file://gst/mpegstream/gstmpegparse.h;beginline=1;endline=18;md5=ff65467b0c53cdfa98d0684c1bc240a9"
-
-DEPENDS += "gst-plugins-base libid3tag libmad mpeg2dec liba52 lame"
-PR = "r3"
-
-inherit gettext
-
-EXTRA_OECONF += "--with-plugins=a52dec,lame,id3tag,mad,mpeg2dec,mpegstream,mpegaudioparse,asfdemux,realmedia \
-                 --disable-orc"
-
-PACKAGECONFIG ??= ""
-PACKAGECONFIG[x264] = "--enable-x264,--disable-x264,x264"
-PACKAGECONFIG[cdio] = "--enable-cdio,--disable-cdio,libcdio"
-PACKAGECONFIG[dvdread] = "--enable-dvdread,--disable-dvdread,libdvdread"
-
-do_configure_prepend() {
-	# This m4 file contains nastiness which conflicts with libtool 2.2.2
-	rm ${S}/m4/lib-link.m4 || true
-}
-
-SRC_URI[md5sum] = "1d81c593e22a6cdf0f2b4f57eae93df2"
-SRC_URI[sha256sum] = "1ca90059275c0f5dca71d4d1601a8f429b7852baed0723e820703b977e2c8df0"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc
deleted file mode 100644
index c852c53..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc
+++ /dev/null
@@ -1,28 +0,0 @@
-SUMMARY = "Plugins for the GStreamer multimedia framework"
-HOMEPAGE = "http://gstreamer.freedesktop.org/"
-BUGTRACKER = "https://bugzilla.gnome.org/enter_bug.cgi?product=Gstreamer"
-SECTION = "multimedia"
-DEPENDS = "gstreamer"
-
-inherit autotools pkgconfig
-
-SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2"
-
-GSTREAMER_DEBUG ?= "--disable-debug"
-EXTRA_OECONF = "--disable-valgrind ${GSTREAMER_DEBUG} --disable-examples "
-
-acpaths = "-I ${S}/common/m4 -I ${S}/m4"
-
-LIBV = "0.10"
-require gst-plugins-package.inc
-
-PACKAGES_DYNAMIC += "^${PN}-.*"
-
-# apply gstreamer hack after Makefile.in.in in source is replaced by our version from
-# ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in, but before configure is executed
-# http://lists.linuxtogo.org/pipermail/openembedded-core/2012-November/032233.html
-oe_runconf_prepend() {
-	if [ -e ${S}/po/Makefile.in.in ]; then
-		sed -i -e "1a\\" -e 'GETTEXT_PACKAGE = @GETTEXT_PACKAGE@' ${S}/po/Makefile.in.in
-	fi
-}
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
deleted file mode 100644
index 3afca4e..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-index gst-rtsp_0.10.8/bindings/python/Makefile.am
---- gst-rtsp_0.10.8.orig/bindings/python/Makefile.am
-+++ gst-rtsp_0.10.8/bindings/python/Makefile.am
-@@ -14,7 +14,7 @@ defs_DATA = $(DEFS)
- defsdir = $(pkgdatadir)/$(GST_MAJORMINOR)/defs
- OVERRIDES = rtspserver.override
-
--INCLUDES = -I$(top_srcdir) -I$(srcdir) $(PYTHON_INCLUDES)
-+AM_CPPFLAGS = -I$(top_srcdir) -I$(srcdir) $(PYTHON_INCLUDES)
-
- rtspserver_la_CFLAGS = -I$(top_srcdir)/src \
-         $(PYGOBJECT_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
-index gst-rtsp_0.10.8/examples/Makefile.am
---- gst-rtsp_0.10.8.orig/examples/Makefile.am
-+++ gst-rtsp_0.10.8/examples/Makefile.am
-@@ -1,6 +1,6 @@
- noinst_PROGRAMS = test-video test-ogg test-mp4 test-readme test-launch test-sdp test-uri test-auth
-
--INCLUDES = -I$(top_srcdir) -I$(srcdir)
-+AM_CPPFLAGS = -I$(top_srcdir) -I$(srcdir)
-
- AM_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
- AM_LDFLAGS = \
-index gst-rtsp_0.10.8/tests/Makefile.am
---- gst-rtsp_0.10.8.orig/tests/Makefile.am
-+++ gst-rtsp_0.10.8/tests/Makefile.am
-@@ -1,6 +1,6 @@
- noinst_PROGRAMS = test-cleanup
-
--INCLUDES = -I$(top_srcdir) -I$(srcdir)
-+AM_CPPFLAGS = -I$(top_srcdir) -I$(srcdir)
-
- AM_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
- AM_LDFLAGS = \
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp_0.10.8.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp_0.10.8.bb
deleted file mode 100644
index 9318656..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp_0.10.8.bb
+++ /dev/null
@@ -1,16 +0,0 @@
-SUMMARY = "GStreamer RTSP server"
-LICENSE = "LGPLv2+"
-LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605"
-
-SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2 \
-           file://0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch"
-SRC_URI[md5sum] = "b511af07000595f63c3a705946221643"
-SRC_URI[sha256sum] = "9915887cf8515bda87462c69738646afb715b597613edc7340477ccab63a6617"
-
-DEPENDS = "gst-plugins-base gstreamer"
-
-# Configure always checks for Python so inherit pythonnative. Better solution
-# would be to disable the checks entirely.
-inherit autotools pythonnative gettext
-
-FILES_${PN}-dev += "${datadir}/vala/vapi/"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
deleted file mode 100644
index d077496..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From ed7f4802222234eef192aa3f74bc92268f338f97 Mon Sep 17 00:00:00 2001
-From: Sebastian Droege <sebastian.droege@collabora.co.uk>
-Date: Tue, 6 Mar 2012 12:28:02 +0100
-Subject: [PATCH] baseparse: Fix 'self-comparison always evaluates to true'
-
-This was really a bug.
-
-Commit is ed7f4802222234eef192aa3f74bc92268f338f97 in 0.10 branch
-
-Upstream Status:  Backported
-
-Signed-off-by: Sebastian Droege <sebastian.droege@collabora.co.uk>
----
- libs/gst/base/gstbaseparse.c |    2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c
-index 851ec1d..108ee89 100644
---- a/libs/gst/base/gstbaseparse.c
-+++ b/libs/gst/base/gstbaseparse.c
-@@ -3899,7 +3899,7 @@ gst_base_parse_handle_seek (GstBaseParse * parse, GstEvent * event)
-        seek event (in bytes) to upstream. Segment / flush handling happens
-        in corresponding src event handlers */
-     GST_DEBUG_OBJECT (parse, "seek in PUSH mode");
--    if (seekstop >= 0 && seekpos <= seekpos)
-+    if (seekstop >= 0 && seekstop <= seekpos)
-       seekstop = seekpos;
-     new_event = gst_event_new_seek (rate, GST_FORMAT_BYTES, flags,
-         GST_SEEK_TYPE_SET, seekpos, stop_type, seekstop);
--- 
-1.7.9.5
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch
deleted file mode 100644
index 5d8bb13..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-# gstreamer: Fix a problem with configure if check has already been built
-# Richard Purdie <rpurdie@linux.intel.com>
-
-Upstream-Status: Inappropriate [configuration]
-
-diff -urN gstreamer-0.10.29-orig/configure.ac gstreamer-0.10.29/configure.ac
---- gstreamer-0.10.29-orig/configure.ac	2010-06-26 12:49:27.774930773 +0800
-+++ gstreamer-0.10.29/configure.ac	2010-06-26 12:51:12.899200233 +0800
-@@ -543,8 +543,10 @@
-       *) BUILD_CHECK=yes ;;
-     esac
- ])
-+
- dnl bit of a misnomer, but keep the conditional named like this so we don't
- dnl have to change too much elsewhere
-+HAVE_CHECK=no
- AM_CONDITIONAL(HAVE_CHECK, test "x$BUILD_CHECK" = "xyes")
- 
- dnl configure the desired buffer alignment
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch
deleted file mode 100644
index 30be85f..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-# Fix crash with gst-inspect
-# Chris Lord <chris@openedhand.com>
-
-Upstream-Status: Pending
-
---- gstreamer-0.10.9/tools/gst-inspect.c.old	2006-09-12 11:56:53.000000000 +0100
-+++ gstreamer-0.10.9/tools/gst-inspect.c	2006-09-12 11:57:27.000000000 +0100
-@@ -1123,7 +1123,7 @@
-   g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
-   g_option_context_add_group (ctx, gst_init_get_option_group ());
-   if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
--    g_print ("Error initializing: %s\n", err->message);
-+    g_print ("Error initializing: %s\n", err ? err->message : "(null)");
-     exit (1);
-   }
-   g_option_context_free (ctx);
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
deleted file mode 100644
index bf93cb2..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-gstreamer: change priv_gst_parse_yylex arguments
-
-Change priv_gst_parse_yylex to fit new bison version, else we will
-get following error:
-
-| grammar.tab.c: In function 'priv_gst_parse_yyparse':
-| grammar.tab.c:67:25: error: too few arguments to function 'priv_gst_parse_yylex'
-|  #define yylex           priv_gst_parse_yylex
-|                          ^
-
-Upstream-Status: Pending
-
-Signed-off-by: Chong Lu <Chong.Lu@windriver.com>
----
- gst/parse/grammar.y | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/gst/parse/grammar.y b/gst/parse/grammar.y
-index 24fc87b..24fe906 100644
---- a/gst/parse/grammar.y
-+++ b/gst/parse/grammar.y
-@@ -36,7 +36,7 @@
- 
- typedef void* yyscan_t;
- 
--int priv_gst_parse_yylex (void * yylval_param , yyscan_t yyscanner);
-+int priv_gst_parse_yylex (yyscan_t yyscanner);
- int priv_gst_parse_yylex_init (yyscan_t scanner);
- int priv_gst_parse_yylex_destroy (yyscan_t scanner);
- struct yy_buffer_state * priv_gst_parse_yy_scan_string (char* , yyscan_t);
--- 
-1.9.1
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c
deleted file mode 100644
index c1f3e71..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c
+++ /dev/null
@@ -1,487 +0,0 @@
-/* GStreamer
- * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
- *                    2000 Wim Taymans <wtay@chello.be>
- *                    2005 David A. Schleef <ds@schleef.org>
- *
- * gstregistryxml.c: GstRegistry object, support routines
- *
- * This library is free software; you can redistribute it and/or
- * modify it ulnder 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.
- */
-
-
-#include <gst/gstregistrybinary.h>
-
-/*
-** Simple handy function to write a memory location to the registry cache file
-*/
-inline static gboolean
-gst_registry_binary_write(GstRegistry *registry, const void *mem, const ssize_t size)
-{
-  if (write(registry->cache_file, mem, size) != size)
-    {
-      GST_ERROR("Failed to write binary registry element: ptr=%p size=%u error=%s\n",
-		mem, size, strerror(errno));
-      return FALSE;
-    }
-  return TRUE;
-}
-
-/*
-** Save features GstBinary style
-*/
-static gboolean 
-gst_registry_binary_fill_feature(GList **list, GstPluginFeature *orig, GstBinaryPluginFeature *dest, const char *name)
-{
-  GstBinaryChunck *chk;
-
-  if ((chk = calloc(1, sizeof (GstBinaryChunck))) == NULL)
-    return FALSE;
-
-  chk->data = dest;
-  chk->size = sizeof (GstBinaryPluginFeature);
-
-  *list = g_list_append(*list, chk);
-
-  dest->rank = orig->rank;
-  if (!strncpy(dest->typename, name, GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN) ||
-      !strncpy(dest->name, orig->name, GST_BINARY_REGISTRY_TYPENAME_NAME_LEN))
-    {
-      GST_ERROR("Failed to write binary registry feature");
-      goto fail;
-    }
-  
-  if (GST_IS_ELEMENT_FACTORY(orig))
-    {
-      GstElementFactory *factory = GST_ELEMENT_FACTORY(orig);
-      
-      if (!strncpy(dest->longname, factory->details.longname, GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN) ||
-	  !strncpy(dest->class, factory->details.klass, GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN) ||
-	  !strncpy(dest->description, factory->details.description, GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN) ||
-	  !strncpy(dest->author, factory->details.author, GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN))
-	{
-	  GST_ERROR("Failed to write binary registry feature");
-	  goto fail;
-	}
-    }
-  
-  dest->npadtemplates = dest->ninterfaces = dest->nuritypes = 0;
-  return TRUE;
-
- fail:
-  free(chk);
-  return FALSE;
-}
-
-
-/*
-** Initialize the GstBinaryRegistryMagic, setting both our magic number and gstreamer major/minor version
-*/
-inline static gboolean
-gst_registry_binary_initialize_magic(GstBinaryRegistryMagic *m)
-{
-  if (!strncpy(m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) ||
-      !strncpy(m->version, GST_MAJORMINOR, GST_BINARY_REGISTRY_VERSION_LEN))
-    {
-      GST_ERROR("Failed to write magic to the registry magic structure");
-      return FALSE;
-    }
-  return TRUE;
-}
-
-/*
-** Check GstBinaryRegistryMagic validity.
-** Return a pointer pointing right after the magic structure
-*/
-static gchar *
-gst_registry_binary_check_magic(gchar *in)
-{
-  GstBinaryRegistryMagic *m = (GstBinaryRegistryMagic *) in;
-
-  if (m == NULL || m->magic == NULL || m->version == NULL)
-    {
-      GST_ERROR("Binary registry magic structure is broken");
-      return NULL;
-    }
-  if (strncmp(m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) != 0)
-    {
-      GST_ERROR("Binary registry magic is different : %02x%02x%02x%02x != %02x%02x%02x%02x",
-		GST_MAGIC_BINARY_REGISTRY_STR[0] & 0xff, GST_MAGIC_BINARY_REGISTRY_STR[1] & 0xff,
-		GST_MAGIC_BINARY_REGISTRY_STR[2] & 0xff, GST_MAGIC_BINARY_REGISTRY_STR[3] & 0xff,
-		m->magic[0] & 0xff, m->magic[1] & 0xff, m->magic[2] & 0xff, m->magic[3] & 0xff);
-      return NULL;
-    }
-  if (strncmp(m->version, GST_MAJORMINOR, GST_BINARY_REGISTRY_VERSION_LEN))
-    {
-      GST_ERROR("Binary registry magic version is different : %s != %s",
-		GST_MAJORMINOR, m->version);
-      return NULL;
-    }
-  return (in + sizeof (GstBinaryRegistryMagic));
-}
-
-/*
-** Adapt a GstPlugin to our GstBinaryPluginElement structure, and write it to the 
-** registry file.
-*/   
-static gboolean
-gst_registry_binary_save_plugin(GList **list, GstRegistry *registry, GstPlugin *plugin)
-{
-  GstBinaryPluginElement *e;
-  GstBinaryChunck *chk;
-  GList *walk;
-
-  if ((e = calloc(1, sizeof (GstBinaryPluginElement))) == NULL ||
-      (chk = calloc(1, sizeof (GstBinaryChunck))) == NULL)
-    return FALSE;
-
-  chk->data = e;
-  chk->size = sizeof (GstBinaryPluginElement);
-  *list = g_list_append(*list, chk);
-
-  if (!strncpy(e->name, plugin->desc.name, GST_BINARY_REGISTRY_NAME_LEN)		       	||
-      !strncpy(e->description, plugin->desc.description, GST_BINARY_REGISTRY_DESCRIPTION_LEN)	||
-      !strncpy(e->filename, plugin->filename, _POSIX_PATH_MAX)					||
-      !strncpy(e->version, plugin->desc.version, GST_BINARY_REGISTRY_VERSION_LEN)		||
-      !strncpy(e->license, plugin->desc.license, GST_BINARY_REGISTRY_LICENSE_LEN)		||
-      !strncpy(e->source, plugin->desc.source, GST_BINARY_REGISTRY_SOURCE_LEN)			||
-      !strncpy(e->package, plugin->desc.package, GST_BINARY_REGISTRY_PACKAGE_LEN)		||
-      !strncpy(e->origin, plugin->desc.origin, GST_BINARY_REGISTRY_ORIGIN_LEN))
-    {
-      GST_DEBUG("Can't adapt GstPlugin to GstBinaryPluginElement");
-      goto fail;
-    }
-
-  e->size = plugin->file_size;
-  e->m32p = plugin->file_mtime;
-  
-  GList *ft_list = gst_registry_get_feature_list_by_plugin(registry, plugin->desc.name);
-
-  for (walk = ft_list; walk; walk = g_list_next(walk), e->nfeatures++)
-    {
-      GstPluginFeature *curfeat = GST_PLUGIN_FEATURE (walk->data);
-      GstBinaryPluginFeature *newfeat;
-      const char *feat_name = g_type_name(G_OBJECT_TYPE(curfeat));
-      
-      if ((newfeat = calloc(1, sizeof (GstBinaryPluginFeature))) == NULL)
-	  goto fail;
-
-      if (!feat_name || !gst_registry_binary_fill_feature(list, curfeat, newfeat, feat_name))
-	{
-	  GST_ERROR("Can't fill plugin feature, aborting.");
-	  goto fail;
-	}
-    }
-
-  GST_DEBUG("Found %d features in plugin \"%s\"\n", e->nfeatures, e->name);
-  return TRUE;
-
- fail:
-  free(chk);
-  free(e);
-  return FALSE;
-}
-
-/*
-** Write the cache to file. Part of the code was taken from gstregistryxml.c
-*/
-gboolean 
-gst_registry_binary_write_cache(GstRegistry *registry, const char *location)
-{
-  GList *walk;
-  char *tmp_location;
-  GstBinaryRegistryMagic *magic;
-  GstBinaryChunck *magic_chunck;
-  GList *to_write = NULL;
- 
-  GST_INFO("Writing binary registry cache");
-
-  g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
-  tmp_location = g_strconcat (location, ".tmpXXXXXX", NULL);
-  registry->cache_file = g_mkstemp (tmp_location);
-  if (registry->cache_file == -1)
-    {
-      char *dir;
-
-      /* oops, I bet the directory doesn't exist */
-      dir = g_path_get_dirname (location);
-      g_mkdir_with_parents (dir, 0777);
-      g_free (dir);
-      
-      registry->cache_file = g_mkstemp (tmp_location);
-    }
-
-  if (registry->cache_file == -1)
-    goto fail;
-
-  if ((magic = calloc(1, sizeof (GstBinaryRegistryMagic))) == NULL ||
-      !gst_registry_binary_initialize_magic(magic))
-    goto fail;
-
-  if ((magic_chunck = calloc(1, sizeof (GstBinaryChunck))) == NULL)
-    goto fail;
-
-  magic_chunck->data = magic;
-  magic_chunck->size = sizeof (GstBinaryRegistryMagic);
-  to_write = g_list_append(to_write, magic_chunck); 
-
-  /* Iterate trough the list of plugins in the GstRegistry and adapt them to our structures */
-  for (walk = g_list_last(registry->plugins); walk; walk = g_list_previous(walk))
-    {
-      GstPlugin *plugin = GST_PLUGIN(walk->data);
-      
-      if (!plugin->filename)
-	continue;
-	  
-      if (plugin->flags & GST_PLUGIN_FLAG_CACHED)
-	{
-	  int ret;
-	  struct stat statbuf;
-	  
-	  ret = g_stat (plugin->filename, &statbuf);
-	  if ((ret = g_stat (plugin->filename, &statbuf)) < 0 	||
-	      plugin->file_mtime != statbuf.st_mtime		||
-	      plugin->file_size != statbuf.st_size)
-	    continue;
-	}
-
-      if (!gst_registry_binary_save_plugin(&to_write, registry, plugin))
-	{
-	  GST_ERROR("Can't write binary plugin information for \"%s\"", plugin->filename);
-	  continue; /* Try anyway */
-	}
-    }
-
-  for (walk = g_list_first(to_write); walk; walk = g_list_next(walk))
-    {
-      GstBinaryChunck *cur = walk->data;
-
-      if (!gst_registry_binary_write(registry, cur->data, cur->size))
-	{
-	  free(cur->data);
-	  free(cur);
-	  g_list_free(to_write);
-	  goto fail;
-	}
-      free(cur->data);
-      free(cur);
-    }
-  g_list_free(to_write);
-
-  if (close(registry->cache_file) < 0)
-    {
-      GST_DEBUG("Can't close registry file : %s", strerror(errno));
-      goto fail;
-    }
-  
-  if (g_file_test (tmp_location, G_FILE_TEST_EXISTS)) {
-#ifdef WIN32
-    remove (location);
-#endif
-    rename (tmp_location, location);
-  }
-
-  g_free (tmp_location);
-  return TRUE;
-
- fail:
-  g_free(tmp_location);
-  return FALSE;
-}
-
-static GstPluginFeature*
-gst_registry_binary_load_feature(GstBinaryPluginFeature *in)
-{
-  GstPluginFeature *feature;
-  GType type;
-
-  if (!in->typename || !*(in->typename))
-    return NULL;
-
-  /*  GST_INFO("Plugin feature typename : %s", in->typename);*/
-
-  if (!(type = g_type_from_name(in->typename)))
-    {
-      GST_ERROR("Unknown type from typename");
-      return NULL;
-    }
-  feature = g_object_new (type, NULL);
-
-  if (!feature) {
-    GST_ERROR("Can't create feature from type");
-    return NULL;
-  }
-
-  if (!GST_IS_PLUGIN_FEATURE (feature)) {
-    /* don't really know what it is */
-    if (GST_IS_OBJECT (feature))
-      gst_object_unref (feature);
-    else
-      g_object_unref (feature);
-    return NULL;
-  }
-
-  feature->name = g_strdup(in->name);
-  feature->rank = in->rank;
-
-  if (GST_IS_ELEMENT_FACTORY(feature))
-    {
-      GstElementFactory *factory = GST_ELEMENT_FACTORY(feature);
-
-      factory->details.longname = g_strdup(in->longname);
-      factory->details.klass = g_strdup(in->class);
-      factory->details.description = g_strdup(in->description);
-      factory->details.author = g_strdup(in->author);
-
-      /*      GST_INFO("Element factory : %s", factory->details.longname); */
-    }
-
-  GST_DEBUG("Added feature %p with name %s", feature, feature->name);
-  return feature;
-}
-
-/*
-** Make a new plugin from current GstBinaryPluginElement structure
-** and save it to the GstRegistry. Return an offset to the next
-** GstBinaryPluginElement structure.
-*/
-static unsigned long
-gst_registry_binary_get_binary_plugin(GstRegistry *registry, gchar *in)
-{
-  GstBinaryPluginElement *p = (GstBinaryPluginElement *) in;
-  GstPlugin *plugin = NULL;
-  GList *plugin_features = NULL;
-  GstBinaryPluginFeature *feat;
-  unsigned int i;
-  unsigned long offset;
-
-  plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
-
-  plugin->flags |= GST_PLUGIN_FLAG_CACHED;
-
-  plugin->desc.name = g_strdup(p->name);
-  plugin->desc.description= g_strdup(p->description);
-  plugin->filename = g_strdup(p->filename);
-  plugin->desc.version = g_strdup(p->version);
-  plugin->desc.license = g_strdup(p->license);
-  plugin->desc.source = g_strdup(p->source);
-  plugin->desc.package = g_strdup(p->package);
-  plugin->desc.origin = g_strdup(p->origin);
-  plugin->file_mtime = p->m32p;
-  plugin->file_size = p->size;
-  plugin->basename = g_path_get_basename (plugin->filename);
-
-  if (plugin->file_mtime < 0 || plugin->file_size < 0)
-    {
-      GST_ERROR("Plugin time or file size is not valid !");
-      g_free(plugin);
-      return -1;
-    }
-
-  if (p->nfeatures < 0)
-    {
-      GST_ERROR("The number of feature structure is not valid !");
-      gst_object_unref(plugin);
-      return -1;
-    }
-
-  for (feat = (GstBinaryPluginFeature *) (in + sizeof (GstBinaryPluginElement)), i = 0; 
-       i < p->nfeatures; i++, feat++)
-    {
-      GstPluginFeature *gstfeat;
-
-      if ((gstfeat = gst_registry_binary_load_feature(feat)) == NULL)
-	{
-	  g_list_free(plugin_features);
-	  g_free(plugin);
-	  GST_ERROR("Error while loading binary feature");
-	  return -1;
-	}
-      gstfeat->plugin_name = g_strdup(plugin->desc.name);
-      plugin_features = g_list_prepend(plugin_features, gstfeat);
-    }
-  
-  GST_DEBUG("Added plugin \"%s\" to global registry from binary registry", plugin->desc.name); 
-  GList *g;
-
-  gst_registry_add_plugin (registry, plugin);
-  for (g = plugin_features; g; g = g_list_next (g))
-    gst_registry_add_feature (registry, GST_PLUGIN_FEATURE (g->data));
-  /*  g_list_free(plugin_features); */
-
-  offset = sizeof (GstBinaryPluginElement) + p->nfeatures * sizeof (GstBinaryPluginFeature);
-  return offset;
-}
-
-
-/*
-** Read the cache and adapt it to fill GstRegistry
-*/ 
-gboolean 
-gst_registry_binary_read_cache(GstRegistry *registry, const char *location)
-{
-  GMappedFile *mapped = NULL;
-  GTimer *timer = NULL;
-  gchar *contents = NULL;
-  gdouble seconds;
-  unsigned long offset, inc;
-  gsize size;
-
-  /* make sure these types exist */
-  GST_TYPE_ELEMENT_FACTORY;
-  GST_TYPE_TYPE_FIND_FACTORY;
-  GST_TYPE_INDEX_FACTORY;
-
-  timer = g_timer_new ();
-
-  if ((mapped = g_mapped_file_new(location, FALSE, NULL)) == NULL ||
-      (contents = g_mapped_file_get_contents(mapped)) == NULL)
-    {
-      GST_ERROR("Can't load file : %s", strerror(errno));
-      return FALSE;
-    }
-  if ((contents = gst_registry_binary_check_magic(contents)) == NULL)
-    {
-      GST_ERROR("Binary registry type not recognized (invalid magic)");
-      g_mapped_file_free(mapped);
-      return FALSE;
-    }
-
-  if ((size = g_mapped_file_get_length(mapped)) < sizeof (GstBinaryPluginElement))
-    {
-      GST_INFO("No binary plugins structure to read");
-      return TRUE; /* This is not really an error */
-    }
-
-  for (offset = inc = 0; (offset + sizeof (GstBinaryPluginElement)) < size &&
-	 (inc = gst_registry_binary_get_binary_plugin(registry, contents + offset)) > 0;
-       offset += inc)
-    ; /* May want in the future to do something here */
-  if (inc < 0)
-    {
-      GST_DEBUG("Problem while reading binary registry");
-      return FALSE;
-    }
-
-  g_timer_stop (timer);
-  seconds = g_timer_elapsed (timer, NULL);
-  g_timer_destroy (timer);
-
-  GST_INFO ("loaded %s in %f seconds", location, seconds);
-
-  if (mapped)
-    g_mapped_file_free (mapped);
-  return TRUE;
-}
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h
deleted file mode 100644
index 2ef24d7..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/* GStreamer
- * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
- *                    2000 Wim Taymans <wim.taymans@chello.be>
- *
- * gstregistry.h: Header for registry handling
- *
- * 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.
- */
-
-/* SUGGESTIONS AND TODO :
-** ====================
-** - Use a compressed registry, but would induce performance loss
-** - Encrypt the registry, for security purpose, but would also reduce performances
-** - Also have a non-mmap based cache reading (work with file descriptors)
-*/
-
-#ifndef __GST_REGISTRYBINARY_H__
-#define __GST_REGISTRYBINARY_H__
-
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include <gst/gst_private.h>
-#include <gst/gstelement.h>
-#include <gst/gsttypefind.h>
-#include <gst/gsttypefindfactory.h>
-#include <gst/gsturi.h>
-#include <gst/gstinfo.h>
-#include <gst/gstenumtypes.h>
-#include <gst/gstregistry.h>
-#include <gst/gstpadtemplate.h>
-
-#include "glib-compat-private.h"
-#include <glib/gstdio.h>
-
-/* A magic, written at the beginning of the file */
-#define GST_MAGIC_BINARY_REGISTRY_STR "\xc0\xde\xf0\x0d"
-#define GST_MAGIC_BINARY_REGISTRY_LEN (4)
-#define GST_MAGIC_BINARY_VERSION_LEN (64)
-
-typedef struct _GstBinaryRegistryMagic
-{
-  char magic[GST_MAGIC_BINARY_REGISTRY_LEN];
-  char version[GST_MAGIC_BINARY_VERSION_LEN];
-} GstBinaryRegistryMagic;
-
-
-/* Used to store pointers to write */
-typedef struct _GstBinaryChunck
-{
-  void *data;
-  unsigned int size;
-} GstBinaryChunck;
-
-
-/* A structure containing (staticely) every information needed for a plugin
-**
-** Notes :
-** "nfeatures" is used to say how many GstBinaryPluginFeature structures we will have 
-** right after the structure itself.
-*/
-
-/* Various lenght defines for our GstBinaryPluginElement structure 
-** Note : We could eventually use smaller size
-*/
-#define GST_BINARY_REGISTRY_NAME_LEN (256)
-#define GST_BINARY_REGISTRY_DESCRIPTION_LEN (1024)
-#define GST_BINARY_REGISTRY_VERSION_LEN (64)
-#define GST_BINARY_REGISTRY_LICENSE_LEN (256)
-#define GST_BINARY_REGISTRY_SOURCE_LEN (256)
-#define GST_BINARY_REGISTRY_PACKAGE_LEN (1024)
-#define GST_BINARY_REGISTRY_ORIGIN_LEN (1024)
-
-typedef struct _GstBinaryPluginElement
-{
-  char name[GST_BINARY_REGISTRY_NAME_LEN];
-  char description[GST_BINARY_REGISTRY_DESCRIPTION_LEN];
-  char filename[_POSIX_PATH_MAX];
-  char version[GST_BINARY_REGISTRY_VERSION_LEN];
-  char license[GST_BINARY_REGISTRY_LICENSE_LEN];
-  char source[GST_BINARY_REGISTRY_SOURCE_LEN];
-  char package[GST_BINARY_REGISTRY_PACKAGE_LEN];
-  char origin[GST_BINARY_REGISTRY_ORIGIN_LEN];
-  unsigned long size;
-  unsigned long m32p;
-  unsigned int nfeatures;
-} GstBinaryPluginElement;
-
-
-/* A structure containing the plugin features
-**
-** Note :
-** "npadtemplates" is used to store the number of GstBinaryPadTemplate structures following the structure itself.
-** "ninterfaces" is used to store the number of GstBinaryInterface structures following the structure itself.
-** "nuritypes" is used to store the number of GstBinaryUriType structures following the structure itself.
-*/
-#define GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN (256)
-#define GST_BINARY_REGISTRY_TYPENAME_NAME_LEN (256)
-#define GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN (1024)
-#define GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN (512)
-#define GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN (1024)
-#define GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN (256)
-
-typedef struct _GstBinaryPluginFeature
-{
-  char typename[GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN];
-  char name[GST_BINARY_REGISTRY_TYPENAME_NAME_LEN];
-  unsigned long rank;
-  char longname[GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN];
-  char class[GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN];
-  char description[GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN];
-  char author[GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN];
-  unsigned int npadtemplates;
-  unsigned int ninterfaces;
-  unsigned int nuritypes;
-} GstBinaryPluginFeature;
-
-
-/* 
-** A structure containing the static pad templates of a plugin feature 
-*/
-#define GST_BINARY_REGISTRY_PADTEMPLATE_NAME_LEN (256)
-#define GST_BINARY_REGISTRY_PADTEMPLATE_CAP_LEN (1024)
-
-typedef struct _GstBinaryPadTemplate
-{
-  char name[GST_BINARY_REGISTRY_PADTEMPLATE_NAME_LEN];
-  char cap[GST_BINARY_REGISTRY_PADTEMPLATE_CAP_LEN];
-  int direction;					/* Either 0:"sink" or 1:"src" */
-  GstPadPresence presence;
-} GstBinaryPadTemplate;
-
-/*
-** A very simple structure defining the plugin feature interface string
-*/
-#define GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN (512)
-typedef struct _GstBinaryInterface
-{
-  char interface[GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN];
-  unsigned long size;
-} GstBinaryInterface;
-
-/* Uri Type */
-typedef struct _GstBinaryUriType
-{
-  GstURIType type;
-  unsigned long nuriprotocols;
-} GstBinaryUriType;
-
-/* 
-** Function prototypes
-*/
-
-/* Local prototypes */
-inline static gboolean gst_registry_binary_write(GstRegistry *registry, const void *mem, const ssize_t size);
-inline static gboolean gst_registry_binary_initialize_magic(GstBinaryRegistryMagic *m);
-static gboolean gst_registry_binary_fill_feature(GList **list, GstPluginFeature *, GstBinaryPluginFeature *, const char *);
-static gboolean gst_registry_binary_save_plugin(GList **list, GstRegistry *registry, GstPlugin *plugin);
-static gchar *gst_registry_binary_check_magic(gchar *in);
-static GstPluginFeature *gst_registry_binary_load_feature(GstBinaryPluginFeature *);
-static unsigned long gst_registry_binary_get_binary_plugin(GstRegistry *registry, gchar *in);
-
-/* Exportable */
-gboolean gst_registry_binary_write_cache(GstRegistry *registry, const char *location);
-gboolean gst_registry_binary_read_cache(GstRegistry *registry, const char *location);
-
-#endif /* !__GST_REGISTRYBINARY_H__ */
-
-
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb
deleted file mode 100644
index 5b30603..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb
+++ /dev/null
@@ -1,51 +0,0 @@
-SUMMARY = "GStreamer multimedia framework"
-DESCRIPTION = "GStreamer is a multimedia framework for encoding and decoding video and sound. \
-It supports a wide range of formats including mp3, ogg, avi, mpeg and quicktime."
-HOMEPAGE = "http://gstreamer.freedesktop.org/"
-BUGTRACKER = "https://bugzilla.gnome.org/enter_bug.cgi?product=Gstreamer"
-SECTION = "multimedia"
-LICENSE = "LGPLv2+"
-LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605 \
-                    file://gst/gst.h;beginline=1;endline=21;md5=8e5fe5e87d33a04479fde862e238eaa4"
-DEPENDS = "glib-2.0 libxml2 bison-native flex-native"
-
-PR = "r2"
-
-SRC_URI = "http://gstreamer.freedesktop.org/src/gstreamer/gstreamer-${PV}.tar.bz2 \
-           file://check_fix.patch \
-           file://gst-inspect-check-error.patch \
-           file://0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch \
-           file://gstreamer-change-priv_gst_parse_yylex-arguments.patch \
-"
-
-SRC_URI[md5sum] = "a0cf7d6877f694a1a2ad2b4d1ecb890b"
-SRC_URI[sha256sum] = "e556a529e0a8cf1cd0afd0cab2af5488c9524e7c3f409de29b5d82bb41ae7a30"
-
-inherit autotools pkgconfig gettext
-
-GSTREAMER_DEBUG ?= "--disable-debug"
-EXTRA_OECONF = "--disable-docbook --disable-gtk-doc \
-            --disable-dependency-tracking --disable-check \
-            --disable-examples --disable-tests \
-            --disable-valgrind ${GSTREAMER_DEBUG} \
-            "
-
-CACHED_CONFIGUREVARS += "ac_cv_header_valgrind_valgrind_h=no"
-
-# apply gstreamer hack after Makefile.in.in in source is replaced by our version from
-# ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in, but before configure is executed
-# http://lists.linuxtogo.org/pipermail/openembedded-core/2012-November/032233.html
-oe_runconf_prepend() {
-        sed -i -e "1a\\" -e 'GETTEXT_PACKAGE = @GETTEXT_PACKAGE@' ${S}/po/Makefile.in.in
-}
-
-#do_compile_prepend () {
-#	mv ${WORKDIR}/gstregistrybinary.[ch] ${S}/gst/
-#}
-
-RRECOMMENDS_${PN}_qemux86    += "kernel-module-snd-ens1370 kernel-module-snd-rawmidi"
-RRECOMMENDS_${PN}_qemux86-64 += "kernel-module-snd-ens1370 kernel-module-snd-rawmidi"
-
-FILES_${PN} += " ${libdir}/gstreamer-0.10/*.so"
-FILES_${PN}-dev += " ${libdir}/gstreamer-0.10/*.la ${libdir}/gstreamer-0.10/*.a"
-FILES_${PN}-dbg += " ${libdir}/gstreamer-0.10/.debug/ ${libexecdir}/gstreamer-0.10/.debug/"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/python-gst/python-path.patch b/meta-multimedia/recipes-multimedia/gstreamer/python-gst/python-path.patch
deleted file mode 100644
index 21b5bbf..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/python-gst/python-path.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-Upstream-Status:Pending
-
-Index: gst-python-0.10.19/acinclude.m4
-===================================================================
---- gst-python-0.10.19.orig/acinclude.m4	2010-04-21 15:23:44.000000000 -0700
-+++ gst-python-0.10.19/acinclude.m4	2010-11-15 14:43:00.642994001 -0800
-@@ -43,6 +43,13 @@
- [AC_REQUIRE([AM_PATH_PYTHON])
- AC_MSG_CHECKING(for headers required to compile python extensions)
- dnl deduce PYTHON_INCLUDES
-+
-+AC_ARG_WITH(python-includes,
-+	[  --with-python-includes=DIR  path to Python includes], py_exec_prefix=$withval)
-+if test x$py_exec_prefix != x; then
-+PYTHON_INCLUDES="-I${py_exec_prefix}/include/python${PYTHON_VERSION}"
-+py_prefix="${py_exec_prefix}"
-+else
- py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
- py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
- if $PYTHON-config --help 2>/dev/null; then
-@@ -53,6 +60,7 @@
-     PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
-   fi
- fi
-+fi
- AC_SUBST(PYTHON_INCLUDES)
- dnl check if the headers exist:
- save_CPPFLAGS="$CPPFLAGS"
diff --git a/meta-multimedia/recipes-multimedia/gstreamer/python-gst_0.10.22.bb b/meta-multimedia/recipes-multimedia/gstreamer/python-gst_0.10.22.bb
deleted file mode 100644
index 2a5f2b3..0000000
--- a/meta-multimedia/recipes-multimedia/gstreamer/python-gst_0.10.22.bb
+++ /dev/null
@@ -1,29 +0,0 @@
-SUMMARY = "Python bindings for the GStreamer multimedia framework"
-SECTION = "devel/python"
-LICENSE = "LGPLv2.1"
-DEPENDS = "gstreamer gst-plugins-base python-pygobject"
-RDEPENDS_${PN} += "python-pygtk"
-PR = "r2"
-
-SRC_URI = "http://gstreamer.freedesktop.org/src/gst-python/gst-python-${PV}.tar.bz2 \
-           file://python-path.patch"
-
-SRC_URI[md5sum] = "937152fe896241f827689f4b53e79b22"
-SRC_URI[sha256sum] = "8f26f519a5bccd770864317e098e5e307fc5ad1201eb96329634b6508b253178"
-S = "${WORKDIR}/gst-python-${PV}"
-
-LIC_FILES_CHKSUM = "file://COPYING;md5=39ff67e932b7bdfa9b78bad67151690b"
-
-inherit autotools distutils-base pkgconfig
-
-EXTRA_OECONF += "--with-python-includes=${STAGING_INCDIR}/../"
-
-FILES_${PN} += "${datadir}/gst-python"
-FILES_${PN}-dev += "${datadir}/gst-python/0.10/defs"
-FILES_${PN}-dbg += "${libdir}/${PYTHON_DIR}/site-packages/gst-0.10/gst/.debug/ ${libdir}/gstreamer-0.10/.debug/"
-
-do_configure_prepend() {
-	if [ `find ${STAGING_LIBDIR} -name libpython*.so` ]; then
-		ln -sf ${STAGING_LIBDIR}/libpython*.so `find ${STAGING_LIBDIR} -name libpython*.a -exec dirname {} \;`
-	fi
-}
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/4] Rename gstreamer directory to gstreamer-0.10
  2015-05-18 14:12 ` [PATCH 4/4] Rename gstreamer directory to gstreamer-0.10 Alexander Kanavin
@ 2015-05-18 14:16   ` Carlos Rafael Giani
  2015-05-18 14:24     ` Alexander Kanavin
  2015-05-18 16:58     ` Burton, Ross
  0 siblings, 2 replies; 20+ messages in thread
From: Carlos Rafael Giani @ 2015-05-18 14:16 UTC (permalink / raw)
  To: openembedded-devel

Would it be possible to rename the recipes to match the naming 
convention of the 1.0 ones?
For example, instead of "gst-plugins-bad", it would be 
"gstreamer0.10-plugins-bad".
Is such a backwards compatibility break tolerable between major OE releases?


On 05/18/2015 04:12 PM, Alexander Kanavin wrote:
> So that it's clear that the recipes it contains are specific to the
> obsolete, unmaintained version of gstreamer.
>
> Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com>
> ---
>   .../0001-aacdec-check-channel-count.patch          |   34 +
>   .../0001-alac-fix-nb_samples-order-case.patch      |   30 +
>   .../0001-alsdec-check-block-length.patch           |   61 +
>   ...ac3dec-Check-coding-mode-against-channels.patch |   37 +
>   ...util-fix-signedness-in-sizeof-comparissio.patch |   40 +
>   ...le-use-av_image_get_linesize-to-calculate.patch |   50 +
>   ...c-parser-reset-indexes-on-realloc-failure.patch |   50 +
>   ...a-Perform-pointer-advance-and-checks-befo.patch |   81 +
>   .../0001-avcodec-smc-fix-off-by-1-error.patch      |   32 +
>   ...egtsenc-Check-data-array-size-in-mpegts_w.patch |   69 +
>   .../0001-eamad-fix-out-of-array-accesses.patch     |   29 +
>   ...-error-concealment-initialize-block-index.patch |   29 +
>   ...alment-Check-that-the-picture-is-not-in-a.patch |   37 +
>   .../0001-ffserver-set-oformat.patch                |   36 +
>   ...t-ref-count-check-and-limit-fix-out-of-ar.patch |   29 +
>   ...t-parameters-from-SPS-whenever-it-changes.patch |  145 +
>   ...rror-concealment-when-SPS-and-slices-are-.patch |   33 +
>   .../0001-h264_sei-Fix-infinite-loop.patch          |   39 +
>   ...01-huffyuvdec-Check-init_vlc-return-codes.patch |   87 +
>   .../0001-huffyuvdec-Skip-len-0-cases.patch         |   61 +
>   ...f-compute-probe-buffer-size-more-reliably.patch |   45 +
>   .../0001-mjpegdec-check-SE.patch                   |   32 +
>   ...heck-RLE-size-before-copying.-Fix-out-of-.patch |   34 +
>   ...er-dont-access-out-of-array-elements-at-t.patch |   44 +
>   ...array-index-before-use-fix-out-of-array-a.patch |   30 +
>   .../0001-qdm2dec-fix-buffer-overflow.patch         |   58 +
>   ...001-roqvideodec-check-dimensions-validity.patch |   36 +
>   ...Check-that-the-last-indexes-are-within-th.patch |   32 +
>   ...-vp3-Copy-all-3-frames-for-thread-updates.patch |   32 +
>   ...-read-for-negative-tokens-and-memleaks-on.patch |  183 +
>   ...o-check-chunk-sizes-before-reading-chunks.patch |   51 +
>   ...egdec-check-bits-per-pixel-for-changes-si.patch |   68 +
>   .../gst-ffmpeg-0.10.13/configure-fix.patch         |   22 +
>   .../gst-ffmpeg-CVE-2013-0855.patch                 |  100 +
>   .../gst-ffmpeg-CVE-2013-3674.patch                 |   26 +
>   .../gst-ffmpeg-0.10.13/h264_qpel_mmx.patch         |   57 +
>   .../gst-ffmpeg-0.10.13/libav-9.patch               | 9304 ++++++++++++++++++++
>   .../gst-ffmpeg-0.10.13/libav_e500mc.patch          |   21 +
>   .../gst-ffmpeg-0.10.13/libav_e5500.patch           |   19 +
>   .../gst-ffmpeg-0.10.13/lower-rank.diff             |   16 +
>   .../gstreamer-0.10/gst-ffmpeg_0.10.13.bb           |   90 +
>   .../gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb      |   14 +
>   .../gst-fluendo-mpegdemux_0.10.85.bb               |   12 +
>   .../gstreamer-0.10/gst-fluendo.inc                 |   14 +
>   .../gstreamer-0.10/gst-meta-base_0.10.bb           |   73 +
>   .../gstreamer-0.10/gst-openmax/gcc_4.6.patch       |   18 +
>   .../gstreamer-0.10/gst-openmax/ptr-array.patch     |   46 +
>   .../gstreamer-0.10/gst-openmax_0.10.1.bb           |   35 +
>   .../gstreamer-0.10/gst-plugins-bad_0.10.23.bb      |   50 +
>   ...le-Fix-build-on-x86-if-emmintrin.h-is-ava.patch |   37 +
>   .../configure.ac-fix-subparse-plugin.patch         |   27 +
>   .../gst-plugins-base-tremor.patch                  |   20 +
>   .../gstreamer-0.10/gst-plugins-base_0.10.36.bb     |   39 +
>   ...-conditional-gl-framebuffer-undefined-use.patch |   35 +
>   .../gstreamer-0.10/gst-plugins-gl_0.10.3.bb        |   25 +
>   ...ild-with-recent-kernels-the-v4l2_buffer-i.patch |   33 +
>   ...define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch |   45 +
>   .../0407-mulawdec-fix-integer-overrun.patch        |   47 +
>   .../gstreamer-0.10/gst-plugins-good_0.10.31.bb     |   47 +
>   .../gstreamer-0.10/gst-plugins-ugly_0.10.19.bb     |   29 +
>   .../gstreamer-0.10/gst-plugins.inc                 |   28 +
>   ...ecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch |   34 +
>   .../gstreamer-0.10/gst-rtsp_0.10.8.bb              |   16 +
>   ...ix-self-comparison-always-evaluates-to-tr.patch |   32 +
>   .../gstreamer-0.10.36/check_fix.patch              |   19 +
>   .../gst-inspect-check-error.patch                  |   16 +
>   ...mer-change-priv_gst_parse_yylex-arguments.patch |   33 +
>   .../gstreamer-0.10.36/gstregistrybinary.c          |  487 +
>   .../gstreamer-0.10.36/gstregistrybinary.h          |  194 +
>   .../gstreamer-0.10/gstreamer_0.10.36.bb            |   51 +
>   .../gstreamer-0.10/python-gst/python-path.patch    |   28 +
>   .../gstreamer-0.10/python-gst_0.10.22.bb           |   29 +
>   .../0001-aacdec-check-channel-count.patch          |   34 -
>   .../0001-alac-fix-nb_samples-order-case.patch      |   30 -
>   .../0001-alsdec-check-block-length.patch           |   61 -
>   ...ac3dec-Check-coding-mode-against-channels.patch |   37 -
>   ...util-fix-signedness-in-sizeof-comparissio.patch |   40 -
>   ...le-use-av_image_get_linesize-to-calculate.patch |   50 -
>   ...c-parser-reset-indexes-on-realloc-failure.patch |   50 -
>   ...a-Perform-pointer-advance-and-checks-befo.patch |   81 -
>   .../0001-avcodec-smc-fix-off-by-1-error.patch      |   32 -
>   ...egtsenc-Check-data-array-size-in-mpegts_w.patch |   69 -
>   .../0001-eamad-fix-out-of-array-accesses.patch     |   29 -
>   ...-error-concealment-initialize-block-index.patch |   29 -
>   ...alment-Check-that-the-picture-is-not-in-a.patch |   37 -
>   .../0001-ffserver-set-oformat.patch                |   36 -
>   ...t-ref-count-check-and-limit-fix-out-of-ar.patch |   29 -
>   ...t-parameters-from-SPS-whenever-it-changes.patch |  145 -
>   ...rror-concealment-when-SPS-and-slices-are-.patch |   33 -
>   .../0001-h264_sei-Fix-infinite-loop.patch          |   39 -
>   ...01-huffyuvdec-Check-init_vlc-return-codes.patch |   87 -
>   .../0001-huffyuvdec-Skip-len-0-cases.patch         |   61 -
>   ...f-compute-probe-buffer-size-more-reliably.patch |   45 -
>   .../0001-mjpegdec-check-SE.patch                   |   32 -
>   ...heck-RLE-size-before-copying.-Fix-out-of-.patch |   34 -
>   ...er-dont-access-out-of-array-elements-at-t.patch |   44 -
>   ...array-index-before-use-fix-out-of-array-a.patch |   30 -
>   .../0001-qdm2dec-fix-buffer-overflow.patch         |   58 -
>   ...001-roqvideodec-check-dimensions-validity.patch |   36 -
>   ...Check-that-the-last-indexes-are-within-th.patch |   32 -
>   ...-vp3-Copy-all-3-frames-for-thread-updates.patch |   32 -
>   ...-read-for-negative-tokens-and-memleaks-on.patch |  183 -
>   ...o-check-chunk-sizes-before-reading-chunks.patch |   51 -
>   ...egdec-check-bits-per-pixel-for-changes-si.patch |   68 -
>   .../gst-ffmpeg-0.10.13/configure-fix.patch         |   22 -
>   .../gst-ffmpeg-CVE-2013-0855.patch                 |  100 -
>   .../gst-ffmpeg-CVE-2013-3674.patch                 |   26 -
>   .../gst-ffmpeg-0.10.13/h264_qpel_mmx.patch         |   57 -
>   .../gstreamer/gst-ffmpeg-0.10.13/libav-9.patch     | 9304 --------------------
>   .../gst-ffmpeg-0.10.13/libav_e500mc.patch          |   21 -
>   .../gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch |   19 -
>   .../gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff   |   16 -
>   .../gstreamer/gst-ffmpeg_0.10.13.bb                |   90 -
>   .../gstreamer/gst-fluendo-mp3_0.10.31.bb           |   14 -
>   .../gstreamer/gst-fluendo-mpegdemux_0.10.85.bb     |   12 -
>   .../recipes-multimedia/gstreamer/gst-fluendo.inc   |   14 -
>   .../gstreamer/gst-meta-base_0.10.bb                |   73 -
>   .../gstreamer/gst-openmax/gcc_4.6.patch            |   18 -
>   .../gstreamer/gst-openmax/ptr-array.patch          |   46 -
>   .../gstreamer/gst-openmax_0.10.1.bb                |   35 -
>   .../gstreamer/gst-plugins-bad_0.10.23.bb           |   50 -
>   ...le-Fix-build-on-x86-if-emmintrin.h-is-ava.patch |   37 -
>   .../configure.ac-fix-subparse-plugin.patch         |   27 -
>   .../gst-plugins-base-tremor.patch                  |   20 -
>   .../gstreamer/gst-plugins-base_0.10.36.bb          |   39 -
>   ...-conditional-gl-framebuffer-undefined-use.patch |   35 -
>   .../gstreamer/gst-plugins-gl_0.10.3.bb             |   25 -
>   ...ild-with-recent-kernels-the-v4l2_buffer-i.patch |   33 -
>   ...define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch |   45 -
>   .../0407-mulawdec-fix-integer-overrun.patch        |   47 -
>   .../gstreamer/gst-plugins-good_0.10.31.bb          |   47 -
>   .../gstreamer/gst-plugins-ugly_0.10.19.bb          |   29 -
>   .../recipes-multimedia/gstreamer/gst-plugins.inc   |   28 -
>   ...ecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch |   34 -
>   .../gstreamer/gst-rtsp_0.10.8.bb                   |   16 -
>   ...ix-self-comparison-always-evaluates-to-tr.patch |   32 -
>   .../gstreamer/gstreamer-0.10.36/check_fix.patch    |   19 -
>   .../gst-inspect-check-error.patch                  |   16 -
>   ...mer-change-priv_gst_parse_yylex-arguments.patch |   33 -
>   .../gstreamer-0.10.36/gstregistrybinary.c          |  487 -
>   .../gstreamer-0.10.36/gstregistrybinary.h          |  194 -
>   .../gstreamer/gstreamer_0.10.36.bb                 |   51 -
>   .../gstreamer/python-gst/python-path.patch         |   28 -
>   .../gstreamer/python-gst_0.10.22.bb                |   29 -
>   144 files changed, 12922 insertions(+), 12922 deletions(-)
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/configure-fix.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav-9.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e500mc.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e5500.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/lower-rank.diff
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg_0.10.13.bb
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mpegdemux_0.10.85.bb
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo.inc
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-meta-base_0.10.bb
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/gcc_4.6.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/ptr-array.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax_0.10.1.bb
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-bad_0.10.23.bb
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base_0.10.36.bb
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl_0.10.3.bb
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good_0.10.31.bb
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-ugly_0.10.19.bb
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins.inc
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp_0.10.8.bb
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/check_fix.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gst-inspect-check-error.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.c
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.h
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer_0.10.36.bb
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst/python-path.patch
>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst_0.10.22.bb
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.31.bb
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.85.bb
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo.inc
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp_0.10.8.bb
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/python-gst/python-path.patch
>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/python-gst_0.10.22.bb
>
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
> new file mode 100644
> index 0000000..7da0e14
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
> @@ -0,0 +1,34 @@
> +gst-ffmpeg: aacdec: check channel count
> +
> +Prevent out of array accesses
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit 96f452ac647dae33c53c242ef3266b65a9beafb6)
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Yue Tao <yue.tao@windriver.com>
> +---
> + libavcodec/aacdec.c |    5 +++++
> + 1 files changed, 5 insertions(+), 0 deletions(-)
> +
> +diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
> +index 239153a..6c17c33 100644
> +--- a/gst-libs/ext/libav/libavcodec/aacdec.c
> ++++ b/gst-libs/ext/libav/libavcodec/aacdec.c
> +@@ -914,6 +914,11 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
> +         }
> +     }
> +
> ++    if (avctx->channels > MAX_CHANNELS) {
> ++        av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
> ++        return AVERROR_INVALIDDATA;
> ++    }
> ++
> +     AAC_INIT_VLC_STATIC( 0, 304);
> +     AAC_INIT_VLC_STATIC( 1, 270);
> +     AAC_INIT_VLC_STATIC( 2, 550);
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
> new file mode 100644
> index 0000000..10ce0f3
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
> @@ -0,0 +1,30 @@
> +From e0884eadf6a15e93142131b695f48776f9a0ac31 Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Sat, 10 Nov 2012 17:14:04 +0100
> +Subject: [PATCH] alac: fix nb_samples < order case
> +
> +Upstream-Status: Backport
> +
> +Commit e0884eadf6a15e93142131b695f48776f9a0ac31 release/1.0
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit fd4f4923cce6a2cbf4f48640b4ac706e614a1594)
> +---
> + libavcodec/alac.c | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/libavcodec/alac.c b/libavcodec/alac.c
> +index 9cd1737..e8e844a 100644
> +--- a/gst-libs/ext/libav/libavcodec/alac.c
> ++++ b/gst-libs/ext/libav/libavcodec/alac.c
> +@@ -278,7 +278,7 @@ static void predictor_decompress_fir_ada
> +
> +     /* read warm-up samples */
> +     if (predictor_coef_num > 0)
> +-        for (i = 0; i < predictor_coef_num; i++) {
> ++        for (i = 0; i < predictor_coef_num && i < output_size; i++) {
> +             int32_t val;
> +
> +             val = buffer_out[i] + error_buffer[i+1];
> +--
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
> new file mode 100644
> index 0000000..73980f4
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
> @@ -0,0 +1,61 @@
> +From 6df0d3e2916c223dbe4262bf1b876dff1cb3f980 Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Wed, 12 Dec 2012 12:28:45 +0100
> +Subject: [PATCH] alsdec: check block length
> +
> +Upstream-Status: Backport
> +
> +Commit 6df0d3e2916c223dbe4262bf1b876dff1cb3f980 release/1.0
> +
> +Fix writing over the end
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit 0ceca269b66ec12a23bf0907bd2c220513cdbf16)
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/alsdec.c | 10 ++++++++--
> + 1 file changed, 8 insertions(+), 2 deletions(-)
> +
> +diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
> +index 46dd0b4..1095b01 100644
> +--- a/gst-libs/ext/libav/libavcodec/alsdec.c
> ++++ b/gst-libs/ext/libav/libavcodec/alsdec.c
> +@@ -552,12 +552,15 @@ static void get_block_sizes(ALSDecContext *ctx, unsigned int *div_blocks,
> +
> + /** Read the block data for a constant block
> +  */
> +-static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
> ++static int read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
> + {
> +     ALSSpecificConfig *sconf = &ctx->sconf;
> +     AVCodecContext *avctx    = ctx->avctx;
> +     GetBitContext *gb        = &ctx->gb;
> +
> ++    if (bd->block_length <= 0)
> ++        return -1;
> ++
> +     *bd->raw_samples = 0;
> +     *bd->const_block = get_bits1(gb);    // 1 = constant value, 0 = zero block (silence)
> +     bd->js_blocks    = get_bits1(gb);
> +@@ -572,6 +575,8 @@ static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
> +
> +     // ensure constant block decoding by reusing this field
> +     *bd->const_block = 1;
> ++
> ++    return 0;
> + }
> +
> +
> +@@ -971,7 +976,8 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
> +         if (read_var_block_data(ctx, bd))
> +             return -1;
> +     } else {
> +-        read_const_block_data(ctx, bd);
> ++        if (read_const_block_data(ctx, bd) < 0)
> ++            return -1;
> +     }
> +
> +     return 0;
> +--
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
> new file mode 100644
> index 0000000..42cb5f4
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
> @@ -0,0 +1,37 @@
> +From 2502914c5f8eb77659d7c0868396862557a63245 Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Fri, 9 Nov 2012 13:26:20 +0100
> +Subject: [PATCH] atrac3dec: Check coding mode against channels.
> +
> +Upstream-Status: Backport
> +
> +Commit 2502914c5f8eb77659d7c0868396862557a63245 release/1.0
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit 13451f5520ce6b0afde861b2285dda659f8d4fb4)
> +
> +Conflicts:
> +
> +	libavcodec/atrac3.c
> +---
> + libavcodec/atrac3.c | 5 +++++
> + 1 file changed, 5 insertions(+)
> +
> +diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
> +index 7d076be..1da4c78 100644
> +--- a/gst-libs/ext/libav/libavcodec/atrac3.c
> ++++ b/gst-libs/ext/libav/libavcodec/atrac3.c
> +@@ -955,6 +955,11 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
> +     }
> +     /* Check the extradata. */
> +
> ++    if (q->codingMode == JOINT_STEREO && avctx->channels < 2) {
> ++        av_log(avctx, AV_LOG_ERROR, "Invalid coding mode\n");
> ++        return AVERROR_INVALIDDATA;
> ++    }
> ++
> +     if (q->atrac3version != 4) {
> +         av_log(avctx,AV_LOG_ERROR,"Version %d != 4.\n",q->atrac3version);
> +         return AVERROR_INVALIDDATA;
> +--
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
> new file mode 100644
> index 0000000..31fa51a
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
> @@ -0,0 +1,40 @@
> +From a99aff4e4bbef8e64b51f267cd1769214e1b4e80 Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Fri, 30 Aug 2013 23:40:47 +0200
> +Subject: [PATCH] avcodec/dsputil: fix signedness in sizeof() comparissions
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit 454a11a1c9c686c78aa97954306fb63453299760)
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/dsputil.c |    4 ++--
> + 1 files changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
> +index 53dc2eb..6264832 100644
> +--- a/gst-libs/ext/libav/libavcodec/dsputil.c
> ++++ b/gst-libs/ext/libav/libavcodec/dsputil.c
> +@@ -1912,7 +1912,7 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
> +
> + static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
> +     long i;
> +-    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
> ++    for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
> +         long a = *(long*)(src+i);
> +         long b = *(long*)(dst+i);
> +         *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
> +@@ -1937,7 +1937,7 @@ static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
> +         }
> +     }else
> + #endif
> +-    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
> ++    for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
> +         long a = *(long*)(src1+i);
> +         long b = *(long*)(src2+i);
> +         *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
> new file mode 100644
> index 0000000..b0a3fb1
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
> @@ -0,0 +1,50 @@
> +From 573d5fdedae72bf59d8c0b0766fdee171063d36f Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Sun, 16 Feb 2014 23:08:52 +0100
> +Subject: [PATCH] avcodec/msrle: use av_image_get_linesize() to calculate the
> + linesize
> +
> +Upstream-Status: Backport
> +
> +Commit 573d5fdedae72bf59d8c0b0766fdee171063d36f release/0.9
> +
> +Fixes out of array access
> +Fixes: 14a74a0a2dc67ede543f0e35d834fbbe-asan_heap-oob_49572c_556_cov_215466444_44_001_engine_room.mov
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit c919e1ca2ecfc47d796382973ba0e48b8f6f92a2)
> +
> +Conflicts:
> +
> +	libavcodec/msrle.c
> +(cherry picked from commit bc1c8ec5e65098fd2ccd8456f667151dfc9cda42)
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/msrle.c |    3 ++-
> + 1 files changed, 2 insertions(+), 1 deletions(-)
> +
> +diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c
> +index 30159bb..c39ae7b 100644
> +--- a/gst-libs/ext/libav/libavcodec/msrle.c
> ++++ b/gst-libs/ext/libav/libavcodec/msrle.c
> +@@ -35,6 +35,7 @@
> + #include "avcodec.h"
> + #include "dsputil.h"
> + #include "msrledec.h"
> ++#include "libavutil/imgutils.h"
> +
> + typedef struct MsrleContext {
> +     AVCodecContext *avctx;
> +@@ -107,7 +108,7 @@ static int msrle_decode_frame(AVCodecContext *avctx,
> +
> +     /* FIXME how to correctly detect RLE ??? */
> +     if (avctx->height * istride == avpkt->size) { /* assume uncompressed */
> +-        int linesize = avctx->width * avctx->bits_per_coded_sample / 8;
> ++        int linesize = av_image_get_linesize(avctx->pix_fmt, avctx->width, 0);
> +         uint8_t *ptr = s->frame.data[0];
> +         uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
> +         int i, j;
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
> new file mode 100644
> index 0000000..5ff6583
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
> @@ -0,0 +1,50 @@
> +gst-ffmpeg: avcodec/parser: reset indexes on realloc failure
> +
> +Fixes Ticket2982
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit f31011e9abfb2ae75bb32bc44e2c34194c8dc40a)
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Yue Tao <yue.tao@windriver.com>
> +
> +---
> + libavcodec/parser.c |   10 +++++++---
> + 1 files changed, 7 insertions(+), 3 deletions(-)
> +
> +diff --git a/libavcodec/parser.c b/libavcodec/parser.c
> +index 2c6de6e..66eca06 100644
> +--- a/gst-libs/ext/libav/libavcodec/parser.c
> ++++ b/gst-libs/ext/libav/libavcodec/parser.c
> +@@ -241,8 +241,10 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
> +     if(next == END_NOT_FOUND){
> +         void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
> +
> +-        if(!new_buffer)
> ++        if(!new_buffer) {
> ++            pc->index = 0;
> +             return AVERROR(ENOMEM);
> ++        }
> +         pc->buffer = new_buffer;
> +         memcpy(&pc->buffer[pc->index], *buf, *buf_size);
> +         pc->index += *buf_size;
> +@@ -255,9 +257,11 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
> +     /* append to buffer */
> +     if(pc->index){
> +         void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
> +-
> +-        if(!new_buffer)
> ++        if(!new_buffer) {
> ++            pc->overread_index =
> ++            pc->index = 0;
> +             return AVERROR(ENOMEM);
> ++        }
> +         pc->buffer = new_buffer;
> +         if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
> +             memcpy(&pc->buffer[pc->index], *buf,
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
> new file mode 100644
> index 0000000..7f6eb48
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
> @@ -0,0 +1,81 @@
> +gst-ffmpeg: avcodec/rpza: Perform pointer advance and checks before
> + using the pointers
> +
> +Fixes out of array accesses
> +Fixes Ticket2850
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit 3819db745da2ac7fb3faacb116788c32f4753f34)
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +
> +Upstream-Status: Backport
> +
> +Singed-off-by: Yue Tao <yue.tao@windriver.com>
> +
> +---
> + libavcodec/rpza.c |    8 ++++----
> + 1 files changed, 4 insertions(+), 4 deletions(-)
> +
> +diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c
> +index 635b406..f291a95 100644
> +--- a/gst-libs/ext/libav/libavcodec/rpza.c
> ++++ b/gst-libs/ext/libav/libavcodec/rpza.c
> +@@ -83,7 +83,7 @@ static void rpza_decode_stream(RpzaContext *s)
> +     unsigned short *pixels = (unsigned short *)s->frame.data[0];
> +
> +     int row_ptr = 0;
> +-    int pixel_ptr = 0;
> ++    int pixel_ptr = -4;
> +     int block_ptr;
> +     int pixel_x, pixel_y;
> +     int total_blocks;
> +@@ -139,6 +139,7 @@ static void rpza_decode_stream(RpzaContext *s)
> +             colorA = AV_RB16 (&s->buf[stream_ptr]);
> +             stream_ptr += 2;
> +             while (n_blocks--) {
> ++                ADVANCE_BLOCK()
> +                 block_ptr = row_ptr + pixel_ptr;
> +                 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
> +                     for (pixel_x = 0; pixel_x < 4; pixel_x++){
> +@@ -147,7 +148,6 @@ static void rpza_decode_stream(RpzaContext *s)
> +                     }
> +                     block_ptr += row_inc;
> +                 }
> +-                ADVANCE_BLOCK();
> +             }
> +             break;
> +
> +@@ -184,6 +184,7 @@ static void rpza_decode_stream(RpzaContext *s)
> +             color4[2] |= ((21 * ta + 11 * tb) >> 5);
> +
> +             while (n_blocks--) {
> ++                ADVANCE_BLOCK();
> +                 block_ptr = row_ptr + pixel_ptr;
> +                 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
> +                     index = s->buf[stream_ptr++];
> +@@ -194,12 +195,12 @@ static void rpza_decode_stream(RpzaContext *s)
> +                     }
> +                     block_ptr += row_inc;
> +                 }
> +-                ADVANCE_BLOCK();
> +             }
> +             break;
> +
> +         /* Fill block with 16 colors */
> +         case 0x00:
> ++            ADVANCE_BLOCK();
> +             block_ptr = row_ptr + pixel_ptr;
> +             for (pixel_y = 0; pixel_y < 4; pixel_y++) {
> +                 for (pixel_x = 0; pixel_x < 4; pixel_x++){
> +@@ -213,7 +214,6 @@ static void rpza_decode_stream(RpzaContext *s)
> +                 }
> +                 block_ptr += row_inc;
> +             }
> +-            ADVANCE_BLOCK();
> +             break;
> +
> +         /* Unknown opcode */
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
> new file mode 100644
> index 0000000..3ca6fc4
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
> @@ -0,0 +1,32 @@
> +From c17a0ad1df15a94d0b1239adc2afb593bdf0a153 Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Fri, 3 Oct 2014 22:50:45 +0200
> +Subject: [PATCH 1/2] avcodec/smc: fix off by 1 error
> +
> +Upstream-Status: Backport
> +
> +Fixes out of array access
> +Fixes: asan_heap-oob_1685bf0_5_asan_heap-oob_1f35116_430_smc.mov
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/smc.c | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/gst-libs/ext/libav/libavcodec/smc.c b/gst-libs/ext/libav/libavcodec/smc.c
> +index 3cd5e53..dec9f71 100644
> +--- a/gst-libs/ext/libav/libavcodec/smc.c
> ++++ b/gst-libs/ext/libav/libavcodec/smc.c
> +@@ -69,7 +69,7 @@ typedef struct SmcContext {
> +         row_ptr += stride * 4; \
> +     } \
> +     total_blocks--; \
> +-    if (total_blocks < 0) \
> ++    if (total_blocks < 0 + !!n_blocks) \
> +     { \
> +         av_log(s->avctx, AV_LOG_INFO, "warning: block counter just went negative (this should not happen)\n"); \
> +         return; \
> +--
> +2.1.0
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
> new file mode 100644
> index 0000000..68bb66e
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
> @@ -0,0 +1,69 @@
> +From 12770701856a05b6b3cd706f708f8e9a4e8a1336 Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Thu, 13 Feb 2014 13:59:51 +0100
> +Subject: [PATCH] avformat/mpegtsenc: Check data array size in
> + mpegts_write_pmt()
> +
> +Upstream-Status: Backport
> +
> +COmmit 12770701856a05b6b3cd706f708f8e9a4e8a1336 release/0.11
> +
> +Prevents out of array writes
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit 842b6c14bcfc1c5da1a2d288fd65386eb8c158ad)
> +
> +Conflicts:
> +
> +	libavformat/mpegtsenc.c
> +(cherry picked from commit e87de3f50b765134588d0b048c32ed4b8acc16fb)
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavformat/mpegtsenc.c |    9 +++++++--
> + 1 files changed, 7 insertions(+), 2 deletions(-)
> +
> +diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> +index 793e205..a12d19f 100644
> +--- a/gst-libs/ext/libav/libavformat/mpegtsenc.c
> ++++ b/gst-libs/ext/libav/libavformat/mpegtsenc.c
> +@@ -240,7 +240,7 @@ static void mpegts_write_pat(AVFormatContext *s)
> +                           data, q - data);
> + }
> +
> +-static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
> ++static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
> + {
> +     //    MpegTSWrite *ts = s->priv_data;
> +     uint8_t data[1012], *q, *desc_length_ptr, *program_info_length_ptr;
> +@@ -293,6 +293,10 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
> +             stream_type = STREAM_TYPE_PRIVATE_DATA;
> +             break;
> +         }
> ++
> ++        if (q - data > sizeof(data) - 32)
> ++            return AVERROR(EINVAL);
> ++
> +         *q++ = stream_type;
> +         put16(&q, 0xe000 | ts_st->pid);
> +         desc_length_ptr = q;
> +@@ -324,7 +328,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
> +                 len_ptr = q++;
> +                 *len_ptr = 0;
> +
> +-                for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next + 1) {
> ++                for (p = lang->value; next && *len_ptr < 255 / 4 * 4 && q - data < sizeof(data) - 4; p = next + 1) {
> +                     next = strchr(p, ',');
> +                     if (strlen(p) != 3 && (!next || next != p + 3))
> +                         continue; /* not a 3-letter code */
> +@@ -386,6 +390,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
> +     }
> +     mpegts_write_section1(&service->pmt, PMT_TID, service->sid, 0, 0, 0,
> +                           data, q - data);
> ++    return 0;
> + }
> +
> + /* NOTE: str == NULL is accepted for an empty string */
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
> new file mode 100644
> index 0000000..f45e3fd
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
> @@ -0,0 +1,29 @@
> +From 63ac64864c6e0e84355aa3caa5b92208997a9a8d Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Sat, 17 Nov 2012 16:26:55 +0100
> +Subject: [PATCH] eamad: fix out of array accesses
> +
> +Upstream-Status: Backport
> +
> +Commit 63ac64864c6e0e84355aa3caa5b92208997a9a8d release/1.1
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/eamad.c | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c
> +index 2805195..e38650e 100644
> +--- a/gst-libs/ext/libav/libavcodec/eamad.c
> ++++ b/gst-libs/ext/libav/libavcodec/eamad.c
> +@@ -237,7 +237,7 @@ static int decode_frame(AVCodecContext *avctx,
> +     int chunk_type;
> +     int inter;
> +
> +-    if (buf_size < 17) {
> ++    if (buf_size < 26) {
> +         av_log(avctx, AV_LOG_ERROR, "Input buffer too small\n");
> +         *data_size = 0;
> +         return -1;
> +--
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
> new file mode 100644
> index 0000000..e0e4239
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
> @@ -0,0 +1,29 @@
> +gst-ffmpeg: error concealment: initialize block index.
> +
> +Fixes CVE-2011-3941 (out of bounds write)
> +
> +Upstream-Status: Backport
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/error_resilience.c |    3 +++
> + 1 files changed, 3 insertions(+), 0 deletions(-)
> +
> +diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
> +index 8bb5d0c..d55c000 100644
> +--- a/gst-libs/ext/libav/libavcodec/error_resilience.c
> ++++ b/gst-libs/ext/libav/libavcodec/error_resilience.c
> +@@ -45,6 +45,9 @@ static void decode_mb(MpegEncContext *s, int ref){
> +     s->dest[1] = s->current_picture.data[1] + (s->mb_y * (16>>s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16>>s->chroma_x_shift);
> +     s->dest[2] = s->current_picture.data[2] + (s->mb_y * (16>>s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16>>s->chroma_x_shift);
> +
> ++    ff_init_block_index(s);
> ++    ff_update_block_index(s);
> ++
> +     if(CONFIG_H264_DECODER && s->codec_id == CODEC_ID_H264){
> +         H264Context *h= (void*)s;
> +         h->mb_xy= s->mb_x + s->mb_y*s->mb_stride;
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
> new file mode 100644
> index 0000000..8eef6e9
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
> @@ -0,0 +1,37 @@
> +gst-ffmpeg: error_concealment: Check that the picture is not in a half
> +
> +Fixes state becoming inconsistent
> +Fixes a null pointer dereference
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit 23318a57358358e7a4dc551e830e4503f0638cfe)
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Yue Tao <yue.tao@windriver.com>
> +
> +---
> + libavcodec/error_resilience.c |    6 ++++++
> + 1 files changed, 6 insertions(+), 0 deletions(-)
> +
> +diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
> +index 01f7424..2b6bc42 100644
> +--- a/gst-libs/ext/libav/libavcodec/error_resilience.c
> ++++ b/gst-libs/ext/libav/libavcodec/error_resilience.c
> +@@ -793,6 +793,12 @@ void ff_er_frame_end(MpegEncContext *s){
> +        s->picture_structure != PICT_FRAME || // we dont support ER of field pictures yet, though it should not crash if enabled
> +        s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return;
> +
> ++    if (   s->picture_structure == PICT_FRAME
> ++        && s->current_picture.linesize[0] != s->current_picture_ptr->linesize[0]) {
> ++        av_log(s->avctx, AV_LOG_ERROR, "Error concealment not possible, frame not fully initialized\n");
> ++        return;
> ++    }
> ++
> +     if(s->current_picture.motion_val[0] == NULL){
> +         av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
> +
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
> new file mode 100644
> index 0000000..80325db
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
> @@ -0,0 +1,36 @@
> +gst-ffmpeg: ffserver: set oformat
> +
> +Fix Ticket1986
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit cbe43e62c9ac7d4aefdc13476f6f691bd626525f)
> +
> +Upstream-Status: Backport
> +
> +---
> + ffserver.c |    4 +++-
> + 1 files changed, 3 insertions(+), 1 deletions(-)
> +
> +diff --git a/ffserver.c b/ffserver.c
> +index 4044d0f..8740140 100644
> +--- a/gst-libs/ext/libav/ffserver.c
> ++++ b/gst-libs/ext/libav/ffserver.c
> +@@ -2937,12 +2937,14 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
> + {
> +     AVFormatContext *avc;
> +     AVStream *avs = NULL;
> ++    AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
> +     int i;
> +
> +     avc =  avformat_alloc_context();
> +-    if (avc == NULL) {
> ++    if (avc == NULL || !rtp_format) {
> +         return -1;
> +     }
> ++    avc->oformat = rtp_format;
> +     av_dict_set(&avc->metadata, "title",
> +                stream->title[0] ? stream->title : "No Title", 0);
> +     avc->nb_streams = stream->nb_streams;
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
> new file mode 100644
> index 0000000..d4f55b2
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
> @@ -0,0 +1,29 @@
> +From d6c184880ee2e09fd68c0ae217173832cee5afc1 Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Sun, 18 Nov 2012 16:29:04 +0100
> +Subject: [PATCH] h264: correct ref count check and limit, fix out of array
> + accesses.
> +
> +Upstream-Status: Backport
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/h264.c | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/libavcodec/h264.c b/libavcodec/h264.c
> +index da43f1e..32cede5 100644
> +--- a/gst-libs/ext/libav/libavcodec/h264.c
> ++++ b/gst-libs/ext/libav/libavcodec/h264.c
> +@@ -2870,6 +2870,9 @@ static int decode_slice_header(H264Conte
> +             h->ref_count[0]= get_ue_golomb(&s->gb) + 1;
> +             if(h->slice_type_nos==AV_PICTURE_TYPE_B)
> +                 h->ref_count[1]= get_ue_golomb(&s->gb) + 1;
> ++            else
> ++                // full range is spec-ok in this case, even for frames
> ++                h->ref_count[1] = 1;
> +
> +             if(h->ref_count[0]-1 > 32-1 || h->ref_count[1]-1 > 32-1){
> +                 av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
> +--
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
> new file mode 100644
> index 0000000..05a9de3
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
> @@ -0,0 +1,145 @@
> +gst-ffmpeg: h264: set parameters from SPS whenever it changes
> +
> +Fixes a crash in the fuzzed sample sample_varPAR.avi_s26638 with
> +alternating bit depths.
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Yue Tao <yue.tao@windriver.com>
> +
> +diff --git a/gst-libs/ext/libav/libavcodec/h264.c.old b/gst-libs/ext/libav/libavcodec/h264.c
> +index 3621f41..718906a 100644
> +--- a/gst-libs/ext/libav/libavcodec/h264.c.old
> ++++ b/gst-libs/ext/libav/libavcodec/h264.c
> +@@ -2491,6 +2491,34 @@ int ff_h264_get_profile(SPS *sps)
> +     return profile;
> + }
> +
> ++static int h264_set_parameter_from_sps(H264Context *h)
> ++{
> ++    MpegEncContext *s = &h->s;
> ++    AVCodecContext * avctx= s->avctx;
> ++
> ++    if (s->flags& CODEC_FLAG_LOW_DELAY ||
> ++        (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames))
> ++        s->low_delay=1;
> ++
> ++    if(avctx->has_b_frames < 2)
> ++        avctx->has_b_frames= !s->low_delay;
> ++
> ++    if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
> ++        if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
> ++            avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
> ++            h->pixel_shift = h->sps.bit_depth_luma > 8;
> ++
> ++            ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
> ++            ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
> ++            dsputil_init(&s->dsp, s->avctx);
> ++        } else {
> ++            av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
> ++            return -1;
> ++        }
> ++    }
> ++    return 0;
> ++}
> ++
> + /**
> +  * decodes a slice header.
> +  * This will also call MPV_common_init() and frame_start() as needed.
> +@@ -2505,7 +2533,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
> +     MpegEncContext * const s0 = &h0->s;
> +     unsigned int first_mb_in_slice;
> +     unsigned int pps_id;
> +-    int num_ref_idx_active_override_flag;
> ++    int num_ref_idx_active_override_flag, ret;
> +     unsigned int slice_type, tmp, i, j;
> +     int default_ref_list_done = 0;
> +     int last_pic_structure;
> +@@ -2569,7 +2597,17 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
> +         av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS %u referenced\n", h->pps.sps_id);
> +         return -1;
> +     }
> +-    h->sps = *h0->sps_buffers[h->pps.sps_id];
> ++
> ++    if (h->pps.sps_id != h->current_sps_id ||
> ++        h0->sps_buffers[h->pps.sps_id]->new) {
> ++        h0->sps_buffers[h->pps.sps_id]->new = 0;
> ++
> ++        h->current_sps_id = h->pps.sps_id;
> ++        h->sps            = *h0->sps_buffers[h->pps.sps_id];
> ++
> ++        if ((ret = h264_set_parameter_from_sps(h)) < 0)
> ++            return ret;
> ++    }
> +
> +     s->avctx->profile = ff_h264_get_profile(&h->sps);
> +     s->avctx->level   = h->sps.level_idc;
> +@@ -3811,26 +3811,8 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
> +         case NAL_SPS:
> +             init_get_bits(&s->gb, ptr, bit_length);
> +             ff_h264_decode_seq_parameter_set(h);
> +-
> +-            if (s->flags& CODEC_FLAG_LOW_DELAY ||
> +-                (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames))
> +-                s->low_delay=1;
> +-
> +-            if(avctx->has_b_frames < 2)
> +-                avctx->has_b_frames= !s->low_delay;
> +-
> +-            if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
> +-                if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
> +-                    avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
> +-                    h->pixel_shift = h->sps.bit_depth_luma > 8;
> +-
> +-                    ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
> +-                    ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
> +-                    dsputil_init(&s->dsp, s->avctx);
> +-                } else {
> +-                    av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
> +-                    return -1;
> +-                }
> ++            if (h264_set_parameter_from_sps(h) < 0) {
> ++                return -1;
> +             }
> +             break;
> +         case NAL_PPS:
> +diff --git a/gst-libs/ext/libav/libavcodec/h264.h.old b/gst-libs/ext/libav/libavcodec/h264.h
> +index e3cc815..b77ad98 100644
> +--- a/gst-libs/ext/libav/libavcodec/h264.h.old
> ++++ b/gst-libs/ext/libav/libavcodec/h264.h
> +@@ -202,6 +202,7 @@ typedef struct SPS{
> +     int bit_depth_chroma;              ///< bit_depth_chroma_minus8 + 8
> +     int residual_color_transform_flag; ///< residual_colour_transform_flag
> +     int constraint_set_flags;          ///< constraint_set[0-3]_flag
> ++    int new;                              ///< flag to keep track if the decoder context needs re-init due to changed SPS
> + }SPS;
> +
> + /**
> +@@ -333,6 +334,7 @@ typedef struct H264Context{
> +     int emu_edge_width;
> +     int emu_edge_height;
> +
> ++    unsigned current_sps_id; ///< id of the current SPS
> +     SPS sps; ///< current sps
> +
> +     /**
> +diff --git a/gst-libs/ext/libav/libavcodec/h264_ps.c.old b/gst-libs/ext/libav/libavcodec/h264_ps.c
> +index 7491807..0929098 100644
> +--- a/gst-libs/ext/libav/libavcodec/h264_ps.c.old
> ++++ b/gst-libs/ext/libav/libavcodec/h264_ps.c
> +@@ -438,10 +438,13 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
> +                sps->timing_info_present_flag ? sps->time_scale : 0
> +                );
> +     }
> ++    sps->new = 1;
> +
> +     av_free(h->sps_buffers[sps_id]);
> +-    h->sps_buffers[sps_id]= sps;
> +-    h->sps = *sps;
> ++    h->sps_buffers[sps_id] = sps;
> ++    h->sps                 = *sps;
> ++    h->current_sps_id      = sps_id;
> ++
> +     return 0;
> + fail:
> +     av_free(sps);
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
> new file mode 100644
> index 0000000..5d45c1a
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
> @@ -0,0 +1,33 @@
> +gst-ffmpeg: h264: skip error concealment when SPS and slices are
> + mismatching
> +
> +Fixes out of array accesses
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit 695af8eed642ff0104834495652d1ee784a4c14d)
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +Signed-off-by: Yue Tao <yue.tao@windriver.com>
> +---
> + libavcodec/h264.c |    2 +-
> + 1 files changed, 1 insertions(+), 1 deletions(-)
> +
> +diff --git a/libavcodec/h264.c b/libavcodec/h264.c
> +index da144db..0aab4e7 100644
> +--- a/gst-libs/ext/libav/libavcodec/h264.c
> ++++ b/gst-libs/ext/libav/libavcodec/h264.c
> +@@ -2351,7 +2351,7 @@ static int field_end(H264Context *h, int in_setup)
> +      * past end by one (callers fault) and resync_mb_y != 0
> +      * causes problems for the first MB line, too.
> +      */
> +-    if (!FIELD_PICTURE)
> ++    if (!FIELD_PICTURE && h->current_slice && !h->sps.new)
> +         ff_er_frame_end(s);
> +
> +     ff_MPV_frame_end(s);
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
> new file mode 100644
> index 0000000..1e62b50
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
> @@ -0,0 +1,39 @@
> +gst-ffmpeg: h264_sei: Fix infinite loop.
> +
> +Fixsot yet fixed parts of CVE-2011-3946.
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Yue Tao <yue.tao@windriver.com>
> +
> +---
> + libavcodec/h264_sei.c |    4 ++++
> + 1 files changed, 4 insertions(+), 0 deletions(-)
> +
> +
> +diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
> +index 374e53d..80d70e5 100644
> +--- a/gst-libs/ext/libav/libavcodec/h264_sei.c
> ++++ b/gst-libs/ext/libav/libavcodec/h264_sei.c
> +@@ -169,11 +169,15 @@ int ff_h264_decode_sei(H264Context *h){
> +
> +         type=0;
> +         do{
> ++            if (get_bits_left(&s->gb) < 8)
> ++                return -1;
> +             type+= show_bits(&s->gb, 8);
> +         }while(get_bits(&s->gb, 8) == 255);
> +
> +         size=0;
> +         do{
> ++            if (get_bits_left(&s->gb) < 8)
> ++                return -1;
> +             size+= show_bits(&s->gb, 8);
> +         }while(get_bits(&s->gb, 8) == 255);
> +
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
> new file mode 100644
> index 0000000..e859e44
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
> @@ -0,0 +1,87 @@
> +From b666debffec1fcbb19ef377635a53b9a58bca8a4 Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Tue, 29 Jan 2013 18:29:41 +0100
> +Subject: [PATCH] huffyuvdec: Check init_vlc() return codes.
> +
> +Upstream-Status: Backport
> +
> +Commit b666debffec1fcbb19ef377635a53b9a58bca8a4 release/1.0
> +
> +Prevents out of array writes
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit f67a0d115254461649470452058fa3c28c0df294)
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/huffyuv.c | 14 ++++++++++----
> + 1 file changed, 10 insertions(+), 4 deletions(-)
> +
> +diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
> +index 58da789..993e524 100644
> +--- a/gst-libs/ext/libav/libavcodec/huffyuv.c
> ++++ b/gst-libs/ext/libav/libavcodec/huffyuv.c
> +@@ -33,6 +33,7 @@
> + #include "put_bits.h"
> + #include "dsputil.h"
> + #include "thread.h"
> ++#include "libavutil/avassert.h"
> +
> + #define VLC_BITS 11
> +
> +@@ -287,6 +287,7 @@ static void generate_joint_tables(HYuvCo
> +                     int len1 = s->len[p][u];
> +                     if (len1 > limit || !len1)
> +                         continue;
> ++                    av_assert0(i < (1 << VLC_BITS));
> +                     len[i] = len0 + len1;
> +                     bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
> +                     symbols[i] = (y<<8) + u;
> +@@ -320,6 +321,7 @@ static void generate_joint_tables(HYuvCo
> +                     int len2 = s->len[2][r&255];
> +                     if (len2 > limit1 || !len2)
> +                         continue;
> ++                    av_assert0(i < (1 << VLC_BITS));
> +                     len[i] = len0 + len1 + len2;
> +                     bits[i] = (code << len2) + s->bits[2][r&255];
> +                     if(s->decorrelate){
> +@@ -343,6 +345,7 @@ static void generate_joint_tables(HYuvCo
> + static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length){
> +     GetBitContext gb;
> +     int i;
> ++    int ret;
> +
> +     init_get_bits(&gb, src, length*8);
> +
> +@@ -353,7 +356,9 @@ static int read_huffman_tables(HYuvConte
> +             return -1;
> +         }
> +         free_vlc(&s->vlc[i]);
> +-        init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
> ++        if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
> ++                           s->bits[i], 4, 4, 0)) < 0)
> ++            return ret;
> +     }
> +
> +     generate_joint_tables(s);
> +@@ -365,6 +370,7 @@ static int read_old_huffman_tables(HYuvC
> + #if 1
> +     GetBitContext gb;
> +     int i;
> ++    int ret;
> +
> +     init_get_bits(&gb, classic_shift_luma, sizeof(classic_shift_luma)*8);
> +     if(read_len_table(s->len[0], &gb)<0)
> +@@ -385,7 +391,9 @@ static int read_old_huffman_tables(HYuvC
> +
> +     for(i=0; i<3; i++){
> +         free_vlc(&s->vlc[i]);
> +-        init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
> ++        if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
> ++                            s->bits[i], 4, 4, 0)) < 0)
> ++            return ret;
> +     }
> +
> +     generate_joint_tables(s);
> +--
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
> new file mode 100644
> index 0000000..94bf4b6
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
> @@ -0,0 +1,61 @@
> +From db0f7f7394e1f994ed38db043f78ed0f10bde0da Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Tue, 29 Jan 2013 19:22:33 +0100
> +Subject: [PATCH] huffyuvdec: Skip len==0 cases
> +
> +Upstream-Status: Backport
> +
> +Commit db0f7f7394e1f994ed38db043f78ed0f10bde0da release/1.0
> +
> +Fixes vlc decoding for hypothetical files that would contain such cases.
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit 0dfc01c2bbf4b71bb56201bc4a393321e15d1b31)
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/huffyuv.c | 10 +++++-----
> + 1 file changed, 5 insertions(+), 5 deletions(-)
> +
> +diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
> +index 993e524..72ed351 100644
> +--- a/gst-libs/ext/libav/libavcodec/huffyuv.c
> ++++ b/gst-libs/ext/libav/libavcodec/huffyuv.c
> +@@ -281,11 +281,11 @@ static void generate_joint_tables(HYuvCo
> +             for(i=y=0; y<256; y++){
> +                 int len0 = s->len[0][y];
> +                 int limit = VLC_BITS - len0;
> +-                if(limit <= 0)
> ++                if(limit <= 0 || !len0)
> +                     continue;
> +                 for(u=0; u<256; u++){
> +                     int len1 = s->len[p][u];
> +-                    if(len1 > limit)
> ++                    if (len1 > limit || !len1)
> +                         continue;
> +                     len[i] = len0 + len1;
> +                     bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
> +@@ -308,17 +308,17 @@ static void generate_joint_tables(HYuvCo
> +         for(i=0, g=-16; g<16; g++){
> +             int len0 = s->len[p0][g&255];
> +             int limit0 = VLC_BITS - len0;
> +-            if(limit0 < 2)
> ++            if (limit0 < 2 || !len0)
> +                 continue;
> +             for(b=-16; b<16; b++){
> +                 int len1 = s->len[p1][b&255];
> +                 int limit1 = limit0 - len1;
> +-                if(limit1 < 1)
> ++                if (limit1 < 1 || !len1)
> +                     continue;
> +                 code = (s->bits[p0][g&255] << len1) + s->bits[p1][b&255];
> +                 for(r=-16; r<16; r++){
> +                     int len2 = s->len[2][r&255];
> +-                    if(len2 > limit1)
> ++                    if (len2 > limit1 || !len2)
> +                         continue;
> +                     len[i] = len0 + len1 + len2;
> +                     bits[i] = (code << len2) + s->bits[2][r&255];
> +--
> +1.8.5.2.233.g932f7e4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
> new file mode 100644
> index 0000000..ea4aa22
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
> @@ -0,0 +1,45 @@
> +gst-ffmpeg: lavf: compute probe buffer size more reliably.
> +
> +The previous code computes the offset by reversing the growth
> +of the allocated buffer size: it is complex and did lead to
> +inconsistencies when the size limit is reached.
> +
> +Fix trac ticket #1991.
> +(cherry picked from commit 03847eb8259291b4ff1bd840bd779d0699d71f96)
> +
> +Conflicts:
> +	libavformat/utils.c
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Yue Tao <yue.tao@windriver.com>
> +
> +---
> + libavformat/utils.c |    4 ++--
> + 1 files changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/libavformat/utils.c b/libavformat/utils.c
> +index 7940037..be73c4a 100644
> +--- a/gst-libs/ext/libav/libavformat/utils.c
> ++++ b/gst-libs/ext/libav/libavformat/utils.c
> +@@ -459,7 +459,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
> + {
> +     AVProbeData pd = { filename ? filename : "", NULL, -offset };
> +     unsigned char *buf = NULL;
> +-    int ret = 0, probe_size;
> ++    int ret = 0, probe_size, buf_offset = 0;
> +
> +     if (!max_probe_size) {
> +         max_probe_size = PROBE_BUF_MAX;
> +@@ -499,7 +499,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
> +             score = 0;
> +             ret = 0;            /* error was end of file, nothing read */
> +         }
> +-        pd.buf_size += ret;
> ++        pd.buf_size = buf_offset += ret;
> +         pd.buf = &buf[offset];
> +
> +         memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
> new file mode 100644
> index 0000000..d90bafa
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
> @@ -0,0 +1,32 @@
> +From 1f41cffe1e3e79620f587545bdfcbd7e6e68ed29 Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Sun, 11 Nov 2012 00:01:24 +0100
> +Subject: [PATCH] mjpegdec: check SE.
> +
> +Upstream-Status: Backport
> +
> +Commit 1f41cffe1e3e79620f587545bdfcbd7e6e68ed29 release/1.1
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/mjpegdec.c | 5 +++++
> + 1 file changed, 5 insertions(+)
> +
> +diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> +index 6b5266d..0a71a6f 100644
> +--- a/gst-libs/ext/libav/libavcodec/mjpegdec.c
> ++++ b/gst-libs/ext/libav/libavcodec/mjpegdec.c
> +@@ -905,6 +905,11 @@ static int mjpeg_decode_scan_progressive
> +     int16_t *quant_matrix = s->quant_matrixes[ s->quant_index[c] ];
> +     GetBitContext mb_bitmask_gb;
> +
> ++    if (se > 63) {
> ++        av_log(s->avctx, AV_LOG_ERROR, "SE %d is too large\n", se);
> ++        return AVERROR_INVALIDDATA;
> ++    }
> ++
> +     if (mb_bitmask) {
> +         init_get_bits(&mb_bitmask_gb, mb_bitmask, s->mb_width*s->mb_height);
> +     }
> +--
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
> new file mode 100644
> index 0000000..1041347
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
> @@ -0,0 +1,34 @@
> +From 28bf685bfc6d0c744369cdf367f61a78d80d0b01 Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Thu, 15 Nov 2012 16:41:28 +0100
> +Subject: [PATCH] pgssubdec: check RLE size before copying. Fix out of array
> + accesses
> +
> +Upstream-Status: Backport
> +
> +Commit 28bf685bfc6d0c744369cdf367f61a78d80d0b01 release/1.1
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit c0d68be555f5858703383040e04fcd6529777061)
> +---
> + libavcodec/pgssubdec.c | 5 +++++
> + 1 file changed, 5 insertions(+)
> +
> +diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
> +index 728f178..26a3c2a 100644
> +--- a/gst-libs/ext/libav/libavcodec/pgssubdec.c
> ++++ b/gst-libs/ext/libav/libavcodec/pgssubdec.c
> +@@ -202,6 +202,11 @@ static int parse_picture_segment(AVCodec
> +         return -1;
> +     }
> +
> ++    if (buf_size > rle_bitmap_len) {
> ++        av_log(avctx, AV_LOG_ERROR, "too much RLE data\n");
> ++        return AVERROR_INVALIDDATA;
> ++    }
> ++
> +     ctx->picture.w = width;
> +     ctx->picture.h = height;
> +
> +--
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
> new file mode 100644
> index 0000000..1e5fb7d
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
> @@ -0,0 +1,44 @@
> +gst-ffmpeg: pngdec/filter: dont access out of array elements at the end
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Yue Tao <yue.tao@windriver.com>
> +---
> + libavcodec/pngdec.c |   12 ++++--------
> + 1 files changed, 4 insertions(+), 8 deletions(-)
> +
> +diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> +index 97c0ad1..193e35e 100644
> +--- a/gst-libs/ext/libav/libavcodec/pngdec.c
> ++++ b/gst-libs/ext/libav/libavcodec/pngdec.c
> +@@ -190,7 +190,7 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w
> +     if(bpp >= 2) g = dst[1];\
> +     if(bpp >= 3) b = dst[2];\
> +     if(bpp >= 4) a = dst[3];\
> +-    for(; i < size; i+=bpp) {\
> ++    for(; i <= size - bpp; i+=bpp) {\
> +         dst[i+0] = r = op(r, src[i+0], last[i+0]);\
> +         if(bpp == 1) continue;\
> +         dst[i+1] = g = op(g, src[i+1], last[i+1]);\
> +@@ -206,13 +206,9 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w
> +     else if(bpp == 2) UNROLL1(2, op)\
> +     else if(bpp == 3) UNROLL1(3, op)\
> +     else if(bpp == 4) UNROLL1(4, op)\
> +-    else {\
> +-        for (; i < size; i += bpp) {\
> +-            int j;\
> +-            for (j = 0; j < bpp; j++)\
> +-                dst[i+j] = op(dst[i+j-bpp], src[i+j], last[i+j]);\
> +-        }\
> +-    }
> ++    for (; i < size; i++) {\
> ++        dst[i] = op(dst[i-bpp], src[i], last[i]);\
> ++    }\
> +
> + /* NOTE: 'dst' can be equal to 'last' */
> + static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
> new file mode 100644
> index 0000000..8c94232
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
> @@ -0,0 +1,30 @@
> +gst-ffmpeg: qdm2: check array index before use, fix out of array
> + accesses
> +
> +Upstream-Status: Backport
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/qdm2.c |    5 +++++
> + 1 files changed, 5 insertions(+), 0 deletions(-)
> +
> +diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
> +index 4cf4b2f..1dfb8d5 100644
> +--- a/gst-libs/ext/libav/libavcodec/qdm2.c
> ++++ b/gst-libs/ext/libav/libavcodec/qdm2.c
> +@@ -1257,6 +1257,11 @@ static void qdm2_decode_super_block (QDM2Context *q)
> +     for (i = 0; packet_bytes > 0; i++) {
> +         int j;
> +
> ++        if (i>=FF_ARRAY_ELEMS(q->sub_packet_list_A)) {
> ++            SAMPLES_NEEDED_2("too many packet bytes");
> ++            return;
> ++        }
> ++
> +         q->sub_packet_list_A[i].next = NULL;
> +
> +         if (i > 0) {
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
> new file mode 100644
> index 0000000..43ffc03
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
> @@ -0,0 +1,58 @@
> +gst-ffmpeg: qdm2dec: fix buffer overflow. Fixes NGS00144
> +
> +This also adds a few lines of code from master that are needed for this fix.
> +
> +Thanks to Phillip for suggestions to improve the patch.
> +Found-by: Phillip Langlois
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/qdm2.c |    9 +++++++--
> + 1 files changed, 7 insertions(+), 2 deletions(-)
> +
> +diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
> +index 3aa9e5b..e000df8 100644
> +--- a/gst-libs/ext/libav/libavcodec/qdm2.c
> ++++ b/gst-libs/ext/libav/libavcodec/qdm2.c
> +@@ -76,6 +76,7 @@ do { \
> + #define SAMPLES_NEEDED_2(why) \
> +      av_log (NULL,AV_LOG_INFO,"This file triggers some missing code. Please contact the developers.\nPosition: %s\n",why);
> +
> ++#define QDM2_MAX_FRAME_SIZE 512
> +
> + typedef int8_t sb_int8_array[2][30][64];
> +
> +@@ -168,7 +169,7 @@ typedef struct {
> +     /// I/O data
> +     const uint8_t *compressed_data;
> +     int compressed_size;
> +-    float output_buffer[1024];
> ++    float output_buffer[QDM2_MAX_FRAME_SIZE * MPA_MAX_CHANNELS * 2];
> +
> +     /// Synthesis filter
> +     MPADSPContext mpadsp;
> +@@ -1819,6 +1820,9 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
> +     s->group_order = av_log2(s->group_size) + 1;
> +     s->frame_size = s->group_size / 16; // 16 iterations per super block
> +
> ++    if (s->frame_size > QDM2_MAX_FRAME_SIZE)
> ++        return AVERROR_INVALIDDATA;
> ++
> +     s->sub_sampling = s->fft_order - 7;
> +     s->frequency_range = 255 / (1 << (2 - s->sub_sampling));
> +
> +@@ -1887,6 +1891,9 @@ static int qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
> +     int ch, i;
> +     const int frame_size = (q->frame_size * q->channels);
> +
> ++    if((unsigned)frame_size > FF_ARRAY_ELEMS(q->output_buffer)/2)
> ++        return -1;
> ++
> +     /* select input buffer */
> +     q->compressed_data = in;
> +     q->compressed_size = q->checksum_size;
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
> new file mode 100644
> index 0000000..7e58afc
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
> @@ -0,0 +1,36 @@
> +From 391e0fc6c90ced6656b74f50f3a487b6dc76ea63 Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Thu, 29 Nov 2012 15:18:17 +0100
> +Subject: [PATCH] roqvideodec: check dimensions validity
> +
> +Upstream-Status: Backport
> +
> +Commit 391e0fc6c90ced6656b74f50f3a487b6dc76ea63 release/0.7
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit 3ae610451170cd5a28b33950006ff0bd23036845)
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/roqvideodec.c | 6 ++++++
> + 1 file changed, 6 insertions(+)
> +
> +diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c
> +index f0977f6..4e34231 100644
> +--- a/gst-libs/ext/libav/libavcodec/roqvideodec.c
> ++++ b/gst-libs/ext/libav/libavcodec/roqvideodec.c
> +@@ -157,6 +157,12 @@ static av_cold int roq_decode_init(AVCodecContext *avctx)
> +     RoqContext *s = avctx->priv_data;
> +
> +     s->avctx = avctx;
> ++
> ++    if (avctx->width%16 || avctx->height%16) {
> ++         av_log_ask_for_sample(avctx, "dimensions not being a multiple of 16 are unsupported\n");
> ++         return AVERROR_PATCHWELCOME;
> ++    }
> ++
> +     s->width = avctx->width;
> +     s->height = avctx->height;
> +     avcodec_get_frame_defaults(&s->frames[0]);
> +--
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
> new file mode 100644
> index 0000000..15b1614
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
> @@ -0,0 +1,32 @@
> +gst-ffmpeg: smackerdec: Check that the last indexes are within the
> + table.
> +
> +Fixes CVE-2011-3944
> +
> +Upstream-Status: Backport
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/smacker.c |    5 +++++
> + 1 files changed, 5 insertions(+), 0 deletions(-)
> +
> +diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
> +index 30f99b4..2a8bae8 100644
> +--- a/gst-libs/ext/libav/libavcodec/smacker.c
> ++++ b/gst-libs/ext/libav/libavcodec/smacker.c
> +@@ -259,6 +259,11 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
> +     if(ctx.last[0] == -1) ctx.last[0] = huff.current++;
> +     if(ctx.last[1] == -1) ctx.last[1] = huff.current++;
> +     if(ctx.last[2] == -1) ctx.last[2] = huff.current++;
> ++    if(huff.current > huff.length){
> ++        ctx.last[0] = ctx.last[1] = ctx.last[2] = 1;
> ++        av_log(smk->avctx, AV_LOG_ERROR, "bigtree damaged\n");
> ++        return -1;
> ++    }
> +
> +     *recodes = huff.values;
> +
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
> new file mode 100644
> index 0000000..a1989cf
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
> @@ -0,0 +1,32 @@
> +gst-ffmpeg: vp3: Copy all 3 frames for thread updates.
> +
> +This fixes a double release of the current frame on deinit.
> +Fixes CVE-2011-3934
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Yue.Tao <yue.tao@windriver.com>
> +
> +---
> + libavcodec/vp3.c |    2 +-
> + 1 files changed, 1 insertions(+), 1 deletions(-)
> +
> +diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> +index 738ae9f..b5daafc 100644
> +--- a/gst-libs/ext/libav/libavcodec/vp3.c
> ++++ b/gst-libs/ext/libav/libavcodec/vp3.c
> +@@ -1859,7 +1859,7 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
> +         ||s->width != s1->width
> +         ||s->height!= s1->height) {
> +         if (s != s1)
> +-            copy_fields(s, s1, golden_frame, current_frame);
> ++            copy_fields(s, s1, golden_frame, keyframe);
> +         return -1;
> +     }
> +
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
> new file mode 100644
> index 0000000..e83d8f4
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
> @@ -0,0 +1,183 @@
> +gst-ffmpeg: vp3: fix oob read for negative tokens and memleaks on error.
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Yue.Tao <yue.tao@windriver.com>
> +
> +---
> + libavcodec/vp3.c |   59 +++++++++++++++++++++++++++++++++++++++++------------
> + 1 files changed, 45 insertions(+), 14 deletions(-)
> +
> +diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> +index 36715bb..ce14e63 100644
> +--- a/gst-libs/ext/libav/libavcodec/vp3.c
> ++++ b/gst-libs/ext/libav/libavcodec/vp3.c
> +@@ -45,6 +45,7 @@
> + #define FRAGMENT_PIXELS 8
> +
> + static av_cold int vp3_decode_end(AVCodecContext *avctx);
> ++static void vp3_decode_flush(AVCodecContext *avctx);
> +
> + //FIXME split things out into their own arrays
> + typedef struct Vp3Fragment {
> +@@ -890,7 +891,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
> +             /* decode a VLC into a token */
> +             token = get_vlc2(gb, vlc_table, 11, 3);
> +             /* use the token to get a zero run, a coefficient, and an eob run */
> +-            if (token <= 6) {
> ++            if ((unsigned) token <= 6U) {
> +                 eob_run = eob_run_base[token];
> +                 if (eob_run_get_bits[token])
> +                     eob_run += get_bits(gb, eob_run_get_bits[token]);
> +@@ -908,7 +909,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
> +                     coeff_i        += eob_run;
> +                     eob_run = 0;
> +                 }
> +-            } else {
> ++            } else if (token >= 0) {
> +                 bits_to_get = coeff_get_bits[token];
> +                 if (bits_to_get)
> +                     bits_to_get = get_bits(gb, bits_to_get);
> +@@ -942,6 +943,10 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
> +                 for (i = coeff_index+1; i <= coeff_index+zero_run; i++)
> +                     s->num_coded_frags[plane][i]--;
> +                 coeff_i++;
> ++            } else {
> ++                av_log(s->avctx, AV_LOG_ERROR,
> ++                       "Invalid token %d\n", token);
> ++                return -1;
> +             }
> +     }
> +
> +@@ -991,6 +996,8 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
> +     /* unpack the Y plane DC coefficients */
> +     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0,
> +         0, residual_eob_run);
> ++    if (residual_eob_run < 0)
> ++        return residual_eob_run;
> +
> +     /* reverse prediction of the Y-plane DC coefficients */
> +     reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]);
> +@@ -998,8 +1005,12 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
> +     /* unpack the C plane DC coefficients */
> +     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
> +         1, residual_eob_run);
> ++    if (residual_eob_run < 0)
> ++        return residual_eob_run;
> +     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
> +         2, residual_eob_run);
> ++    if (residual_eob_run < 0)
> ++        return residual_eob_run;
> +
> +     /* reverse prediction of the C-plane DC coefficients */
> +     if (!(s->avctx->flags & CODEC_FLAG_GRAY))
> +@@ -1036,11 +1047,17 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
> +     for (i = 1; i <= 63; i++) {
> +             residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i,
> +                 0, residual_eob_run);
> ++            if (residual_eob_run < 0)
> ++                return residual_eob_run;
> +
> +             residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
> +                 1, residual_eob_run);
> ++            if (residual_eob_run < 0)
> ++                return residual_eob_run;
> +             residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
> +                 2, residual_eob_run);
> ++            if (residual_eob_run < 0)
> ++                return residual_eob_run;
> +     }
> +
> +     return 0;
> +@@ -1777,10 +1794,15 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
> +     Vp3DecodeContext *s = dst->priv_data, *s1 = src->priv_data;
> +     int qps_changed = 0, i, err;
> +
> ++#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
> ++
> +     if (!s1->current_frame.data[0]
> +         ||s->width != s1->width
> +-        ||s->height!= s1->height)
> ++        ||s->height!= s1->height) {
> ++        if (s != s1)
> ++            copy_fields(s, s1, golden_frame, current_frame);
> +         return -1;
> ++    }
> +
> +     if (s != s1) {
> +         // init tables if the first frame hasn't been decoded
> +@@ -1796,8 +1818,6 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
> +             memcpy(s->motion_val[1], s1->motion_val[1], c_fragment_count * sizeof(*s->motion_val[1]));
> +         }
> +
> +-#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
> +-
> +         // copy previous frame data
> +         copy_fields(s, s1, golden_frame, dsp);
> +
> +@@ -1987,9 +2007,6 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
> +     Vp3DecodeContext *s = avctx->priv_data;
> +     int i;
> +
> +-    if (avctx->is_copy && !s->current_frame.data[0])
> +-        return 0;
> +-
> +     av_free(s->superblock_coding);
> +     av_free(s->all_fragments);
> +     av_free(s->coded_fragment_list[0]);
> +@@ -2016,12 +2033,7 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
> +     free_vlc(&s->motion_vector_vlc);
> +
> +     /* release all frames */
> +-    if (s->golden_frame.data[0])
> +-        ff_thread_release_buffer(avctx, &s->golden_frame);
> +-    if (s->last_frame.data[0] && s->last_frame.type != FF_BUFFER_TYPE_COPY)
> +-        ff_thread_release_buffer(avctx, &s->last_frame);
> +-    /* no need to release the current_frame since it will always be pointing
> +-     * to the same frame as either the golden or last frame */
> ++    vp3_decode_flush(avctx);
> +
> +     return 0;
> + }
> +@@ -2341,6 +2353,23 @@ static void vp3_decode_flush(AVCodecContext *avctx)
> +         ff_thread_release_buffer(avctx, &s->current_frame);
> + }
> +
> ++static int vp3_init_thread_copy(AVCodecContext *avctx)
> ++{
> ++    Vp3DecodeContext *s = avctx->priv_data;
> ++
> ++    s->superblock_coding      = NULL;
> ++    s->all_fragments          = NULL;
> ++    s->coded_fragment_list[0] = NULL;
> ++    s->dct_tokens_base        = NULL;
> ++    s->superblock_fragments   = NULL;
> ++    s->macroblock_coding      = NULL;
> ++    s->motion_val[0]          = NULL;
> ++    s->motion_val[1]          = NULL;
> ++    s->edge_emu_buffer        = NULL;
> ++
> ++    return 0;
> ++}
> ++
> + AVCodec ff_theora_decoder = {
> +     .name           = "theora",
> +     .type           = AVMEDIA_TYPE_VIDEO,
> +@@ -2352,6 +2381,7 @@ AVCodec ff_theora_decoder = {
> +     .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
> +     .flush = vp3_decode_flush,
> +     .long_name = NULL_IF_CONFIG_SMALL("Theora"),
> ++    .init_thread_copy      = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
> +     .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
> + };
> + #endif
> +@@ -2367,5 +2397,6 @@ AVCodec ff_vp3_decoder = {
> +     .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
> +     .flush = vp3_decode_flush,
> +     .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"),
> ++    .init_thread_copy      = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
> +     .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
> + };
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
> new file mode 100644
> index 0000000..7e4f682
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
> @@ -0,0 +1,51 @@
> +From 2cac35086c9e103fa98960c546d5017e7363803a Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Fri, 25 Jan 2013 06:11:59 +0100
> +Subject: [PATCH] vqavideo: check chunk sizes before reading chunks
> +
> +Upstream-Status: Backport
> +
> +Commit 2cac35086c9e103fa98960c546d5017e7363803a release/0.7
> +
> +Fixes out of array writes
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +(cherry picked from commit ab6c9332bfa1e20127a16392a0b85a4aa4840889)
> +
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +---
> + libavcodec/vqavideo.c |   10 ++++++++++
> + 1 files changed, 10 insertions(+), 0 deletions(-)
> +
> +diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
> +index d1eab5b..6e1ce6c 100644
> +--- a/gst-libs/ext/libav/libavcodec/vqavideo.c
> ++++ b/gst-libs/ext/libav/libavcodec/vqavideo.c
> +@@ -527,6 +527,11 @@ static void vqa_decode_chunk(VqaContext *s)
> +         chunk_size = AV_RB32(&s->buf[cbp0_chunk + 4]);
> +         cbp0_chunk += CHUNK_PREAMBLE_SIZE;
> +
> ++        if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
> ++            av_log(s->avctx, AV_LOG_ERROR, "cbp0 chunk too large (0x%X bytes)\n", chunk_size);
> ++            return AVERROR_INVALIDDATA;
> ++        }
> ++
> +         /* accumulate partial codebook */
> +         memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
> +             &s->buf[cbp0_chunk], chunk_size);
> +@@ -550,6 +555,11 @@ static void vqa_decode_chunk(VqaContext *s)
> +         chunk_size = AV_RB32(&s->buf[cbpz_chunk + 4]);
> +         cbpz_chunk += CHUNK_PREAMBLE_SIZE;
> +
> ++        if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
> ++            av_log(s->avctx, AV_LOG_ERROR, "cbpz chunk too large (0x%X bytes)\n", chunk_size);
> ++            return AVERROR_INVALIDDATA;
> ++        }
> ++
> +         /* accumulate partial codebook */
> +         memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
> +             &s->buf[cbpz_chunk], chunk_size);
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
> new file mode 100644
> index 0000000..c8bafd5
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
> @@ -0,0 +1,68 @@
> +From 6043c431c97d55173f339fafbd033d3c0642e2e9 Mon Sep 17 00:00:00 2001
> +From: Michael Niedermayer <michaelni@gmx.at>
> +Date: Fri, 3 Oct 2014 01:50:27 +0200
> +Subject: [PATCH 2/2] avcodec/mjpegdec: check bits per pixel for changes
> + similar to dimensions
> +
> +Upstream-Status: Backport
> +
> +Fixes out of array accesses
> +Fixes: asan_heap-oob_16668e9_2_asan_heap-oob_16668e9_346_miss_congeniality_pegasus_mjpg.avi
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +
> +Conflicts:
> +	libavcodec/mjpegdec.c
> +---
> + libavcodec/mjpegdec.c | 15 ++++++++-------
> + 1 file changed, 8 insertions(+), 7 deletions(-)
> +
> +diff --git a/gst-libs/ext/libav/libavcodec/mjpegdec.c b/gst-libs/ext/libav/libavcodec/mjpegdec.c
> +index 84343c0..c0137d8 100644
> +--- a/gst-libs/ext/libav/libavcodec/mjpegdec.c
> ++++ b/gst-libs/ext/libav/libavcodec/mjpegdec.c
> +@@ -210,16 +210,16 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
> +
> + int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
> + {
> +-    int len, nb_components, i, width, height, pix_fmt_id;
> ++    int len, nb_components, i, bits, width, height, pix_fmt_id;
> +
> +     /* XXX: verify len field validity */
> +     len = get_bits(&s->gb, 16);
> +-    s->bits= get_bits(&s->gb, 8);
> ++    bits= get_bits(&s->gb, 8);
> +
> +-    if(s->pegasus_rct) s->bits=9;
> +-    if(s->bits==9 && !s->pegasus_rct) s->rct=1;    //FIXME ugly
> ++    if(s->pegasus_rct) bits=9;
> ++    if(bits==9 && !s->pegasus_rct) s->rct=1;    //FIXME ugly
> +
> +-    if (s->bits != 8 && !s->lossless){
> ++    if (bits != 8 && !s->lossless){
> +         av_log(s->avctx, AV_LOG_ERROR, "only 8 bits/component accepted\n");
> +         return -1;
> +     }
> +@@ -239,7 +239,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
> +     if (nb_components <= 0 ||
> +         nb_components > MAX_COMPONENTS)
> +         return -1;
> +-    if (s->ls && !(s->bits <= 8 || nb_components == 1)){
> ++    if (s->ls && !(bits <= 8 || nb_components == 1)){
> +         av_log(s->avctx, AV_LOG_ERROR, "only <= 8 bits/component or 16-bit gray accepted for JPEG-LS\n");
> +         return -1;
> +     }
> +@@ -272,10 +272,11 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
> +
> +     /* if different size, realloc/alloc picture */
> +     /* XXX: also check h_count and v_count */
> +-    if (width != s->width || height != s->height) {
> ++    if (width != s->width || height != s->height || bits != s->bits) {
> +         av_freep(&s->qscale_table);
> +
> +         s->width = width;
> ++        s->bits= bits;
> +         s->height = height;
> +         s->interlaced = 0;
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/configure-fix.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/configure-fix.patch
> new file mode 100644
> index 0000000..9ef6f7c
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/configure-fix.patch
> @@ -0,0 +1,22 @@
> +Disable yasm for libav when --disable-yasm
> +
> +Upstream-Status: Inappropriate [configuration]
> +
> +Signed-off-by: Shane Wang <shane.wang@intel.com>
> +
> +diff -r f2f8f74c6e30 configure.ac
> +--- a/configure.ac	Thu Dec 22 23:56:09 2011 +0800
> ++++ b/configure.ac	Thu Dec 22 23:57:37 2011 +0800
> +@@ -325,6 +325,12 @@
> +         --enable-gpl"
> +   fi
> +
> ++ AC_ARG_ENABLE(yasm,
> ++              [AC_HELP_STRING([--disable-yasm], [disable use of yasm assembler])])
> ++  if test "x$enable_yasm" = "xno"; then
> ++    embffmpeg_configure_args="$embffmpeg_configure_args --disable-yasm"
> ++  fi
> ++
> +   # if we are cross-compiling, tell ffmpeg so
> +   target_os=`echo $host_os | sed 's/-gnu//'`
> +   if test "x$cross_compiling" = xyes; then
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
> new file mode 100644
> index 0000000..3c8d8e3
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
> @@ -0,0 +1,100 @@
> +gst-ffmpeg: Security Advisory - ffmpeg - CVE-2013-0855
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Yue Tao <yue.tao@windriver.com>
> +
> +diff --git a/gst-libs/ext/libav/libavcodec/alac.c.old b/gst-libs/ext/libav/libavcodec/alac.c
> +index 2a0df8c..bcbd56d 100644
> +--- a/gst-libs/ext/libav/libavcodec/alac.c.old
> ++++ b/gst-libs/ext/libav/libavcodec/alac.c
> +@@ -87,18 +87,44 @@ typedef struct {
> +     int wasted_bits;
> + } ALACContext;
> +
> +-static void allocate_buffers(ALACContext *alac)
> ++static av_cold int alac_decode_close(AVCodecContext *avctx)
> ++{
> ++    ALACContext *alac = avctx->priv_data;
> ++
> ++    int chan;
> ++    for (chan = 0; chan < MAX_CHANNELS; chan++) {
> ++        av_freep(&alac->predicterror_buffer[chan]);
> ++        av_freep(&alac->outputsamples_buffer[chan]);
> ++        av_freep(&alac->wasted_bits_buffer[chan]);
> ++    }
> ++
> ++    return 0;
> ++}
> ++
> ++static int allocate_buffers(ALACContext *alac)
> + {
> +     int chan;
> ++    int buf_size;
> ++
> ++    if (alac->setinfo_max_samples_per_frame > INT_MAX / sizeof(int32_t))
> ++        goto buf_alloc_fail;
> ++    buf_size = alac->setinfo_max_samples_per_frame * sizeof(int32_t);
> ++
> +     for (chan = 0; chan < MAX_CHANNELS; chan++) {
> +-        alac->predicterror_buffer[chan] =
> +-            av_malloc(alac->setinfo_max_samples_per_frame * 4);
> +
> +-        alac->outputsamples_buffer[chan] =
> +-            av_malloc(alac->setinfo_max_samples_per_frame * 4);
> ++        FF_ALLOC_OR_GOTO(alac->avctx, alac->predicterror_buffer[chan],
> ++                         buf_size, buf_alloc_fail);
> +
> +-        alac->wasted_bits_buffer[chan] = av_malloc(alac->setinfo_max_samples_per_frame * 4);
> ++        FF_ALLOC_OR_GOTO(alac->avctx, alac->outputsamples_buffer[chan],
> ++                         buf_size, buf_alloc_fail);
> ++
> ++        FF_ALLOC_OR_GOTO(alac->avctx, alac->wasted_bits_buffer[chan],
> ++                         buf_size, buf_alloc_fail);
> +     }
> ++    return 0;
> ++buf_alloc_fail:
> ++    alac_decode_close(alac->avctx);
> ++    return AVERROR(ENOMEM);
> + }
> +
> + static int alac_set_info(ALACContext *alac)
> +@@ -131,8 +157,6 @@ static int alac_set_info(ALACContext *alac)
> +     bytestream_get_be32(&ptr);      /* bitrate ? */
> +     bytestream_get_be32(&ptr);      /* samplerate */
> +
> +-    allocate_buffers(alac);
> +-
> +     return 0;
> + }
> +
> +@@ -659,6 +683,7 @@ static int alac_decode_frame(AVCodecContext *avctx,
> +
> + static av_cold int alac_decode_init(AVCodecContext * avctx)
> + {
> ++    int ret;
> +     ALACContext *alac = avctx->priv_data;
> +     alac->avctx = avctx;
> +     alac->numchannels = alac->avctx->channels;
> +@@ -674,18 +699,9 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
> +         return -1;
> +     }
> +
> +-    return 0;
> +-}
> +-
> +-static av_cold int alac_decode_close(AVCodecContext *avctx)
> +-{
> +-    ALACContext *alac = avctx->priv_data;
> +-
> +-    int chan;
> +-    for (chan = 0; chan < MAX_CHANNELS; chan++) {
> +-        av_freep(&alac->predicterror_buffer[chan]);
> +-        av_freep(&alac->outputsamples_buffer[chan]);
> +-        av_freep(&alac->wasted_bits_buffer[chan]);
> ++    if ((ret = allocate_buffers(alac)) < 0) {
> ++        av_log(avctx, AV_LOG_ERROR, "Error allocating buffers\n");
> ++        return ret;
> +     }
> +
> +     return 0;
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
> new file mode 100644
> index 0000000..aa385f5
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
> @@ -0,0 +1,26 @@
> +avcodec/cdgraphics: check buffer size before use
> +
> +Fixes out of array accesses
> +
> +Backported from:http://git.videolan.org/?p=ffmpeg.git;a=commit;h=ad002e1a13a8df934bd6cb2c84175a4780ab8942
> +
> +Upstream-Status: Backport
> +
> +Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> +Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> +Signed-off-by: Ming Liu <ming.liu@windriver.com>
> +
> +diff -urpN a/gst-libs/ext/libav/libavcodec/cdgraphics.c b/gst-libs/ext/libav/libavcodec/cdgraphics.c
> +--- a/gst-libs/ext/libav/libavcodec/cdgraphics.c	2013-07-18 13:17:08.399876575 +0800
> ++++ b/gst-libs/ext/libav/libavcodec/cdgraphics.c	2013-07-18 13:18:05.880502267 +0800
> +@@ -291,7 +291,9 @@ static int cdg_decode_frame(AVCodecConte
> +     inst    = bytestream_get_byte(&buf);
> +     inst    &= CDG_MASK;
> +     buf += 2;  /// skipping 2 unneeded bytes
> +-    bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
> ++
> ++    if (buf_size > CDG_HEADER_SIZE)
> ++        bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
> +
> +     if ((command & CDG_MASK) == CDG_COMMAND) {
> +         switch (inst) {
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
> new file mode 100644
> index 0000000..ade24dc
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
> @@ -0,0 +1,57 @@
> +Backport http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=5f654897e325349dacf2546674e0510bb72ecb50;hp=250cebeb3b348c3da71f9972eb500d6005dc01f1
> +
> +Fixes these errors on x86
> +
> +libavcodec/x86/h264_qpel_mmx.c: Assembler messages:
> +libavcodec/x86/h264_qpel_mmx.c:1294: Error: operand type mismatch for `cmp'
> +libavcodec/x86/h264_qpel_mmx.c:1294: Error: operand type mismatch for `cmp'
> +libavcodec/x86/h264_qpel_mmx.c:1298: Error: operand type mismatch for `cmp'
> +libavcodec/x86/h264_qpel_mmx.c:1298: Error: operand type mismatch for `cmp'
> +libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
> +libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
> +libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
> +make[5]: *** [libavcodec/x86/dsputil_mmx.o] Error 1
> +
> +
> +Signed-off-by: Khem Raj <raj.khem@gmail.com>
> +Upstream-Status: Backport
> +Index: gst-ffmpeg-0.10.13/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c
> +===================================================================
> +--- gst-ffmpeg-0.10.13.orig/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c	2012-03-30 11:39:41.324522051 -0700
> ++++ gst-ffmpeg-0.10.13/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c	2012-03-30 11:54:08.152564075 -0700
> +@@ -398,7 +398,7 @@
> +             "2:                         \n\t"\
> +             \
> +             : "+a"(src), "+c"(dst)\
> +-            : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\
> ++            : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "rm"(h)\
> +             : "memory"\
> +         );\
> +         src += 4-(h+5)*srcStride;\
> +@@ -446,7 +446,7 @@
> +             QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 15*48)\
> +             "2:                     \n\t"\
> +             : "+a"(src)\
> +-            : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)\
> ++            : "c"(tmp), "S"((x86_reg)srcStride), "rm"(size)\
> +             : "memory"\
> +             );\
> +         tmp += 4;\
> +@@ -823,7 +823,7 @@
> +         "2:                          \n\t"\
> +         \
> +         : "+a"(src), "+c"(dst)\
> +-        : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\
> ++        : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "rm"(h)\
> +         : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
> +                        "%xmm4", "%xmm5", "%xmm6", "%xmm7",)\
> +           "memory"\
> +@@ -878,7 +878,7 @@
> +             QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 15*48)
> +             "2:                         \n\t"
> +             : "+a"(src)
> +-            : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)
> ++            : "c"(tmp), "S"((x86_reg)srcStride), "rm"(size)
> +             : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3",
> +                            "%xmm4", "%xmm5", "%xmm6", "%xmm7",)
> +               "memory"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav-9.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav-9.patch
> new file mode 100644
> index 0000000..1860752
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav-9.patch
> @@ -0,0 +1,9304 @@
> +Taken from gentoo patchset:
> +http://dev.gentoo.org/~tetromino/distfiles/gst-plugins-ffmpeg/gst-ffmpeg-0.10.13_p2012.11-libav-9-patches.tar.xz
> +
> +Upstream-Status: Pending
> +
> +Contains following changes, rebased to apply on top of our changes
> +0002-Fix-includes-for-systemwide-build.patch
> +0003-libav-Switch-to-non-deprecated-symbols.patch
> +0005-av-Update-for-some-constant-changes.patch
> +0006-av-Remove-palette-support-for-now.patch
> +0007-av-Port-remaining-simple-bits.patch
> +0008-av-Use-av_codec_is_-en-de-coder-API-instead-of-priva.patch
> +0009-avprotocol-Port-from-the-URL-protocol-handler-to-san.patch
> +0010-avdec-don-t-wait-for-keyframe.patch
> +
> +Following changes were skipped:
> +0001-Partially-revert-commit-0300801b.patch
> +0004-av-update-to-use-AVOption-variants.patch
> +0011-av_get_bits_per_sample_format-was-removed-in-libav-9.patch
> +
> +Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> +
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.c
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.c	2011-10-31 11:14:03.000000000 +0100
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.c	2014-08-08 15:26:07.872857555 +0200
> +@@ -151,9 +151,6 @@
> + #endif
> +   gst_ffmpegaudioresample_register (plugin);
> +
> +-  av_register_protocol2 (&gstreamer_protocol, sizeof (URLProtocol));
> +-  av_register_protocol2 (&gstpipe_protocol, sizeof (URLProtocol));
> +-
> +   /* Now we can return the pointer to the newly created Plugin object. */
> +   return TRUE;
> + }
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.h gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.h
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.h	2011-05-17 10:53:16.000000000 +0200
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.h	2014-08-08 15:26:07.872857555 +0200
> +@@ -58,10 +58,13 @@
> + int gst_ffmpeg_avcodec_close (AVCodecContext *avctx);
> + int gst_ffmpeg_av_find_stream_info(AVFormatContext *ic);
> +
> +-G_END_DECLS
> ++int gst_ffmpegdata_open (GstPad * pad, int flags, AVIOContext ** context);
> ++int gst_ffmpegdata_close (AVIOContext * h);
> ++typedef struct _GstFFMpegPipe GstFFMpegPipe;
> ++int gst_ffmpeg_pipe_open (GstFFMpegPipe *ffpipe, int flags, AVIOContext ** context);
> ++int gst_ffmpeg_pipe_close (AVIOContext * h);
> +
> +-extern URLProtocol gstreamer_protocol;
> +-extern URLProtocol gstpipe_protocol;
> ++G_END_DECLS
> +
> + /* use GST_FFMPEG URL_STREAMHEADER with URL_WRONLY if the first
> +  * buffer should be used as streamheader property on the pad's caps. */
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcfg.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcfg.c
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcfg.c	2011-07-12 16:35:27.000000000 +0200
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcfg.c	2014-08-08 15:24:17.899853612 +0200
> +@@ -147,7 +147,6 @@
> +       {FF_DCT_FASTINT, "Fast Integer", "fastint"},
> +       {FF_DCT_INT, "Accurate Integer", "int"},
> +       {FF_DCT_MMX, "MMX", "mmx"},
> +-      {FF_DCT_MLIB, "MLIB", "mlib"},
> +       {FF_DCT_ALTIVEC, "ALTIVEC", "altivec"},
> +       {FF_DCT_FAAN, "FAAN", "faan"},
> +       {0, NULL, NULL},
> +@@ -173,8 +172,6 @@
> +       {FF_IDCT_SIMPLE, "Simple", "simple"},
> +       {FF_IDCT_SIMPLEMMX, "Simple MMX", "simplemmx"},
> +       {FF_IDCT_LIBMPEG2MMX, "LIBMPEG2MMX", "libmpeg2mmx"},
> +-      {FF_IDCT_PS2, "PS2", "ps2"},
> +-      {FF_IDCT_MLIB, "MLIB", "mlib"},
> +       {FF_IDCT_ARM, "ARM", "arm"},
> +       {FF_IDCT_ALTIVEC, "ALTIVEC", "altivec"},
> +       {FF_IDCT_SH4, "SH4", "sh4"},
> +@@ -263,16 +260,11 @@
> +
> +   if (!ffmpeg_flags_type) {
> +     static const GFlagsValue ffmpeg_flags[] = {
> +-      {CODEC_FLAG_OBMC, "Use overlapped block motion compensation (h263+)",
> +-          "obmc"},
> +       {CODEC_FLAG_QSCALE, "Use fixed qscale", "qscale"},
> +       {CODEC_FLAG_4MV, "Allow 4 MV per MB", "4mv"},
> +-      {CODEC_FLAG_H263P_AIV, "H.263 alternative inter VLC", "aiv"},
> +       {CODEC_FLAG_QPEL, "Quartel Pel Motion Compensation", "qpel"},
> +       {CODEC_FLAG_GMC, "GMC", "gmc"},
> +       {CODEC_FLAG_MV0, "Always try a MB with MV (0,0)", "mv0"},
> +-      {CODEC_FLAG_PART,
> +-          "Store MV, DC and AC coefficients in seperate partitions", "part"},
> +       {CODEC_FLAG_LOOP_FILTER, "Loop filter", "loop-filter"},
> +       {CODEC_FLAG_GRAY, "Only decode/encode grayscale", "gray"},
> +       {CODEC_FLAG_NORMALIZE_AQP,
> +@@ -282,13 +274,9 @@
> +           "global-headers"},
> +       {CODEC_FLAG_AC_PRED, "H263 Advanced Intra Coding / MPEG4 AC prediction",
> +           "aic"},
> +-      {CODEC_FLAG_H263P_UMV, "Unlimited Motion Vector", "umv"},
> +       {CODEC_FLAG_CBP_RD, "Rate Distoration Optimization for CBP", "cbp-rd"},
> +       {CODEC_FLAG_QP_RD, "Rate Distoration Optimization for QP selection",
> +           "qp-rd"},
> +-      {CODEC_FLAG_H263P_SLICE_STRUCT, "H263 slice struct", "ss"},
> +-      {CODEC_FLAG_SVCD_SCAN_OFFSET,
> +-          "Reserve space for SVCD scan offset user data", "scanoffset"},
> +       {CODEC_FLAG_CLOSED_GOP, "Closed GOP", "closedgop"},
> +       {0, NULL, NULL},
> +     };
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c	2011-10-31 11:14:03.000000000 +0100
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c	2014-08-08 15:31:30.968869139 +0200
> +@@ -25,8 +25,10 @@
> + #include <gst/gst.h>
> + #ifdef HAVE_FFMPEG_UNINSTALLED
> + #include <avcodec.h>
> ++#include <channel_layout.h>
> + #else
> + #include <libavcodec/avcodec.h>
> ++#include <libavutil/channel_layout.h>
> + #endif
> + #include <string.h>
> +
> +@@ -35,43 +37,6 @@
> +
> + #include <gst/pbutils/codec-utils.h>
> +
> +-/*
> +- * Read a palette from a caps.
> +- */
> +-
> +-static void
> +-gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
> +-{
> +-  GstStructure *str = gst_caps_get_structure (caps, 0);
> +-  const GValue *palette_v;
> +-  const GstBuffer *palette;
> +-
> +-  /* do we have a palette? */
> +-  if ((palette_v = gst_structure_get_value (str, "palette_data")) && context) {
> +-    palette = gst_value_get_buffer (palette_v);
> +-    if (GST_BUFFER_SIZE (palette) >= AVPALETTE_SIZE) {
> +-      if (context->palctrl)
> +-        av_free (context->palctrl);
> +-      context->palctrl = av_malloc (sizeof (AVPaletteControl));
> +-      context->palctrl->palette_changed = 1;
> +-      memcpy (context->palctrl->palette, GST_BUFFER_DATA (palette),
> +-          AVPALETTE_SIZE);
> +-    }
> +-  }
> +-}
> +-
> +-static void
> +-gst_ffmpeg_set_palette (GstCaps * caps, AVCodecContext * context)
> +-{
> +-  if (context->palctrl) {
> +-    GstBuffer *palette = gst_buffer_new_and_alloc (AVPALETTE_SIZE);
> +-
> +-    memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
> +-        AVPALETTE_SIZE);
> +-    gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, palette, NULL);
> +-  }
> +-}
> +-
> + /* IMPORTANT: Keep this sorted by the ffmpeg channel masks */
> + static const struct
> + {
> +@@ -79,26 +44,26 @@
> +   GstAudioChannelPosition gst;
> + } _ff_to_gst_layout[] = {
> +   {
> +-  CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
> +-  CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
> +-  CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
> +-  CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
> +-  CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
> +-  CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
> +-  CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
> +-  CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
> +-  CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
> +-  CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
> +-  CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
> +-  CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> +-  CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> +-  CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> +-  CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> +-  CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> +-  CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> +-  CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> +-  CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
> +-  CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
> ++  AV_CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
> ++  AV_CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
> ++  AV_CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
> ++  AV_CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
> ++  AV_CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
> ++  AV_CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
> ++  AV_CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
> ++  AV_CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
> ++  AV_CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
> ++  AV_CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
> ++  AV_CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
> ++  AV_CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> ++  AV_CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> ++  AV_CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> ++  AV_CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> ++  AV_CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> ++  AV_CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> ++  AV_CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> ++  AV_CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
> ++  AV_CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
> + };
> +
> + static GstAudioChannelPosition *
> +@@ -342,8 +307,8 @@
> +
> +     if (channel_layout == 0) {
> +       const guint64 default_channel_set[] = {
> +-        0, 0, CH_LAYOUT_SURROUND, CH_LAYOUT_QUAD, CH_LAYOUT_5POINT0,
> +-        CH_LAYOUT_5POINT1, 0, CH_LAYOUT_7POINT1
> ++        0, 0, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_5POINT0,
> ++        AV_CH_LAYOUT_5POINT1, 0, AV_CH_LAYOUT_7POINT1
> +       };
> +
> +       switch (codec_id) {
> +@@ -1267,8 +1232,6 @@
> +     case CODEC_ID_FLIC:
> +     case CODEC_ID_VMDVIDEO:
> +     case CODEC_ID_VMDAUDIO:
> +-    case CODEC_ID_SONIC:
> +-    case CODEC_ID_SONIC_LS:
> +     case CODEC_ID_SNOW:
> +     case CODEC_ID_VIXL:
> +     case CODEC_ID_QPEG:
> +@@ -1689,11 +1652,6 @@
> +       gst_buffer_unref (data);
> +     }
> +
> +-    /* palette */
> +-    if (context) {
> +-      gst_ffmpeg_set_palette (caps, context);
> +-    }
> +-
> +     GST_LOG ("caps for codec_id=%d: %" GST_PTR_FORMAT, codec_id, caps);
> +
> +   } else {
> +@@ -1830,9 +1788,6 @@
> +             "bpp", G_TYPE_INT, bpp,
> +             "depth", G_TYPE_INT, depth,
> +             "endianness", G_TYPE_INT, endianness, NULL);
> +-        if (caps && context) {
> +-          gst_ffmpeg_set_palette (caps, context);
> +-        }
> +       }
> +     } else if (fmt) {
> +       caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-yuv",
> +@@ -1857,7 +1812,7 @@
> +  */
> +
> + static GstCaps *
> +-gst_ffmpeg_smpfmt_to_caps (enum SampleFormat sample_fmt,
> ++gst_ffmpeg_smpfmt_to_caps (enum AVSampleFormat sample_fmt,
> +     AVCodecContext * context, enum CodecID codec_id)
> + {
> +   GstCaps *caps = NULL;
> +@@ -1867,22 +1822,22 @@
> +   gboolean signedness = FALSE;
> +
> +   switch (sample_fmt) {
> +-    case SAMPLE_FMT_S16:
> ++    case AV_SAMPLE_FMT_S16:
> +       signedness = TRUE;
> +       bpp = 16;
> +       break;
> +
> +-    case SAMPLE_FMT_S32:
> ++    case AV_SAMPLE_FMT_S32:
> +       signedness = TRUE;
> +       bpp = 32;
> +       break;
> +
> +-    case SAMPLE_FMT_FLT:
> ++    case AV_SAMPLE_FMT_FLT:
> +       integer = FALSE;
> +       bpp = 32;
> +       break;
> +
> +-    case SAMPLE_FMT_DBL:
> ++    case AV_SAMPLE_FMT_DBL:
> +       integer = FALSE;
> +       bpp = 64;
> +       break;
> +@@ -1941,12 +1896,12 @@
> +     }
> +   } else {
> +     GstCaps *temp;
> +-    enum SampleFormat i;
> ++    enum AVSampleFormat i;
> +     AVCodecContext ctx = { 0, };
> +
> +     ctx.channels = -1;
> +     caps = gst_caps_new_empty ();
> +-    for (i = 0; i <= SAMPLE_FMT_DBL; i++) {
> ++    for (i = 0; i <= AV_SAMPLE_FMT_DBL; i++) {
> +       temp = gst_ffmpeg_smpfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
> +       if (temp != NULL) {
> +         gst_caps_append (caps, temp);
> +@@ -2049,9 +2004,9 @@
> +         gst_structure_get_int (structure, "endianness", &endianness)) {
> +       if (endianness == G_BYTE_ORDER) {
> +         if (width == 32)
> +-          context->sample_fmt = SAMPLE_FMT_FLT;
> ++          context->sample_fmt = AV_SAMPLE_FMT_FLT;
> +         else if (width == 64)
> +-          context->sample_fmt = SAMPLE_FMT_DBL;
> ++          context->sample_fmt = AV_SAMPLE_FMT_DBL;
> +       }
> +     }
> +   } else {
> +@@ -2062,9 +2017,9 @@
> +         gst_structure_get_int (structure, "endianness", &endianness)) {
> +       if ((endianness == G_BYTE_ORDER) && (signedness == TRUE)) {
> +         if ((width == 16) && (depth == 16))
> +-          context->sample_fmt = SAMPLE_FMT_S16;
> ++          context->sample_fmt = AV_SAMPLE_FMT_S16;
> +         else if ((width == 32) && (depth == 32))
> +-          context->sample_fmt = SAMPLE_FMT_S32;
> ++          context->sample_fmt = AV_SAMPLE_FMT_S32;
> +       }
> +     }
> +   }
> +@@ -2190,7 +2145,6 @@
> +       } else {
> +         if (bpp == 8) {
> +           context->pix_fmt = PIX_FMT_PAL8;
> +-          gst_ffmpeg_get_palette (caps, context);
> +         }
> +       }
> +     }
> +@@ -2576,7 +2530,6 @@
> +   switch (codec_type) {
> +     case AVMEDIA_TYPE_VIDEO:
> +       gst_ffmpeg_caps_to_pixfmt (caps, context, codec_id == CODEC_ID_RAWVIDEO);
> +-      gst_ffmpeg_get_palette (caps, context);
> +       break;
> +     case AVMEDIA_TYPE_AUDIO:
> +       gst_ffmpeg_caps_to_smpfmt (caps, context, FALSE);
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.orig
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.orig	1970-01-01 01:00:00.000000000 +0100
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.orig	2014-08-08 15:30:34.006867097 +0200
> +@@ -0,0 +1,3447 @@
> ++/* GStreamer
> ++ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
> ++ * This file:
> ++ * Copyright (c) 2002-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 <gst/gst.h>
> ++#ifdef HAVE_FFMPEG_UNINSTALLED
> ++#include <avcodec.h>
> ++#include <channel_layout.h>>
> ++#else
> ++#include <libavcodec/avcodec.h>
> ++#include <libavutil/channel_layout.h>
> ++#endif
> ++#include <string.h>
> ++
> ++#include "gstffmpeg.h"
> ++#include "gstffmpegcodecmap.h"
> ++
> ++#include <gst/pbutils/codec-utils.h>
> ++
> ++/*
> ++ * Read a palette from a caps.
> ++ */
> ++
> ++static void
> ++gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
> ++{
> ++  GstStructure *str = gst_caps_get_structure (caps, 0);
> ++  const GValue *palette_v;
> ++  const GstBuffer *palette;
> ++
> ++  /* do we have a palette? */
> ++  if ((palette_v = gst_structure_get_value (str, "palette_data")) && context) {
> ++    palette = gst_value_get_buffer (palette_v);
> ++    if (GST_BUFFER_SIZE (palette) >= AVPALETTE_SIZE) {
> ++      if (context->palctrl)
> ++        av_free (context->palctrl);
> ++      context->palctrl = av_malloc (sizeof (AVPaletteControl));
> ++      context->palctrl->palette_changed = 1;
> ++      memcpy (context->palctrl->palette, GST_BUFFER_DATA (palette),
> ++          AVPALETTE_SIZE);
> ++    }
> ++  }
> ++}
> ++
> ++static void
> ++gst_ffmpeg_set_palette (GstCaps * caps, AVCodecContext * context)
> ++{
> ++  if (context->palctrl) {
> ++    GstBuffer *palette = gst_buffer_new_and_alloc (AVPALETTE_SIZE);
> ++
> ++    memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
> ++        AVPALETTE_SIZE);
> ++    gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, palette, NULL);
> ++  }
> ++}
> ++
> ++/* IMPORTANT: Keep this sorted by the ffmpeg channel masks */
> ++static const struct
> ++{
> ++  guint64 ff;
> ++  GstAudioChannelPosition gst;
> ++} _ff_to_gst_layout[] = {
> ++  {
> ++  AV_CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
> ++  AV_CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
> ++  AV_CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
> ++  AV_CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
> ++  AV_CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
> ++  AV_CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
> ++  AV_CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
> ++  AV_CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
> ++  AV_CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
> ++  AV_CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
> ++  AV_CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
> ++  AV_CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> ++  AV_CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> ++  AV_CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> ++  AV_CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> ++  AV_CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> ++  AV_CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> ++  AV_CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> ++  AV_CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
> ++  AV_CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
> ++};
> ++
> ++static GstAudioChannelPosition *
> ++gst_ff_channel_layout_to_gst (guint64 channel_layout, guint channels)
> ++{
> ++  guint nchannels = 0, i, j;
> ++  GstAudioChannelPosition *pos = NULL;
> ++  gboolean none_layout = FALSE;
> ++
> ++  for (i = 0; i < 64; i++) {
> ++    if ((channel_layout & (G_GUINT64_CONSTANT (1) << i)) != 0) {
> ++      nchannels++;
> ++    }
> ++  }
> ++
> ++  if (channel_layout == 0) {
> ++    nchannels = channels;
> ++    none_layout = TRUE;
> ++  }
> ++
> ++  if (nchannels != channels) {
> ++    GST_ERROR ("Number of channels is different (%u != %u)", channels,
> ++        nchannels);
> ++    return NULL;
> ++  }
> ++
> ++  pos = g_new (GstAudioChannelPosition, nchannels);
> ++
> ++  for (i = 0, j = 0; i < G_N_ELEMENTS (_ff_to_gst_layout); i++) {
> ++    if ((channel_layout & _ff_to_gst_layout[i].ff) != 0) {
> ++      pos[j++] = _ff_to_gst_layout[i].gst;
> ++
> ++      if (_ff_to_gst_layout[i].gst == GST_AUDIO_CHANNEL_POSITION_NONE)
> ++        none_layout = TRUE;
> ++    }
> ++  }
> ++
> ++  if (j != nchannels) {
> ++    GST_WARNING ("Unknown channels in channel layout - assuming NONE layout");
> ++    none_layout = TRUE;
> ++  }
> ++
> ++  if (!none_layout && !gst_audio_check_channel_positions (pos, nchannels)) {
> ++    GST_ERROR ("Invalid channel layout %" G_GUINT64_FORMAT
> ++        " - assuming NONE layout", channel_layout);
> ++    none_layout = TRUE;
> ++  }
> ++
> ++  if (none_layout) {
> ++    if (nchannels == 1) {
> ++      pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_MONO;
> ++    } else if (nchannels == 2) {
> ++      pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
> ++      pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
> ++    } else if (channel_layout == 0) {
> ++      g_free (pos);
> ++      pos = NULL;
> ++    } else {
> ++      for (i = 0; i < nchannels; i++)
> ++        pos[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
> ++    }
> ++  }
> ++
> ++  if (nchannels == 1 && pos[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER) {
> ++    GST_DEBUG ("mono common case; won't set channel positions");
> ++    g_free (pos);
> ++    pos = NULL;
> ++  } else if (nchannels == 2 && pos[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT
> ++      && pos[1] == GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT) {
> ++    GST_DEBUG ("stereo common case; won't set channel positions");
> ++    g_free (pos);
> ++    pos = NULL;
> ++  }
> ++
> ++  return pos;
> ++}
> ++
> ++/* this macro makes a caps width fixed or unfixed width/height
> ++ * properties depending on whether we've got a context.
> ++ *
> ++ * See below for why we use this.
> ++ *
> ++ * We should actually do this stuff at the end, like in riff-media.c,
> ++ * but I'm too lazy today. Maybe later.
> ++ */
> ++static GstCaps *
> ++gst_ff_vid_caps_new (AVCodecContext * context, enum CodecID codec_id,
> ++    const char *mimetype, const char *fieldname, ...)
> ++{
> ++  GstStructure *structure = NULL;
> ++  GstCaps *caps = NULL;
> ++  va_list var_args;
> ++  gint i;
> ++
> ++  GST_LOG ("context:%p, codec_id:%d, mimetype:%s", context, codec_id, mimetype);
> ++
> ++  /* fixed, non probing context */
> ++  if (context != NULL && context->width != -1) {
> ++    gint num, denom;
> ++
> ++    caps = gst_caps_new_simple (mimetype,
> ++        "width", G_TYPE_INT, context->width,
> ++        "height", G_TYPE_INT, context->height, NULL);
> ++
> ++    num = context->time_base.den / context->ticks_per_frame;
> ++    denom = context->time_base.num;
> ++
> ++    if (!denom) {
> ++      GST_LOG ("invalid framerate: %d/0, -> %d/1", num, num);
> ++      denom = 1;
> ++    }
> ++    if (gst_util_fraction_compare (num, denom, 1000, 1) > 0) {
> ++      GST_LOG ("excessive framerate: %d/%d, -> 0/1", num, denom);
> ++      num = 0;
> ++      denom = 1;
> ++    }
> ++    GST_LOG ("setting framerate: %d/%d", num, denom);
> ++    gst_caps_set_simple (caps,
> ++        "framerate", GST_TYPE_FRACTION, num, denom, NULL);
> ++  } else {
> ++    /* so we are after restricted caps in this case */
> ++    switch (codec_id) {
> ++      case CODEC_ID_H261:
> ++      {
> ++        caps = gst_caps_new_simple (mimetype,
> ++            "width", G_TYPE_INT, 352,
> ++            "height", G_TYPE_INT, 288,
> ++            "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
> ++        gst_caps_append (caps, gst_caps_new_simple (mimetype,
> ++                "width", G_TYPE_INT, 176,
> ++                "height", G_TYPE_INT, 144,
> ++                "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL));
> ++        break;
> ++      }
> ++      case CODEC_ID_H263:
> ++      {
> ++        /* 128x96, 176x144, 352x288, 704x576, and 1408x1152. slightly reordered
> ++         * because we want automatic negotiation to go as close to 320x240 as
> ++         * possible. */
> ++        const static gint widths[] = { 352, 704, 176, 1408, 128 };
> ++        const static gint heights[] = { 288, 576, 144, 1152, 96 };
> ++        GstCaps *temp;
> ++        gint n_sizes = G_N_ELEMENTS (widths);
> ++
> ++        caps = gst_caps_new_empty ();
> ++        for (i = 0; i < n_sizes; i++) {
> ++          temp = gst_caps_new_simple (mimetype,
> ++              "width", G_TYPE_INT, widths[i],
> ++              "height", G_TYPE_INT, heights[i],
> ++              "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
> ++
> ++          gst_caps_append (caps, temp);
> ++        }
> ++        break;
> ++      }
> ++      case CODEC_ID_DVVIDEO:
> ++      {
> ++        static struct
> ++        {
> ++          guint32 csp;
> ++          gint width, height;
> ++          gint par_n, par_d;
> ++          gint framerate_n, framerate_d;
> ++        } profiles[] = {
> ++          {
> ++          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 480, 10, 11, 30000, 1001}, {
> ++          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 480, 40, 33, 30000, 1001}, {
> ++          GST_MAKE_FOURCC ('I', '4', '2', '0'), 720, 576, 59, 54, 25, 1}, {
> ++          GST_MAKE_FOURCC ('I', '4', '2', '0'), 720, 576, 118, 81, 25, 1}, {
> ++          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 576, 59, 54, 25, 1}, {
> ++          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 576, 118, 81, 25, 1}
> ++        };
> ++        GstCaps *temp;
> ++        gint n_sizes = G_N_ELEMENTS (profiles);
> ++
> ++        caps = gst_caps_new_empty ();
> ++        for (i = 0; i < n_sizes; i++) {
> ++          temp = gst_caps_new_simple (mimetype,
> ++              "width", G_TYPE_INT, profiles[i].width,
> ++              "height", G_TYPE_INT, profiles[i].height,
> ++              "framerate", GST_TYPE_FRACTION, profiles[i].framerate_n,
> ++              profiles[i].framerate_d, "pixel-aspect-ratio", GST_TYPE_FRACTION,
> ++              profiles[i].par_n, profiles[i].par_d, NULL);
> ++
> ++          gst_caps_append (caps, temp);
> ++        }
> ++        break;
> ++      }
> ++      case CODEC_ID_DNXHD:
> ++      {
> ++        caps = gst_caps_new_simple (mimetype,
> ++            "width", G_TYPE_INT, 1920,
> ++            "height", G_TYPE_INT, 1080,
> ++            "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
> ++        gst_caps_append (caps, gst_caps_new_simple (mimetype,
> ++                "width", G_TYPE_INT, 1280,
> ++                "height", G_TYPE_INT, 720,
> ++                "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL));
> ++        break;
> ++      }
> ++      default:
> ++        break;
> ++    }
> ++  }
> ++
> ++  /* no fixed caps or special restrictions applied;
> ++   * default unfixed setting */
> ++  if (!caps) {
> ++    GST_DEBUG ("Creating default caps");
> ++    caps = gst_caps_new_simple (mimetype,
> ++        "width", GST_TYPE_INT_RANGE, 16, 4096,
> ++        "height", GST_TYPE_INT_RANGE, 16, 4096,
> ++        "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
> ++  }
> ++
> ++  for (i = 0; i < gst_caps_get_size (caps); i++) {
> ++    va_start (var_args, fieldname);
> ++    structure = gst_caps_get_structure (caps, i);
> ++    gst_structure_set_valist (structure, fieldname, var_args);
> ++    va_end (var_args);
> ++  }
> ++
> ++  return caps;
> ++}
> ++
> ++/* same for audio - now with channels/sample rate
> ++ */
> ++static GstCaps *
> ++gst_ff_aud_caps_new (AVCodecContext * context, enum CodecID codec_id,
> ++    const char *mimetype, const char *fieldname, ...)
> ++{
> ++  GstCaps *caps = NULL;
> ++  GstStructure *structure = NULL;
> ++  gint i;
> ++  va_list var_args;
> ++
> ++  /* fixed, non-probing context */
> ++  if (context != NULL && context->channels != -1) {
> ++    GstAudioChannelPosition *pos;
> ++    guint64 channel_layout = context->channel_layout;
> ++
> ++    if (channel_layout == 0) {
> ++      const guint64 default_channel_set[] = {
> ++        0, 0, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_5POINT0,
> ++        AV_CH_LAYOUT_5POINT1, 0, AV_CH_LAYOUT_7POINT1
> ++      };
> ++
> ++      switch (codec_id) {
> ++        case CODEC_ID_EAC3:
> ++        case CODEC_ID_AC3:
> ++        case CODEC_ID_DTS:
> ++          if (context->channels > 0
> ++              && context->channels < G_N_ELEMENTS (default_channel_set))
> ++            channel_layout = default_channel_set[context->channels - 1];
> ++          break;
> ++        default:
> ++          break;
> ++      }
> ++    }
> ++
> ++    caps = gst_caps_new_simple (mimetype,
> ++        "rate", G_TYPE_INT, context->sample_rate,
> ++        "channels", G_TYPE_INT, context->channels, NULL);
> ++
> ++    pos = gst_ff_channel_layout_to_gst (channel_layout, context->channels);
> ++    if (pos != NULL) {
> ++      gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
> ++      g_free (pos);
> ++    }
> ++  } else {
> ++    gint maxchannels = 2;
> ++    const gint *rates = NULL;
> ++    gint n_rates = 0;
> ++
> ++    /* so we must be after restricted caps in this case */
> ++    switch (codec_id) {
> ++      case CODEC_ID_AAC:
> ++      case CODEC_ID_AAC_LATM:
> ++      case CODEC_ID_DTS:
> ++        maxchannels = 6;
> ++        break;
> ++      case CODEC_ID_MP2:
> ++      {
> ++        const static gint l_rates[] =
> ++            { 48000, 44100, 32000, 24000, 22050, 16000 };
> ++        n_rates = G_N_ELEMENTS (l_rates);
> ++        rates = l_rates;
> ++        break;
> ++      }
> ++      case CODEC_ID_EAC3:
> ++      case CODEC_ID_AC3:
> ++      {
> ++        const static gint l_rates[] = { 48000, 44100, 32000 };
> ++        maxchannels = 6;
> ++        n_rates = G_N_ELEMENTS (l_rates);
> ++        rates = l_rates;
> ++        break;
> ++      }
> ++      case CODEC_ID_ADPCM_G722:
> ++      {
> ++        const static gint l_rates[] = { 16000 };
> ++        n_rates = G_N_ELEMENTS (l_rates);
> ++        rates = l_rates;
> ++        maxchannels = 1;
> ++        break;
> ++      }
> ++      case CODEC_ID_ADPCM_G726:
> ++      {
> ++        const static gint l_rates[] = { 8000 };
> ++        n_rates = G_N_ELEMENTS (l_rates);
> ++        rates = l_rates;
> ++        maxchannels = 1;
> ++        break;
> ++      }
> ++      case CODEC_ID_ADPCM_SWF:
> ++      {
> ++        const static gint l_rates[] = { 11025, 22050, 44100 };
> ++        n_rates = G_N_ELEMENTS (l_rates);
> ++        rates = l_rates;
> ++        break;
> ++      }
> ++      case CODEC_ID_ROQ_DPCM:
> ++      {
> ++        const static gint l_rates[] = { 22050 };
> ++        n_rates = G_N_ELEMENTS (l_rates);
> ++        rates = l_rates;
> ++        break;
> ++      }
> ++      case CODEC_ID_AMR_NB:
> ++      {
> ++        const static gint l_rates[] = { 8000 };
> ++        maxchannels = 1;
> ++        n_rates = G_N_ELEMENTS (l_rates);
> ++        rates = l_rates;
> ++        break;
> ++      }
> ++      case CODEC_ID_AMR_WB:
> ++      {
> ++        const static gint l_rates[] = { 16000 };
> ++        maxchannels = 1;
> ++        n_rates = G_N_ELEMENTS (l_rates);
> ++        rates = l_rates;
> ++        break;
> ++      }
> ++      default:
> ++        break;
> ++    }
> ++
> ++    /* TODO: handle context->channel_layouts here to set
> ++     * the list of channel layouts supported by the encoder.
> ++     * Unfortunately no encoder uses this yet....
> ++     */
> ++    /* regardless of encode/decode, open up channels if applicable */
> ++    /* Until decoders/encoders expose the maximum number of channels
> ++     * they support, we whitelist them here. */
> ++    switch (codec_id) {
> ++      case CODEC_ID_WMAPRO:
> ++      case CODEC_ID_TRUEHD:
> ++        maxchannels = 8;
> ++        break;
> ++      default:
> ++        break;
> ++    }
> ++
> ++    if (maxchannels == 1)
> ++      caps = gst_caps_new_simple (mimetype,
> ++          "channels", G_TYPE_INT, maxchannels, NULL);
> ++    else
> ++      caps = gst_caps_new_simple (mimetype,
> ++          "channels", GST_TYPE_INT_RANGE, 1, maxchannels, NULL);
> ++    if (n_rates) {
> ++      GValue list = { 0, };
> ++      GstStructure *structure;
> ++
> ++      g_value_init (&list, GST_TYPE_LIST);
> ++      for (i = 0; i < n_rates; i++) {
> ++        GValue v = { 0, };
> ++
> ++        g_value_init (&v, G_TYPE_INT);
> ++        g_value_set_int (&v, rates[i]);
> ++        gst_value_list_append_value (&list, &v);
> ++        g_value_unset (&v);
> ++      }
> ++      structure = gst_caps_get_structure (caps, 0);
> ++      gst_structure_set_value (structure, "rate", &list);
> ++      g_value_unset (&list);
> ++    } else
> ++      gst_caps_set_simple (caps, "rate", GST_TYPE_INT_RANGE, 4000, 96000, NULL);
> ++  }
> ++
> ++  for (i = 0; i < gst_caps_get_size (caps); i++) {
> ++    va_start (var_args, fieldname);
> ++    structure = gst_caps_get_structure (caps, i);
> ++    gst_structure_set_valist (structure, fieldname, var_args);
> ++    va_end (var_args);
> ++  }
> ++
> ++  return caps;
> ++}
> ++
> ++/* Convert a FFMPEG codec ID and optional AVCodecContext
> ++ * to a GstCaps. If the context is ommitted, no fixed values
> ++ * for video/audio size will be included in the GstCaps
> ++ *
> ++ * CodecID is primarily meant for compressed data GstCaps!
> ++ *
> ++ * encode is a special parameter. gstffmpegdec will say
> ++ * FALSE, gstffmpegenc will say TRUE. The output caps
> ++ * depends on this, in such a way that it will be very
> ++ * specific, defined, fixed and correct caps for encoders,
> ++ * yet very wide, "forgiving" caps for decoders. Example
> ++ * for mp3: decode: audio/mpeg,mpegversion=1,layer=[1-3]
> ++ * but encode: audio/mpeg,mpegversion=1,layer=3,bitrate=x,
> ++ * rate=x,channels=x.
> ++ */
> ++
> ++GstCaps *
> ++gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
> ++    AVCodecContext * context, gboolean encode)
> ++{
> ++  GstCaps *caps = NULL;
> ++  gboolean buildcaps = FALSE;
> ++
> ++  GST_LOG ("codec_id:%d, context:%p, encode:%d", codec_id, context, encode);
> ++
> ++  switch (codec_id) {
> ++    case CODEC_ID_MPEG1VIDEO:
> ++      /* FIXME: bitrate */
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
> ++          "mpegversion", G_TYPE_INT, 1,
> ++          "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_MPEG2VIDEO:
> ++      if (encode) {
> ++        /* FIXME: bitrate */
> ++        caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
> ++            "mpegversion", G_TYPE_INT, 2,
> ++            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
> ++      } else {
> ++        /* decode both MPEG-1 and MPEG-2; width/height/fps are all in
> ++         * the MPEG video stream headers, so may be omitted from caps. */
> ++        caps = gst_caps_new_simple ("video/mpeg",
> ++            "mpegversion", GST_TYPE_INT_RANGE, 1, 2,
> ++            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
> ++      }
> ++      break;
> ++
> ++    case CODEC_ID_MPEG2VIDEO_XVMC:
> ++      /* this is a special ID - don't need it in GStreamer, I think */
> ++      break;
> ++
> ++    case CODEC_ID_H263:
> ++      if (encode) {
> ++        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h263",
> ++            "variant", G_TYPE_STRING, "itu",
> ++            "h263version", G_TYPE_STRING, "h263", NULL);
> ++      } else {
> ++        /* don't pass codec_id, we can decode other variants with the H263
> ++         * decoder that don't have specific size requirements
> ++         */
> ++        caps = gst_ff_vid_caps_new (context, CODEC_ID_NONE, "video/x-h263",
> ++            "variant", G_TYPE_STRING, "itu", NULL);
> ++      }
> ++      break;
> ++
> ++    case CODEC_ID_H263P:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h263",
> ++          "variant", G_TYPE_STRING, "itu",
> ++          "h263version", G_TYPE_STRING, "h263p", NULL);
> ++      if (encode && context) {
> ++
> ++        gst_caps_set_simple (caps,
> ++            "annex-f", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_4MV,
> ++            "annex-j", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_LOOP_FILTER,
> ++            "annex-i", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_AC_PRED,
> ++            "annex-t", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_AC_PRED,
> ++            NULL);
> ++      }
> ++      break;
> ++
> ++    case CODEC_ID_H263I:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-intel-h263",
> ++          "variant", G_TYPE_STRING, "intel", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_H261:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h261", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_RV10:
> ++    case CODEC_ID_RV20:
> ++    case CODEC_ID_RV30:
> ++    case CODEC_ID_RV40:
> ++    {
> ++      gint version;
> ++
> ++      switch (codec_id) {
> ++        case CODEC_ID_RV40:
> ++          version = 4;
> ++          break;
> ++        case CODEC_ID_RV30:
> ++          version = 3;
> ++          break;
> ++        case CODEC_ID_RV20:
> ++          version = 2;
> ++          break;
> ++        default:
> ++          version = 1;
> ++          break;
> ++      }
> ++
> ++      /* FIXME: context->sub_id must be filled in during decoding */
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-pn-realvideo",
> ++          "systemstream", G_TYPE_BOOLEAN, FALSE,
> ++          "rmversion", G_TYPE_INT, version, NULL);
> ++      if (context) {
> ++        gst_caps_set_simple (caps, "format", G_TYPE_INT, context->sub_id, NULL);
> ++        if (context->extradata_size >= 8) {
> ++          gst_caps_set_simple (caps,
> ++              "subformat", G_TYPE_INT, GST_READ_UINT32_BE (context->extradata),
> ++              NULL);
> ++        }
> ++      }
> ++    }
> ++      break;
> ++
> ++    case CODEC_ID_MP1:
> ++      /* FIXME: bitrate */
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
> ++          "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 1, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_MP2:
> ++      /* FIXME: bitrate */
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
> ++          "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 2, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_MP3:
> ++      if (encode) {
> ++        /* FIXME: bitrate */
> ++        caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
> ++            "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
> ++      } else {
> ++        /* Decodes MPEG-1 layer 1/2/3. Samplerate, channels et al are
> ++         * in the MPEG audio header, so may be omitted from caps. */
> ++        caps = gst_caps_new_simple ("audio/mpeg",
> ++            "mpegversion", G_TYPE_INT, 1,
> ++            "layer", GST_TYPE_INT_RANGE, 1, 3, NULL);
> ++      }
> ++      break;
> ++
> ++    case CODEC_ID_MUSEPACK7:
> ++      caps =
> ++          gst_ff_aud_caps_new (context, codec_id,
> ++          "audio/x-ffmpeg-parsed-musepack", "streamversion", G_TYPE_INT, 7,
> ++          NULL);
> ++      break;
> ++
> ++    case CODEC_ID_MUSEPACK8:
> ++      caps =
> ++          gst_ff_aud_caps_new (context, codec_id,
> ++          "audio/x-ffmpeg-parsed-musepack", "streamversion", G_TYPE_INT, 8,
> ++          NULL);
> ++      break;
> ++
> ++    case CODEC_ID_AC3:
> ++      /* FIXME: bitrate */
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-ac3", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_EAC3:
> ++      /* FIXME: bitrate */
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-eac3", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_TRUEHD:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-true-hd", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_ATRAC1:
> ++      caps =
> ++          gst_ff_aud_caps_new (context, codec_id, "audio/x-vnd.sony.atrac1",
> ++          NULL);
> ++      break;
> ++
> ++    case CODEC_ID_ATRAC3:
> ++      caps =
> ++          gst_ff_aud_caps_new (context, codec_id, "audio/x-vnd.sony.atrac3",
> ++          NULL);
> ++      break;
> ++
> ++    case CODEC_ID_DTS:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dts", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_APE:
> ++      caps =
> ++          gst_ff_aud_caps_new (context, codec_id, "audio/x-ffmpeg-parsed-ape",
> ++          NULL);
> ++      if (context) {
> ++        gst_caps_set_simple (caps,
> ++            "depth", G_TYPE_INT, context->bits_per_coded_sample, NULL);
> ++      }
> ++      break;
> ++
> ++    case CODEC_ID_MLP:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mlp", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_IMC:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-imc", NULL);
> ++      break;
> ++
> ++      /* MJPEG is normal JPEG, Motion-JPEG and Quicktime MJPEG-A. MJPEGB
> ++       * is Quicktime's MJPEG-B. LJPEG is lossless JPEG. I don't know what
> ++       * sp5x is, but it's apparently something JPEG... We don't separate
> ++       * between those in GStreamer. Should we (at least between MJPEG,
> ++       * MJPEG-B and sp5x decoding...)? */
> ++    case CODEC_ID_MJPEG:
> ++    case CODEC_ID_LJPEG:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "image/jpeg", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_SP5X:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/sp5x", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_MJPEGB:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mjpeg-b", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_MPEG4:
> ++      if (encode && context != NULL) {
> ++        /* I'm not exactly sure what ffmpeg outputs... ffmpeg itself uses
> ++         * the AVI fourcc 'DIVX', but 'mp4v' for Quicktime... */
> ++        switch (context->codec_tag) {
> ++          case GST_MAKE_FOURCC ('D', 'I', 'V', 'X'):
> ++            caps = gst_ff_vid_caps_new (context, codec_id, "video/x-divx",
> ++                "divxversion", G_TYPE_INT, 5, NULL);
> ++            break;
> ++          case GST_MAKE_FOURCC ('m', 'p', '4', 'v'):
> ++          default:
> ++            /* FIXME: bitrate */
> ++            caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
> ++                "systemstream", G_TYPE_BOOLEAN, FALSE,
> ++                "mpegversion", G_TYPE_INT, 4, NULL);
> ++            break;
> ++        }
> ++      } else {
> ++        /* The trick here is to separate xvid, divx, mpeg4, 3ivx et al */
> ++        caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
> ++            "mpegversion", G_TYPE_INT, 4,
> ++            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
> ++        if (encode) {
> ++          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
> ++                  "video/x-divx", "divxversion", G_TYPE_INT, 5, NULL));
> ++        } else {
> ++          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
> ++                  "video/x-divx", "divxversion", GST_TYPE_INT_RANGE, 4, 5,
> ++                  NULL));
> ++          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
> ++                  "video/x-xvid", NULL));
> ++          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
> ++                  "video/x-3ivx", NULL));
> ++        }
> ++      }
> ++      break;
> ++
> ++    case CODEC_ID_RAWVIDEO:
> ++      caps =
> ++          gst_ffmpeg_codectype_to_caps (AVMEDIA_TYPE_VIDEO, context, codec_id,
> ++          encode);
> ++      break;
> ++
> ++    case CODEC_ID_MSMPEG4V1:
> ++    case CODEC_ID_MSMPEG4V2:
> ++    case CODEC_ID_MSMPEG4V3:
> ++    {
> ++      gint version = 41 + codec_id - CODEC_ID_MSMPEG4V1;
> ++
> ++      /* encode-FIXME: bitrate */
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-msmpeg",
> ++          "msmpegversion", G_TYPE_INT, version, NULL);
> ++      if (!encode && codec_id == CODEC_ID_MSMPEG4V3) {
> ++        gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
> ++                "video/x-divx", "divxversion", G_TYPE_INT, 3, NULL));
> ++      }
> ++    }
> ++      break;
> ++
> ++    case CODEC_ID_WMV1:
> ++    case CODEC_ID_WMV2:
> ++    {
> ++      gint version = (codec_id == CODEC_ID_WMV1) ? 1 : 2;
> ++
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
> ++          "wmvversion", G_TYPE_INT, version, NULL);
> ++    }
> ++      break;
> ++
> ++    case CODEC_ID_FLV1:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-flash-video",
> ++          "flvversion", G_TYPE_INT, 1, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_SVQ1:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-svq",
> ++          "svqversion", G_TYPE_INT, 1, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_SVQ3:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-svq",
> ++          "svqversion", G_TYPE_INT, 3, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_DVAUDIO:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dv", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_DVVIDEO:
> ++    {
> ++      if (encode && context) {
> ++        guint32 fourcc;
> ++
> ++        switch (context->pix_fmt) {
> ++          case PIX_FMT_YUYV422:
> ++            fourcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
> ++            break;
> ++          case PIX_FMT_YUV420P:
> ++            fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
> ++            break;
> ++          case PIX_FMT_YUVA420P:
> ++            fourcc = GST_MAKE_FOURCC ('A', '4', '2', '0');
> ++            break;
> ++          case PIX_FMT_YUV411P:
> ++            fourcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
> ++            break;
> ++          case PIX_FMT_YUV422P:
> ++            fourcc = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
> ++            break;
> ++          case PIX_FMT_YUV410P:
> ++            fourcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
> ++            break;
> ++          default:
> ++            GST_WARNING
> ++                ("Couldnt' find fourcc for pixfmt %d, defaulting to I420",
> ++                context->pix_fmt);
> ++            fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
> ++            break;
> ++        }
> ++        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dv",
> ++            "systemstream", G_TYPE_BOOLEAN, FALSE,
> ++            "format", GST_TYPE_FOURCC, fourcc, NULL);
> ++      } else {
> ++        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dv",
> ++            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
> ++      }
> ++    }
> ++      break;
> ++
> ++    case CODEC_ID_WMAV1:
> ++    case CODEC_ID_WMAV2:
> ++    {
> ++      gint version = (codec_id == CODEC_ID_WMAV1) ? 1 : 2;
> ++
> ++      if (context) {
> ++        caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
> ++            "wmaversion", G_TYPE_INT, version,
> ++            "block_align", G_TYPE_INT, context->block_align,
> ++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> ++      } else {
> ++        caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
> ++            "wmaversion", G_TYPE_INT, version,
> ++            "block_align", GST_TYPE_INT_RANGE, 0, G_MAXINT,
> ++            "bitrate", GST_TYPE_INT_RANGE, 0, G_MAXINT, NULL);
> ++      }
> ++    }
> ++      break;
> ++    case CODEC_ID_WMAPRO:
> ++    {
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
> ++          "wmaversion", G_TYPE_INT, 3, NULL);
> ++      break;
> ++    }
> ++
> ++    case CODEC_ID_WMAVOICE:
> ++    {
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wms", NULL);
> ++      break;
> ++    }
> ++
> ++    case CODEC_ID_MACE3:
> ++    case CODEC_ID_MACE6:
> ++    {
> ++      gint version = (codec_id == CODEC_ID_MACE3) ? 3 : 6;
> ++
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mace",
> ++          "maceversion", G_TYPE_INT, version, NULL);
> ++    }
> ++      break;
> ++
> ++    case CODEC_ID_HUFFYUV:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-huffyuv", NULL);
> ++      if (context) {
> ++        gst_caps_set_simple (caps,
> ++            "bpp", G_TYPE_INT, context->bits_per_coded_sample, NULL);
> ++      }
> ++      break;
> ++
> ++    case CODEC_ID_CYUV:
> ++      caps =
> ++          gst_ff_vid_caps_new (context, codec_id, "video/x-compressed-yuv",
> ++          NULL);
> ++      break;
> ++
> ++    case CODEC_ID_H264:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h264", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_INDEO5:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
> ++          "indeoversion", G_TYPE_INT, 5, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_INDEO3:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
> ++          "indeoversion", G_TYPE_INT, 3, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_INDEO2:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
> ++          "indeoversion", G_TYPE_INT, 2, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_FLASHSV:
> ++      caps =
> ++          gst_ff_vid_caps_new (context, codec_id, "video/x-flash-screen", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_VP3:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp3", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_VP5:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp5", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_VP6:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_VP6F:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6-flash", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_VP6A:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6-alpha", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_VP8:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp8", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_THEORA:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-theora", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_AAC:
> ++    {
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg", NULL);
> ++
> ++      if (!encode) {
> ++        GValue arr = { 0, };
> ++        GValue item = { 0, };
> ++
> ++        g_value_init (&arr, GST_TYPE_LIST);
> ++        g_value_init (&item, G_TYPE_INT);
> ++        g_value_set_int (&item, 2);
> ++        gst_value_list_append_value (&arr, &item);
> ++        g_value_set_int (&item, 4);
> ++        gst_value_list_append_value (&arr, &item);
> ++        g_value_unset (&item);
> ++
> ++        gst_caps_set_value (caps, "mpegversion", &arr);
> ++        g_value_unset (&arr);
> ++
> ++        g_value_init (&arr, GST_TYPE_LIST);
> ++        g_value_init (&item, G_TYPE_STRING);
> ++        g_value_set_string (&item, "raw");
> ++        gst_value_list_append_value (&arr, &item);
> ++        g_value_set_string (&item, "adts");
> ++        gst_value_list_append_value (&arr, &item);
> ++        g_value_set_string (&item, "adif");
> ++        gst_value_list_append_value (&arr, &item);
> ++        g_value_unset (&item);
> ++
> ++        gst_caps_set_value (caps, "stream-format", &arr);
> ++        g_value_unset (&arr);
> ++      } else {
> ++        gst_caps_set_simple (caps, "mpegversion", G_TYPE_INT, 4,
> ++            "stream-format", G_TYPE_STRING, "raw",
> ++            "base-profile", G_TYPE_STRING, "lc", NULL);
> ++
> ++        if (context && context->extradata_size > 0)
> ++          gst_codec_utils_aac_caps_set_level_and_profile (caps,
> ++              context->extradata, context->extradata_size);
> ++      }
> ++
> ++      break;
> ++    }
> ++    case CODEC_ID_AAC_LATM:    /* LATM/LOAS AAC syntax */
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
> ++          "mpegversion", G_TYPE_INT, 4, "stream-format", G_TYPE_STRING, "loas",
> ++          NULL);
> ++      break;
> ++
> ++    case CODEC_ID_ASV1:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-asus",
> ++          "asusversion", G_TYPE_INT, 1, NULL);
> ++      break;
> ++    case CODEC_ID_ASV2:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-asus",
> ++          "asusversion", G_TYPE_INT, 2, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_FFV1:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ffv",
> ++          "ffvversion", G_TYPE_INT, 1, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_4XM:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-4xm", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_XAN_WC3:
> ++    case CODEC_ID_XAN_WC4:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-xan",
> ++          "wcversion", G_TYPE_INT, 3 - CODEC_ID_XAN_WC3 + codec_id, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_CLJR:
> ++      caps =
> ++          gst_ff_vid_caps_new (context, codec_id,
> ++          "video/x-cirrus-logic-accupak", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_FRAPS:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-fraps", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_MDEC:
> ++    case CODEC_ID_ROQ:
> ++    case CODEC_ID_INTERPLAY_VIDEO:
> ++      buildcaps = TRUE;
> ++      break;
> ++
> ++    case CODEC_ID_VCR1:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ati-vcr",
> ++          "vcrversion", G_TYPE_INT, 1, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_RPZA:
> ++      caps =
> ++          gst_ff_vid_caps_new (context, codec_id, "video/x-apple-video", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_CINEPAK:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-cinepak", NULL);
> ++      break;
> ++
> ++      /* WS_VQA belogns here (order) */
> ++
> ++    case CODEC_ID_MSRLE:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-rle",
> ++          "layout", G_TYPE_STRING, "microsoft", NULL);
> ++      if (context) {
> ++        gst_caps_set_simple (caps,
> ++            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
> ++      } else {
> ++        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 1, 64, NULL);
> ++      }
> ++      break;
> ++
> ++    case CODEC_ID_QTRLE:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-rle",
> ++          "layout", G_TYPE_STRING, "quicktime", NULL);
> ++      if (context) {
> ++        gst_caps_set_simple (caps,
> ++            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
> ++      } else {
> ++        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 1, 64, NULL);
> ++      }
> ++      break;
> ++
> ++    case CODEC_ID_MSVIDEO1:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-msvideocodec",
> ++          "msvideoversion", G_TYPE_INT, 1, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_WMV3:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
> ++          "wmvversion", G_TYPE_INT, 3, NULL);
> ++      break;
> ++    case CODEC_ID_VC1:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
> ++          "wmvversion", G_TYPE_INT, 3, "format", GST_TYPE_FOURCC,
> ++          GST_MAKE_FOURCC ('W', 'V', 'C', '1'), NULL);
> ++      break;
> ++    case CODEC_ID_QDM2:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-qdm2", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_MSZH:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mszh", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_ZLIB:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-zlib", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_TRUEMOTION1:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-truemotion",
> ++          "trueversion", G_TYPE_INT, 1, NULL);
> ++      break;
> ++    case CODEC_ID_TRUEMOTION2:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-truemotion",
> ++          "trueversion", G_TYPE_INT, 2, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_ULTI:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ultimotion",
> ++          NULL);
> ++      break;
> ++
> ++    case CODEC_ID_TSCC:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-camtasia", NULL);
> ++      if (context) {
> ++        gst_caps_set_simple (caps,
> ++            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
> ++      } else {
> ++        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 8, 32, NULL);
> ++      }
> ++      break;
> ++
> ++    case CODEC_ID_KMVC:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-kmvc", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_NUV:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-nuv", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_GIF:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "image/gif", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_PNG:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "image/png", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_PPM:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "image/ppm", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_PBM:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "image/pbm", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_PAM:
> ++      caps =
> ++          gst_ff_vid_caps_new (context, codec_id, "image/x-portable-anymap",
> ++          NULL);
> ++      break;
> ++
> ++    case CODEC_ID_PGM:
> ++      caps =
> ++          gst_ff_vid_caps_new (context, codec_id, "image/x-portable-graymap",
> ++          NULL);
> ++      break;
> ++
> ++    case CODEC_ID_PCX:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-pcx", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_SGI:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-sgi", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_TARGA:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-tga", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_TIFF:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "image/tiff", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_SUNRAST:
> ++      caps =
> ++          gst_ff_vid_caps_new (context, codec_id, "image/x-sun-raster", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_SMC:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-smc", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_QDRAW:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-qdrw", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_DNXHD:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dnxhd", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_MIMIC:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mimic", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_VMNC:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vmnc", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_TRUESPEECH:
> ++      caps =
> ++          gst_ff_aud_caps_new (context, codec_id, "audio/x-truespeech", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_QCELP:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/qcelp", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_AMV:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-amv", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_AASC:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-aasc", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_LOCO:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-loco", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_ZMBV:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-zmbv", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_LAGARITH:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-lagarith", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_CSCD:
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-camstudio", NULL);
> ++      if (context) {
> ++        gst_caps_set_simple (caps,
> ++            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
> ++      } else {
> ++        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 8, 32, NULL);
> ++      }
> ++      break;
> ++
> ++    case CODEC_ID_WS_VQA:
> ++    case CODEC_ID_IDCIN:
> ++    case CODEC_ID_8BPS:
> ++    case CODEC_ID_FLIC:
> ++    case CODEC_ID_VMDVIDEO:
> ++    case CODEC_ID_VMDAUDIO:
> ++    case CODEC_ID_SNOW:
> ++    case CODEC_ID_VIXL:
> ++    case CODEC_ID_QPEG:
> ++    case CODEC_ID_PGMYUV:
> ++    case CODEC_ID_FFVHUFF:
> ++    case CODEC_ID_WNV1:
> ++    case CODEC_ID_MP3ADU:
> ++    case CODEC_ID_MP3ON4:
> ++    case CODEC_ID_WESTWOOD_SND1:
> ++    case CODEC_ID_MMVIDEO:
> ++    case CODEC_ID_AVS:
> ++    case CODEC_ID_CAVS:
> ++      buildcaps = TRUE;
> ++      break;
> ++
> ++      /* weird quasi-codecs for the demuxers only */
> ++    case CODEC_ID_PCM_S16LE:
> ++    case CODEC_ID_PCM_S16BE:
> ++    case CODEC_ID_PCM_U16LE:
> ++    case CODEC_ID_PCM_U16BE:
> ++    case CODEC_ID_PCM_S8:
> ++    case CODEC_ID_PCM_U8:
> ++    {
> ++      gint width = 0, depth = 0, endianness = 0;
> ++      gboolean signedness = FALSE;      /* blabla */
> ++
> ++      switch (codec_id) {
> ++        case CODEC_ID_PCM_S16LE:
> ++          width = 16;
> ++          depth = 16;
> ++          endianness = G_LITTLE_ENDIAN;
> ++          signedness = TRUE;
> ++          break;
> ++        case CODEC_ID_PCM_S16BE:
> ++          width = 16;
> ++          depth = 16;
> ++          endianness = G_BIG_ENDIAN;
> ++          signedness = TRUE;
> ++          break;
> ++        case CODEC_ID_PCM_U16LE:
> ++          width = 16;
> ++          depth = 16;
> ++          endianness = G_LITTLE_ENDIAN;
> ++          signedness = FALSE;
> ++          break;
> ++        case CODEC_ID_PCM_U16BE:
> ++          width = 16;
> ++          depth = 16;
> ++          endianness = G_BIG_ENDIAN;
> ++          signedness = FALSE;
> ++          break;
> ++        case CODEC_ID_PCM_S8:
> ++          width = 8;
> ++          depth = 8;
> ++          endianness = G_BYTE_ORDER;
> ++          signedness = TRUE;
> ++          break;
> ++        case CODEC_ID_PCM_U8:
> ++          width = 8;
> ++          depth = 8;
> ++          endianness = G_BYTE_ORDER;
> ++          signedness = FALSE;
> ++          break;
> ++        default:
> ++          g_assert (0);         /* don't worry, we never get here */
> ++          break;
> ++      }
> ++
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-int",
> ++          "width", G_TYPE_INT, width,
> ++          "depth", G_TYPE_INT, depth,
> ++          "endianness", G_TYPE_INT, endianness,
> ++          "signed", G_TYPE_BOOLEAN, signedness, NULL);
> ++    }
> ++      break;
> ++
> ++    case CODEC_ID_PCM_MULAW:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mulaw", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_PCM_ALAW:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-alaw", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_ADPCM_G722:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/G722", NULL);
> ++      if (context)
> ++        gst_caps_set_simple (caps,
> ++            "block_align", G_TYPE_INT, context->block_align,
> ++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> ++      break;
> ++
> ++    case CODEC_ID_ADPCM_G726:
> ++    {
> ++      /* the G726 decoder can also handle G721 */
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-adpcm",
> ++          "layout", G_TYPE_STRING, "g726", NULL);
> ++      if (context)
> ++        gst_caps_set_simple (caps,
> ++            "block_align", G_TYPE_INT, context->block_align,
> ++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> ++
> ++      if (!encode) {
> ++        gst_caps_append (caps, gst_caps_new_simple ("audio/x-adpcm",
> ++                "layout", G_TYPE_STRING, "g721",
> ++                "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL));
> ++      }
> ++      break;
> ++    }
> ++    case CODEC_ID_ADPCM_IMA_QT:
> ++    case CODEC_ID_ADPCM_IMA_WAV:
> ++    case CODEC_ID_ADPCM_IMA_DK3:
> ++    case CODEC_ID_ADPCM_IMA_DK4:
> ++    case CODEC_ID_ADPCM_IMA_WS:
> ++    case CODEC_ID_ADPCM_IMA_SMJPEG:
> ++    case CODEC_ID_ADPCM_IMA_AMV:
> ++    case CODEC_ID_ADPCM_IMA_ISS:
> ++    case CODEC_ID_ADPCM_IMA_EA_EACS:
> ++    case CODEC_ID_ADPCM_IMA_EA_SEAD:
> ++    case CODEC_ID_ADPCM_MS:
> ++    case CODEC_ID_ADPCM_4XM:
> ++    case CODEC_ID_ADPCM_XA:
> ++    case CODEC_ID_ADPCM_ADX:
> ++    case CODEC_ID_ADPCM_EA:
> ++    case CODEC_ID_ADPCM_CT:
> ++    case CODEC_ID_ADPCM_SWF:
> ++    case CODEC_ID_ADPCM_YAMAHA:
> ++    case CODEC_ID_ADPCM_SBPRO_2:
> ++    case CODEC_ID_ADPCM_SBPRO_3:
> ++    case CODEC_ID_ADPCM_SBPRO_4:
> ++    case CODEC_ID_ADPCM_EA_R1:
> ++    case CODEC_ID_ADPCM_EA_R2:
> ++    case CODEC_ID_ADPCM_EA_R3:
> ++    case CODEC_ID_ADPCM_EA_MAXIS_XA:
> ++    case CODEC_ID_ADPCM_EA_XAS:
> ++    case CODEC_ID_ADPCM_THP:
> ++    {
> ++      const gchar *layout = NULL;
> ++
> ++      switch (codec_id) {
> ++        case CODEC_ID_ADPCM_IMA_QT:
> ++          layout = "quicktime";
> ++          break;
> ++        case CODEC_ID_ADPCM_IMA_WAV:
> ++          layout = "dvi";
> ++          break;
> ++        case CODEC_ID_ADPCM_IMA_DK3:
> ++          layout = "dk3";
> ++          break;
> ++        case CODEC_ID_ADPCM_IMA_DK4:
> ++          layout = "dk4";
> ++          break;
> ++        case CODEC_ID_ADPCM_IMA_WS:
> ++          layout = "westwood";
> ++          break;
> ++        case CODEC_ID_ADPCM_IMA_SMJPEG:
> ++          layout = "smjpeg";
> ++          break;
> ++        case CODEC_ID_ADPCM_IMA_AMV:
> ++          layout = "amv";
> ++          break;
> ++        case CODEC_ID_ADPCM_IMA_ISS:
> ++          layout = "iss";
> ++          break;
> ++        case CODEC_ID_ADPCM_IMA_EA_EACS:
> ++          layout = "ea-eacs";
> ++          break;
> ++        case CODEC_ID_ADPCM_IMA_EA_SEAD:
> ++          layout = "ea-sead";
> ++          break;
> ++        case CODEC_ID_ADPCM_MS:
> ++          layout = "microsoft";
> ++          break;
> ++        case CODEC_ID_ADPCM_4XM:
> ++          layout = "4xm";
> ++          break;
> ++        case CODEC_ID_ADPCM_XA:
> ++          layout = "xa";
> ++          break;
> ++        case CODEC_ID_ADPCM_ADX:
> ++          layout = "adx";
> ++          break;
> ++        case CODEC_ID_ADPCM_EA:
> ++          layout = "ea";
> ++          break;
> ++        case CODEC_ID_ADPCM_CT:
> ++          layout = "ct";
> ++          break;
> ++        case CODEC_ID_ADPCM_SWF:
> ++          layout = "swf";
> ++          break;
> ++        case CODEC_ID_ADPCM_YAMAHA:
> ++          layout = "yamaha";
> ++          break;
> ++        case CODEC_ID_ADPCM_SBPRO_2:
> ++          layout = "sbpro2";
> ++          break;
> ++        case CODEC_ID_ADPCM_SBPRO_3:
> ++          layout = "sbpro3";
> ++          break;
> ++        case CODEC_ID_ADPCM_SBPRO_4:
> ++          layout = "sbpro4";
> ++          break;
> ++        case CODEC_ID_ADPCM_EA_R1:
> ++          layout = "ea-r1";
> ++          break;
> ++        case CODEC_ID_ADPCM_EA_R2:
> ++          layout = "ea-r3";
> ++          break;
> ++        case CODEC_ID_ADPCM_EA_R3:
> ++          layout = "ea-r3";
> ++          break;
> ++        case CODEC_ID_ADPCM_EA_MAXIS_XA:
> ++          layout = "ea-maxis-xa";
> ++          break;
> ++        case CODEC_ID_ADPCM_EA_XAS:
> ++          layout = "ea-xas";
> ++          break;
> ++        case CODEC_ID_ADPCM_THP:
> ++          layout = "thp";
> ++          break;
> ++        default:
> ++          g_assert (0);         /* don't worry, we never get here */
> ++          break;
> ++      }
> ++
> ++      /* FIXME: someone please check whether we need additional properties
> ++       * in this caps definition. */
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-adpcm",
> ++          "layout", G_TYPE_STRING, layout, NULL);
> ++      if (context)
> ++        gst_caps_set_simple (caps,
> ++            "block_align", G_TYPE_INT, context->block_align,
> ++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> ++    }
> ++      break;
> ++
> ++    case CODEC_ID_AMR_NB:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/AMR", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_AMR_WB:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/AMR-WB", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_GSM:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-gsm", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_GSM_MS:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/ms-gsm", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_NELLYMOSER:
> ++      caps =
> ++          gst_ff_aud_caps_new (context, codec_id, "audio/x-nellymoser", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_SIPR:
> ++    {
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-sipro", NULL);
> ++      if (context) {
> ++        gst_caps_set_simple (caps,
> ++            "leaf_size", G_TYPE_INT, context->block_align,
> ++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> ++      }
> ++    }
> ++      break;
> ++
> ++    case CODEC_ID_RA_144:
> ++    case CODEC_ID_RA_288:
> ++    case CODEC_ID_COOK:
> ++    {
> ++      gint version = 0;
> ++
> ++      switch (codec_id) {
> ++        case CODEC_ID_RA_144:
> ++          version = 1;
> ++          break;
> ++        case CODEC_ID_RA_288:
> ++          version = 2;
> ++          break;
> ++        case CODEC_ID_COOK:
> ++          version = 8;
> ++          break;
> ++        default:
> ++          break;
> ++      }
> ++
> ++      /* FIXME: properties? */
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-pn-realaudio",
> ++          "raversion", G_TYPE_INT, version, NULL);
> ++      if (context) {
> ++        gst_caps_set_simple (caps,
> ++            "leaf_size", G_TYPE_INT, context->block_align,
> ++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> ++      }
> ++    }
> ++      break;
> ++
> ++    case CODEC_ID_ROQ_DPCM:
> ++    case CODEC_ID_INTERPLAY_DPCM:
> ++    case CODEC_ID_XAN_DPCM:
> ++    case CODEC_ID_SOL_DPCM:
> ++    {
> ++      const gchar *layout = NULL;
> ++
> ++      switch (codec_id) {
> ++        case CODEC_ID_ROQ_DPCM:
> ++          layout = "roq";
> ++          break;
> ++        case CODEC_ID_INTERPLAY_DPCM:
> ++          layout = "interplay";
> ++          break;
> ++        case CODEC_ID_XAN_DPCM:
> ++          layout = "xan";
> ++          break;
> ++        case CODEC_ID_SOL_DPCM:
> ++          layout = "sol";
> ++          break;
> ++        default:
> ++          g_assert (0);         /* don't worry, we never get here */
> ++          break;
> ++      }
> ++
> ++      /* FIXME: someone please check whether we need additional properties
> ++       * in this caps definition. */
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dpcm",
> ++          "layout", G_TYPE_STRING, layout, NULL);
> ++      if (context)
> ++        gst_caps_set_simple (caps,
> ++            "block_align", G_TYPE_INT, context->block_align,
> ++            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> ++    }
> ++      break;
> ++
> ++    case CODEC_ID_SHORTEN:
> ++      caps = gst_caps_new_simple ("audio/x-shorten", NULL);
> ++      break;
> ++
> ++    case CODEC_ID_ALAC:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-alac", NULL);
> ++      if (context) {
> ++        gst_caps_set_simple (caps,
> ++            "samplesize", G_TYPE_INT, context->bits_per_coded_sample, NULL);
> ++      }
> ++      break;
> ++
> ++    case CODEC_ID_FLAC:
> ++      /* Note that ffmpeg has no encoder yet, but just for safety. In the
> ++       * encoder case, we want to add things like samplerate, channels... */
> ++      if (!encode) {
> ++        caps = gst_caps_new_simple ("audio/x-flac", NULL);
> ++      }
> ++      break;
> ++
> ++    case CODEC_ID_DVD_SUBTITLE:
> ++    case CODEC_ID_DVB_SUBTITLE:
> ++      caps = NULL;
> ++      break;
> ++    case CODEC_ID_BMP:
> ++      caps = gst_caps_new_simple ("image/bmp", NULL);
> ++      break;
> ++    case CODEC_ID_TTA:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-tta", NULL);
> ++      if (context) {
> ++        gst_caps_set_simple (caps,
> ++            "samplesize", G_TYPE_INT, context->bits_per_coded_sample, NULL);
> ++      }
> ++      break;
> ++    case CODEC_ID_TWINVQ:
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-twin-vq", NULL);
> ++      break;
> ++    default:
> ++      GST_DEBUG ("Unknown codec ID %d, please add mapping here", codec_id);
> ++      break;
> ++  }
> ++
> ++  if (buildcaps) {
> ++    AVCodec *codec;
> ++
> ++    if ((codec = avcodec_find_decoder (codec_id)) ||
> ++        (codec = avcodec_find_encoder (codec_id))) {
> ++      gchar *mime = NULL;
> ++
> ++      GST_LOG ("Could not create stream format caps for %s", codec->name);
> ++
> ++      switch (codec->type) {
> ++        case AVMEDIA_TYPE_VIDEO:
> ++          mime = g_strdup_printf ("video/x-gst_ff-%s", codec->name);
> ++          caps = gst_ff_vid_caps_new (context, codec_id, mime, NULL);
> ++          g_free (mime);
> ++          break;
> ++        case AVMEDIA_TYPE_AUDIO:
> ++          mime = g_strdup_printf ("audio/x-gst_ff-%s", codec->name);
> ++          caps = gst_ff_aud_caps_new (context, codec_id, mime, NULL);
> ++          if (context)
> ++            gst_caps_set_simple (caps,
> ++                "block_align", G_TYPE_INT, context->block_align,
> ++                "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> ++          g_free (mime);
> ++          break;
> ++        default:
> ++          break;
> ++      }
> ++    }
> ++  }
> ++
> ++  if (caps != NULL) {
> ++
> ++    /* set private data */
> ++    if (context && context->extradata_size > 0) {
> ++      GstBuffer *data = gst_buffer_new_and_alloc (context->extradata_size);
> ++
> ++      memcpy (GST_BUFFER_DATA (data), context->extradata,
> ++          context->extradata_size);
> ++      gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, data, NULL);
> ++      gst_buffer_unref (data);
> ++    }
> ++
> ++    /* palette */
> ++    if (context) {
> ++      gst_ffmpeg_set_palette (caps, context);
> ++    }
> ++
> ++    GST_LOG ("caps for codec_id=%d: %" GST_PTR_FORMAT, codec_id, caps);
> ++
> ++  } else {
> ++    GST_LOG ("No caps found for codec_id=%d", codec_id);
> ++  }
> ++
> ++  return caps;
> ++}
> ++
> ++/* Convert a FFMPEG Pixel Format and optional AVCodecContext
> ++ * to a GstCaps. If the context is ommitted, no fixed values
> ++ * for video/audio size will be included in the GstCaps
> ++ *
> ++ * See below for usefullness
> ++ */
> ++
> ++GstCaps *
> ++gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context,
> ++    enum CodecID codec_id)
> ++{
> ++  GstCaps *caps = NULL;
> ++
> ++  int bpp = 0, depth = 0, endianness = 0;
> ++  gulong g_mask = 0, r_mask = 0, b_mask = 0, a_mask = 0;
> ++  guint32 fmt = 0;
> ++
> ++  switch (pix_fmt) {
> ++    case PIX_FMT_YUVJ420P:
> ++    case PIX_FMT_YUV420P:
> ++      fmt = GST_MAKE_FOURCC ('I', '4', '2', '0');
> ++      break;
> ++    case PIX_FMT_YUVA420P:
> ++      fmt = GST_MAKE_FOURCC ('A', '4', '2', '0');
> ++      break;
> ++    case PIX_FMT_YUYV422:
> ++      fmt = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
> ++      break;
> ++    case PIX_FMT_RGB24:
> ++      bpp = depth = 24;
> ++      endianness = G_BIG_ENDIAN;
> ++      r_mask = 0xff0000;
> ++      g_mask = 0x00ff00;
> ++      b_mask = 0x0000ff;
> ++      break;
> ++    case PIX_FMT_BGR24:
> ++      bpp = depth = 24;
> ++      endianness = G_BIG_ENDIAN;
> ++      r_mask = 0x0000ff;
> ++      g_mask = 0x00ff00;
> ++      b_mask = 0xff0000;
> ++      break;
> ++    case PIX_FMT_YUVJ422P:
> ++    case PIX_FMT_YUV422P:
> ++      fmt = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
> ++      break;
> ++    case PIX_FMT_YUVJ444P:
> ++    case PIX_FMT_YUV444P:
> ++      fmt = GST_MAKE_FOURCC ('Y', '4', '4', '4');
> ++      break;
> ++    case PIX_FMT_RGB32:
> ++      bpp = 32;
> ++      depth = 32;
> ++      endianness = G_BIG_ENDIAN;
> ++#if (G_BYTE_ORDER == G_BIG_ENDIAN)
> ++      r_mask = 0x00ff0000;
> ++      g_mask = 0x0000ff00;
> ++      b_mask = 0x000000ff;
> ++      a_mask = 0xff000000;
> ++#else
> ++      r_mask = 0x0000ff00;
> ++      g_mask = 0x00ff0000;
> ++      b_mask = 0xff000000;
> ++      a_mask = 0x000000ff;
> ++#endif
> ++      break;
> ++    case PIX_FMT_YUV410P:
> ++      fmt = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
> ++      break;
> ++    case PIX_FMT_YUV411P:
> ++      fmt = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
> ++      break;
> ++    case PIX_FMT_RGB565:
> ++      bpp = depth = 16;
> ++      endianness = G_BYTE_ORDER;
> ++      r_mask = 0xf800;
> ++      g_mask = 0x07e0;
> ++      b_mask = 0x001f;
> ++      break;
> ++    case PIX_FMT_RGB555:
> ++      bpp = 16;
> ++      depth = 15;
> ++      endianness = G_BYTE_ORDER;
> ++      r_mask = 0x7c00;
> ++      g_mask = 0x03e0;
> ++      b_mask = 0x001f;
> ++      break;
> ++    case PIX_FMT_PAL8:
> ++      bpp = depth = 8;
> ++      endianness = G_BYTE_ORDER;
> ++      break;
> ++    case PIX_FMT_GRAY8:
> ++      bpp = depth = 8;
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-gray",
> ++          "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, NULL);
> ++      break;
> ++    default:
> ++      /* give up ... */
> ++      break;
> ++  }
> ++
> ++  if (caps == NULL) {
> ++    if (bpp != 0) {
> ++      if (r_mask != 0) {
> ++        if (a_mask) {
> ++          caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
> ++              "bpp", G_TYPE_INT, bpp,
> ++              "depth", G_TYPE_INT, depth,
> ++              "red_mask", G_TYPE_INT, r_mask,
> ++              "green_mask", G_TYPE_INT, g_mask,
> ++              "blue_mask", G_TYPE_INT, b_mask,
> ++              "alpha_mask", G_TYPE_INT, a_mask,
> ++              "endianness", G_TYPE_INT, endianness, NULL);
> ++        } else {
> ++          caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
> ++              "bpp", G_TYPE_INT, bpp,
> ++              "depth", G_TYPE_INT, depth,
> ++              "red_mask", G_TYPE_INT, r_mask,
> ++              "green_mask", G_TYPE_INT, g_mask,
> ++              "blue_mask", G_TYPE_INT, b_mask,
> ++              "endianness", G_TYPE_INT, endianness, NULL);
> ++        }
> ++      } else {
> ++        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
> ++            "bpp", G_TYPE_INT, bpp,
> ++            "depth", G_TYPE_INT, depth,
> ++            "endianness", G_TYPE_INT, endianness, NULL);
> ++        if (caps && context) {
> ++          gst_ffmpeg_set_palette (caps, context);
> ++        }
> ++      }
> ++    } else if (fmt) {
> ++      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-yuv",
> ++          "format", GST_TYPE_FOURCC, fmt, NULL);
> ++    }
> ++  }
> ++
> ++  if (caps != NULL) {
> ++    GST_DEBUG ("caps for pix_fmt=%d: %" GST_PTR_FORMAT, pix_fmt, caps);
> ++  } else {
> ++    GST_LOG ("No caps found for pix_fmt=%d", pix_fmt);
> ++  }
> ++
> ++  return caps;
> ++}
> ++
> ++/* Convert a FFMPEG Sample Format and optional AVCodecContext
> ++ * to a GstCaps. If the context is ommitted, no fixed values
> ++ * for video/audio size will be included in the GstCaps
> ++ *
> ++ * See below for usefullness
> ++ */
> ++
> ++static GstCaps *
> ++gst_ffmpeg_smpfmt_to_caps (enum AVSampleFormat sample_fmt,
> ++    AVCodecContext * context, enum CodecID codec_id)
> ++{
> ++  GstCaps *caps = NULL;
> ++
> ++  int bpp = 0;
> ++  gboolean integer = TRUE;
> ++  gboolean signedness = FALSE;
> ++
> ++  switch (sample_fmt) {
> ++    case AV_SAMPLE_FMT_S16:
> ++      signedness = TRUE;
> ++      bpp = 16;
> ++      break;
> ++
> ++    case AV_SAMPLE_FMT_S32:
> ++      signedness = TRUE;
> ++      bpp = 32;
> ++      break;
> ++
> ++    case AV_SAMPLE_FMT_FLT:
> ++      integer = FALSE;
> ++      bpp = 32;
> ++      break;
> ++
> ++    case AV_SAMPLE_FMT_DBL:
> ++      integer = FALSE;
> ++      bpp = 64;
> ++      break;
> ++    default:
> ++      /* .. */
> ++      break;
> ++  }
> ++
> ++  if (bpp) {
> ++    if (integer) {
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-int",
> ++          "signed", G_TYPE_BOOLEAN, signedness,
> ++          "endianness", G_TYPE_INT, G_BYTE_ORDER,
> ++          "width", G_TYPE_INT, bpp, "depth", G_TYPE_INT, bpp, NULL);
> ++    } else {
> ++      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-float",
> ++          "endianness", G_TYPE_INT, G_BYTE_ORDER,
> ++          "width", G_TYPE_INT, bpp, NULL);
> ++    }
> ++  }
> ++
> ++  if (caps != NULL) {
> ++    GST_LOG ("caps for sample_fmt=%d: %" GST_PTR_FORMAT, sample_fmt, caps);
> ++  } else {
> ++    GST_LOG ("No caps found for sample_fmt=%d", sample_fmt);
> ++  }
> ++
> ++  return caps;
> ++}
> ++
> ++GstCaps *
> ++gst_ffmpeg_codectype_to_audio_caps (AVCodecContext * context,
> ++    enum CodecID codec_id, gboolean encode, AVCodec * codec)
> ++{
> ++  GstCaps *caps = NULL;
> ++
> ++  GST_DEBUG ("context:%p, codec_id:%d, encode:%d, codec:%p",
> ++      context, codec_id, encode, codec);
> ++  if (codec)
> ++    GST_DEBUG ("sample_fmts:%p, samplerates:%p",
> ++        codec->sample_fmts, codec->supported_samplerates);
> ++
> ++  if (context) {
> ++    /* Specific codec context */
> ++    caps = gst_ffmpeg_smpfmt_to_caps (context->sample_fmt, context, codec_id);
> ++  } else if (codec && codec->sample_fmts) {
> ++    GstCaps *temp;
> ++    int i;
> ++
> ++    caps = gst_caps_new_empty ();
> ++    for (i = 0; codec->sample_fmts[i] != -1; i++) {
> ++      temp =
> ++          gst_ffmpeg_smpfmt_to_caps (codec->sample_fmts[i], context, codec_id);
> ++      if (temp != NULL)
> ++        gst_caps_append (caps, temp);
> ++    }
> ++  } else {
> ++    GstCaps *temp;
> ++    enum AVSampleFormat i;
> ++    AVCodecContext ctx = { 0, };
> ++
> ++    ctx.channels = -1;
> ++    caps = gst_caps_new_empty ();
> ++    for (i = 0; i <= AV_SAMPLE_FMT_DBL; i++) {
> ++      temp = gst_ffmpeg_smpfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
> ++      if (temp != NULL) {
> ++        gst_caps_append (caps, temp);
> ++      }
> ++    }
> ++  }
> ++  return caps;
> ++}
> ++
> ++GstCaps *
> ++gst_ffmpeg_codectype_to_video_caps (AVCodecContext * context,
> ++    enum CodecID codec_id, gboolean encode, AVCodec * codec)
> ++{
> ++  GstCaps *caps;
> ++
> ++  GST_LOG ("context:%p, codec_id:%d, encode:%d, codec:%p",
> ++      context, codec_id, encode, codec);
> ++
> ++  if (context) {
> ++    caps = gst_ffmpeg_pixfmt_to_caps (context->pix_fmt, context, codec_id);
> ++  } else {
> ++    GstCaps *temp;
> ++    enum PixelFormat i;
> ++    AVCodecContext ctx = { 0, };
> ++
> ++    caps = gst_caps_new_empty ();
> ++    for (i = 0; i < PIX_FMT_NB; i++) {
> ++      ctx.width = -1;
> ++      ctx.pix_fmt = i;
> ++      temp = gst_ffmpeg_pixfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
> ++      if (temp != NULL) {
> ++        gst_caps_append (caps, temp);
> ++      }
> ++    }
> ++  }
> ++  return caps;
> ++}
> ++
> ++/* Convert a FFMPEG codec Type and optional AVCodecContext
> ++ * to a GstCaps. If the context is ommitted, no fixed values
> ++ * for video/audio size will be included in the GstCaps
> ++ *
> ++ * AVMediaType is primarily meant for uncompressed data GstCaps!
> ++ */
> ++
> ++GstCaps *
> ++gst_ffmpeg_codectype_to_caps (enum AVMediaType codec_type,
> ++    AVCodecContext * context, enum CodecID codec_id, gboolean encode)
> ++{
> ++  GstCaps *caps;
> ++
> ++  switch (codec_type) {
> ++    case AVMEDIA_TYPE_VIDEO:
> ++      caps =
> ++          gst_ffmpeg_codectype_to_video_caps (context, codec_id, encode, NULL);
> ++      break;
> ++    case AVMEDIA_TYPE_AUDIO:
> ++      caps =
> ++          gst_ffmpeg_codectype_to_audio_caps (context, codec_id, encode, NULL);
> ++      break;
> ++    default:
> ++      caps = NULL;
> ++      break;
> ++  }
> ++
> ++  return caps;
> ++}
> ++
> ++/* Convert a GstCaps (audio/raw) to a FFMPEG SampleFmt
> ++ * and other audio properties in a AVCodecContext.
> ++ *
> ++ * For usefullness, see below
> ++ */
> ++
> ++static void
> ++gst_ffmpeg_caps_to_smpfmt (const GstCaps * caps,
> ++    AVCodecContext * context, gboolean raw)
> ++{
> ++  GstStructure *structure;
> ++  gint depth = 0, width = 0, endianness = 0;
> ++  gboolean signedness = FALSE;
> ++  const gchar *name;
> ++
> ++  g_return_if_fail (gst_caps_get_size (caps) == 1);
> ++  structure = gst_caps_get_structure (caps, 0);
> ++
> ++  gst_structure_get_int (structure, "channels", &context->channels);
> ++  gst_structure_get_int (structure, "rate", &context->sample_rate);
> ++  gst_structure_get_int (structure, "block_align", &context->block_align);
> ++  gst_structure_get_int (structure, "bitrate", &context->bit_rate);
> ++
> ++  if (!raw)
> ++    return;
> ++
> ++  name = gst_structure_get_name (structure);
> ++
> ++  if (!strcmp (name, "audio/x-raw-float")) {
> ++    /* FLOAT */
> ++    if (gst_structure_get_int (structure, "width", &width) &&
> ++        gst_structure_get_int (structure, "endianness", &endianness)) {
> ++      if (endianness == G_BYTE_ORDER) {
> ++        if (width == 32)
> ++          context->sample_fmt = AV_SAMPLE_FMT_FLT;
> ++        else if (width == 64)
> ++          context->sample_fmt = AV_SAMPLE_FMT_DBL;
> ++      }
> ++    }
> ++  } else {
> ++    /* INT */
> ++    if (gst_structure_get_int (structure, "width", &width) &&
> ++        gst_structure_get_int (structure, "depth", &depth) &&
> ++        gst_structure_get_boolean (structure, "signed", &signedness) &&
> ++        gst_structure_get_int (structure, "endianness", &endianness)) {
> ++      if ((endianness == G_BYTE_ORDER) && (signedness == TRUE)) {
> ++        if ((width == 16) && (depth == 16))
> ++          context->sample_fmt = AV_SAMPLE_FMT_S16;
> ++        else if ((width == 32) && (depth == 32))
> ++          context->sample_fmt = AV_SAMPLE_FMT_S32;
> ++      }
> ++    }
> ++  }
> ++}
> ++
> ++
> ++/* Convert a GstCaps (video/raw) to a FFMPEG PixFmt
> ++ * and other video properties in a AVCodecContext.
> ++ *
> ++ * For usefullness, see below
> ++ */
> ++
> ++static void
> ++gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
> ++    AVCodecContext * context, gboolean raw)
> ++{
> ++  GstStructure *structure;
> ++  const GValue *fps;
> ++  const GValue *par = NULL;
> ++
> ++  GST_DEBUG ("converting caps %" GST_PTR_FORMAT, caps);
> ++  g_return_if_fail (gst_caps_get_size (caps) == 1);
> ++  structure = gst_caps_get_structure (caps, 0);
> ++
> ++  gst_structure_get_int (structure, "width", &context->width);
> ++  gst_structure_get_int (structure, "height", &context->height);
> ++  gst_structure_get_int (structure, "bpp", &context->bits_per_coded_sample);
> ++
> ++  fps = gst_structure_get_value (structure, "framerate");
> ++  if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
> ++
> ++    /* somehow these seem mixed up.. */
> ++    context->time_base.den = gst_value_get_fraction_numerator (fps);
> ++    context->time_base.num = gst_value_get_fraction_denominator (fps);
> ++    context->ticks_per_frame = 1;
> ++
> ++    GST_DEBUG ("setting framerate %d/%d = %lf",
> ++        context->time_base.den, context->time_base.num,
> ++        1. * context->time_base.den / context->time_base.num);
> ++  }
> ++
> ++  par = gst_structure_get_value (structure, "pixel-aspect-ratio");
> ++  if (par && GST_VALUE_HOLDS_FRACTION (par)) {
> ++
> ++    context->sample_aspect_ratio.num = gst_value_get_fraction_numerator (par);
> ++    context->sample_aspect_ratio.den = gst_value_get_fraction_denominator (par);
> ++
> ++    GST_DEBUG ("setting pixel-aspect-ratio %d/%d = %lf",
> ++        context->sample_aspect_ratio.den, context->sample_aspect_ratio.num,
> ++        1. * context->sample_aspect_ratio.den /
> ++        context->sample_aspect_ratio.num);
> ++  }
> ++
> ++  if (!raw)
> ++    return;
> ++
> ++  g_return_if_fail (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps));
> ++
> ++  if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
> ++    guint32 fourcc;
> ++
> ++    if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
> ++      switch (fourcc) {
> ++        case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
> ++          context->pix_fmt = PIX_FMT_YUYV422;
> ++          break;
> ++        case GST_MAKE_FOURCC ('I', '4', '2', '0'):
> ++          context->pix_fmt = PIX_FMT_YUV420P;
> ++          break;
> ++        case GST_MAKE_FOURCC ('A', '4', '2', '0'):
> ++          context->pix_fmt = PIX_FMT_YUVA420P;
> ++          break;
> ++        case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
> ++          context->pix_fmt = PIX_FMT_YUV411P;
> ++          break;
> ++        case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
> ++          context->pix_fmt = PIX_FMT_YUV422P;
> ++          break;
> ++        case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
> ++          context->pix_fmt = PIX_FMT_YUV410P;
> ++          break;
> ++#if 0
> ++        case FIXME:
> ++          context->pix_fmt = PIX_FMT_YUV444P;
> ++          break;
> ++#endif
> ++      }
> ++    }
> ++  } else if (strcmp (gst_structure_get_name (structure),
> ++          "video/x-raw-rgb") == 0) {
> ++    gint bpp = 0, rmask = 0, endianness = 0;
> ++
> ++    if (gst_structure_get_int (structure, "bpp", &bpp) &&
> ++        gst_structure_get_int (structure, "endianness", &endianness)) {
> ++      if (gst_structure_get_int (structure, "red_mask", &rmask)) {
> ++        switch (bpp) {
> ++          case 32:
> ++#if (G_BYTE_ORDER == G_BIG_ENDIAN)
> ++            if (rmask == 0x00ff0000)
> ++#else
> ++            if (rmask == 0x0000ff00)
> ++#endif
> ++              context->pix_fmt = PIX_FMT_RGB32;
> ++            break;
> ++          case 24:
> ++            if (rmask == 0x0000FF)
> ++              context->pix_fmt = PIX_FMT_BGR24;
> ++            else
> ++              context->pix_fmt = PIX_FMT_RGB24;
> ++            break;
> ++          case 16:
> ++            if (endianness == G_BYTE_ORDER)
> ++              context->pix_fmt = PIX_FMT_RGB565;
> ++            break;
> ++          case 15:
> ++            if (endianness == G_BYTE_ORDER)
> ++              context->pix_fmt = PIX_FMT_RGB555;
> ++            break;
> ++          default:
> ++            /* nothing */
> ++            break;
> ++        }
> ++      } else {
> ++        if (bpp == 8) {
> ++          context->pix_fmt = PIX_FMT_PAL8;
> ++          gst_ffmpeg_get_palette (caps, context);
> ++        }
> ++      }
> ++    }
> ++  } else if (strcmp (gst_structure_get_name (structure),
> ++          "video/x-raw-gray") == 0) {
> ++    gint bpp = 0;
> ++
> ++    if (gst_structure_get_int (structure, "bpp", &bpp)) {
> ++      switch (bpp) {
> ++        case 8:
> ++          context->pix_fmt = PIX_FMT_GRAY8;
> ++          break;
> ++      }
> ++    }
> ++  }
> ++}
> ++
> ++/* Convert a GstCaps and a FFMPEG codec Type to a
> ++ * AVCodecContext. If the context is ommitted, no fixed values
> ++ * for video/audio size will be included in the context
> ++ *
> ++ * AVMediaType is primarily meant for uncompressed data GstCaps!
> ++ */
> ++
> ++void
> ++gst_ffmpeg_caps_with_codectype (enum AVMediaType type,
> ++    const GstCaps * caps, AVCodecContext * context)
> ++{
> ++  if (context == NULL)
> ++    return;
> ++
> ++  switch (type) {
> ++    case AVMEDIA_TYPE_VIDEO:
> ++      gst_ffmpeg_caps_to_pixfmt (caps, context, TRUE);
> ++      break;
> ++
> ++    case AVMEDIA_TYPE_AUDIO:
> ++      gst_ffmpeg_caps_to_smpfmt (caps, context, TRUE);
> ++      break;
> ++
> ++    default:
> ++      /* unknown */
> ++      break;
> ++  }
> ++}
> ++
> ++#if 0
> ++static void
> ++nal_escape (guint8 * dst, guint8 * src, guint size, guint * destsize)
> ++{
> ++  guint8 *dstp = dst;
> ++  guint8 *srcp = src;
> ++  guint8 *end = src + size;
> ++  gint count = 0;
> ++
> ++  while (srcp < end) {
> ++    if (count == 2 && *srcp <= 0x03) {
> ++      GST_DEBUG ("added escape code");
> ++      *dstp++ = 0x03;
> ++      count = 0;
> ++    }
> ++    if (*srcp == 0)
> ++      count++;
> ++    else
> ++      count = 0;
> ++
> ++    GST_DEBUG ("copy %02x, count %d", *srcp, count);
> ++    *dstp++ = *srcp++;
> ++  }
> ++  *destsize = dstp - dst;
> ++}
> ++
> ++/* copy the config, escaping NAL units as we iterate them, if something fails we
> ++ * copy everything and hope for the best. */
> ++static void
> ++copy_config (guint8 * dst, guint8 * src, guint size, guint * destsize)
> ++{
> ++  guint8 *dstp = dst;
> ++  guint8 *srcp = src;
> ++  gint cnt, i;
> ++  guint nalsize, esize;
> ++
> ++  /* check size */
> ++  if (size < 7)
> ++    goto full_copy;
> ++
> ++  /* check version */
> ++  if (*srcp != 1)
> ++    goto full_copy;
> ++
> ++  cnt = *(srcp + 5) & 0x1f;     /* Number of sps */
> ++
> ++  GST_DEBUG ("num SPS %d", cnt);
> ++
> ++  memcpy (dstp, srcp, 6);
> ++  srcp += 6;
> ++  dstp += 6;
> ++
> ++  for (i = 0; i < cnt; i++) {
> ++    GST_DEBUG ("copy SPS %d", i);
> ++    nalsize = (srcp[0] << 8) | srcp[1];
> ++    nal_escape (dstp + 2, srcp + 2, nalsize, &esize);
> ++    dstp[0] = esize >> 8;
> ++    dstp[1] = esize & 0xff;
> ++    dstp += esize + 2;
> ++    srcp += nalsize + 2;
> ++  }
> ++
> ++  cnt = *(dstp++) = *(srcp++);  /* Number of pps */
> ++
> ++  GST_DEBUG ("num PPS %d", cnt);
> ++
> ++  for (i = 0; i < cnt; i++) {
> ++    GST_DEBUG ("copy PPS %d", i);
> ++    nalsize = (srcp[0] << 8) | srcp[1];
> ++    nal_escape (dstp + 2, srcp + 2, nalsize, &esize);
> ++    dstp[0] = esize >> 8;
> ++    dstp[1] = esize & 0xff;
> ++    dstp += esize + 2;
> ++    srcp += nalsize + 2;
> ++  }
> ++  *destsize = dstp - dst;
> ++
> ++  return;
> ++
> ++full_copy:
> ++  {
> ++    GST_DEBUG ("something unexpected, doing full copy");
> ++    memcpy (dst, src, size);
> ++    *destsize = size;
> ++    return;
> ++  }
> ++}
> ++#endif
> ++
> ++/*
> ++ * caps_with_codecid () transforms a GstCaps for a known codec
> ++ * ID into a filled-in context.
> ++ * codec_data from caps will override possible extradata already in the context
> ++ */
> ++
> ++void
> ++gst_ffmpeg_caps_with_codecid (enum CodecID codec_id,
> ++    enum AVMediaType codec_type, const GstCaps * caps, AVCodecContext * context)
> ++{
> ++  GstStructure *str;
> ++  const GValue *value;
> ++  const GstBuffer *buf;
> ++
> ++  GST_LOG ("codec_id:%d, codec_type:%d, caps:%" GST_PTR_FORMAT " context:%p",
> ++      codec_id, codec_type, caps, context);
> ++
> ++  if (!context || !gst_caps_get_size (caps))
> ++    return;
> ++
> ++  str = gst_caps_get_structure (caps, 0);
> ++
> ++  /* extradata parsing (esds [mpeg4], wma/wmv, msmpeg4v1/2/3, etc.) */
> ++  if ((value = gst_structure_get_value (str, "codec_data"))) {
> ++    guint size;
> ++    guint8 *data;
> ++
> ++    buf = GST_BUFFER_CAST (gst_value_get_mini_object (value));
> ++    size = GST_BUFFER_SIZE (buf);
> ++    data = GST_BUFFER_DATA (buf);
> ++
> ++    /* free the old one if it is there */
> ++    if (context->extradata)
> ++      av_free (context->extradata);
> ++
> ++#if 0
> ++    if (codec_id == CODEC_ID_H264) {
> ++      guint extrasize;
> ++
> ++      GST_DEBUG ("copy, escaping codec_data %d", size);
> ++      /* ffmpeg h264 expects the codec_data to be escaped, there is no real
> ++       * reason for this but let's just escape it for now. Start by allocating
> ++       * enough space, x2 is more than enough.
> ++       *
> ++       * FIXME, we disabled escaping because some file already contain escaped
> ++       * codec_data and then we escape twice and fail. It's better to leave it
> ++       * as is, as that is what most players do. */
> ++      context->extradata =
> ++          av_mallocz (GST_ROUND_UP_16 (size * 2 +
> ++              FF_INPUT_BUFFER_PADDING_SIZE));
> ++      copy_config (context->extradata, data, size, &extrasize);
> ++      GST_DEBUG ("escaped size: %d", extrasize);
> ++      context->extradata_size = extrasize;
> ++    } else
> ++#endif
> ++    {
> ++      /* allocate with enough padding */
> ++      GST_DEBUG ("copy codec_data");
> ++      context->extradata =
> ++          av_mallocz (GST_ROUND_UP_16 (size + FF_INPUT_BUFFER_PADDING_SIZE));
> ++      memcpy (context->extradata, data, size);
> ++      context->extradata_size = size;
> ++    }
> ++
> ++    /* Hack for VC1. Sometimes the first (length) byte is 0 for some files */
> ++    if (codec_id == CODEC_ID_VC1 && size > 0 && data[0] == 0) {
> ++      context->extradata[0] = (guint8) size;
> ++    }
> ++
> ++    GST_DEBUG ("have codec data of size %d", size);
> ++  } else if (context->extradata == NULL && codec_id != CODEC_ID_AAC_LATM &&
> ++      codec_id != CODEC_ID_FLAC) {
> ++    /* no extradata, alloc dummy with 0 sized, some codecs insist on reading
> ++     * extradata anyway which makes then segfault. */
> ++    context->extradata =
> ++        av_mallocz (GST_ROUND_UP_16 (FF_INPUT_BUFFER_PADDING_SIZE));
> ++    context->extradata_size = 0;
> ++    GST_DEBUG ("no codec data");
> ++  }
> ++
> ++  switch (codec_id) {
> ++    case CODEC_ID_MPEG4:
> ++    {
> ++      const gchar *mime = gst_structure_get_name (str);
> ++
> ++      if (!strcmp (mime, "video/x-divx"))
> ++        context->codec_tag = GST_MAKE_FOURCC ('D', 'I', 'V', 'X');
> ++      else if (!strcmp (mime, "video/x-xvid"))
> ++        context->codec_tag = GST_MAKE_FOURCC ('X', 'V', 'I', 'D');
> ++      else if (!strcmp (mime, "video/x-3ivx"))
> ++        context->codec_tag = GST_MAKE_FOURCC ('3', 'I', 'V', '1');
> ++      else if (!strcmp (mime, "video/mpeg"))
> ++        context->codec_tag = GST_MAKE_FOURCC ('m', 'p', '4', 'v');
> ++    }
> ++      break;
> ++
> ++    case CODEC_ID_SVQ3:
> ++      /* FIXME: this is a workaround for older gst-plugins releases
> ++       * (<= 0.8.9). This should be removed at some point, because
> ++       * it causes wrong decoded frame order. */
> ++      if (!context->extradata) {
> ++        gint halfpel_flag, thirdpel_flag, low_delay, unknown_svq3_flag;
> ++        guint16 flags;
> ++
> ++        if (gst_structure_get_int (str, "halfpel_flag", &halfpel_flag) ||
> ++            gst_structure_get_int (str, "thirdpel_flag", &thirdpel_flag) ||
> ++            gst_structure_get_int (str, "low_delay", &low_delay) ||
> ++            gst_structure_get_int (str, "unknown_svq3_flag",
> ++                &unknown_svq3_flag)) {
> ++          context->extradata = (guint8 *) av_mallocz (0x64);
> ++          g_stpcpy ((gchar *) context->extradata, "SVQ3");
> ++          flags = 1 << 3;
> ++          flags |= low_delay;
> ++          flags = flags << 2;
> ++          flags |= unknown_svq3_flag;
> ++          flags = flags << 6;
> ++          flags |= halfpel_flag;
> ++          flags = flags << 1;
> ++          flags |= thirdpel_flag;
> ++          flags = flags << 3;
> ++
> ++          flags = GUINT16_FROM_LE (flags);
> ++
> ++          memcpy ((gchar *) context->extradata + 0x62, &flags, 2);
> ++          context->extradata_size = 0x64;
> ++        }
> ++      }
> ++      break;
> ++
> ++    case CODEC_ID_MSRLE:
> ++    case CODEC_ID_QTRLE:
> ++    case CODEC_ID_TSCC:
> ++    case CODEC_ID_CSCD:
> ++    case CODEC_ID_APE:
> ++    {
> ++      gint depth;
> ++
> ++      if (gst_structure_get_int (str, "depth", &depth)) {
> ++        context->bits_per_coded_sample = depth;
> ++      } else {
> ++        GST_WARNING ("No depth field in caps %" GST_PTR_FORMAT, caps);
> ++      }
> ++
> ++    }
> ++      break;
> ++
> ++    case CODEC_ID_RV10:
> ++    case CODEC_ID_RV20:
> ++    case CODEC_ID_RV30:
> ++    case CODEC_ID_RV40:
> ++    {
> ++      gint format;
> ++
> ++      if (gst_structure_get_int (str, "format", &format))
> ++        context->sub_id = format;
> ++
> ++      break;
> ++    }
> ++    case CODEC_ID_COOK:
> ++    case CODEC_ID_RA_288:
> ++    case CODEC_ID_RA_144:
> ++    case CODEC_ID_SIPR:
> ++    {
> ++      gint leaf_size;
> ++      gint bitrate;
> ++
> ++      if (gst_structure_get_int (str, "leaf_size", &leaf_size))
> ++        context->block_align = leaf_size;
> ++      if (gst_structure_get_int (str, "bitrate", &bitrate))
> ++        context->bit_rate = bitrate;
> ++    }
> ++    case CODEC_ID_ALAC:
> ++      gst_structure_get_int (str, "samplesize",
> ++          &context->bits_per_coded_sample);
> ++      break;
> ++
> ++    case CODEC_ID_DVVIDEO:
> ++    {
> ++      guint32 fourcc;
> ++
> ++      if (gst_structure_get_fourcc (str, "format", &fourcc))
> ++        switch (fourcc) {
> ++          case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
> ++            context->pix_fmt = PIX_FMT_YUYV422;
> ++            break;
> ++          case GST_MAKE_FOURCC ('I', '4', '2', '0'):
> ++            context->pix_fmt = PIX_FMT_YUV420P;
> ++            break;
> ++          case GST_MAKE_FOURCC ('A', '4', '2', '0'):
> ++            context->pix_fmt = PIX_FMT_YUVA420P;
> ++            break;
> ++          case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
> ++            context->pix_fmt = PIX_FMT_YUV411P;
> ++            break;
> ++          case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
> ++            context->pix_fmt = PIX_FMT_YUV422P;
> ++            break;
> ++          case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
> ++            context->pix_fmt = PIX_FMT_YUV410P;
> ++            break;
> ++          default:
> ++            GST_WARNING ("couldn't convert fourcc %" GST_FOURCC_FORMAT
> ++                " to a pixel format", GST_FOURCC_ARGS (fourcc));
> ++            break;
> ++        }
> ++      break;
> ++    }
> ++    case CODEC_ID_H263P:
> ++    {
> ++      gboolean val;
> ++
> ++      if (!gst_structure_get_boolean (str, "annex-f", &val) || val)
> ++        context->flags |= CODEC_FLAG_4MV;
> ++      else
> ++        context->flags &= ~CODEC_FLAG_4MV;
> ++      if ((!gst_structure_get_boolean (str, "annex-i", &val) || val) &&
> ++          (!gst_structure_get_boolean (str, "annex-t", &val) || val))
> ++        context->flags |= CODEC_FLAG_AC_PRED;
> ++      else
> ++        context->flags &= ~CODEC_FLAG_AC_PRED;
> ++      if (!gst_structure_get_boolean (str, "annex-j", &val) || val)
> ++        context->flags |= CODEC_FLAG_LOOP_FILTER;
> ++      else
> ++        context->flags &= ~CODEC_FLAG_LOOP_FILTER;
> ++      break;
> ++    }
> ++    case CODEC_ID_ADPCM_G726:
> ++    {
> ++      const gchar *layout;
> ++
> ++      if ((layout = gst_structure_get_string (str, "layout"))) {
> ++        if (!strcmp (layout, "g721")) {
> ++          context->sample_rate = 8000;
> ++          context->channels = 1;
> ++          context->bit_rate = 32000;
> ++        }
> ++      }
> ++      break;
> ++    }
> ++    default:
> ++      break;
> ++  }
> ++
> ++  if (!gst_caps_is_fixed (caps))
> ++    return;
> ++
> ++  /* common properties (width, height, fps) */
> ++  switch (codec_type) {
> ++    case AVMEDIA_TYPE_VIDEO:
> ++      gst_ffmpeg_caps_to_pixfmt (caps, context, codec_id == CODEC_ID_RAWVIDEO);
> ++      gst_ffmpeg_get_palette (caps, context);
> ++      break;
> ++    case AVMEDIA_TYPE_AUDIO:
> ++      gst_ffmpeg_caps_to_smpfmt (caps, context, FALSE);
> ++      break;
> ++    default:
> ++      break;
> ++  }
> ++
> ++  /* fixup of default settings */
> ++  switch (codec_id) {
> ++    case CODEC_ID_QCELP:
> ++      /* QCELP is always mono, no matter what the caps say */
> ++      context->channels = 1;
> ++      break;
> ++    default:
> ++      break;
> ++  }
> ++}
> ++
> ++/* _formatid_to_caps () is meant for muxers/demuxers, it
> ++ * transforms a name (ffmpeg way of ID'ing these, why don't
> ++ * they have unique numerical IDs?) to the corresponding
> ++ * caps belonging to that mux-format
> ++ *
> ++ * Note: we don't need any additional info because the caps
> ++ * isn't supposed to contain any useful info besides the
> ++ * media type anyway
> ++ */
> ++
> ++GstCaps *
> ++gst_ffmpeg_formatid_to_caps (const gchar * format_name)
> ++{
> ++  GstCaps *caps = NULL;
> ++
> ++  if (!strcmp (format_name, "mpeg")) {
> ++    caps = gst_caps_new_simple ("video/mpeg",
> ++        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
> ++  } else if (!strcmp (format_name, "mpegts")) {
> ++    caps = gst_caps_new_simple ("video/mpegts",
> ++        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
> ++  } else if (!strcmp (format_name, "rm")) {
> ++    caps = gst_caps_new_simple ("application/x-pn-realmedia",
> ++        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
> ++  } else if (!strcmp (format_name, "asf")) {
> ++    caps = gst_caps_new_simple ("video/x-ms-asf", NULL);
> ++  } else if (!strcmp (format_name, "avi")) {
> ++    caps = gst_caps_new_simple ("video/x-msvideo", NULL);
> ++  } else if (!strcmp (format_name, "wav")) {
> ++    caps = gst_caps_new_simple ("audio/x-wav", NULL);
> ++  } else if (!strcmp (format_name, "ape")) {
> ++    caps = gst_caps_new_simple ("application/x-ape", NULL);
> ++  } else if (!strcmp (format_name, "swf")) {
> ++    caps = gst_caps_new_simple ("application/x-shockwave-flash", NULL);
> ++  } else if (!strcmp (format_name, "au")) {
> ++    caps = gst_caps_new_simple ("audio/x-au", NULL);
> ++  } else if (!strcmp (format_name, "dv")) {
> ++    caps = gst_caps_new_simple ("video/x-dv",
> ++        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
> ++  } else if (!strcmp (format_name, "4xm")) {
> ++    caps = gst_caps_new_simple ("video/x-4xm", NULL);
> ++  } else if (!strcmp (format_name, "matroska")) {
> ++    caps = gst_caps_new_simple ("video/x-matroska", NULL);
> ++  } else if (!strcmp (format_name, "mp3")) {
> ++    caps = gst_caps_new_simple ("application/x-id3", NULL);
> ++  } else if (!strcmp (format_name, "flic")) {
> ++    caps = gst_caps_new_simple ("video/x-fli", NULL);
> ++  } else if (!strcmp (format_name, "flv")) {
> ++    caps = gst_caps_new_simple ("video/x-flv", NULL);
> ++  } else if (!strcmp (format_name, "tta")) {
> ++    caps = gst_caps_new_simple ("audio/x-ttafile", NULL);
> ++  } else if (!strcmp (format_name, "aiff")) {
> ++    caps = gst_caps_new_simple ("audio/x-aiff", NULL);
> ++  } else if (!strcmp (format_name, "mov_mp4_m4a_3gp_3g2")) {
> ++    caps =
> ++        gst_caps_from_string
> ++        ("application/x-3gp; video/quicktime; audio/x-m4a");
> ++  } else if (!strcmp (format_name, "mov")) {
> ++    caps = gst_caps_from_string ("video/quicktime,variant=(string)apple");
> ++  } else if (!strcmp (format_name, "mp4")) {
> ++    caps = gst_caps_from_string ("video/quicktime,variant=(string)iso");
> ++  } else if (!strcmp (format_name, "3gp")) {
> ++    caps = gst_caps_from_string ("video/quicktime,variant=(string)3gpp");
> ++  } else if (!strcmp (format_name, "3g2")) {
> ++    caps = gst_caps_from_string ("video/quicktime,variant=(string)3g2");
> ++  } else if (!strcmp (format_name, "psp")) {
> ++    caps = gst_caps_from_string ("video/quicktime,variant=(string)psp");
> ++  } else if (!strcmp (format_name, "ipod")) {
> ++    caps = gst_caps_from_string ("video/quicktime,variant=(string)ipod");
> ++  } else if (!strcmp (format_name, "aac")) {
> ++    caps = gst_caps_new_simple ("audio/mpeg",
> ++        "mpegversion", G_TYPE_INT, 4, NULL);
> ++  } else if (!strcmp (format_name, "gif")) {
> ++    caps = gst_caps_from_string ("image/gif");
> ++  } else if (!strcmp (format_name, "ogg")) {
> ++    caps = gst_caps_from_string ("application/ogg");
> ++  } else if (!strcmp (format_name, "mxf") || !strcmp (format_name, "mxf_d10")) {
> ++    caps = gst_caps_from_string ("application/mxf");
> ++  } else if (!strcmp (format_name, "gxf")) {
> ++    caps = gst_caps_from_string ("application/gxf");
> ++  } else if (!strcmp (format_name, "yuv4mpegpipe")) {
> ++    caps = gst_caps_new_simple ("application/x-yuv4mpeg",
> ++        "y4mversion", G_TYPE_INT, 2, NULL);
> ++  } else if (!strcmp (format_name, "mpc")) {
> ++    caps = gst_caps_from_string ("audio/x-musepack, streamversion = (int) 7");
> ++  } else if (!strcmp (format_name, "vqf")) {
> ++    caps = gst_caps_from_string ("audio/x-vqf");
> ++  } else if (!strcmp (format_name, "nsv")) {
> ++    caps = gst_caps_from_string ("video/x-nsv");
> ++  } else if (!strcmp (format_name, "amr")) {
> ++    caps = gst_caps_from_string ("audio/x-amr-nb-sh");
> ++  } else if (!strcmp (format_name, "webm")) {
> ++    caps = gst_caps_from_string ("video/webm");
> ++  } else {
> ++    gchar *name;
> ++
> ++    GST_LOG ("Could not create stream format caps for %s", format_name);
> ++    name = g_strdup_printf ("application/x-gst_ff-%s", format_name);
> ++    caps = gst_caps_new_simple (name, NULL);
> ++    g_free (name);
> ++  }
> ++
> ++  return caps;
> ++}
> ++
> ++gboolean
> ++gst_ffmpeg_formatid_get_codecids (const gchar * format_name,
> ++    enum CodecID ** video_codec_list, enum CodecID ** audio_codec_list,
> ++    AVOutputFormat * plugin)
> ++{
> ++  static enum CodecID tmp_vlist[] = {
> ++    CODEC_ID_NONE,
> ++    CODEC_ID_NONE
> ++  };
> ++  static enum CodecID tmp_alist[] = {
> ++    CODEC_ID_NONE,
> ++    CODEC_ID_NONE
> ++  };
> ++
> ++  GST_LOG ("format_name : %s", format_name);
> ++
> ++  if (!strcmp (format_name, "mp4")) {
> ++    static enum CodecID mp4_video_list[] = {
> ++      CODEC_ID_MPEG4, CODEC_ID_H264,
> ++      CODEC_ID_MJPEG,
> ++      CODEC_ID_NONE
> ++    };
> ++    static enum CodecID mp4_audio_list[] = {
> ++      CODEC_ID_AAC, CODEC_ID_MP3,
> ++      CODEC_ID_NONE
> ++    };
> ++
> ++    *video_codec_list = mp4_video_list;
> ++    *audio_codec_list = mp4_audio_list;
> ++  } else if (!strcmp (format_name, "mpeg")) {
> ++    static enum CodecID mpeg_video_list[] = { CODEC_ID_MPEG1VIDEO,
> ++      CODEC_ID_MPEG2VIDEO,
> ++      CODEC_ID_H264,
> ++      CODEC_ID_NONE
> ++    };
> ++    static enum CodecID mpeg_audio_list[] = { CODEC_ID_MP1,
> ++      CODEC_ID_MP2,
> ++      CODEC_ID_MP3,
> ++      CODEC_ID_NONE
> ++    };
> ++
> ++    *video_codec_list = mpeg_video_list;
> ++    *audio_codec_list = mpeg_audio_list;
> ++  } else if (!strcmp (format_name, "dvd")) {
> ++    static enum CodecID mpeg_video_list[] = { CODEC_ID_MPEG2VIDEO,
> ++      CODEC_ID_NONE
> ++    };
> ++    static enum CodecID mpeg_audio_list[] = { CODEC_ID_MP2,
> ++      CODEC_ID_AC3,
> ++      CODEC_ID_DTS,
> ++      CODEC_ID_PCM_S16BE,
> ++      CODEC_ID_NONE
> ++    };
> ++
> ++    *video_codec_list = mpeg_video_list;
> ++    *audio_codec_list = mpeg_audio_list;
> ++  } else if (!strcmp (format_name, "mpegts")) {
> ++    static enum CodecID mpegts_video_list[] = { CODEC_ID_MPEG1VIDEO,
> ++      CODEC_ID_MPEG2VIDEO,
> ++      CODEC_ID_H264,
> ++      CODEC_ID_NONE
> ++    };
> ++    static enum CodecID mpegts_audio_list[] = { CODEC_ID_MP2,
> ++      CODEC_ID_MP3,
> ++      CODEC_ID_AC3,
> ++      CODEC_ID_DTS,
> ++      CODEC_ID_AAC,
> ++      CODEC_ID_NONE
> ++    };
> ++
> ++    *video_codec_list = mpegts_video_list;
> ++    *audio_codec_list = mpegts_audio_list;
> ++  } else if (!strcmp (format_name, "vob")) {
> ++    static enum CodecID vob_video_list[] =
> ++        { CODEC_ID_MPEG2VIDEO, CODEC_ID_NONE };
> ++    static enum CodecID vob_audio_list[] = { CODEC_ID_MP2, CODEC_ID_AC3,
> ++      CODEC_ID_DTS, CODEC_ID_NONE
> ++    };
> ++
> ++    *video_codec_list = vob_video_list;
> ++    *audio_codec_list = vob_audio_list;
> ++  } else if (!strcmp (format_name, "flv")) {
> ++    static enum CodecID flv_video_list[] = { CODEC_ID_FLV1, CODEC_ID_NONE };
> ++    static enum CodecID flv_audio_list[] = { CODEC_ID_MP3, CODEC_ID_NONE };
> ++
> ++    *video_codec_list = flv_video_list;
> ++    *audio_codec_list = flv_audio_list;
> ++  } else if (!strcmp (format_name, "asf")) {
> ++    static enum CodecID asf_video_list[] =
> ++        { CODEC_ID_WMV1, CODEC_ID_WMV2, CODEC_ID_MSMPEG4V3, CODEC_ID_NONE };
> ++    static enum CodecID asf_audio_list[] =
> ++        { CODEC_ID_WMAV1, CODEC_ID_WMAV2, CODEC_ID_MP3, CODEC_ID_NONE };
> ++
> ++    *video_codec_list = asf_video_list;
> ++    *audio_codec_list = asf_audio_list;
> ++  } else if (!strcmp (format_name, "dv")) {
> ++    static enum CodecID dv_video_list[] = { CODEC_ID_DVVIDEO, CODEC_ID_NONE };
> ++    static enum CodecID dv_audio_list[] = { CODEC_ID_PCM_S16LE, CODEC_ID_NONE };
> ++
> ++    *video_codec_list = dv_video_list;
> ++    *audio_codec_list = dv_audio_list;
> ++  } else if (!strcmp (format_name, "mov")) {
> ++    static enum CodecID mov_video_list[] = {
> ++      CODEC_ID_SVQ1, CODEC_ID_SVQ3, CODEC_ID_MPEG4,
> ++      CODEC_ID_H263, CODEC_ID_H263P,
> ++      CODEC_ID_H264, CODEC_ID_DVVIDEO,
> ++      CODEC_ID_MJPEG,
> ++      CODEC_ID_NONE
> ++    };
> ++    static enum CodecID mov_audio_list[] = {
> ++      CODEC_ID_PCM_MULAW, CODEC_ID_PCM_ALAW, CODEC_ID_ADPCM_IMA_QT,
> ++      CODEC_ID_MACE3, CODEC_ID_MACE6, CODEC_ID_AAC,
> ++      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
> ++      CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE,
> ++      CODEC_ID_MP3, CODEC_ID_NONE
> ++    };
> ++
> ++    *video_codec_list = mov_video_list;
> ++    *audio_codec_list = mov_audio_list;
> ++  } else if ((!strcmp (format_name, "3gp") || !strcmp (format_name, "3g2"))) {
> ++    static enum CodecID tgp_video_list[] = {
> ++      CODEC_ID_MPEG4, CODEC_ID_H263, CODEC_ID_H263P, CODEC_ID_H264,
> ++      CODEC_ID_NONE
> ++    };
> ++    static enum CodecID tgp_audio_list[] = {
> ++      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
> ++      CODEC_ID_AAC,
> ++      CODEC_ID_NONE
> ++    };
> ++
> ++    *video_codec_list = tgp_video_list;
> ++    *audio_codec_list = tgp_audio_list;
> ++  } else if (!strcmp (format_name, "mmf")) {
> ++    static enum CodecID mmf_audio_list[] = {
> ++      CODEC_ID_ADPCM_YAMAHA, CODEC_ID_NONE
> ++    };
> ++    *video_codec_list = NULL;
> ++    *audio_codec_list = mmf_audio_list;
> ++  } else if (!strcmp (format_name, "amr")) {
> ++    static enum CodecID amr_audio_list[] = {
> ++      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
> ++      CODEC_ID_NONE
> ++    };
> ++    *video_codec_list = NULL;
> ++    *audio_codec_list = amr_audio_list;
> ++  } else if (!strcmp (format_name, "gif")) {
> ++    static enum CodecID gif_image_list[] = {
> ++      CODEC_ID_RAWVIDEO, CODEC_ID_NONE
> ++    };
> ++    *video_codec_list = gif_image_list;
> ++    *audio_codec_list = NULL;
> ++  } else if ((plugin->audio_codec != CODEC_ID_NONE) ||
> ++      (plugin->video_codec != CODEC_ID_NONE)) {
> ++    tmp_vlist[0] = plugin->video_codec;
> ++    tmp_alist[0] = plugin->audio_codec;
> ++
> ++    *video_codec_list = tmp_vlist;
> ++    *audio_codec_list = tmp_alist;
> ++  } else {
> ++    GST_LOG ("Format %s not found", format_name);
> ++    return FALSE;
> ++  }
> ++
> ++  return TRUE;
> ++}
> ++
> ++/* Convert a GstCaps to a FFMPEG codec ID. Size et all
> ++ * are omitted, that can be queried by the user itself,
> ++ * we're not eating the GstCaps or anything
> ++ * A pointer to an allocated context is also needed for
> ++ * optional extra info
> ++ */
> ++
> ++enum CodecID
> ++gst_ffmpeg_caps_to_codecid (const GstCaps * caps, AVCodecContext * context)
> ++{
> ++  enum CodecID id = CODEC_ID_NONE;
> ++  const gchar *mimetype;
> ++  const GstStructure *structure;
> ++  gboolean video = FALSE, audio = FALSE;        /* we want to be sure! */
> ++
> ++  g_return_val_if_fail (caps != NULL, CODEC_ID_NONE);
> ++  g_return_val_if_fail (gst_caps_get_size (caps) == 1, CODEC_ID_NONE);
> ++  structure = gst_caps_get_structure (caps, 0);
> ++
> ++  mimetype = gst_structure_get_name (structure);
> ++
> ++  if (!strcmp (mimetype, "video/x-raw-rgb") ||
> ++      !strcmp (mimetype, "video/x-raw-yuv")) {
> ++    id = CODEC_ID_RAWVIDEO;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-raw-int")) {
> ++    gint depth, width, endianness;
> ++    gboolean signedness;
> ++
> ++    if (gst_structure_get_int (structure, "endianness", &endianness) &&
> ++        gst_structure_get_boolean (structure, "signed", &signedness) &&
> ++        gst_structure_get_int (structure, "width", &width) &&
> ++        gst_structure_get_int (structure, "depth", &depth) && depth == width) {
> ++      switch (depth) {
> ++        case 8:
> ++          if (signedness) {
> ++            id = CODEC_ID_PCM_S8;
> ++          } else {
> ++            id = CODEC_ID_PCM_U8;
> ++          }
> ++          break;
> ++        case 16:
> ++          switch (endianness) {
> ++            case G_BIG_ENDIAN:
> ++              if (signedness) {
> ++                id = CODEC_ID_PCM_S16BE;
> ++              } else {
> ++                id = CODEC_ID_PCM_U16BE;
> ++              }
> ++              break;
> ++            case G_LITTLE_ENDIAN:
> ++              if (signedness) {
> ++                id = CODEC_ID_PCM_S16LE;
> ++              } else {
> ++                id = CODEC_ID_PCM_U16LE;
> ++              }
> ++              break;
> ++          }
> ++          break;
> ++      }
> ++      if (id != CODEC_ID_NONE)
> ++        audio = TRUE;
> ++    }
> ++  } else if (!strcmp (mimetype, "audio/x-mulaw")) {
> ++    id = CODEC_ID_PCM_MULAW;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-alaw")) {
> ++    id = CODEC_ID_PCM_ALAW;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-dv")) {
> ++    gboolean sys_strm;
> ++
> ++    if (gst_structure_get_boolean (structure, "systemstream", &sys_strm) &&
> ++        !sys_strm) {
> ++      id = CODEC_ID_DVVIDEO;
> ++      video = TRUE;
> ++    }
> ++  } else if (!strcmp (mimetype, "audio/x-dv")) {        /* ??? */
> ++    id = CODEC_ID_DVAUDIO;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-h263")) {
> ++    const gchar *h263version =
> ++        gst_structure_get_string (structure, "h263version");
> ++    if (h263version && !strcmp (h263version, "h263p"))
> ++      id = CODEC_ID_H263P;
> ++    else
> ++      id = CODEC_ID_H263;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-intel-h263")) {
> ++    id = CODEC_ID_H263I;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-h261")) {
> ++    id = CODEC_ID_H261;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/mpeg")) {
> ++    gboolean sys_strm;
> ++    gint mpegversion;
> ++
> ++    if (gst_structure_get_boolean (structure, "systemstream", &sys_strm) &&
> ++        gst_structure_get_int (structure, "mpegversion", &mpegversion) &&
> ++        !sys_strm) {
> ++      switch (mpegversion) {
> ++        case 1:
> ++          id = CODEC_ID_MPEG1VIDEO;
> ++          break;
> ++        case 2:
> ++          id = CODEC_ID_MPEG2VIDEO;
> ++          break;
> ++        case 4:
> ++          id = CODEC_ID_MPEG4;
> ++          break;
> ++      }
> ++    }
> ++    if (id != CODEC_ID_NONE)
> ++      video = TRUE;
> ++  } else if (!strcmp (mimetype, "image/jpeg")) {
> ++    id = CODEC_ID_MJPEG;        /* A... B... */
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-jpeg-b")) {
> ++    id = CODEC_ID_MJPEGB;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-wmv")) {
> ++    gint wmvversion = 0;
> ++
> ++    if (gst_structure_get_int (structure, "wmvversion", &wmvversion)) {
> ++      switch (wmvversion) {
> ++        case 1:
> ++          id = CODEC_ID_WMV1;
> ++          break;
> ++        case 2:
> ++          id = CODEC_ID_WMV2;
> ++          break;
> ++        case 3:
> ++        {
> ++          guint32 fourcc;
> ++
> ++          /* WMV3 unless the fourcc exists and says otherwise */
> ++          id = CODEC_ID_WMV3;
> ++
> ++          if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
> ++            if ((fourcc == GST_MAKE_FOURCC ('W', 'V', 'C', '1')) ||
> ++                (fourcc == GST_MAKE_FOURCC ('W', 'M', 'V', 'A'))) {
> ++              id = CODEC_ID_VC1;
> ++            }
> ++          }
> ++        }
> ++          break;
> ++      }
> ++    }
> ++    if (id != CODEC_ID_NONE)
> ++      video = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-vorbis")) {
> ++    id = CODEC_ID_VORBIS;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-qdm2")) {
> ++    id = CODEC_ID_QDM2;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/mpeg")) {
> ++    gint layer = 0;
> ++    gint mpegversion = 0;
> ++
> ++    if (gst_structure_get_int (structure, "mpegversion", &mpegversion)) {
> ++      switch (mpegversion) {
> ++        case 2:                /* ffmpeg uses faad for both... */
> ++        case 4:
> ++          id = CODEC_ID_AAC;
> ++          break;
> ++        case 1:
> ++          if (gst_structure_get_int (structure, "layer", &layer)) {
> ++            switch (layer) {
> ++              case 1:
> ++                id = CODEC_ID_MP1;
> ++                break;
> ++              case 2:
> ++                id = CODEC_ID_MP2;
> ++                break;
> ++              case 3:
> ++                id = CODEC_ID_MP3;
> ++                break;
> ++            }
> ++          }
> ++      }
> ++    }
> ++    if (id != CODEC_ID_NONE)
> ++      audio = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-musepack")) {
> ++    gint streamversion = -1;
> ++
> ++    if (gst_structure_get_int (structure, "streamversion", &streamversion)) {
> ++      if (streamversion == 7)
> ++        id = CODEC_ID_MUSEPACK7;
> ++    } else {
> ++      id = CODEC_ID_MUSEPACK7;
> ++    }
> ++  } else if (!strcmp (mimetype, "audio/x-wma")) {
> ++    gint wmaversion = 0;
> ++
> ++    if (gst_structure_get_int (structure, "wmaversion", &wmaversion)) {
> ++      switch (wmaversion) {
> ++        case 1:
> ++          id = CODEC_ID_WMAV1;
> ++          break;
> ++        case 2:
> ++          id = CODEC_ID_WMAV2;
> ++          break;
> ++        case 3:
> ++          id = CODEC_ID_WMAPRO;
> ++          break;
> ++      }
> ++    }
> ++    if (id != CODEC_ID_NONE)
> ++      audio = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-wms")) {
> ++    id = CODEC_ID_WMAVOICE;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-ac3")) {
> ++    id = CODEC_ID_AC3;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-eac3")) {
> ++    id = CODEC_ID_EAC3;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-vnd.sony.atrac3") ||
> ++      !strcmp (mimetype, "audio/atrac3")) {
> ++    id = CODEC_ID_ATRAC3;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-dts")) {
> ++    id = CODEC_ID_DTS;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "application/x-ape")) {
> ++    id = CODEC_ID_APE;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-msmpeg")) {
> ++    gint msmpegversion = 0;
> ++
> ++    if (gst_structure_get_int (structure, "msmpegversion", &msmpegversion)) {
> ++      switch (msmpegversion) {
> ++        case 41:
> ++          id = CODEC_ID_MSMPEG4V1;
> ++          break;
> ++        case 42:
> ++          id = CODEC_ID_MSMPEG4V2;
> ++          break;
> ++        case 43:
> ++          id = CODEC_ID_MSMPEG4V3;
> ++          break;
> ++      }
> ++    }
> ++    if (id != CODEC_ID_NONE)
> ++      video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-svq")) {
> ++    gint svqversion = 0;
> ++
> ++    if (gst_structure_get_int (structure, "svqversion", &svqversion)) {
> ++      switch (svqversion) {
> ++        case 1:
> ++          id = CODEC_ID_SVQ1;
> ++          break;
> ++        case 3:
> ++          id = CODEC_ID_SVQ3;
> ++          break;
> ++      }
> ++    }
> ++    if (id != CODEC_ID_NONE)
> ++      video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-huffyuv")) {
> ++    id = CODEC_ID_HUFFYUV;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-mace")) {
> ++    gint maceversion = 0;
> ++
> ++    if (gst_structure_get_int (structure, "maceversion", &maceversion)) {
> ++      switch (maceversion) {
> ++        case 3:
> ++          id = CODEC_ID_MACE3;
> ++          break;
> ++        case 6:
> ++          id = CODEC_ID_MACE6;
> ++          break;
> ++      }
> ++    }
> ++    if (id != CODEC_ID_NONE)
> ++      audio = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-theora")) {
> ++    id = CODEC_ID_THEORA;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-vp3")) {
> ++    id = CODEC_ID_VP3;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-vp5")) {
> ++    id = CODEC_ID_VP5;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-vp6")) {
> ++    id = CODEC_ID_VP6;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-vp6-flash")) {
> ++    id = CODEC_ID_VP6F;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-vp6-alpha")) {
> ++    id = CODEC_ID_VP6A;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-vp8")) {
> ++    id = CODEC_ID_VP8;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-flash-screen")) {
> ++    id = CODEC_ID_FLASHSV;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-indeo")) {
> ++    gint indeoversion = 0;
> ++
> ++    if (gst_structure_get_int (structure, "indeoversion", &indeoversion)) {
> ++      switch (indeoversion) {
> ++        case 5:
> ++          id = CODEC_ID_INDEO5;
> ++          break;
> ++        case 3:
> ++          id = CODEC_ID_INDEO3;
> ++          break;
> ++        case 2:
> ++          id = CODEC_ID_INDEO2;
> ++          break;
> ++      }
> ++      if (id != CODEC_ID_NONE)
> ++        video = TRUE;
> ++    }
> ++  } else if (!strcmp (mimetype, "video/x-divx")) {
> ++    gint divxversion = 0;
> ++
> ++    if (gst_structure_get_int (structure, "divxversion", &divxversion)) {
> ++      switch (divxversion) {
> ++        case 3:
> ++          id = CODEC_ID_MSMPEG4V3;
> ++          break;
> ++        case 4:
> ++        case 5:
> ++          id = CODEC_ID_MPEG4;
> ++          break;
> ++      }
> ++    }
> ++    if (id != CODEC_ID_NONE)
> ++      video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-3ivx")) {
> ++    id = CODEC_ID_MPEG4;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-xvid")) {
> ++    id = CODEC_ID_MPEG4;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-ffv")) {
> ++    gint ffvversion = 0;
> ++
> ++    if (gst_structure_get_int (structure, "ffvversion", &ffvversion) &&
> ++        ffvversion == 1) {
> ++      id = CODEC_ID_FFV1;
> ++      video = TRUE;
> ++    }
> ++  } else if (!strcmp (mimetype, "audio/x-adpcm")) {
> ++    const gchar *layout;
> ++
> ++    layout = gst_structure_get_string (structure, "layout");
> ++    if (layout == NULL) {
> ++      /* break */
> ++    } else if (!strcmp (layout, "quicktime")) {
> ++      id = CODEC_ID_ADPCM_IMA_QT;
> ++    } else if (!strcmp (layout, "microsoft")) {
> ++      id = CODEC_ID_ADPCM_MS;
> ++    } else if (!strcmp (layout, "dvi")) {
> ++      id = CODEC_ID_ADPCM_IMA_WAV;
> ++    } else if (!strcmp (layout, "4xm")) {
> ++      id = CODEC_ID_ADPCM_4XM;
> ++    } else if (!strcmp (layout, "smjpeg")) {
> ++      id = CODEC_ID_ADPCM_IMA_SMJPEG;
> ++    } else if (!strcmp (layout, "dk3")) {
> ++      id = CODEC_ID_ADPCM_IMA_DK3;
> ++    } else if (!strcmp (layout, "dk4")) {
> ++      id = CODEC_ID_ADPCM_IMA_DK4;
> ++    } else if (!strcmp (layout, "westwood")) {
> ++      id = CODEC_ID_ADPCM_IMA_WS;
> ++    } else if (!strcmp (layout, "iss")) {
> ++      id = CODEC_ID_ADPCM_IMA_ISS;
> ++    } else if (!strcmp (layout, "xa")) {
> ++      id = CODEC_ID_ADPCM_XA;
> ++    } else if (!strcmp (layout, "adx")) {
> ++      id = CODEC_ID_ADPCM_ADX;
> ++    } else if (!strcmp (layout, "ea")) {
> ++      id = CODEC_ID_ADPCM_EA;
> ++    } else if (!strcmp (layout, "g726")) {
> ++      id = CODEC_ID_ADPCM_G726;
> ++    } else if (!strcmp (layout, "g721")) {
> ++      id = CODEC_ID_ADPCM_G726;
> ++    } else if (!strcmp (layout, "ct")) {
> ++      id = CODEC_ID_ADPCM_CT;
> ++    } else if (!strcmp (layout, "swf")) {
> ++      id = CODEC_ID_ADPCM_SWF;
> ++    } else if (!strcmp (layout, "yamaha")) {
> ++      id = CODEC_ID_ADPCM_YAMAHA;
> ++    } else if (!strcmp (layout, "sbpro2")) {
> ++      id = CODEC_ID_ADPCM_SBPRO_2;
> ++    } else if (!strcmp (layout, "sbpro3")) {
> ++      id = CODEC_ID_ADPCM_SBPRO_3;
> ++    } else if (!strcmp (layout, "sbpro4")) {
> ++      id = CODEC_ID_ADPCM_SBPRO_4;
> ++    }
> ++    if (id != CODEC_ID_NONE)
> ++      audio = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-4xm")) {
> ++    id = CODEC_ID_4XM;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-dpcm")) {
> ++    const gchar *layout;
> ++
> ++    layout = gst_structure_get_string (structure, "layout");
> ++    if (!layout) {
> ++      /* .. */
> ++    } else if (!strcmp (layout, "roq")) {
> ++      id = CODEC_ID_ROQ_DPCM;
> ++    } else if (!strcmp (layout, "interplay")) {
> ++      id = CODEC_ID_INTERPLAY_DPCM;
> ++    } else if (!strcmp (layout, "xan")) {
> ++      id = CODEC_ID_XAN_DPCM;
> ++    } else if (!strcmp (layout, "sol")) {
> ++      id = CODEC_ID_SOL_DPCM;
> ++    }
> ++    if (id != CODEC_ID_NONE)
> ++      audio = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-flac")) {
> ++    id = CODEC_ID_FLAC;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-shorten")) {
> ++    id = CODEC_ID_SHORTEN;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-alac")) {
> ++    id = CODEC_ID_ALAC;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-cinepak")) {
> ++    id = CODEC_ID_CINEPAK;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-pn-realvideo")) {
> ++    gint rmversion;
> ++
> ++    if (gst_structure_get_int (structure, "rmversion", &rmversion)) {
> ++      switch (rmversion) {
> ++        case 1:
> ++          id = CODEC_ID_RV10;
> ++          break;
> ++        case 2:
> ++          id = CODEC_ID_RV20;
> ++          break;
> ++        case 3:
> ++          id = CODEC_ID_RV30;
> ++          break;
> ++        case 4:
> ++          id = CODEC_ID_RV40;
> ++          break;
> ++      }
> ++    }
> ++    if (id != CODEC_ID_NONE)
> ++      video = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-sipro")) {
> ++    id = CODEC_ID_SIPR;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/x-pn-realaudio")) {
> ++    gint raversion;
> ++
> ++    if (gst_structure_get_int (structure, "raversion", &raversion)) {
> ++      switch (raversion) {
> ++        case 1:
> ++          id = CODEC_ID_RA_144;
> ++          break;
> ++        case 2:
> ++          id = CODEC_ID_RA_288;
> ++          break;
> ++        case 8:
> ++          id = CODEC_ID_COOK;
> ++          break;
> ++      }
> ++    }
> ++    if (id != CODEC_ID_NONE)
> ++      audio = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-rle")) {
> ++    const gchar *layout;
> ++
> ++    if ((layout = gst_structure_get_string (structure, "layout"))) {
> ++      if (!strcmp (layout, "microsoft")) {
> ++        id = CODEC_ID_MSRLE;
> ++        video = TRUE;
> ++      }
> ++    }
> ++  } else if (!strcmp (mimetype, "video/x-xan")) {
> ++    gint wcversion = 0;
> ++
> ++    if ((gst_structure_get_int (structure, "wcversion", &wcversion))) {
> ++      switch (wcversion) {
> ++        case 3:
> ++          id = CODEC_ID_XAN_WC3;
> ++          video = TRUE;
> ++          break;
> ++        case 4:
> ++          id = CODEC_ID_XAN_WC4;
> ++          video = TRUE;
> ++          break;
> ++        default:
> ++          break;
> ++      }
> ++    }
> ++  } else if (!strcmp (mimetype, "audio/AMR")) {
> ++    audio = TRUE;
> ++    id = CODEC_ID_AMR_NB;
> ++  } else if (!strcmp (mimetype, "audio/AMR-WB")) {
> ++    id = CODEC_ID_AMR_WB;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "audio/qcelp")) {
> ++    id = CODEC_ID_QCELP;
> ++    audio = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-h264")) {
> ++    id = CODEC_ID_H264;
> ++    video = TRUE;
> ++  } else if (!strcmp (mimetype, "video/x-flash-video")) {
> ++    gint flvversion = 0;
> ++
> ++    if ((gst_structure_get_int (structure, "flvversion", &flvversion))) {
> ++      switch (flvversion) {
> ++        case 1:
> ++          id = CODEC_ID_FLV1;
> ++          video = TRUE;
> ++          break;
> ++        default:
> ++          break;
> ++      }
> ++    }
> ++
> ++  } else if (!strcmp (mimetype, "audio/x-nellymoser")) {
> ++    id = CODEC_ID_NELLYMOSER;
> ++    audio = TRUE;
> ++  } else if (!strncmp (mimetype, "audio/x-gst_ff-", 15)) {
> ++    gchar ext[16];
> ++    AVCodec *codec;
> ++
> ++    if (strlen (mimetype) <= 30 &&
> ++        sscanf (mimetype, "audio/x-gst_ff-%s", ext) == 1) {
> ++      if ((codec = avcodec_find_decoder_by_name (ext)) ||
> ++          (codec = avcodec_find_encoder_by_name (ext))) {
> ++        id = codec->id;
> ++        audio = TRUE;
> ++      }
> ++    }
> ++  } else if (!strncmp (mimetype, "video/x-gst_ff-", 15)) {
> ++    gchar ext[16];
> ++    AVCodec *codec;
> ++
> ++    if (strlen (mimetype) <= 30 &&
> ++        sscanf (mimetype, "video/x-gst_ff-%s", ext) == 1) {
> ++      if ((codec = avcodec_find_decoder_by_name (ext)) ||
> ++          (codec = avcodec_find_encoder_by_name (ext))) {
> ++        id = codec->id;
> ++        video = TRUE;
> ++      }
> ++    }
> ++  }
> ++
> ++  if (context != NULL) {
> ++    if (video == TRUE) {
> ++      context->codec_type = AVMEDIA_TYPE_VIDEO;
> ++    } else if (audio == TRUE) {
> ++      context->codec_type = AVMEDIA_TYPE_AUDIO;
> ++    } else {
> ++      context->codec_type = AVMEDIA_TYPE_UNKNOWN;
> ++    }
> ++    context->codec_id = id;
> ++    gst_ffmpeg_caps_with_codecid (id, context->codec_type, caps, context);
> ++  }
> ++
> ++  if (id != CODEC_ID_NONE) {
> ++    GST_DEBUG ("The id=%d belongs to the caps %" GST_PTR_FORMAT, id, caps);
> ++  } else {
> ++    GST_WARNING ("Couldn't figure out the id for caps %" GST_PTR_FORMAT, caps);
> ++  }
> ++
> ++  return id;
> ++}
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.rej gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.rej
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.rej	1970-01-01 01:00:00.000000000 +0100
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.rej	2014-08-08 15:31:06.055868246 +0200
> +@@ -0,0 +1,12 @@
> ++--- ext/ffmpeg/gstffmpegcodecmap.c
> +++++ ext/ffmpeg/gstffmpegcodecmap.c
> ++@@ -1884,9 +1842,6 @@
> ++             gst_ff_vid_caps_new (context, codec_id, encode, "video/x-raw-rgb",
> ++             "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, "endianness",
> ++             G_TYPE_INT, endianness, NULL);
> ++-        if (caps && context) {
> ++-          gst_ffmpeg_set_palette (caps, context);
> ++-        }
> ++       }
> ++     } else if (fmt) {
> ++       caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-raw-yuv",
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c	2014-08-08 14:46:31.462772351 +0200
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c	2014-08-08 15:32:18.608870847 +0200
> +@@ -88,7 +88,6 @@
> +       gint depth;
> +     } audio;
> +   } format;
> +-  gboolean waiting_for_key;
> +   gboolean discont;
> +   gboolean clear_ts;
> +
> +@@ -438,7 +437,6 @@
> +   ffmpegdec->pcache = NULL;
> +   ffmpegdec->par = NULL;
> +   ffmpegdec->opened = FALSE;
> +-  ffmpegdec->waiting_for_key = TRUE;
> +   ffmpegdec->skip_frame = ffmpegdec->lowres = 0;
> +   ffmpegdec->direct_rendering = DEFAULT_DIRECT_RENDERING;
> +   ffmpegdec->do_padding = DEFAULT_DO_PADDING;
> +@@ -608,11 +606,6 @@
> +     gst_ffmpeg_avcodec_close (ffmpegdec->context);
> +   ffmpegdec->opened = FALSE;
> +
> +-  if (ffmpegdec->context->palctrl) {
> +-    av_free (ffmpegdec->context->palctrl);
> +-    ffmpegdec->context->palctrl = NULL;
> +-  }
> +-
> +   if (ffmpegdec->context->extradata) {
> +     av_free (ffmpegdec->context->extradata);
> +     ffmpegdec->context->extradata = NULL;
> +@@ -864,7 +857,7 @@
> +
> +   /* workaround encoder bugs */
> +   ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
> +-  ffmpegdec->context->error_recognition = 1;
> ++  ffmpegdec->context->err_recognition = 1;
> +
> +   /* for slow cpus */
> +   ffmpegdec->context->lowres = ffmpegdec->lowres;
> +@@ -944,7 +937,7 @@
> +   fsize = gst_ffmpeg_avpicture_get_size (ffmpegdec->context->pix_fmt,
> +       width, height);
> +
> +-  if (!ffmpegdec->context->palctrl && ffmpegdec->can_allocate_aligned) {
> ++  if (ffmpegdec->can_allocate_aligned) {
> +     GST_LOG_OBJECT (ffmpegdec, "calling pad_alloc");
> +     /* no pallete, we can use the buffer size to alloc */
> +     ret = gst_pad_alloc_buffer_and_set_caps (ffmpegdec->srcpad,
> +@@ -1083,7 +1076,6 @@
> +   /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to
> +    * the opaque data. */
> +   picture->type = FF_BUFFER_TYPE_USER;
> +-  picture->age = 256 * 256 * 256 * 64;
> +   picture->opaque = buf;
> +
> + #ifdef EXTRA_REF
> +@@ -1414,10 +1406,6 @@
> +   } else {
> +     if (diff >= 0) {
> +       /* we're too slow, try to speed up */
> +-      if (ffmpegdec->waiting_for_key) {
> +-        /* we were waiting for a keyframe, that's ok */
> +-        goto skipping;
> +-      }
> +       /* switch to skip_frame mode */
> +       goto skip_frame;
> +     }
> +@@ -1427,11 +1415,6 @@
> +   ffmpegdec->processed++;
> +   return TRUE;
> +
> +-skipping:
> +-  {
> +-    res = FALSE;
> +-    goto drop_qos;
> +-  }
> + normal_mode:
> +   {
> +     if (ffmpegdec->context->skip_frame != AVDISCARD_DEFAULT) {
> +@@ -1528,43 +1511,6 @@
> + }
> +
> +
> +-/* figure out if the current picture is a keyframe, return TRUE if that is
> +- * the case. */
> +-static gboolean
> +-check_keyframe (GstFFMpegDec * ffmpegdec)
> +-{
> +-  GstFFMpegDecClass *oclass;
> +-  gboolean is_itype = FALSE;
> +-  gboolean is_reference = FALSE;
> +-  gboolean iskeyframe;
> +-
> +-  /* figure out if we are dealing with a keyframe */
> +-  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> +-
> +-  /* remember that we have B frames, we need this for the DTS -> PTS conversion
> +-   * code */
> +-  if (!ffmpegdec->has_b_frames && ffmpegdec->picture->pict_type == FF_B_TYPE) {
> +-    GST_DEBUG_OBJECT (ffmpegdec, "we have B frames");
> +-    ffmpegdec->has_b_frames = TRUE;
> +-  }
> +-
> +-  is_itype = (ffmpegdec->picture->pict_type == FF_I_TYPE);
> +-  is_reference = (ffmpegdec->picture->reference == 1);
> +-
> +-  iskeyframe = (is_itype || is_reference || ffmpegdec->picture->key_frame)
> +-      || (oclass->in_plugin->id == CODEC_ID_INDEO3)
> +-      || (oclass->in_plugin->id == CODEC_ID_MSZH)
> +-      || (oclass->in_plugin->id == CODEC_ID_ZLIB)
> +-      || (oclass->in_plugin->id == CODEC_ID_VP3)
> +-      || (oclass->in_plugin->id == CODEC_ID_HUFFYUV);
> +-
> +-  GST_LOG_OBJECT (ffmpegdec,
> +-      "current picture: type: %d, is_keyframe:%d, is_itype:%d, is_reference:%d",
> +-      ffmpegdec->picture->pict_type, iskeyframe, is_itype, is_reference);
> +-
> +-  return iskeyframe;
> +-}
> +-
> + /* get an outbuf buffer with the current picture */
> + static GstFlowReturn
> + get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
> +@@ -1694,7 +1640,6 @@
> + {
> +   gint len = -1;
> +   gint have_data;
> +-  gboolean iskeyframe;
> +   gboolean mode_switch;
> +   gboolean decode;
> +   gint skip_frame = AVDISCARD_DEFAULT;
> +@@ -1809,7 +1754,6 @@
> +     gst_ffmpegdec_negotiate (ffmpegdec, TRUE);
> +   }
> +
> +-
> +   /* Whether a frame is interlaced or not is unknown at the time of
> +      buffer allocation, so caps on the buffer in opaque will have
> +      the previous frame's interlaced flag set. So if interlacedness
> +@@ -1831,10 +1775,6 @@
> +     }
> +   }
> +
> +-  /* check if we are dealing with a keyframe here, this will also check if we
> +-   * are dealing with B frames. */
> +-  iskeyframe = check_keyframe (ffmpegdec);
> +-
> +   /* check that the timestamps go upwards */
> +   if (ffmpegdec->last_out != -1 && ffmpegdec->last_out > out_pts) {
> +     /* timestamps go backwards, this means frames were reordered and we must
> +@@ -1865,7 +1805,7 @@
> +    * timestamps */
> +   if (!ffmpegdec->reordered_in && ffmpegdec->reordered_out) {
> +     /* PTS and DTS are the same for keyframes */
> +-    if (!iskeyframe && ffmpegdec->next_out != -1) {
> ++    if (ffmpegdec->next_out != -1) {
> +       /* interpolate all timestamps except for keyframes, FIXME, this is
> +        * wrong when QoS is active. */
> +       GST_DEBUG_OBJECT (ffmpegdec, "interpolate timestamps");
> +@@ -1874,16 +1814,6 @@
> +     }
> +   }
> +
> +-  /* when we're waiting for a keyframe, see if we have one or drop the current
> +-   * non-keyframe */
> +-  if (G_UNLIKELY (ffmpegdec->waiting_for_key)) {
> +-    if (G_LIKELY (!iskeyframe))
> +-      goto drop_non_keyframe;
> +-
> +-    /* we have a keyframe, we can stop waiting for one */
> +-    ffmpegdec->waiting_for_key = FALSE;
> +-  }
> +-
> +   /* get a handle to the output buffer */
> +   *ret = get_output_buffer (ffmpegdec, outbuf);
> +   if (G_UNLIKELY (*ret != GST_FLOW_OK))
> +@@ -2000,20 +1930,11 @@
> +   else
> +     ffmpegdec->next_out = -1;
> +
> +-  /* palette is not part of raw video frame in gst and the size
> +-   * of the outgoing buffer needs to be adjusted accordingly */
> +-  if (ffmpegdec->context->palctrl != NULL)
> +-    GST_BUFFER_SIZE (*outbuf) -= AVPALETTE_SIZE;
> +-
> +   /* now see if we need to clip the buffer against the segment boundaries. */
> +   if (G_UNLIKELY (!clip_video_buffer (ffmpegdec, *outbuf, out_timestamp,
> +               out_duration)))
> +     goto clipped;
> +
> +-  /* mark as keyframe or delta unit */
> +-  if (!iskeyframe)
> +-    GST_BUFFER_FLAG_SET (*outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
> +-
> +   if (ffmpegdec->picture->top_field_first)
> +     GST_BUFFER_FLAG_SET (*outbuf, GST_VIDEO_BUFFER_TFF);
> +
> +@@ -2024,11 +1945,6 @@
> +   return len;
> +
> +   /* special cases */
> +-drop_non_keyframe:
> +-  {
> +-    GST_WARNING_OBJECT (ffmpegdec, "Dropping non-keyframe (seek/init)");
> +-    goto beach;
> +-  }
> + no_output:
> +   {
> +     GST_DEBUG_OBJECT (ffmpegdec, "no output buffer");
> +@@ -2422,7 +2338,6 @@
> +       gst_ffmpegdec_reset_ts (ffmpegdec);
> +       gst_ffmpegdec_reset_qos (ffmpegdec);
> +       gst_ffmpegdec_flush_pcache (ffmpegdec);
> +-      ffmpegdec->waiting_for_key = TRUE;
> +       gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
> +       clear_queued (ffmpegdec);
> +       break;
> +@@ -2560,17 +2475,6 @@
> +
> +   oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> +
> +-  /* do early keyframe check pretty bad to rely on the keyframe flag in the
> +-   * source for this as it might not even be parsed (UDP/file/..).  */
> +-  if (G_UNLIKELY (ffmpegdec->waiting_for_key)) {
> +-    GST_DEBUG_OBJECT (ffmpegdec, "waiting for keyframe");
> +-    if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_DELTA_UNIT) &&
> +-        oclass->in_plugin->type != AVMEDIA_TYPE_AUDIO)
> +-      goto skip_keyframe;
> +-
> +-    GST_DEBUG_OBJECT (ffmpegdec, "got keyframe");
> +-    ffmpegdec->waiting_for_key = FALSE;
> +-  }
> +   /* parse cache joining. If there is cached data */
> +   if (ffmpegdec->pcache) {
> +     /* join with previous data */
> +@@ -2805,12 +2709,6 @@
> +     gst_buffer_unref (inbuf);
> +     return GST_FLOW_NOT_NEGOTIATED;
> +   }
> +-skip_keyframe:
> +-  {
> +-    GST_DEBUG_OBJECT (ffmpegdec, "skipping non keyframe");
> +-    gst_buffer_unref (inbuf);
> +-    return GST_FLOW_OK;
> +-  }
> + }
> +
> + static GstStateChangeReturn
> +@@ -2936,7 +2834,7 @@
> +     gchar *plugin_name;
> +
> +     /* only decoders */
> +-    if (!in_plugin->decode) {
> ++    if (!av_codec_is_decoder (in_plugin)) {
> +       goto next;
> +     }
> +
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.orig
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.orig	1970-01-01 01:00:00.000000000 +0100
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.orig	2014-08-08 15:31:06.057868246 +0200
> +@@ -0,0 +1,2973 @@
> ++/* 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 <assert.h>
> ++#include <string.h>
> ++
> ++#ifdef HAVE_FFMPEG_UNINSTALLED
> ++#include <avcodec.h>
> ++#else
> ++#include <libavcodec/avcodec.h>
> ++#endif
> ++
> ++#include <gst/gst.h>
> ++#include <gst/video/video.h>
> ++
> ++#include "gstffmpeg.h"
> ++#include "gstffmpegcodecmap.h"
> ++#include "gstffmpegutils.h"
> ++
> ++/* define to enable alternative buffer refcounting algorithm */
> ++#undef EXTRA_REF
> ++
> ++typedef struct _GstFFMpegDec GstFFMpegDec;
> ++
> ++#define MAX_TS_MASK 0xff
> ++
> ++/* for each incomming buffer we keep all timing info in a structure like this.
> ++ * We keep a circular array of these structures around to store the timing info.
> ++ * The index in the array is what we pass as opaque data (to pictures) and
> ++ * pts (to parsers) so that ffmpeg can remember them for us. */
> ++typedef struct
> ++{
> ++  gint idx;
> ++  GstClockTime timestamp;
> ++  GstClockTime duration;
> ++  gint64 offset;
> ++} GstTSInfo;
> ++
> ++struct _GstFFMpegDec
> ++{
> ++  GstElement element;
> ++
> ++  /* We need to keep track of our pads, so we do so here. */
> ++  GstPad *srcpad;
> ++  GstPad *sinkpad;
> ++
> ++  /* decoding */
> ++  AVCodecContext *context;
> ++  AVFrame *picture;
> ++  gboolean opened;
> ++  union
> ++  {
> ++    struct
> ++    {
> ++      gint width, height;
> ++      gint clip_width, clip_height;
> ++      gint par_n, par_d;
> ++      gint fps_n, fps_d;
> ++      gint old_fps_n, old_fps_d;
> ++      gboolean interlaced;
> ++
> ++      enum PixelFormat pix_fmt;
> ++    } video;
> ++    struct
> ++    {
> ++      gint channels;
> ++      gint samplerate;
> ++      gint depth;
> ++    } audio;
> ++  } format;
> ++  gboolean discont;
> ++  gboolean clear_ts;
> ++
> ++  /* for tracking DTS/PTS */
> ++  gboolean has_b_frames;
> ++  gboolean reordered_in;
> ++  GstClockTime last_in;
> ++  GstClockTime last_diff;
> ++  guint last_frames;
> ++  gboolean reordered_out;
> ++  GstClockTime last_out;
> ++  GstClockTime next_out;
> ++
> ++  /* parsing */
> ++  gboolean turnoff_parser;      /* used for turning off aac raw parsing
> ++                                 * See bug #566250 */
> ++  AVCodecParserContext *pctx;
> ++  GstBuffer *pcache;
> ++  guint8 *padded;
> ++  guint padded_size;
> ++
> ++  GValue *par;                  /* pixel aspect ratio of incoming data */
> ++  gboolean current_dr;          /* if direct rendering is enabled */
> ++  gboolean extra_ref;           /* keep extra ref around in get/release */
> ++
> ++  /* some properties */
> ++  enum AVDiscard skip_frame;
> ++  gint lowres;
> ++  gboolean direct_rendering;
> ++  gboolean do_padding;
> ++  gboolean debug_mv;
> ++  gboolean crop;
> ++  int max_threads;
> ++
> ++  /* QoS stuff *//* with LOCK */
> ++  gdouble proportion;
> ++  GstClockTime earliest_time;
> ++  gint64 processed;
> ++  gint64 dropped;
> ++
> ++  /* clipping segment */
> ++  GstSegment segment;
> ++
> ++  gboolean is_realvideo;
> ++
> ++  GstTSInfo ts_info[MAX_TS_MASK + 1];
> ++  gint ts_idx;
> ++
> ++  /* reverse playback queue */
> ++  GList *queued;
> ++
> ++  /* Can downstream allocate 16bytes aligned data. */
> ++  gboolean can_allocate_aligned;
> ++};
> ++
> ++typedef struct _GstFFMpegDecClass GstFFMpegDecClass;
> ++
> ++struct _GstFFMpegDecClass
> ++{
> ++  GstElementClass parent_class;
> ++
> ++  AVCodec *in_plugin;
> ++  GstPadTemplate *srctempl, *sinktempl;
> ++};
> ++
> ++#define GST_TS_INFO_NONE &ts_info_none
> ++static const GstTSInfo ts_info_none = { -1, -1, -1, -1 };
> ++
> ++static const GstTSInfo *
> ++gst_ts_info_store (GstFFMpegDec * dec, GstClockTime timestamp,
> ++    GstClockTime duration, gint64 offset)
> ++{
> ++  gint idx = dec->ts_idx;
> ++  dec->ts_info[idx].idx = idx;
> ++  dec->ts_info[idx].timestamp = timestamp;
> ++  dec->ts_info[idx].duration = duration;
> ++  dec->ts_info[idx].offset = offset;
> ++  dec->ts_idx = (idx + 1) & MAX_TS_MASK;
> ++
> ++  return &dec->ts_info[idx];
> ++}
> ++
> ++static const GstTSInfo *
> ++gst_ts_info_get (GstFFMpegDec * dec, gint idx)
> ++{
> ++  if (G_UNLIKELY (idx < 0 || idx > MAX_TS_MASK))
> ++    return GST_TS_INFO_NONE;
> ++
> ++  return &dec->ts_info[idx];
> ++}
> ++
> ++#define GST_TYPE_FFMPEGDEC \
> ++  (gst_ffmpegdec_get_type())
> ++#define GST_FFMPEGDEC(obj) \
> ++  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGDEC,GstFFMpegDec))
> ++#define GST_FFMPEGDEC_CLASS(klass) \
> ++  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGDEC,GstFFMpegDecClass))
> ++#define GST_IS_FFMPEGDEC(obj) \
> ++  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGDEC))
> ++#define GST_IS_FFMPEGDEC_CLASS(klass) \
> ++  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGDEC))
> ++
> ++#define DEFAULT_LOWRES			0
> ++#define DEFAULT_SKIPFRAME		0
> ++#define DEFAULT_DIRECT_RENDERING	TRUE
> ++#define DEFAULT_DO_PADDING		TRUE
> ++#define DEFAULT_DEBUG_MV		FALSE
> ++#define DEFAULT_CROP			TRUE
> ++#define DEFAULT_MAX_THREADS		1
> ++
> ++enum
> ++{
> ++  PROP_0,
> ++  PROP_LOWRES,
> ++  PROP_SKIPFRAME,
> ++  PROP_DIRECT_RENDERING,
> ++  PROP_DO_PADDING,
> ++  PROP_DEBUG_MV,
> ++  PROP_CROP,
> ++  PROP_MAX_THREADS,
> ++  PROP_LAST
> ++};
> ++
> ++/* A number of function prototypes are given so we can refer to them later. */
> ++static void gst_ffmpegdec_base_init (GstFFMpegDecClass * klass);
> ++static void gst_ffmpegdec_class_init (GstFFMpegDecClass * klass);
> ++static void gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec);
> ++static void gst_ffmpegdec_finalize (GObject * object);
> ++
> ++static gboolean gst_ffmpegdec_query (GstPad * pad, GstQuery * query);
> ++static gboolean gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event);
> ++
> ++static gboolean gst_ffmpegdec_setcaps (GstPad * pad, GstCaps * caps);
> ++static gboolean gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event);
> ++static GstFlowReturn gst_ffmpegdec_chain (GstPad * pad, GstBuffer * buf);
> ++
> ++static GstStateChangeReturn gst_ffmpegdec_change_state (GstElement * element,
> ++    GstStateChange transition);
> ++
> ++static void gst_ffmpegdec_set_property (GObject * object,
> ++    guint prop_id, const GValue * value, GParamSpec * pspec);
> ++static void gst_ffmpegdec_get_property (GObject * object,
> ++    guint prop_id, GValue * value, GParamSpec * pspec);
> ++
> ++static gboolean gst_ffmpegdec_negotiate (GstFFMpegDec * ffmpegdec,
> ++    gboolean force);
> ++
> ++/* some sort of bufferpool handling, but different */
> ++static int gst_ffmpegdec_get_buffer (AVCodecContext * context,
> ++    AVFrame * picture);
> ++static void gst_ffmpegdec_release_buffer (AVCodecContext * context,
> ++    AVFrame * picture);
> ++
> ++static void gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec);
> ++
> ++#define GST_FFDEC_PARAMS_QDATA g_quark_from_static_string("ffdec-params")
> ++
> ++static GstElementClass *parent_class = NULL;
> ++
> ++#define GST_FFMPEGDEC_TYPE_LOWRES (gst_ffmpegdec_lowres_get_type())
> ++static GType
> ++gst_ffmpegdec_lowres_get_type (void)
> ++{
> ++  static GType ffmpegdec_lowres_type = 0;
> ++
> ++  if (!ffmpegdec_lowres_type) {
> ++    static const GEnumValue ffmpegdec_lowres[] = {
> ++      {0, "0", "full"},
> ++      {1, "1", "1/2-size"},
> ++      {2, "2", "1/4-size"},
> ++      {0, NULL, NULL},
> ++    };
> ++
> ++    ffmpegdec_lowres_type =
> ++        g_enum_register_static ("GstFFMpegDecLowres", ffmpegdec_lowres);
> ++  }
> ++
> ++  return ffmpegdec_lowres_type;
> ++}
> ++
> ++#define GST_FFMPEGDEC_TYPE_SKIPFRAME (gst_ffmpegdec_skipframe_get_type())
> ++static GType
> ++gst_ffmpegdec_skipframe_get_type (void)
> ++{
> ++  static GType ffmpegdec_skipframe_type = 0;
> ++
> ++  if (!ffmpegdec_skipframe_type) {
> ++    static const GEnumValue ffmpegdec_skipframe[] = {
> ++      {0, "0", "Skip nothing"},
> ++      {1, "1", "Skip B-frames"},
> ++      {2, "2", "Skip IDCT/Dequantization"},
> ++      {5, "5", "Skip everything"},
> ++      {0, NULL, NULL},
> ++    };
> ++
> ++    ffmpegdec_skipframe_type =
> ++        g_enum_register_static ("GstFFMpegDecSkipFrame", ffmpegdec_skipframe);
> ++  }
> ++
> ++  return ffmpegdec_skipframe_type;
> ++}
> ++
> ++static void
> ++gst_ffmpegdec_base_init (GstFFMpegDecClass * klass)
> ++{
> ++  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
> ++  GstPadTemplate *sinktempl, *srctempl;
> ++  GstCaps *sinkcaps, *srccaps;
> ++  AVCodec *in_plugin;
> ++  gchar *longname, *classification, *description;
> ++
> ++  in_plugin =
> ++      (AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
> ++      GST_FFDEC_PARAMS_QDATA);
> ++  g_assert (in_plugin != NULL);
> ++
> ++  /* construct the element details struct */
> ++  longname = g_strdup_printf ("FFmpeg %s decoder", in_plugin->long_name);
> ++  classification = g_strdup_printf ("Codec/Decoder/%s",
> ++      (in_plugin->type == AVMEDIA_TYPE_VIDEO) ? "Video" : "Audio");
> ++  description = g_strdup_printf ("FFmpeg %s decoder", in_plugin->name);
> ++  gst_element_class_set_details_simple (element_class, longname, classification,
> ++      description,
> ++      "Wim Taymans <wim.taymans@gmail.com>, "
> ++      "Ronald Bultje <rbultje@ronald.bitfreak.net>, "
> ++      "Edward Hervey <bilboed@bilboed.com>");
> ++  g_free (longname);
> ++  g_free (classification);
> ++  g_free (description);
> ++
> ++  /* get the caps */
> ++  sinkcaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, FALSE);
> ++  if (!sinkcaps) {
> ++    GST_DEBUG ("Couldn't get sink caps for decoder '%s'", in_plugin->name);
> ++    sinkcaps = gst_caps_from_string ("unknown/unknown");
> ++  }
> ++  if (in_plugin->type == AVMEDIA_TYPE_VIDEO) {
> ++    srccaps = gst_caps_from_string ("video/x-raw-rgb; video/x-raw-yuv");
> ++  } else {
> ++    srccaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
> ++        in_plugin->id, FALSE, in_plugin);
> ++  }
> ++  if (!srccaps) {
> ++    GST_DEBUG ("Couldn't get source caps for decoder '%s'", in_plugin->name);
> ++    srccaps = gst_caps_from_string ("unknown/unknown");
> ++  }
> ++
> ++  /* pad templates */
> ++  sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
> ++      GST_PAD_ALWAYS, sinkcaps);
> ++  srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
> ++
> ++  gst_element_class_add_pad_template (element_class, srctempl);
> ++  gst_element_class_add_pad_template (element_class, sinktempl);
> ++
> ++  klass->in_plugin = in_plugin;
> ++  klass->srctempl = srctempl;
> ++  klass->sinktempl = sinktempl;
> ++}
> ++
> ++static void
> ++gst_ffmpegdec_class_init (GstFFMpegDecClass * klass)
> ++{
> ++  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
> ++  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
> ++
> ++  parent_class = g_type_class_peek_parent (klass);
> ++
> ++  gobject_class->finalize = gst_ffmpegdec_finalize;
> ++
> ++  gobject_class->set_property = gst_ffmpegdec_set_property;
> ++  gobject_class->get_property = gst_ffmpegdec_get_property;
> ++
> ++  if (klass->in_plugin->type == AVMEDIA_TYPE_VIDEO) {
> ++    int caps;
> ++
> ++    g_object_class_install_property (gobject_class, PROP_SKIPFRAME,
> ++        g_param_spec_enum ("skip-frame", "Skip frames",
> ++            "Which types of frames to skip during decoding",
> ++            GST_FFMPEGDEC_TYPE_SKIPFRAME, 0,
> ++            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> ++    g_object_class_install_property (gobject_class, PROP_LOWRES,
> ++        g_param_spec_enum ("lowres", "Low resolution",
> ++            "At which resolution to decode images", GST_FFMPEGDEC_TYPE_LOWRES,
> ++            0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> ++    g_object_class_install_property (gobject_class, PROP_DIRECT_RENDERING,
> ++        g_param_spec_boolean ("direct-rendering", "Direct Rendering",
> ++            "Enable direct rendering", DEFAULT_DIRECT_RENDERING,
> ++            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> ++    g_object_class_install_property (gobject_class, PROP_DO_PADDING,
> ++        g_param_spec_boolean ("do-padding", "Do Padding",
> ++            "Add 0 padding before decoding data", DEFAULT_DO_PADDING,
> ++            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> ++    g_object_class_install_property (gobject_class, PROP_DEBUG_MV,
> ++        g_param_spec_boolean ("debug-mv", "Debug motion vectors",
> ++            "Whether ffmpeg should print motion vectors on top of the image",
> ++            DEFAULT_DEBUG_MV, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> ++#if 0
> ++    g_object_class_install_property (gobject_class, PROP_CROP,
> ++        g_param_spec_boolean ("crop", "Crop",
> ++            "Crop images to the display region",
> ++            DEFAULT_CROP, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> ++#endif
> ++
> ++    caps = klass->in_plugin->capabilities;
> ++    if (caps & (CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS)) {
> ++      g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_THREADS,
> ++          g_param_spec_int ("max-threads", "Maximum decode threads",
> ++              "Maximum number of worker threads to spawn. (0 = auto)",
> ++              0, G_MAXINT, DEFAULT_MAX_THREADS,
> ++              G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> ++    }
> ++  }
> ++
> ++  gstelement_class->change_state = gst_ffmpegdec_change_state;
> ++}
> ++
> ++static void
> ++gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec)
> ++{
> ++  GstFFMpegDecClass *oclass;
> ++
> ++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> ++
> ++  /* setup pads */
> ++  ffmpegdec->sinkpad = gst_pad_new_from_template (oclass->sinktempl, "sink");
> ++  gst_pad_set_setcaps_function (ffmpegdec->sinkpad,
> ++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_setcaps));
> ++  gst_pad_set_event_function (ffmpegdec->sinkpad,
> ++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_sink_event));
> ++  gst_pad_set_chain_function (ffmpegdec->sinkpad,
> ++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_chain));
> ++  gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->sinkpad);
> ++
> ++  ffmpegdec->srcpad = gst_pad_new_from_template (oclass->srctempl, "src");
> ++  gst_pad_use_fixed_caps (ffmpegdec->srcpad);
> ++  gst_pad_set_event_function (ffmpegdec->srcpad,
> ++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_src_event));
> ++  gst_pad_set_query_function (ffmpegdec->srcpad,
> ++      GST_DEBUG_FUNCPTR (gst_ffmpegdec_query));
> ++  gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->srcpad);
> ++
> ++  /* some ffmpeg data */
> ++  ffmpegdec->context = avcodec_alloc_context ();
> ++  ffmpegdec->picture = avcodec_alloc_frame ();
> ++  ffmpegdec->pctx = NULL;
> ++  ffmpegdec->pcache = NULL;
> ++  ffmpegdec->par = NULL;
> ++  ffmpegdec->opened = FALSE;
> ++  ffmpegdec->skip_frame = ffmpegdec->lowres = 0;
> ++  ffmpegdec->direct_rendering = DEFAULT_DIRECT_RENDERING;
> ++  ffmpegdec->do_padding = DEFAULT_DO_PADDING;
> ++  ffmpegdec->debug_mv = DEFAULT_DEBUG_MV;
> ++  ffmpegdec->crop = DEFAULT_CROP;
> ++  ffmpegdec->max_threads = DEFAULT_MAX_THREADS;
> ++
> ++  ffmpegdec->format.video.par_n = -1;
> ++  ffmpegdec->format.video.fps_n = -1;
> ++  ffmpegdec->format.video.old_fps_n = -1;
> ++  gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
> ++
> ++  /* We initially assume downstream can allocate 16 bytes aligned buffers */
> ++  ffmpegdec->can_allocate_aligned = TRUE;
> ++}
> ++
> ++static void
> ++gst_ffmpegdec_finalize (GObject * object)
> ++{
> ++  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
> ++
> ++  if (ffmpegdec->context != NULL) {
> ++    av_free (ffmpegdec->context);
> ++    ffmpegdec->context = NULL;
> ++  }
> ++
> ++  if (ffmpegdec->picture != NULL) {
> ++    av_free (ffmpegdec->picture);
> ++    ffmpegdec->picture = NULL;
> ++  }
> ++
> ++  G_OBJECT_CLASS (parent_class)->finalize (object);
> ++}
> ++
> ++static gboolean
> ++gst_ffmpegdec_query (GstPad * pad, GstQuery * query)
> ++{
> ++  GstFFMpegDec *ffmpegdec;
> ++  GstPad *peer;
> ++  gboolean res;
> ++
> ++  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
> ++
> ++  res = FALSE;
> ++
> ++  if ((peer = gst_pad_get_peer (ffmpegdec->sinkpad))) {
> ++    /* just forward to peer */
> ++    res = gst_pad_query (peer, query);
> ++    gst_object_unref (peer);
> ++  }
> ++#if 0
> ++  {
> ++    GstFormat bfmt;
> ++
> ++    bfmt = GST_FORMAT_BYTES;
> ++
> ++    /* ok, do bitrate calc... */
> ++    if ((type != GST_QUERY_POSITION && type != GST_QUERY_TOTAL) ||
> ++        *fmt != GST_FORMAT_TIME || ffmpegdec->context->bit_rate == 0 ||
> ++        !gst_pad_query (peer, type, &bfmt, value))
> ++      return FALSE;
> ++
> ++    if (ffmpegdec->pcache && type == GST_QUERY_POSITION)
> ++      *value -= GST_BUFFER_SIZE (ffmpegdec->pcache);
> ++    *value *= GST_SECOND / ffmpegdec->context->bit_rate;
> ++  }
> ++#endif
> ++
> ++  gst_object_unref (ffmpegdec);
> ++
> ++  return res;
> ++}
> ++
> ++static void
> ++gst_ffmpegdec_reset_ts (GstFFMpegDec * ffmpegdec)
> ++{
> ++  ffmpegdec->last_in = GST_CLOCK_TIME_NONE;
> ++  ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
> ++  ffmpegdec->last_frames = 0;
> ++  ffmpegdec->last_out = GST_CLOCK_TIME_NONE;
> ++  ffmpegdec->next_out = GST_CLOCK_TIME_NONE;
> ++  ffmpegdec->reordered_in = FALSE;
> ++  ffmpegdec->reordered_out = FALSE;
> ++}
> ++
> ++static void
> ++gst_ffmpegdec_update_qos (GstFFMpegDec * ffmpegdec, gdouble proportion,
> ++    GstClockTime timestamp)
> ++{
> ++  GST_LOG_OBJECT (ffmpegdec, "update QOS: %f, %" GST_TIME_FORMAT,
> ++      proportion, GST_TIME_ARGS (timestamp));
> ++
> ++  GST_OBJECT_LOCK (ffmpegdec);
> ++  ffmpegdec->proportion = proportion;
> ++  ffmpegdec->earliest_time = timestamp;
> ++  GST_OBJECT_UNLOCK (ffmpegdec);
> ++}
> ++
> ++static void
> ++gst_ffmpegdec_reset_qos (GstFFMpegDec * ffmpegdec)
> ++{
> ++  gst_ffmpegdec_update_qos (ffmpegdec, 0.5, GST_CLOCK_TIME_NONE);
> ++  ffmpegdec->processed = 0;
> ++  ffmpegdec->dropped = 0;
> ++}
> ++
> ++static void
> ++gst_ffmpegdec_read_qos (GstFFMpegDec * ffmpegdec, gdouble * proportion,
> ++    GstClockTime * timestamp)
> ++{
> ++  GST_OBJECT_LOCK (ffmpegdec);
> ++  *proportion = ffmpegdec->proportion;
> ++  *timestamp = ffmpegdec->earliest_time;
> ++  GST_OBJECT_UNLOCK (ffmpegdec);
> ++}
> ++
> ++static gboolean
> ++gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event)
> ++{
> ++  GstFFMpegDec *ffmpegdec;
> ++  gboolean res;
> ++
> ++  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
> ++
> ++  switch (GST_EVENT_TYPE (event)) {
> ++    case GST_EVENT_QOS:
> ++    {
> ++      gdouble proportion;
> ++      GstClockTimeDiff diff;
> ++      GstClockTime timestamp;
> ++
> ++      gst_event_parse_qos (event, &proportion, &diff, &timestamp);
> ++
> ++      /* update our QoS values */
> ++      gst_ffmpegdec_update_qos (ffmpegdec, proportion, timestamp + diff);
> ++
> ++      /* forward upstream */
> ++      res = gst_pad_push_event (ffmpegdec->sinkpad, event);
> ++      break;
> ++    }
> ++    default:
> ++      /* forward upstream */
> ++      res = gst_pad_push_event (ffmpegdec->sinkpad, event);
> ++      break;
> ++  }
> ++
> ++  gst_object_unref (ffmpegdec);
> ++
> ++  return res;
> ++}
> ++
> ++/* with LOCK */
> ++static void
> ++gst_ffmpegdec_close (GstFFMpegDec * ffmpegdec)
> ++{
> ++  if (!ffmpegdec->opened)
> ++    return;
> ++
> ++  GST_LOG_OBJECT (ffmpegdec, "closing ffmpeg codec");
> ++
> ++  if (ffmpegdec->par) {
> ++    g_free (ffmpegdec->par);
> ++    ffmpegdec->par = NULL;
> ++  }
> ++
> ++  if (ffmpegdec->context->priv_data)
> ++    gst_ffmpeg_avcodec_close (ffmpegdec->context);
> ++  ffmpegdec->opened = FALSE;
> ++
> ++  if (ffmpegdec->context->extradata) {
> ++    av_free (ffmpegdec->context->extradata);
> ++    ffmpegdec->context->extradata = NULL;
> ++  }
> ++
> ++  if (ffmpegdec->pctx) {
> ++    if (ffmpegdec->pcache) {
> ++      gst_buffer_unref (ffmpegdec->pcache);
> ++      ffmpegdec->pcache = NULL;
> ++    }
> ++    av_parser_close (ffmpegdec->pctx);
> ++    ffmpegdec->pctx = NULL;
> ++  }
> ++
> ++  ffmpegdec->format.video.par_n = -1;
> ++  ffmpegdec->format.video.fps_n = -1;
> ++  ffmpegdec->format.video.old_fps_n = -1;
> ++  ffmpegdec->format.video.interlaced = FALSE;
> ++}
> ++
> ++/* with LOCK */
> ++static gboolean
> ++gst_ffmpegdec_open (GstFFMpegDec * ffmpegdec)
> ++{
> ++  GstFFMpegDecClass *oclass;
> ++
> ++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> ++
> ++  if (gst_ffmpeg_avcodec_open (ffmpegdec->context, oclass->in_plugin) < 0)
> ++    goto could_not_open;
> ++
> ++  ffmpegdec->opened = TRUE;
> ++  ffmpegdec->is_realvideo = FALSE;
> ++
> ++  GST_LOG_OBJECT (ffmpegdec, "Opened ffmpeg codec %s, id %d",
> ++      oclass->in_plugin->name, oclass->in_plugin->id);
> ++
> ++  /* open a parser if we can */
> ++  switch (oclass->in_plugin->id) {
> ++    case CODEC_ID_MPEG4:
> ++    case CODEC_ID_MJPEG:
> ++    case CODEC_ID_VC1:
> ++      GST_LOG_OBJECT (ffmpegdec, "not using parser, blacklisted codec");
> ++      ffmpegdec->pctx = NULL;
> ++      break;
> ++    case CODEC_ID_H264:
> ++      /* For H264, only use a parser if there is no context data, if there is,
> ++       * we're talking AVC */
> ++      if (ffmpegdec->context->extradata_size == 0) {
> ++        GST_LOG_OBJECT (ffmpegdec, "H264 with no extradata, creating parser");
> ++        ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
> ++      } else {
> ++        GST_LOG_OBJECT (ffmpegdec,
> ++            "H264 with extradata implies framed data - not using parser");
> ++        ffmpegdec->pctx = NULL;
> ++      }
> ++      break;
> ++    case CODEC_ID_RV10:
> ++    case CODEC_ID_RV30:
> ++    case CODEC_ID_RV20:
> ++    case CODEC_ID_RV40:
> ++      ffmpegdec->is_realvideo = TRUE;
> ++      break;
> ++    default:
> ++      if (!ffmpegdec->turnoff_parser) {
> ++        ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
> ++        if (ffmpegdec->pctx)
> ++          GST_LOG_OBJECT (ffmpegdec, "Using parser %p", ffmpegdec->pctx);
> ++        else
> ++          GST_LOG_OBJECT (ffmpegdec, "No parser for codec");
> ++      } else {
> ++        GST_LOG_OBJECT (ffmpegdec, "Parser deactivated for format");
> ++      }
> ++      break;
> ++  }
> ++
> ++  switch (oclass->in_plugin->type) {
> ++    case AVMEDIA_TYPE_VIDEO:
> ++      ffmpegdec->format.video.width = 0;
> ++      ffmpegdec->format.video.height = 0;
> ++      ffmpegdec->format.video.clip_width = -1;
> ++      ffmpegdec->format.video.clip_height = -1;
> ++      ffmpegdec->format.video.pix_fmt = PIX_FMT_NB;
> ++      ffmpegdec->format.video.interlaced = FALSE;
> ++      break;
> ++    case AVMEDIA_TYPE_AUDIO:
> ++      ffmpegdec->format.audio.samplerate = 0;
> ++      ffmpegdec->format.audio.channels = 0;
> ++      ffmpegdec->format.audio.depth = 0;
> ++      break;
> ++    default:
> ++      break;
> ++  }
> ++
> ++  gst_ffmpegdec_reset_ts (ffmpegdec);
> ++  /* FIXME, reset_qos holds the LOCK */
> ++  ffmpegdec->proportion = 0.0;
> ++  ffmpegdec->earliest_time = -1;
> ++
> ++  return TRUE;
> ++
> ++  /* ERRORS */
> ++could_not_open:
> ++  {
> ++    gst_ffmpegdec_close (ffmpegdec);
> ++    GST_DEBUG_OBJECT (ffmpegdec, "ffdec_%s: Failed to open FFMPEG codec",
> ++        oclass->in_plugin->name);
> ++    return FALSE;
> ++  }
> ++}
> ++
> ++static gboolean
> ++gst_ffmpegdec_setcaps (GstPad * pad, GstCaps * caps)
> ++{
> ++  GstFFMpegDec *ffmpegdec;
> ++  GstFFMpegDecClass *oclass;
> ++  GstStructure *structure;
> ++  const GValue *par;
> ++  const GValue *fps;
> ++  gboolean ret = TRUE;
> ++
> ++  ffmpegdec = (GstFFMpegDec *) (gst_pad_get_parent (pad));
> ++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> ++
> ++  GST_DEBUG_OBJECT (pad, "setcaps called");
> ++
> ++  GST_OBJECT_LOCK (ffmpegdec);
> ++
> ++  /* stupid check for VC1 */
> ++  if ((oclass->in_plugin->id == CODEC_ID_WMV3) ||
> ++      (oclass->in_plugin->id == CODEC_ID_VC1))
> ++    oclass->in_plugin->id = gst_ffmpeg_caps_to_codecid (caps, NULL);
> ++
> ++  /* close old session */
> ++  if (ffmpegdec->opened) {
> ++    GST_OBJECT_UNLOCK (ffmpegdec);
> ++    gst_ffmpegdec_drain (ffmpegdec);
> ++    GST_OBJECT_LOCK (ffmpegdec);
> ++    gst_ffmpegdec_close (ffmpegdec);
> ++
> ++    /* and reset the defaults that were set when a context is created */
> ++    avcodec_get_context_defaults (ffmpegdec->context);
> ++  }
> ++
> ++  /* set buffer functions */
> ++  ffmpegdec->context->get_buffer = gst_ffmpegdec_get_buffer;
> ++  ffmpegdec->context->release_buffer = gst_ffmpegdec_release_buffer;
> ++  ffmpegdec->context->draw_horiz_band = NULL;
> ++
> ++  /* default is to let format decide if it needs a parser */
> ++  ffmpegdec->turnoff_parser = FALSE;
> ++
> ++  ffmpegdec->has_b_frames = FALSE;
> ++
> ++  GST_LOG_OBJECT (ffmpegdec, "size %dx%d", ffmpegdec->context->width,
> ++      ffmpegdec->context->height);
> ++
> ++  /* get size and so */
> ++  gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
> ++      oclass->in_plugin->type, caps, ffmpegdec->context);
> ++
> ++  GST_LOG_OBJECT (ffmpegdec, "size after %dx%d", ffmpegdec->context->width,
> ++      ffmpegdec->context->height);
> ++
> ++  if (!ffmpegdec->context->time_base.den || !ffmpegdec->context->time_base.num) {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "forcing 25/1 framerate");
> ++    ffmpegdec->context->time_base.num = 1;
> ++    ffmpegdec->context->time_base.den = 25;
> ++  }
> ++
> ++  /* get pixel aspect ratio if it's set */
> ++  structure = gst_caps_get_structure (caps, 0);
> ++
> ++  par = gst_structure_get_value (structure, "pixel-aspect-ratio");
> ++  if (par) {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "sink caps have pixel-aspect-ratio of %d:%d",
> ++        gst_value_get_fraction_numerator (par),
> ++        gst_value_get_fraction_denominator (par));
> ++    /* should be NULL */
> ++    if (ffmpegdec->par)
> ++      g_free (ffmpegdec->par);
> ++    ffmpegdec->par = g_new0 (GValue, 1);
> ++    gst_value_init_and_copy (ffmpegdec->par, par);
> ++  }
> ++
> ++  /* get the framerate from incoming caps. fps_n is set to -1 when
> ++   * there is no valid framerate */
> ++  fps = gst_structure_get_value (structure, "framerate");
> ++  if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
> ++    ffmpegdec->format.video.fps_n = gst_value_get_fraction_numerator (fps);
> ++    ffmpegdec->format.video.fps_d = gst_value_get_fraction_denominator (fps);
> ++    GST_DEBUG_OBJECT (ffmpegdec, "Using framerate %d/%d from incoming caps",
> ++        ffmpegdec->format.video.fps_n, ffmpegdec->format.video.fps_d);
> ++  } else {
> ++    ffmpegdec->format.video.fps_n = -1;
> ++    GST_DEBUG_OBJECT (ffmpegdec, "Using framerate from codec");
> ++  }
> ++
> ++  /* figure out if we can use direct rendering */
> ++  ffmpegdec->current_dr = FALSE;
> ++  ffmpegdec->extra_ref = FALSE;
> ++  if (ffmpegdec->direct_rendering) {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "trying to enable direct rendering");
> ++    if (oclass->in_plugin->capabilities & CODEC_CAP_DR1) {
> ++      if (oclass->in_plugin->id == CODEC_ID_H264) {
> ++        GST_DEBUG_OBJECT (ffmpegdec, "disable direct rendering setup for H264");
> ++        /* does not work, many stuff reads outside of the planes */
> ++        ffmpegdec->current_dr = FALSE;
> ++        ffmpegdec->extra_ref = TRUE;
> ++      } else if ((oclass->in_plugin->id == CODEC_ID_SVQ1) ||
> ++          (oclass->in_plugin->id == CODEC_ID_VP5) ||
> ++          (oclass->in_plugin->id == CODEC_ID_VP6) ||
> ++          (oclass->in_plugin->id == CODEC_ID_VP6F) ||
> ++          (oclass->in_plugin->id == CODEC_ID_VP6A)) {
> ++        GST_DEBUG_OBJECT (ffmpegdec,
> ++            "disable direct rendering setup for broken stride support");
> ++        /* does not work, uses a incompatible stride. See #610613 */
> ++        ffmpegdec->current_dr = FALSE;
> ++        ffmpegdec->extra_ref = TRUE;
> ++      } else {
> ++        GST_DEBUG_OBJECT (ffmpegdec, "enabled direct rendering");
> ++        ffmpegdec->current_dr = TRUE;
> ++      }
> ++    } else {
> ++      GST_DEBUG_OBJECT (ffmpegdec, "direct rendering not supported");
> ++    }
> ++  }
> ++  if (ffmpegdec->current_dr) {
> ++    /* do *not* draw edges when in direct rendering, for some reason it draws
> ++     * outside of the memory. */
> ++    ffmpegdec->context->flags |= CODEC_FLAG_EMU_EDGE;
> ++  }
> ++
> ++  /* for AAC we only use av_parse if not on stream-format==raw or ==loas */
> ++  if (oclass->in_plugin->id == CODEC_ID_AAC
> ++      || oclass->in_plugin->id == CODEC_ID_AAC_LATM) {
> ++    const gchar *format = gst_structure_get_string (structure, "stream-format");
> ++
> ++    if (format == NULL || strcmp (format, "raw") == 0) {
> ++      ffmpegdec->turnoff_parser = TRUE;
> ++    }
> ++  }
> ++
> ++  /* for FLAC, don't parse if it's already parsed */
> ++  if (oclass->in_plugin->id == CODEC_ID_FLAC) {
> ++    if (gst_structure_has_field (structure, "streamheader"))
> ++      ffmpegdec->turnoff_parser = TRUE;
> ++  }
> ++
> ++  /* workaround encoder bugs */
> ++  ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
> ++  ffmpegdec->context->err_recognition = 1;
> ++
> ++  /* for slow cpus */
> ++  ffmpegdec->context->lowres = ffmpegdec->lowres;
> ++  ffmpegdec->context->skip_frame = ffmpegdec->skip_frame;
> ++
> ++  /* ffmpeg can draw motion vectors on top of the image (not every decoder
> ++   * supports it) */
> ++  ffmpegdec->context->debug_mv = ffmpegdec->debug_mv;
> ++
> ++  if (ffmpegdec->max_threads == 0)
> ++    ffmpegdec->context->thread_count = gst_ffmpeg_auto_max_threads ();
> ++  else
> ++    ffmpegdec->context->thread_count = ffmpegdec->max_threads;
> ++
> ++  /* open codec - we don't select an output pix_fmt yet,
> ++   * simply because we don't know! We only get it
> ++   * during playback... */
> ++  if (!gst_ffmpegdec_open (ffmpegdec))
> ++    goto open_failed;
> ++
> ++  /* clipping region */
> ++  gst_structure_get_int (structure, "width",
> ++      &ffmpegdec->format.video.clip_width);
> ++  gst_structure_get_int (structure, "height",
> ++      &ffmpegdec->format.video.clip_height);
> ++
> ++  GST_DEBUG_OBJECT (pad, "clipping to %dx%d",
> ++      ffmpegdec->format.video.clip_width, ffmpegdec->format.video.clip_height);
> ++
> ++  /* take into account the lowres property */
> ++  if (ffmpegdec->format.video.clip_width != -1)
> ++    ffmpegdec->format.video.clip_width >>= ffmpegdec->lowres;
> ++  if (ffmpegdec->format.video.clip_height != -1)
> ++    ffmpegdec->format.video.clip_height >>= ffmpegdec->lowres;
> ++
> ++  GST_DEBUG_OBJECT (pad, "final clipping to %dx%d",
> ++      ffmpegdec->format.video.clip_width, ffmpegdec->format.video.clip_height);
> ++
> ++done:
> ++  GST_OBJECT_UNLOCK (ffmpegdec);
> ++
> ++  gst_object_unref (ffmpegdec);
> ++
> ++  return ret;
> ++
> ++  /* ERRORS */
> ++open_failed:
> ++  {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "Failed to open");
> ++    if (ffmpegdec->par) {
> ++      g_free (ffmpegdec->par);
> ++      ffmpegdec->par = NULL;
> ++    }
> ++    ret = FALSE;
> ++    goto done;
> ++  }
> ++}
> ++
> ++static GstFlowReturn
> ++alloc_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf,
> ++    gint width, gint height)
> ++{
> ++  GstFlowReturn ret;
> ++  gint fsize;
> ++
> ++  ret = GST_FLOW_ERROR;
> ++  *outbuf = NULL;
> ++
> ++  GST_LOG_OBJECT (ffmpegdec, "alloc output buffer");
> ++
> ++  /* see if we need renegotiation */
> ++  if (G_UNLIKELY (!gst_ffmpegdec_negotiate (ffmpegdec, FALSE)))
> ++    goto negotiate_failed;
> ++
> ++  /* get the size of the gstreamer output buffer given a
> ++   * width/height/format */
> ++  fsize = gst_ffmpeg_avpicture_get_size (ffmpegdec->context->pix_fmt,
> ++      width, height);
> ++
> ++  if (ffmpegdec->can_allocate_aligned) {
> ++    GST_LOG_OBJECT (ffmpegdec, "calling pad_alloc");
> ++    /* no pallete, we can use the buffer size to alloc */
> ++    ret = gst_pad_alloc_buffer_and_set_caps (ffmpegdec->srcpad,
> ++        GST_BUFFER_OFFSET_NONE, fsize,
> ++        GST_PAD_CAPS (ffmpegdec->srcpad), outbuf);
> ++    if (G_UNLIKELY (ret != GST_FLOW_OK))
> ++      goto alloc_failed;
> ++
> ++    /* If buffer isn't 128-bit aligned, create a memaligned one ourselves */
> ++    if (((uintptr_t) GST_BUFFER_DATA (*outbuf)) % 16) {
> ++      GST_DEBUG_OBJECT (ffmpegdec,
> ++          "Downstream can't allocate aligned buffers.");
> ++      ffmpegdec->can_allocate_aligned = FALSE;
> ++      gst_buffer_unref (*outbuf);
> ++      *outbuf = new_aligned_buffer (fsize, GST_PAD_CAPS (ffmpegdec->srcpad));
> ++    }
> ++  } else {
> ++    GST_LOG_OBJECT (ffmpegdec,
> ++        "not calling pad_alloc, we have a pallete or downstream can't give 16 byte aligned buffers.");
> ++    /* for paletted data we can't use pad_alloc_buffer(), because
> ++     * fsize contains the size of the palette, so the overall size
> ++     * is bigger than ffmpegcolorspace's unit size, which will
> ++     * prompt GstBaseTransform to complain endlessly ... */
> ++    *outbuf = new_aligned_buffer (fsize, GST_PAD_CAPS (ffmpegdec->srcpad));
> ++    ret = GST_FLOW_OK;
> ++  }
> ++  /* set caps, we do this here because the buffer is still writable here and we
> ++   * are sure to be negotiated */
> ++  gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (ffmpegdec->srcpad));
> ++
> ++  return ret;
> ++
> ++  /* special cases */
> ++negotiate_failed:
> ++  {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "negotiate failed");
> ++    return GST_FLOW_NOT_NEGOTIATED;
> ++  }
> ++alloc_failed:
> ++  {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "pad_alloc failed %d (%s)", ret,
> ++        gst_flow_get_name (ret));
> ++    return ret;
> ++  }
> ++}
> ++
> ++static int
> ++gst_ffmpegdec_get_buffer (AVCodecContext * context, AVFrame * picture)
> ++{
> ++  GstBuffer *buf = NULL;
> ++  GstFFMpegDec *ffmpegdec;
> ++  gint width, height;
> ++  gint coded_width, coded_height;
> ++  gint res;
> ++
> ++  ffmpegdec = (GstFFMpegDec *) context->opaque;
> ++
> ++  GST_DEBUG_OBJECT (ffmpegdec, "getting buffer");
> ++
> ++  /* apply the last info we have seen to this picture, when we get the
> ++   * picture back from ffmpeg we can use this to correctly timestamp the output
> ++   * buffer */
> ++  picture->reordered_opaque = context->reordered_opaque;
> ++  /* make sure we don't free the buffer when it's not ours */
> ++  picture->opaque = NULL;
> ++
> ++  /* take width and height before clipping */
> ++  width = context->width;
> ++  height = context->height;
> ++  coded_width = context->coded_width;
> ++  coded_height = context->coded_height;
> ++
> ++  GST_LOG_OBJECT (ffmpegdec, "dimension %dx%d, coded %dx%d", width, height,
> ++      coded_width, coded_height);
> ++  if (!ffmpegdec->current_dr) {
> ++    GST_LOG_OBJECT (ffmpegdec, "direct rendering disabled, fallback alloc");
> ++    res = avcodec_default_get_buffer (context, picture);
> ++
> ++    GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", picture->linesize[0],
> ++        picture->linesize[1], picture->linesize[2]);
> ++    GST_LOG_OBJECT (ffmpegdec, "data %u %u %u", 0,
> ++        (guint) (picture->data[1] - picture->data[0]),
> ++        (guint) (picture->data[2] - picture->data[0]));
> ++    return res;
> ++  }
> ++
> ++  switch (context->codec_type) {
> ++    case AVMEDIA_TYPE_VIDEO:
> ++      /* some ffmpeg video plugins don't see the point in setting codec_type ... */
> ++    case AVMEDIA_TYPE_UNKNOWN:
> ++    {
> ++      GstFlowReturn ret;
> ++      gint clip_width, clip_height;
> ++
> ++      /* take final clipped output size */
> ++      if ((clip_width = ffmpegdec->format.video.clip_width) == -1)
> ++        clip_width = width;
> ++      if ((clip_height = ffmpegdec->format.video.clip_height) == -1)
> ++        clip_height = height;
> ++
> ++      GST_LOG_OBJECT (ffmpegdec, "raw outsize %d/%d", width, height);
> ++
> ++      /* this is the size ffmpeg needs for the buffer */
> ++      avcodec_align_dimensions (context, &width, &height);
> ++
> ++      GST_LOG_OBJECT (ffmpegdec, "aligned outsize %d/%d, clip %d/%d",
> ++          width, height, clip_width, clip_height);
> ++
> ++      if (width != clip_width || height != clip_height) {
> ++        /* We can't alloc if we need to clip the output buffer later */
> ++        GST_LOG_OBJECT (ffmpegdec, "we need clipping, fallback alloc");
> ++        return avcodec_default_get_buffer (context, picture);
> ++      }
> ++
> ++      /* alloc with aligned dimensions for ffmpeg */
> ++      ret = alloc_output_buffer (ffmpegdec, &buf, width, height);
> ++      if (G_UNLIKELY (ret != GST_FLOW_OK)) {
> ++        /* alloc default buffer when we can't get one from downstream */
> ++        GST_LOG_OBJECT (ffmpegdec, "alloc failed, fallback alloc");
> ++        return avcodec_default_get_buffer (context, picture);
> ++      }
> ++
> ++      /* copy the right pointers and strides in the picture object */
> ++      gst_ffmpeg_avpicture_fill ((AVPicture *) picture,
> ++          GST_BUFFER_DATA (buf), context->pix_fmt, width, height);
> ++      break;
> ++    }
> ++    case AVMEDIA_TYPE_AUDIO:
> ++    default:
> ++      GST_ERROR_OBJECT (ffmpegdec,
> ++          "_get_buffer() should never get called for non-video buffers !");
> ++      g_assert_not_reached ();
> ++      break;
> ++  }
> ++
> ++  /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to
> ++   * the opaque data. */
> ++  picture->type = FF_BUFFER_TYPE_USER;
> ++  picture->opaque = buf;
> ++
> ++#ifdef EXTRA_REF
> ++  if (picture->reference != 0 || ffmpegdec->extra_ref) {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "adding extra ref");
> ++    gst_buffer_ref (buf);
> ++  }
> ++#endif
> ++
> ++  GST_LOG_OBJECT (ffmpegdec, "returned buffer %p", buf);
> ++
> ++  return 0;
> ++}
> ++
> ++static void
> ++gst_ffmpegdec_release_buffer (AVCodecContext * context, AVFrame * picture)
> ++{
> ++  gint i;
> ++  GstBuffer *buf;
> ++  GstFFMpegDec *ffmpegdec;
> ++
> ++  ffmpegdec = (GstFFMpegDec *) context->opaque;
> ++
> ++  /* check if it was our buffer */
> ++  if (picture->opaque == NULL) {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "default release buffer");
> ++    avcodec_default_release_buffer (context, picture);
> ++    return;
> ++  }
> ++
> ++  /* we remove the opaque data now */
> ++  buf = GST_BUFFER_CAST (picture->opaque);
> ++  GST_DEBUG_OBJECT (ffmpegdec, "release buffer %p", buf);
> ++  picture->opaque = NULL;
> ++
> ++#ifdef EXTRA_REF
> ++  if (picture->reference != 0 || ffmpegdec->extra_ref) {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "remove extra ref");
> ++    gst_buffer_unref (buf);
> ++  }
> ++#else
> ++  gst_buffer_unref (buf);
> ++#endif
> ++
> ++  /* zero out the reference in ffmpeg */
> ++  for (i = 0; i < 4; i++) {
> ++    picture->data[i] = NULL;
> ++    picture->linesize[i] = 0;
> ++  }
> ++}
> ++
> ++static void
> ++gst_ffmpegdec_add_pixel_aspect_ratio (GstFFMpegDec * ffmpegdec,
> ++    GstStructure * s)
> ++{
> ++  gboolean demuxer_par_set = FALSE;
> ++  gboolean decoder_par_set = FALSE;
> ++  gint demuxer_num = 1, demuxer_denom = 1;
> ++  gint decoder_num = 1, decoder_denom = 1;
> ++
> ++  GST_OBJECT_LOCK (ffmpegdec);
> ++
> ++  if (ffmpegdec->par) {
> ++    demuxer_num = gst_value_get_fraction_numerator (ffmpegdec->par);
> ++    demuxer_denom = gst_value_get_fraction_denominator (ffmpegdec->par);
> ++    demuxer_par_set = TRUE;
> ++    GST_DEBUG_OBJECT (ffmpegdec, "Demuxer PAR: %d:%d", demuxer_num,
> ++        demuxer_denom);
> ++  }
> ++
> ++  if (ffmpegdec->context->sample_aspect_ratio.num &&
> ++      ffmpegdec->context->sample_aspect_ratio.den) {
> ++    decoder_num = ffmpegdec->context->sample_aspect_ratio.num;
> ++    decoder_denom = ffmpegdec->context->sample_aspect_ratio.den;
> ++    decoder_par_set = TRUE;
> ++    GST_DEBUG_OBJECT (ffmpegdec, "Decoder PAR: %d:%d", decoder_num,
> ++        decoder_denom);
> ++  }
> ++
> ++  GST_OBJECT_UNLOCK (ffmpegdec);
> ++
> ++  if (!demuxer_par_set && !decoder_par_set)
> ++    goto no_par;
> ++
> ++  if (demuxer_par_set && !decoder_par_set)
> ++    goto use_demuxer_par;
> ++
> ++  if (decoder_par_set && !demuxer_par_set)
> ++    goto use_decoder_par;
> ++
> ++  /* Both the demuxer and the decoder provide a PAR. If one of
> ++   * the two PARs is 1:1 and the other one is not, use the one
> ++   * that is not 1:1. */
> ++  if (demuxer_num == demuxer_denom && decoder_num != decoder_denom)
> ++    goto use_decoder_par;
> ++
> ++  if (decoder_num == decoder_denom && demuxer_num != demuxer_denom)
> ++    goto use_demuxer_par;
> ++
> ++  /* Both PARs are non-1:1, so use the PAR provided by the demuxer */
> ++  goto use_demuxer_par;
> ++
> ++use_decoder_par:
> ++  {
> ++    GST_DEBUG_OBJECT (ffmpegdec,
> ++        "Setting decoder provided pixel-aspect-ratio of %u:%u", decoder_num,
> ++        decoder_denom);
> ++    gst_structure_set (s, "pixel-aspect-ratio", GST_TYPE_FRACTION, decoder_num,
> ++        decoder_denom, NULL);
> ++    return;
> ++  }
> ++
> ++use_demuxer_par:
> ++  {
> ++    GST_DEBUG_OBJECT (ffmpegdec,
> ++        "Setting demuxer provided pixel-aspect-ratio of %u:%u", demuxer_num,
> ++        demuxer_denom);
> ++    gst_structure_set (s, "pixel-aspect-ratio", GST_TYPE_FRACTION, demuxer_num,
> ++        demuxer_denom, NULL);
> ++    return;
> ++  }
> ++no_par:
> ++  {
> ++    GST_DEBUG_OBJECT (ffmpegdec,
> ++        "Neither demuxer nor codec provide a pixel-aspect-ratio");
> ++    return;
> ++  }
> ++}
> ++
> ++static gboolean
> ++gst_ffmpegdec_negotiate (GstFFMpegDec * ffmpegdec, gboolean force)
> ++{
> ++  GstFFMpegDecClass *oclass;
> ++  GstCaps *caps;
> ++
> ++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> ++
> ++  switch (oclass->in_plugin->type) {
> ++    case AVMEDIA_TYPE_VIDEO:
> ++      if (!force && ffmpegdec->format.video.width == ffmpegdec->context->width
> ++          && ffmpegdec->format.video.height == ffmpegdec->context->height
> ++          && ffmpegdec->format.video.fps_n == ffmpegdec->format.video.old_fps_n
> ++          && ffmpegdec->format.video.fps_d == ffmpegdec->format.video.old_fps_d
> ++          && ffmpegdec->format.video.pix_fmt == ffmpegdec->context->pix_fmt
> ++          && ffmpegdec->format.video.par_n ==
> ++          ffmpegdec->context->sample_aspect_ratio.num
> ++          && ffmpegdec->format.video.par_d ==
> ++          ffmpegdec->context->sample_aspect_ratio.den)
> ++        return TRUE;
> ++      GST_DEBUG_OBJECT (ffmpegdec,
> ++          "Renegotiating video from %dx%d@ %d:%d PAR %d/%d fps to %dx%d@ %d:%d PAR %d/%d fps",
> ++          ffmpegdec->format.video.width, ffmpegdec->format.video.height,
> ++          ffmpegdec->format.video.par_n, ffmpegdec->format.video.par_d,
> ++          ffmpegdec->format.video.old_fps_n, ffmpegdec->format.video.old_fps_n,
> ++          ffmpegdec->context->width, ffmpegdec->context->height,
> ++          ffmpegdec->context->sample_aspect_ratio.num,
> ++          ffmpegdec->context->sample_aspect_ratio.den,
> ++          ffmpegdec->format.video.fps_n, ffmpegdec->format.video.fps_d);
> ++      ffmpegdec->format.video.width = ffmpegdec->context->width;
> ++      ffmpegdec->format.video.height = ffmpegdec->context->height;
> ++      ffmpegdec->format.video.old_fps_n = ffmpegdec->format.video.fps_n;
> ++      ffmpegdec->format.video.old_fps_d = ffmpegdec->format.video.fps_d;
> ++      ffmpegdec->format.video.pix_fmt = ffmpegdec->context->pix_fmt;
> ++      ffmpegdec->format.video.par_n =
> ++          ffmpegdec->context->sample_aspect_ratio.num;
> ++      ffmpegdec->format.video.par_d =
> ++          ffmpegdec->context->sample_aspect_ratio.den;
> ++      break;
> ++    case AVMEDIA_TYPE_AUDIO:
> ++    {
> ++      gint depth = av_smp_format_depth (ffmpegdec->context->sample_fmt);
> ++      if (!force && ffmpegdec->format.audio.samplerate ==
> ++          ffmpegdec->context->sample_rate &&
> ++          ffmpegdec->format.audio.channels == ffmpegdec->context->channels &&
> ++          ffmpegdec->format.audio.depth == depth)
> ++        return TRUE;
> ++      GST_DEBUG_OBJECT (ffmpegdec,
> ++          "Renegotiating audio from %dHz@%dchannels (%d) to %dHz@%dchannels (%d)",
> ++          ffmpegdec->format.audio.samplerate, ffmpegdec->format.audio.channels,
> ++          ffmpegdec->format.audio.depth,
> ++          ffmpegdec->context->sample_rate, ffmpegdec->context->channels, depth);
> ++      ffmpegdec->format.audio.samplerate = ffmpegdec->context->sample_rate;
> ++      ffmpegdec->format.audio.channels = ffmpegdec->context->channels;
> ++      ffmpegdec->format.audio.depth = depth;
> ++    }
> ++      break;
> ++    default:
> ++      break;
> ++  }
> ++
> ++  caps = gst_ffmpeg_codectype_to_caps (oclass->in_plugin->type,
> ++      ffmpegdec->context, oclass->in_plugin->id, FALSE);
> ++
> ++  if (caps == NULL)
> ++    goto no_caps;
> ++
> ++  switch (oclass->in_plugin->type) {
> ++    case AVMEDIA_TYPE_VIDEO:
> ++    {
> ++      gint width, height;
> ++      gboolean interlaced;
> ++
> ++      width = ffmpegdec->format.video.clip_width;
> ++      height = ffmpegdec->format.video.clip_height;
> ++      interlaced = ffmpegdec->format.video.interlaced;
> ++
> ++      if (width != -1 && height != -1) {
> ++        /* overwrite the output size with the dimension of the
> ++         * clipping region but only if they are smaller. */
> ++        if (width < ffmpegdec->context->width)
> ++          gst_caps_set_simple (caps, "width", G_TYPE_INT, width, NULL);
> ++        if (height < ffmpegdec->context->height)
> ++          gst_caps_set_simple (caps, "height", G_TYPE_INT, height, NULL);
> ++      }
> ++      gst_caps_set_simple (caps, "interlaced", G_TYPE_BOOLEAN, interlaced,
> ++          NULL);
> ++
> ++      /* If a demuxer provided a framerate then use it (#313970) */
> ++      if (ffmpegdec->format.video.fps_n != -1) {
> ++        gst_caps_set_simple (caps, "framerate",
> ++            GST_TYPE_FRACTION, ffmpegdec->format.video.fps_n,
> ++            ffmpegdec->format.video.fps_d, NULL);
> ++      }
> ++      gst_ffmpegdec_add_pixel_aspect_ratio (ffmpegdec,
> ++          gst_caps_get_structure (caps, 0));
> ++      break;
> ++    }
> ++    case AVMEDIA_TYPE_AUDIO:
> ++    {
> ++      break;
> ++    }
> ++    default:
> ++      break;
> ++  }
> ++
> ++  if (!gst_pad_set_caps (ffmpegdec->srcpad, caps))
> ++    goto caps_failed;
> ++
> ++  gst_caps_unref (caps);
> ++
> ++  return TRUE;
> ++
> ++  /* ERRORS */
> ++no_caps:
> ++  {
> ++#ifdef HAVE_FFMPEG_UNINSTALLED
> ++    /* using internal ffmpeg snapshot */
> ++    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
> ++        ("Could not find GStreamer caps mapping for FFmpeg codec '%s'.",
> ++            oclass->in_plugin->name), (NULL));
> ++#else
> ++    /* using external ffmpeg */
> ++    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
> ++        ("Could not find GStreamer caps mapping for FFmpeg codec '%s', and "
> ++            "you are using an external libavcodec. This is most likely due to "
> ++            "a packaging problem and/or libavcodec having been upgraded to a "
> ++            "version that is not compatible with this version of "
> ++            "gstreamer-ffmpeg. Make sure your gstreamer-ffmpeg and libavcodec "
> ++            "packages come from the same source/repository.",
> ++            oclass->in_plugin->name), (NULL));
> ++#endif
> ++    return FALSE;
> ++  }
> ++caps_failed:
> ++  {
> ++    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
> ++        ("Could not set caps for ffmpeg decoder (%s), not fixed?",
> ++            oclass->in_plugin->name));
> ++    gst_caps_unref (caps);
> ++
> ++    return FALSE;
> ++  }
> ++}
> ++
> ++/* perform qos calculations before decoding the next frame.
> ++ *
> ++ * Sets the skip_frame flag and if things are really bad, skips to the next
> ++ * keyframe.
> ++ *
> ++ * Returns TRUE if the frame should be decoded, FALSE if the frame can be dropped
> ++ * entirely.
> ++ */
> ++static gboolean
> ++gst_ffmpegdec_do_qos (GstFFMpegDec * ffmpegdec, GstClockTime timestamp,
> ++    gboolean * mode_switch)
> ++{
> ++  GstClockTimeDiff diff;
> ++  gdouble proportion;
> ++  GstClockTime qostime, earliest_time;
> ++  gboolean res = TRUE;
> ++
> ++  *mode_switch = FALSE;
> ++
> ++  /* no timestamp, can't do QoS */
> ++  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (timestamp)))
> ++    goto no_qos;
> ++
> ++  /* get latest QoS observation values */
> ++  gst_ffmpegdec_read_qos (ffmpegdec, &proportion, &earliest_time);
> ++
> ++  /* skip qos if we have no observation (yet) */
> ++  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (earliest_time))) {
> ++    /* no skip_frame initialy */
> ++    ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
> ++    goto no_qos;
> ++  }
> ++
> ++  /* qos is done on running time of the timestamp */
> ++  qostime = gst_segment_to_running_time (&ffmpegdec->segment, GST_FORMAT_TIME,
> ++      timestamp);
> ++
> ++  /* timestamp can be out of segment, then we don't do QoS */
> ++  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (qostime)))
> ++    goto no_qos;
> ++
> ++  /* see how our next timestamp relates to the latest qos timestamp. negative
> ++   * values mean we are early, positive values mean we are too late. */
> ++  diff = GST_CLOCK_DIFF (qostime, earliest_time);
> ++
> ++  GST_DEBUG_OBJECT (ffmpegdec, "QOS: qostime %" GST_TIME_FORMAT
> ++      ", earliest %" GST_TIME_FORMAT, GST_TIME_ARGS (qostime),
> ++      GST_TIME_ARGS (earliest_time));
> ++
> ++  /* if we using less than 40% of the available time, we can try to
> ++   * speed up again when we were slow. */
> ++  if (proportion < 0.4 && diff < 0) {
> ++    goto normal_mode;
> ++  } else {
> ++    if (diff >= 0) {
> ++      /* we're too slow, try to speed up */
> ++      /* switch to skip_frame mode */
> ++      goto skip_frame;
> ++    }
> ++  }
> ++
> ++no_qos:
> ++  ffmpegdec->processed++;
> ++  return TRUE;
> ++
> ++normal_mode:
> ++  {
> ++    if (ffmpegdec->context->skip_frame != AVDISCARD_DEFAULT) {
> ++      ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
> ++      *mode_switch = TRUE;
> ++      GST_DEBUG_OBJECT (ffmpegdec, "QOS: normal mode %g < 0.4", proportion);
> ++    }
> ++    ffmpegdec->processed++;
> ++    return TRUE;
> ++  }
> ++skip_frame:
> ++  {
> ++    if (ffmpegdec->context->skip_frame != AVDISCARD_NONREF) {
> ++      ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
> ++      *mode_switch = TRUE;
> ++      GST_DEBUG_OBJECT (ffmpegdec,
> ++          "QOS: hurry up, diff %" G_GINT64_FORMAT " >= 0", diff);
> ++    }
> ++    goto drop_qos;
> ++  }
> ++drop_qos:
> ++  {
> ++    GstClockTime stream_time, jitter;
> ++    GstMessage *qos_msg;
> ++
> ++    ffmpegdec->dropped++;
> ++    stream_time =
> ++        gst_segment_to_stream_time (&ffmpegdec->segment, GST_FORMAT_TIME,
> ++        timestamp);
> ++    jitter = GST_CLOCK_DIFF (qostime, earliest_time);
> ++    qos_msg =
> ++        gst_message_new_qos (GST_OBJECT_CAST (ffmpegdec), FALSE, qostime,
> ++        stream_time, timestamp, GST_CLOCK_TIME_NONE);
> ++    gst_message_set_qos_values (qos_msg, jitter, proportion, 1000000);
> ++    gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
> ++        ffmpegdec->processed, ffmpegdec->dropped);
> ++    gst_element_post_message (GST_ELEMENT_CAST (ffmpegdec), qos_msg);
> ++
> ++    return res;
> ++  }
> ++}
> ++
> ++/* returns TRUE if buffer is within segment, else FALSE.
> ++ * if Buffer is on segment border, it's timestamp and duration will be clipped */
> ++static gboolean
> ++clip_video_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
> ++    GstClockTime in_dur)
> ++{
> ++  gboolean res = TRUE;
> ++  gint64 cstart, cstop;
> ++  GstClockTime stop;
> ++
> ++  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 (G_UNLIKELY (dec->segment.format != GST_FORMAT_TIME))
> ++    goto beach;
> ++
> ++  /* we need a start time */
> ++  if (G_UNLIKELY (!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 */
> ++  res =
> ++      gst_segment_clip (&dec->segment, GST_FORMAT_TIME, in_ts, stop, &cstart,
> ++      &cstop);
> ++  if (G_UNLIKELY (!res))
> ++    goto beach;
> ++
> ++  /* we're pretty sure the duration of this buffer is not till the end of this
> ++   * segment (which _clip will assume when the stop is -1) */
> ++  if (stop == GST_CLOCK_TIME_NONE)
> ++    cstop = GST_CLOCK_TIME_NONE;
> ++
> ++  /* 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;
> ++
> ++  GST_LOG_OBJECT (dec,
> ++      "clipped timestamp:%" GST_TIME_FORMAT " , duration:%" GST_TIME_FORMAT,
> ++      GST_TIME_ARGS (cstart), GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
> ++
> ++beach:
> ++  GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
> ++  return res;
> ++}
> ++
> ++
> ++/* get an outbuf buffer with the current picture */
> ++static GstFlowReturn
> ++get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
> ++{
> ++  GstFlowReturn ret;
> ++
> ++  ret = GST_FLOW_OK;
> ++  *outbuf = NULL;
> ++
> ++  if (ffmpegdec->picture->opaque != NULL) {
> ++    /* we allocated a picture already for ffmpeg to decode into, let's pick it
> ++     * up and use it now. */
> ++    *outbuf = (GstBuffer *) ffmpegdec->picture->opaque;
> ++    GST_LOG_OBJECT (ffmpegdec, "using opaque buffer %p", *outbuf);
> ++#ifndef EXTRA_REF
> ++    gst_buffer_ref (*outbuf);
> ++#endif
> ++  } else {
> ++    AVPicture pic, *outpic;
> ++    gint width, height;
> ++
> ++    GST_LOG_OBJECT (ffmpegdec, "get output buffer");
> ++
> ++    /* figure out size of output buffer, this is the clipped output size because
> ++     * we will copy the picture into it but only when the clipping region is
> ++     * smaller than the actual picture size. */
> ++    if ((width = ffmpegdec->format.video.clip_width) == -1)
> ++      width = ffmpegdec->context->width;
> ++    else if (width > ffmpegdec->context->width)
> ++      width = ffmpegdec->context->width;
> ++
> ++    if ((height = ffmpegdec->format.video.clip_height) == -1)
> ++      height = ffmpegdec->context->height;
> ++    else if (height > ffmpegdec->context->height)
> ++      height = ffmpegdec->context->height;
> ++
> ++    GST_LOG_OBJECT (ffmpegdec, "clip width %d/height %d", width, height);
> ++
> ++    ret = alloc_output_buffer (ffmpegdec, outbuf, width, height);
> ++    if (G_UNLIKELY (ret != GST_FLOW_OK))
> ++      goto alloc_failed;
> ++
> ++    /* original ffmpeg code does not handle odd sizes correctly.
> ++     * This patched up version does */
> ++    gst_ffmpeg_avpicture_fill (&pic, GST_BUFFER_DATA (*outbuf),
> ++        ffmpegdec->context->pix_fmt, width, height);
> ++
> ++    outpic = (AVPicture *) ffmpegdec->picture;
> ++
> ++    GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", outpic->linesize[0],
> ++        outpic->linesize[1], outpic->linesize[2]);
> ++    GST_LOG_OBJECT (ffmpegdec, "data %u %u %u", 0,
> ++        (guint) (outpic->data[1] - outpic->data[0]),
> ++        (guint) (outpic->data[2] - outpic->data[0]));
> ++
> ++    av_picture_copy (&pic, outpic, ffmpegdec->context->pix_fmt, width, height);
> ++  }
> ++  ffmpegdec->picture->reordered_opaque = -1;
> ++
> ++  return ret;
> ++
> ++  /* special cases */
> ++alloc_failed:
> ++  {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "pad_alloc failed");
> ++    return ret;
> ++  }
> ++}
> ++
> ++static void
> ++clear_queued (GstFFMpegDec * ffmpegdec)
> ++{
> ++  g_list_foreach (ffmpegdec->queued, (GFunc) gst_mini_object_unref, NULL);
> ++  g_list_free (ffmpegdec->queued);
> ++  ffmpegdec->queued = NULL;
> ++}
> ++
> ++static GstFlowReturn
> ++flush_queued (GstFFMpegDec * ffmpegdec)
> ++{
> ++  GstFlowReturn res = GST_FLOW_OK;
> ++
> ++  while (ffmpegdec->queued) {
> ++    GstBuffer *buf = GST_BUFFER_CAST (ffmpegdec->queued->data);
> ++
> ++    GST_LOG_OBJECT (ffmpegdec, "pushing buffer %p, offset %"
> ++        G_GUINT64_FORMAT ", timestamp %"
> ++        GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT, buf,
> ++        GST_BUFFER_OFFSET (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 (ffmpegdec->srcpad, buf);
> ++
> ++    ffmpegdec->queued =
> ++        g_list_delete_link (ffmpegdec->queued, ffmpegdec->queued);
> ++  }
> ++  return res;
> ++}
> ++
> ++static void
> ++gst_avpacket_init (AVPacket * packet, guint8 * data, guint size)
> ++{
> ++  memset (packet, 0, sizeof (AVPacket));
> ++  packet->data = data;
> ++  packet->size = size;
> ++}
> ++
> ++/* gst_ffmpegdec_[video|audio]_frame:
> ++ * ffmpegdec:
> ++ * data: pointer to the data to decode
> ++ * size: size of data in bytes
> ++ * in_timestamp: incoming timestamp.
> ++ * in_duration: incoming duration.
> ++ * in_offset: incoming offset (frame number).
> ++ * outbuf: outgoing buffer. Different from NULL ONLY if it contains decoded data.
> ++ * ret: Return flow.
> ++ *
> ++ * Returns: number of bytes used in decoding. The check for successful decode is
> ++ *   outbuf being non-NULL.
> ++ */
> ++static gint
> ++gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
> ++    guint8 * data, guint size,
> ++    const GstTSInfo * dec_info, GstBuffer ** outbuf, GstFlowReturn * ret)
> ++{
> ++  gint len = -1;
> ++  gint have_data;
> ++  gboolean mode_switch;
> ++  gboolean decode;
> ++  gint skip_frame = AVDISCARD_DEFAULT;
> ++  GstClockTime out_timestamp, out_duration, out_pts;
> ++  gint64 out_offset;
> ++  const GstTSInfo *out_info;
> ++  AVPacket packet;
> ++
> ++  *ret = GST_FLOW_OK;
> ++  *outbuf = NULL;
> ++
> ++  ffmpegdec->context->opaque = ffmpegdec;
> ++
> ++  /* in case we skip frames */
> ++  ffmpegdec->picture->pict_type = -1;
> ++
> ++  /* run QoS code, we don't stop decoding the frame when we are late because
> ++   * else we might skip a reference frame */
> ++  decode = gst_ffmpegdec_do_qos (ffmpegdec, dec_info->timestamp, &mode_switch);
> ++
> ++  if (ffmpegdec->is_realvideo && data != NULL) {
> ++    gint slice_count;
> ++    gint i;
> ++
> ++    /* setup the slice table for realvideo */
> ++    if (ffmpegdec->context->slice_offset == NULL)
> ++      ffmpegdec->context->slice_offset = g_malloc (sizeof (guint32) * 1000);
> ++
> ++    slice_count = (*data++) + 1;
> ++    ffmpegdec->context->slice_count = slice_count;
> ++
> ++    for (i = 0; i < slice_count; i++) {
> ++      data += 4;
> ++      ffmpegdec->context->slice_offset[i] = GST_READ_UINT32_LE (data);
> ++      data += 4;
> ++    }
> ++  }
> ++
> ++  if (!decode) {
> ++    /* no decoding needed, save previous skip_frame value and brutely skip
> ++     * decoding everything */
> ++    skip_frame = ffmpegdec->context->skip_frame;
> ++    ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
> ++  }
> ++
> ++  /* save reference to the timing info */
> ++  ffmpegdec->context->reordered_opaque = (gint64) dec_info->idx;
> ++  ffmpegdec->picture->reordered_opaque = (gint64) dec_info->idx;
> ++
> ++  GST_DEBUG_OBJECT (ffmpegdec, "stored opaque values idx %d", dec_info->idx);
> ++
> ++  /* now decode the frame */
> ++  gst_avpacket_init (&packet, data, size);
> ++  len = avcodec_decode_video2 (ffmpegdec->context,
> ++      ffmpegdec->picture, &have_data, &packet);
> ++
> ++  /* restore previous state */
> ++  if (!decode)
> ++    ffmpegdec->context->skip_frame = skip_frame;
> ++
> ++  GST_DEBUG_OBJECT (ffmpegdec, "after decode: len %d, have_data %d",
> ++      len, have_data);
> ++
> ++  /* when we are in skip_frame mode, don't complain when ffmpeg returned
> ++   * no data because we told it to skip stuff. */
> ++  if (len < 0 && (mode_switch || ffmpegdec->context->skip_frame))
> ++    len = 0;
> ++
> ++  if (len > 0 && have_data <= 0 && (mode_switch
> ++          || ffmpegdec->context->skip_frame)) {
> ++    /* we consumed some bytes but nothing decoded and we are skipping frames,
> ++     * disable the interpollation of DTS timestamps */
> ++    ffmpegdec->last_out = -1;
> ++  }
> ++
> ++  /* no data, we're done */
> ++  if (len < 0 || have_data <= 0)
> ++    goto beach;
> ++
> ++  /* get the output picture timing info again */
> ++  out_info = gst_ts_info_get (ffmpegdec, ffmpegdec->picture->reordered_opaque);
> ++  out_pts = out_info->timestamp;
> ++  out_duration = out_info->duration;
> ++  out_offset = out_info->offset;
> ++
> ++  GST_DEBUG_OBJECT (ffmpegdec,
> ++      "pts %" G_GUINT64_FORMAT " duration %" G_GUINT64_FORMAT " offset %"
> ++      G_GINT64_FORMAT, out_pts, out_duration, out_offset);
> ++  GST_DEBUG_OBJECT (ffmpegdec, "picture: pts %" G_GUINT64_FORMAT,
> ++      (guint64) ffmpegdec->picture->pts);
> ++  GST_DEBUG_OBJECT (ffmpegdec, "picture: num %d",
> ++      ffmpegdec->picture->coded_picture_number);
> ++  GST_DEBUG_OBJECT (ffmpegdec, "picture: ref %d",
> ++      ffmpegdec->picture->reference);
> ++  GST_DEBUG_OBJECT (ffmpegdec, "picture: display %d",
> ++      ffmpegdec->picture->display_picture_number);
> ++  GST_DEBUG_OBJECT (ffmpegdec, "picture: opaque %p",
> ++      ffmpegdec->picture->opaque);
> ++  GST_DEBUG_OBJECT (ffmpegdec, "picture: reordered opaque %" G_GUINT64_FORMAT,
> ++      (guint64) ffmpegdec->picture->reordered_opaque);
> ++  GST_DEBUG_OBJECT (ffmpegdec, "repeat_pict:%d",
> ++      ffmpegdec->picture->repeat_pict);
> ++  GST_DEBUG_OBJECT (ffmpegdec, "interlaced_frame:%d",
> ++      ffmpegdec->picture->interlaced_frame);
> ++
> ++  if (G_UNLIKELY (ffmpegdec->picture->interlaced_frame !=
> ++          ffmpegdec->format.video.interlaced)) {
> ++    GST_WARNING ("Change in interlacing ! picture:%d, recorded:%d",
> ++        ffmpegdec->picture->interlaced_frame,
> ++        ffmpegdec->format.video.interlaced);
> ++    ffmpegdec->format.video.interlaced = ffmpegdec->picture->interlaced_frame;
> ++    gst_ffmpegdec_negotiate (ffmpegdec, TRUE);
> ++  }
> ++
> ++  /* Whether a frame is interlaced or not is unknown at the time of
> ++     buffer allocation, so caps on the buffer in opaque will have
> ++     the previous frame's interlaced flag set. So if interlacedness
> ++     has changed since allocation, we update the buffer (if any)
> ++     caps now with the correct interlaced flag. */
> ++  if (ffmpegdec->picture->opaque != NULL) {
> ++    GstBuffer *buffer = ffmpegdec->picture->opaque;
> ++    if (GST_BUFFER_CAPS (buffer) && GST_PAD_CAPS (ffmpegdec->srcpad)) {
> ++      GstStructure *s = gst_caps_get_structure (GST_BUFFER_CAPS (buffer), 0);
> ++      gboolean interlaced;
> ++      gboolean found = gst_structure_get_boolean (s, "interlaced", &interlaced);
> ++      if (!found || (!!interlaced != !!ffmpegdec->format.video.interlaced)) {
> ++        GST_DEBUG_OBJECT (ffmpegdec,
> ++            "Buffer interlacing does not match pad, updating");
> ++        buffer = gst_buffer_make_metadata_writable (buffer);
> ++        gst_buffer_set_caps (buffer, GST_PAD_CAPS (ffmpegdec->srcpad));
> ++        ffmpegdec->picture->opaque = buffer;
> ++      }
> ++    }
> ++  }
> ++
> ++  /* check that the timestamps go upwards */
> ++  if (ffmpegdec->last_out != -1 && ffmpegdec->last_out > out_pts) {
> ++    /* timestamps go backwards, this means frames were reordered and we must
> ++     * be dealing with DTS as the buffer timestamps */
> ++    if (!ffmpegdec->reordered_out) {
> ++      GST_DEBUG_OBJECT (ffmpegdec, "detected reordered out timestamps");
> ++      ffmpegdec->reordered_out = TRUE;
> ++    }
> ++    if (ffmpegdec->reordered_in) {
> ++      /* we reset the input reordering here because we want to recover from an
> ++       * occasionally wrong reordered input timestamp */
> ++      GST_DEBUG_OBJECT (ffmpegdec, "assuming DTS input timestamps");
> ++      ffmpegdec->reordered_in = FALSE;
> ++    }
> ++  }
> ++
> ++  if (out_pts == 0 && out_pts == ffmpegdec->last_out) {
> ++    GST_LOG_OBJECT (ffmpegdec, "ffmpeg returns 0 timestamps, ignoring");
> ++    /* some codecs only output 0 timestamps, when that happens, make us select an
> ++     * output timestamp based on the input timestamp. We do this by making the
> ++     * ffmpeg timestamp and the interpollated next timestamp invalid. */
> ++    out_pts = -1;
> ++    ffmpegdec->next_out = -1;
> ++  } else
> ++    ffmpegdec->last_out = out_pts;
> ++
> ++  /* we assume DTS as input timestamps unless we see reordered input
> ++   * timestamps */
> ++  if (!ffmpegdec->reordered_in && ffmpegdec->reordered_out) {
> ++    /* PTS and DTS are the same for keyframes */
> ++    if (ffmpegdec->next_out != -1) {
> ++      /* interpolate all timestamps except for keyframes, FIXME, this is
> ++       * wrong when QoS is active. */
> ++      GST_DEBUG_OBJECT (ffmpegdec, "interpolate timestamps");
> ++      out_pts = -1;
> ++      out_offset = -1;
> ++    }
> ++  }
> ++
> ++  /* get a handle to the output buffer */
> ++  *ret = get_output_buffer (ffmpegdec, outbuf);
> ++  if (G_UNLIKELY (*ret != GST_FLOW_OK))
> ++    goto no_output;
> ++
> ++  /*
> ++   * Timestamps:
> ++   *
> ++   *  1) Copy picture timestamp if valid
> ++   *  2) else interpolate from previous output timestamp
> ++   *  3) else copy input timestamp
> ++   */
> ++  out_timestamp = -1;
> ++  if (out_pts != -1) {
> ++    /* Get (interpolated) timestamp from FFMPEG */
> ++    out_timestamp = (GstClockTime) out_pts;
> ++    GST_LOG_OBJECT (ffmpegdec, "using timestamp %" GST_TIME_FORMAT
> ++        " returned by ffmpeg", GST_TIME_ARGS (out_timestamp));
> ++  }
> ++  if (!GST_CLOCK_TIME_IS_VALID (out_timestamp) && ffmpegdec->next_out != -1) {
> ++    out_timestamp = ffmpegdec->next_out;
> ++    GST_LOG_OBJECT (ffmpegdec, "using next timestamp %" GST_TIME_FORMAT,
> ++        GST_TIME_ARGS (out_timestamp));
> ++  }
> ++  if (!GST_CLOCK_TIME_IS_VALID (out_timestamp)) {
> ++    out_timestamp = dec_info->timestamp;
> ++    GST_LOG_OBJECT (ffmpegdec, "using in timestamp %" GST_TIME_FORMAT,
> ++        GST_TIME_ARGS (out_timestamp));
> ++  }
> ++  GST_BUFFER_TIMESTAMP (*outbuf) = out_timestamp;
> ++
> ++  /*
> ++   * Offset:
> ++   *  0) Use stored input offset (from opaque)
> ++   *  1) Use value converted from timestamp if valid
> ++   *  2) Use input offset if valid
> ++   */
> ++  if (out_offset != GST_BUFFER_OFFSET_NONE) {
> ++    /* out_offset already contains the offset from ts_info */
> ++    GST_LOG_OBJECT (ffmpegdec, "Using offset returned by ffmpeg");
> ++  } else if (out_timestamp != GST_CLOCK_TIME_NONE) {
> ++    GstFormat out_fmt = GST_FORMAT_DEFAULT;
> ++    GST_LOG_OBJECT (ffmpegdec, "Using offset converted from timestamp");
> ++    /* FIXME, we should really remove this as it's not nice at all to do
> ++     * upstream queries for each frame to get the frame offset. We also can't
> ++     * really remove this because it is the only way of setting frame offsets
> ++     * on outgoing buffers. We should have metadata so that the upstream peer
> ++     * can set a frame number on the encoded data. */
> ++    gst_pad_query_peer_convert (ffmpegdec->sinkpad,
> ++        GST_FORMAT_TIME, out_timestamp, &out_fmt, &out_offset);
> ++  } else if (dec_info->offset != GST_BUFFER_OFFSET_NONE) {
> ++    /* FIXME, the input offset is input media specific and might not
> ++     * be the same for the output media. (byte offset as input, frame number
> ++     * as output, for example) */
> ++    GST_LOG_OBJECT (ffmpegdec, "using in_offset %" G_GINT64_FORMAT,
> ++        dec_info->offset);
> ++    out_offset = dec_info->offset;
> ++  } else {
> ++    GST_LOG_OBJECT (ffmpegdec, "no valid offset found");
> ++    out_offset = GST_BUFFER_OFFSET_NONE;
> ++  }
> ++  GST_BUFFER_OFFSET (*outbuf) = out_offset;
> ++
> ++  /*
> ++   * Duration:
> ++   *
> ++   *  1) Use reordered input duration if valid
> ++   *  2) Else use input duration
> ++   *  3) else use input framerate
> ++   *  4) else use ffmpeg framerate
> ++   */
> ++  if (GST_CLOCK_TIME_IS_VALID (out_duration)) {
> ++    /* We have a valid (reordered) duration */
> ++    GST_LOG_OBJECT (ffmpegdec, "Using duration returned by ffmpeg");
> ++  } else if (GST_CLOCK_TIME_IS_VALID (dec_info->duration)) {
> ++    GST_LOG_OBJECT (ffmpegdec, "using in_duration");
> ++    out_duration = dec_info->duration;
> ++  } else if (GST_CLOCK_TIME_IS_VALID (ffmpegdec->last_diff)) {
> ++    GST_LOG_OBJECT (ffmpegdec, "using last-diff");
> ++    out_duration = ffmpegdec->last_diff;
> ++  } else {
> ++    /* if we have an input framerate, use that */
> ++    if (ffmpegdec->format.video.fps_n != -1 &&
> ++        (ffmpegdec->format.video.fps_n != 1000 &&
> ++            ffmpegdec->format.video.fps_d != 1)) {
> ++      GST_LOG_OBJECT (ffmpegdec, "using input framerate for duration");
> ++      out_duration = gst_util_uint64_scale_int (GST_SECOND,
> ++          ffmpegdec->format.video.fps_d, ffmpegdec->format.video.fps_n);
> ++    } else {
> ++      /* don't try to use the decoder's framerate when it seems a bit abnormal,
> ++       * which we assume when den >= 1000... */
> ++      if (ffmpegdec->context->time_base.num != 0 &&
> ++          (ffmpegdec->context->time_base.den > 0 &&
> ++              ffmpegdec->context->time_base.den < 1000)) {
> ++        GST_LOG_OBJECT (ffmpegdec, "using decoder's framerate for duration");
> ++        out_duration = gst_util_uint64_scale_int (GST_SECOND,
> ++            ffmpegdec->context->time_base.num *
> ++            ffmpegdec->context->ticks_per_frame,
> ++            ffmpegdec->context->time_base.den);
> ++      } else {
> ++        GST_LOG_OBJECT (ffmpegdec, "no valid duration found");
> ++      }
> ++    }
> ++  }
> ++
> ++  /* Take repeat_pict into account */
> ++  if (GST_CLOCK_TIME_IS_VALID (out_duration)) {
> ++    out_duration += out_duration * ffmpegdec->picture->repeat_pict / 2;
> ++  }
> ++  GST_BUFFER_DURATION (*outbuf) = out_duration;
> ++
> ++  if (out_timestamp != -1 && out_duration != -1 && out_duration != 0)
> ++    ffmpegdec->next_out = out_timestamp + out_duration;
> ++  else
> ++    ffmpegdec->next_out = -1;
> ++
> ++  /* now see if we need to clip the buffer against the segment boundaries. */
> ++  if (G_UNLIKELY (!clip_video_buffer (ffmpegdec, *outbuf, out_timestamp,
> ++              out_duration)))
> ++    goto clipped;
> ++
> ++  if (ffmpegdec->picture->top_field_first)
> ++    GST_BUFFER_FLAG_SET (*outbuf, GST_VIDEO_BUFFER_TFF);
> ++
> ++
> ++beach:
> ++  GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
> ++      *ret, *outbuf, len);
> ++  return len;
> ++
> ++  /* special cases */
> ++no_output:
> ++  {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "no output buffer");
> ++    len = -1;
> ++    goto beach;
> ++  }
> ++clipped:
> ++  {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "buffer clipped");
> ++    gst_buffer_unref (*outbuf);
> ++    *outbuf = NULL;
> ++    goto beach;
> ++  }
> ++}
> ++
> ++/* returns TRUE if buffer is within segment, else FALSE.
> ++ * if Buffer is on segment border, it's timestamp and duration will be clipped */
> ++static gboolean
> ++clip_audio_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
> ++    GstClockTime in_dur)
> ++{
> ++  GstClockTime stop;
> ++  gint64 diff, ctime, cstop;
> ++  gboolean res = TRUE;
> ++
> ++  GST_LOG_OBJECT (dec,
> ++      "timestamp:%" GST_TIME_FORMAT ", duration:%" GST_TIME_FORMAT
> ++      ", size %u", GST_TIME_ARGS (in_ts), GST_TIME_ARGS (in_dur),
> ++      GST_BUFFER_SIZE (buf));
> ++
> ++  /* can't clip without TIME segment */
> ++  if (G_UNLIKELY (dec->segment.format != GST_FORMAT_TIME))
> ++    goto beach;
> ++
> ++  /* we need a start time */
> ++  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (in_ts)))
> ++    goto beach;
> ++
> ++  /* trust duration */
> ++  stop = in_ts + in_dur;
> ++
> ++  res = gst_segment_clip (&dec->segment, GST_FORMAT_TIME, in_ts, stop, &ctime,
> ++      &cstop);
> ++  if (G_UNLIKELY (!res))
> ++    goto out_of_segment;
> ++
> ++  /* see if some clipping happened */
> ++  if (G_UNLIKELY ((diff = ctime - in_ts) > 0)) {
> ++    /* bring clipped time to bytes */
> ++    diff =
> ++        gst_util_uint64_scale_int (diff, dec->format.audio.samplerate,
> ++        GST_SECOND) * (dec->format.audio.depth * dec->format.audio.channels);
> ++
> ++    GST_DEBUG_OBJECT (dec, "clipping start to %" GST_TIME_FORMAT " %"
> ++        G_GINT64_FORMAT " bytes", GST_TIME_ARGS (ctime), diff);
> ++
> ++    GST_BUFFER_SIZE (buf) -= diff;
> ++    GST_BUFFER_DATA (buf) += diff;
> ++  }
> ++  if (G_UNLIKELY ((diff = stop - cstop) > 0)) {
> ++    /* bring clipped time to bytes */
> ++    diff =
> ++        gst_util_uint64_scale_int (diff, dec->format.audio.samplerate,
> ++        GST_SECOND) * (dec->format.audio.depth * dec->format.audio.channels);
> ++
> ++    GST_DEBUG_OBJECT (dec, "clipping stop to %" GST_TIME_FORMAT " %"
> ++        G_GINT64_FORMAT " bytes", GST_TIME_ARGS (cstop), diff);
> ++
> ++    GST_BUFFER_SIZE (buf) -= diff;
> ++  }
> ++  GST_BUFFER_TIMESTAMP (buf) = ctime;
> ++  GST_BUFFER_DURATION (buf) = cstop - ctime;
> ++
> ++beach:
> ++  GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
> ++  return res;
> ++
> ++  /* ERRORS */
> ++out_of_segment:
> ++  {
> ++    GST_LOG_OBJECT (dec, "out of segment");
> ++    goto beach;
> ++  }
> ++}
> ++
> ++static gint
> ++gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec,
> ++    AVCodec * in_plugin, guint8 * data, guint size,
> ++    const GstTSInfo * dec_info, GstBuffer ** outbuf, GstFlowReturn * ret)
> ++{
> ++  gint len = -1;
> ++  gint have_data = AVCODEC_MAX_AUDIO_FRAME_SIZE;
> ++  GstClockTime out_timestamp, out_duration;
> ++  gint64 out_offset;
> ++  AVPacket packet;
> ++
> ++  GST_DEBUG_OBJECT (ffmpegdec,
> ++      "size:%d, offset:%" G_GINT64_FORMAT ", ts:%" GST_TIME_FORMAT ", dur:%"
> ++      GST_TIME_FORMAT ", ffmpegdec->next_out:%" GST_TIME_FORMAT, size,
> ++      dec_info->offset, GST_TIME_ARGS (dec_info->timestamp),
> ++      GST_TIME_ARGS (dec_info->duration), GST_TIME_ARGS (ffmpegdec->next_out));
> ++
> ++  *outbuf =
> ++      new_aligned_buffer (AVCODEC_MAX_AUDIO_FRAME_SIZE,
> ++      GST_PAD_CAPS (ffmpegdec->srcpad));
> ++
> ++  gst_avpacket_init (&packet, data, size);
> ++  len = avcodec_decode_audio3 (ffmpegdec->context,
> ++      (int16_t *) GST_BUFFER_DATA (*outbuf), &have_data, &packet);
> ++  GST_DEBUG_OBJECT (ffmpegdec,
> ++      "Decode audio: len=%d, have_data=%d", len, have_data);
> ++
> ++  if (len >= 0 && have_data > 0) {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "Creating output buffer");
> ++    if (!gst_ffmpegdec_negotiate (ffmpegdec, FALSE)) {
> ++      gst_buffer_unref (*outbuf);
> ++      *outbuf = NULL;
> ++      len = -1;
> ++      goto beach;
> ++    }
> ++
> ++    /* Buffer size */
> ++    GST_BUFFER_SIZE (*outbuf) = have_data;
> ++
> ++    /*
> ++     * Timestamps:
> ++     *
> ++     *  1) Copy input timestamp if valid
> ++     *  2) else interpolate from previous input timestamp
> ++     */
> ++    /* always take timestamps from the input buffer if any */
> ++    if (GST_CLOCK_TIME_IS_VALID (dec_info->timestamp)) {
> ++      out_timestamp = dec_info->timestamp;
> ++    } else {
> ++      out_timestamp = ffmpegdec->next_out;
> ++    }
> ++
> ++    /*
> ++     * Duration:
> ++     *
> ++     *  1) calculate based on number of samples
> ++     */
> ++    out_duration = gst_util_uint64_scale (have_data, GST_SECOND,
> ++        ffmpegdec->format.audio.depth * ffmpegdec->format.audio.channels *
> ++        ffmpegdec->format.audio.samplerate);
> ++
> ++    /* offset:
> ++     *
> ++     * Just copy
> ++     */
> ++    out_offset = dec_info->offset;
> ++
> ++    GST_DEBUG_OBJECT (ffmpegdec,
> ++        "Buffer created. Size:%d , timestamp:%" GST_TIME_FORMAT " , duration:%"
> ++        GST_TIME_FORMAT, have_data,
> ++        GST_TIME_ARGS (out_timestamp), GST_TIME_ARGS (out_duration));
> ++
> ++    GST_BUFFER_TIMESTAMP (*outbuf) = out_timestamp;
> ++    GST_BUFFER_DURATION (*outbuf) = out_duration;
> ++    GST_BUFFER_OFFSET (*outbuf) = out_offset;
> ++    gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (ffmpegdec->srcpad));
> ++
> ++    /* the next timestamp we'll use when interpolating */
> ++    if (GST_CLOCK_TIME_IS_VALID (out_timestamp))
> ++      ffmpegdec->next_out = out_timestamp + out_duration;
> ++
> ++    /* now see if we need to clip the buffer against the segment boundaries. */
> ++    if (G_UNLIKELY (!clip_audio_buffer (ffmpegdec, *outbuf, out_timestamp,
> ++                out_duration)))
> ++      goto clipped;
> ++
> ++  } else {
> ++    gst_buffer_unref (*outbuf);
> ++    *outbuf = NULL;
> ++  }
> ++
> ++  /* If we don't error out after the first failed read with the AAC decoder,
> ++   * we must *not* carry on pushing data, else we'll cause segfaults... */
> ++  if (len == -1 && (in_plugin->id == CODEC_ID_AAC
> ++          || in_plugin->id == CODEC_ID_AAC_LATM)) {
> ++    GST_ELEMENT_ERROR (ffmpegdec, STREAM, DECODE, (NULL),
> ++        ("Decoding of AAC stream by FFMPEG failed."));
> ++    *ret = GST_FLOW_ERROR;
> ++  }
> ++
> ++beach:
> ++  GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
> ++      *ret, *outbuf, len);
> ++  return len;
> ++
> ++  /* ERRORS */
> ++clipped:
> ++  {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "buffer clipped");
> ++    gst_buffer_unref (*outbuf);
> ++    *outbuf = NULL;
> ++    goto beach;
> ++  }
> ++}
> ++
> ++/* gst_ffmpegdec_frame:
> ++ * ffmpegdec:
> ++ * data: pointer to the data to decode
> ++ * size: size of data in bytes
> ++ * got_data: 0 if no data was decoded, != 0 otherwise.
> ++ * in_time: timestamp of data
> ++ * in_duration: duration of data
> ++ * ret: GstFlowReturn to return in the chain function
> ++ *
> ++ * Decode the given frame and pushes it downstream.
> ++ *
> ++ * Returns: Number of bytes used in decoding, -1 on error/failure.
> ++ */
> ++
> ++static gint
> ++gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec,
> ++    guint8 * data, guint size, gint * got_data, const GstTSInfo * dec_info,
> ++    GstFlowReturn * ret)
> ++{
> ++  GstFFMpegDecClass *oclass;
> ++  GstBuffer *outbuf = NULL;
> ++  gint have_data = 0, len = 0;
> ++
> ++  if (G_UNLIKELY (ffmpegdec->context->codec == NULL))
> ++    goto no_codec;
> ++
> ++  GST_LOG_OBJECT (ffmpegdec, "data:%p, size:%d, id:%d", data, size,
> ++      dec_info->idx);
> ++
> ++  *ret = GST_FLOW_OK;
> ++  ffmpegdec->context->frame_number++;
> ++
> ++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> ++
> ++  switch (oclass->in_plugin->type) {
> ++    case AVMEDIA_TYPE_VIDEO:
> ++      len =
> ++          gst_ffmpegdec_video_frame (ffmpegdec, data, size, dec_info, &outbuf,
> ++          ret);
> ++      break;
> ++    case AVMEDIA_TYPE_AUDIO:
> ++      len =
> ++          gst_ffmpegdec_audio_frame (ffmpegdec, oclass->in_plugin, data, size,
> ++          dec_info, &outbuf, ret);
> ++
> ++      /* if we did not get an output buffer and we have a pending discont, don't
> ++       * clear the input timestamps, we will put them on the next buffer because
> ++       * else we might create the first buffer with a very big timestamp gap. */
> ++      if (outbuf == NULL && ffmpegdec->discont) {
> ++        GST_DEBUG_OBJECT (ffmpegdec, "no buffer but keeping timestamp");
> ++        ffmpegdec->clear_ts = FALSE;
> ++      }
> ++      break;
> ++    default:
> ++      GST_ERROR_OBJECT (ffmpegdec, "Asked to decode non-audio/video frame !");
> ++      g_assert_not_reached ();
> ++      break;
> ++  }
> ++
> ++  if (outbuf)
> ++    have_data = 1;
> ++
> ++  if (len < 0 || have_data < 0) {
> ++    GST_WARNING_OBJECT (ffmpegdec,
> ++        "ffdec_%s: decoding error (len: %d, have_data: %d)",
> ++        oclass->in_plugin->name, len, have_data);
> ++    *got_data = 0;
> ++    goto beach;
> ++  } else if (len == 0 && have_data == 0) {
> ++    *got_data = 0;
> ++    goto beach;
> ++  } else {
> ++    /* this is where I lost my last clue on ffmpeg... */
> ++    *got_data = 1;
> ++  }
> ++
> ++  if (outbuf) {
> ++    GST_LOG_OBJECT (ffmpegdec,
> ++        "Decoded data, now pushing buffer %p with offset %" G_GINT64_FORMAT
> ++        ", timestamp %" GST_TIME_FORMAT " and duration %" GST_TIME_FORMAT,
> ++        outbuf, GST_BUFFER_OFFSET (outbuf),
> ++        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
> ++        GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)));
> ++
> ++    /* mark pending discont */
> ++    if (ffmpegdec->discont) {
> ++      GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
> ++      ffmpegdec->discont = FALSE;
> ++    }
> ++
> ++    if (ffmpegdec->segment.rate > 0.0) {
> ++      /* and off we go */
> ++      *ret = gst_pad_push (ffmpegdec->srcpad, outbuf);
> ++    } else {
> ++      /* reverse playback, queue frame till later when we get a discont. */
> ++      GST_DEBUG_OBJECT (ffmpegdec, "queued frame");
> ++      ffmpegdec->queued = g_list_prepend (ffmpegdec->queued, outbuf);
> ++      *ret = GST_FLOW_OK;
> ++    }
> ++  } else {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "We didn't get a decoded buffer");
> ++  }
> ++
> ++beach:
> ++  return len;
> ++
> ++  /* ERRORS */
> ++no_codec:
> ++  {
> ++    GST_ERROR_OBJECT (ffmpegdec, "no codec context");
> ++    return -1;
> ++  }
> ++}
> ++
> ++static void
> ++gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec)
> ++{
> ++  GstFFMpegDecClass *oclass;
> ++
> ++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> ++
> ++  if (oclass->in_plugin->capabilities & CODEC_CAP_DELAY) {
> ++    gint have_data, len, try = 0;
> ++
> ++    GST_LOG_OBJECT (ffmpegdec,
> ++        "codec has delay capabilities, calling until ffmpeg has drained everything");
> ++
> ++    do {
> ++      GstFlowReturn ret;
> ++
> ++      len =
> ++          gst_ffmpegdec_frame (ffmpegdec, NULL, 0, &have_data, &ts_info_none,
> ++          &ret);
> ++      if (len < 0 || have_data == 0)
> ++        break;
> ++    } while (try++ < 10);
> ++  }
> ++  if (ffmpegdec->segment.rate < 0.0) {
> ++    /* if we have some queued frames for reverse playback, flush them now */
> ++    flush_queued (ffmpegdec);
> ++  }
> ++}
> ++
> ++static void
> ++gst_ffmpegdec_flush_pcache (GstFFMpegDec * ffmpegdec)
> ++{
> ++  if (ffmpegdec->pctx) {
> ++    gint size, bsize;
> ++    guint8 *data;
> ++    guint8 bdata[FF_INPUT_BUFFER_PADDING_SIZE];
> ++
> ++    bsize = FF_INPUT_BUFFER_PADDING_SIZE;
> ++    memset (bdata, 0, bsize);
> ++
> ++    /* parse some dummy data to work around some ffmpeg weirdness where it keeps
> ++     * the previous pts around */
> ++    av_parser_parse2 (ffmpegdec->pctx, ffmpegdec->context,
> ++        &data, &size, bdata, bsize, -1, -1, -1);
> ++    ffmpegdec->pctx->pts = -1;
> ++    ffmpegdec->pctx->dts = -1;
> ++  }
> ++
> ++  if (ffmpegdec->pcache) {
> ++    gst_buffer_unref (ffmpegdec->pcache);
> ++    ffmpegdec->pcache = NULL;
> ++  }
> ++}
> ++
> ++static gboolean
> ++gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event)
> ++{
> ++  GstFFMpegDec *ffmpegdec;
> ++  gboolean ret = FALSE;
> ++
> ++  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
> ++
> ++  GST_DEBUG_OBJECT (ffmpegdec, "Handling %s event",
> ++      GST_EVENT_TYPE_NAME (event));
> ++
> ++  switch (GST_EVENT_TYPE (event)) {
> ++    case GST_EVENT_EOS:
> ++    {
> ++      gst_ffmpegdec_drain (ffmpegdec);
> ++      break;
> ++    }
> ++    case GST_EVENT_FLUSH_STOP:
> ++    {
> ++      if (ffmpegdec->opened) {
> ++        avcodec_flush_buffers (ffmpegdec->context);
> ++      }
> ++      gst_ffmpegdec_reset_ts (ffmpegdec);
> ++      gst_ffmpegdec_reset_qos (ffmpegdec);
> ++      gst_ffmpegdec_flush_pcache (ffmpegdec);
> ++      gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
> ++      clear_queued (ffmpegdec);
> ++      break;
> ++    }
> ++    case GST_EVENT_NEWSEGMENT:
> ++    {
> ++      gboolean update;
> ++      GstFormat fmt;
> ++      gint64 start, stop, time;
> ++      gdouble rate, arate;
> ++
> ++      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &fmt,
> ++          &start, &stop, &time);
> ++
> ++      switch (fmt) {
> ++        case GST_FORMAT_TIME:
> ++          /* fine, our native segment format */
> ++          break;
> ++        case GST_FORMAT_BYTES:
> ++        {
> ++          gint bit_rate;
> ++
> ++          bit_rate = ffmpegdec->context->bit_rate;
> ++
> ++          /* convert to time or fail */
> ++          if (!bit_rate)
> ++            goto no_bitrate;
> ++
> ++          GST_DEBUG_OBJECT (ffmpegdec, "bitrate: %d", bit_rate);
> ++
> ++          /* convert values to TIME */
> ++          if (start != -1)
> ++            start = gst_util_uint64_scale_int (start, GST_SECOND, bit_rate);
> ++          if (stop != -1)
> ++            stop = gst_util_uint64_scale_int (stop, GST_SECOND, bit_rate);
> ++          if (time != -1)
> ++            time = gst_util_uint64_scale_int (time, GST_SECOND, bit_rate);
> ++
> ++          /* unref old event */
> ++          gst_event_unref (event);
> ++
> ++          /* create new converted time segment */
> ++          fmt = GST_FORMAT_TIME;
> ++          /* FIXME, bitrate is not good enough too find a good stop, let's
> ++           * hope start and time were 0... meh. */
> ++          stop = -1;
> ++          event = gst_event_new_new_segment (update, rate, fmt,
> ++              start, stop, time);
> ++          break;
> ++        }
> ++        default:
> ++          /* invalid format */
> ++          goto invalid_format;
> ++      }
> ++
> ++      /* drain pending frames before trying to use the new segment, queued
> ++       * buffers belonged to the previous segment. */
> ++      if (ffmpegdec->context->codec)
> ++        gst_ffmpegdec_drain (ffmpegdec);
> ++
> ++      GST_DEBUG_OBJECT (ffmpegdec,
> ++          "NEWSEGMENT in time start %" GST_TIME_FORMAT " -- stop %"
> ++          GST_TIME_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
> ++
> ++      /* and store the values */
> ++      gst_segment_set_newsegment_full (&ffmpegdec->segment, update,
> ++          rate, arate, fmt, start, stop, time);
> ++      break;
> ++    }
> ++    default:
> ++      break;
> ++  }
> ++
> ++  /* and push segment downstream */
> ++  ret = gst_pad_push_event (ffmpegdec->srcpad, event);
> ++
> ++done:
> ++  gst_object_unref (ffmpegdec);
> ++
> ++  return ret;
> ++
> ++  /* ERRORS */
> ++no_bitrate:
> ++  {
> ++    GST_WARNING_OBJECT (ffmpegdec, "no bitrate to convert BYTES to TIME");
> ++    gst_event_unref (event);
> ++    goto done;
> ++  }
> ++invalid_format:
> ++  {
> ++    GST_WARNING_OBJECT (ffmpegdec, "unknown format received in NEWSEGMENT");
> ++    gst_event_unref (event);
> ++    goto done;
> ++  }
> ++}
> ++
> ++static GstFlowReturn
> ++gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
> ++{
> ++  GstFFMpegDec *ffmpegdec;
> ++  GstFFMpegDecClass *oclass;
> ++  guint8 *data, *bdata;
> ++  gint size, bsize, len, have_data;
> ++  GstFlowReturn ret = GST_FLOW_OK;
> ++  GstClockTime in_timestamp;
> ++  GstClockTime in_duration;
> ++  gboolean discont;
> ++  gint64 in_offset;
> ++  const GstTSInfo *in_info;
> ++  const GstTSInfo *dec_info;
> ++
> ++  ffmpegdec = (GstFFMpegDec *) (GST_PAD_PARENT (pad));
> ++
> ++  if (G_UNLIKELY (!ffmpegdec->opened))
> ++    goto not_negotiated;
> ++
> ++  discont = GST_BUFFER_IS_DISCONT (inbuf);
> ++
> ++  /* The discont flags marks a buffer that is not continuous with the previous
> ++   * buffer. This means we need to clear whatever data we currently have. We
> ++   * currently also wait for a new keyframe, which might be suboptimal in the
> ++   * case of a network error, better show the errors than to drop all data.. */
> ++  if (G_UNLIKELY (discont)) {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "received DISCONT");
> ++    /* drain what we have queued */
> ++    gst_ffmpegdec_drain (ffmpegdec);
> ++    gst_ffmpegdec_flush_pcache (ffmpegdec);
> ++    avcodec_flush_buffers (ffmpegdec->context);
> ++    ffmpegdec->discont = TRUE;
> ++    gst_ffmpegdec_reset_ts (ffmpegdec);
> ++  }
> ++  /* by default we clear the input timestamp after decoding each frame so that
> ++   * interpollation can work. */
> ++  ffmpegdec->clear_ts = TRUE;
> ++
> ++  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> ++
> ++  /* parse cache joining. If there is cached data */
> ++  if (ffmpegdec->pcache) {
> ++    /* join with previous data */
> ++    GST_LOG_OBJECT (ffmpegdec, "join parse cache");
> ++    inbuf = gst_buffer_join (ffmpegdec->pcache, inbuf);
> ++    /* no more cached data, we assume we can consume the complete cache */
> ++    ffmpegdec->pcache = NULL;
> ++  }
> ++
> ++  in_timestamp = GST_BUFFER_TIMESTAMP (inbuf);
> ++  in_duration = GST_BUFFER_DURATION (inbuf);
> ++  in_offset = GST_BUFFER_OFFSET (inbuf);
> ++
> ++  /* get handle to timestamp info, we can pass this around to ffmpeg */
> ++  in_info = gst_ts_info_store (ffmpegdec, in_timestamp, in_duration, in_offset);
> ++
> ++  if (in_timestamp != -1) {
> ++    /* check for increasing timestamps if they are jumping backwards, we
> ++     * probably are dealing with PTS as timestamps */
> ++    if (!ffmpegdec->reordered_in && ffmpegdec->last_in != -1) {
> ++      if (in_timestamp < ffmpegdec->last_in) {
> ++        GST_LOG_OBJECT (ffmpegdec, "detected reordered input timestamps");
> ++        ffmpegdec->reordered_in = TRUE;
> ++        ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
> ++      } else if (in_timestamp > ffmpegdec->last_in) {
> ++        GstClockTime diff;
> ++        /* keep track of timestamp diff to estimate duration */
> ++        diff = in_timestamp - ffmpegdec->last_in;
> ++        /* need to scale with amount of frames in the interval */
> ++        if (ffmpegdec->last_frames)
> ++          diff /= ffmpegdec->last_frames;
> ++
> ++        GST_LOG_OBJECT (ffmpegdec, "estimated duration %" GST_TIME_FORMAT " %u",
> ++            GST_TIME_ARGS (diff), ffmpegdec->last_frames);
> ++
> ++        ffmpegdec->last_diff = diff;
> ++      }
> ++    }
> ++    ffmpegdec->last_in = in_timestamp;
> ++    ffmpegdec->last_frames = 0;
> ++  }
> ++
> ++  GST_LOG_OBJECT (ffmpegdec,
> ++      "Received new data of size %u, offset:%" G_GUINT64_FORMAT ", ts:%"
> ++      GST_TIME_FORMAT ", dur:%" GST_TIME_FORMAT ", info %d",
> ++      GST_BUFFER_SIZE (inbuf), GST_BUFFER_OFFSET (inbuf),
> ++      GST_TIME_ARGS (in_timestamp), GST_TIME_ARGS (in_duration), in_info->idx);
> ++
> ++  /* workarounds, functions write to buffers:
> ++   *  libavcodec/svq1.c:svq1_decode_frame writes to the given buffer.
> ++   *  libavcodec/svq3.c:svq3_decode_slice_header too.
> ++   * ffmpeg devs know about it and will fix it (they said). */
> ++  if (oclass->in_plugin->id == CODEC_ID_SVQ1 ||
> ++      oclass->in_plugin->id == CODEC_ID_SVQ3) {
> ++    inbuf = gst_buffer_make_writable (inbuf);
> ++  }
> ++
> ++  bdata = GST_BUFFER_DATA (inbuf);
> ++  bsize = GST_BUFFER_SIZE (inbuf);
> ++
> ++  if (ffmpegdec->do_padding) {
> ++    /* add padding */
> ++    if (ffmpegdec->padded_size < bsize + FF_INPUT_BUFFER_PADDING_SIZE) {
> ++      ffmpegdec->padded_size = bsize + FF_INPUT_BUFFER_PADDING_SIZE;
> ++      ffmpegdec->padded = g_realloc (ffmpegdec->padded, ffmpegdec->padded_size);
> ++      GST_LOG_OBJECT (ffmpegdec, "resized padding buffer to %d",
> ++          ffmpegdec->padded_size);
> ++    }
> ++    memcpy (ffmpegdec->padded, bdata, bsize);
> ++    memset (ffmpegdec->padded + bsize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
> ++
> ++    bdata = ffmpegdec->padded;
> ++  }
> ++
> ++  do {
> ++    guint8 tmp_padding[FF_INPUT_BUFFER_PADDING_SIZE];
> ++
> ++    /* parse, if at all possible */
> ++    if (ffmpegdec->pctx) {
> ++      gint res;
> ++
> ++      GST_LOG_OBJECT (ffmpegdec,
> ++          "Calling av_parser_parse2 with offset %" G_GINT64_FORMAT ", ts:%"
> ++          GST_TIME_FORMAT " size %d", in_offset, GST_TIME_ARGS (in_timestamp),
> ++          bsize);
> ++
> ++      /* feed the parser. We pass the timestamp info so that we can recover all
> ++       * info again later */
> ++      res = av_parser_parse2 (ffmpegdec->pctx, ffmpegdec->context,
> ++          &data, &size, bdata, bsize, in_info->idx, in_info->idx, in_offset);
> ++
> ++      GST_LOG_OBJECT (ffmpegdec,
> ++          "parser returned res %d and size %d, id %" G_GINT64_FORMAT, res, size,
> ++          ffmpegdec->pctx->pts);
> ++
> ++      /* store pts for decoding */
> ++      if (ffmpegdec->pctx->pts != AV_NOPTS_VALUE && ffmpegdec->pctx->pts != -1)
> ++        dec_info = gst_ts_info_get (ffmpegdec, ffmpegdec->pctx->pts);
> ++      else {
> ++        /* ffmpeg sometimes loses track after a flush, help it by feeding a
> ++         * valid start time */
> ++        ffmpegdec->pctx->pts = in_info->idx;
> ++        ffmpegdec->pctx->dts = in_info->idx;
> ++        dec_info = in_info;
> ++      }
> ++
> ++      GST_LOG_OBJECT (ffmpegdec, "consuming %d bytes. id %d", size,
> ++          dec_info->idx);
> ++
> ++      if (res) {
> ++        /* there is output, set pointers for next round. */
> ++        bsize -= res;
> ++        bdata += res;
> ++      } else {
> ++        /* Parser did not consume any data, make sure we don't clear the
> ++         * timestamp for the next round */
> ++        ffmpegdec->clear_ts = FALSE;
> ++      }
> ++
> ++      /* if there is no output, we must break and wait for more data. also the
> ++       * timestamp in the context is not updated. */
> ++      if (size == 0) {
> ++        if (bsize > 0)
> ++          continue;
> ++        else
> ++          break;
> ++      }
> ++    } else {
> ++      data = bdata;
> ++      size = bsize;
> ++
> ++      dec_info = in_info;
> ++    }
> ++
> ++    if (ffmpegdec->do_padding) {
> ++      /* add temporary padding */
> ++      memcpy (tmp_padding, data + size, FF_INPUT_BUFFER_PADDING_SIZE);
> ++      memset (data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
> ++    }
> ++
> ++    /* decode a frame of audio/video now */
> ++    len =
> ++        gst_ffmpegdec_frame (ffmpegdec, data, size, &have_data, dec_info, &ret);
> ++
> ++    if (ffmpegdec->do_padding) {
> ++      memcpy (data + size, tmp_padding, FF_INPUT_BUFFER_PADDING_SIZE);
> ++    }
> ++
> ++    if (ret != GST_FLOW_OK) {
> ++      GST_LOG_OBJECT (ffmpegdec, "breaking because of flow ret %s",
> ++          gst_flow_get_name (ret));
> ++      /* bad flow retun, make sure we discard all data and exit */
> ++      bsize = 0;
> ++      break;
> ++    }
> ++    if (!ffmpegdec->pctx) {
> ++      if (len == 0 && !have_data) {
> ++        /* nothing was decoded, this could be because no data was available or
> ++         * because we were skipping frames.
> ++         * If we have no context we must exit and wait for more data, we keep the
> ++         * data we tried. */
> ++        GST_LOG_OBJECT (ffmpegdec, "Decoding didn't return any data, breaking");
> ++        break;
> ++      } else if (len < 0) {
> ++        /* a decoding error happened, we must break and try again with next data. */
> ++        GST_LOG_OBJECT (ffmpegdec, "Decoding error, breaking");
> ++        bsize = 0;
> ++        break;
> ++      }
> ++      /* prepare for the next round, for codecs with a context we did this
> ++       * already when using the parser. */
> ++      bsize -= len;
> ++      bdata += len;
> ++    } else {
> ++      if (len == 0) {
> ++        /* nothing was decoded, this could be because no data was available or
> ++         * because we were skipping frames. Since we have a parser we can
> ++         * continue with the next frame */
> ++        GST_LOG_OBJECT (ffmpegdec,
> ++            "Decoding didn't return any data, trying next");
> ++      } else if (len < 0) {
> ++        /* we have a context that will bring us to the next frame */
> ++        GST_LOG_OBJECT (ffmpegdec, "Decoding error, trying next");
> ++      }
> ++    }
> ++
> ++    /* make sure we don't use the same old timestamp for the next frame and let
> ++     * the interpollation take care of it. */
> ++    if (ffmpegdec->clear_ts) {
> ++      in_timestamp = GST_CLOCK_TIME_NONE;
> ++      in_duration = GST_CLOCK_TIME_NONE;
> ++      in_offset = GST_BUFFER_OFFSET_NONE;
> ++      in_info = GST_TS_INFO_NONE;
> ++    } else {
> ++      ffmpegdec->clear_ts = TRUE;
> ++    }
> ++    ffmpegdec->last_frames++;
> ++
> ++    GST_LOG_OBJECT (ffmpegdec, "Before (while bsize>0).  bsize:%d , bdata:%p",
> ++        bsize, bdata);
> ++  } while (bsize > 0);
> ++
> ++  /* keep left-over */
> ++  if (ffmpegdec->pctx && bsize > 0) {
> ++    in_timestamp = GST_BUFFER_TIMESTAMP (inbuf);
> ++    in_offset = GST_BUFFER_OFFSET (inbuf);
> ++
> ++    GST_LOG_OBJECT (ffmpegdec,
> ++        "Keeping %d bytes of data with offset %" G_GINT64_FORMAT ", timestamp %"
> ++        GST_TIME_FORMAT, bsize, in_offset, GST_TIME_ARGS (in_timestamp));
> ++
> ++    ffmpegdec->pcache = gst_buffer_create_sub (inbuf,
> ++        GST_BUFFER_SIZE (inbuf) - bsize, bsize);
> ++    /* we keep timestamp, even though all we really know is that the correct
> ++     * timestamp is not below the one from inbuf */
> ++    GST_BUFFER_TIMESTAMP (ffmpegdec->pcache) = in_timestamp;
> ++    GST_BUFFER_OFFSET (ffmpegdec->pcache) = in_offset;
> ++  } else if (bsize > 0) {
> ++    GST_DEBUG_OBJECT (ffmpegdec, "Dropping %d bytes of data", bsize);
> ++  }
> ++  gst_buffer_unref (inbuf);
> ++
> ++  return ret;
> ++
> ++  /* ERRORS */
> ++not_negotiated:
> ++  {
> ++    oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> ++    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
> ++        ("ffdec_%s: input format was not set before data start",
> ++            oclass->in_plugin->name));
> ++    gst_buffer_unref (inbuf);
> ++    return GST_FLOW_NOT_NEGOTIATED;
> ++  }
> ++}
> ++
> ++static GstStateChangeReturn
> ++gst_ffmpegdec_change_state (GstElement * element, GstStateChange transition)
> ++{
> ++  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) element;
> ++  GstStateChangeReturn ret;
> ++
> ++  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
> ++
> ++  switch (transition) {
> ++    case GST_STATE_CHANGE_PAUSED_TO_READY:
> ++      GST_OBJECT_LOCK (ffmpegdec);
> ++      gst_ffmpegdec_close (ffmpegdec);
> ++      GST_OBJECT_UNLOCK (ffmpegdec);
> ++      clear_queued (ffmpegdec);
> ++      g_free (ffmpegdec->padded);
> ++      ffmpegdec->padded = NULL;
> ++      ffmpegdec->padded_size = 0;
> ++      ffmpegdec->can_allocate_aligned = TRUE;
> ++      break;
> ++    default:
> ++      break;
> ++  }
> ++
> ++  return ret;
> ++}
> ++
> ++static void
> ++gst_ffmpegdec_set_property (GObject * object,
> ++    guint prop_id, const GValue * value, GParamSpec * pspec)
> ++{
> ++  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
> ++
> ++  switch (prop_id) {
> ++    case PROP_LOWRES:
> ++      ffmpegdec->lowres = ffmpegdec->context->lowres = g_value_get_enum (value);
> ++      break;
> ++    case PROP_SKIPFRAME:
> ++      ffmpegdec->skip_frame = ffmpegdec->context->skip_frame =
> ++          g_value_get_enum (value);
> ++      break;
> ++    case PROP_DIRECT_RENDERING:
> ++      ffmpegdec->direct_rendering = g_value_get_boolean (value);
> ++      break;
> ++    case PROP_DO_PADDING:
> ++      ffmpegdec->do_padding = g_value_get_boolean (value);
> ++      break;
> ++    case PROP_DEBUG_MV:
> ++      ffmpegdec->debug_mv = ffmpegdec->context->debug_mv =
> ++          g_value_get_boolean (value);
> ++      break;
> ++    case PROP_CROP:
> ++      ffmpegdec->crop = g_value_get_boolean (value);
> ++      break;
> ++    case PROP_MAX_THREADS:
> ++      ffmpegdec->max_threads = g_value_get_int (value);
> ++      break;
> ++    default:
> ++      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
> ++      break;
> ++  }
> ++}
> ++
> ++static void
> ++gst_ffmpegdec_get_property (GObject * object,
> ++    guint prop_id, GValue * value, GParamSpec * pspec)
> ++{
> ++  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
> ++
> ++  switch (prop_id) {
> ++    case PROP_LOWRES:
> ++      g_value_set_enum (value, ffmpegdec->context->lowres);
> ++      break;
> ++    case PROP_SKIPFRAME:
> ++      g_value_set_enum (value, ffmpegdec->context->skip_frame);
> ++      break;
> ++    case PROP_DIRECT_RENDERING:
> ++      g_value_set_boolean (value, ffmpegdec->direct_rendering);
> ++      break;
> ++    case PROP_DO_PADDING:
> ++      g_value_set_boolean (value, ffmpegdec->do_padding);
> ++      break;
> ++    case PROP_DEBUG_MV:
> ++      g_value_set_boolean (value, ffmpegdec->context->debug_mv);
> ++      break;
> ++    case PROP_CROP:
> ++      g_value_set_boolean (value, ffmpegdec->crop);
> ++      break;
> ++    case PROP_MAX_THREADS:
> ++      g_value_set_int (value, ffmpegdec->max_threads);
> ++      break;
> ++    default:
> ++      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
> ++      break;
> ++  }
> ++}
> ++
> ++gboolean
> ++gst_ffmpegdec_register (GstPlugin * plugin)
> ++{
> ++  GTypeInfo typeinfo = {
> ++    sizeof (GstFFMpegDecClass),
> ++    (GBaseInitFunc) gst_ffmpegdec_base_init,
> ++    NULL,
> ++    (GClassInitFunc) gst_ffmpegdec_class_init,
> ++    NULL,
> ++    NULL,
> ++    sizeof (GstFFMpegDec),
> ++    0,
> ++    (GInstanceInitFunc) gst_ffmpegdec_init,
> ++  };
> ++  GType type;
> ++  AVCodec *in_plugin;
> ++  gint rank;
> ++
> ++  in_plugin = av_codec_next (NULL);
> ++
> ++  GST_LOG ("Registering decoders");
> ++
> ++  while (in_plugin) {
> ++    gchar *type_name;
> ++    gchar *plugin_name;
> ++
> ++    /* only decoders */
> ++    if (!in_plugin->decode) {
> ++      goto next;
> ++    }
> ++
> ++    /* no quasi-codecs, please */
> ++    if (in_plugin->id == CODEC_ID_RAWVIDEO ||
> ++        in_plugin->id == CODEC_ID_V210 ||
> ++        in_plugin->id == CODEC_ID_V210X ||
> ++        in_plugin->id == CODEC_ID_R210 ||
> ++        (in_plugin->id >= CODEC_ID_PCM_S16LE &&
> ++            in_plugin->id <= CODEC_ID_PCM_BLURAY)) {
> ++      goto next;
> ++    }
> ++
> ++    /* No decoders depending on external libraries (we don't build them, but
> ++     * people who build against an external ffmpeg might have them.
> ++     * We have native gstreamer plugins for all of those libraries anyway. */
> ++    if (!strncmp (in_plugin->name, "lib", 3)) {
> ++      GST_DEBUG
> ++          ("Not using external library decoder %s. Use the gstreamer-native ones instead.",
> ++          in_plugin->name);
> ++      goto next;
> ++    }
> ++
> ++    /* No vdpau plugins until we can figure out how to properly use them
> ++     * outside of ffmpeg. */
> ++    if (g_str_has_suffix (in_plugin->name, "_vdpau")) {
> ++      GST_DEBUG
> ++          ("Ignoring VDPAU decoder %s. We can't handle this outside of ffmpeg",
> ++          in_plugin->name);
> ++      goto next;
> ++    }
> ++
> ++    if (g_str_has_suffix (in_plugin->name, "_xvmc")) {
> ++      GST_DEBUG
> ++          ("Ignoring XVMC decoder %s. We can't handle this outside of ffmpeg",
> ++          in_plugin->name);
> ++      goto next;
> ++    }
> ++
> ++    GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name);
> ++
> ++    /* no codecs for which we're GUARANTEED to have better alternatives */
> ++    /* MPEG1VIDEO : the mpeg2video decoder is preferred */
> ++    /* MP1 : Use MP3 for decoding */
> ++    /* MP2 : Use MP3 for decoding */
> ++    /* Theora: Use libtheora based theoradec */
> ++    if (!strcmp (in_plugin->name, "gif") ||
> ++        !strcmp (in_plugin->name, "vorbis") ||
> ++        !strcmp (in_plugin->name, "theora") ||
> ++        !strcmp (in_plugin->name, "mpeg1video") ||
> ++        !strcmp (in_plugin->name, "wavpack") ||
> ++        !strcmp (in_plugin->name, "mp1") ||
> ++        !strcmp (in_plugin->name, "mp2") ||
> ++        !strcmp (in_plugin->name, "libfaad") ||
> ++        !strcmp (in_plugin->name, "mpeg4aac") ||
> ++        !strcmp (in_plugin->name, "ass") ||
> ++        !strcmp (in_plugin->name, "srt") ||
> ++        !strcmp (in_plugin->name, "pgssub") ||
> ++        !strcmp (in_plugin->name, "dvdsub") ||
> ++        !strcmp (in_plugin->name, "dvbsub")) {
> ++      GST_LOG ("Ignoring decoder %s", in_plugin->name);
> ++      goto next;
> ++    }
> ++
> ++    /* construct the type */
> ++    plugin_name = g_strdup ((gchar *) in_plugin->name);
> ++    g_strdelimit (plugin_name, NULL, '_');
> ++    type_name = g_strdup_printf ("ffdec_%s", plugin_name);
> ++    g_free (plugin_name);
> ++
> ++    type = g_type_from_name (type_name);
> ++
> ++    if (!type) {
> ++      /* create the gtype now */
> ++      type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
> ++      g_type_set_qdata (type, GST_FFDEC_PARAMS_QDATA, (gpointer) in_plugin);
> ++    }
> ++
> ++    /* (Ronald) MPEG-4 gets a higher priority because it has been well-
> ++     * tested and by far outperforms divxdec/xviddec - so we prefer it.
> ++     * msmpeg4v3 same, as it outperforms divxdec for divx3 playback.
> ++     * VC1/WMV3 are not working and thus unpreferred for now. */
> ++    switch (in_plugin->id) {
> ++      case CODEC_ID_MPEG4:
> ++      case CODEC_ID_MSMPEG4V3:
> ++      case CODEC_ID_H264:
> ++      case CODEC_ID_RA_144:
> ++      case CODEC_ID_RA_288:
> ++      case CODEC_ID_RV10:
> ++      case CODEC_ID_RV20:
> ++      case CODEC_ID_RV30:
> ++      case CODEC_ID_RV40:
> ++      case CODEC_ID_COOK:
> ++        rank = GST_RANK_SECONDARY;
> ++        break;
> ++        /* DVVIDEO: we have a good dv decoder, fast on both ppc as well as x86.
> ++         * They say libdv's quality is better though. leave as secondary.
> ++         * note: if you change this, see the code in gstdv.c in good/ext/dv.
> ++         *
> ++         * SIPR: decoder should have a higher rank than realaudiodec.
> ++         */
> ++      case CODEC_ID_DVVIDEO:
> ++      case CODEC_ID_SIPR:
> ++        rank = GST_RANK_SECONDARY;
> ++        break;
> ++      case CODEC_ID_MP3:
> ++        rank = GST_RANK_NONE;
> ++        break;
> ++        /* TEMPORARILY DISABLING AC3/EAC3/DTS for 0.10.12 release
> ++         * due to downmixing failure.
> ++         * See Bug #608892 for more details */
> ++      case CODEC_ID_EAC3:
> ++      case CODEC_ID_AC3:
> ++      case CODEC_ID_DTS:
> ++        rank = GST_RANK_NONE;
> ++        break;
> ++      default:
> ++        rank = GST_RANK_MARGINAL;
> ++        break;
> ++    }
> ++    if (!gst_element_register (plugin, type_name, rank, type)) {
> ++      g_warning ("Failed to register %s", type_name);
> ++      g_free (type_name);
> ++      return FALSE;
> ++    }
> ++
> ++    g_free (type_name);
> ++
> ++  next:
> ++    in_plugin = av_codec_next (in_plugin);
> ++  }
> ++
> ++  GST_LOG ("Finished Registering decoders");
> ++
> ++  return TRUE;
> ++}
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.rej gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.rej
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.rej	1970-01-01 01:00:00.000000000 +0100
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.rej	2014-08-08 15:26:38.471858652 +0200
> +@@ -0,0 +1,11 @@
> ++--- ext/ffmpeg/gstffmpegdec.c
> +++++ ext/ffmpeg/gstffmpegdec.c
> ++@@ -1565,7 +1564,7 @@
> ++         gst_message_new_latency (GST_OBJECT_CAST (ffmpegdec)));
> ++   }
> ++
> ++-  is_itype = (ffmpegdec->picture->pict_type == FF_I_TYPE);
> +++  is_itype = (ffmpegdec->picture->pict_type == AV_PICTURE_TYPE_I);
> ++   is_reference = (ffmpegdec->picture->reference == 1);
> ++
> ++   iskeyframe = (is_itype || is_reference || ffmpegdec->picture->key_frame)
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdemux.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdemux.c
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdemux.c	2011-07-13 11:07:28.000000000 +0200
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdemux.c	2014-08-08 15:26:07.874857555 +0200
> +@@ -343,8 +343,11 @@
> +   demux->audiopads = 0;
> +
> +   /* close demuxer context from ffmpeg */
> +-  av_close_input_file (demux->context);
> +-  demux->context = NULL;
> ++  if (demux->seekable)
> ++    gst_ffmpegdata_close (demux->context->pb);
> ++  else
> ++    gst_ffmpeg_pipe_close (demux->context->pb);
> ++  avformat_close_input (&demux->context);
> +
> +   GST_OBJECT_LOCK (demux);
> +   demux->opened = FALSE;
> +@@ -1146,9 +1149,9 @@
> + static gboolean
> + gst_ffmpegdemux_open (GstFFMpegDemux * demux)
> + {
> ++  AVIOContext *iocontext = NULL;
> +   GstFFMpegDemuxClass *oclass =
> +       (GstFFMpegDemuxClass *) G_OBJECT_GET_CLASS (demux);
> +-  gchar *location;
> +   gint res, n_streams, i;
> + #if 0
> +   /* Re-enable once converted to new AVMetaData API
> +@@ -1164,15 +1167,14 @@
> +
> +   /* open via our input protocol hack */
> +   if (demux->seekable)
> +-    location = g_strdup_printf ("gstreamer://%p", demux->sinkpad);
> ++    res = gst_ffmpegdata_open (demux->sinkpad, AVIO_FLAG_READ, &iocontext);
> +   else
> +-    location = g_strdup_printf ("gstpipe://%p", &demux->ffpipe);
> +-  GST_DEBUG_OBJECT (demux, "about to call av_open_input_file %s", location);
> ++    res = gst_ffmpeg_pipe_open (&demux->ffpipe, AVIO_FLAG_READ, &iocontext);
> +
> +-  res = av_open_input_file (&demux->context, location,
> +-      oclass->in_plugin, 0, NULL);
> ++  demux->context = avformat_alloc_context ();
> ++  demux->context->pb = iocontext;
> ++  res = avformat_open_input (&demux->context, NULL, oclass->in_plugin, NULL);
> +
> +-  g_free (location);
> +   GST_DEBUG_OBJECT (demux, "av_open_input returned %d", res);
> +   if (res < 0)
> +     goto open_failed;
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegenc.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegenc.c
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegenc.c	2011-10-31 11:14:03.000000000 +0100
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegenc.c	2014-08-08 15:32:18.608870847 +0200
> +@@ -770,7 +770,7 @@
> +   GST_OBJECT_UNLOCK (ffmpegenc);
> +
> +   if (force_keyframe)
> +-    ffmpegenc->picture->pict_type = FF_I_TYPE;
> ++    ffmpegenc->picture->pict_type = AV_PICTURE_TYPE_I;
> +
> +   frame_size = gst_ffmpeg_avpicture_fill ((AVPicture *) ffmpegenc->picture,
> +       GST_BUFFER_DATA (inbuf),
> +@@ -1136,7 +1136,7 @@
> +       const GstStructure *s;
> +       s = gst_event_get_structure (event);
> +       if (gst_structure_has_name (s, "GstForceKeyUnit")) {
> +-        ffmpegenc->picture->pict_type = FF_I_TYPE;
> ++        ffmpegenc->picture->pict_type = AV_PICTURE_TYPE_I;
> +       }
> +       break;
> +     }
> +@@ -1339,7 +1339,7 @@
> +     }
> +
> +     /* only encoders */
> +-    if (!in_plugin->encode) {
> ++    if (!av_codec_is_encoder (in_plugin)) {
> +       goto next;
> +     }
> +
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c	2011-07-13 11:07:28.000000000 +0200
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c	2014-08-08 15:26:07.874857555 +0200
> +@@ -24,8 +24,10 @@
> + #include <string.h>
> + #ifdef HAVE_FFMPEG_UNINSTALLED
> + #include <avformat.h>
> ++#include <opt.h>
> + #else
> + #include <libavformat/avformat.h>
> ++#include <libavutil/opt.h>
> + #endif
> +
> + #include <gst/gst.h>
> +@@ -336,9 +338,6 @@
> +   ffmpegmux->context = g_new0 (AVFormatContext, 1);
> +   ffmpegmux->context->oformat = oclass->in_plugin;
> +   ffmpegmux->context->nb_streams = 0;
> +-  g_snprintf (ffmpegmux->context->filename,
> +-      sizeof (ffmpegmux->context->filename),
> +-      "gstreamer://%p", ffmpegmux->srcpad);
> +   ffmpegmux->opened = FALSE;
> +
> +   ffmpegmux->videopads = 0;
> +@@ -450,10 +449,10 @@
> +   gst_element_add_pad (element, pad);
> +
> +   /* AVStream needs to be created */
> +-  st = av_new_stream (ffmpegmux->context, collect_pad->padnum);
> ++  st = avformat_new_stream (ffmpegmux->context, NULL);
> ++  st->id = collect_pad->padnum;
> +   st->codec->codec_type = type;
> +   st->codec->codec_id = CODEC_ID_NONE;  /* this is a check afterwards */
> +-  st->stream_copy = 1;          /* we're not the actual encoder */
> +   st->codec->bit_rate = bitrate;
> +   st->codec->frame_size = framesize;
> +   /* we fill in codec during capsnego */
> +@@ -485,7 +484,7 @@
> +   collect_pad = (GstFFMpegMuxPad *) gst_pad_get_element_private (pad);
> +
> +   st = ffmpegmux->context->streams[collect_pad->padnum];
> +-  ffmpegmux->context->preload = ffmpegmux->preload;
> ++  av_opt_set_int (&ffmpegmux->context, "preload", ffmpegmux->preload, 0);
> +   ffmpegmux->context->max_delay = ffmpegmux->max_delay;
> +
> +   /* for the format-specific guesses, we'll go to
> +@@ -552,7 +551,7 @@
> +
> +   /* open "file" (gstreamer protocol to next element) */
> +   if (!ffmpegmux->opened) {
> +-    int open_flags = URL_WRONLY;
> ++    int open_flags = AVIO_FLAG_WRITE;
> +
> +     /* we do need all streams to have started capsnego,
> +      * or things will go horribly wrong */
> +@@ -646,19 +645,13 @@
> +       open_flags |= GST_FFMPEG_URL_STREAMHEADER;
> +     }
> +
> +-    if (url_fopen (&ffmpegmux->context->pb,
> +-            ffmpegmux->context->filename, open_flags) < 0) {
> ++    if (gst_ffmpegdata_open (ffmpegmux->srcpad, open_flags,
> ++            &ffmpegmux->context->pb) < 0) {
> +       GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, TOO_LAZY, (NULL),
> +           ("Failed to open stream context in ffmux"));
> +       return GST_FLOW_ERROR;
> +     }
> +
> +-    if (av_set_parameters (ffmpegmux->context, NULL) < 0) {
> +-      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, INIT, (NULL),
> +-          ("Failed to initialize muxer"));
> +-      return GST_FLOW_ERROR;
> +-    }
> +-
> +     /* now open the mux format */
> +     if (av_write_header (ffmpegmux->context) < 0) {
> +       GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, SETTINGS, (NULL),
> +@@ -670,7 +663,7 @@
> +     ffmpegmux->opened = TRUE;
> +
> +     /* flush the header so it will be used as streamheader */
> +-    put_flush_packet (ffmpegmux->context->pb);
> ++    avio_flush (ffmpegmux->context->pb);
> +   }
> +
> +   /* take the one with earliest timestamp,
> +@@ -770,8 +763,8 @@
> +     /* close down */
> +     av_write_trailer (ffmpegmux->context);
> +     ffmpegmux->opened = FALSE;
> +-    put_flush_packet (ffmpegmux->context->pb);
> +-    url_fclose (ffmpegmux->context->pb);
> ++    avio_flush (ffmpegmux->context->pb);
> ++    gst_ffmpegdata_close (ffmpegmux->context->pb);
> +     gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_eos ());
> +     return GST_FLOW_UNEXPECTED;
> +   }
> +@@ -795,6 +788,10 @@
> +       break;
> +     case GST_STATE_CHANGE_PAUSED_TO_READY:
> +       gst_collect_pads_stop (ffmpegmux->collect);
> ++      if (ffmpegmux->opened) {
> ++        ffmpegmux->opened = FALSE;
> ++        gst_ffmpegdata_close (ffmpegmux->context->pb);
> ++      }
> +       break;
> +     default:
> +       break;
> +@@ -809,7 +806,7 @@
> +       gst_tag_setter_reset_tags (GST_TAG_SETTER (ffmpegmux));
> +       if (ffmpegmux->opened) {
> +         ffmpegmux->opened = FALSE;
> +-        url_fclose (ffmpegmux->context->pb);
> ++        avio_close (ffmpegmux->context->pb);
> +       }
> +       break;
> +     case GST_STATE_CHANGE_READY_TO_NULL:
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c.orig
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c.orig	1970-01-01 01:00:00.000000000 +0100
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c.orig	2011-07-13 11:07:28.000000000 +0200
> +@@ -0,0 +1,970 @@
> ++/* 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>
> ++#ifdef HAVE_FFMPEG_UNINSTALLED
> ++#include <avformat.h>
> ++#else
> ++#include <libavformat/avformat.h>
> ++#endif
> ++
> ++#include <gst/gst.h>
> ++#include <gst/base/gstcollectpads.h>
> ++
> ++#include "gstffmpeg.h"
> ++#include "gstffmpegcodecmap.h"
> ++#include "gstffmpegutils.h"
> ++
> ++typedef struct _GstFFMpegMux GstFFMpegMux;
> ++typedef struct _GstFFMpegMuxPad GstFFMpegMuxPad;
> ++
> ++struct _GstFFMpegMuxPad
> ++{
> ++  GstCollectData collect;       /* we extend the CollectData */
> ++
> ++  gint padnum;
> ++};
> ++
> ++struct _GstFFMpegMux
> ++{
> ++  GstElement element;
> ++
> ++  GstCollectPads *collect;
> ++  /* We need to keep track of our pads, so we do so here. */
> ++  GstPad *srcpad;
> ++
> ++  AVFormatContext *context;
> ++  gboolean opened;
> ++
> ++  gint videopads, audiopads;
> ++
> ++  /*< private > */
> ++  /* event_function is the collectpads default eventfunction */
> ++  GstPadEventFunction event_function;
> ++  int preload;
> ++  int max_delay;
> ++};
> ++
> ++typedef struct _GstFFMpegMuxClass GstFFMpegMuxClass;
> ++
> ++struct _GstFFMpegMuxClass
> ++{
> ++  GstElementClass parent_class;
> ++
> ++  AVOutputFormat *in_plugin;
> ++};
> ++
> ++#define GST_TYPE_FFMPEGMUX \
> ++  (gst_ffmpegdec_get_type())
> ++#define GST_FFMPEGMUX(obj) \
> ++  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGMUX,GstFFMpegMux))
> ++#define GST_FFMPEGMUX_CLASS(klass) \
> ++  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGMUX,GstFFMpegMuxClass))
> ++#define GST_IS_FFMPEGMUX(obj) \
> ++  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGMUX))
> ++#define GST_IS_FFMPEGMUX_CLASS(klass) \
> ++  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGMUX))
> ++
> ++enum
> ++{
> ++  /* FILL ME */
> ++  LAST_SIGNAL
> ++};
> ++
> ++enum
> ++{
> ++  ARG_0,
> ++  /* FILL ME */
> ++};
> ++
> ++enum
> ++{
> ++  PROP_0,
> ++  PROP_PRELOAD,
> ++  PROP_MAXDELAY
> ++};
> ++
> ++/* A number of function prototypes are given so we can refer to them later. */
> ++static void gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass);
> ++static void gst_ffmpegmux_base_init (gpointer g_class);
> ++static void gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux,
> ++    GstFFMpegMuxClass * g_class);
> ++static void gst_ffmpegmux_finalize (GObject * object);
> ++
> ++static gboolean gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps);
> ++static GstPad *gst_ffmpegmux_request_new_pad (GstElement * element,
> ++    GstPadTemplate * templ, const gchar * name);
> ++static GstFlowReturn gst_ffmpegmux_collected (GstCollectPads * pads,
> ++    gpointer user_data);
> ++
> ++static gboolean gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event);
> ++
> ++static GstStateChangeReturn gst_ffmpegmux_change_state (GstElement * element,
> ++    GstStateChange transition);
> ++
> ++static void gst_ffmpegmux_set_property (GObject * object, guint prop_id,
> ++    const GValue * value, GParamSpec * pspec);
> ++static void gst_ffmpegmux_get_property (GObject * object, guint prop_id,
> ++    GValue * value, GParamSpec * pspec);
> ++
> ++static GstCaps *gst_ffmpegmux_get_id_caps (enum CodecID *id_list);
> ++static void gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * caps,
> ++    const gchar * field, guint num, const gint * values);
> ++
> ++#define GST_FFMUX_PARAMS_QDATA g_quark_from_static_string("ffmux-params")
> ++
> ++static GstElementClass *parent_class = NULL;
> ++
> ++/*static guint gst_ffmpegmux_signals[LAST_SIGNAL] = { 0 }; */
> ++
> ++typedef struct
> ++{
> ++  const char *name;
> ++  const char *replacement;
> ++} GstFFMpegMuxReplacement;
> ++
> ++static const char *
> ++gst_ffmpegmux_get_replacement (const char *name)
> ++{
> ++  static const GstFFMpegMuxReplacement blacklist[] = {
> ++    {"avi", "avimux"},
> ++    {"matroska", "matroskamux"},
> ++    {"mov", "qtmux"},
> ++    {"mpegts", "mpegtsmux"},
> ++    {"mp4", "mp4mux"},
> ++    {"mpjpeg", "multipartmux"},
> ++    {"ogg", "oggmux"},
> ++    {"wav", "wavenc"},
> ++    {"webm", "webmmux"},
> ++    {"mxf", "mxfmux"},
> ++    {"3gp", "gppmux"},
> ++    {"yuv4mpegpipe", "y4menc"},
> ++    {"aiff", "aiffmux"},
> ++    {"adts", "aacparse"},
> ++    {"asf", "asfmux"},
> ++    {"asf_stream", "asfmux"},
> ++    {"flv", "flvmux"},
> ++    {"mp3", "id3v2mux"},
> ++    {"mp2", "id3v2mux"}
> ++  };
> ++  int i;
> ++
> ++  for (i = 0; i < sizeof (blacklist) / sizeof (blacklist[0]); i++) {
> ++    if (strcmp (blacklist[i].name, name) == 0) {
> ++      return blacklist[i].replacement;
> ++    }
> ++  }
> ++
> ++  return NULL;
> ++}
> ++
> ++static gboolean
> ++gst_ffmpegmux_is_formatter (const char *name)
> ++{
> ++  static const char *replace[] = {
> ++    "mp2", "mp3", NULL
> ++  };
> ++  int i;
> ++
> ++  for (i = 0; replace[i]; i++)
> ++    if (strcmp (replace[i], name) == 0)
> ++      return TRUE;
> ++  return FALSE;
> ++}
> ++
> ++static void
> ++gst_ffmpegmux_base_init (gpointer g_class)
> ++{
> ++  GstFFMpegMuxClass *klass = (GstFFMpegMuxClass *) g_class;
> ++  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
> ++  GstPadTemplate *videosinktempl, *audiosinktempl, *srctempl;
> ++  AVOutputFormat *in_plugin;
> ++  GstCaps *srccaps, *audiosinkcaps, *videosinkcaps;
> ++  enum CodecID *video_ids = NULL, *audio_ids = NULL;
> ++  gchar *longname, *description;
> ++  const char *replacement;
> ++  gboolean is_formatter;
> ++
> ++  in_plugin =
> ++      (AVOutputFormat *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
> ++      GST_FFMUX_PARAMS_QDATA);
> ++  g_assert (in_plugin != NULL);
> ++
> ++  /* construct the element details struct */
> ++  replacement = gst_ffmpegmux_get_replacement (in_plugin->name);
> ++  is_formatter = gst_ffmpegmux_is_formatter (in_plugin->name);
> ++  if (replacement != NULL) {
> ++    longname =
> ++        g_strdup_printf ("FFmpeg %s %s (not recommended, use %s instead)",
> ++        in_plugin->long_name, is_formatter ? "formatter" : "muxer",
> ++        replacement);
> ++    description =
> ++        g_strdup_printf ("FFmpeg %s %s (not recommended, use %s instead)",
> ++        in_plugin->long_name, is_formatter ? "formatter" : "muxer",
> ++        replacement);
> ++  } else {
> ++    longname = g_strdup_printf ("FFmpeg %s %s", in_plugin->long_name,
> ++        is_formatter ? "formatter" : "muxer");
> ++    description = g_strdup_printf ("FFmpeg %s %s", in_plugin->long_name,
> ++        is_formatter ? "formatter" : "muxer");
> ++  }
> ++  gst_element_class_set_details_simple (element_class, longname,
> ++      is_formatter ? "Formatter/Metadata" : "Codec/Muxer", description,
> ++      "Wim Taymans <wim.taymans@chello.be>, "
> ++      "Ronald Bultje <rbultje@ronald.bitfreak.net>");
> ++  g_free (longname);
> ++  g_free (description);
> ++
> ++  /* Try to find the caps that belongs here */
> ++  srccaps = gst_ffmpeg_formatid_to_caps (in_plugin->name);
> ++  if (!srccaps) {
> ++    GST_DEBUG ("Couldn't get source caps for muxer '%s', skipping format",
> ++        in_plugin->name);
> ++    goto beach;
> ++  }
> ++
> ++  if (!gst_ffmpeg_formatid_get_codecids (in_plugin->name,
> ++          &video_ids, &audio_ids, in_plugin)) {
> ++    gst_caps_unref (srccaps);
> ++    GST_DEBUG
> ++        ("Couldn't get sink caps for muxer '%s'. Most likely because no input format mapping exists.",
> ++        in_plugin->name);
> ++    goto beach;
> ++  }
> ++
> ++  videosinkcaps = video_ids ? gst_ffmpegmux_get_id_caps (video_ids) : NULL;
> ++  audiosinkcaps = audio_ids ? gst_ffmpegmux_get_id_caps (audio_ids) : NULL;
> ++
> ++  /* fix up allowed caps for some muxers */
> ++  /* FIXME : This should be in gstffmpegcodecmap.c ! */
> ++  if (strcmp (in_plugin->name, "flv") == 0) {
> ++    const gint rates[] = { 44100, 22050, 11025 };
> ++
> ++    gst_ffmpeg_mux_simple_caps_set_int_list (audiosinkcaps, "rate", 3, rates);
> ++  } else if (strcmp (in_plugin->name, "gif") == 0) {
> ++    if (videosinkcaps)
> ++      gst_caps_unref (videosinkcaps);
> ++
> ++    videosinkcaps =
> ++        gst_caps_from_string ("video/x-raw-rgb, bpp=(int)24, depth=(int)24");
> ++  }
> ++
> ++  /* pad templates */
> ++  srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
> ++  gst_element_class_add_pad_template (element_class, srctempl);
> ++
> ++  if (audiosinkcaps) {
> ++    audiosinktempl = gst_pad_template_new ("audio_%d",
> ++        GST_PAD_SINK, GST_PAD_REQUEST, audiosinkcaps);
> ++    gst_element_class_add_pad_template (element_class, audiosinktempl);
> ++  }
> ++
> ++  if (videosinkcaps) {
> ++    videosinktempl = gst_pad_template_new ("video_%d",
> ++        GST_PAD_SINK, GST_PAD_REQUEST, videosinkcaps);
> ++    gst_element_class_add_pad_template (element_class, videosinktempl);
> ++  }
> ++
> ++beach:
> ++  klass->in_plugin = in_plugin;
> ++}
> ++
> ++static void
> ++gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass)
> ++{
> ++  GObjectClass *gobject_class;
> ++  GstElementClass *gstelement_class;
> ++
> ++  gobject_class = (GObjectClass *) klass;
> ++  gstelement_class = (GstElementClass *) klass;
> ++
> ++  parent_class = g_type_class_peek_parent (klass);
> ++
> ++  gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_ffmpegmux_set_property);
> ++  gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_ffmpegmux_get_property);
> ++
> ++  g_object_class_install_property (gobject_class, PROP_PRELOAD,
> ++      g_param_spec_int ("preload", "preload",
> ++          "Set the initial demux-decode delay (in microseconds)", 0, G_MAXINT,
> ++          0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> ++
> ++  g_object_class_install_property (gobject_class, PROP_MAXDELAY,
> ++      g_param_spec_int ("maxdelay", "maxdelay",
> ++          "Set the maximum demux-decode delay (in microseconds)", 0, G_MAXINT,
> ++          0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> ++
> ++  gstelement_class->request_new_pad = gst_ffmpegmux_request_new_pad;
> ++  gstelement_class->change_state = gst_ffmpegmux_change_state;
> ++  gobject_class->finalize = gst_ffmpegmux_finalize;
> ++}
> ++
> ++static void
> ++gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux, GstFFMpegMuxClass * g_class)
> ++{
> ++  GstElementClass *klass = GST_ELEMENT_CLASS (g_class);
> ++  GstFFMpegMuxClass *oclass = (GstFFMpegMuxClass *) klass;
> ++  GstPadTemplate *templ = gst_element_class_get_pad_template (klass, "src");
> ++
> ++  ffmpegmux->srcpad = gst_pad_new_from_template (templ, "src");
> ++  gst_pad_set_caps (ffmpegmux->srcpad, gst_pad_template_get_caps (templ));
> ++  gst_element_add_pad (GST_ELEMENT (ffmpegmux), ffmpegmux->srcpad);
> ++
> ++  ffmpegmux->collect = gst_collect_pads_new ();
> ++  gst_collect_pads_set_function (ffmpegmux->collect,
> ++      (GstCollectPadsFunction) gst_ffmpegmux_collected, ffmpegmux);
> ++
> ++  ffmpegmux->context = g_new0 (AVFormatContext, 1);
> ++  ffmpegmux->context->oformat = oclass->in_plugin;
> ++  ffmpegmux->context->nb_streams = 0;
> ++  g_snprintf (ffmpegmux->context->filename,
> ++      sizeof (ffmpegmux->context->filename),
> ++      "gstreamer://%p", ffmpegmux->srcpad);
> ++  ffmpegmux->opened = FALSE;
> ++
> ++  ffmpegmux->videopads = 0;
> ++  ffmpegmux->audiopads = 0;
> ++  ffmpegmux->preload = 0;
> ++  ffmpegmux->max_delay = 0;
> ++}
> ++
> ++static void
> ++gst_ffmpegmux_set_property (GObject * object, guint prop_id,
> ++    const GValue * value, GParamSpec * pspec)
> ++{
> ++  GstFFMpegMux *src;
> ++
> ++  src = (GstFFMpegMux *) object;
> ++
> ++  switch (prop_id) {
> ++    case PROP_PRELOAD:
> ++      src->preload = g_value_get_int (value);
> ++      break;
> ++    case PROP_MAXDELAY:
> ++      src->max_delay = g_value_get_int (value);
> ++      break;
> ++    default:
> ++      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
> ++      break;
> ++  }
> ++}
> ++
> ++static void
> ++gst_ffmpegmux_get_property (GObject * object, guint prop_id, GValue * value,
> ++    GParamSpec * pspec)
> ++{
> ++  GstFFMpegMux *src;
> ++
> ++  src = (GstFFMpegMux *) object;
> ++
> ++  switch (prop_id) {
> ++    case PROP_PRELOAD:
> ++      g_value_set_int (value, src->preload);
> ++      break;
> ++    case PROP_MAXDELAY:
> ++      g_value_set_int (value, src->max_delay);
> ++      break;
> ++    default:
> ++      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
> ++      break;
> ++  }
> ++}
> ++
> ++
> ++static void
> ++gst_ffmpegmux_finalize (GObject * object)
> ++{
> ++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) object;
> ++
> ++  g_free (ffmpegmux->context);
> ++  gst_object_unref (ffmpegmux->collect);
> ++
> ++  if (G_OBJECT_CLASS (parent_class)->finalize)
> ++    G_OBJECT_CLASS (parent_class)->finalize (object);
> ++}
> ++
> ++static GstPad *
> ++gst_ffmpegmux_request_new_pad (GstElement * element,
> ++    GstPadTemplate * templ, const gchar * name)
> ++{
> ++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) element;
> ++  GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
> ++  GstFFMpegMuxPad *collect_pad;
> ++  gchar *padname;
> ++  GstPad *pad;
> ++  AVStream *st;
> ++  enum AVMediaType type;
> ++  gint bitrate = 0, framesize = 0;
> ++
> ++  g_return_val_if_fail (templ != NULL, NULL);
> ++  g_return_val_if_fail (templ->direction == GST_PAD_SINK, NULL);
> ++  g_return_val_if_fail (ffmpegmux->opened == FALSE, NULL);
> ++
> ++  /* figure out a name that *we* like */
> ++  if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
> ++    padname = g_strdup_printf ("video_%d", ffmpegmux->videopads++);
> ++    type = AVMEDIA_TYPE_VIDEO;
> ++    bitrate = 64 * 1024;
> ++    framesize = 1152;
> ++  } else if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
> ++    padname = g_strdup_printf ("audio_%d", ffmpegmux->audiopads++);
> ++    type = AVMEDIA_TYPE_AUDIO;
> ++    bitrate = 285 * 1024;
> ++  } else {
> ++    g_warning ("ffmux: unknown pad template!");
> ++    return NULL;
> ++  }
> ++
> ++  /* create pad */
> ++  pad = gst_pad_new_from_template (templ, padname);
> ++  collect_pad = (GstFFMpegMuxPad *)
> ++      gst_collect_pads_add_pad (ffmpegmux->collect, pad,
> ++      sizeof (GstFFMpegMuxPad));
> ++  collect_pad->padnum = ffmpegmux->context->nb_streams;
> ++
> ++  /* small hack to put our own event pad function and chain up to collect pad */
> ++  ffmpegmux->event_function = GST_PAD_EVENTFUNC (pad);
> ++  gst_pad_set_event_function (pad,
> ++      GST_DEBUG_FUNCPTR (gst_ffmpegmux_sink_event));
> ++
> ++  gst_pad_set_setcaps_function (pad, GST_DEBUG_FUNCPTR (gst_ffmpegmux_setcaps));
> ++  gst_element_add_pad (element, pad);
> ++
> ++  /* AVStream needs to be created */
> ++  st = av_new_stream (ffmpegmux->context, collect_pad->padnum);
> ++  st->codec->codec_type = type;
> ++  st->codec->codec_id = CODEC_ID_NONE;  /* this is a check afterwards */
> ++  st->stream_copy = 1;          /* we're not the actual encoder */
> ++  st->codec->bit_rate = bitrate;
> ++  st->codec->frame_size = framesize;
> ++  /* we fill in codec during capsnego */
> ++
> ++  /* we love debug output (c) (tm) (r) */
> ++  GST_DEBUG ("Created %s pad for ffmux_%s element",
> ++      padname, ((GstFFMpegMuxClass *) klass)->in_plugin->name);
> ++  g_free (padname);
> ++
> ++  return pad;
> ++}
> ++
> ++/**
> ++ * gst_ffmpegmux_setcaps
> ++ * @pad: #GstPad
> ++ * @caps: New caps.
> ++ *
> ++ * Set caps to pad.
> ++ *
> ++ * Returns: #TRUE on success.
> ++ */
> ++static gboolean
> ++gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps)
> ++{
> ++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (gst_pad_get_parent (pad));
> ++  GstFFMpegMuxPad *collect_pad;
> ++  AVStream *st;
> ++
> ++  collect_pad = (GstFFMpegMuxPad *) gst_pad_get_element_private (pad);
> ++
> ++  st = ffmpegmux->context->streams[collect_pad->padnum];
> ++  ffmpegmux->context->preload = ffmpegmux->preload;
> ++  ffmpegmux->context->max_delay = ffmpegmux->max_delay;
> ++
> ++  /* for the format-specific guesses, we'll go to
> ++   * our famous codec mapper */
> ++  if (gst_ffmpeg_caps_to_codecid (caps, st->codec) == CODEC_ID_NONE)
> ++    goto not_accepted;
> ++
> ++  /* copy over the aspect ratios, ffmpeg expects the stream aspect to match the
> ++   * codec aspect. */
> ++  st->sample_aspect_ratio = st->codec->sample_aspect_ratio;
> ++
> ++  GST_LOG_OBJECT (pad, "accepted caps %" GST_PTR_FORMAT, caps);
> ++  return TRUE;
> ++
> ++  /* ERRORS */
> ++not_accepted:
> ++  {
> ++    GST_LOG_OBJECT (pad, "rejecting caps %" GST_PTR_FORMAT, caps);
> ++    return FALSE;
> ++  }
> ++}
> ++
> ++
> ++static gboolean
> ++gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event)
> ++{
> ++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) gst_pad_get_parent (pad);
> ++  gboolean res = TRUE;
> ++
> ++  switch (GST_EVENT_TYPE (event)) {
> ++    case GST_EVENT_TAG:{
> ++      GstTagList *taglist;
> ++      GstTagSetter *setter = GST_TAG_SETTER (ffmpegmux);
> ++      const GstTagMergeMode mode = gst_tag_setter_get_tag_merge_mode (setter);
> ++
> ++      gst_event_parse_tag (event, &taglist);
> ++      gst_tag_setter_merge_tags (setter, taglist, mode);
> ++      break;
> ++    }
> ++    default:
> ++      break;
> ++  }
> ++
> ++  /* chaining up to collectpads default event function */
> ++  res = ffmpegmux->event_function (pad, event);
> ++
> ++  gst_object_unref (ffmpegmux);
> ++  return res;
> ++}
> ++
> ++static GstFlowReturn
> ++gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
> ++{
> ++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) user_data;
> ++  GSList *collected;
> ++  GstFFMpegMuxPad *best_pad;
> ++  GstClockTime best_time;
> ++#if 0
> ++  /* Re-enable once converted to new AVMetaData API
> ++   * See #566605
> ++   */
> ++  const GstTagList *tags;
> ++#endif
> ++
> ++  /* open "file" (gstreamer protocol to next element) */
> ++  if (!ffmpegmux->opened) {
> ++    int open_flags = URL_WRONLY;
> ++
> ++    /* we do need all streams to have started capsnego,
> ++     * or things will go horribly wrong */
> ++    for (collected = ffmpegmux->collect->data; collected;
> ++        collected = g_slist_next (collected)) {
> ++      GstFFMpegMuxPad *collect_pad = (GstFFMpegMuxPad *) collected->data;
> ++      AVStream *st = ffmpegmux->context->streams[collect_pad->padnum];
> ++
> ++      /* check whether the pad has successfully completed capsnego */
> ++      if (st->codec->codec_id == CODEC_ID_NONE) {
> ++        GST_ELEMENT_ERROR (ffmpegmux, CORE, NEGOTIATION, (NULL),
> ++            ("no caps set on stream %d (%s)", collect_pad->padnum,
> ++                (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ?
> ++                "video" : "audio"));
> ++        return GST_FLOW_ERROR;
> ++      }
> ++      /* set framerate for audio */
> ++      if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
> ++        switch (st->codec->codec_id) {
> ++          case CODEC_ID_PCM_S16LE:
> ++          case CODEC_ID_PCM_S16BE:
> ++          case CODEC_ID_PCM_U16LE:
> ++          case CODEC_ID_PCM_U16BE:
> ++          case CODEC_ID_PCM_S8:
> ++          case CODEC_ID_PCM_U8:
> ++            st->codec->frame_size = 1;
> ++            break;
> ++          default:
> ++          {
> ++            GstBuffer *buffer;
> ++
> ++            /* FIXME : This doesn't work for RAW AUDIO...
> ++             * in fact I'm wondering if it even works for any kind of audio... */
> ++            buffer = gst_collect_pads_peek (ffmpegmux->collect,
> ++                (GstCollectData *) collect_pad);
> ++            if (buffer) {
> ++              st->codec->frame_size =
> ++                  st->codec->sample_rate *
> ++                  GST_BUFFER_DURATION (buffer) / GST_SECOND;
> ++              gst_buffer_unref (buffer);
> ++            }
> ++          }
> ++        }
> ++      }
> ++    }
> ++
> ++#if 0
> ++    /* Re-enable once converted to new AVMetaData API
> ++     * See #566605
> ++     */
> ++
> ++    /* tags */
> ++    tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (ffmpegmux));
> ++    if (tags) {
> ++      gint i;
> ++      gchar *s;
> ++
> ++      /* get the interesting ones */
> ++      if (gst_tag_list_get_string (tags, GST_TAG_TITLE, &s)) {
> ++        strncpy (ffmpegmux->context->title, s,
> ++            sizeof (ffmpegmux->context->title));
> ++      }
> ++      if (gst_tag_list_get_string (tags, GST_TAG_ARTIST, &s)) {
> ++        strncpy (ffmpegmux->context->author, s,
> ++            sizeof (ffmpegmux->context->author));
> ++      }
> ++      if (gst_tag_list_get_string (tags, GST_TAG_COPYRIGHT, &s)) {
> ++        strncpy (ffmpegmux->context->copyright, s,
> ++            sizeof (ffmpegmux->context->copyright));
> ++      }
> ++      if (gst_tag_list_get_string (tags, GST_TAG_COMMENT, &s)) {
> ++        strncpy (ffmpegmux->context->comment, s,
> ++            sizeof (ffmpegmux->context->comment));
> ++      }
> ++      if (gst_tag_list_get_string (tags, GST_TAG_ALBUM, &s)) {
> ++        strncpy (ffmpegmux->context->album, s,
> ++            sizeof (ffmpegmux->context->album));
> ++      }
> ++      if (gst_tag_list_get_string (tags, GST_TAG_GENRE, &s)) {
> ++        strncpy (ffmpegmux->context->genre, s,
> ++            sizeof (ffmpegmux->context->genre));
> ++      }
> ++      if (gst_tag_list_get_int (tags, GST_TAG_TRACK_NUMBER, &i)) {
> ++        ffmpegmux->context->track = i;
> ++      }
> ++    }
> ++#endif
> ++
> ++    /* set the streamheader flag for gstffmpegprotocol if codec supports it */
> ++    if (!strcmp (ffmpegmux->context->oformat->name, "flv")) {
> ++      open_flags |= GST_FFMPEG_URL_STREAMHEADER;
> ++    }
> ++
> ++    if (url_fopen (&ffmpegmux->context->pb,
> ++            ffmpegmux->context->filename, open_flags) < 0) {
> ++      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, TOO_LAZY, (NULL),
> ++          ("Failed to open stream context in ffmux"));
> ++      return GST_FLOW_ERROR;
> ++    }
> ++
> ++    if (av_set_parameters (ffmpegmux->context, NULL) < 0) {
> ++      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, INIT, (NULL),
> ++          ("Failed to initialize muxer"));
> ++      return GST_FLOW_ERROR;
> ++    }
> ++
> ++    /* now open the mux format */
> ++    if (av_write_header (ffmpegmux->context) < 0) {
> ++      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, SETTINGS, (NULL),
> ++          ("Failed to write file header - check codec settings"));
> ++      return GST_FLOW_ERROR;
> ++    }
> ++
> ++    /* we're now opened */
> ++    ffmpegmux->opened = TRUE;
> ++
> ++    /* flush the header so it will be used as streamheader */
> ++    put_flush_packet (ffmpegmux->context->pb);
> ++  }
> ++
> ++  /* take the one with earliest timestamp,
> ++   * and push it forward */
> ++  best_pad = NULL;
> ++  best_time = GST_CLOCK_TIME_NONE;
> ++  for (collected = ffmpegmux->collect->data; collected;
> ++      collected = g_slist_next (collected)) {
> ++    GstFFMpegMuxPad *collect_pad = (GstFFMpegMuxPad *) collected->data;
> ++    GstBuffer *buffer = gst_collect_pads_peek (ffmpegmux->collect,
> ++        (GstCollectData *) collect_pad);
> ++
> ++    /* if there's no buffer, just continue */
> ++    if (buffer == NULL) {
> ++      continue;
> ++    }
> ++
> ++    /* if we have no buffer yet, just use the first one */
> ++    if (best_pad == NULL) {
> ++      best_pad = collect_pad;
> ++      best_time = GST_BUFFER_TIMESTAMP (buffer);
> ++      goto next_pad;
> ++    }
> ++
> ++    /* if we do have one, only use this one if it's older */
> ++    if (GST_BUFFER_TIMESTAMP (buffer) < best_time) {
> ++      best_time = GST_BUFFER_TIMESTAMP (buffer);
> ++      best_pad = collect_pad;
> ++    }
> ++
> ++  next_pad:
> ++    gst_buffer_unref (buffer);
> ++
> ++    /* Mux buffers with invalid timestamp first */
> ++    if (!GST_CLOCK_TIME_IS_VALID (best_time))
> ++      break;
> ++  }
> ++
> ++  /* now handle the buffer, or signal EOS if we have
> ++   * no buffers left */
> ++  if (best_pad != NULL) {
> ++    GstBuffer *buf;
> ++    AVPacket pkt;
> ++    gboolean need_free = FALSE;
> ++
> ++    /* push out current buffer */
> ++    buf = gst_collect_pads_pop (ffmpegmux->collect,
> ++        (GstCollectData *) best_pad);
> ++
> ++    ffmpegmux->context->streams[best_pad->padnum]->codec->frame_number++;
> ++
> ++    /* set time */
> ++    pkt.pts = gst_ffmpeg_time_gst_to_ff (GST_BUFFER_TIMESTAMP (buf),
> ++        ffmpegmux->context->streams[best_pad->padnum]->time_base);
> ++    pkt.dts = pkt.pts;
> ++
> ++    if (strcmp (ffmpegmux->context->oformat->name, "gif") == 0) {
> ++      AVStream *st = ffmpegmux->context->streams[best_pad->padnum];
> ++      AVPicture src, dst;
> ++
> ++      need_free = TRUE;
> ++      pkt.size = st->codec->width * st->codec->height * 3;
> ++      pkt.data = g_malloc (pkt.size);
> ++
> ++      dst.data[0] = pkt.data;
> ++      dst.data[1] = NULL;
> ++      dst.data[2] = NULL;
> ++      dst.linesize[0] = st->codec->width * 3;
> ++
> ++      gst_ffmpeg_avpicture_fill (&src, GST_BUFFER_DATA (buf),
> ++          PIX_FMT_RGB24, st->codec->width, st->codec->height);
> ++
> ++      av_picture_copy (&dst, &src, PIX_FMT_RGB24,
> ++          st->codec->width, st->codec->height);
> ++    } else {
> ++      pkt.data = GST_BUFFER_DATA (buf);
> ++      pkt.size = GST_BUFFER_SIZE (buf);
> ++    }
> ++
> ++    pkt.stream_index = best_pad->padnum;
> ++    pkt.flags = 0;
> ++
> ++    if (!GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT))
> ++      pkt.flags |= AV_PKT_FLAG_KEY;
> ++
> ++    if (GST_BUFFER_DURATION_IS_VALID (buf))
> ++      pkt.duration =
> ++          gst_ffmpeg_time_gst_to_ff (GST_BUFFER_DURATION (buf),
> ++          ffmpegmux->context->streams[best_pad->padnum]->time_base);
> ++    else
> ++      pkt.duration = 0;
> ++    av_write_frame (ffmpegmux->context, &pkt);
> ++    gst_buffer_unref (buf);
> ++    if (need_free)
> ++      g_free (pkt.data);
> ++  } else {
> ++    /* close down */
> ++    av_write_trailer (ffmpegmux->context);
> ++    ffmpegmux->opened = FALSE;
> ++    put_flush_packet (ffmpegmux->context->pb);
> ++    url_fclose (ffmpegmux->context->pb);
> ++    gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_eos ());
> ++    return GST_FLOW_UNEXPECTED;
> ++  }
> ++
> ++  return GST_FLOW_OK;
> ++}
> ++
> ++static GstStateChangeReturn
> ++gst_ffmpegmux_change_state (GstElement * element, GstStateChange transition)
> ++{
> ++  GstFlowReturn ret;
> ++  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (element);
> ++
> ++  switch (transition) {
> ++    case GST_STATE_CHANGE_NULL_TO_READY:
> ++      break;
> ++    case GST_STATE_CHANGE_READY_TO_PAUSED:
> ++      gst_collect_pads_start (ffmpegmux->collect);
> ++      break;
> ++    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
> ++      break;
> ++    case GST_STATE_CHANGE_PAUSED_TO_READY:
> ++      gst_collect_pads_stop (ffmpegmux->collect);
> ++      break;
> ++    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_tag_setter_reset_tags (GST_TAG_SETTER (ffmpegmux));
> ++      if (ffmpegmux->opened) {
> ++        ffmpegmux->opened = FALSE;
> ++        url_fclose (ffmpegmux->context->pb);
> ++      }
> ++      break;
> ++    case GST_STATE_CHANGE_READY_TO_NULL:
> ++      break;
> ++    default:
> ++      break;
> ++  }
> ++
> ++  return ret;
> ++}
> ++
> ++static GstCaps *
> ++gst_ffmpegmux_get_id_caps (enum CodecID *id_list)
> ++{
> ++  GstCaps *caps, *t;
> ++  gint i;
> ++
> ++  caps = gst_caps_new_empty ();
> ++  for (i = 0; id_list[i] != CODEC_ID_NONE; i++) {
> ++    if ((t = gst_ffmpeg_codecid_to_caps (id_list[i], NULL, TRUE)))
> ++      gst_caps_append (caps, t);
> ++  }
> ++  if (gst_caps_is_empty (caps)) {
> ++    gst_caps_unref (caps);
> ++    return NULL;
> ++  }
> ++
> ++  return caps;
> ++}
> ++
> ++/* set a list of integer values on the caps, e.g. for sample rates */
> ++static void
> ++gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * caps, const gchar * field,
> ++    guint num, const gint * values)
> ++{
> ++  GValue list = { 0, };
> ++  GValue val = { 0, };
> ++  gint i;
> ++
> ++  g_return_if_fail (GST_CAPS_IS_SIMPLE (caps));
> ++
> ++  g_value_init (&list, GST_TYPE_LIST);
> ++  g_value_init (&val, G_TYPE_INT);
> ++
> ++  for (i = 0; i < num; ++i) {
> ++    g_value_set_int (&val, values[i]);
> ++    gst_value_list_append_value (&list, &val);
> ++  }
> ++
> ++  gst_structure_set_value (gst_caps_get_structure (caps, 0), field, &list);
> ++
> ++  g_value_unset (&val);
> ++  g_value_unset (&list);
> ++}
> ++
> ++gboolean
> ++gst_ffmpegmux_register (GstPlugin * plugin)
> ++{
> ++  GTypeInfo typeinfo = {
> ++    sizeof (GstFFMpegMuxClass),
> ++    (GBaseInitFunc) gst_ffmpegmux_base_init,
> ++    NULL,
> ++    (GClassInitFunc) gst_ffmpegmux_class_init,
> ++    NULL,
> ++    NULL,
> ++    sizeof (GstFFMpegMux),
> ++    0,
> ++    (GInstanceInitFunc) gst_ffmpegmux_init,
> ++  };
> ++  static const GInterfaceInfo tag_setter_info = {
> ++    NULL, NULL, NULL
> ++  };
> ++  GType type;
> ++  AVOutputFormat *in_plugin;
> ++
> ++  in_plugin = av_oformat_next (NULL);
> ++
> ++  GST_LOG ("Registering muxers");
> ++
> ++  while (in_plugin) {
> ++    gchar *type_name;
> ++    gchar *p;
> ++    GstRank rank = GST_RANK_MARGINAL;
> ++
> ++    if ((!strncmp (in_plugin->name, "u16", 3)) ||
> ++        (!strncmp (in_plugin->name, "s16", 3)) ||
> ++        (!strncmp (in_plugin->name, "u24", 3)) ||
> ++        (!strncmp (in_plugin->name, "s24", 3)) ||
> ++        (!strncmp (in_plugin->name, "u8", 2)) ||
> ++        (!strncmp (in_plugin->name, "s8", 2)) ||
> ++        (!strncmp (in_plugin->name, "u32", 3)) ||
> ++        (!strncmp (in_plugin->name, "s32", 3)) ||
> ++        (!strncmp (in_plugin->name, "f32", 3)) ||
> ++        (!strncmp (in_plugin->name, "f64", 3)) ||
> ++        (!strncmp (in_plugin->name, "raw", 3)) ||
> ++        (!strncmp (in_plugin->name, "crc", 3)) ||
> ++        (!strncmp (in_plugin->name, "null", 4)) ||
> ++        (!strncmp (in_plugin->name, "gif", 3)) ||
> ++        (!strncmp (in_plugin->name, "frame", 5)) ||
> ++        (!strncmp (in_plugin->name, "image", 5)) ||
> ++        (!strncmp (in_plugin->name, "mulaw", 5)) ||
> ++        (!strncmp (in_plugin->name, "alaw", 4)) ||
> ++        (!strncmp (in_plugin->name, "h26", 3)) ||
> ++        (!strncmp (in_plugin->name, "rtp", 3)) ||
> ++        (!strncmp (in_plugin->name, "ass", 3)) ||
> ++        (!strncmp (in_plugin->name, "ffmetadata", 10)) ||
> ++        (!strncmp (in_plugin->name, "srt", 3))
> ++        ) {
> ++      GST_LOG ("Ignoring muxer %s", in_plugin->name);
> ++      goto next;
> ++    }
> ++
> ++    if ((!strncmp (in_plugin->long_name, "raw ", 4))) {
> ++      GST_LOG ("Ignoring raw muxer %s", in_plugin->name);
> ++      goto next;
> ++    }
> ++
> ++    if (gst_ffmpegmux_get_replacement (in_plugin->name))
> ++      rank = GST_RANK_NONE;
> ++
> ++    /* FIXME : We need a fast way to know whether we have mappings for this
> ++     * muxer type. */
> ++
> ++    /* construct the type */
> ++    type_name = g_strdup_printf ("ffmux_%s", in_plugin->name);
> ++
> ++    p = type_name;
> ++
> ++    while (*p) {
> ++      if (*p == '.')
> ++        *p = '_';
> ++      p++;
> ++    }
> ++
> ++    type = g_type_from_name (type_name);
> ++
> ++    if (!type) {
> ++      /* create the type now */
> ++      type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
> ++      g_type_set_qdata (type, GST_FFMUX_PARAMS_QDATA, (gpointer) in_plugin);
> ++      g_type_add_interface_static (type, GST_TYPE_TAG_SETTER, &tag_setter_info);
> ++    }
> ++
> ++    if (!gst_element_register (plugin, type_name, rank, type)) {
> ++      g_free (type_name);
> ++      return FALSE;
> ++    }
> ++
> ++    g_free (type_name);
> ++
> ++  next:
> ++    in_plugin = av_oformat_next (in_plugin);
> ++  }
> ++
> ++  GST_LOG ("Finished registering muxers");
> ++
> ++  return TRUE;
> ++}
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegprotocol.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegprotocol.c
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegprotocol.c	2011-07-12 16:35:28.000000000 +0200
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegprotocol.c	2014-08-08 15:26:07.875857555 +0200
> +@@ -46,63 +46,14 @@
> + };
> +
> + static int
> +-gst_ffmpegdata_open (URLContext * h, const char *filename, int flags)
> +-{
> +-  GstProtocolInfo *info;
> +-  GstPad *pad;
> +-
> +-  GST_LOG ("Opening %s", filename);
> +-
> +-  info = g_new0 (GstProtocolInfo, 1);
> +-
> +-  info->set_streamheader = flags & GST_FFMPEG_URL_STREAMHEADER;
> +-  flags &= ~GST_FFMPEG_URL_STREAMHEADER;
> +-  h->flags &= ~GST_FFMPEG_URL_STREAMHEADER;
> +-
> +-  /* we don't support R/W together */
> +-  if (flags != URL_RDONLY && flags != URL_WRONLY) {
> +-    GST_WARNING ("Only read-only or write-only are supported");
> +-    return -EINVAL;
> +-  }
> +-
> +-  if (sscanf (&filename[12], "%p", &pad) != 1) {
> +-    GST_WARNING ("could not decode pad from %s", filename);
> +-    return -EIO;
> +-  }
> +-
> +-  /* make sure we're a pad and that we're of the right type */
> +-  g_return_val_if_fail (GST_IS_PAD (pad), -EINVAL);
> +-
> +-  switch (flags) {
> +-    case URL_RDONLY:
> +-      g_return_val_if_fail (GST_PAD_IS_SINK (pad), -EINVAL);
> +-      break;
> +-    case URL_WRONLY:
> +-      g_return_val_if_fail (GST_PAD_IS_SRC (pad), -EINVAL);
> +-      break;
> +-  }
> +-
> +-  info->eos = FALSE;
> +-  info->pad = pad;
> +-  info->offset = 0;
> +-
> +-  h->priv_data = (void *) info;
> +-  h->is_streamed = FALSE;
> +-  h->max_packet_size = 0;
> +-
> +-  return 0;
> +-}
> +-
> +-static int
> +-gst_ffmpegdata_peek (URLContext * h, unsigned char *buf, int size)
> ++gst_ffmpegdata_peek (void *priv_data, unsigned char *buf, int size)
> + {
> +   GstProtocolInfo *info;
> +   GstBuffer *inbuf = NULL;
> +   GstFlowReturn ret;
> +   int total = 0;
> +
> +-  g_return_val_if_fail (h->flags == URL_RDONLY, AVERROR (EIO));
> +-  info = (GstProtocolInfo *) h->priv_data;
> ++  info = (GstProtocolInfo *) priv_data;
> +
> +   GST_DEBUG ("Pulling %d bytes at position %" G_GUINT64_FORMAT, size,
> +       info->offset);
> +@@ -134,17 +85,17 @@
> + }
> +
> + static int
> +-gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size)
> ++gst_ffmpegdata_read (void *priv_data, unsigned char *buf, int size)
> + {
> +   gint res;
> +   GstProtocolInfo *info;
> +
> +-  info = (GstProtocolInfo *) h->priv_data;
> ++  info = (GstProtocolInfo *) priv_data;
> +
> +   GST_DEBUG ("Reading %d bytes of data at position %" G_GUINT64_FORMAT, size,
> +       info->offset);
> +
> +-  res = gst_ffmpegdata_peek (h, buf, size);
> ++  res = gst_ffmpegdata_peek (priv_data, buf, size);
> +   if (res >= 0)
> +     info->offset += res;
> +
> +@@ -154,15 +105,13 @@
> + }
> +
> + static int
> +-gst_ffmpegdata_write (URLContext * h, const unsigned char *buf, int size)
> ++gst_ffmpegdata_write (void *priv_data, const unsigned char *buf, int size)
> + {
> +   GstProtocolInfo *info;
> +   GstBuffer *outbuf;
> +
> +   GST_DEBUG ("Writing %d bytes", size);
> +-  info = (GstProtocolInfo *) h->priv_data;
> +-
> +-  g_return_val_if_fail (h->flags != URL_RDONLY, -EIO);
> ++  info = (GstProtocolInfo *) priv_data;
> +
> +   /* create buffer and push data further */
> +   if (gst_pad_alloc_buffer_and_set_caps (info->pad,
> +@@ -179,7 +128,7 @@
> + }
> +
> + static int64_t
> +-gst_ffmpegdata_seek (URLContext * h, int64_t pos, int whence)
> ++gst_ffmpegdata_seek (void *priv_data, int64_t pos, int whence)
> + {
> +   GstProtocolInfo *info;
> +   guint64 newpos = 0;
> +@@ -187,70 +136,62 @@
> +   GST_DEBUG ("Seeking to %" G_GINT64_FORMAT ", whence=%d",
> +       (gint64) pos, whence);
> +
> +-  info = (GstProtocolInfo *) h->priv_data;
> ++  info = (GstProtocolInfo *) priv_data;
> +
> +   /* TODO : if we are push-based, we need to return sensible info */
> +
> +-  switch (h->flags) {
> +-    case URL_RDONLY:
> +-    {
> +-      /* sinkpad */
> +-      switch (whence) {
> +-        case SEEK_SET:
> +-          newpos = (guint64) pos;
> +-          break;
> +-        case SEEK_CUR:
> +-          newpos = info->offset + pos;
> +-          break;
> +-        case SEEK_END:
> +-        case AVSEEK_SIZE:
> +-          /* ffmpeg wants to know the current end position in bytes ! */
> +-        {
> +-          GstFormat format = GST_FORMAT_BYTES;
> +-          gint64 duration;
> +-
> +-          GST_DEBUG ("Seek end");
> +-
> +-          if (gst_pad_is_linked (info->pad))
> +-            if (gst_pad_query_duration (GST_PAD_PEER (info->pad), &format,
> +-                    &duration))
> +-              newpos = ((guint64) duration) + pos;
> +-        }
> +-          break;
> +-        default:
> +-          g_assert (0);
> +-          break;
> ++  if (GST_PAD_IS_SINK (info->pad)) {
> ++    /* sinkpad */
> ++    switch (whence) {
> ++      case SEEK_SET:
> ++        newpos = (guint64) pos;
> ++        break;
> ++      case SEEK_CUR:
> ++        newpos = info->offset + pos;
> ++        break;
> ++      case SEEK_END:
> ++      case AVSEEK_SIZE:
> ++        /* ffmpeg wants to know the current end position in bytes ! */
> ++      {
> ++        GstFormat format = GST_FORMAT_BYTES;
> ++        gint64 duration;
> ++
> ++        GST_DEBUG ("Seek end");
> ++
> ++        if (gst_pad_is_linked (info->pad))
> ++          if (gst_pad_query_duration (GST_PAD_PEER (info->pad), &format,
> ++                  &duration))
> ++            newpos = ((guint64) duration) + pos;
> +       }
> +-      /* FIXME : implement case for push-based behaviour */
> +-      if (whence != AVSEEK_SIZE)
> +-        info->offset = newpos;
> ++        break;
> ++      default:
> ++        g_assert (0);
> ++        break;
> +     }
> +-      break;
> +-    case URL_WRONLY:
> +-    {
> +-      /* srcpad */
> +-      switch (whence) {
> +-        case SEEK_SET:
> +-          info->offset = (guint64) pos;
> +-          gst_pad_push_event (info->pad, gst_event_new_new_segment
> +-              (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
> +-                  GST_CLOCK_TIME_NONE, info->offset));
> +-          break;
> +-        case SEEK_CUR:
> +-          info->offset += pos;
> +-          gst_pad_push_event (info->pad, gst_event_new_new_segment
> +-              (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
> +-                  GST_CLOCK_TIME_NONE, info->offset));
> +-          break;
> +-        default:
> +-          break;
> +-      }
> +-      newpos = info->offset;
> ++    /* FIXME : implement case for push-based behaviour */
> ++    if (whence != AVSEEK_SIZE)
> ++      info->offset = newpos;
> ++  } else if (GST_PAD_IS_SRC (info->pad)) {
> ++    /* srcpad */
> ++    switch (whence) {
> ++      case SEEK_SET:
> ++        info->offset = (guint64) pos;
> ++        gst_pad_push_event (info->pad, gst_event_new_new_segment
> ++            (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
> ++                GST_CLOCK_TIME_NONE, info->offset));
> ++        break;
> ++      case SEEK_CUR:
> ++        info->offset += pos;
> ++        gst_pad_push_event (info->pad, gst_event_new_new_segment
> ++            (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
> ++                GST_CLOCK_TIME_NONE, info->offset));
> ++        break;
> ++      default:
> ++        break;
> +     }
> +-      break;
> +-    default:
> +-      g_assert (0);
> +-      break;
> ++    newpos = info->offset;
> ++  } else {
> ++    g_assert_not_reached ();
> +   }
> +
> +   GST_DEBUG ("Now at offset %" G_GUINT64_FORMAT " (returning %" G_GUINT64_FORMAT
> +@@ -258,85 +199,91 @@
> +   return newpos;
> + }
> +
> +-static int
> +-gst_ffmpegdata_close (URLContext * h)
> ++int
> ++gst_ffmpegdata_close (AVIOContext * h)
> + {
> +   GstProtocolInfo *info;
> +
> +-  info = (GstProtocolInfo *) h->priv_data;
> ++  info = (GstProtocolInfo *) h->opaque;
> +   if (info == NULL)
> +     return 0;
> +
> +   GST_LOG ("Closing file");
> +
> +-  switch (h->flags) {
> +-    case URL_WRONLY:
> +-    {
> +-      /* send EOS - that closes down the stream */
> +-      gst_pad_push_event (info->pad, gst_event_new_eos ());
> +-      break;
> +-    }
> +-    default:
> +-      break;
> ++  if (GST_PAD_IS_SRC (info->pad)) {
> ++    /* send EOS - that closes down the stream */
> ++    gst_pad_push_event (info->pad, gst_event_new_eos ());
> +   }
> +
> +   /* clean up data */
> +   g_free (info);
> +-  h->priv_data = NULL;
> ++  h->opaque = NULL;
> ++
> ++  av_freep (&h->buffer);
> ++  av_free (h);
> +
> +   return 0;
> + }
> +
> ++int
> ++gst_ffmpegdata_open (GstPad * pad, int flags, AVIOContext ** context)
> ++{
> ++  GstProtocolInfo *info;
> ++  static const int buffer_size = 4096;
> ++  unsigned char *buffer = NULL;
> +
> +-URLProtocol gstreamer_protocol = {
> +-  /*.name = */ "gstreamer",
> +-  /*.url_open = */ gst_ffmpegdata_open,
> +-  /*.url_read = */ gst_ffmpegdata_read,
> +-  /*.url_write = */ gst_ffmpegdata_write,
> +-  /*.url_seek = */ gst_ffmpegdata_seek,
> +-  /*.url_close = */ gst_ffmpegdata_close,
> +-};
> ++  info = g_new0 (GstProtocolInfo, 1);
> +
> ++  info->set_streamheader = flags & GST_FFMPEG_URL_STREAMHEADER;
> ++  flags &= ~GST_FFMPEG_URL_STREAMHEADER;
> +
> +-/* specialized protocol for cross-thread pushing,
> +- * based on ffmpeg's pipe protocol */
> ++  /* we don't support R/W together */
> ++  if ((flags & AVIO_FLAG_WRITE) && (flags & AVIO_FLAG_READ)) {
> ++    GST_WARNING ("Only read-only or write-only are supported");
> ++    return -EINVAL;
> ++  }
> +
> +-static int
> +-gst_ffmpeg_pipe_open (URLContext * h, const char *filename, int flags)
> +-{
> +-  GstFFMpegPipe *ffpipe;
> ++  /* make sure we're a pad and that we're of the right type */
> ++  g_return_val_if_fail (GST_IS_PAD (pad), -EINVAL);
> +
> +-  GST_LOG ("Opening %s", filename);
> ++  if ((flags & AVIO_FLAG_READ))
> ++    g_return_val_if_fail (GST_PAD_IS_SINK (pad), -EINVAL);
> ++  if ((flags & AVIO_FLAG_WRITE))
> ++    g_return_val_if_fail (GST_PAD_IS_SRC (pad), -EINVAL);
> +
> +-  /* we don't support W together */
> +-  if (flags != URL_RDONLY) {
> +-    GST_WARNING ("Only read-only is supported");
> +-    return -EINVAL;
> +-  }
> ++  info->eos = FALSE;
> ++  info->pad = pad;
> ++  info->offset = 0;
> +
> +-  if (sscanf (&filename[10], "%p", &ffpipe) != 1) {
> +-    GST_WARNING ("could not decode pipe info from %s", filename);
> +-    return -EIO;
> ++  buffer = av_malloc (buffer_size);
> ++  if (buffer == NULL) {
> ++    GST_WARNING ("Failed to allocate buffer");
> ++    return -ENOMEM;
> +   }
> +
> +-  /* sanity check */
> +-  g_return_val_if_fail (GST_IS_ADAPTER (ffpipe->adapter), -EINVAL);
> +-
> +-  h->priv_data = (void *) ffpipe;
> +-  h->is_streamed = TRUE;
> +-  h->max_packet_size = 0;
> ++  *context =
> ++      avio_alloc_context (buffer, buffer_size, flags, (void *) info,
> ++      gst_ffmpegdata_read, gst_ffmpegdata_write, gst_ffmpegdata_seek);
> ++  (*context)->seekable = AVIO_SEEKABLE_NORMAL;
> ++  if (!(flags & AVIO_FLAG_WRITE)) {
> ++    (*context)->buf_ptr = (*context)->buf_end;
> ++    (*context)->write_flag = 0;
> ++  }
> +
> +   return 0;
> + }
> +
> ++/* specialized protocol for cross-thread pushing,
> ++ * based on ffmpeg's pipe protocol */
> ++
> + static int
> +-gst_ffmpeg_pipe_read (URLContext * h, unsigned char *buf, int size)
> ++gst_ffmpeg_pipe_read (void *priv_data, unsigned char *buf, int size)
> + {
> +   GstFFMpegPipe *ffpipe;
> +   const guint8 *data;
> +   guint available;
> +
> +-  ffpipe = (GstFFMpegPipe *) h->priv_data;
> ++  ffpipe = (GstFFMpegPipe *) priv_data;
> +
> +   GST_LOG ("requested size %d", size);
> +
> +@@ -367,21 +314,38 @@
> +   return size;
> + }
> +
> +-static int
> +-gst_ffmpeg_pipe_close (URLContext * h)
> ++int
> ++gst_ffmpeg_pipe_close (AVIOContext * h)
> + {
> +   GST_LOG ("Closing pipe");
> +
> +-  h->priv_data = NULL;
> ++  h->opaque = NULL;
> ++  av_freep (&h->buffer);
> ++  av_free (h);
> +
> +   return 0;
> + }
> +
> +-URLProtocol gstpipe_protocol = {
> +-  "gstpipe",
> +-  gst_ffmpeg_pipe_open,
> +-  gst_ffmpeg_pipe_read,
> +-  NULL,
> +-  NULL,
> +-  gst_ffmpeg_pipe_close,
> +-};
> ++int
> ++gst_ffmpeg_pipe_open (GstFFMpegPipe * ffpipe, int flags, AVIOContext ** context)
> ++{
> ++  static const int buffer_size = 4096;
> ++  unsigned char *buffer = NULL;
> ++
> ++  /* sanity check */
> ++  g_return_val_if_fail (GST_IS_ADAPTER (ffpipe->adapter), -EINVAL);
> ++
> ++  buffer = av_malloc (buffer_size);
> ++  if (buffer == NULL) {
> ++    GST_WARNING ("Failed to allocate buffer");
> ++    return -ENOMEM;
> ++  }
> ++
> ++  *context =
> ++      avio_alloc_context (buffer, buffer_size, 0, (void *) ffpipe,
> ++      gst_ffmpeg_pipe_read, NULL, NULL);
> ++  (*context)->seekable = 0;
> ++  (*context)->buf_ptr = (*context)->buf_end;
> ++
> ++  return 0;
> ++}
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c	2011-07-13 11:07:28.000000000 +0200
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c	2014-08-08 15:34:04.007874626 +0200
> +@@ -25,6 +25,11 @@
> + #ifdef __APPLE__
> + #include <sys/sysctl.h>
> + #endif
> ++#ifdef HAVE_FFMPEG_UNINSTALLED
> ++#include <avformat.h>
> ++#else
> ++#include <libavformat/avformat.h>
> ++#endif
> +
> + G_CONST_RETURN gchar *
> + gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
> +@@ -39,21 +44,21 @@
> + }
> +
> + gint
> +-av_smp_format_depth (enum SampleFormat smp_fmt)
> ++av_smp_format_depth (enum AVSampleFormat smp_fmt)
> + {
> +   gint depth = -1;
> +   switch (smp_fmt) {
> +-    case SAMPLE_FMT_U8:
> ++    case AV_SAMPLE_FMT_U8:
> +       depth = 1;
> +       break;
> +-    case SAMPLE_FMT_S16:
> ++    case AV_SAMPLE_FMT_S16:
> +       depth = 2;
> +       break;
> +-    case SAMPLE_FMT_S32:
> +-    case SAMPLE_FMT_FLT:
> ++    case AV_SAMPLE_FMT_S32:
> ++    case AV_SAMPLE_FMT_FLT:
> +       depth = 4;
> +       break;
> +-    case SAMPLE_FMT_DBL:
> ++    case AV_SAMPLE_FMT_DBL:
> +       depth = 8;
> +       break;
> +     default:
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c.orig
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c.orig	1970-01-01 01:00:00.000000000 +0100
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c.orig	2011-07-13 11:07:28.000000000 +0200
> +@@ -0,0 +1,483 @@
> ++/* GStreamer
> ++ * Copyright (c) 2009 Edward Hervey <bilboed@bilboed.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.
> ++ */
> ++
> ++#ifdef HAVE_CONFIG_H
> ++#include "config.h"
> ++#endif
> ++#include "gstffmpegutils.h"
> ++#include <unistd.h>
> ++#ifdef __APPLE__
> ++#include <sys/sysctl.h>
> ++#endif
> ++
> ++G_CONST_RETURN gchar *
> ++gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
> ++{
> ++  AVCodec *codec;
> ++  /* Let's use what ffmpeg can provide us */
> ++
> ++  if ((codec = avcodec_find_decoder (codec_id)) ||
> ++      (codec = avcodec_find_encoder (codec_id)))
> ++    return codec->long_name;
> ++  return NULL;
> ++}
> ++
> ++gint
> ++av_smp_format_depth (enum SampleFormat smp_fmt)
> ++{
> ++  gint depth = -1;
> ++  switch (smp_fmt) {
> ++    case SAMPLE_FMT_U8:
> ++      depth = 1;
> ++      break;
> ++    case SAMPLE_FMT_S16:
> ++      depth = 2;
> ++      break;
> ++    case SAMPLE_FMT_S32:
> ++    case SAMPLE_FMT_FLT:
> ++      depth = 4;
> ++      break;
> ++    case SAMPLE_FMT_DBL:
> ++      depth = 8;
> ++      break;
> ++    default:
> ++      GST_ERROR ("UNHANDLED SAMPLE FORMAT !");
> ++      break;
> ++  }
> ++  return depth;
> ++}
> ++
> ++
> ++/*
> ++ * Fill in pointers to memory in a AVPicture, where
> ++ * everything is aligned by 4 (as required by X).
> ++ * This is mostly a copy from imgconvert.c with some
> ++ * small changes.
> ++ */
> ++
> ++#define FF_COLOR_RGB      0     /* RGB color space */
> ++#define FF_COLOR_GRAY     1     /* gray color space */
> ++#define FF_COLOR_YUV      2     /* YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */
> ++#define FF_COLOR_YUV_JPEG 3     /* YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */
> ++
> ++#define FF_PIXEL_PLANAR   0     /* each channel has one component in AVPicture */
> ++#define FF_PIXEL_PACKED   1     /* only one components containing all the channels */
> ++#define FF_PIXEL_PALETTE  2     /* one components containing indexes for a palette */
> ++
> ++typedef struct PixFmtInfo
> ++{
> ++  const char *name;
> ++  uint8_t nb_channels;          /* number of channels (including alpha) */
> ++  uint8_t color_type;           /* color type (see FF_COLOR_xxx constants) */
> ++  uint8_t pixel_type;           /* pixel storage type (see FF_PIXEL_xxx constants) */
> ++  uint8_t is_alpha:1;           /* true if alpha can be specified */
> ++  uint8_t x_chroma_shift;       /* X chroma subsampling factor is 2 ^ shift */
> ++  uint8_t y_chroma_shift;       /* Y chroma subsampling factor is 2 ^ shift */
> ++  uint8_t depth;                /* bit depth of the color components */
> ++} PixFmtInfo;
> ++
> ++
> ++/* this table gives more information about formats */
> ++static PixFmtInfo pix_fmt_info[PIX_FMT_NB];
> ++void
> ++gst_ffmpeg_init_pix_fmt_info (void)
> ++{
> ++  /* YUV formats */
> ++  pix_fmt_info[PIX_FMT_YUV420P].name = g_strdup ("yuv420p");
> ++  pix_fmt_info[PIX_FMT_YUV420P].nb_channels = 3;
> ++  pix_fmt_info[PIX_FMT_YUV420P].color_type = FF_COLOR_YUV;
> ++  pix_fmt_info[PIX_FMT_YUV420P].pixel_type = FF_PIXEL_PLANAR;
> ++  pix_fmt_info[PIX_FMT_YUV420P].depth = 8,
> ++      pix_fmt_info[PIX_FMT_YUV420P].x_chroma_shift = 1,
> ++      pix_fmt_info[PIX_FMT_YUV420P].y_chroma_shift = 1;
> ++
> ++  pix_fmt_info[PIX_FMT_YUV422P].name = g_strdup ("yuv422p");
> ++  pix_fmt_info[PIX_FMT_YUV422P].nb_channels = 3;
> ++  pix_fmt_info[PIX_FMT_YUV422P].color_type = FF_COLOR_YUV;
> ++  pix_fmt_info[PIX_FMT_YUV422P].pixel_type = FF_PIXEL_PLANAR;
> ++  pix_fmt_info[PIX_FMT_YUV422P].depth = 8;
> ++  pix_fmt_info[PIX_FMT_YUV422P].x_chroma_shift = 1;
> ++  pix_fmt_info[PIX_FMT_YUV422P].y_chroma_shift = 0;
> ++
> ++  pix_fmt_info[PIX_FMT_YUV444P].name = g_strdup ("yuv444p");
> ++  pix_fmt_info[PIX_FMT_YUV444P].nb_channels = 3;
> ++  pix_fmt_info[PIX_FMT_YUV444P].color_type = FF_COLOR_YUV;
> ++  pix_fmt_info[PIX_FMT_YUV444P].pixel_type = FF_PIXEL_PLANAR;
> ++  pix_fmt_info[PIX_FMT_YUV444P].depth = 8;
> ++  pix_fmt_info[PIX_FMT_YUV444P].x_chroma_shift = 0;
> ++  pix_fmt_info[PIX_FMT_YUV444P].y_chroma_shift = 0;
> ++
> ++  pix_fmt_info[PIX_FMT_YUYV422].name = g_strdup ("yuv422");
> ++  pix_fmt_info[PIX_FMT_YUYV422].nb_channels = 1;
> ++  pix_fmt_info[PIX_FMT_YUYV422].color_type = FF_COLOR_YUV;
> ++  pix_fmt_info[PIX_FMT_YUYV422].pixel_type = FF_PIXEL_PACKED;
> ++  pix_fmt_info[PIX_FMT_YUYV422].depth = 8;
> ++  pix_fmt_info[PIX_FMT_YUYV422].x_chroma_shift = 1;
> ++  pix_fmt_info[PIX_FMT_YUYV422].y_chroma_shift = 0;
> ++
> ++  pix_fmt_info[PIX_FMT_YUV410P].name = g_strdup ("yuv410p");
> ++  pix_fmt_info[PIX_FMT_YUV410P].nb_channels = 3;
> ++  pix_fmt_info[PIX_FMT_YUV410P].color_type = FF_COLOR_YUV;
> ++  pix_fmt_info[PIX_FMT_YUV410P].pixel_type = FF_PIXEL_PLANAR;
> ++  pix_fmt_info[PIX_FMT_YUV410P].depth = 8;
> ++  pix_fmt_info[PIX_FMT_YUV410P].x_chroma_shift = 2;
> ++  pix_fmt_info[PIX_FMT_YUV410P].y_chroma_shift = 2;
> ++
> ++  pix_fmt_info[PIX_FMT_YUV411P].name = g_strdup ("yuv411p");
> ++  pix_fmt_info[PIX_FMT_YUV411P].nb_channels = 3;
> ++  pix_fmt_info[PIX_FMT_YUV411P].color_type = FF_COLOR_YUV;
> ++  pix_fmt_info[PIX_FMT_YUV411P].pixel_type = FF_PIXEL_PLANAR;
> ++  pix_fmt_info[PIX_FMT_YUV411P].depth = 8;
> ++  pix_fmt_info[PIX_FMT_YUV411P].x_chroma_shift = 2;
> ++  pix_fmt_info[PIX_FMT_YUV411P].y_chroma_shift = 0;
> ++
> ++  /* JPEG YUV */
> ++  pix_fmt_info[PIX_FMT_YUVJ420P].name = g_strdup ("yuvj420p");
> ++  pix_fmt_info[PIX_FMT_YUVJ420P].nb_channels = 3;
> ++  pix_fmt_info[PIX_FMT_YUVJ420P].color_type = FF_COLOR_YUV_JPEG;
> ++  pix_fmt_info[PIX_FMT_YUVJ420P].pixel_type = FF_PIXEL_PLANAR;
> ++  pix_fmt_info[PIX_FMT_YUVJ420P].depth = 8;
> ++  pix_fmt_info[PIX_FMT_YUVJ420P].x_chroma_shift = 1;
> ++  pix_fmt_info[PIX_FMT_YUVJ420P].y_chroma_shift = 1;
> ++
> ++  pix_fmt_info[PIX_FMT_YUVJ422P].name = g_strdup ("yuvj422p");
> ++  pix_fmt_info[PIX_FMT_YUVJ422P].nb_channels = 3;
> ++  pix_fmt_info[PIX_FMT_YUVJ422P].color_type = FF_COLOR_YUV_JPEG;
> ++  pix_fmt_info[PIX_FMT_YUVJ422P].pixel_type = FF_PIXEL_PLANAR;
> ++  pix_fmt_info[PIX_FMT_YUVJ422P].depth = 8;
> ++  pix_fmt_info[PIX_FMT_YUVJ422P].x_chroma_shift = 1;
> ++  pix_fmt_info[PIX_FMT_YUVJ422P].y_chroma_shift = 0;
> ++
> ++  pix_fmt_info[PIX_FMT_YUVJ444P].name = g_strdup ("yuvj444p");
> ++  pix_fmt_info[PIX_FMT_YUVJ444P].nb_channels = 3;
> ++  pix_fmt_info[PIX_FMT_YUVJ444P].color_type = FF_COLOR_YUV_JPEG;
> ++  pix_fmt_info[PIX_FMT_YUVJ444P].pixel_type = FF_PIXEL_PLANAR;
> ++  pix_fmt_info[PIX_FMT_YUVJ444P].depth = 8;
> ++  pix_fmt_info[PIX_FMT_YUVJ444P].x_chroma_shift = 0;
> ++  pix_fmt_info[PIX_FMT_YUVJ444P].y_chroma_shift = 0;
> ++
> ++  /* RGB formats */
> ++  pix_fmt_info[PIX_FMT_RGB24].name = g_strdup ("rgb24");
> ++  pix_fmt_info[PIX_FMT_RGB24].nb_channels = 3;
> ++  pix_fmt_info[PIX_FMT_RGB24].color_type = FF_COLOR_RGB;
> ++  pix_fmt_info[PIX_FMT_RGB24].pixel_type = FF_PIXEL_PACKED;
> ++  pix_fmt_info[PIX_FMT_RGB24].depth = 8;
> ++  pix_fmt_info[PIX_FMT_RGB24].x_chroma_shift = 0;
> ++  pix_fmt_info[PIX_FMT_RGB24].y_chroma_shift = 0;
> ++
> ++  pix_fmt_info[PIX_FMT_BGR24].name = g_strdup ("bgr24");
> ++  pix_fmt_info[PIX_FMT_BGR24].nb_channels = 3;
> ++  pix_fmt_info[PIX_FMT_BGR24].color_type = FF_COLOR_RGB;
> ++  pix_fmt_info[PIX_FMT_BGR24].pixel_type = FF_PIXEL_PACKED;
> ++  pix_fmt_info[PIX_FMT_BGR24].depth = 8;
> ++  pix_fmt_info[PIX_FMT_BGR24].x_chroma_shift = 0;
> ++  pix_fmt_info[PIX_FMT_BGR24].y_chroma_shift = 0;
> ++
> ++  pix_fmt_info[PIX_FMT_RGB32].name = g_strdup ("rgba32");
> ++  pix_fmt_info[PIX_FMT_RGB32].nb_channels = 4;
> ++  pix_fmt_info[PIX_FMT_RGB32].is_alpha = 1;
> ++  pix_fmt_info[PIX_FMT_RGB32].color_type = FF_COLOR_RGB;
> ++  pix_fmt_info[PIX_FMT_RGB32].pixel_type = FF_PIXEL_PACKED;
> ++  pix_fmt_info[PIX_FMT_RGB32].depth = 8;
> ++  pix_fmt_info[PIX_FMT_RGB32].x_chroma_shift = 0;
> ++  pix_fmt_info[PIX_FMT_RGB32].y_chroma_shift = 0;
> ++
> ++  pix_fmt_info[PIX_FMT_RGB565].name = g_strdup ("rgb565");
> ++  pix_fmt_info[PIX_FMT_RGB565].nb_channels = 3;
> ++  pix_fmt_info[PIX_FMT_RGB565].color_type = FF_COLOR_RGB;
> ++  pix_fmt_info[PIX_FMT_RGB565].pixel_type = FF_PIXEL_PACKED;
> ++  pix_fmt_info[PIX_FMT_RGB565].depth = 5;
> ++  pix_fmt_info[PIX_FMT_RGB565].x_chroma_shift = 0;
> ++  pix_fmt_info[PIX_FMT_RGB565].y_chroma_shift = 0;
> ++
> ++  pix_fmt_info[PIX_FMT_RGB555].name = g_strdup ("rgb555");
> ++  pix_fmt_info[PIX_FMT_RGB555].nb_channels = 4;
> ++  pix_fmt_info[PIX_FMT_RGB555].is_alpha = 1;
> ++  pix_fmt_info[PIX_FMT_RGB555].color_type = FF_COLOR_RGB;
> ++  pix_fmt_info[PIX_FMT_RGB555].pixel_type = FF_PIXEL_PACKED;
> ++  pix_fmt_info[PIX_FMT_RGB555].depth = 5;
> ++  pix_fmt_info[PIX_FMT_RGB555].x_chroma_shift = 0;
> ++  pix_fmt_info[PIX_FMT_RGB555].y_chroma_shift = 0;
> ++
> ++  /* gray / mono formats */
> ++  pix_fmt_info[PIX_FMT_GRAY8].name = g_strdup ("gray");
> ++  pix_fmt_info[PIX_FMT_GRAY8].nb_channels = 1;
> ++  pix_fmt_info[PIX_FMT_GRAY8].color_type = FF_COLOR_GRAY;
> ++  pix_fmt_info[PIX_FMT_GRAY8].pixel_type = FF_PIXEL_PLANAR;
> ++  pix_fmt_info[PIX_FMT_GRAY8].depth = 8;
> ++
> ++  pix_fmt_info[PIX_FMT_MONOWHITE].name = g_strdup ("monow");
> ++  pix_fmt_info[PIX_FMT_MONOWHITE].nb_channels = 1;
> ++  pix_fmt_info[PIX_FMT_MONOWHITE].color_type = FF_COLOR_GRAY;
> ++  pix_fmt_info[PIX_FMT_MONOWHITE].pixel_type = FF_PIXEL_PLANAR;
> ++  pix_fmt_info[PIX_FMT_MONOWHITE].depth = 1;
> ++
> ++  pix_fmt_info[PIX_FMT_MONOBLACK].name = g_strdup ("monob");
> ++  pix_fmt_info[PIX_FMT_MONOBLACK].nb_channels = 1;
> ++  pix_fmt_info[PIX_FMT_MONOBLACK].color_type = FF_COLOR_GRAY;
> ++  pix_fmt_info[PIX_FMT_MONOBLACK].pixel_type = FF_PIXEL_PLANAR;
> ++  pix_fmt_info[PIX_FMT_MONOBLACK].depth = 1;
> ++
> ++  /* paletted formats */
> ++  pix_fmt_info[PIX_FMT_PAL8].name = g_strdup ("pal8");
> ++  pix_fmt_info[PIX_FMT_PAL8].nb_channels = 4;
> ++  pix_fmt_info[PIX_FMT_PAL8].is_alpha = 1;
> ++  pix_fmt_info[PIX_FMT_PAL8].color_type = FF_COLOR_RGB;
> ++  pix_fmt_info[PIX_FMT_PAL8].pixel_type = FF_PIXEL_PALETTE;
> ++  pix_fmt_info[PIX_FMT_PAL8].depth = 8;
> ++
> ++  pix_fmt_info[PIX_FMT_YUVA420P].name = g_strdup ("yuva420p");
> ++  pix_fmt_info[PIX_FMT_YUVA420P].nb_channels = 4;
> ++  pix_fmt_info[PIX_FMT_YUVA420P].is_alpha = 1;
> ++  pix_fmt_info[PIX_FMT_YUVA420P].color_type = FF_COLOR_YUV;
> ++  pix_fmt_info[PIX_FMT_YUVA420P].pixel_type = FF_PIXEL_PLANAR;
> ++  pix_fmt_info[PIX_FMT_YUVA420P].depth = 8,
> ++      pix_fmt_info[PIX_FMT_YUVA420P].x_chroma_shift = 1,
> ++      pix_fmt_info[PIX_FMT_YUVA420P].y_chroma_shift = 1;
> ++};
> ++
> ++int
> ++gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height)
> ++{
> ++  AVPicture dummy_pict;
> ++
> ++  return gst_ffmpeg_avpicture_fill (&dummy_pict, NULL, pix_fmt, width, height);
> ++}
> ++
> ++#define GEN_MASK(x) ((1<<(x))-1)
> ++#define ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) & ~GEN_MASK(x))
> ++#define ROUND_UP_2(x) ROUND_UP_X (x, 1)
> ++#define ROUND_UP_4(x) ROUND_UP_X (x, 2)
> ++#define ROUND_UP_8(x) ROUND_UP_X (x, 3)
> ++#define DIV_ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) >> (x))
> ++
> ++int
> ++gst_ffmpeg_avpicture_fill (AVPicture * picture,
> ++    uint8_t * ptr, enum PixelFormat pix_fmt, int width, int height)
> ++{
> ++  int size, w2, h2, size2;
> ++  int stride, stride2;
> ++  PixFmtInfo *pinfo;
> ++
> ++  pinfo = &pix_fmt_info[pix_fmt];
> ++
> ++  switch (pix_fmt) {
> ++    case PIX_FMT_YUV420P:
> ++    case PIX_FMT_YUV422P:
> ++    case PIX_FMT_YUV444P:
> ++    case PIX_FMT_YUV410P:
> ++    case PIX_FMT_YUV411P:
> ++    case PIX_FMT_YUVJ420P:
> ++    case PIX_FMT_YUVJ422P:
> ++    case PIX_FMT_YUVJ444P:
> ++      stride = ROUND_UP_4 (width);
> ++      h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
> ++      size = stride * h2;
> ++      w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
> ++      stride2 = ROUND_UP_4 (w2);
> ++      h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift);
> ++      size2 = stride2 * h2;
> ++      picture->data[0] = ptr;
> ++      picture->data[1] = picture->data[0] + size;
> ++      picture->data[2] = picture->data[1] + size2;
> ++      picture->data[3] = NULL;
> ++      picture->linesize[0] = stride;
> ++      picture->linesize[1] = stride2;
> ++      picture->linesize[2] = stride2;
> ++      picture->linesize[3] = 0;
> ++      GST_DEBUG ("planes %d %d %d", 0, size, size + size2);
> ++      GST_DEBUG ("strides %d %d %d", stride, stride2, stride2);
> ++      return size + 2 * size2;
> ++    case PIX_FMT_YUVA420P:
> ++      stride = ROUND_UP_4 (width);
> ++      h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
> ++      size = stride * h2;
> ++      w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
> ++      stride2 = ROUND_UP_4 (w2);
> ++      h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift);
> ++      size2 = stride2 * h2;
> ++      picture->data[0] = ptr;
> ++      picture->data[1] = picture->data[0] + size;
> ++      picture->data[2] = picture->data[1] + size2;
> ++      picture->data[3] = picture->data[2] + size2;
> ++      picture->linesize[0] = stride;
> ++      picture->linesize[1] = stride2;
> ++      picture->linesize[2] = stride2;
> ++      picture->linesize[3] = stride;
> ++      GST_DEBUG ("planes %d %d %d %d", 0, size, size + size2, size + 2 * size2);
> ++      GST_DEBUG ("strides %d %d %d %d", stride, stride2, stride2, stride);
> ++      return 2 * size + 2 * size2;
> ++    case PIX_FMT_RGB24:
> ++    case PIX_FMT_BGR24:
> ++      stride = ROUND_UP_4 (width * 3);
> ++      size = stride * height;
> ++      picture->data[0] = ptr;
> ++      picture->data[1] = NULL;
> ++      picture->data[2] = NULL;
> ++      picture->data[3] = NULL;
> ++      picture->linesize[0] = stride;
> ++      picture->linesize[1] = 0;
> ++      picture->linesize[2] = 0;
> ++      picture->linesize[3] = 0;
> ++      return size;
> ++      /*case PIX_FMT_AYUV4444:
> ++         case PIX_FMT_BGR32:
> ++         case PIX_FMT_BGRA32:
> ++         case PIX_FMT_RGB32: */
> ++    case PIX_FMT_RGB32:
> ++      stride = width * 4;
> ++      size = stride * height;
> ++      picture->data[0] = ptr;
> ++      picture->data[1] = NULL;
> ++      picture->data[2] = NULL;
> ++      picture->data[3] = NULL;
> ++      picture->linesize[0] = stride;
> ++      picture->linesize[1] = 0;
> ++      picture->linesize[2] = 0;
> ++      picture->linesize[3] = 0;
> ++      return size;
> ++    case PIX_FMT_RGB555:
> ++    case PIX_FMT_RGB565:
> ++    case PIX_FMT_YUYV422:
> ++    case PIX_FMT_UYVY422:
> ++      stride = ROUND_UP_4 (width * 2);
> ++      size = stride * height;
> ++      picture->data[0] = ptr;
> ++      picture->data[1] = NULL;
> ++      picture->data[2] = NULL;
> ++      picture->data[3] = NULL;
> ++      picture->linesize[0] = stride;
> ++      picture->linesize[1] = 0;
> ++      picture->linesize[2] = 0;
> ++      picture->linesize[3] = 0;
> ++      return size;
> ++    case PIX_FMT_UYYVYY411:
> ++      /* FIXME, probably not the right stride */
> ++      stride = ROUND_UP_4 (width);
> ++      size = stride * height;
> ++      picture->data[0] = ptr;
> ++      picture->data[1] = NULL;
> ++      picture->data[2] = NULL;
> ++      picture->data[3] = NULL;
> ++      picture->linesize[0] = width + width / 2;
> ++      picture->linesize[1] = 0;
> ++      picture->linesize[2] = 0;
> ++      picture->linesize[3] = 0;
> ++      return size + size / 2;
> ++    case PIX_FMT_GRAY8:
> ++      stride = ROUND_UP_4 (width);
> ++      size = stride * height;
> ++      picture->data[0] = ptr;
> ++      picture->data[1] = NULL;
> ++      picture->data[2] = NULL;
> ++      picture->data[3] = NULL;
> ++      picture->linesize[0] = stride;
> ++      picture->linesize[1] = 0;
> ++      picture->linesize[2] = 0;
> ++      picture->linesize[3] = 0;
> ++      return size;
> ++    case PIX_FMT_MONOWHITE:
> ++    case PIX_FMT_MONOBLACK:
> ++      stride = ROUND_UP_4 ((width + 7) >> 3);
> ++      size = stride * height;
> ++      picture->data[0] = ptr;
> ++      picture->data[1] = NULL;
> ++      picture->data[2] = NULL;
> ++      picture->data[3] = NULL;
> ++      picture->linesize[0] = stride;
> ++      picture->linesize[1] = 0;
> ++      picture->linesize[2] = 0;
> ++      picture->linesize[3] = 0;
> ++      return size;
> ++    case PIX_FMT_PAL8:
> ++      /* already forced to be with stride, so same result as other function */
> ++      stride = ROUND_UP_4 (width);
> ++      size = stride * height;
> ++      picture->data[0] = ptr;
> ++      picture->data[1] = ptr + size;    /* palette is stored here as 256 32 bit words */
> ++      picture->data[2] = NULL;
> ++      picture->data[3] = NULL;
> ++      picture->linesize[0] = stride;
> ++      picture->linesize[1] = 4;
> ++      picture->linesize[2] = 0;
> ++      picture->linesize[3] = 0;
> ++      return size + 256 * 4;
> ++    default:
> ++      picture->data[0] = NULL;
> ++      picture->data[1] = NULL;
> ++      picture->data[2] = NULL;
> ++      picture->data[3] = NULL;
> ++      return -1;
> ++  }
> ++
> ++  return 0;
> ++}
> ++
> ++/* Create a GstBuffer of the requested size and caps.
> ++ * The memory will be allocated by ffmpeg, making sure it's properly aligned
> ++ * for any processing. */
> ++
> ++GstBuffer *
> ++new_aligned_buffer (gint size, GstCaps * caps)
> ++{
> ++  GstBuffer *buf;
> ++
> ++  buf = gst_buffer_new ();
> ++  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = av_malloc (size);
> ++  GST_BUFFER_SIZE (buf) = size;
> ++  GST_BUFFER_FREE_FUNC (buf) = av_free;
> ++  if (caps)
> ++    gst_buffer_set_caps (buf, caps);
> ++
> ++  return buf;
> ++}
> ++
> ++int
> ++gst_ffmpeg_auto_max_threads (void)
> ++{
> ++  static gsize n_threads = 0;
> ++  if (g_once_init_enter (&n_threads)) {
> ++    int n = 1;
> ++#if defined(_WIN32)
> ++    {
> ++      const char *s = getenv ("NUMBER_OF_PROCESSORS");
> ++      if (s) {
> ++        n = atoi (s);
> ++      }
> ++    }
> ++#elif defined(__APPLE__)
> ++    {
> ++      int mib[] = { CTL_HW, HW_NCPU };
> ++      size_t dataSize = sizeof (int);
> ++
> ++      if (sysctl (mib, 2, &n_threads, &dataSize, NULL, 0)) {
> ++        n = 1;
> ++      }
> ++    }
> ++#else
> ++    n = sysconf (_SC_NPROCESSORS_CONF);
> ++#endif
> ++    if (n < 1)
> ++      n = 1;
> ++
> ++    g_once_init_leave (&n_threads, n);
> ++  }
> ++
> ++  return (int) (n_threads);
> ++}
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h	2011-11-02 14:04:05.000000000 +0100
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h	2014-08-08 15:34:04.007874626 +0200
> +@@ -23,6 +23,7 @@
> + #ifdef HAVE_FFMPEG_UNINSTALLED
> + #include <avcodec.h>
> + #else
> ++#include <libavutil/mathematics.h>
> + #include <libavcodec/avcodec.h>
> + #endif
> + #include <gst/gst.h>
> +@@ -87,7 +88,7 @@
> + gst_ffmpeg_get_codecid_longname (enum CodecID codec_id);
> +
> + gint
> +-av_smp_format_depth(enum SampleFormat smp_fmt);
> ++av_smp_format_depth(enum AVSampleFormat smp_fmt);
> +
> + GstBuffer *
> + new_aligned_buffer (gint size, GstCaps * caps);
> +diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h.orig
> +--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h.orig	1970-01-01 01:00:00.000000000 +0100
> ++++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h.orig	2014-08-08 15:26:38.473858652 +0200
> +@@ -0,0 +1,95 @@
> ++/* GStreamer
> ++ * Copyright (C) <2009> Edward Hervey <bilboed@bilboed.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.
> ++ */
> ++
> ++#ifndef __GST_FFMPEG_UTILS_H__
> ++#define __GST_FFMPEG_UTILS_H__
> ++
> ++#ifdef HAVE_FFMPEG_UNINSTALLED
> ++#include <avcodec.h>
> ++#else
> ++#include <libavcodec/avcodec.h>
> ++#endif
> ++#include <gst/gst.h>
> ++
> ++/*
> ++ *Get the size of an picture
> ++ */
> ++int
> ++gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height);
> ++
> ++/*
> ++ * Fill in pointers in an AVPicture, aligned by 4 (required by X).
> ++ */
> ++
> ++int
> ++gst_ffmpeg_avpicture_fill (AVPicture * picture,
> ++                           uint8_t *   ptr,
> ++                           enum PixelFormat pix_fmt,
> ++                           int         width,
> ++                           int         height);
> ++
> ++/*
> ++ * Convert from/to a GStreamer <-> FFMpeg timestamp.
> ++ */
> ++static inline guint64
> ++gst_ffmpeg_time_ff_to_gst (gint64 pts, AVRational base)
> ++{
> ++  guint64 out;
> ++
> ++  if (pts == AV_NOPTS_VALUE){
> ++    out = GST_CLOCK_TIME_NONE;
> ++  } else {
> ++    AVRational bq = { 1, GST_SECOND };
> ++    out = av_rescale_q (pts, base, bq);
> ++  }
> ++
> ++  return out;
> ++}
> ++
> ++static inline gint64
> ++gst_ffmpeg_time_gst_to_ff (guint64 time, AVRational base)
> ++{
> ++  gint64 out;
> ++
> ++  if (!GST_CLOCK_TIME_IS_VALID (time) || base.num == 0) {
> ++    out = AV_NOPTS_VALUE;
> ++  } else {
> ++    AVRational bq = { 1, GST_SECOND };
> ++    out = av_rescale_q (time, bq, base);
> ++  }
> ++
> ++  return out;
> ++}
> ++
> ++void
> ++gst_ffmpeg_init_pix_fmt_info(void);
> ++
> ++int
> ++gst_ffmpeg_auto_max_threads(void);
> ++
> ++G_CONST_RETURN gchar *
> ++gst_ffmpeg_get_codecid_longname (enum CodecID codec_id);
> ++
> ++gint
> ++av_smp_format_depth(enum AVSampleFormat smp_fmt);
> ++
> ++GstBuffer *
> ++new_aligned_buffer (gint size, GstCaps * caps);
> ++
> ++#endif /* __GST_FFMPEG_UTILS_H__ */
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e500mc.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e500mc.patch
> new file mode 100644
> index 0000000..eba4988
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e500mc.patch
> @@ -0,0 +1,21 @@
> +diff --git a/gst-libs/ext/libav/configure b/gst-libs/ext/libav/configure
> +index 8473069..4f74952 100755
> +--- a/gst-libs/ext/libav/configure
> ++++ b/gst-libs/ext/libav/configure
> +Fix gst-ffmpeg build issues for libav on e500mc (fsl-p4080)
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Yao Zhao <yao.zhao@windriver.com>
> +
> +@@ -2210,6 +2210,10 @@ elif enabled ppc; then
> +             cpuflags="-mcpu=cell"
> +             enable ldbrx
> +         ;;
> ++        e500mc)
> ++            cpuflags="-mcpu=e500mc"
> ++            disable altivec
> ++        ;;
> +         e500v2)
> +             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
> +             disable altivec
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e5500.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e5500.patch
> new file mode 100644
> index 0000000..d9ea2c2
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e5500.patch
> @@ -0,0 +1,19 @@
> +libav: Add configs for ppc e5500
> +
> +Upstream-Status: Pending
> +
> +Signed-off-by: Jesse Zhang <sen.zhang@windriver.com>
> +
> +--- gst-ffmpeg-0.10.13/gst-libs/ext/libav/configure	2013-06-20 05:18:36.073104964 -0400
> ++++ gst-ffmpeg-0.10.13/gst-libs/ext/libav/configure	2013-06-20 05:18:38.269104150 -0400
> +@@ -2222,6 +2222,10 @@
> +             cpuflags="-mcpu=8540 -mhard-float"
> +             disable altivec
> +         ;;
> ++        e5500)
> ++            cpuflags="-mcpu=e5500 -mhard-float"
> ++            disable altivec
> ++        ;;
> +     esac
> +
> + elif enabled x86; then
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/lower-rank.diff b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/lower-rank.diff
> new file mode 100644
> index 0000000..5f08afe
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/lower-rank.diff
> @@ -0,0 +1,16 @@
> +Lower the rank of ffmpeg plugin so codecs that hook into accelerated pieces (e.g. dsp or hw engines) can get picked over this
> +Derived from OE by Dongxiao Xu <dongxiao.xu@intel.com>
> +
> +Upstream-Status: Inappropriate [embedded specific]
> +
> +--- /tmp/gstffmpegdec.c	2009-03-05 09:31:15.000000000 +0100
> ++++ gst-ffmpeg-0.10.6/ext/ffmpeg/gstffmpegdec.c	2009-03-05 09:33:09.000000000 +0100
> +@@ -2588,7 +2588,7 @@
> +       case CODEC_ID_MSMPEG4V3:
> +       case CODEC_ID_H264:
> +       case CODEC_ID_COOK:
> +-        rank = GST_RANK_PRIMARY;
> ++        rank = GST_RANK_SECONDARY;
> +         break;
> +       case CODEC_ID_DVVIDEO:
> +         /* we have a good dv decoder, fast on both ppc as well as x86. they say
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg_0.10.13.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg_0.10.13.bb
> new file mode 100644
> index 0000000..b5c838f
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg_0.10.13.bb
> @@ -0,0 +1,90 @@
> +SUMMARY = "FFmpeg-based GStreamer plug-in"
> +SECTION = "multimedia"
> +LICENSE = "GPLv2+ & LGPLv2+ & ( (GPLv2+ & LGPLv2.1+) | (GPLv3+ & LGPLv3+) )"
> +LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
> +                    file://ext/libpostproc/gstpostproc.c;beginline=1;endline=18;md5=5896e445e41681324381f5869ee33d38 \
> +                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
> +                    file://ext/ffmpeg/gstffmpeg.h;beginline=1;endline=18;md5=ff65467b0c53cdfa98d0684c1bc240a9 \
> +                    file://gst-libs/ext/libav/LICENSE;md5=abc3b8cb02856aa7823bbbd162d16232 \
> +                    file://gst-libs/ext/libav/COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
> +                    file://gst-libs/ext/libav/COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \
> +                    file://gst-libs/ext/libav/COPYING.LGPLv2.1;md5=e344c8fa836c3a41c4cbd79d7bd3a379 \
> +                    file://gst-libs/ext/libav/COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02"
> +LICENSE_FLAGS = "commercial"
> +HOMEPAGE = "http://www.gstreamer.net/"
> +DEPENDS = "gstreamer gst-plugins-base zlib bzip2 yasm-native libpostproc"
> +
> +inherit autotools-brokensep pkgconfig
> +
> +SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2 \
> +           file://lower-rank.diff \
> +           file://configure-fix.patch \
> +           file://h264_qpel_mmx.patch \
> +           file://libav_e500mc.patch \
> +           file://libav_e5500.patch \
> +           file://gst-ffmpeg-CVE-2013-3674.patch \
> +           file://0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch \
> +           file://0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch \
> +           file://0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch \
> +           file://0001-huffyuvdec-Skip-len-0-cases.patch \
> +           file://0001-huffyuvdec-Check-init_vlc-return-codes.patch \
> +           file://0001-alsdec-check-block-length.patch \
> +           file://0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch \
> +           file://0001-atrac3dec-Check-coding-mode-against-channels.patch \
> +           file://0001-eamad-fix-out-of-array-accesses.patch \
> +           file://0001-mjpegdec-check-SE.patch \
> +           file://0001-alac-fix-nb_samples-order-case.patch \
> +           file://0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch \
> +           file://0001-roqvideodec-check-dimensions-validity.patch \
> +           file://0001-aacdec-check-channel-count.patch \
> +           file://0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch \
> +           file://0001-error_concealment-Check-that-the-picture-is-not-in-a.patch \
> +           file://0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch \
> +           file://0001-vp3-Copy-all-3-frames-for-thread-updates.patch \
> +           file://0001-h264_sei-Fix-infinite-loop.patch \
> +           file://0001-avcodec-parser-reset-indexes-on-realloc-failure.patch \
> +           file://0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch \
> +           file://gst-ffmpeg-CVE-2013-0855.patch \
> +           file://0001-qdm2dec-fix-buffer-overflow.patch \
> +           file://0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch \
> +           file://0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch \
> +           file://0001-error-concealment-initialize-block-index.patch \
> +           file://0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch \
> +           file://0001-lavf-compute-probe-buffer-size-more-reliably.patch \
> +           file://0001-ffserver-set-oformat.patch \
> +           file://0001-h264-set-parameters-from-SPS-whenever-it-changes.patch \
> +           file://0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch \
> +           file://0001-avcodec-smc-fix-off-by-1-error.patch \
> +           file://0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch \
> +           file://libav-9.patch \
> +"
> +
> +SRC_URI[md5sum] = "7f5beacaf1312db2db30a026b36888c4"
> +SRC_URI[sha256sum] = "76fca05b08e00134e3cb92fa347507f42cbd48ddb08ed3343a912def187fbb62"
> +
> +PR = "r8"
> +
> +GSTREAMER_DEBUG ?= "--disable-debug"
> +
> +FFMPEG_EXTRA_CONFIGURE = "--with-ffmpeg-extra-configure"
> +# pass --cpu for powerpc. get cpu name by stripping "ppc" or "ppc64"
> +# from DEFAULTTUNE
> +FFMPEG_CPU_powerpc = "--cpu=${@d.getVar('DEFAULTTUNE')[3:]}"
> +FFMPEG_CPU_powerpc64 = "--cpu=${@d.getVar('DEFAULTTUNE')[5:]}"
> +FFMPEG_EXTRA_CONFIGURE_COMMON_ARG = "--target-os=linux ${FFMPEG_CPU} \
> +  --cc='${CC}' --as='${CC}' --ld='${CC}' --nm='${NM}' --ar='${AR}' \
> +  --ranlib='${RANLIB}' \
> +  ${GSTREAMER_DEBUG}"
> +FFMPEG_EXTRA_CONFIGURE_COMMON = \
> +'${FFMPEG_EXTRA_CONFIGURE}="${FFMPEG_EXTRA_CONFIGURE_COMMON_ARG}"'
> +
> +EXTRA_OECONF = "${FFMPEG_EXTRA_CONFIGURE_COMMON}"
> +
> +PACKAGECONFIG ??= "external-libav"
> +PACKAGECONFIG[external-libav] = "--with-system-ffmpeg,,libav"
> +PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
> +
> +FILES_${PN} += "${libdir}/gstreamer-0.10/*.so"
> +FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug"
> +FILES_${PN}-dev += "${libdir}/gstreamer-0.10/*.la"
> +FILES_${PN}-staticdev += "${libdir}/gstreamer-0.10/*.a"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb
> new file mode 100644
> index 0000000..1e2cd2a
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb
> @@ -0,0 +1,14 @@
> +require gst-fluendo.inc
> +
> +SUMMARY = "Fluendo closed-format mp3 GStreamer plug-in"
> +LICENSE = "MIT"
> +LIC_FILES_CHKSUM = "file://COPYING;md5=259a43dd1c9854b71fc396f74699f4d2"
> +LICENSE_FLAGS = "commercial"
> +
> +GSTREAMER_DEBUG ?= "--disable-debug"
> +EXTRA_OECONF += "${GSTREAMER_DEBUG} --with-gstreamer-api=0.10"
> +
> +acpaths = "-I ${S}/common/m4 -I ${S}/m4"
> +
> +SRC_URI[md5sum] = "adf0390f3416bb72f91c358528be0c38"
> +SRC_URI[sha256sum] = "dae0d0559a4e159c0dd92b7e18de059a5783f8d038904c7de4ca6393f7d55c7d"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mpegdemux_0.10.85.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mpegdemux_0.10.85.bb
> new file mode 100644
> index 0000000..7bba41a
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mpegdemux_0.10.85.bb
> @@ -0,0 +1,12 @@
> +require gst-fluendo.inc
> +
> +SUMMARY = "Fluendo MPEG Transport Stream and Program Stream demuxer for GStreamer"
> +LICENSE = "MPLv1.1"
> +LIC_FILES_CHKSUM = "file://COPYING;md5=be282f1c3cc9a98cc0dc5c2b25dfc510 \
> +                    file://src/gstmpegdemux.h;beginline=1;endline=19;md5=a9e90033f59897b91664d9f2a2ff01dd"
> +LICENSE_FLAGS = "commercial"
> +
> +acpaths = "-I ${S}/common/m4 -I ${S}/m4"
> +
> +SRC_URI[md5sum] = "7c4fb993f80b9ae631b11897733f0970"
> +SRC_URI[sha256sum] = "df04c91cc8e5d9a892c2492ed989974b4547beaa2a3647649e85113317897424"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo.inc b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo.inc
> new file mode 100644
> index 0000000..7a77d62
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo.inc
> @@ -0,0 +1,14 @@
> +SUMMARY = "Fluendo closed-format GStreamer plug-in"
> +SECTION = "multimedia"
> +HOMEPAGE = "https://core.fluendo.com/gstreamer/trac/wiki"
> +DEPENDS = "gstreamer gst-plugins-base zlib"
> +
> +inherit autotools pkgconfig
> +
> +SRC_URI = "http://core.fluendo.com/gstreamer/src/${BPN}/${BPN}-${PV}.tar.bz2"
> +
> +FILES_${PN} += "${libdir}/gstreamer-0.10/*.so"
> +FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug"
> +FILES_${PN}-dev += "${libdir}/gstreamer-0.10/*.la ${libdir}/gstreamer-0.10/*.a"
> +
> +EXTRA_OECONF = "--disable-valgrind"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-meta-base_0.10.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-meta-base_0.10.bb
> new file mode 100644
> index 0000000..039abe1
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-meta-base_0.10.bb
> @@ -0,0 +1,73 @@
> +SUMMARY = "GStreamer package groups"
> +LICENSE = "MIT"
> +
> +COMMERCIAL_PLUGINS = "${COMMERCIAL_AUDIO_PLUGINS} ${COMMERCIAL_VIDEO_PLUGINS}"
> +DEPENDS_UGLY="${@'gst-plugins-ugly' if 'ugly' in COMMERCIAL_PLUGINS.split('-') else ''}"
> +DEPENDS_BAD="${@'gst-plugins-bad' if 'bad' in COMMERCIAL_PLUGINS.split('-') else ''}"
> +DEPENDS = "gstreamer gst-plugins-base gst-plugins-good ${DEPENDS_UGLY} ${DEPENDS_BAD}"
> +
> +LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
> +                    file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
> +
> +
> +PR = "r13"
> +
> +PACKAGES = "\
> +    gst-meta-base \
> +    gst-meta-x11-base \
> +    gst-meta-audio \
> +    gst-meta-debug \
> +    gst-meta-video"
> +
> +ALLOW_EMPTY_gst-meta-base = "1"
> +ALLOW_EMPTY_gst-meta-x11-base = "1"
> +ALLOW_EMPTY_gst-meta-audio = "1"
> +ALLOW_EMPTY_gst-meta-debug = "1"
> +ALLOW_EMPTY_gst-meta-video = "1"
> +
> +RDEPENDS_gst-meta-base = "\
> +    ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'gst-meta-x11-base', '', d)} \
> +    gstreamer \
> +    gst-plugins-base-playbin \
> +    gst-plugins-base-decodebin \
> +    gst-plugins-base-decodebin2 \
> +    gst-plugins-base-gio \
> +    gst-plugins-base-alsa \
> +    gst-plugins-base-volume \
> +    gst-plugins-base-audioconvert \
> +    gst-plugins-base-audioresample \
> +    gst-plugins-base-typefindfunctions \
> +    gst-plugins-base-videoscale \
> +    gst-plugins-base-ffmpegcolorspace \
> +    gst-plugins-good-autodetect \
> +    gst-plugins-good-souphttpsrc"
> +
> +RRECOMMENDS_gst-meta-x11-base = "\
> +    gst-plugins-base-ximagesink \
> +    gst-plugins-base-xvimagesink"
> +
> +RDEPENDS_gst-meta-audio = "\
> +    gst-meta-base \
> +    gst-plugins-base-vorbis \
> +    gst-plugins-base-ogg \
> +    gst-plugins-good-wavparse \
> +    gst-plugins-good-flac \
> +    ${COMMERCIAL_AUDIO_PLUGINS}"
> +
> +
> +RDEPENDS_gst-meta-debug = "\
> +    gst-meta-base \
> +    gst-plugins-good-debug \
> +    gst-plugins-base-audiotestsrc \
> +    gst-plugins-base-videotestsrc"
> +
> +
> +RDEPENDS_gst-meta-video = "\
> +    gst-meta-base \
> +    gst-plugins-good-avi \
> +    gst-plugins-good-matroska \
> +    gst-plugins-base-theora \
> +    ${COMMERCIAL_VIDEO_PLUGINS}"
> +
> +RRECOMMENDS_gst-meta-video = "\
> +    gst-meta-audio"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/gcc_4.6.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/gcc_4.6.patch
> new file mode 100644
> index 0000000..57a63b5
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/gcc_4.6.patch
> @@ -0,0 +1,18 @@
> +Upstream-Status: Pending
> +
> +Signed-off-by: Saul Wold <sgw@linux.intel.com>
> +
> +Index: gst-openmax-0.10.1/omx/gstomx.c
> +===================================================================
> +--- gst-openmax-0.10.1.orig/omx/gstomx.c	2010-09-30 18:00:24.000000000 -0700
> ++++ gst-openmax-0.10.1/omx/gstomx.c	2011-05-17 23:08:08.794535872 -0700
> +@@ -238,7 +238,8 @@
> +     const gchar *element_name = gst_structure_nth_field_name (element_table, i);
> +     GstStructure *element = get_element_entry (element_name);
> +     const gchar *type_name, *parent_type_name;
> +-    const gchar *component_name, *component_role, *library_name;
> ++    const gchar *component_name, *library_name;
> ++    const gchar __attribute__((__unused__)) *component_role;
> +     GType type;
> +     gint rank;
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/ptr-array.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/ptr-array.patch
> new file mode 100644
> index 0000000..5965bba
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/ptr-array.patch
> @@ -0,0 +1,46 @@
> +Rename static functions that use GLib naming conventions as one of them
> +(g_ptr_array_insert) has now been added to GLib.
> +
> +Upstream-Status: Pending
> +Signed-off-by: Ross Burton <ross.burton@intel.com>
> +
> +diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
> +index 423e441..579dbf5 100644
> +--- a/omx/gstomx_util.c
> ++++ b/omx/gstomx_util.c
> +@@ -85,7 +85,7 @@ static gboolean initialized;
> +  */
> +
> + static void
> +-g_ptr_array_clear (GPtrArray * array)
> ++omx_g_ptr_array_clear (GPtrArray * array)
> + {
> +   guint index;
> +   for (index = 0; index < array->len; index++)
> +@@ -93,7 +93,7 @@ g_ptr_array_clear (GPtrArray * array)
> + }
> +
> + static void
> +-g_ptr_array_insert (GPtrArray * array, guint index, gpointer data)
> ++omx_g_ptr_array_insert (GPtrArray * array, guint index, gpointer data)
> + {
> +   if (index + 1 > array->len) {
> +     g_ptr_array_set_size (array, index + 1);
> +@@ -394,7 +394,7 @@ g_omx_core_unload (GOmxCore * core)
> +   }
> +
> +   core_for_each_port (core, g_omx_port_free);
> +-  g_ptr_array_clear (core->ports);
> ++  omx_g_ptr_array_clear (core->ports);
> + }
> +
> + static inline GOmxPort *
> +@@ -418,7 +418,7 @@ g_omx_core_new_port (GOmxCore * core, guint index)
> +   }
> +
> +   port = g_omx_port_new (core, index);
> +-  g_ptr_array_insert (core->ports, index, port);
> ++  omx_g_ptr_array_insert (core->ports, index, port);
> +
> +   return port;
> + }
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax_0.10.1.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax_0.10.1.bb
> new file mode 100644
> index 0000000..2e01579
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax_0.10.1.bb
> @@ -0,0 +1,35 @@
> +SUMMARY = "GStreamer plug-in for communication with OpenMAX IL components"
> +DESCRIPTION = "GstOpenMAX is a GStreamer plug-in that allows \
> +communication with OpenMAX Integration Layer (IL) components. OpenMAX \
> +IL is an industry standard that provides an abstraction layer for \
> +computer graphics, video, and sound routines."
> +HOMEPAGE = "http://freedesktop.org/wiki/GstOpenMAX"
> +DEPENDS = "gstreamer"
> +RDEPENDS_${PN} = "libomxil"
> +LICENSE = "LGPLv2.1"
> +LICENSE_FLAGS = "commercial"
> +LIC_FILES_CHKSUM = "file://COPYING;md5=fbc093901857fcd118f065f900982c24 \
> +                    file://util/sem.h;beginline=1;endline=20;md5=accce5550d5583b839b441a0623f09fc"
> +
> +SRC_URI = "http://gstreamer.freedesktop.org/src/gst-openmax/gst-openmax-${PV}.tar.bz2 \
> +           file://gcc_4.6.patch \
> +           file://ptr-array.patch \
> +           "
> +
> +inherit autotools pkgconfig
> +
> +# Tell configure that this isn't a development snapshot so we don't want
> +# -Werror (hopefully fixed in 0.10.2)
> +export GST_CVS="no"
> +
> +EXTRA_OECONF += "--disable-valgrind"
> +
> +PR = "r4"
> +
> +FILES_${PN} += "${libdir}/gstreamer-0.10/libgstomx.so"
> +FILES_${PN}-dev += "${libdir}/gstreamer-0.10/libgstomx.la"
> +FILES_${PN}-staticdev += "${libdir}/gstreamer-0.10/libgstomx.a"
> +FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug/"
> +
> +SRC_URI[md5sum] = "4d0370bfe99dea20918c84347abadb4e"
> +SRC_URI[sha256sum] = "9074d5a0591995133d19cfb15144f19664f902c1623f996595695cf2c2070e1f"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-bad_0.10.23.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-bad_0.10.23.bb
> new file mode 100644
> index 0000000..0f64871
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-bad_0.10.23.bb
> @@ -0,0 +1,50 @@
> +require gst-plugins.inc
> +
> +LICENSE = "GPLv2+ & LGPLv2+ & LGPLv2.1+ "
> +LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
> +                    file://gst/tta/filters.h;beginline=12;endline=29;md5=629b0c7a665d155a6677778f4460ec06 \
> +                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
> +                    file://gst/tta/crc32.h;beginline=12;endline=29;md5=71a904d99ce7ae0c1cf129891b98145c"
> +
> +DEPENDS += "gst-plugins-base"
> +
> +PR = "r4"
> +
> +inherit gettext gsettings
> +
> +EXTRA_OECONF += "--disable-experimental \
> +                 --disable-sdl --disable-cdaudio --disable-directfb \
> +                 --disable-vdpau --disable-apexsink"
> +
> +PACKAGECONFIG ??= "bzip curl \
> +                   ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'rsvg', '', d)}"
> +
> +PACKAGECONFIG[bzip] = "--enable-bz2,--disable-bz2,bzip2"
> +PACKAGECONFIG[curl] = "--enable-curl,--disable-curl,curl"
> +PACKAGECONFIG[rsvg] = "--enable-rsvg,--disable-rsvg,librsvg,"
> +PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
> +PACKAGECONFIG[neon] = "--enable-neon,--disable-neon,neon"
> +PACKAGECONFIG[mms] = "--enable-libmms,--disable-libmms,libmms"
> +PACKAGECONFIG[cog] = "--enable-cog,--disable-cog,libpng"
> +PACKAGECONFIG[faad] = "--enable-faad,--disable-faad,faad2"
> +PACKAGECONFIG[jp2k] = "--enable-jp2k,--disable-jp2k,jasper"
> +PACKAGECONFIG[modplug] = "--enable-modplug,--disable-modplug,libmodplug"
> +PACKAGECONFIG[opus] = "--enable-opus,--disable-opus,libopus"
> +PACKAGECONFIG[sndfile] = "--enable-sndfile,--disable-sndfile,libsndfile1"
> +PACKAGECONFIG[vp8] = "--enable-vp8,--disable-vp8,libvpx"
> +PACKAGECONFIG[ass] = "--enable-assrender,--disable-assrender,libass"
> +PACKAGECONFIG[openal] = "--enable-openal,--disable-openal,openal-soft"
> +PACKAGECONFIG[schro] = "--enable-schro,--disable-schro,schroedinger"
> +PACKAGECONFIG[dc1394] = "--enable-dc1394,--disable-dc1394,libdc1394"
> +PACKAGECONFIG[faac] = "--enable-faac,--disable-faac,faac"
> +PACKAGECONFIG[rtmp] = "--enable-rtmp,--disable-rtmp,rtmpdump"
> +
> +ARM_INSTRUCTION_SET = "arm"
> +
> +do_configure_prepend() {
> +	# This m4 file contains nastiness which conflicts with libtool 2.2.2
> +	rm ${S}/m4/lib-link.m4 || true
> +}
> +
> +SRC_URI[md5sum] = "fcb09798114461955260e4d940db5987"
> +SRC_URI[sha256sum] = "0eae7d1a1357ae8377fded6a1b42e663887beabe0e6cc336e2ef9ada42e11491"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
> new file mode 100644
> index 0000000..5214256
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
> @@ -0,0 +1,37 @@
> +audioresample: Fix build on x86 if emmintrin.h is available but can't be used
> +
> +On x86, EMMINTRIN is defined but not usable without SSE so check for
> +__SSE__ and __SSE2__ as well.
> +
> +https://bugzilla.gnome.org/show_bug.cgi?id=670690
> +
> +Upstream-Status: Backport
> +
> +Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
> +---
> + gst/audioresample/resample.c |    4 ++--
> + 1 files changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/gst/audioresample/resample.c b/gst/audioresample/resample.c
> +index 98d006c..481fa01 100644
> +--- a/gst/audioresample/resample.c
> ++++ b/gst/audioresample/resample.c
> +@@ -77,13 +77,13 @@
> + #define EXPORT G_GNUC_INTERNAL
> +
> + #ifdef _USE_SSE
> +-#ifndef HAVE_XMMINTRIN_H
> ++#if !defined(__SSE__) || !defined(HAVE_XMMINTRIN_H)
> + #undef _USE_SSE
> + #endif
> + #endif
> +
> + #ifdef _USE_SSE2
> +-#ifndef HAVE_EMMINTRIN_H
> ++#if !defined(__SSE2__) || !defined(HAVE_EMMINTRIN_H)
> + #undef _USE_SSE2
> + #endif
> + #endif
> +--
> +1.7.1
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
> new file mode 100644
> index 0000000..b8602c8
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
> @@ -0,0 +1,27 @@
> +Upstream-Status: Submitted [similar patch by other author, bugzilla]
> +Bugtracker-URL: https://bugzilla.gnome.org/show_bug.cgi?id=663600
> +
> +Prepend PKG_CONFIG_SYSROOT to includedir, so configure doesn't
> +search for gstconfig.h in /usr/include.
> +
> +Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
> +---
> + configure.ac |    2 +-
> + 1 files changed, 1 insertions(+), 1 deletions(-)
> +
> +diff --git a/configure.ac b/configure.ac
> +index 1901bcf..460fb0a 100644
> +--- a/configure.ac
> ++++ b/configure.ac
> +@@ -435,7 +435,7 @@ AG_GST_CHECK_PLUGIN(volume)
> + dnl check for gstreamer core features (subsystems)
> + dnl FIXME: this assumes srcdir == builddir for uninstalled setups
> + GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-0.10`"/gst/gstconfig.h"
> +-AG_GST_PARSE_SUBSYSTEM_DISABLES($GST_CONFIGPATH)
> ++AG_GST_PARSE_SUBSYSTEM_DISABLES($PKG_CONFIG_SYSROOT_DIR$GST_CONFIGPATH)
> + AM_CONDITIONAL(USE_XML, test $GST_DISABLE_XML != "1")
> +
> + dnl disable plug-ins that require libxml2's HTML support if it is not available
> +--
> +1.7.5.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
> new file mode 100644
> index 0000000..99dbc9d
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
> @@ -0,0 +1,20 @@
> +Remove -DTREMOR option since Tremor has dropped its internal
> +libogg2, and gst-plugins-base has dependency on that.
> +
> +Upstream-Status: Inappropriate [configuration]
> +
> +Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
> +Signed-off-by: Shane Wang <shane.wang@intel.com>
> +
> +diff -r 70065fb4e085 ext/vorbis/Makefile.am
> +--- a/ext/vorbis/Makefile.am	Tue Mar 13 16:36:56 2012 +0800
> ++++ b/ext/vorbis/Makefile.am	Tue Mar 13 16:38:53 2012 +0800
> +@@ -30,7 +30,7 @@
> + 	gstvorbisdec.c gstvorbisdeclib.c gstvorbiscommon.c
> + libgstivorbisdec_la_CFLAGS = \
> + 	$(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \
> +-	-DTREMOR $(IVORBIS_CFLAGS)
> ++	$(IVORBIS_CFLAGS)
> + libgstivorbisdec_la_LIBADD = \
> + 	$(top_builddir)/gst-libs/gst/tag/libgsttag-@GST_MAJORMINOR@.la \
> + 	$(top_builddir)/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la \
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base_0.10.36.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base_0.10.36.bb
> new file mode 100644
> index 0000000..c8a9499
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base_0.10.36.bb
> @@ -0,0 +1,39 @@
> +require gst-plugins.inc
> +
> +LICENSE = "GPLv2+ & LGPLv2+"
> +LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
> +                    file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=622921ffad8cb18ab906c56052788a3f \
> +                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
> +                    file://gst/ffmpegcolorspace/utils.c;beginline=1;endline=20;md5=9c83a200b8e597b26ca29df20fc6ecd0"
> +
> +DEPENDS += "alsa-lib liboil libogg libvorbis libtheora util-linux tremor glib-2.0-native"
> +
> +SRC_URI += "file://gst-plugins-base-tremor.patch \
> +            file://configure.ac-fix-subparse-plugin.patch \
> +            file://audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch \
> +"
> +
> +SRC_URI[md5sum] = "776c73883e567f67b9c4a2847d8d041a"
> +SRC_URI[sha256sum] = "2cd3b0fa8e9b595db8f514ef7c2bdbcd639a0d63d154c00f8c9b609321f49976"
> +
> +PR = "r8"
> +
> +inherit gettext
> +
> +EXTRA_OECONF += "--disable-freetypetest"
> +
> +PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}"
> +
> +PACKAGECONFIG[gnomevfs] = "--enable-gnome_vfs,--disable-gnome_vfs,gnome-vfs"
> +PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
> +PACKAGECONFIG[pango] = "--enable-pango,--disable-pango,pango"
> +PACKAGECONFIG[x11] = "--enable-x --enable-xvideo,--disable-x --disable-xvideo,virtual/libx11 libxv libsm libice"
> +
> +do_configure_prepend() {
> +	# This m4 file contains nastiness which conflicts with libtool 2.2.2
> +	rm -f ${S}/m4/lib-link.m4
> +}
> +
> +FILES_${PN} += "${datadir}/${BPN}"
> +
> +CACHED_CONFIGUREVARS_append_i586 = " ac_cv_header_emmintrin_h=no ac_cv_header_xmmintrin_h=no"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
> new file mode 100644
> index 0000000..bc2f88b
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
> @@ -0,0 +1,35 @@
> +From 14d51cbefef19737e7ab2b6818ee1d3bdb248d12 Mon Sep 17 00:00:00 2001
> +From: Jeremy Stashluk <jstashluk@dekaresearch.com>
> +Date: Wed, 6 Feb 2013 09:59:48 -0500
> +Subject: [PATCH] conditional gl framebuffer undefined use
> +
> +The OpenGL extension GL_ARB_framebuffer_object defines the macro
> +GL_FRAMEBUFFER_UNDEFINED. The macro will only need to map to an error
> +string if the extension provides functions that might return the macro.
> +
> +Upstream-Status: Pending
> +
> +Signed-off-by: Jeremy Stashluk <jstashluk@dekaresearch.com>
> +---
> + gst-libs/gst/gl/gstgldisplay.c |    2 ++
> + 1 file changed, 2 insertions(+)
> +
> +diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c
> +index 3ed0b71..64c6c2c 100644
> +--- a/gst-libs/gst/gl/gstgldisplay.c
> ++++ b/gst-libs/gst/gl/gstgldisplay.c
> +@@ -2177,9 +2177,11 @@ gst_gl_display_check_framebuffer_status (void)
> +       GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
> +       break;
> +
> ++#if defined(GL_ARB_framebuffer_object)
> +     case GL_FRAMEBUFFER_UNDEFINED:
> +       GST_ERROR ("GL_FRAMEBUFFER_UNDEFINED");
> +       break;
> ++#endif
> +
> +     default:
> +       GST_ERROR ("General FBO error");
> +--
> +1.7.9.5
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl_0.10.3.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl_0.10.3.bb
> new file mode 100644
> index 0000000..90efbcc
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl_0.10.3.bb
> @@ -0,0 +1,25 @@
> +require recipes-multimedia/gstreamer/gst-plugins.inc
> +
> +LICENSE = "GPLv2+ & LGPLv2+ & LGPLv2.1+ "
> +LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605"
> +
> +SRC_URI[md5sum] = "ac70ede13f79978d56eaed8abaa3c938"
> +SRC_URI[sha256sum] = "48340b6a4b8abce16344a7bc33e74a94fdcce4f57ef6342cdf2f941c429bf210"
> +
> +SRC_URI += " file://0001-conditional-gl-framebuffer-undefined-use.patch"
> +
> +DEPENDS += "gst-plugins-base virtual/libgles2 virtual/egl jpeg libpng glew"
> +
> +PR = "r4"
> +
> +inherit gettext
> +
> +# This package doesn't have a configure switch for EGL or GL, so forcibly tell
> +# configure that it can't find gl.h so it always uses EGL.  If/when we have some
> +# way for machines to specify their preferred GL flavour this can be
> +# automatically adapted.
> +EXTRA_OECONF += "ac_cv_header_GL_gl_h=no"
> +
> +ALLOW_EMPTY_${PN} = "1"
> +ALLOW_EMPTY_${PN}-apps = "1"
> +ALLOW_EMPTY_${PN}-glib = "1"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
> new file mode 100644
> index 0000000..6456d3c
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
> @@ -0,0 +1,33 @@
> +From 12d18fe4e98e7c232d59b56d529a0521f293fe6d Mon Sep 17 00:00:00 2001
> +From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com>
> +Date: Wed, 5 Sep 2012 18:54:42 +0200
> +Subject: [PATCH] v4l2: fix build with recent kernels, the v4l2_buffer input
> + field was removed
> +MIME-Version: 1.0
> +Content-Type: text/plain; charset=UTF-8
> +Content-Transfer-Encoding: 8bit
> +
> +Upstream-Status: Backport
> +
> +[1] http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=9f2aa8d47f835ea155aaf635f618c0fc1ca87012
> +
> +Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
> +---
> + sys/v4l2/gstv4l2bufferpool.c |    1 -
> + 1 files changed, 0 insertions(+), 1 deletions(-)
> +
> +diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c
> +index b81c6a4..51cc0ce 100644
> +--- a/sys/v4l2/gstv4l2bufferpool.c
> ++++ b/sys/v4l2/gstv4l2bufferpool.c
> +@@ -181,7 +181,6 @@ gst_v4l2_buffer_new (GstV4l2BufferPool * pool, guint index, GstCaps * caps)
> +     GST_LOG_OBJECT (pool->v4l2elem, "  MMAP offset:  %u",
> +         ret->vbuffer.m.offset);
> +   GST_LOG_OBJECT (pool->v4l2elem, "  length:    %u", ret->vbuffer.length);
> +-  GST_LOG_OBJECT (pool->v4l2elem, "  input:     %u", ret->vbuffer.input);
> +
> +   data = (guint8 *) v4l2_mmap (0, ret->vbuffer.length,
> +       PROT_READ | PROT_WRITE, MAP_SHARED, pool->video_fd,
> +--
> +1.7.6.5
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
> new file mode 100644
> index 0000000..bd0de58
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
> @@ -0,0 +1,45 @@
> +From ccb01de8096a32d86d47b0d92ec3416c57ee4d25 Mon Sep 17 00:00:00 2001
> +From: Bruce Ashfield <bruce.ashfield@windriver.com>
> +Date: Thu, 22 Aug 2013 12:15:54 -0400
> +Subject: [PATCH] v4l2_calls: define V4L2_CID_HCENTER and V4L2_CID_VCENTER
> +
> +kernel commit 24b9f5017 [[media] V4L: Remove deprecated image centering controls]
> +removed the definitions of V4L2_CID_HCENTER and V4L2_CID_VCENTER after three
> +years of depreciation.
> +
> +The ioctl values are still free, and the case statement which processess them
> +in v4l2 userspace falls through to the proper replacement. So in the short
> +term, we can explicitly define them using the old absolute values, and everything
> +will work.
> +
> +Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
> +---
> + sys/v4l2/v4l2_calls.c |    9 +++++++--
> + 1 file changed, 7 insertions(+), 2 deletions(-)
> +
> +diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c
> +index 309bfb6..3c64544 100644
> +--- a/sys/v4l2/v4l2_calls.c
> ++++ b/sys/v4l2/v4l2_calls.c
> +@@ -54,11 +54,16 @@
> + #include "gst/gst-i18n-plugin.h"
> +
> + /* Those are ioctl calls */
> ++
> ++/* V4L2_CID_HCENTER has been removed from the mainline kernel, but
> ++   the ioctl space is still present. Since these values fall through
> ++   to their replacement, it is safe (in the short term) to re-use the
> ++    old values explictily */
> + #ifndef V4L2_CID_HCENTER
> +-#define V4L2_CID_HCENTER V4L2_CID_HCENTER_DEPRECATED
> ++#define V4L2_CID_HCENTER V4L2_CID_BASE+22
> + #endif
> + #ifndef V4L2_CID_VCENTER
> +-#define V4L2_CID_VCENTER V4L2_CID_VCENTER_DEPRECATED
> ++#define V4L2_CID_VCENTER V4L2_CID_BASE+23
> + #endif
> +
> + GST_DEBUG_CATEGORY_EXTERN (v4l2_debug);
> +--
> +1.7.10.4
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
> new file mode 100644
> index 0000000..48b8e98
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
> @@ -0,0 +1,47 @@
> +From ce94b2c2b91b6db190c121860e12a6afafce7ae1 Mon Sep 17 00:00:00 2001
> +From: Roland Krikava <rkrikava@gmail.com>
> +Date: Fri, 2 Nov 2012 12:38:44 -0400
> +Subject: [PATCH 407/440] mulawdec: fix integer overrun
> +
> +There might be more than 65535 samples in a chunk of data.
> +
> +https://bugzilla.gnome.org/show_bug.cgi?id=687469
> +
> +Commit - 3be45f70220310ec1c60d819f90b5f2ae03b5d83 in 0.10 branch
> +
> +Upstream Status:  Backported
> +
> +Signed-off-by: Roland Krikava <rkrikava@gmail.com>
> +---
> + gst/law/mulaw-conversion.c |    6 ++++--
> + 1 file changed, 4 insertions(+), 2 deletions(-)
> +
> +diff --git a/gst/law/mulaw-conversion.c b/gst/law/mulaw-conversion.c
> +index 8afae80..190a9f5 100644
> +--- a/gst/law/mulaw-conversion.c
> ++++ b/gst/law/mulaw-conversion.c
> +@@ -51,9 +51,10 @@ mulaw_encode (gint16 * in, guint8 * out, gint numsamples)
> +     7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
> +     7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
> +   };
> +-  gint16 sign, exponent, mantissa, i;
> ++  gint16 sign, exponent, mantissa;
> +   gint16 sample;
> +   guint8 ulawbyte;
> ++  gint i;
> +
> +   for (i = 0; i < numsamples; i++) {
> +     sample = in[i];
> +@@ -102,7 +103,8 @@ mulaw_decode (guint8 * in, gint16 * out, gint numsamples)
> +   static gint16 exp_lut[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 };
> +   gint16 sign, exponent, mantissa;
> +   guint8 ulawbyte;
> +-  gint16 linear, i;
> ++  gint16 linear;
> ++  gint i;
> +
> +   for (i = 0; i < numsamples; i++) {
> +     ulawbyte = in[i];
> +--
> +1.7.9.5
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good_0.10.31.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good_0.10.31.bb
> new file mode 100644
> index 0000000..af18281
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good_0.10.31.bb
> @@ -0,0 +1,47 @@
> +require gst-plugins.inc
> +
> +LICENSE = "GPLv2+ & LGPLv2.1+"
> +LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
> +                    file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=622921ffad8cb18ab906c56052788a3f \
> +                    file://gst/replaygain/rganalysis.c;beginline=1;endline=23;md5=b60ebefd5b2f5a8e0cab6bfee391a5fe"
> +
> +PR = "r8"
> +
> +PACKAGECONFIG ?= "jpeg v4l \
> +    ${@bb.utils.contains('DISTRO_FEATURES', 'pulseaudio', 'pulseaudio', '', d)} \
> +    ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)} \
> +"
> +PACKAGECONFIG[pulseaudio] = "--enable-pulse,--disable-pulse,pulseaudio"
> +PACKAGECONFIG[jack] = "--enable-jack,--disable-jack,jack"
> +PACKAGECONFIG[jpeg] = "--enable-jpeg,--disable-jpeg,jpeg"
> +PACKAGECONFIG[wavpack] = "--enable-wavpack,--disable-wavpack,wavpack"
> +PACKAGECONFIG[gdkpixbuf] = "--enable-gdk_pixbuf,--disable-gdk_pixbuf,gdk-pixbuf"
> +PACKAGECONFIG[v4l] = "--enable-gst_v4l2 --with-gudev,--disable-gst_v4l2 --without-gudev,udev"
> +# sub-feature of v4l, but control separately since libv4l is not part of oe-core
> +PACKAGECONFIG[libv4l] = "--with-libv4l2,--without-libv4l2,libv4l"
> +PACKAGECONFIG[bzip2] = "--enable-bz2,--disable-bz2,bzip2"
> +PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
> +PACKAGECONFIG[x11] = "--enable-x,--disable-x,virtual/libx11 libxfixes libxdamage"
> +
> +DEPENDS += "gst-plugins-base gconf cairo libpng zlib libid3tag flac \
> +            speex libsoup-2.4 libcap"
> +
> +inherit gettext gconf
> +
> +SRC_URI += "file://0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch \
> +            file://0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch \
> +            file://0407-mulawdec-fix-integer-overrun.patch \
> +"
> +EXTRA_OECONF += "--disable-aalib --disable-esd --disable-shout2 --disable-libcaca --disable-hal \
> +                 --disable-examples --disable-taglib"
> +
> +do_configure_prepend() {
> +	# This m4 file contains nastiness which conflicts with libtool 2.2.2
> +	rm ${S}/m4/lib-link.m4 || true
> +}
> +
> +SRC_URI[md5sum] = "24f98a294a2b521e1b29412bdadae2e6"
> +SRC_URI[sha256sum] = "7e27840e40a7932ef2dc032d7201f9f41afcaf0b437daf5d1d44dc96d9e35ac6"
> +
> +FILES_${PN}-gconfelements += "${sysconfdir}/gconf/schemas/gstreamer-0.10.schemas"
> +FILES_${PN}-equalizer += "${datadir}/gstreamer-0.10/presets/*.prs"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-ugly_0.10.19.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-ugly_0.10.19.bb
> new file mode 100644
> index 0000000..2fdf03f
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-ugly_0.10.19.bb
> @@ -0,0 +1,29 @@
> +require gst-plugins.inc
> +
> +LICENSE = "GPLv2+ & LGPLv2.1+ & LGPLv2+"
> +LICENSE_FLAGS = "commercial"
> +LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
> +                    file://gst/synaesthesia/synaescope.h;beginline=1;endline=20;md5=99f301df7b80490c6ff8305fcc712838 \
> +                    file://tests/check/elements/xingmux.c;beginline=1;endline=21;md5=4c771b8af188724855cb99cadd390068 \
> +                    file://gst/mpegstream/gstmpegparse.h;beginline=1;endline=18;md5=ff65467b0c53cdfa98d0684c1bc240a9"
> +
> +DEPENDS += "gst-plugins-base libid3tag libmad mpeg2dec liba52 lame"
> +PR = "r3"
> +
> +inherit gettext
> +
> +EXTRA_OECONF += "--with-plugins=a52dec,lame,id3tag,mad,mpeg2dec,mpegstream,mpegaudioparse,asfdemux,realmedia \
> +                 --disable-orc"
> +
> +PACKAGECONFIG ??= ""
> +PACKAGECONFIG[x264] = "--enable-x264,--disable-x264,x264"
> +PACKAGECONFIG[cdio] = "--enable-cdio,--disable-cdio,libcdio"
> +PACKAGECONFIG[dvdread] = "--enable-dvdread,--disable-dvdread,libdvdread"
> +
> +do_configure_prepend() {
> +	# This m4 file contains nastiness which conflicts with libtool 2.2.2
> +	rm ${S}/m4/lib-link.m4 || true
> +}
> +
> +SRC_URI[md5sum] = "1d81c593e22a6cdf0f2b4f57eae93df2"
> +SRC_URI[sha256sum] = "1ca90059275c0f5dca71d4d1601a8f429b7852baed0723e820703b977e2c8df0"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins.inc b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins.inc
> new file mode 100644
> index 0000000..c852c53
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins.inc
> @@ -0,0 +1,28 @@
> +SUMMARY = "Plugins for the GStreamer multimedia framework"
> +HOMEPAGE = "http://gstreamer.freedesktop.org/"
> +BUGTRACKER = "https://bugzilla.gnome.org/enter_bug.cgi?product=Gstreamer"
> +SECTION = "multimedia"
> +DEPENDS = "gstreamer"
> +
> +inherit autotools pkgconfig
> +
> +SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2"
> +
> +GSTREAMER_DEBUG ?= "--disable-debug"
> +EXTRA_OECONF = "--disable-valgrind ${GSTREAMER_DEBUG} --disable-examples "
> +
> +acpaths = "-I ${S}/common/m4 -I ${S}/m4"
> +
> +LIBV = "0.10"
> +require gst-plugins-package.inc
> +
> +PACKAGES_DYNAMIC += "^${PN}-.*"
> +
> +# apply gstreamer hack after Makefile.in.in in source is replaced by our version from
> +# ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in, but before configure is executed
> +# http://lists.linuxtogo.org/pipermail/openembedded-core/2012-November/032233.html
> +oe_runconf_prepend() {
> +	if [ -e ${S}/po/Makefile.in.in ]; then
> +		sed -i -e "1a\\" -e 'GETTEXT_PACKAGE = @GETTEXT_PACKAGE@' ${S}/po/Makefile.in.in
> +	fi
> +}
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
> new file mode 100644
> index 0000000..3afca4e
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
> @@ -0,0 +1,34 @@
> +index gst-rtsp_0.10.8/bindings/python/Makefile.am
> +--- gst-rtsp_0.10.8.orig/bindings/python/Makefile.am
> ++++ gst-rtsp_0.10.8/bindings/python/Makefile.am
> +@@ -14,7 +14,7 @@ defs_DATA = $(DEFS)
> + defsdir = $(pkgdatadir)/$(GST_MAJORMINOR)/defs
> + OVERRIDES = rtspserver.override
> +
> +-INCLUDES = -I$(top_srcdir) -I$(srcdir) $(PYTHON_INCLUDES)
> ++AM_CPPFLAGS = -I$(top_srcdir) -I$(srcdir) $(PYTHON_INCLUDES)
> +
> + rtspserver_la_CFLAGS = -I$(top_srcdir)/src \
> +         $(PYGOBJECT_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
> +index gst-rtsp_0.10.8/examples/Makefile.am
> +--- gst-rtsp_0.10.8.orig/examples/Makefile.am
> ++++ gst-rtsp_0.10.8/examples/Makefile.am
> +@@ -1,6 +1,6 @@
> + noinst_PROGRAMS = test-video test-ogg test-mp4 test-readme test-launch test-sdp test-uri test-auth
> +
> +-INCLUDES = -I$(top_srcdir) -I$(srcdir)
> ++AM_CPPFLAGS = -I$(top_srcdir) -I$(srcdir)
> +
> + AM_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
> + AM_LDFLAGS = \
> +index gst-rtsp_0.10.8/tests/Makefile.am
> +--- gst-rtsp_0.10.8.orig/tests/Makefile.am
> ++++ gst-rtsp_0.10.8/tests/Makefile.am
> +@@ -1,6 +1,6 @@
> + noinst_PROGRAMS = test-cleanup
> +
> +-INCLUDES = -I$(top_srcdir) -I$(srcdir)
> ++AM_CPPFLAGS = -I$(top_srcdir) -I$(srcdir)
> +
> + AM_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
> + AM_LDFLAGS = \
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp_0.10.8.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp_0.10.8.bb
> new file mode 100644
> index 0000000..9318656
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp_0.10.8.bb
> @@ -0,0 +1,16 @@
> +SUMMARY = "GStreamer RTSP server"
> +LICENSE = "LGPLv2+"
> +LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605"
> +
> +SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2 \
> +           file://0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch"
> +SRC_URI[md5sum] = "b511af07000595f63c3a705946221643"
> +SRC_URI[sha256sum] = "9915887cf8515bda87462c69738646afb715b597613edc7340477ccab63a6617"
> +
> +DEPENDS = "gst-plugins-base gstreamer"
> +
> +# Configure always checks for Python so inherit pythonnative. Better solution
> +# would be to disable the checks entirely.
> +inherit autotools pythonnative gettext
> +
> +FILES_${PN}-dev += "${datadir}/vala/vapi/"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
> new file mode 100644
> index 0000000..d077496
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
> @@ -0,0 +1,32 @@
> +From ed7f4802222234eef192aa3f74bc92268f338f97 Mon Sep 17 00:00:00 2001
> +From: Sebastian Droege <sebastian.droege@collabora.co.uk>
> +Date: Tue, 6 Mar 2012 12:28:02 +0100
> +Subject: [PATCH] baseparse: Fix 'self-comparison always evaluates to true'
> +
> +This was really a bug.
> +
> +Commit is ed7f4802222234eef192aa3f74bc92268f338f97 in 0.10 branch
> +
> +Upstream Status:  Backported
> +
> +Signed-off-by: Sebastian Droege <sebastian.droege@collabora.co.uk>
> +---
> + libs/gst/base/gstbaseparse.c |    2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c
> +index 851ec1d..108ee89 100644
> +--- a/libs/gst/base/gstbaseparse.c
> ++++ b/libs/gst/base/gstbaseparse.c
> +@@ -3899,7 +3899,7 @@ gst_base_parse_handle_seek (GstBaseParse * parse, GstEvent * event)
> +        seek event (in bytes) to upstream. Segment / flush handling happens
> +        in corresponding src event handlers */
> +     GST_DEBUG_OBJECT (parse, "seek in PUSH mode");
> +-    if (seekstop >= 0 && seekpos <= seekpos)
> ++    if (seekstop >= 0 && seekstop <= seekpos)
> +       seekstop = seekpos;
> +     new_event = gst_event_new_seek (rate, GST_FORMAT_BYTES, flags,
> +         GST_SEEK_TYPE_SET, seekpos, stop_type, seekstop);
> +--
> +1.7.9.5
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/check_fix.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/check_fix.patch
> new file mode 100644
> index 0000000..5d8bb13
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/check_fix.patch
> @@ -0,0 +1,19 @@
> +# gstreamer: Fix a problem with configure if check has already been built
> +# Richard Purdie <rpurdie@linux.intel.com>
> +
> +Upstream-Status: Inappropriate [configuration]
> +
> +diff -urN gstreamer-0.10.29-orig/configure.ac gstreamer-0.10.29/configure.ac
> +--- gstreamer-0.10.29-orig/configure.ac	2010-06-26 12:49:27.774930773 +0800
> ++++ gstreamer-0.10.29/configure.ac	2010-06-26 12:51:12.899200233 +0800
> +@@ -543,8 +543,10 @@
> +       *) BUILD_CHECK=yes ;;
> +     esac
> + ])
> ++
> + dnl bit of a misnomer, but keep the conditional named like this so we don't
> + dnl have to change too much elsewhere
> ++HAVE_CHECK=no
> + AM_CONDITIONAL(HAVE_CHECK, test "x$BUILD_CHECK" = "xyes")
> +
> + dnl configure the desired buffer alignment
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gst-inspect-check-error.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gst-inspect-check-error.patch
> new file mode 100644
> index 0000000..30be85f
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gst-inspect-check-error.patch
> @@ -0,0 +1,16 @@
> +# Fix crash with gst-inspect
> +# Chris Lord <chris@openedhand.com>
> +
> +Upstream-Status: Pending
> +
> +--- gstreamer-0.10.9/tools/gst-inspect.c.old	2006-09-12 11:56:53.000000000 +0100
> ++++ gstreamer-0.10.9/tools/gst-inspect.c	2006-09-12 11:57:27.000000000 +0100
> +@@ -1123,7 +1123,7 @@
> +   g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
> +   g_option_context_add_group (ctx, gst_init_get_option_group ());
> +   if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
> +-    g_print ("Error initializing: %s\n", err->message);
> ++    g_print ("Error initializing: %s\n", err ? err->message : "(null)");
> +     exit (1);
> +   }
> +   g_option_context_free (ctx);
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
> new file mode 100644
> index 0000000..bf93cb2
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
> @@ -0,0 +1,33 @@
> +gstreamer: change priv_gst_parse_yylex arguments
> +
> +Change priv_gst_parse_yylex to fit new bison version, else we will
> +get following error:
> +
> +| grammar.tab.c: In function 'priv_gst_parse_yyparse':
> +| grammar.tab.c:67:25: error: too few arguments to function 'priv_gst_parse_yylex'
> +|  #define yylex           priv_gst_parse_yylex
> +|                          ^
> +
> +Upstream-Status: Pending
> +
> +Signed-off-by: Chong Lu <Chong.Lu@windriver.com>
> +---
> + gst/parse/grammar.y | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/gst/parse/grammar.y b/gst/parse/grammar.y
> +index 24fc87b..24fe906 100644
> +--- a/gst/parse/grammar.y
> ++++ b/gst/parse/grammar.y
> +@@ -36,7 +36,7 @@
> +
> + typedef void* yyscan_t;
> +
> +-int priv_gst_parse_yylex (void * yylval_param , yyscan_t yyscanner);
> ++int priv_gst_parse_yylex (yyscan_t yyscanner);
> + int priv_gst_parse_yylex_init (yyscan_t scanner);
> + int priv_gst_parse_yylex_destroy (yyscan_t scanner);
> + struct yy_buffer_state * priv_gst_parse_yy_scan_string (char* , yyscan_t);
> +--
> +1.9.1
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.c b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.c
> new file mode 100644
> index 0000000..c1f3e71
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.c
> @@ -0,0 +1,487 @@
> +/* GStreamer
> + * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
> + *                    2000 Wim Taymans <wtay@chello.be>
> + *                    2005 David A. Schleef <ds@schleef.org>
> + *
> + * gstregistryxml.c: GstRegistry object, support routines
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it ulnder 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.
> + */
> +
> +
> +#include <gst/gstregistrybinary.h>
> +
> +/*
> +** Simple handy function to write a memory location to the registry cache file
> +*/
> +inline static gboolean
> +gst_registry_binary_write(GstRegistry *registry, const void *mem, const ssize_t size)
> +{
> +  if (write(registry->cache_file, mem, size) != size)
> +    {
> +      GST_ERROR("Failed to write binary registry element: ptr=%p size=%u error=%s\n",
> +		mem, size, strerror(errno));
> +      return FALSE;
> +    }
> +  return TRUE;
> +}
> +
> +/*
> +** Save features GstBinary style
> +*/
> +static gboolean
> +gst_registry_binary_fill_feature(GList **list, GstPluginFeature *orig, GstBinaryPluginFeature *dest, const char *name)
> +{
> +  GstBinaryChunck *chk;
> +
> +  if ((chk = calloc(1, sizeof (GstBinaryChunck))) == NULL)
> +    return FALSE;
> +
> +  chk->data = dest;
> +  chk->size = sizeof (GstBinaryPluginFeature);
> +
> +  *list = g_list_append(*list, chk);
> +
> +  dest->rank = orig->rank;
> +  if (!strncpy(dest->typename, name, GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN) ||
> +      !strncpy(dest->name, orig->name, GST_BINARY_REGISTRY_TYPENAME_NAME_LEN))
> +    {
> +      GST_ERROR("Failed to write binary registry feature");
> +      goto fail;
> +    }
> +
> +  if (GST_IS_ELEMENT_FACTORY(orig))
> +    {
> +      GstElementFactory *factory = GST_ELEMENT_FACTORY(orig);
> +
> +      if (!strncpy(dest->longname, factory->details.longname, GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN) ||
> +	  !strncpy(dest->class, factory->details.klass, GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN) ||
> +	  !strncpy(dest->description, factory->details.description, GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN) ||
> +	  !strncpy(dest->author, factory->details.author, GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN))
> +	{
> +	  GST_ERROR("Failed to write binary registry feature");
> +	  goto fail;
> +	}
> +    }
> +
> +  dest->npadtemplates = dest->ninterfaces = dest->nuritypes = 0;
> +  return TRUE;
> +
> + fail:
> +  free(chk);
> +  return FALSE;
> +}
> +
> +
> +/*
> +** Initialize the GstBinaryRegistryMagic, setting both our magic number and gstreamer major/minor version
> +*/
> +inline static gboolean
> +gst_registry_binary_initialize_magic(GstBinaryRegistryMagic *m)
> +{
> +  if (!strncpy(m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) ||
> +      !strncpy(m->version, GST_MAJORMINOR, GST_BINARY_REGISTRY_VERSION_LEN))
> +    {
> +      GST_ERROR("Failed to write magic to the registry magic structure");
> +      return FALSE;
> +    }
> +  return TRUE;
> +}
> +
> +/*
> +** Check GstBinaryRegistryMagic validity.
> +** Return a pointer pointing right after the magic structure
> +*/
> +static gchar *
> +gst_registry_binary_check_magic(gchar *in)
> +{
> +  GstBinaryRegistryMagic *m = (GstBinaryRegistryMagic *) in;
> +
> +  if (m == NULL || m->magic == NULL || m->version == NULL)
> +    {
> +      GST_ERROR("Binary registry magic structure is broken");
> +      return NULL;
> +    }
> +  if (strncmp(m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) != 0)
> +    {
> +      GST_ERROR("Binary registry magic is different : %02x%02x%02x%02x != %02x%02x%02x%02x",
> +		GST_MAGIC_BINARY_REGISTRY_STR[0] & 0xff, GST_MAGIC_BINARY_REGISTRY_STR[1] & 0xff,
> +		GST_MAGIC_BINARY_REGISTRY_STR[2] & 0xff, GST_MAGIC_BINARY_REGISTRY_STR[3] & 0xff,
> +		m->magic[0] & 0xff, m->magic[1] & 0xff, m->magic[2] & 0xff, m->magic[3] & 0xff);
> +      return NULL;
> +    }
> +  if (strncmp(m->version, GST_MAJORMINOR, GST_BINARY_REGISTRY_VERSION_LEN))
> +    {
> +      GST_ERROR("Binary registry magic version is different : %s != %s",
> +		GST_MAJORMINOR, m->version);
> +      return NULL;
> +    }
> +  return (in + sizeof (GstBinaryRegistryMagic));
> +}
> +
> +/*
> +** Adapt a GstPlugin to our GstBinaryPluginElement structure, and write it to the
> +** registry file.
> +*/
> +static gboolean
> +gst_registry_binary_save_plugin(GList **list, GstRegistry *registry, GstPlugin *plugin)
> +{
> +  GstBinaryPluginElement *e;
> +  GstBinaryChunck *chk;
> +  GList *walk;
> +
> +  if ((e = calloc(1, sizeof (GstBinaryPluginElement))) == NULL ||
> +      (chk = calloc(1, sizeof (GstBinaryChunck))) == NULL)
> +    return FALSE;
> +
> +  chk->data = e;
> +  chk->size = sizeof (GstBinaryPluginElement);
> +  *list = g_list_append(*list, chk);
> +
> +  if (!strncpy(e->name, plugin->desc.name, GST_BINARY_REGISTRY_NAME_LEN)		       	||
> +      !strncpy(e->description, plugin->desc.description, GST_BINARY_REGISTRY_DESCRIPTION_LEN)	||
> +      !strncpy(e->filename, plugin->filename, _POSIX_PATH_MAX)					||
> +      !strncpy(e->version, plugin->desc.version, GST_BINARY_REGISTRY_VERSION_LEN)		||
> +      !strncpy(e->license, plugin->desc.license, GST_BINARY_REGISTRY_LICENSE_LEN)		||
> +      !strncpy(e->source, plugin->desc.source, GST_BINARY_REGISTRY_SOURCE_LEN)			||
> +      !strncpy(e->package, plugin->desc.package, GST_BINARY_REGISTRY_PACKAGE_LEN)		||
> +      !strncpy(e->origin, plugin->desc.origin, GST_BINARY_REGISTRY_ORIGIN_LEN))
> +    {
> +      GST_DEBUG("Can't adapt GstPlugin to GstBinaryPluginElement");
> +      goto fail;
> +    }
> +
> +  e->size = plugin->file_size;
> +  e->m32p = plugin->file_mtime;
> +
> +  GList *ft_list = gst_registry_get_feature_list_by_plugin(registry, plugin->desc.name);
> +
> +  for (walk = ft_list; walk; walk = g_list_next(walk), e->nfeatures++)
> +    {
> +      GstPluginFeature *curfeat = GST_PLUGIN_FEATURE (walk->data);
> +      GstBinaryPluginFeature *newfeat;
> +      const char *feat_name = g_type_name(G_OBJECT_TYPE(curfeat));
> +
> +      if ((newfeat = calloc(1, sizeof (GstBinaryPluginFeature))) == NULL)
> +	  goto fail;
> +
> +      if (!feat_name || !gst_registry_binary_fill_feature(list, curfeat, newfeat, feat_name))
> +	{
> +	  GST_ERROR("Can't fill plugin feature, aborting.");
> +	  goto fail;
> +	}
> +    }
> +
> +  GST_DEBUG("Found %d features in plugin \"%s\"\n", e->nfeatures, e->name);
> +  return TRUE;
> +
> + fail:
> +  free(chk);
> +  free(e);
> +  return FALSE;
> +}
> +
> +/*
> +** Write the cache to file. Part of the code was taken from gstregistryxml.c
> +*/
> +gboolean
> +gst_registry_binary_write_cache(GstRegistry *registry, const char *location)
> +{
> +  GList *walk;
> +  char *tmp_location;
> +  GstBinaryRegistryMagic *magic;
> +  GstBinaryChunck *magic_chunck;
> +  GList *to_write = NULL;
> +
> +  GST_INFO("Writing binary registry cache");
> +
> +  g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
> +  tmp_location = g_strconcat (location, ".tmpXXXXXX", NULL);
> +  registry->cache_file = g_mkstemp (tmp_location);
> +  if (registry->cache_file == -1)
> +    {
> +      char *dir;
> +
> +      /* oops, I bet the directory doesn't exist */
> +      dir = g_path_get_dirname (location);
> +      g_mkdir_with_parents (dir, 0777);
> +      g_free (dir);
> +
> +      registry->cache_file = g_mkstemp (tmp_location);
> +    }
> +
> +  if (registry->cache_file == -1)
> +    goto fail;
> +
> +  if ((magic = calloc(1, sizeof (GstBinaryRegistryMagic))) == NULL ||
> +      !gst_registry_binary_initialize_magic(magic))
> +    goto fail;
> +
> +  if ((magic_chunck = calloc(1, sizeof (GstBinaryChunck))) == NULL)
> +    goto fail;
> +
> +  magic_chunck->data = magic;
> +  magic_chunck->size = sizeof (GstBinaryRegistryMagic);
> +  to_write = g_list_append(to_write, magic_chunck);
> +
> +  /* Iterate trough the list of plugins in the GstRegistry and adapt them to our structures */
> +  for (walk = g_list_last(registry->plugins); walk; walk = g_list_previous(walk))
> +    {
> +      GstPlugin *plugin = GST_PLUGIN(walk->data);
> +
> +      if (!plugin->filename)
> +	continue;
> +	
> +      if (plugin->flags & GST_PLUGIN_FLAG_CACHED)
> +	{
> +	  int ret;
> +	  struct stat statbuf;
> +	
> +	  ret = g_stat (plugin->filename, &statbuf);
> +	  if ((ret = g_stat (plugin->filename, &statbuf)) < 0 	||
> +	      plugin->file_mtime != statbuf.st_mtime		||
> +	      plugin->file_size != statbuf.st_size)
> +	    continue;
> +	}
> +
> +      if (!gst_registry_binary_save_plugin(&to_write, registry, plugin))
> +	{
> +	  GST_ERROR("Can't write binary plugin information for \"%s\"", plugin->filename);
> +	  continue; /* Try anyway */
> +	}
> +    }
> +
> +  for (walk = g_list_first(to_write); walk; walk = g_list_next(walk))
> +    {
> +      GstBinaryChunck *cur = walk->data;
> +
> +      if (!gst_registry_binary_write(registry, cur->data, cur->size))
> +	{
> +	  free(cur->data);
> +	  free(cur);
> +	  g_list_free(to_write);
> +	  goto fail;
> +	}
> +      free(cur->data);
> +      free(cur);
> +    }
> +  g_list_free(to_write);
> +
> +  if (close(registry->cache_file) < 0)
> +    {
> +      GST_DEBUG("Can't close registry file : %s", strerror(errno));
> +      goto fail;
> +    }
> +
> +  if (g_file_test (tmp_location, G_FILE_TEST_EXISTS)) {
> +#ifdef WIN32
> +    remove (location);
> +#endif
> +    rename (tmp_location, location);
> +  }
> +
> +  g_free (tmp_location);
> +  return TRUE;
> +
> + fail:
> +  g_free(tmp_location);
> +  return FALSE;
> +}
> +
> +static GstPluginFeature*
> +gst_registry_binary_load_feature(GstBinaryPluginFeature *in)
> +{
> +  GstPluginFeature *feature;
> +  GType type;
> +
> +  if (!in->typename || !*(in->typename))
> +    return NULL;
> +
> +  /*  GST_INFO("Plugin feature typename : %s", in->typename);*/
> +
> +  if (!(type = g_type_from_name(in->typename)))
> +    {
> +      GST_ERROR("Unknown type from typename");
> +      return NULL;
> +    }
> +  feature = g_object_new (type, NULL);
> +
> +  if (!feature) {
> +    GST_ERROR("Can't create feature from type");
> +    return NULL;
> +  }
> +
> +  if (!GST_IS_PLUGIN_FEATURE (feature)) {
> +    /* don't really know what it is */
> +    if (GST_IS_OBJECT (feature))
> +      gst_object_unref (feature);
> +    else
> +      g_object_unref (feature);
> +    return NULL;
> +  }
> +
> +  feature->name = g_strdup(in->name);
> +  feature->rank = in->rank;
> +
> +  if (GST_IS_ELEMENT_FACTORY(feature))
> +    {
> +      GstElementFactory *factory = GST_ELEMENT_FACTORY(feature);
> +
> +      factory->details.longname = g_strdup(in->longname);
> +      factory->details.klass = g_strdup(in->class);
> +      factory->details.description = g_strdup(in->description);
> +      factory->details.author = g_strdup(in->author);
> +
> +      /*      GST_INFO("Element factory : %s", factory->details.longname); */
> +    }
> +
> +  GST_DEBUG("Added feature %p with name %s", feature, feature->name);
> +  return feature;
> +}
> +
> +/*
> +** Make a new plugin from current GstBinaryPluginElement structure
> +** and save it to the GstRegistry. Return an offset to the next
> +** GstBinaryPluginElement structure.
> +*/
> +static unsigned long
> +gst_registry_binary_get_binary_plugin(GstRegistry *registry, gchar *in)
> +{
> +  GstBinaryPluginElement *p = (GstBinaryPluginElement *) in;
> +  GstPlugin *plugin = NULL;
> +  GList *plugin_features = NULL;
> +  GstBinaryPluginFeature *feat;
> +  unsigned int i;
> +  unsigned long offset;
> +
> +  plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
> +
> +  plugin->flags |= GST_PLUGIN_FLAG_CACHED;
> +
> +  plugin->desc.name = g_strdup(p->name);
> +  plugin->desc.description= g_strdup(p->description);
> +  plugin->filename = g_strdup(p->filename);
> +  plugin->desc.version = g_strdup(p->version);
> +  plugin->desc.license = g_strdup(p->license);
> +  plugin->desc.source = g_strdup(p->source);
> +  plugin->desc.package = g_strdup(p->package);
> +  plugin->desc.origin = g_strdup(p->origin);
> +  plugin->file_mtime = p->m32p;
> +  plugin->file_size = p->size;
> +  plugin->basename = g_path_get_basename (plugin->filename);
> +
> +  if (plugin->file_mtime < 0 || plugin->file_size < 0)
> +    {
> +      GST_ERROR("Plugin time or file size is not valid !");
> +      g_free(plugin);
> +      return -1;
> +    }
> +
> +  if (p->nfeatures < 0)
> +    {
> +      GST_ERROR("The number of feature structure is not valid !");
> +      gst_object_unref(plugin);
> +      return -1;
> +    }
> +
> +  for (feat = (GstBinaryPluginFeature *) (in + sizeof (GstBinaryPluginElement)), i = 0;
> +       i < p->nfeatures; i++, feat++)
> +    {
> +      GstPluginFeature *gstfeat;
> +
> +      if ((gstfeat = gst_registry_binary_load_feature(feat)) == NULL)
> +	{
> +	  g_list_free(plugin_features);
> +	  g_free(plugin);
> +	  GST_ERROR("Error while loading binary feature");
> +	  return -1;
> +	}
> +      gstfeat->plugin_name = g_strdup(plugin->desc.name);
> +      plugin_features = g_list_prepend(plugin_features, gstfeat);
> +    }
> +
> +  GST_DEBUG("Added plugin \"%s\" to global registry from binary registry", plugin->desc.name);
> +  GList *g;
> +
> +  gst_registry_add_plugin (registry, plugin);
> +  for (g = plugin_features; g; g = g_list_next (g))
> +    gst_registry_add_feature (registry, GST_PLUGIN_FEATURE (g->data));
> +  /*  g_list_free(plugin_features); */
> +
> +  offset = sizeof (GstBinaryPluginElement) + p->nfeatures * sizeof (GstBinaryPluginFeature);
> +  return offset;
> +}
> +
> +
> +/*
> +** Read the cache and adapt it to fill GstRegistry
> +*/
> +gboolean
> +gst_registry_binary_read_cache(GstRegistry *registry, const char *location)
> +{
> +  GMappedFile *mapped = NULL;
> +  GTimer *timer = NULL;
> +  gchar *contents = NULL;
> +  gdouble seconds;
> +  unsigned long offset, inc;
> +  gsize size;
> +
> +  /* make sure these types exist */
> +  GST_TYPE_ELEMENT_FACTORY;
> +  GST_TYPE_TYPE_FIND_FACTORY;
> +  GST_TYPE_INDEX_FACTORY;
> +
> +  timer = g_timer_new ();
> +
> +  if ((mapped = g_mapped_file_new(location, FALSE, NULL)) == NULL ||
> +      (contents = g_mapped_file_get_contents(mapped)) == NULL)
> +    {
> +      GST_ERROR("Can't load file : %s", strerror(errno));
> +      return FALSE;
> +    }
> +  if ((contents = gst_registry_binary_check_magic(contents)) == NULL)
> +    {
> +      GST_ERROR("Binary registry type not recognized (invalid magic)");
> +      g_mapped_file_free(mapped);
> +      return FALSE;
> +    }
> +
> +  if ((size = g_mapped_file_get_length(mapped)) < sizeof (GstBinaryPluginElement))
> +    {
> +      GST_INFO("No binary plugins structure to read");
> +      return TRUE; /* This is not really an error */
> +    }
> +
> +  for (offset = inc = 0; (offset + sizeof (GstBinaryPluginElement)) < size &&
> +	 (inc = gst_registry_binary_get_binary_plugin(registry, contents + offset)) > 0;
> +       offset += inc)
> +    ; /* May want in the future to do something here */
> +  if (inc < 0)
> +    {
> +      GST_DEBUG("Problem while reading binary registry");
> +      return FALSE;
> +    }
> +
> +  g_timer_stop (timer);
> +  seconds = g_timer_elapsed (timer, NULL);
> +  g_timer_destroy (timer);
> +
> +  GST_INFO ("loaded %s in %f seconds", location, seconds);
> +
> +  if (mapped)
> +    g_mapped_file_free (mapped);
> +  return TRUE;
> +}
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.h b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.h
> new file mode 100644
> index 0000000..2ef24d7
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.h
> @@ -0,0 +1,194 @@
> +/* GStreamer
> + * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
> + *                    2000 Wim Taymans <wim.taymans@chello.be>
> + *
> + * gstregistry.h: Header for registry handling
> + *
> + * 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.
> + */
> +
> +/* SUGGESTIONS AND TODO :
> +** ====================
> +** - Use a compressed registry, but would induce performance loss
> +** - Encrypt the registry, for security purpose, but would also reduce performances
> +** - Also have a non-mmap based cache reading (work with file descriptors)
> +*/
> +
> +#ifndef __GST_REGISTRYBINARY_H__
> +#define __GST_REGISTRYBINARY_H__
> +
> +#ifdef HAVE_CONFIG_H
> +#  include "config.h"
> +#endif
> +
> +#include <stdio.h>
> +#include <errno.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <dirent.h>
> +#include <fcntl.h>
> +#include <sys/mman.h>
> +#ifdef HAVE_UNISTD_H
> +#include <unistd.h>
> +#endif
> +
> +#include <gst/gst_private.h>
> +#include <gst/gstelement.h>
> +#include <gst/gsttypefind.h>
> +#include <gst/gsttypefindfactory.h>
> +#include <gst/gsturi.h>
> +#include <gst/gstinfo.h>
> +#include <gst/gstenumtypes.h>
> +#include <gst/gstregistry.h>
> +#include <gst/gstpadtemplate.h>
> +
> +#include "glib-compat-private.h"
> +#include <glib/gstdio.h>
> +
> +/* A magic, written at the beginning of the file */
> +#define GST_MAGIC_BINARY_REGISTRY_STR "\xc0\xde\xf0\x0d"
> +#define GST_MAGIC_BINARY_REGISTRY_LEN (4)
> +#define GST_MAGIC_BINARY_VERSION_LEN (64)
> +
> +typedef struct _GstBinaryRegistryMagic
> +{
> +  char magic[GST_MAGIC_BINARY_REGISTRY_LEN];
> +  char version[GST_MAGIC_BINARY_VERSION_LEN];
> +} GstBinaryRegistryMagic;
> +
> +
> +/* Used to store pointers to write */
> +typedef struct _GstBinaryChunck
> +{
> +  void *data;
> +  unsigned int size;
> +} GstBinaryChunck;
> +
> +
> +/* A structure containing (staticely) every information needed for a plugin
> +**
> +** Notes :
> +** "nfeatures" is used to say how many GstBinaryPluginFeature structures we will have
> +** right after the structure itself.
> +*/
> +
> +/* Various lenght defines for our GstBinaryPluginElement structure
> +** Note : We could eventually use smaller size
> +*/
> +#define GST_BINARY_REGISTRY_NAME_LEN (256)
> +#define GST_BINARY_REGISTRY_DESCRIPTION_LEN (1024)
> +#define GST_BINARY_REGISTRY_VERSION_LEN (64)
> +#define GST_BINARY_REGISTRY_LICENSE_LEN (256)
> +#define GST_BINARY_REGISTRY_SOURCE_LEN (256)
> +#define GST_BINARY_REGISTRY_PACKAGE_LEN (1024)
> +#define GST_BINARY_REGISTRY_ORIGIN_LEN (1024)
> +
> +typedef struct _GstBinaryPluginElement
> +{
> +  char name[GST_BINARY_REGISTRY_NAME_LEN];
> +  char description[GST_BINARY_REGISTRY_DESCRIPTION_LEN];
> +  char filename[_POSIX_PATH_MAX];
> +  char version[GST_BINARY_REGISTRY_VERSION_LEN];
> +  char license[GST_BINARY_REGISTRY_LICENSE_LEN];
> +  char source[GST_BINARY_REGISTRY_SOURCE_LEN];
> +  char package[GST_BINARY_REGISTRY_PACKAGE_LEN];
> +  char origin[GST_BINARY_REGISTRY_ORIGIN_LEN];
> +  unsigned long size;
> +  unsigned long m32p;
> +  unsigned int nfeatures;
> +} GstBinaryPluginElement;
> +
> +
> +/* A structure containing the plugin features
> +**
> +** Note :
> +** "npadtemplates" is used to store the number of GstBinaryPadTemplate structures following the structure itself.
> +** "ninterfaces" is used to store the number of GstBinaryInterface structures following the structure itself.
> +** "nuritypes" is used to store the number of GstBinaryUriType structures following the structure itself.
> +*/
> +#define GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN (256)
> +#define GST_BINARY_REGISTRY_TYPENAME_NAME_LEN (256)
> +#define GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN (1024)
> +#define GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN (512)
> +#define GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN (1024)
> +#define GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN (256)
> +
> +typedef struct _GstBinaryPluginFeature
> +{
> +  char typename[GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN];
> +  char name[GST_BINARY_REGISTRY_TYPENAME_NAME_LEN];
> +  unsigned long rank;
> +  char longname[GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN];
> +  char class[GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN];
> +  char description[GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN];
> +  char author[GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN];
> +  unsigned int npadtemplates;
> +  unsigned int ninterfaces;
> +  unsigned int nuritypes;
> +} GstBinaryPluginFeature;
> +
> +
> +/*
> +** A structure containing the static pad templates of a plugin feature
> +*/
> +#define GST_BINARY_REGISTRY_PADTEMPLATE_NAME_LEN (256)
> +#define GST_BINARY_REGISTRY_PADTEMPLATE_CAP_LEN (1024)
> +
> +typedef struct _GstBinaryPadTemplate
> +{
> +  char name[GST_BINARY_REGISTRY_PADTEMPLATE_NAME_LEN];
> +  char cap[GST_BINARY_REGISTRY_PADTEMPLATE_CAP_LEN];
> +  int direction;					/* Either 0:"sink" or 1:"src" */
> +  GstPadPresence presence;
> +} GstBinaryPadTemplate;
> +
> +/*
> +** A very simple structure defining the plugin feature interface string
> +*/
> +#define GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN (512)
> +typedef struct _GstBinaryInterface
> +{
> +  char interface[GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN];
> +  unsigned long size;
> +} GstBinaryInterface;
> +
> +/* Uri Type */
> +typedef struct _GstBinaryUriType
> +{
> +  GstURIType type;
> +  unsigned long nuriprotocols;
> +} GstBinaryUriType;
> +
> +/*
> +** Function prototypes
> +*/
> +
> +/* Local prototypes */
> +inline static gboolean gst_registry_binary_write(GstRegistry *registry, const void *mem, const ssize_t size);
> +inline static gboolean gst_registry_binary_initialize_magic(GstBinaryRegistryMagic *m);
> +static gboolean gst_registry_binary_fill_feature(GList **list, GstPluginFeature *, GstBinaryPluginFeature *, const char *);
> +static gboolean gst_registry_binary_save_plugin(GList **list, GstRegistry *registry, GstPlugin *plugin);
> +static gchar *gst_registry_binary_check_magic(gchar *in);
> +static GstPluginFeature *gst_registry_binary_load_feature(GstBinaryPluginFeature *);
> +static unsigned long gst_registry_binary_get_binary_plugin(GstRegistry *registry, gchar *in);
> +
> +/* Exportable */
> +gboolean gst_registry_binary_write_cache(GstRegistry *registry, const char *location);
> +gboolean gst_registry_binary_read_cache(GstRegistry *registry, const char *location);
> +
> +#endif /* !__GST_REGISTRYBINARY_H__ */
> +
> +
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer_0.10.36.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer_0.10.36.bb
> new file mode 100644
> index 0000000..5b30603
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer_0.10.36.bb
> @@ -0,0 +1,51 @@
> +SUMMARY = "GStreamer multimedia framework"
> +DESCRIPTION = "GStreamer is a multimedia framework for encoding and decoding video and sound. \
> +It supports a wide range of formats including mp3, ogg, avi, mpeg and quicktime."
> +HOMEPAGE = "http://gstreamer.freedesktop.org/"
> +BUGTRACKER = "https://bugzilla.gnome.org/enter_bug.cgi?product=Gstreamer"
> +SECTION = "multimedia"
> +LICENSE = "LGPLv2+"
> +LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605 \
> +                    file://gst/gst.h;beginline=1;endline=21;md5=8e5fe5e87d33a04479fde862e238eaa4"
> +DEPENDS = "glib-2.0 libxml2 bison-native flex-native"
> +
> +PR = "r2"
> +
> +SRC_URI = "http://gstreamer.freedesktop.org/src/gstreamer/gstreamer-${PV}.tar.bz2 \
> +           file://check_fix.patch \
> +           file://gst-inspect-check-error.patch \
> +           file://0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch \
> +           file://gstreamer-change-priv_gst_parse_yylex-arguments.patch \
> +"
> +
> +SRC_URI[md5sum] = "a0cf7d6877f694a1a2ad2b4d1ecb890b"
> +SRC_URI[sha256sum] = "e556a529e0a8cf1cd0afd0cab2af5488c9524e7c3f409de29b5d82bb41ae7a30"
> +
> +inherit autotools pkgconfig gettext
> +
> +GSTREAMER_DEBUG ?= "--disable-debug"
> +EXTRA_OECONF = "--disable-docbook --disable-gtk-doc \
> +            --disable-dependency-tracking --disable-check \
> +            --disable-examples --disable-tests \
> +            --disable-valgrind ${GSTREAMER_DEBUG} \
> +            "
> +
> +CACHED_CONFIGUREVARS += "ac_cv_header_valgrind_valgrind_h=no"
> +
> +# apply gstreamer hack after Makefile.in.in in source is replaced by our version from
> +# ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in, but before configure is executed
> +# http://lists.linuxtogo.org/pipermail/openembedded-core/2012-November/032233.html
> +oe_runconf_prepend() {
> +        sed -i -e "1a\\" -e 'GETTEXT_PACKAGE = @GETTEXT_PACKAGE@' ${S}/po/Makefile.in.in
> +}
> +
> +#do_compile_prepend () {
> +#	mv ${WORKDIR}/gstregistrybinary.[ch] ${S}/gst/
> +#}
> +
> +RRECOMMENDS_${PN}_qemux86    += "kernel-module-snd-ens1370 kernel-module-snd-rawmidi"
> +RRECOMMENDS_${PN}_qemux86-64 += "kernel-module-snd-ens1370 kernel-module-snd-rawmidi"
> +
> +FILES_${PN} += " ${libdir}/gstreamer-0.10/*.so"
> +FILES_${PN}-dev += " ${libdir}/gstreamer-0.10/*.la ${libdir}/gstreamer-0.10/*.a"
> +FILES_${PN}-dbg += " ${libdir}/gstreamer-0.10/.debug/ ${libexecdir}/gstreamer-0.10/.debug/"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst/python-path.patch b/meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst/python-path.patch
> new file mode 100644
> index 0000000..21b5bbf
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst/python-path.patch
> @@ -0,0 +1,28 @@
> +Upstream-Status:Pending
> +
> +Index: gst-python-0.10.19/acinclude.m4
> +===================================================================
> +--- gst-python-0.10.19.orig/acinclude.m4	2010-04-21 15:23:44.000000000 -0700
> ++++ gst-python-0.10.19/acinclude.m4	2010-11-15 14:43:00.642994001 -0800
> +@@ -43,6 +43,13 @@
> + [AC_REQUIRE([AM_PATH_PYTHON])
> + AC_MSG_CHECKING(for headers required to compile python extensions)
> + dnl deduce PYTHON_INCLUDES
> ++
> ++AC_ARG_WITH(python-includes,
> ++	[  --with-python-includes=DIR  path to Python includes], py_exec_prefix=$withval)
> ++if test x$py_exec_prefix != x; then
> ++PYTHON_INCLUDES="-I${py_exec_prefix}/include/python${PYTHON_VERSION}"
> ++py_prefix="${py_exec_prefix}"
> ++else
> + py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
> + py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
> + if $PYTHON-config --help 2>/dev/null; then
> +@@ -53,6 +60,7 @@
> +     PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
> +   fi
> + fi
> ++fi
> + AC_SUBST(PYTHON_INCLUDES)
> + dnl check if the headers exist:
> + save_CPPFLAGS="$CPPFLAGS"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst_0.10.22.bb b/meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst_0.10.22.bb
> new file mode 100644
> index 0000000..2a5f2b3
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst_0.10.22.bb
> @@ -0,0 +1,29 @@
> +SUMMARY = "Python bindings for the GStreamer multimedia framework"
> +SECTION = "devel/python"
> +LICENSE = "LGPLv2.1"
> +DEPENDS = "gstreamer gst-plugins-base python-pygobject"
> +RDEPENDS_${PN} += "python-pygtk"
> +PR = "r2"
> +
> +SRC_URI = "http://gstreamer.freedesktop.org/src/gst-python/gst-python-${PV}.tar.bz2 \
> +           file://python-path.patch"
> +
> +SRC_URI[md5sum] = "937152fe896241f827689f4b53e79b22"
> +SRC_URI[sha256sum] = "8f26f519a5bccd770864317e098e5e307fc5ad1201eb96329634b6508b253178"
> +S = "${WORKDIR}/gst-python-${PV}"
> +
> +LIC_FILES_CHKSUM = "file://COPYING;md5=39ff67e932b7bdfa9b78bad67151690b"
> +
> +inherit autotools distutils-base pkgconfig
> +
> +EXTRA_OECONF += "--with-python-includes=${STAGING_INCDIR}/../"
> +
> +FILES_${PN} += "${datadir}/gst-python"
> +FILES_${PN}-dev += "${datadir}/gst-python/0.10/defs"
> +FILES_${PN}-dbg += "${libdir}/${PYTHON_DIR}/site-packages/gst-0.10/gst/.debug/ ${libdir}/gstreamer-0.10/.debug/"
> +
> +do_configure_prepend() {
> +	if [ `find ${STAGING_LIBDIR} -name libpython*.so` ]; then
> +		ln -sf ${STAGING_LIBDIR}/libpython*.so `find ${STAGING_LIBDIR} -name libpython*.a -exec dirname {} \;`
> +	fi
> +}
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
> deleted file mode 100644
> index 7da0e14..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -gst-ffmpeg: aacdec: check channel count
> -
> -Prevent out of array accesses
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit 96f452ac647dae33c53c242ef3266b65a9beafb6)
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Yue Tao <yue.tao@windriver.com>
> ----
> - libavcodec/aacdec.c |    5 +++++
> - 1 files changed, 5 insertions(+), 0 deletions(-)
> -
> -diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
> -index 239153a..6c17c33 100644
> ---- a/gst-libs/ext/libav/libavcodec/aacdec.c
> -+++ b/gst-libs/ext/libav/libavcodec/aacdec.c
> -@@ -914,6 +914,11 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
> -         }
> -     }
> -
> -+    if (avctx->channels > MAX_CHANNELS) {
> -+        av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
> -+        return AVERROR_INVALIDDATA;
> -+    }
> -+
> -     AAC_INIT_VLC_STATIC( 0, 304);
> -     AAC_INIT_VLC_STATIC( 1, 270);
> -     AAC_INIT_VLC_STATIC( 2, 550);
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
> deleted file mode 100644
> index 10ce0f3..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -From e0884eadf6a15e93142131b695f48776f9a0ac31 Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Sat, 10 Nov 2012 17:14:04 +0100
> -Subject: [PATCH] alac: fix nb_samples < order case
> -
> -Upstream-Status: Backport
> -
> -Commit e0884eadf6a15e93142131b695f48776f9a0ac31 release/1.0
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit fd4f4923cce6a2cbf4f48640b4ac706e614a1594)
> ----
> - libavcodec/alac.c | 2 +-
> - 1 file changed, 1 insertion(+), 1 deletion(-)
> -
> -diff --git a/libavcodec/alac.c b/libavcodec/alac.c
> -index 9cd1737..e8e844a 100644
> ---- a/gst-libs/ext/libav/libavcodec/alac.c
> -+++ b/gst-libs/ext/libav/libavcodec/alac.c
> -@@ -278,7 +278,7 @@ static void predictor_decompress_fir_ada
> -
> -     /* read warm-up samples */
> -     if (predictor_coef_num > 0)
> --        for (i = 0; i < predictor_coef_num; i++) {
> -+        for (i = 0; i < predictor_coef_num && i < output_size; i++) {
> -             int32_t val;
> -
> -             val = buffer_out[i] + error_buffer[i+1];
> ---
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
> deleted file mode 100644
> index 73980f4..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
> +++ /dev/null
> @@ -1,61 +0,0 @@
> -From 6df0d3e2916c223dbe4262bf1b876dff1cb3f980 Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Wed, 12 Dec 2012 12:28:45 +0100
> -Subject: [PATCH] alsdec: check block length
> -
> -Upstream-Status: Backport
> -
> -Commit 6df0d3e2916c223dbe4262bf1b876dff1cb3f980 release/1.0
> -
> -Fix writing over the end
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit 0ceca269b66ec12a23bf0907bd2c220513cdbf16)
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/alsdec.c | 10 ++++++++--
> - 1 file changed, 8 insertions(+), 2 deletions(-)
> -
> -diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
> -index 46dd0b4..1095b01 100644
> ---- a/gst-libs/ext/libav/libavcodec/alsdec.c
> -+++ b/gst-libs/ext/libav/libavcodec/alsdec.c
> -@@ -552,12 +552,15 @@ static void get_block_sizes(ALSDecContext *ctx, unsigned int *div_blocks,
> -
> - /** Read the block data for a constant block
> -  */
> --static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
> -+static int read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
> - {
> -     ALSSpecificConfig *sconf = &ctx->sconf;
> -     AVCodecContext *avctx    = ctx->avctx;
> -     GetBitContext *gb        = &ctx->gb;
> -
> -+    if (bd->block_length <= 0)
> -+        return -1;
> -+
> -     *bd->raw_samples = 0;
> -     *bd->const_block = get_bits1(gb);    // 1 = constant value, 0 = zero block (silence)
> -     bd->js_blocks    = get_bits1(gb);
> -@@ -572,6 +575,8 @@ static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
> -
> -     // ensure constant block decoding by reusing this field
> -     *bd->const_block = 1;
> -+
> -+    return 0;
> - }
> -
> -
> -@@ -971,7 +976,8 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
> -         if (read_var_block_data(ctx, bd))
> -             return -1;
> -     } else {
> --        read_const_block_data(ctx, bd);
> -+        if (read_const_block_data(ctx, bd) < 0)
> -+            return -1;
> -     }
> -
> -     return 0;
> ---
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
> deleted file mode 100644
> index 42cb5f4..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
> +++ /dev/null
> @@ -1,37 +0,0 @@
> -From 2502914c5f8eb77659d7c0868396862557a63245 Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Fri, 9 Nov 2012 13:26:20 +0100
> -Subject: [PATCH] atrac3dec: Check coding mode against channels.
> -
> -Upstream-Status: Backport
> -
> -Commit 2502914c5f8eb77659d7c0868396862557a63245 release/1.0
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit 13451f5520ce6b0afde861b2285dda659f8d4fb4)
> -
> -Conflicts:
> -
> -	libavcodec/atrac3.c
> ----
> - libavcodec/atrac3.c | 5 +++++
> - 1 file changed, 5 insertions(+)
> -
> -diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
> -index 7d076be..1da4c78 100644
> ---- a/gst-libs/ext/libav/libavcodec/atrac3.c
> -+++ b/gst-libs/ext/libav/libavcodec/atrac3.c
> -@@ -955,6 +955,11 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
> -     }
> -     /* Check the extradata. */
> -
> -+    if (q->codingMode == JOINT_STEREO && avctx->channels < 2) {
> -+        av_log(avctx, AV_LOG_ERROR, "Invalid coding mode\n");
> -+        return AVERROR_INVALIDDATA;
> -+    }
> -+
> -     if (q->atrac3version != 4) {
> -         av_log(avctx,AV_LOG_ERROR,"Version %d != 4.\n",q->atrac3version);
> -         return AVERROR_INVALIDDATA;
> ---
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
> deleted file mode 100644
> index 31fa51a..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
> +++ /dev/null
> @@ -1,40 +0,0 @@
> -From a99aff4e4bbef8e64b51f267cd1769214e1b4e80 Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Fri, 30 Aug 2013 23:40:47 +0200
> -Subject: [PATCH] avcodec/dsputil: fix signedness in sizeof() comparissions
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit 454a11a1c9c686c78aa97954306fb63453299760)
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/dsputil.c |    4 ++--
> - 1 files changed, 2 insertions(+), 2 deletions(-)
> -
> -diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
> -index 53dc2eb..6264832 100644
> ---- a/gst-libs/ext/libav/libavcodec/dsputil.c
> -+++ b/gst-libs/ext/libav/libavcodec/dsputil.c
> -@@ -1912,7 +1912,7 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
> -
> - static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
> -     long i;
> --    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
> -+    for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
> -         long a = *(long*)(src+i);
> -         long b = *(long*)(dst+i);
> -         *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
> -@@ -1937,7 +1937,7 @@ static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
> -         }
> -     }else
> - #endif
> --    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
> -+    for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
> -         long a = *(long*)(src1+i);
> -         long b = *(long*)(src2+i);
> -         *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
> deleted file mode 100644
> index b0a3fb1..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
> +++ /dev/null
> @@ -1,50 +0,0 @@
> -From 573d5fdedae72bf59d8c0b0766fdee171063d36f Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Sun, 16 Feb 2014 23:08:52 +0100
> -Subject: [PATCH] avcodec/msrle: use av_image_get_linesize() to calculate the
> - linesize
> -
> -Upstream-Status: Backport
> -
> -Commit 573d5fdedae72bf59d8c0b0766fdee171063d36f release/0.9
> -
> -Fixes out of array access
> -Fixes: 14a74a0a2dc67ede543f0e35d834fbbe-asan_heap-oob_49572c_556_cov_215466444_44_001_engine_room.mov
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit c919e1ca2ecfc47d796382973ba0e48b8f6f92a2)
> -
> -Conflicts:
> -
> -	libavcodec/msrle.c
> -(cherry picked from commit bc1c8ec5e65098fd2ccd8456f667151dfc9cda42)
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/msrle.c |    3 ++-
> - 1 files changed, 2 insertions(+), 1 deletions(-)
> -
> -diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c
> -index 30159bb..c39ae7b 100644
> ---- a/gst-libs/ext/libav/libavcodec/msrle.c
> -+++ b/gst-libs/ext/libav/libavcodec/msrle.c
> -@@ -35,6 +35,7 @@
> - #include "avcodec.h"
> - #include "dsputil.h"
> - #include "msrledec.h"
> -+#include "libavutil/imgutils.h"
> -
> - typedef struct MsrleContext {
> -     AVCodecContext *avctx;
> -@@ -107,7 +108,7 @@ static int msrle_decode_frame(AVCodecContext *avctx,
> -
> -     /* FIXME how to correctly detect RLE ??? */
> -     if (avctx->height * istride == avpkt->size) { /* assume uncompressed */
> --        int linesize = avctx->width * avctx->bits_per_coded_sample / 8;
> -+        int linesize = av_image_get_linesize(avctx->pix_fmt, avctx->width, 0);
> -         uint8_t *ptr = s->frame.data[0];
> -         uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
> -         int i, j;
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
> deleted file mode 100644
> index 5ff6583..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
> +++ /dev/null
> @@ -1,50 +0,0 @@
> -gst-ffmpeg: avcodec/parser: reset indexes on realloc failure
> -
> -Fixes Ticket2982
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit f31011e9abfb2ae75bb32bc44e2c34194c8dc40a)
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Yue Tao <yue.tao@windriver.com>
> -
> ----
> - libavcodec/parser.c |   10 +++++++---
> - 1 files changed, 7 insertions(+), 3 deletions(-)
> -
> -diff --git a/libavcodec/parser.c b/libavcodec/parser.c
> -index 2c6de6e..66eca06 100644
> ---- a/gst-libs/ext/libav/libavcodec/parser.c
> -+++ b/gst-libs/ext/libav/libavcodec/parser.c
> -@@ -241,8 +241,10 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
> -     if(next == END_NOT_FOUND){
> -         void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
> -
> --        if(!new_buffer)
> -+        if(!new_buffer) {
> -+            pc->index = 0;
> -             return AVERROR(ENOMEM);
> -+        }
> -         pc->buffer = new_buffer;
> -         memcpy(&pc->buffer[pc->index], *buf, *buf_size);
> -         pc->index += *buf_size;
> -@@ -255,9 +257,11 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
> -     /* append to buffer */
> -     if(pc->index){
> -         void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
> --
> --        if(!new_buffer)
> -+        if(!new_buffer) {
> -+            pc->overread_index =
> -+            pc->index = 0;
> -             return AVERROR(ENOMEM);
> -+        }
> -         pc->buffer = new_buffer;
> -         if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
> -             memcpy(&pc->buffer[pc->index], *buf,
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
> deleted file mode 100644
> index 7f6eb48..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
> +++ /dev/null
> @@ -1,81 +0,0 @@
> -gst-ffmpeg: avcodec/rpza: Perform pointer advance and checks before
> - using the pointers
> -
> -Fixes out of array accesses
> -Fixes Ticket2850
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit 3819db745da2ac7fb3faacb116788c32f4753f34)
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -
> -Upstream-Status: Backport
> -
> -Singed-off-by: Yue Tao <yue.tao@windriver.com>
> -
> ----
> - libavcodec/rpza.c |    8 ++++----
> - 1 files changed, 4 insertions(+), 4 deletions(-)
> -
> -diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c
> -index 635b406..f291a95 100644
> ---- a/gst-libs/ext/libav/libavcodec/rpza.c
> -+++ b/gst-libs/ext/libav/libavcodec/rpza.c
> -@@ -83,7 +83,7 @@ static void rpza_decode_stream(RpzaContext *s)
> -     unsigned short *pixels = (unsigned short *)s->frame.data[0];
> -
> -     int row_ptr = 0;
> --    int pixel_ptr = 0;
> -+    int pixel_ptr = -4;
> -     int block_ptr;
> -     int pixel_x, pixel_y;
> -     int total_blocks;
> -@@ -139,6 +139,7 @@ static void rpza_decode_stream(RpzaContext *s)
> -             colorA = AV_RB16 (&s->buf[stream_ptr]);
> -             stream_ptr += 2;
> -             while (n_blocks--) {
> -+                ADVANCE_BLOCK()
> -                 block_ptr = row_ptr + pixel_ptr;
> -                 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
> -                     for (pixel_x = 0; pixel_x < 4; pixel_x++){
> -@@ -147,7 +148,6 @@ static void rpza_decode_stream(RpzaContext *s)
> -                     }
> -                     block_ptr += row_inc;
> -                 }
> --                ADVANCE_BLOCK();
> -             }
> -             break;
> -
> -@@ -184,6 +184,7 @@ static void rpza_decode_stream(RpzaContext *s)
> -             color4[2] |= ((21 * ta + 11 * tb) >> 5);
> -
> -             while (n_blocks--) {
> -+                ADVANCE_BLOCK();
> -                 block_ptr = row_ptr + pixel_ptr;
> -                 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
> -                     index = s->buf[stream_ptr++];
> -@@ -194,12 +195,12 @@ static void rpza_decode_stream(RpzaContext *s)
> -                     }
> -                     block_ptr += row_inc;
> -                 }
> --                ADVANCE_BLOCK();
> -             }
> -             break;
> -
> -         /* Fill block with 16 colors */
> -         case 0x00:
> -+            ADVANCE_BLOCK();
> -             block_ptr = row_ptr + pixel_ptr;
> -             for (pixel_y = 0; pixel_y < 4; pixel_y++) {
> -                 for (pixel_x = 0; pixel_x < 4; pixel_x++){
> -@@ -213,7 +214,6 @@ static void rpza_decode_stream(RpzaContext *s)
> -                 }
> -                 block_ptr += row_inc;
> -             }
> --            ADVANCE_BLOCK();
> -             break;
> -
> -         /* Unknown opcode */
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
> deleted file mode 100644
> index 3ca6fc4..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -From c17a0ad1df15a94d0b1239adc2afb593bdf0a153 Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Fri, 3 Oct 2014 22:50:45 +0200
> -Subject: [PATCH 1/2] avcodec/smc: fix off by 1 error
> -
> -Upstream-Status: Backport
> -
> -Fixes out of array access
> -Fixes: asan_heap-oob_1685bf0_5_asan_heap-oob_1f35116_430_smc.mov
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/smc.c | 2 +-
> - 1 file changed, 1 insertion(+), 1 deletion(-)
> -
> -diff --git a/gst-libs/ext/libav/libavcodec/smc.c b/gst-libs/ext/libav/libavcodec/smc.c
> -index 3cd5e53..dec9f71 100644
> ---- a/gst-libs/ext/libav/libavcodec/smc.c
> -+++ b/gst-libs/ext/libav/libavcodec/smc.c
> -@@ -69,7 +69,7 @@ typedef struct SmcContext {
> -         row_ptr += stride * 4; \
> -     } \
> -     total_blocks--; \
> --    if (total_blocks < 0) \
> -+    if (total_blocks < 0 + !!n_blocks) \
> -     { \
> -         av_log(s->avctx, AV_LOG_INFO, "warning: block counter just went negative (this should not happen)\n"); \
> -         return; \
> ---
> -2.1.0
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
> deleted file mode 100644
> index 68bb66e..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
> +++ /dev/null
> @@ -1,69 +0,0 @@
> -From 12770701856a05b6b3cd706f708f8e9a4e8a1336 Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Thu, 13 Feb 2014 13:59:51 +0100
> -Subject: [PATCH] avformat/mpegtsenc: Check data array size in
> - mpegts_write_pmt()
> -
> -Upstream-Status: Backport
> -
> -COmmit 12770701856a05b6b3cd706f708f8e9a4e8a1336 release/0.11
> -
> -Prevents out of array writes
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit 842b6c14bcfc1c5da1a2d288fd65386eb8c158ad)
> -
> -Conflicts:
> -
> -	libavformat/mpegtsenc.c
> -(cherry picked from commit e87de3f50b765134588d0b048c32ed4b8acc16fb)
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavformat/mpegtsenc.c |    9 +++++++--
> - 1 files changed, 7 insertions(+), 2 deletions(-)
> -
> -diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> -index 793e205..a12d19f 100644
> ---- a/gst-libs/ext/libav/libavformat/mpegtsenc.c
> -+++ b/gst-libs/ext/libav/libavformat/mpegtsenc.c
> -@@ -240,7 +240,7 @@ static void mpegts_write_pat(AVFormatContext *s)
> -                           data, q - data);
> - }
> -
> --static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
> -+static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
> - {
> -     //    MpegTSWrite *ts = s->priv_data;
> -     uint8_t data[1012], *q, *desc_length_ptr, *program_info_length_ptr;
> -@@ -293,6 +293,10 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
> -             stream_type = STREAM_TYPE_PRIVATE_DATA;
> -             break;
> -         }
> -+
> -+        if (q - data > sizeof(data) - 32)
> -+            return AVERROR(EINVAL);
> -+
> -         *q++ = stream_type;
> -         put16(&q, 0xe000 | ts_st->pid);
> -         desc_length_ptr = q;
> -@@ -324,7 +328,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
> -                 len_ptr = q++;
> -                 *len_ptr = 0;
> -
> --                for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next + 1) {
> -+                for (p = lang->value; next && *len_ptr < 255 / 4 * 4 && q - data < sizeof(data) - 4; p = next + 1) {
> -                     next = strchr(p, ',');
> -                     if (strlen(p) != 3 && (!next || next != p + 3))
> -                         continue; /* not a 3-letter code */
> -@@ -386,6 +390,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
> -     }
> -     mpegts_write_section1(&service->pmt, PMT_TID, service->sid, 0, 0, 0,
> -                           data, q - data);
> -+    return 0;
> - }
> -
> - /* NOTE: str == NULL is accepted for an empty string */
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
> deleted file mode 100644
> index f45e3fd..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -From 63ac64864c6e0e84355aa3caa5b92208997a9a8d Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Sat, 17 Nov 2012 16:26:55 +0100
> -Subject: [PATCH] eamad: fix out of array accesses
> -
> -Upstream-Status: Backport
> -
> -Commit 63ac64864c6e0e84355aa3caa5b92208997a9a8d release/1.1
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/eamad.c | 2 +-
> - 1 file changed, 1 insertion(+), 1 deletion(-)
> -
> -diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c
> -index 2805195..e38650e 100644
> ---- a/gst-libs/ext/libav/libavcodec/eamad.c
> -+++ b/gst-libs/ext/libav/libavcodec/eamad.c
> -@@ -237,7 +237,7 @@ static int decode_frame(AVCodecContext *avctx,
> -     int chunk_type;
> -     int inter;
> -
> --    if (buf_size < 17) {
> -+    if (buf_size < 26) {
> -         av_log(avctx, AV_LOG_ERROR, "Input buffer too small\n");
> -         *data_size = 0;
> -         return -1;
> ---
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
> deleted file mode 100644
> index e0e4239..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -gst-ffmpeg: error concealment: initialize block index.
> -
> -Fixes CVE-2011-3941 (out of bounds write)
> -
> -Upstream-Status: Backport
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/error_resilience.c |    3 +++
> - 1 files changed, 3 insertions(+), 0 deletions(-)
> -
> -diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
> -index 8bb5d0c..d55c000 100644
> ---- a/gst-libs/ext/libav/libavcodec/error_resilience.c
> -+++ b/gst-libs/ext/libav/libavcodec/error_resilience.c
> -@@ -45,6 +45,9 @@ static void decode_mb(MpegEncContext *s, int ref){
> -     s->dest[1] = s->current_picture.data[1] + (s->mb_y * (16>>s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16>>s->chroma_x_shift);
> -     s->dest[2] = s->current_picture.data[2] + (s->mb_y * (16>>s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16>>s->chroma_x_shift);
> -
> -+    ff_init_block_index(s);
> -+    ff_update_block_index(s);
> -+
> -     if(CONFIG_H264_DECODER && s->codec_id == CODEC_ID_H264){
> -         H264Context *h= (void*)s;
> -         h->mb_xy= s->mb_x + s->mb_y*s->mb_stride;
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
> deleted file mode 100644
> index 8eef6e9..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
> +++ /dev/null
> @@ -1,37 +0,0 @@
> -gst-ffmpeg: error_concealment: Check that the picture is not in a half
> -
> -Fixes state becoming inconsistent
> -Fixes a null pointer dereference
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit 23318a57358358e7a4dc551e830e4503f0638cfe)
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Yue Tao <yue.tao@windriver.com>
> -
> ----
> - libavcodec/error_resilience.c |    6 ++++++
> - 1 files changed, 6 insertions(+), 0 deletions(-)
> -
> -diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
> -index 01f7424..2b6bc42 100644
> ---- a/gst-libs/ext/libav/libavcodec/error_resilience.c
> -+++ b/gst-libs/ext/libav/libavcodec/error_resilience.c
> -@@ -793,6 +793,12 @@ void ff_er_frame_end(MpegEncContext *s){
> -        s->picture_structure != PICT_FRAME || // we dont support ER of field pictures yet, though it should not crash if enabled
> -        s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return;
> -
> -+    if (   s->picture_structure == PICT_FRAME
> -+        && s->current_picture.linesize[0] != s->current_picture_ptr->linesize[0]) {
> -+        av_log(s->avctx, AV_LOG_ERROR, "Error concealment not possible, frame not fully initialized\n");
> -+        return;
> -+    }
> -+
> -     if(s->current_picture.motion_val[0] == NULL){
> -         av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
> -
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
> deleted file mode 100644
> index 80325db..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
> +++ /dev/null
> @@ -1,36 +0,0 @@
> -gst-ffmpeg: ffserver: set oformat
> -
> -Fix Ticket1986
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit cbe43e62c9ac7d4aefdc13476f6f691bd626525f)
> -
> -Upstream-Status: Backport
> -
> ----
> - ffserver.c |    4 +++-
> - 1 files changed, 3 insertions(+), 1 deletions(-)
> -
> -diff --git a/ffserver.c b/ffserver.c
> -index 4044d0f..8740140 100644
> ---- a/gst-libs/ext/libav/ffserver.c
> -+++ b/gst-libs/ext/libav/ffserver.c
> -@@ -2937,12 +2937,14 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
> - {
> -     AVFormatContext *avc;
> -     AVStream *avs = NULL;
> -+    AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
> -     int i;
> -
> -     avc =  avformat_alloc_context();
> --    if (avc == NULL) {
> -+    if (avc == NULL || !rtp_format) {
> -         return -1;
> -     }
> -+    avc->oformat = rtp_format;
> -     av_dict_set(&avc->metadata, "title",
> -                stream->title[0] ? stream->title : "No Title", 0);
> -     avc->nb_streams = stream->nb_streams;
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
> deleted file mode 100644
> index d4f55b2..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -From d6c184880ee2e09fd68c0ae217173832cee5afc1 Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Sun, 18 Nov 2012 16:29:04 +0100
> -Subject: [PATCH] h264: correct ref count check and limit, fix out of array
> - accesses.
> -
> -Upstream-Status: Backport
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/h264.c | 2 +-
> - 1 file changed, 1 insertion(+), 1 deletion(-)
> -
> -diff --git a/libavcodec/h264.c b/libavcodec/h264.c
> -index da43f1e..32cede5 100644
> ---- a/gst-libs/ext/libav/libavcodec/h264.c
> -+++ b/gst-libs/ext/libav/libavcodec/h264.c
> -@@ -2870,6 +2870,9 @@ static int decode_slice_header(H264Conte
> -             h->ref_count[0]= get_ue_golomb(&s->gb) + 1;
> -             if(h->slice_type_nos==AV_PICTURE_TYPE_B)
> -                 h->ref_count[1]= get_ue_golomb(&s->gb) + 1;
> -+            else
> -+                // full range is spec-ok in this case, even for frames
> -+                h->ref_count[1] = 1;
> -
> -             if(h->ref_count[0]-1 > 32-1 || h->ref_count[1]-1 > 32-1){
> -                 av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
> ---
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
> deleted file mode 100644
> index 05a9de3..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
> +++ /dev/null
> @@ -1,145 +0,0 @@
> -gst-ffmpeg: h264: set parameters from SPS whenever it changes
> -
> -Fixes a crash in the fuzzed sample sample_varPAR.avi_s26638 with
> -alternating bit depths.
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Yue Tao <yue.tao@windriver.com>
> -
> -diff --git a/gst-libs/ext/libav/libavcodec/h264.c.old b/gst-libs/ext/libav/libavcodec/h264.c
> -index 3621f41..718906a 100644
> ---- a/gst-libs/ext/libav/libavcodec/h264.c.old
> -+++ b/gst-libs/ext/libav/libavcodec/h264.c
> -@@ -2491,6 +2491,34 @@ int ff_h264_get_profile(SPS *sps)
> -     return profile;
> - }
> -
> -+static int h264_set_parameter_from_sps(H264Context *h)
> -+{
> -+    MpegEncContext *s = &h->s;
> -+    AVCodecContext * avctx= s->avctx;
> -+
> -+    if (s->flags& CODEC_FLAG_LOW_DELAY ||
> -+        (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames))
> -+        s->low_delay=1;
> -+
> -+    if(avctx->has_b_frames < 2)
> -+        avctx->has_b_frames= !s->low_delay;
> -+
> -+    if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
> -+        if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
> -+            avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
> -+            h->pixel_shift = h->sps.bit_depth_luma > 8;
> -+
> -+            ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
> -+            ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
> -+            dsputil_init(&s->dsp, s->avctx);
> -+        } else {
> -+            av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
> -+            return -1;
> -+        }
> -+    }
> -+    return 0;
> -+}
> -+
> - /**
> -  * decodes a slice header.
> -  * This will also call MPV_common_init() and frame_start() as needed.
> -@@ -2505,7 +2533,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
> -     MpegEncContext * const s0 = &h0->s;
> -     unsigned int first_mb_in_slice;
> -     unsigned int pps_id;
> --    int num_ref_idx_active_override_flag;
> -+    int num_ref_idx_active_override_flag, ret;
> -     unsigned int slice_type, tmp, i, j;
> -     int default_ref_list_done = 0;
> -     int last_pic_structure;
> -@@ -2569,7 +2597,17 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
> -         av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS %u referenced\n", h->pps.sps_id);
> -         return -1;
> -     }
> --    h->sps = *h0->sps_buffers[h->pps.sps_id];
> -+
> -+    if (h->pps.sps_id != h->current_sps_id ||
> -+        h0->sps_buffers[h->pps.sps_id]->new) {
> -+        h0->sps_buffers[h->pps.sps_id]->new = 0;
> -+
> -+        h->current_sps_id = h->pps.sps_id;
> -+        h->sps            = *h0->sps_buffers[h->pps.sps_id];
> -+
> -+        if ((ret = h264_set_parameter_from_sps(h)) < 0)
> -+            return ret;
> -+    }
> -
> -     s->avctx->profile = ff_h264_get_profile(&h->sps);
> -     s->avctx->level   = h->sps.level_idc;
> -@@ -3811,26 +3811,8 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
> -         case NAL_SPS:
> -             init_get_bits(&s->gb, ptr, bit_length);
> -             ff_h264_decode_seq_parameter_set(h);
> --
> --            if (s->flags& CODEC_FLAG_LOW_DELAY ||
> --                (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames))
> --                s->low_delay=1;
> --
> --            if(avctx->has_b_frames < 2)
> --                avctx->has_b_frames= !s->low_delay;
> --
> --            if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
> --                if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
> --                    avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
> --                    h->pixel_shift = h->sps.bit_depth_luma > 8;
> --
> --                    ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
> --                    ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
> --                    dsputil_init(&s->dsp, s->avctx);
> --                } else {
> --                    av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
> --                    return -1;
> --                }
> -+            if (h264_set_parameter_from_sps(h) < 0) {
> -+                return -1;
> -             }
> -             break;
> -         case NAL_PPS:
> -diff --git a/gst-libs/ext/libav/libavcodec/h264.h.old b/gst-libs/ext/libav/libavcodec/h264.h
> -index e3cc815..b77ad98 100644
> ---- a/gst-libs/ext/libav/libavcodec/h264.h.old
> -+++ b/gst-libs/ext/libav/libavcodec/h264.h
> -@@ -202,6 +202,7 @@ typedef struct SPS{
> -     int bit_depth_chroma;              ///< bit_depth_chroma_minus8 + 8
> -     int residual_color_transform_flag; ///< residual_colour_transform_flag
> -     int constraint_set_flags;          ///< constraint_set[0-3]_flag
> -+    int new;                              ///< flag to keep track if the decoder context needs re-init due to changed SPS
> - }SPS;
> -
> - /**
> -@@ -333,6 +334,7 @@ typedef struct H264Context{
> -     int emu_edge_width;
> -     int emu_edge_height;
> -
> -+    unsigned current_sps_id; ///< id of the current SPS
> -     SPS sps; ///< current sps
> -
> -     /**
> -diff --git a/gst-libs/ext/libav/libavcodec/h264_ps.c.old b/gst-libs/ext/libav/libavcodec/h264_ps.c
> -index 7491807..0929098 100644
> ---- a/gst-libs/ext/libav/libavcodec/h264_ps.c.old
> -+++ b/gst-libs/ext/libav/libavcodec/h264_ps.c
> -@@ -438,10 +438,13 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
> -                sps->timing_info_present_flag ? sps->time_scale : 0
> -                );
> -     }
> -+    sps->new = 1;
> -
> -     av_free(h->sps_buffers[sps_id]);
> --    h->sps_buffers[sps_id]= sps;
> --    h->sps = *sps;
> -+    h->sps_buffers[sps_id] = sps;
> -+    h->sps                 = *sps;
> -+    h->current_sps_id      = sps_id;
> -+
> -     return 0;
> - fail:
> -     av_free(sps);
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
> deleted file mode 100644
> index 5d45c1a..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
> +++ /dev/null
> @@ -1,33 +0,0 @@
> -gst-ffmpeg: h264: skip error concealment when SPS and slices are
> - mismatching
> -
> -Fixes out of array accesses
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit 695af8eed642ff0104834495652d1ee784a4c14d)
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -Signed-off-by: Yue Tao <yue.tao@windriver.com>
> ----
> - libavcodec/h264.c |    2 +-
> - 1 files changed, 1 insertions(+), 1 deletions(-)
> -
> -diff --git a/libavcodec/h264.c b/libavcodec/h264.c
> -index da144db..0aab4e7 100644
> ---- a/gst-libs/ext/libav/libavcodec/h264.c
> -+++ b/gst-libs/ext/libav/libavcodec/h264.c
> -@@ -2351,7 +2351,7 @@ static int field_end(H264Context *h, int in_setup)
> -      * past end by one (callers fault) and resync_mb_y != 0
> -      * causes problems for the first MB line, too.
> -      */
> --    if (!FIELD_PICTURE)
> -+    if (!FIELD_PICTURE && h->current_slice && !h->sps.new)
> -         ff_er_frame_end(s);
> -
> -     ff_MPV_frame_end(s);
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
> deleted file mode 100644
> index 1e62b50..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
> +++ /dev/null
> @@ -1,39 +0,0 @@
> -gst-ffmpeg: h264_sei: Fix infinite loop.
> -
> -Fixsot yet fixed parts of CVE-2011-3946.
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Yue Tao <yue.tao@windriver.com>
> -
> ----
> - libavcodec/h264_sei.c |    4 ++++
> - 1 files changed, 4 insertions(+), 0 deletions(-)
> -
> -
> -diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
> -index 374e53d..80d70e5 100644
> ---- a/gst-libs/ext/libav/libavcodec/h264_sei.c
> -+++ b/gst-libs/ext/libav/libavcodec/h264_sei.c
> -@@ -169,11 +169,15 @@ int ff_h264_decode_sei(H264Context *h){
> -
> -         type=0;
> -         do{
> -+            if (get_bits_left(&s->gb) < 8)
> -+                return -1;
> -             type+= show_bits(&s->gb, 8);
> -         }while(get_bits(&s->gb, 8) == 255);
> -
> -         size=0;
> -         do{
> -+            if (get_bits_left(&s->gb) < 8)
> -+                return -1;
> -             size+= show_bits(&s->gb, 8);
> -         }while(get_bits(&s->gb, 8) == 255);
> -
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
> deleted file mode 100644
> index e859e44..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
> +++ /dev/null
> @@ -1,87 +0,0 @@
> -From b666debffec1fcbb19ef377635a53b9a58bca8a4 Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Tue, 29 Jan 2013 18:29:41 +0100
> -Subject: [PATCH] huffyuvdec: Check init_vlc() return codes.
> -
> -Upstream-Status: Backport
> -
> -Commit b666debffec1fcbb19ef377635a53b9a58bca8a4 release/1.0
> -
> -Prevents out of array writes
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit f67a0d115254461649470452058fa3c28c0df294)
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/huffyuv.c | 14 ++++++++++----
> - 1 file changed, 10 insertions(+), 4 deletions(-)
> -
> -diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
> -index 58da789..993e524 100644
> ---- a/gst-libs/ext/libav/libavcodec/huffyuv.c
> -+++ b/gst-libs/ext/libav/libavcodec/huffyuv.c
> -@@ -33,6 +33,7 @@
> - #include "put_bits.h"
> - #include "dsputil.h"
> - #include "thread.h"
> -+#include "libavutil/avassert.h"
> -
> - #define VLC_BITS 11
> -
> -@@ -287,6 +287,7 @@ static void generate_joint_tables(HYuvCo
> -                     int len1 = s->len[p][u];
> -                     if (len1 > limit || !len1)
> -                         continue;
> -+                    av_assert0(i < (1 << VLC_BITS));
> -                     len[i] = len0 + len1;
> -                     bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
> -                     symbols[i] = (y<<8) + u;
> -@@ -320,6 +321,7 @@ static void generate_joint_tables(HYuvCo
> -                     int len2 = s->len[2][r&255];
> -                     if (len2 > limit1 || !len2)
> -                         continue;
> -+                    av_assert0(i < (1 << VLC_BITS));
> -                     len[i] = len0 + len1 + len2;
> -                     bits[i] = (code << len2) + s->bits[2][r&255];
> -                     if(s->decorrelate){
> -@@ -343,6 +345,7 @@ static void generate_joint_tables(HYuvCo
> - static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length){
> -     GetBitContext gb;
> -     int i;
> -+    int ret;
> -
> -     init_get_bits(&gb, src, length*8);
> -
> -@@ -353,7 +356,9 @@ static int read_huffman_tables(HYuvConte
> -             return -1;
> -         }
> -         free_vlc(&s->vlc[i]);
> --        init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
> -+        if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
> -+                           s->bits[i], 4, 4, 0)) < 0)
> -+            return ret;
> -     }
> -
> -     generate_joint_tables(s);
> -@@ -365,6 +370,7 @@ static int read_old_huffman_tables(HYuvC
> - #if 1
> -     GetBitContext gb;
> -     int i;
> -+    int ret;
> -
> -     init_get_bits(&gb, classic_shift_luma, sizeof(classic_shift_luma)*8);
> -     if(read_len_table(s->len[0], &gb)<0)
> -@@ -385,7 +391,9 @@ static int read_old_huffman_tables(HYuvC
> -
> -     for(i=0; i<3; i++){
> -         free_vlc(&s->vlc[i]);
> --        init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
> -+        if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
> -+                            s->bits[i], 4, 4, 0)) < 0)
> -+            return ret;
> -     }
> -
> -     generate_joint_tables(s);
> ---
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
> deleted file mode 100644
> index 94bf4b6..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
> +++ /dev/null
> @@ -1,61 +0,0 @@
> -From db0f7f7394e1f994ed38db043f78ed0f10bde0da Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Tue, 29 Jan 2013 19:22:33 +0100
> -Subject: [PATCH] huffyuvdec: Skip len==0 cases
> -
> -Upstream-Status: Backport
> -
> -Commit db0f7f7394e1f994ed38db043f78ed0f10bde0da release/1.0
> -
> -Fixes vlc decoding for hypothetical files that would contain such cases.
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit 0dfc01c2bbf4b71bb56201bc4a393321e15d1b31)
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/huffyuv.c | 10 +++++-----
> - 1 file changed, 5 insertions(+), 5 deletions(-)
> -
> -diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
> -index 993e524..72ed351 100644
> ---- a/gst-libs/ext/libav/libavcodec/huffyuv.c
> -+++ b/gst-libs/ext/libav/libavcodec/huffyuv.c
> -@@ -281,11 +281,11 @@ static void generate_joint_tables(HYuvCo
> -             for(i=y=0; y<256; y++){
> -                 int len0 = s->len[0][y];
> -                 int limit = VLC_BITS - len0;
> --                if(limit <= 0)
> -+                if(limit <= 0 || !len0)
> -                     continue;
> -                 for(u=0; u<256; u++){
> -                     int len1 = s->len[p][u];
> --                    if(len1 > limit)
> -+                    if (len1 > limit || !len1)
> -                         continue;
> -                     len[i] = len0 + len1;
> -                     bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
> -@@ -308,17 +308,17 @@ static void generate_joint_tables(HYuvCo
> -         for(i=0, g=-16; g<16; g++){
> -             int len0 = s->len[p0][g&255];
> -             int limit0 = VLC_BITS - len0;
> --            if(limit0 < 2)
> -+            if (limit0 < 2 || !len0)
> -                 continue;
> -             for(b=-16; b<16; b++){
> -                 int len1 = s->len[p1][b&255];
> -                 int limit1 = limit0 - len1;
> --                if(limit1 < 1)
> -+                if (limit1 < 1 || !len1)
> -                     continue;
> -                 code = (s->bits[p0][g&255] << len1) + s->bits[p1][b&255];
> -                 for(r=-16; r<16; r++){
> -                     int len2 = s->len[2][r&255];
> --                    if(len2 > limit1)
> -+                    if (len2 > limit1 || !len2)
> -                         continue;
> -                     len[i] = len0 + len1 + len2;
> -                     bits[i] = (code << len2) + s->bits[2][r&255];
> ---
> -1.8.5.2.233.g932f7e4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
> deleted file mode 100644
> index ea4aa22..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
> +++ /dev/null
> @@ -1,45 +0,0 @@
> -gst-ffmpeg: lavf: compute probe buffer size more reliably.
> -
> -The previous code computes the offset by reversing the growth
> -of the allocated buffer size: it is complex and did lead to
> -inconsistencies when the size limit is reached.
> -
> -Fix trac ticket #1991.
> -(cherry picked from commit 03847eb8259291b4ff1bd840bd779d0699d71f96)
> -
> -Conflicts:
> -	libavformat/utils.c
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Yue Tao <yue.tao@windriver.com>
> -
> ----
> - libavformat/utils.c |    4 ++--
> - 1 files changed, 2 insertions(+), 2 deletions(-)
> -
> -diff --git a/libavformat/utils.c b/libavformat/utils.c
> -index 7940037..be73c4a 100644
> ---- a/gst-libs/ext/libav/libavformat/utils.c
> -+++ b/gst-libs/ext/libav/libavformat/utils.c
> -@@ -459,7 +459,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
> - {
> -     AVProbeData pd = { filename ? filename : "", NULL, -offset };
> -     unsigned char *buf = NULL;
> --    int ret = 0, probe_size;
> -+    int ret = 0, probe_size, buf_offset = 0;
> -
> -     if (!max_probe_size) {
> -         max_probe_size = PROBE_BUF_MAX;
> -@@ -499,7 +499,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
> -             score = 0;
> -             ret = 0;            /* error was end of file, nothing read */
> -         }
> --        pd.buf_size += ret;
> -+        pd.buf_size = buf_offset += ret;
> -         pd.buf = &buf[offset];
> -
> -         memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
> deleted file mode 100644
> index d90bafa..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -From 1f41cffe1e3e79620f587545bdfcbd7e6e68ed29 Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Sun, 11 Nov 2012 00:01:24 +0100
> -Subject: [PATCH] mjpegdec: check SE.
> -
> -Upstream-Status: Backport
> -
> -Commit 1f41cffe1e3e79620f587545bdfcbd7e6e68ed29 release/1.1
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/mjpegdec.c | 5 +++++
> - 1 file changed, 5 insertions(+)
> -
> -diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> -index 6b5266d..0a71a6f 100644
> ---- a/gst-libs/ext/libav/libavcodec/mjpegdec.c
> -+++ b/gst-libs/ext/libav/libavcodec/mjpegdec.c
> -@@ -905,6 +905,11 @@ static int mjpeg_decode_scan_progressive
> -     int16_t *quant_matrix = s->quant_matrixes[ s->quant_index[c] ];
> -     GetBitContext mb_bitmask_gb;
> -
> -+    if (se > 63) {
> -+        av_log(s->avctx, AV_LOG_ERROR, "SE %d is too large\n", se);
> -+        return AVERROR_INVALIDDATA;
> -+    }
> -+
> -     if (mb_bitmask) {
> -         init_get_bits(&mb_bitmask_gb, mb_bitmask, s->mb_width*s->mb_height);
> -     }
> ---
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
> deleted file mode 100644
> index 1041347..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -From 28bf685bfc6d0c744369cdf367f61a78d80d0b01 Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Thu, 15 Nov 2012 16:41:28 +0100
> -Subject: [PATCH] pgssubdec: check RLE size before copying. Fix out of array
> - accesses
> -
> -Upstream-Status: Backport
> -
> -Commit 28bf685bfc6d0c744369cdf367f61a78d80d0b01 release/1.1
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit c0d68be555f5858703383040e04fcd6529777061)
> ----
> - libavcodec/pgssubdec.c | 5 +++++
> - 1 file changed, 5 insertions(+)
> -
> -diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
> -index 728f178..26a3c2a 100644
> ---- a/gst-libs/ext/libav/libavcodec/pgssubdec.c
> -+++ b/gst-libs/ext/libav/libavcodec/pgssubdec.c
> -@@ -202,6 +202,11 @@ static int parse_picture_segment(AVCodec
> -         return -1;
> -     }
> -
> -+    if (buf_size > rle_bitmap_len) {
> -+        av_log(avctx, AV_LOG_ERROR, "too much RLE data\n");
> -+        return AVERROR_INVALIDDATA;
> -+    }
> -+
> -     ctx->picture.w = width;
> -     ctx->picture.h = height;
> -
> ---
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
> deleted file mode 100644
> index 1e5fb7d..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
> +++ /dev/null
> @@ -1,44 +0,0 @@
> -gst-ffmpeg: pngdec/filter: dont access out of array elements at the end
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Yue Tao <yue.tao@windriver.com>
> ----
> - libavcodec/pngdec.c |   12 ++++--------
> - 1 files changed, 4 insertions(+), 8 deletions(-)
> -
> -diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> -index 97c0ad1..193e35e 100644
> ---- a/gst-libs/ext/libav/libavcodec/pngdec.c
> -+++ b/gst-libs/ext/libav/libavcodec/pngdec.c
> -@@ -190,7 +190,7 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w
> -     if(bpp >= 2) g = dst[1];\
> -     if(bpp >= 3) b = dst[2];\
> -     if(bpp >= 4) a = dst[3];\
> --    for(; i < size; i+=bpp) {\
> -+    for(; i <= size - bpp; i+=bpp) {\
> -         dst[i+0] = r = op(r, src[i+0], last[i+0]);\
> -         if(bpp == 1) continue;\
> -         dst[i+1] = g = op(g, src[i+1], last[i+1]);\
> -@@ -206,13 +206,9 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w
> -     else if(bpp == 2) UNROLL1(2, op)\
> -     else if(bpp == 3) UNROLL1(3, op)\
> -     else if(bpp == 4) UNROLL1(4, op)\
> --    else {\
> --        for (; i < size; i += bpp) {\
> --            int j;\
> --            for (j = 0; j < bpp; j++)\
> --                dst[i+j] = op(dst[i+j-bpp], src[i+j], last[i+j]);\
> --        }\
> --    }
> -+    for (; i < size; i++) {\
> -+        dst[i] = op(dst[i-bpp], src[i], last[i]);\
> -+    }\
> -
> - /* NOTE: 'dst' can be equal to 'last' */
> - static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
> deleted file mode 100644
> index 8c94232..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -gst-ffmpeg: qdm2: check array index before use, fix out of array
> - accesses
> -
> -Upstream-Status: Backport
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/qdm2.c |    5 +++++
> - 1 files changed, 5 insertions(+), 0 deletions(-)
> -
> -diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
> -index 4cf4b2f..1dfb8d5 100644
> ---- a/gst-libs/ext/libav/libavcodec/qdm2.c
> -+++ b/gst-libs/ext/libav/libavcodec/qdm2.c
> -@@ -1257,6 +1257,11 @@ static void qdm2_decode_super_block (QDM2Context *q)
> -     for (i = 0; packet_bytes > 0; i++) {
> -         int j;
> -
> -+        if (i>=FF_ARRAY_ELEMS(q->sub_packet_list_A)) {
> -+            SAMPLES_NEEDED_2("too many packet bytes");
> -+            return;
> -+        }
> -+
> -         q->sub_packet_list_A[i].next = NULL;
> -
> -         if (i > 0) {
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
> deleted file mode 100644
> index 43ffc03..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
> +++ /dev/null
> @@ -1,58 +0,0 @@
> -gst-ffmpeg: qdm2dec: fix buffer overflow. Fixes NGS00144
> -
> -This also adds a few lines of code from master that are needed for this fix.
> -
> -Thanks to Phillip for suggestions to improve the patch.
> -Found-by: Phillip Langlois
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/qdm2.c |    9 +++++++--
> - 1 files changed, 7 insertions(+), 2 deletions(-)
> -
> -diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
> -index 3aa9e5b..e000df8 100644
> ---- a/gst-libs/ext/libav/libavcodec/qdm2.c
> -+++ b/gst-libs/ext/libav/libavcodec/qdm2.c
> -@@ -76,6 +76,7 @@ do { \
> - #define SAMPLES_NEEDED_2(why) \
> -      av_log (NULL,AV_LOG_INFO,"This file triggers some missing code. Please contact the developers.\nPosition: %s\n",why);
> -
> -+#define QDM2_MAX_FRAME_SIZE 512
> -
> - typedef int8_t sb_int8_array[2][30][64];
> -
> -@@ -168,7 +169,7 @@ typedef struct {
> -     /// I/O data
> -     const uint8_t *compressed_data;
> -     int compressed_size;
> --    float output_buffer[1024];
> -+    float output_buffer[QDM2_MAX_FRAME_SIZE * MPA_MAX_CHANNELS * 2];
> -
> -     /// Synthesis filter
> -     MPADSPContext mpadsp;
> -@@ -1819,6 +1820,9 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
> -     s->group_order = av_log2(s->group_size) + 1;
> -     s->frame_size = s->group_size / 16; // 16 iterations per super block
> -
> -+    if (s->frame_size > QDM2_MAX_FRAME_SIZE)
> -+        return AVERROR_INVALIDDATA;
> -+
> -     s->sub_sampling = s->fft_order - 7;
> -     s->frequency_range = 255 / (1 << (2 - s->sub_sampling));
> -
> -@@ -1887,6 +1891,9 @@ static int qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
> -     int ch, i;
> -     const int frame_size = (q->frame_size * q->channels);
> -
> -+    if((unsigned)frame_size > FF_ARRAY_ELEMS(q->output_buffer)/2)
> -+        return -1;
> -+
> -     /* select input buffer */
> -     q->compressed_data = in;
> -     q->compressed_size = q->checksum_size;
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
> deleted file mode 100644
> index 7e58afc..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
> +++ /dev/null
> @@ -1,36 +0,0 @@
> -From 391e0fc6c90ced6656b74f50f3a487b6dc76ea63 Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Thu, 29 Nov 2012 15:18:17 +0100
> -Subject: [PATCH] roqvideodec: check dimensions validity
> -
> -Upstream-Status: Backport
> -
> -Commit 391e0fc6c90ced6656b74f50f3a487b6dc76ea63 release/0.7
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit 3ae610451170cd5a28b33950006ff0bd23036845)
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/roqvideodec.c | 6 ++++++
> - 1 file changed, 6 insertions(+)
> -
> -diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c
> -index f0977f6..4e34231 100644
> ---- a/gst-libs/ext/libav/libavcodec/roqvideodec.c
> -+++ b/gst-libs/ext/libav/libavcodec/roqvideodec.c
> -@@ -157,6 +157,12 @@ static av_cold int roq_decode_init(AVCodecContext *avctx)
> -     RoqContext *s = avctx->priv_data;
> -
> -     s->avctx = avctx;
> -+
> -+    if (avctx->width%16 || avctx->height%16) {
> -+         av_log_ask_for_sample(avctx, "dimensions not being a multiple of 16 are unsupported\n");
> -+         return AVERROR_PATCHWELCOME;
> -+    }
> -+
> -     s->width = avctx->width;
> -     s->height = avctx->height;
> -     avcodec_get_frame_defaults(&s->frames[0]);
> ---
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
> deleted file mode 100644
> index 15b1614..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -gst-ffmpeg: smackerdec: Check that the last indexes are within the
> - table.
> -
> -Fixes CVE-2011-3944
> -
> -Upstream-Status: Backport
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/smacker.c |    5 +++++
> - 1 files changed, 5 insertions(+), 0 deletions(-)
> -
> -diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
> -index 30f99b4..2a8bae8 100644
> ---- a/gst-libs/ext/libav/libavcodec/smacker.c
> -+++ b/gst-libs/ext/libav/libavcodec/smacker.c
> -@@ -259,6 +259,11 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
> -     if(ctx.last[0] == -1) ctx.last[0] = huff.current++;
> -     if(ctx.last[1] == -1) ctx.last[1] = huff.current++;
> -     if(ctx.last[2] == -1) ctx.last[2] = huff.current++;
> -+    if(huff.current > huff.length){
> -+        ctx.last[0] = ctx.last[1] = ctx.last[2] = 1;
> -+        av_log(smk->avctx, AV_LOG_ERROR, "bigtree damaged\n");
> -+        return -1;
> -+    }
> -
> -     *recodes = huff.values;
> -
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
> deleted file mode 100644
> index a1989cf..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -gst-ffmpeg: vp3: Copy all 3 frames for thread updates.
> -
> -This fixes a double release of the current frame on deinit.
> -Fixes CVE-2011-3934
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Yue.Tao <yue.tao@windriver.com>
> -
> ----
> - libavcodec/vp3.c |    2 +-
> - 1 files changed, 1 insertions(+), 1 deletions(-)
> -
> -diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> -index 738ae9f..b5daafc 100644
> ---- a/gst-libs/ext/libav/libavcodec/vp3.c
> -+++ b/gst-libs/ext/libav/libavcodec/vp3.c
> -@@ -1859,7 +1859,7 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
> -         ||s->width != s1->width
> -         ||s->height!= s1->height) {
> -         if (s != s1)
> --            copy_fields(s, s1, golden_frame, current_frame);
> -+            copy_fields(s, s1, golden_frame, keyframe);
> -         return -1;
> -     }
> -
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
> deleted file mode 100644
> index e83d8f4..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
> +++ /dev/null
> @@ -1,183 +0,0 @@
> -gst-ffmpeg: vp3: fix oob read for negative tokens and memleaks on error.
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Yue.Tao <yue.tao@windriver.com>
> -
> ----
> - libavcodec/vp3.c |   59 +++++++++++++++++++++++++++++++++++++++++------------
> - 1 files changed, 45 insertions(+), 14 deletions(-)
> -
> -diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> -index 36715bb..ce14e63 100644
> ---- a/gst-libs/ext/libav/libavcodec/vp3.c
> -+++ b/gst-libs/ext/libav/libavcodec/vp3.c
> -@@ -45,6 +45,7 @@
> - #define FRAGMENT_PIXELS 8
> -
> - static av_cold int vp3_decode_end(AVCodecContext *avctx);
> -+static void vp3_decode_flush(AVCodecContext *avctx);
> -
> - //FIXME split things out into their own arrays
> - typedef struct Vp3Fragment {
> -@@ -890,7 +891,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
> -             /* decode a VLC into a token */
> -             token = get_vlc2(gb, vlc_table, 11, 3);
> -             /* use the token to get a zero run, a coefficient, and an eob run */
> --            if (token <= 6) {
> -+            if ((unsigned) token <= 6U) {
> -                 eob_run = eob_run_base[token];
> -                 if (eob_run_get_bits[token])
> -                     eob_run += get_bits(gb, eob_run_get_bits[token]);
> -@@ -908,7 +909,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
> -                     coeff_i        += eob_run;
> -                     eob_run = 0;
> -                 }
> --            } else {
> -+            } else if (token >= 0) {
> -                 bits_to_get = coeff_get_bits[token];
> -                 if (bits_to_get)
> -                     bits_to_get = get_bits(gb, bits_to_get);
> -@@ -942,6 +943,10 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
> -                 for (i = coeff_index+1; i <= coeff_index+zero_run; i++)
> -                     s->num_coded_frags[plane][i]--;
> -                 coeff_i++;
> -+            } else {
> -+                av_log(s->avctx, AV_LOG_ERROR,
> -+                       "Invalid token %d\n", token);
> -+                return -1;
> -             }
> -     }
> -
> -@@ -991,6 +996,8 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
> -     /* unpack the Y plane DC coefficients */
> -     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0,
> -         0, residual_eob_run);
> -+    if (residual_eob_run < 0)
> -+        return residual_eob_run;
> -
> -     /* reverse prediction of the Y-plane DC coefficients */
> -     reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]);
> -@@ -998,8 +1005,12 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
> -     /* unpack the C plane DC coefficients */
> -     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
> -         1, residual_eob_run);
> -+    if (residual_eob_run < 0)
> -+        return residual_eob_run;
> -     residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
> -         2, residual_eob_run);
> -+    if (residual_eob_run < 0)
> -+        return residual_eob_run;
> -
> -     /* reverse prediction of the C-plane DC coefficients */
> -     if (!(s->avctx->flags & CODEC_FLAG_GRAY))
> -@@ -1036,11 +1047,17 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
> -     for (i = 1; i <= 63; i++) {
> -             residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i,
> -                 0, residual_eob_run);
> -+            if (residual_eob_run < 0)
> -+                return residual_eob_run;
> -
> -             residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
> -                 1, residual_eob_run);
> -+            if (residual_eob_run < 0)
> -+                return residual_eob_run;
> -             residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
> -                 2, residual_eob_run);
> -+            if (residual_eob_run < 0)
> -+                return residual_eob_run;
> -     }
> -
> -     return 0;
> -@@ -1777,10 +1794,15 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
> -     Vp3DecodeContext *s = dst->priv_data, *s1 = src->priv_data;
> -     int qps_changed = 0, i, err;
> -
> -+#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
> -+
> -     if (!s1->current_frame.data[0]
> -         ||s->width != s1->width
> --        ||s->height!= s1->height)
> -+        ||s->height!= s1->height) {
> -+        if (s != s1)
> -+            copy_fields(s, s1, golden_frame, current_frame);
> -         return -1;
> -+    }
> -
> -     if (s != s1) {
> -         // init tables if the first frame hasn't been decoded
> -@@ -1796,8 +1818,6 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
> -             memcpy(s->motion_val[1], s1->motion_val[1], c_fragment_count * sizeof(*s->motion_val[1]));
> -         }
> -
> --#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
> --
> -         // copy previous frame data
> -         copy_fields(s, s1, golden_frame, dsp);
> -
> -@@ -1987,9 +2007,6 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
> -     Vp3DecodeContext *s = avctx->priv_data;
> -     int i;
> -
> --    if (avctx->is_copy && !s->current_frame.data[0])
> --        return 0;
> --
> -     av_free(s->superblock_coding);
> -     av_free(s->all_fragments);
> -     av_free(s->coded_fragment_list[0]);
> -@@ -2016,12 +2033,7 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
> -     free_vlc(&s->motion_vector_vlc);
> -
> -     /* release all frames */
> --    if (s->golden_frame.data[0])
> --        ff_thread_release_buffer(avctx, &s->golden_frame);
> --    if (s->last_frame.data[0] && s->last_frame.type != FF_BUFFER_TYPE_COPY)
> --        ff_thread_release_buffer(avctx, &s->last_frame);
> --    /* no need to release the current_frame since it will always be pointing
> --     * to the same frame as either the golden or last frame */
> -+    vp3_decode_flush(avctx);
> -
> -     return 0;
> - }
> -@@ -2341,6 +2353,23 @@ static void vp3_decode_flush(AVCodecContext *avctx)
> -         ff_thread_release_buffer(avctx, &s->current_frame);
> - }
> -
> -+static int vp3_init_thread_copy(AVCodecContext *avctx)
> -+{
> -+    Vp3DecodeContext *s = avctx->priv_data;
> -+
> -+    s->superblock_coding      = NULL;
> -+    s->all_fragments          = NULL;
> -+    s->coded_fragment_list[0] = NULL;
> -+    s->dct_tokens_base        = NULL;
> -+    s->superblock_fragments   = NULL;
> -+    s->macroblock_coding      = NULL;
> -+    s->motion_val[0]          = NULL;
> -+    s->motion_val[1]          = NULL;
> -+    s->edge_emu_buffer        = NULL;
> -+
> -+    return 0;
> -+}
> -+
> - AVCodec ff_theora_decoder = {
> -     .name           = "theora",
> -     .type           = AVMEDIA_TYPE_VIDEO,
> -@@ -2352,6 +2381,7 @@ AVCodec ff_theora_decoder = {
> -     .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
> -     .flush = vp3_decode_flush,
> -     .long_name = NULL_IF_CONFIG_SMALL("Theora"),
> -+    .init_thread_copy      = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
> -     .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
> - };
> - #endif
> -@@ -2367,5 +2397,6 @@ AVCodec ff_vp3_decoder = {
> -     .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
> -     .flush = vp3_decode_flush,
> -     .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"),
> -+    .init_thread_copy      = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
> -     .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
> - };
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
> deleted file mode 100644
> index 7e4f682..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
> +++ /dev/null
> @@ -1,51 +0,0 @@
> -From 2cac35086c9e103fa98960c546d5017e7363803a Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Fri, 25 Jan 2013 06:11:59 +0100
> -Subject: [PATCH] vqavideo: check chunk sizes before reading chunks
> -
> -Upstream-Status: Backport
> -
> -Commit 2cac35086c9e103fa98960c546d5017e7363803a release/0.7
> -
> -Fixes out of array writes
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -(cherry picked from commit ab6c9332bfa1e20127a16392a0b85a4aa4840889)
> -
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> ----
> - libavcodec/vqavideo.c |   10 ++++++++++
> - 1 files changed, 10 insertions(+), 0 deletions(-)
> -
> -diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
> -index d1eab5b..6e1ce6c 100644
> ---- a/gst-libs/ext/libav/libavcodec/vqavideo.c
> -+++ b/gst-libs/ext/libav/libavcodec/vqavideo.c
> -@@ -527,6 +527,11 @@ static void vqa_decode_chunk(VqaContext *s)
> -         chunk_size = AV_RB32(&s->buf[cbp0_chunk + 4]);
> -         cbp0_chunk += CHUNK_PREAMBLE_SIZE;
> -
> -+        if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
> -+            av_log(s->avctx, AV_LOG_ERROR, "cbp0 chunk too large (0x%X bytes)\n", chunk_size);
> -+            return AVERROR_INVALIDDATA;
> -+        }
> -+
> -         /* accumulate partial codebook */
> -         memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
> -             &s->buf[cbp0_chunk], chunk_size);
> -@@ -550,6 +555,11 @@ static void vqa_decode_chunk(VqaContext *s)
> -         chunk_size = AV_RB32(&s->buf[cbpz_chunk + 4]);
> -         cbpz_chunk += CHUNK_PREAMBLE_SIZE;
> -
> -+        if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
> -+            av_log(s->avctx, AV_LOG_ERROR, "cbpz chunk too large (0x%X bytes)\n", chunk_size);
> -+            return AVERROR_INVALIDDATA;
> -+        }
> -+
> -         /* accumulate partial codebook */
> -         memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
> -             &s->buf[cbpz_chunk], chunk_size);
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
> deleted file mode 100644
> index c8bafd5..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
> +++ /dev/null
> @@ -1,68 +0,0 @@
> -From 6043c431c97d55173f339fafbd033d3c0642e2e9 Mon Sep 17 00:00:00 2001
> -From: Michael Niedermayer <michaelni@gmx.at>
> -Date: Fri, 3 Oct 2014 01:50:27 +0200
> -Subject: [PATCH 2/2] avcodec/mjpegdec: check bits per pixel for changes
> - similar to dimensions
> -
> -Upstream-Status: Backport
> -
> -Fixes out of array accesses
> -Fixes: asan_heap-oob_16668e9_2_asan_heap-oob_16668e9_346_miss_congeniality_pegasus_mjpg.avi
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -
> -Conflicts:
> -	libavcodec/mjpegdec.c
> ----
> - libavcodec/mjpegdec.c | 15 ++++++++-------
> - 1 file changed, 8 insertions(+), 7 deletions(-)
> -
> -diff --git a/gst-libs/ext/libav/libavcodec/mjpegdec.c b/gst-libs/ext/libav/libavcodec/mjpegdec.c
> -index 84343c0..c0137d8 100644
> ---- a/gst-libs/ext/libav/libavcodec/mjpegdec.c
> -+++ b/gst-libs/ext/libav/libavcodec/mjpegdec.c
> -@@ -210,16 +210,16 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
> -
> - int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
> - {
> --    int len, nb_components, i, width, height, pix_fmt_id;
> -+    int len, nb_components, i, bits, width, height, pix_fmt_id;
> -
> -     /* XXX: verify len field validity */
> -     len = get_bits(&s->gb, 16);
> --    s->bits= get_bits(&s->gb, 8);
> -+    bits= get_bits(&s->gb, 8);
> -
> --    if(s->pegasus_rct) s->bits=9;
> --    if(s->bits==9 && !s->pegasus_rct) s->rct=1;    //FIXME ugly
> -+    if(s->pegasus_rct) bits=9;
> -+    if(bits==9 && !s->pegasus_rct) s->rct=1;    //FIXME ugly
> -
> --    if (s->bits != 8 && !s->lossless){
> -+    if (bits != 8 && !s->lossless){
> -         av_log(s->avctx, AV_LOG_ERROR, "only 8 bits/component accepted\n");
> -         return -1;
> -     }
> -@@ -239,7 +239,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
> -     if (nb_components <= 0 ||
> -         nb_components > MAX_COMPONENTS)
> -         return -1;
> --    if (s->ls && !(s->bits <= 8 || nb_components == 1)){
> -+    if (s->ls && !(bits <= 8 || nb_components == 1)){
> -         av_log(s->avctx, AV_LOG_ERROR, "only <= 8 bits/component or 16-bit gray accepted for JPEG-LS\n");
> -         return -1;
> -     }
> -@@ -272,10 +272,11 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
> -
> -     /* if different size, realloc/alloc picture */
> -     /* XXX: also check h_count and v_count */
> --    if (width != s->width || height != s->height) {
> -+    if (width != s->width || height != s->height || bits != s->bits) {
> -         av_freep(&s->qscale_table);
> -
> -         s->width = width;
> -+        s->bits= bits;
> -         s->height = height;
> -         s->interlaced = 0;
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch
> deleted file mode 100644
> index 9ef6f7c..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch
> +++ /dev/null
> @@ -1,22 +0,0 @@
> -Disable yasm for libav when --disable-yasm
> -
> -Upstream-Status: Inappropriate [configuration]
> -
> -Signed-off-by: Shane Wang <shane.wang@intel.com>
> -
> -diff -r f2f8f74c6e30 configure.ac
> ---- a/configure.ac	Thu Dec 22 23:56:09 2011 +0800
> -+++ b/configure.ac	Thu Dec 22 23:57:37 2011 +0800
> -@@ -325,6 +325,12 @@
> -         --enable-gpl"
> -   fi
> -
> -+ AC_ARG_ENABLE(yasm,
> -+              [AC_HELP_STRING([--disable-yasm], [disable use of yasm assembler])])
> -+  if test "x$enable_yasm" = "xno"; then
> -+    embffmpeg_configure_args="$embffmpeg_configure_args --disable-yasm"
> -+  fi
> -+
> -   # if we are cross-compiling, tell ffmpeg so
> -   target_os=`echo $host_os | sed 's/-gnu//'`
> -   if test "x$cross_compiling" = xyes; then
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
> deleted file mode 100644
> index 3c8d8e3..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
> +++ /dev/null
> @@ -1,100 +0,0 @@
> -gst-ffmpeg: Security Advisory - ffmpeg - CVE-2013-0855
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Yue Tao <yue.tao@windriver.com>
> -
> -diff --git a/gst-libs/ext/libav/libavcodec/alac.c.old b/gst-libs/ext/libav/libavcodec/alac.c
> -index 2a0df8c..bcbd56d 100644
> ---- a/gst-libs/ext/libav/libavcodec/alac.c.old
> -+++ b/gst-libs/ext/libav/libavcodec/alac.c
> -@@ -87,18 +87,44 @@ typedef struct {
> -     int wasted_bits;
> - } ALACContext;
> -
> --static void allocate_buffers(ALACContext *alac)
> -+static av_cold int alac_decode_close(AVCodecContext *avctx)
> -+{
> -+    ALACContext *alac = avctx->priv_data;
> -+
> -+    int chan;
> -+    for (chan = 0; chan < MAX_CHANNELS; chan++) {
> -+        av_freep(&alac->predicterror_buffer[chan]);
> -+        av_freep(&alac->outputsamples_buffer[chan]);
> -+        av_freep(&alac->wasted_bits_buffer[chan]);
> -+    }
> -+
> -+    return 0;
> -+}
> -+
> -+static int allocate_buffers(ALACContext *alac)
> - {
> -     int chan;
> -+    int buf_size;
> -+
> -+    if (alac->setinfo_max_samples_per_frame > INT_MAX / sizeof(int32_t))
> -+        goto buf_alloc_fail;
> -+    buf_size = alac->setinfo_max_samples_per_frame * sizeof(int32_t);
> -+
> -     for (chan = 0; chan < MAX_CHANNELS; chan++) {
> --        alac->predicterror_buffer[chan] =
> --            av_malloc(alac->setinfo_max_samples_per_frame * 4);
> -
> --        alac->outputsamples_buffer[chan] =
> --            av_malloc(alac->setinfo_max_samples_per_frame * 4);
> -+        FF_ALLOC_OR_GOTO(alac->avctx, alac->predicterror_buffer[chan],
> -+                         buf_size, buf_alloc_fail);
> -
> --        alac->wasted_bits_buffer[chan] = av_malloc(alac->setinfo_max_samples_per_frame * 4);
> -+        FF_ALLOC_OR_GOTO(alac->avctx, alac->outputsamples_buffer[chan],
> -+                         buf_size, buf_alloc_fail);
> -+
> -+        FF_ALLOC_OR_GOTO(alac->avctx, alac->wasted_bits_buffer[chan],
> -+                         buf_size, buf_alloc_fail);
> -     }
> -+    return 0;
> -+buf_alloc_fail:
> -+    alac_decode_close(alac->avctx);
> -+    return AVERROR(ENOMEM);
> - }
> -
> - static int alac_set_info(ALACContext *alac)
> -@@ -131,8 +157,6 @@ static int alac_set_info(ALACContext *alac)
> -     bytestream_get_be32(&ptr);      /* bitrate ? */
> -     bytestream_get_be32(&ptr);      /* samplerate */
> -
> --    allocate_buffers(alac);
> --
> -     return 0;
> - }
> -
> -@@ -659,6 +683,7 @@ static int alac_decode_frame(AVCodecContext *avctx,
> -
> - static av_cold int alac_decode_init(AVCodecContext * avctx)
> - {
> -+    int ret;
> -     ALACContext *alac = avctx->priv_data;
> -     alac->avctx = avctx;
> -     alac->numchannels = alac->avctx->channels;
> -@@ -674,18 +699,9 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
> -         return -1;
> -     }
> -
> --    return 0;
> --}
> --
> --static av_cold int alac_decode_close(AVCodecContext *avctx)
> --{
> --    ALACContext *alac = avctx->priv_data;
> --
> --    int chan;
> --    for (chan = 0; chan < MAX_CHANNELS; chan++) {
> --        av_freep(&alac->predicterror_buffer[chan]);
> --        av_freep(&alac->outputsamples_buffer[chan]);
> --        av_freep(&alac->wasted_bits_buffer[chan]);
> -+    if ((ret = allocate_buffers(alac)) < 0) {
> -+        av_log(avctx, AV_LOG_ERROR, "Error allocating buffers\n");
> -+        return ret;
> -     }
> -
> -     return 0;
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
> deleted file mode 100644
> index aa385f5..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
> +++ /dev/null
> @@ -1,26 +0,0 @@
> -avcodec/cdgraphics: check buffer size before use
> -
> -Fixes out of array accesses
> -
> -Backported from:http://git.videolan.org/?p=ffmpeg.git;a=commit;h=ad002e1a13a8df934bd6cb2c84175a4780ab8942
> -
> -Upstream-Status: Backport
> -
> -Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> -Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
> -Signed-off-by: Ming Liu <ming.liu@windriver.com>
> -
> -diff -urpN a/gst-libs/ext/libav/libavcodec/cdgraphics.c b/gst-libs/ext/libav/libavcodec/cdgraphics.c
> ---- a/gst-libs/ext/libav/libavcodec/cdgraphics.c	2013-07-18 13:17:08.399876575 +0800
> -+++ b/gst-libs/ext/libav/libavcodec/cdgraphics.c	2013-07-18 13:18:05.880502267 +0800
> -@@ -291,7 +291,9 @@ static int cdg_decode_frame(AVCodecConte
> -     inst    = bytestream_get_byte(&buf);
> -     inst    &= CDG_MASK;
> -     buf += 2;  /// skipping 2 unneeded bytes
> --    bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
> -+
> -+    if (buf_size > CDG_HEADER_SIZE)
> -+        bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
> -
> -     if ((command & CDG_MASK) == CDG_COMMAND) {
> -         switch (inst) {
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
> deleted file mode 100644
> index ade24dc..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
> +++ /dev/null
> @@ -1,57 +0,0 @@
> -Backport http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=5f654897e325349dacf2546674e0510bb72ecb50;hp=250cebeb3b348c3da71f9972eb500d6005dc01f1
> -
> -Fixes these errors on x86
> -
> -libavcodec/x86/h264_qpel_mmx.c: Assembler messages:
> -libavcodec/x86/h264_qpel_mmx.c:1294: Error: operand type mismatch for `cmp'
> -libavcodec/x86/h264_qpel_mmx.c:1294: Error: operand type mismatch for `cmp'
> -libavcodec/x86/h264_qpel_mmx.c:1298: Error: operand type mismatch for `cmp'
> -libavcodec/x86/h264_qpel_mmx.c:1298: Error: operand type mismatch for `cmp'
> -libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
> -libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
> -libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
> -make[5]: *** [libavcodec/x86/dsputil_mmx.o] Error 1
> -
> -
> -Signed-off-by: Khem Raj <raj.khem@gmail.com>
> -Upstream-Status: Backport
> -Index: gst-ffmpeg-0.10.13/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c
> -===================================================================
> ---- gst-ffmpeg-0.10.13.orig/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c	2012-03-30 11:39:41.324522051 -0700
> -+++ gst-ffmpeg-0.10.13/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c	2012-03-30 11:54:08.152564075 -0700
> -@@ -398,7 +398,7 @@
> -             "2:                         \n\t"\
> -             \
> -             : "+a"(src), "+c"(dst)\
> --            : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\
> -+            : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "rm"(h)\
> -             : "memory"\
> -         );\
> -         src += 4-(h+5)*srcStride;\
> -@@ -446,7 +446,7 @@
> -             QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 15*48)\
> -             "2:                     \n\t"\
> -             : "+a"(src)\
> --            : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)\
> -+            : "c"(tmp), "S"((x86_reg)srcStride), "rm"(size)\
> -             : "memory"\
> -             );\
> -         tmp += 4;\
> -@@ -823,7 +823,7 @@
> -         "2:                          \n\t"\
> -         \
> -         : "+a"(src), "+c"(dst)\
> --        : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\
> -+        : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "rm"(h)\
> -         : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
> -                        "%xmm4", "%xmm5", "%xmm6", "%xmm7",)\
> -           "memory"\
> -@@ -878,7 +878,7 @@
> -             QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 15*48)
> -             "2:                         \n\t"
> -             : "+a"(src)
> --            : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)
> -+            : "c"(tmp), "S"((x86_reg)srcStride), "rm"(size)
> -             : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3",
> -                            "%xmm4", "%xmm5", "%xmm6", "%xmm7",)
> -               "memory"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch
> deleted file mode 100644
> index 1860752..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch
> +++ /dev/null
> @@ -1,9304 +0,0 @@
> -Taken from gentoo patchset:
> -http://dev.gentoo.org/~tetromino/distfiles/gst-plugins-ffmpeg/gst-ffmpeg-0.10.13_p2012.11-libav-9-patches.tar.xz
> -
> -Upstream-Status: Pending
> -
> -Contains following changes, rebased to apply on top of our changes
> -0002-Fix-includes-for-systemwide-build.patch
> -0003-libav-Switch-to-non-deprecated-symbols.patch
> -0005-av-Update-for-some-constant-changes.patch
> -0006-av-Remove-palette-support-for-now.patch
> -0007-av-Port-remaining-simple-bits.patch
> -0008-av-Use-av_codec_is_-en-de-coder-API-instead-of-priva.patch
> -0009-avprotocol-Port-from-the-URL-protocol-handler-to-san.patch
> -0010-avdec-don-t-wait-for-keyframe.patch
> -
> -Following changes were skipped:
> -0001-Partially-revert-commit-0300801b.patch
> -0004-av-update-to-use-AVOption-variants.patch
> -0011-av_get_bits_per_sample_format-was-removed-in-libav-9.patch
> -
> -Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> -
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.c
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.c	2011-10-31 11:14:03.000000000 +0100
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.c	2014-08-08 15:26:07.872857555 +0200
> -@@ -151,9 +151,6 @@
> - #endif
> -   gst_ffmpegaudioresample_register (plugin);
> -
> --  av_register_protocol2 (&gstreamer_protocol, sizeof (URLProtocol));
> --  av_register_protocol2 (&gstpipe_protocol, sizeof (URLProtocol));
> --
> -   /* Now we can return the pointer to the newly created Plugin object. */
> -   return TRUE;
> - }
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.h gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.h
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.h	2011-05-17 10:53:16.000000000 +0200
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.h	2014-08-08 15:26:07.872857555 +0200
> -@@ -58,10 +58,13 @@
> - int gst_ffmpeg_avcodec_close (AVCodecContext *avctx);
> - int gst_ffmpeg_av_find_stream_info(AVFormatContext *ic);
> -
> --G_END_DECLS
> -+int gst_ffmpegdata_open (GstPad * pad, int flags, AVIOContext ** context);
> -+int gst_ffmpegdata_close (AVIOContext * h);
> -+typedef struct _GstFFMpegPipe GstFFMpegPipe;
> -+int gst_ffmpeg_pipe_open (GstFFMpegPipe *ffpipe, int flags, AVIOContext ** context);
> -+int gst_ffmpeg_pipe_close (AVIOContext * h);
> -
> --extern URLProtocol gstreamer_protocol;
> --extern URLProtocol gstpipe_protocol;
> -+G_END_DECLS
> -
> - /* use GST_FFMPEG URL_STREAMHEADER with URL_WRONLY if the first
> -  * buffer should be used as streamheader property on the pad's caps. */
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcfg.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcfg.c
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcfg.c	2011-07-12 16:35:27.000000000 +0200
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcfg.c	2014-08-08 15:24:17.899853612 +0200
> -@@ -147,7 +147,6 @@
> -       {FF_DCT_FASTINT, "Fast Integer", "fastint"},
> -       {FF_DCT_INT, "Accurate Integer", "int"},
> -       {FF_DCT_MMX, "MMX", "mmx"},
> --      {FF_DCT_MLIB, "MLIB", "mlib"},
> -       {FF_DCT_ALTIVEC, "ALTIVEC", "altivec"},
> -       {FF_DCT_FAAN, "FAAN", "faan"},
> -       {0, NULL, NULL},
> -@@ -173,8 +172,6 @@
> -       {FF_IDCT_SIMPLE, "Simple", "simple"},
> -       {FF_IDCT_SIMPLEMMX, "Simple MMX", "simplemmx"},
> -       {FF_IDCT_LIBMPEG2MMX, "LIBMPEG2MMX", "libmpeg2mmx"},
> --      {FF_IDCT_PS2, "PS2", "ps2"},
> --      {FF_IDCT_MLIB, "MLIB", "mlib"},
> -       {FF_IDCT_ARM, "ARM", "arm"},
> -       {FF_IDCT_ALTIVEC, "ALTIVEC", "altivec"},
> -       {FF_IDCT_SH4, "SH4", "sh4"},
> -@@ -263,16 +260,11 @@
> -
> -   if (!ffmpeg_flags_type) {
> -     static const GFlagsValue ffmpeg_flags[] = {
> --      {CODEC_FLAG_OBMC, "Use overlapped block motion compensation (h263+)",
> --          "obmc"},
> -       {CODEC_FLAG_QSCALE, "Use fixed qscale", "qscale"},
> -       {CODEC_FLAG_4MV, "Allow 4 MV per MB", "4mv"},
> --      {CODEC_FLAG_H263P_AIV, "H.263 alternative inter VLC", "aiv"},
> -       {CODEC_FLAG_QPEL, "Quartel Pel Motion Compensation", "qpel"},
> -       {CODEC_FLAG_GMC, "GMC", "gmc"},
> -       {CODEC_FLAG_MV0, "Always try a MB with MV (0,0)", "mv0"},
> --      {CODEC_FLAG_PART,
> --          "Store MV, DC and AC coefficients in seperate partitions", "part"},
> -       {CODEC_FLAG_LOOP_FILTER, "Loop filter", "loop-filter"},
> -       {CODEC_FLAG_GRAY, "Only decode/encode grayscale", "gray"},
> -       {CODEC_FLAG_NORMALIZE_AQP,
> -@@ -282,13 +274,9 @@
> -           "global-headers"},
> -       {CODEC_FLAG_AC_PRED, "H263 Advanced Intra Coding / MPEG4 AC prediction",
> -           "aic"},
> --      {CODEC_FLAG_H263P_UMV, "Unlimited Motion Vector", "umv"},
> -       {CODEC_FLAG_CBP_RD, "Rate Distoration Optimization for CBP", "cbp-rd"},
> -       {CODEC_FLAG_QP_RD, "Rate Distoration Optimization for QP selection",
> -           "qp-rd"},
> --      {CODEC_FLAG_H263P_SLICE_STRUCT, "H263 slice struct", "ss"},
> --      {CODEC_FLAG_SVCD_SCAN_OFFSET,
> --          "Reserve space for SVCD scan offset user data", "scanoffset"},
> -       {CODEC_FLAG_CLOSED_GOP, "Closed GOP", "closedgop"},
> -       {0, NULL, NULL},
> -     };
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c	2011-10-31 11:14:03.000000000 +0100
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c	2014-08-08 15:31:30.968869139 +0200
> -@@ -25,8 +25,10 @@
> - #include <gst/gst.h>
> - #ifdef HAVE_FFMPEG_UNINSTALLED
> - #include <avcodec.h>
> -+#include <channel_layout.h>
> - #else
> - #include <libavcodec/avcodec.h>
> -+#include <libavutil/channel_layout.h>
> - #endif
> - #include <string.h>
> -
> -@@ -35,43 +37,6 @@
> -
> - #include <gst/pbutils/codec-utils.h>
> -
> --/*
> -- * Read a palette from a caps.
> -- */
> --
> --static void
> --gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
> --{
> --  GstStructure *str = gst_caps_get_structure (caps, 0);
> --  const GValue *palette_v;
> --  const GstBuffer *palette;
> --
> --  /* do we have a palette? */
> --  if ((palette_v = gst_structure_get_value (str, "palette_data")) && context) {
> --    palette = gst_value_get_buffer (palette_v);
> --    if (GST_BUFFER_SIZE (palette) >= AVPALETTE_SIZE) {
> --      if (context->palctrl)
> --        av_free (context->palctrl);
> --      context->palctrl = av_malloc (sizeof (AVPaletteControl));
> --      context->palctrl->palette_changed = 1;
> --      memcpy (context->palctrl->palette, GST_BUFFER_DATA (palette),
> --          AVPALETTE_SIZE);
> --    }
> --  }
> --}
> --
> --static void
> --gst_ffmpeg_set_palette (GstCaps * caps, AVCodecContext * context)
> --{
> --  if (context->palctrl) {
> --    GstBuffer *palette = gst_buffer_new_and_alloc (AVPALETTE_SIZE);
> --
> --    memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
> --        AVPALETTE_SIZE);
> --    gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, palette, NULL);
> --  }
> --}
> --
> - /* IMPORTANT: Keep this sorted by the ffmpeg channel masks */
> - static const struct
> - {
> -@@ -79,26 +44,26 @@
> -   GstAudioChannelPosition gst;
> - } _ff_to_gst_layout[] = {
> -   {
> --  CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
> --  CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
> --  CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
> --  CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
> --  CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
> --  CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
> --  CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
> --  CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
> --  CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
> --  CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
> --  CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
> --  CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> --  CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> --  CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> --  CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> --  CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> --  CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> --  CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> --  CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
> --  CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
> -+  AV_CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
> -+  AV_CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
> -+  AV_CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
> -+  AV_CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
> -+  AV_CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
> -+  AV_CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
> -+  AV_CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
> -+  AV_CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
> -+  AV_CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
> -+  AV_CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
> -+  AV_CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
> -+  AV_CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> -+  AV_CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> -+  AV_CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> -+  AV_CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> -+  AV_CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> -+  AV_CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> -+  AV_CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> -+  AV_CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
> -+  AV_CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
> - };
> -
> - static GstAudioChannelPosition *
> -@@ -342,8 +307,8 @@
> -
> -     if (channel_layout == 0) {
> -       const guint64 default_channel_set[] = {
> --        0, 0, CH_LAYOUT_SURROUND, CH_LAYOUT_QUAD, CH_LAYOUT_5POINT0,
> --        CH_LAYOUT_5POINT1, 0, CH_LAYOUT_7POINT1
> -+        0, 0, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_5POINT0,
> -+        AV_CH_LAYOUT_5POINT1, 0, AV_CH_LAYOUT_7POINT1
> -       };
> -
> -       switch (codec_id) {
> -@@ -1267,8 +1232,6 @@
> -     case CODEC_ID_FLIC:
> -     case CODEC_ID_VMDVIDEO:
> -     case CODEC_ID_VMDAUDIO:
> --    case CODEC_ID_SONIC:
> --    case CODEC_ID_SONIC_LS:
> -     case CODEC_ID_SNOW:
> -     case CODEC_ID_VIXL:
> -     case CODEC_ID_QPEG:
> -@@ -1689,11 +1652,6 @@
> -       gst_buffer_unref (data);
> -     }
> -
> --    /* palette */
> --    if (context) {
> --      gst_ffmpeg_set_palette (caps, context);
> --    }
> --
> -     GST_LOG ("caps for codec_id=%d: %" GST_PTR_FORMAT, codec_id, caps);
> -
> -   } else {
> -@@ -1830,9 +1788,6 @@
> -             "bpp", G_TYPE_INT, bpp,
> -             "depth", G_TYPE_INT, depth,
> -             "endianness", G_TYPE_INT, endianness, NULL);
> --        if (caps && context) {
> --          gst_ffmpeg_set_palette (caps, context);
> --        }
> -       }
> -     } else if (fmt) {
> -       caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-yuv",
> -@@ -1857,7 +1812,7 @@
> -  */
> -
> - static GstCaps *
> --gst_ffmpeg_smpfmt_to_caps (enum SampleFormat sample_fmt,
> -+gst_ffmpeg_smpfmt_to_caps (enum AVSampleFormat sample_fmt,
> -     AVCodecContext * context, enum CodecID codec_id)
> - {
> -   GstCaps *caps = NULL;
> -@@ -1867,22 +1822,22 @@
> -   gboolean signedness = FALSE;
> -
> -   switch (sample_fmt) {
> --    case SAMPLE_FMT_S16:
> -+    case AV_SAMPLE_FMT_S16:
> -       signedness = TRUE;
> -       bpp = 16;
> -       break;
> -
> --    case SAMPLE_FMT_S32:
> -+    case AV_SAMPLE_FMT_S32:
> -       signedness = TRUE;
> -       bpp = 32;
> -       break;
> -
> --    case SAMPLE_FMT_FLT:
> -+    case AV_SAMPLE_FMT_FLT:
> -       integer = FALSE;
> -       bpp = 32;
> -       break;
> -
> --    case SAMPLE_FMT_DBL:
> -+    case AV_SAMPLE_FMT_DBL:
> -       integer = FALSE;
> -       bpp = 64;
> -       break;
> -@@ -1941,12 +1896,12 @@
> -     }
> -   } else {
> -     GstCaps *temp;
> --    enum SampleFormat i;
> -+    enum AVSampleFormat i;
> -     AVCodecContext ctx = { 0, };
> -
> -     ctx.channels = -1;
> -     caps = gst_caps_new_empty ();
> --    for (i = 0; i <= SAMPLE_FMT_DBL; i++) {
> -+    for (i = 0; i <= AV_SAMPLE_FMT_DBL; i++) {
> -       temp = gst_ffmpeg_smpfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
> -       if (temp != NULL) {
> -         gst_caps_append (caps, temp);
> -@@ -2049,9 +2004,9 @@
> -         gst_structure_get_int (structure, "endianness", &endianness)) {
> -       if (endianness == G_BYTE_ORDER) {
> -         if (width == 32)
> --          context->sample_fmt = SAMPLE_FMT_FLT;
> -+          context->sample_fmt = AV_SAMPLE_FMT_FLT;
> -         else if (width == 64)
> --          context->sample_fmt = SAMPLE_FMT_DBL;
> -+          context->sample_fmt = AV_SAMPLE_FMT_DBL;
> -       }
> -     }
> -   } else {
> -@@ -2062,9 +2017,9 @@
> -         gst_structure_get_int (structure, "endianness", &endianness)) {
> -       if ((endianness == G_BYTE_ORDER) && (signedness == TRUE)) {
> -         if ((width == 16) && (depth == 16))
> --          context->sample_fmt = SAMPLE_FMT_S16;
> -+          context->sample_fmt = AV_SAMPLE_FMT_S16;
> -         else if ((width == 32) && (depth == 32))
> --          context->sample_fmt = SAMPLE_FMT_S32;
> -+          context->sample_fmt = AV_SAMPLE_FMT_S32;
> -       }
> -     }
> -   }
> -@@ -2190,7 +2145,6 @@
> -       } else {
> -         if (bpp == 8) {
> -           context->pix_fmt = PIX_FMT_PAL8;
> --          gst_ffmpeg_get_palette (caps, context);
> -         }
> -       }
> -     }
> -@@ -2576,7 +2530,6 @@
> -   switch (codec_type) {
> -     case AVMEDIA_TYPE_VIDEO:
> -       gst_ffmpeg_caps_to_pixfmt (caps, context, codec_id == CODEC_ID_RAWVIDEO);
> --      gst_ffmpeg_get_palette (caps, context);
> -       break;
> -     case AVMEDIA_TYPE_AUDIO:
> -       gst_ffmpeg_caps_to_smpfmt (caps, context, FALSE);
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.orig
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.orig	1970-01-01 01:00:00.000000000 +0100
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.orig	2014-08-08 15:30:34.006867097 +0200
> -@@ -0,0 +1,3447 @@
> -+/* GStreamer
> -+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
> -+ * This file:
> -+ * Copyright (c) 2002-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 <gst/gst.h>
> -+#ifdef HAVE_FFMPEG_UNINSTALLED
> -+#include <avcodec.h>
> -+#include <channel_layout.h>>
> -+#else
> -+#include <libavcodec/avcodec.h>
> -+#include <libavutil/channel_layout.h>
> -+#endif
> -+#include <string.h>
> -+
> -+#include "gstffmpeg.h"
> -+#include "gstffmpegcodecmap.h"
> -+
> -+#include <gst/pbutils/codec-utils.h>
> -+
> -+/*
> -+ * Read a palette from a caps.
> -+ */
> -+
> -+static void
> -+gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
> -+{
> -+  GstStructure *str = gst_caps_get_structure (caps, 0);
> -+  const GValue *palette_v;
> -+  const GstBuffer *palette;
> -+
> -+  /* do we have a palette? */
> -+  if ((palette_v = gst_structure_get_value (str, "palette_data")) && context) {
> -+    palette = gst_value_get_buffer (palette_v);
> -+    if (GST_BUFFER_SIZE (palette) >= AVPALETTE_SIZE) {
> -+      if (context->palctrl)
> -+        av_free (context->palctrl);
> -+      context->palctrl = av_malloc (sizeof (AVPaletteControl));
> -+      context->palctrl->palette_changed = 1;
> -+      memcpy (context->palctrl->palette, GST_BUFFER_DATA (palette),
> -+          AVPALETTE_SIZE);
> -+    }
> -+  }
> -+}
> -+
> -+static void
> -+gst_ffmpeg_set_palette (GstCaps * caps, AVCodecContext * context)
> -+{
> -+  if (context->palctrl) {
> -+    GstBuffer *palette = gst_buffer_new_and_alloc (AVPALETTE_SIZE);
> -+
> -+    memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
> -+        AVPALETTE_SIZE);
> -+    gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, palette, NULL);
> -+  }
> -+}
> -+
> -+/* IMPORTANT: Keep this sorted by the ffmpeg channel masks */
> -+static const struct
> -+{
> -+  guint64 ff;
> -+  GstAudioChannelPosition gst;
> -+} _ff_to_gst_layout[] = {
> -+  {
> -+  AV_CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
> -+  AV_CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
> -+  AV_CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
> -+  AV_CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
> -+  AV_CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
> -+  AV_CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
> -+  AV_CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
> -+  AV_CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
> -+  AV_CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
> -+  AV_CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
> -+  AV_CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
> -+  AV_CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> -+  AV_CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> -+  AV_CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> -+  AV_CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> -+  AV_CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> -+  AV_CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> -+  AV_CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
> -+  AV_CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
> -+  AV_CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
> -+};
> -+
> -+static GstAudioChannelPosition *
> -+gst_ff_channel_layout_to_gst (guint64 channel_layout, guint channels)
> -+{
> -+  guint nchannels = 0, i, j;
> -+  GstAudioChannelPosition *pos = NULL;
> -+  gboolean none_layout = FALSE;
> -+
> -+  for (i = 0; i < 64; i++) {
> -+    if ((channel_layout & (G_GUINT64_CONSTANT (1) << i)) != 0) {
> -+      nchannels++;
> -+    }
> -+  }
> -+
> -+  if (channel_layout == 0) {
> -+    nchannels = channels;
> -+    none_layout = TRUE;
> -+  }
> -+
> -+  if (nchannels != channels) {
> -+    GST_ERROR ("Number of channels is different (%u != %u)", channels,
> -+        nchannels);
> -+    return NULL;
> -+  }
> -+
> -+  pos = g_new (GstAudioChannelPosition, nchannels);
> -+
> -+  for (i = 0, j = 0; i < G_N_ELEMENTS (_ff_to_gst_layout); i++) {
> -+    if ((channel_layout & _ff_to_gst_layout[i].ff) != 0) {
> -+      pos[j++] = _ff_to_gst_layout[i].gst;
> -+
> -+      if (_ff_to_gst_layout[i].gst == GST_AUDIO_CHANNEL_POSITION_NONE)
> -+        none_layout = TRUE;
> -+    }
> -+  }
> -+
> -+  if (j != nchannels) {
> -+    GST_WARNING ("Unknown channels in channel layout - assuming NONE layout");
> -+    none_layout = TRUE;
> -+  }
> -+
> -+  if (!none_layout && !gst_audio_check_channel_positions (pos, nchannels)) {
> -+    GST_ERROR ("Invalid channel layout %" G_GUINT64_FORMAT
> -+        " - assuming NONE layout", channel_layout);
> -+    none_layout = TRUE;
> -+  }
> -+
> -+  if (none_layout) {
> -+    if (nchannels == 1) {
> -+      pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_MONO;
> -+    } else if (nchannels == 2) {
> -+      pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
> -+      pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
> -+    } else if (channel_layout == 0) {
> -+      g_free (pos);
> -+      pos = NULL;
> -+    } else {
> -+      for (i = 0; i < nchannels; i++)
> -+        pos[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
> -+    }
> -+  }
> -+
> -+  if (nchannels == 1 && pos[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER) {
> -+    GST_DEBUG ("mono common case; won't set channel positions");
> -+    g_free (pos);
> -+    pos = NULL;
> -+  } else if (nchannels == 2 && pos[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT
> -+      && pos[1] == GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT) {
> -+    GST_DEBUG ("stereo common case; won't set channel positions");
> -+    g_free (pos);
> -+    pos = NULL;
> -+  }
> -+
> -+  return pos;
> -+}
> -+
> -+/* this macro makes a caps width fixed or unfixed width/height
> -+ * properties depending on whether we've got a context.
> -+ *
> -+ * See below for why we use this.
> -+ *
> -+ * We should actually do this stuff at the end, like in riff-media.c,
> -+ * but I'm too lazy today. Maybe later.
> -+ */
> -+static GstCaps *
> -+gst_ff_vid_caps_new (AVCodecContext * context, enum CodecID codec_id,
> -+    const char *mimetype, const char *fieldname, ...)
> -+{
> -+  GstStructure *structure = NULL;
> -+  GstCaps *caps = NULL;
> -+  va_list var_args;
> -+  gint i;
> -+
> -+  GST_LOG ("context:%p, codec_id:%d, mimetype:%s", context, codec_id, mimetype);
> -+
> -+  /* fixed, non probing context */
> -+  if (context != NULL && context->width != -1) {
> -+    gint num, denom;
> -+
> -+    caps = gst_caps_new_simple (mimetype,
> -+        "width", G_TYPE_INT, context->width,
> -+        "height", G_TYPE_INT, context->height, NULL);
> -+
> -+    num = context->time_base.den / context->ticks_per_frame;
> -+    denom = context->time_base.num;
> -+
> -+    if (!denom) {
> -+      GST_LOG ("invalid framerate: %d/0, -> %d/1", num, num);
> -+      denom = 1;
> -+    }
> -+    if (gst_util_fraction_compare (num, denom, 1000, 1) > 0) {
> -+      GST_LOG ("excessive framerate: %d/%d, -> 0/1", num, denom);
> -+      num = 0;
> -+      denom = 1;
> -+    }
> -+    GST_LOG ("setting framerate: %d/%d", num, denom);
> -+    gst_caps_set_simple (caps,
> -+        "framerate", GST_TYPE_FRACTION, num, denom, NULL);
> -+  } else {
> -+    /* so we are after restricted caps in this case */
> -+    switch (codec_id) {
> -+      case CODEC_ID_H261:
> -+      {
> -+        caps = gst_caps_new_simple (mimetype,
> -+            "width", G_TYPE_INT, 352,
> -+            "height", G_TYPE_INT, 288,
> -+            "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
> -+        gst_caps_append (caps, gst_caps_new_simple (mimetype,
> -+                "width", G_TYPE_INT, 176,
> -+                "height", G_TYPE_INT, 144,
> -+                "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL));
> -+        break;
> -+      }
> -+      case CODEC_ID_H263:
> -+      {
> -+        /* 128x96, 176x144, 352x288, 704x576, and 1408x1152. slightly reordered
> -+         * because we want automatic negotiation to go as close to 320x240 as
> -+         * possible. */
> -+        const static gint widths[] = { 352, 704, 176, 1408, 128 };
> -+        const static gint heights[] = { 288, 576, 144, 1152, 96 };
> -+        GstCaps *temp;
> -+        gint n_sizes = G_N_ELEMENTS (widths);
> -+
> -+        caps = gst_caps_new_empty ();
> -+        for (i = 0; i < n_sizes; i++) {
> -+          temp = gst_caps_new_simple (mimetype,
> -+              "width", G_TYPE_INT, widths[i],
> -+              "height", G_TYPE_INT, heights[i],
> -+              "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
> -+
> -+          gst_caps_append (caps, temp);
> -+        }
> -+        break;
> -+      }
> -+      case CODEC_ID_DVVIDEO:
> -+      {
> -+        static struct
> -+        {
> -+          guint32 csp;
> -+          gint width, height;
> -+          gint par_n, par_d;
> -+          gint framerate_n, framerate_d;
> -+        } profiles[] = {
> -+          {
> -+          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 480, 10, 11, 30000, 1001}, {
> -+          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 480, 40, 33, 30000, 1001}, {
> -+          GST_MAKE_FOURCC ('I', '4', '2', '0'), 720, 576, 59, 54, 25, 1}, {
> -+          GST_MAKE_FOURCC ('I', '4', '2', '0'), 720, 576, 118, 81, 25, 1}, {
> -+          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 576, 59, 54, 25, 1}, {
> -+          GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 576, 118, 81, 25, 1}
> -+        };
> -+        GstCaps *temp;
> -+        gint n_sizes = G_N_ELEMENTS (profiles);
> -+
> -+        caps = gst_caps_new_empty ();
> -+        for (i = 0; i < n_sizes; i++) {
> -+          temp = gst_caps_new_simple (mimetype,
> -+              "width", G_TYPE_INT, profiles[i].width,
> -+              "height", G_TYPE_INT, profiles[i].height,
> -+              "framerate", GST_TYPE_FRACTION, profiles[i].framerate_n,
> -+              profiles[i].framerate_d, "pixel-aspect-ratio", GST_TYPE_FRACTION,
> -+              profiles[i].par_n, profiles[i].par_d, NULL);
> -+
> -+          gst_caps_append (caps, temp);
> -+        }
> -+        break;
> -+      }
> -+      case CODEC_ID_DNXHD:
> -+      {
> -+        caps = gst_caps_new_simple (mimetype,
> -+            "width", G_TYPE_INT, 1920,
> -+            "height", G_TYPE_INT, 1080,
> -+            "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
> -+        gst_caps_append (caps, gst_caps_new_simple (mimetype,
> -+                "width", G_TYPE_INT, 1280,
> -+                "height", G_TYPE_INT, 720,
> -+                "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL));
> -+        break;
> -+      }
> -+      default:
> -+        break;
> -+    }
> -+  }
> -+
> -+  /* no fixed caps or special restrictions applied;
> -+   * default unfixed setting */
> -+  if (!caps) {
> -+    GST_DEBUG ("Creating default caps");
> -+    caps = gst_caps_new_simple (mimetype,
> -+        "width", GST_TYPE_INT_RANGE, 16, 4096,
> -+        "height", GST_TYPE_INT_RANGE, 16, 4096,
> -+        "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
> -+  }
> -+
> -+  for (i = 0; i < gst_caps_get_size (caps); i++) {
> -+    va_start (var_args, fieldname);
> -+    structure = gst_caps_get_structure (caps, i);
> -+    gst_structure_set_valist (structure, fieldname, var_args);
> -+    va_end (var_args);
> -+  }
> -+
> -+  return caps;
> -+}
> -+
> -+/* same for audio - now with channels/sample rate
> -+ */
> -+static GstCaps *
> -+gst_ff_aud_caps_new (AVCodecContext * context, enum CodecID codec_id,
> -+    const char *mimetype, const char *fieldname, ...)
> -+{
> -+  GstCaps *caps = NULL;
> -+  GstStructure *structure = NULL;
> -+  gint i;
> -+  va_list var_args;
> -+
> -+  /* fixed, non-probing context */
> -+  if (context != NULL && context->channels != -1) {
> -+    GstAudioChannelPosition *pos;
> -+    guint64 channel_layout = context->channel_layout;
> -+
> -+    if (channel_layout == 0) {
> -+      const guint64 default_channel_set[] = {
> -+        0, 0, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_5POINT0,
> -+        AV_CH_LAYOUT_5POINT1, 0, AV_CH_LAYOUT_7POINT1
> -+      };
> -+
> -+      switch (codec_id) {
> -+        case CODEC_ID_EAC3:
> -+        case CODEC_ID_AC3:
> -+        case CODEC_ID_DTS:
> -+          if (context->channels > 0
> -+              && context->channels < G_N_ELEMENTS (default_channel_set))
> -+            channel_layout = default_channel_set[context->channels - 1];
> -+          break;
> -+        default:
> -+          break;
> -+      }
> -+    }
> -+
> -+    caps = gst_caps_new_simple (mimetype,
> -+        "rate", G_TYPE_INT, context->sample_rate,
> -+        "channels", G_TYPE_INT, context->channels, NULL);
> -+
> -+    pos = gst_ff_channel_layout_to_gst (channel_layout, context->channels);
> -+    if (pos != NULL) {
> -+      gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
> -+      g_free (pos);
> -+    }
> -+  } else {
> -+    gint maxchannels = 2;
> -+    const gint *rates = NULL;
> -+    gint n_rates = 0;
> -+
> -+    /* so we must be after restricted caps in this case */
> -+    switch (codec_id) {
> -+      case CODEC_ID_AAC:
> -+      case CODEC_ID_AAC_LATM:
> -+      case CODEC_ID_DTS:
> -+        maxchannels = 6;
> -+        break;
> -+      case CODEC_ID_MP2:
> -+      {
> -+        const static gint l_rates[] =
> -+            { 48000, 44100, 32000, 24000, 22050, 16000 };
> -+        n_rates = G_N_ELEMENTS (l_rates);
> -+        rates = l_rates;
> -+        break;
> -+      }
> -+      case CODEC_ID_EAC3:
> -+      case CODEC_ID_AC3:
> -+      {
> -+        const static gint l_rates[] = { 48000, 44100, 32000 };
> -+        maxchannels = 6;
> -+        n_rates = G_N_ELEMENTS (l_rates);
> -+        rates = l_rates;
> -+        break;
> -+      }
> -+      case CODEC_ID_ADPCM_G722:
> -+      {
> -+        const static gint l_rates[] = { 16000 };
> -+        n_rates = G_N_ELEMENTS (l_rates);
> -+        rates = l_rates;
> -+        maxchannels = 1;
> -+        break;
> -+      }
> -+      case CODEC_ID_ADPCM_G726:
> -+      {
> -+        const static gint l_rates[] = { 8000 };
> -+        n_rates = G_N_ELEMENTS (l_rates);
> -+        rates = l_rates;
> -+        maxchannels = 1;
> -+        break;
> -+      }
> -+      case CODEC_ID_ADPCM_SWF:
> -+      {
> -+        const static gint l_rates[] = { 11025, 22050, 44100 };
> -+        n_rates = G_N_ELEMENTS (l_rates);
> -+        rates = l_rates;
> -+        break;
> -+      }
> -+      case CODEC_ID_ROQ_DPCM:
> -+      {
> -+        const static gint l_rates[] = { 22050 };
> -+        n_rates = G_N_ELEMENTS (l_rates);
> -+        rates = l_rates;
> -+        break;
> -+      }
> -+      case CODEC_ID_AMR_NB:
> -+      {
> -+        const static gint l_rates[] = { 8000 };
> -+        maxchannels = 1;
> -+        n_rates = G_N_ELEMENTS (l_rates);
> -+        rates = l_rates;
> -+        break;
> -+      }
> -+      case CODEC_ID_AMR_WB:
> -+      {
> -+        const static gint l_rates[] = { 16000 };
> -+        maxchannels = 1;
> -+        n_rates = G_N_ELEMENTS (l_rates);
> -+        rates = l_rates;
> -+        break;
> -+      }
> -+      default:
> -+        break;
> -+    }
> -+
> -+    /* TODO: handle context->channel_layouts here to set
> -+     * the list of channel layouts supported by the encoder.
> -+     * Unfortunately no encoder uses this yet....
> -+     */
> -+    /* regardless of encode/decode, open up channels if applicable */
> -+    /* Until decoders/encoders expose the maximum number of channels
> -+     * they support, we whitelist them here. */
> -+    switch (codec_id) {
> -+      case CODEC_ID_WMAPRO:
> -+      case CODEC_ID_TRUEHD:
> -+        maxchannels = 8;
> -+        break;
> -+      default:
> -+        break;
> -+    }
> -+
> -+    if (maxchannels == 1)
> -+      caps = gst_caps_new_simple (mimetype,
> -+          "channels", G_TYPE_INT, maxchannels, NULL);
> -+    else
> -+      caps = gst_caps_new_simple (mimetype,
> -+          "channels", GST_TYPE_INT_RANGE, 1, maxchannels, NULL);
> -+    if (n_rates) {
> -+      GValue list = { 0, };
> -+      GstStructure *structure;
> -+
> -+      g_value_init (&list, GST_TYPE_LIST);
> -+      for (i = 0; i < n_rates; i++) {
> -+        GValue v = { 0, };
> -+
> -+        g_value_init (&v, G_TYPE_INT);
> -+        g_value_set_int (&v, rates[i]);
> -+        gst_value_list_append_value (&list, &v);
> -+        g_value_unset (&v);
> -+      }
> -+      structure = gst_caps_get_structure (caps, 0);
> -+      gst_structure_set_value (structure, "rate", &list);
> -+      g_value_unset (&list);
> -+    } else
> -+      gst_caps_set_simple (caps, "rate", GST_TYPE_INT_RANGE, 4000, 96000, NULL);
> -+  }
> -+
> -+  for (i = 0; i < gst_caps_get_size (caps); i++) {
> -+    va_start (var_args, fieldname);
> -+    structure = gst_caps_get_structure (caps, i);
> -+    gst_structure_set_valist (structure, fieldname, var_args);
> -+    va_end (var_args);
> -+  }
> -+
> -+  return caps;
> -+}
> -+
> -+/* Convert a FFMPEG codec ID and optional AVCodecContext
> -+ * to a GstCaps. If the context is ommitted, no fixed values
> -+ * for video/audio size will be included in the GstCaps
> -+ *
> -+ * CodecID is primarily meant for compressed data GstCaps!
> -+ *
> -+ * encode is a special parameter. gstffmpegdec will say
> -+ * FALSE, gstffmpegenc will say TRUE. The output caps
> -+ * depends on this, in such a way that it will be very
> -+ * specific, defined, fixed and correct caps for encoders,
> -+ * yet very wide, "forgiving" caps for decoders. Example
> -+ * for mp3: decode: audio/mpeg,mpegversion=1,layer=[1-3]
> -+ * but encode: audio/mpeg,mpegversion=1,layer=3,bitrate=x,
> -+ * rate=x,channels=x.
> -+ */
> -+
> -+GstCaps *
> -+gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
> -+    AVCodecContext * context, gboolean encode)
> -+{
> -+  GstCaps *caps = NULL;
> -+  gboolean buildcaps = FALSE;
> -+
> -+  GST_LOG ("codec_id:%d, context:%p, encode:%d", codec_id, context, encode);
> -+
> -+  switch (codec_id) {
> -+    case CODEC_ID_MPEG1VIDEO:
> -+      /* FIXME: bitrate */
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
> -+          "mpegversion", G_TYPE_INT, 1,
> -+          "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_MPEG2VIDEO:
> -+      if (encode) {
> -+        /* FIXME: bitrate */
> -+        caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
> -+            "mpegversion", G_TYPE_INT, 2,
> -+            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
> -+      } else {
> -+        /* decode both MPEG-1 and MPEG-2; width/height/fps are all in
> -+         * the MPEG video stream headers, so may be omitted from caps. */
> -+        caps = gst_caps_new_simple ("video/mpeg",
> -+            "mpegversion", GST_TYPE_INT_RANGE, 1, 2,
> -+            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
> -+      }
> -+      break;
> -+
> -+    case CODEC_ID_MPEG2VIDEO_XVMC:
> -+      /* this is a special ID - don't need it in GStreamer, I think */
> -+      break;
> -+
> -+    case CODEC_ID_H263:
> -+      if (encode) {
> -+        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h263",
> -+            "variant", G_TYPE_STRING, "itu",
> -+            "h263version", G_TYPE_STRING, "h263", NULL);
> -+      } else {
> -+        /* don't pass codec_id, we can decode other variants with the H263
> -+         * decoder that don't have specific size requirements
> -+         */
> -+        caps = gst_ff_vid_caps_new (context, CODEC_ID_NONE, "video/x-h263",
> -+            "variant", G_TYPE_STRING, "itu", NULL);
> -+      }
> -+      break;
> -+
> -+    case CODEC_ID_H263P:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h263",
> -+          "variant", G_TYPE_STRING, "itu",
> -+          "h263version", G_TYPE_STRING, "h263p", NULL);
> -+      if (encode && context) {
> -+
> -+        gst_caps_set_simple (caps,
> -+            "annex-f", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_4MV,
> -+            "annex-j", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_LOOP_FILTER,
> -+            "annex-i", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_AC_PRED,
> -+            "annex-t", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_AC_PRED,
> -+            NULL);
> -+      }
> -+      break;
> -+
> -+    case CODEC_ID_H263I:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-intel-h263",
> -+          "variant", G_TYPE_STRING, "intel", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_H261:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h261", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_RV10:
> -+    case CODEC_ID_RV20:
> -+    case CODEC_ID_RV30:
> -+    case CODEC_ID_RV40:
> -+    {
> -+      gint version;
> -+
> -+      switch (codec_id) {
> -+        case CODEC_ID_RV40:
> -+          version = 4;
> -+          break;
> -+        case CODEC_ID_RV30:
> -+          version = 3;
> -+          break;
> -+        case CODEC_ID_RV20:
> -+          version = 2;
> -+          break;
> -+        default:
> -+          version = 1;
> -+          break;
> -+      }
> -+
> -+      /* FIXME: context->sub_id must be filled in during decoding */
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-pn-realvideo",
> -+          "systemstream", G_TYPE_BOOLEAN, FALSE,
> -+          "rmversion", G_TYPE_INT, version, NULL);
> -+      if (context) {
> -+        gst_caps_set_simple (caps, "format", G_TYPE_INT, context->sub_id, NULL);
> -+        if (context->extradata_size >= 8) {
> -+          gst_caps_set_simple (caps,
> -+              "subformat", G_TYPE_INT, GST_READ_UINT32_BE (context->extradata),
> -+              NULL);
> -+        }
> -+      }
> -+    }
> -+      break;
> -+
> -+    case CODEC_ID_MP1:
> -+      /* FIXME: bitrate */
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
> -+          "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 1, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_MP2:
> -+      /* FIXME: bitrate */
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
> -+          "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 2, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_MP3:
> -+      if (encode) {
> -+        /* FIXME: bitrate */
> -+        caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
> -+            "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
> -+      } else {
> -+        /* Decodes MPEG-1 layer 1/2/3. Samplerate, channels et al are
> -+         * in the MPEG audio header, so may be omitted from caps. */
> -+        caps = gst_caps_new_simple ("audio/mpeg",
> -+            "mpegversion", G_TYPE_INT, 1,
> -+            "layer", GST_TYPE_INT_RANGE, 1, 3, NULL);
> -+      }
> -+      break;
> -+
> -+    case CODEC_ID_MUSEPACK7:
> -+      caps =
> -+          gst_ff_aud_caps_new (context, codec_id,
> -+          "audio/x-ffmpeg-parsed-musepack", "streamversion", G_TYPE_INT, 7,
> -+          NULL);
> -+      break;
> -+
> -+    case CODEC_ID_MUSEPACK8:
> -+      caps =
> -+          gst_ff_aud_caps_new (context, codec_id,
> -+          "audio/x-ffmpeg-parsed-musepack", "streamversion", G_TYPE_INT, 8,
> -+          NULL);
> -+      break;
> -+
> -+    case CODEC_ID_AC3:
> -+      /* FIXME: bitrate */
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-ac3", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_EAC3:
> -+      /* FIXME: bitrate */
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-eac3", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_TRUEHD:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-true-hd", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_ATRAC1:
> -+      caps =
> -+          gst_ff_aud_caps_new (context, codec_id, "audio/x-vnd.sony.atrac1",
> -+          NULL);
> -+      break;
> -+
> -+    case CODEC_ID_ATRAC3:
> -+      caps =
> -+          gst_ff_aud_caps_new (context, codec_id, "audio/x-vnd.sony.atrac3",
> -+          NULL);
> -+      break;
> -+
> -+    case CODEC_ID_DTS:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dts", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_APE:
> -+      caps =
> -+          gst_ff_aud_caps_new (context, codec_id, "audio/x-ffmpeg-parsed-ape",
> -+          NULL);
> -+      if (context) {
> -+        gst_caps_set_simple (caps,
> -+            "depth", G_TYPE_INT, context->bits_per_coded_sample, NULL);
> -+      }
> -+      break;
> -+
> -+    case CODEC_ID_MLP:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mlp", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_IMC:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-imc", NULL);
> -+      break;
> -+
> -+      /* MJPEG is normal JPEG, Motion-JPEG and Quicktime MJPEG-A. MJPEGB
> -+       * is Quicktime's MJPEG-B. LJPEG is lossless JPEG. I don't know what
> -+       * sp5x is, but it's apparently something JPEG... We don't separate
> -+       * between those in GStreamer. Should we (at least between MJPEG,
> -+       * MJPEG-B and sp5x decoding...)? */
> -+    case CODEC_ID_MJPEG:
> -+    case CODEC_ID_LJPEG:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "image/jpeg", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_SP5X:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/sp5x", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_MJPEGB:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mjpeg-b", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_MPEG4:
> -+      if (encode && context != NULL) {
> -+        /* I'm not exactly sure what ffmpeg outputs... ffmpeg itself uses
> -+         * the AVI fourcc 'DIVX', but 'mp4v' for Quicktime... */
> -+        switch (context->codec_tag) {
> -+          case GST_MAKE_FOURCC ('D', 'I', 'V', 'X'):
> -+            caps = gst_ff_vid_caps_new (context, codec_id, "video/x-divx",
> -+                "divxversion", G_TYPE_INT, 5, NULL);
> -+            break;
> -+          case GST_MAKE_FOURCC ('m', 'p', '4', 'v'):
> -+          default:
> -+            /* FIXME: bitrate */
> -+            caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
> -+                "systemstream", G_TYPE_BOOLEAN, FALSE,
> -+                "mpegversion", G_TYPE_INT, 4, NULL);
> -+            break;
> -+        }
> -+      } else {
> -+        /* The trick here is to separate xvid, divx, mpeg4, 3ivx et al */
> -+        caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
> -+            "mpegversion", G_TYPE_INT, 4,
> -+            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
> -+        if (encode) {
> -+          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
> -+                  "video/x-divx", "divxversion", G_TYPE_INT, 5, NULL));
> -+        } else {
> -+          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
> -+                  "video/x-divx", "divxversion", GST_TYPE_INT_RANGE, 4, 5,
> -+                  NULL));
> -+          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
> -+                  "video/x-xvid", NULL));
> -+          gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
> -+                  "video/x-3ivx", NULL));
> -+        }
> -+      }
> -+      break;
> -+
> -+    case CODEC_ID_RAWVIDEO:
> -+      caps =
> -+          gst_ffmpeg_codectype_to_caps (AVMEDIA_TYPE_VIDEO, context, codec_id,
> -+          encode);
> -+      break;
> -+
> -+    case CODEC_ID_MSMPEG4V1:
> -+    case CODEC_ID_MSMPEG4V2:
> -+    case CODEC_ID_MSMPEG4V3:
> -+    {
> -+      gint version = 41 + codec_id - CODEC_ID_MSMPEG4V1;
> -+
> -+      /* encode-FIXME: bitrate */
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-msmpeg",
> -+          "msmpegversion", G_TYPE_INT, version, NULL);
> -+      if (!encode && codec_id == CODEC_ID_MSMPEG4V3) {
> -+        gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
> -+                "video/x-divx", "divxversion", G_TYPE_INT, 3, NULL));
> -+      }
> -+    }
> -+      break;
> -+
> -+    case CODEC_ID_WMV1:
> -+    case CODEC_ID_WMV2:
> -+    {
> -+      gint version = (codec_id == CODEC_ID_WMV1) ? 1 : 2;
> -+
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
> -+          "wmvversion", G_TYPE_INT, version, NULL);
> -+    }
> -+      break;
> -+
> -+    case CODEC_ID_FLV1:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-flash-video",
> -+          "flvversion", G_TYPE_INT, 1, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_SVQ1:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-svq",
> -+          "svqversion", G_TYPE_INT, 1, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_SVQ3:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-svq",
> -+          "svqversion", G_TYPE_INT, 3, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_DVAUDIO:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dv", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_DVVIDEO:
> -+    {
> -+      if (encode && context) {
> -+        guint32 fourcc;
> -+
> -+        switch (context->pix_fmt) {
> -+          case PIX_FMT_YUYV422:
> -+            fourcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
> -+            break;
> -+          case PIX_FMT_YUV420P:
> -+            fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
> -+            break;
> -+          case PIX_FMT_YUVA420P:
> -+            fourcc = GST_MAKE_FOURCC ('A', '4', '2', '0');
> -+            break;
> -+          case PIX_FMT_YUV411P:
> -+            fourcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
> -+            break;
> -+          case PIX_FMT_YUV422P:
> -+            fourcc = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
> -+            break;
> -+          case PIX_FMT_YUV410P:
> -+            fourcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
> -+            break;
> -+          default:
> -+            GST_WARNING
> -+                ("Couldnt' find fourcc for pixfmt %d, defaulting to I420",
> -+                context->pix_fmt);
> -+            fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
> -+            break;
> -+        }
> -+        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dv",
> -+            "systemstream", G_TYPE_BOOLEAN, FALSE,
> -+            "format", GST_TYPE_FOURCC, fourcc, NULL);
> -+      } else {
> -+        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dv",
> -+            "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
> -+      }
> -+    }
> -+      break;
> -+
> -+    case CODEC_ID_WMAV1:
> -+    case CODEC_ID_WMAV2:
> -+    {
> -+      gint version = (codec_id == CODEC_ID_WMAV1) ? 1 : 2;
> -+
> -+      if (context) {
> -+        caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
> -+            "wmaversion", G_TYPE_INT, version,
> -+            "block_align", G_TYPE_INT, context->block_align,
> -+            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> -+      } else {
> -+        caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
> -+            "wmaversion", G_TYPE_INT, version,
> -+            "block_align", GST_TYPE_INT_RANGE, 0, G_MAXINT,
> -+            "bitrate", GST_TYPE_INT_RANGE, 0, G_MAXINT, NULL);
> -+      }
> -+    }
> -+      break;
> -+    case CODEC_ID_WMAPRO:
> -+    {
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
> -+          "wmaversion", G_TYPE_INT, 3, NULL);
> -+      break;
> -+    }
> -+
> -+    case CODEC_ID_WMAVOICE:
> -+    {
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wms", NULL);
> -+      break;
> -+    }
> -+
> -+    case CODEC_ID_MACE3:
> -+    case CODEC_ID_MACE6:
> -+    {
> -+      gint version = (codec_id == CODEC_ID_MACE3) ? 3 : 6;
> -+
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mace",
> -+          "maceversion", G_TYPE_INT, version, NULL);
> -+    }
> -+      break;
> -+
> -+    case CODEC_ID_HUFFYUV:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-huffyuv", NULL);
> -+      if (context) {
> -+        gst_caps_set_simple (caps,
> -+            "bpp", G_TYPE_INT, context->bits_per_coded_sample, NULL);
> -+      }
> -+      break;
> -+
> -+    case CODEC_ID_CYUV:
> -+      caps =
> -+          gst_ff_vid_caps_new (context, codec_id, "video/x-compressed-yuv",
> -+          NULL);
> -+      break;
> -+
> -+    case CODEC_ID_H264:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h264", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_INDEO5:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
> -+          "indeoversion", G_TYPE_INT, 5, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_INDEO3:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
> -+          "indeoversion", G_TYPE_INT, 3, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_INDEO2:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
> -+          "indeoversion", G_TYPE_INT, 2, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_FLASHSV:
> -+      caps =
> -+          gst_ff_vid_caps_new (context, codec_id, "video/x-flash-screen", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_VP3:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp3", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_VP5:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp5", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_VP6:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_VP6F:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6-flash", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_VP6A:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6-alpha", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_VP8:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp8", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_THEORA:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-theora", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_AAC:
> -+    {
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg", NULL);
> -+
> -+      if (!encode) {
> -+        GValue arr = { 0, };
> -+        GValue item = { 0, };
> -+
> -+        g_value_init (&arr, GST_TYPE_LIST);
> -+        g_value_init (&item, G_TYPE_INT);
> -+        g_value_set_int (&item, 2);
> -+        gst_value_list_append_value (&arr, &item);
> -+        g_value_set_int (&item, 4);
> -+        gst_value_list_append_value (&arr, &item);
> -+        g_value_unset (&item);
> -+
> -+        gst_caps_set_value (caps, "mpegversion", &arr);
> -+        g_value_unset (&arr);
> -+
> -+        g_value_init (&arr, GST_TYPE_LIST);
> -+        g_value_init (&item, G_TYPE_STRING);
> -+        g_value_set_string (&item, "raw");
> -+        gst_value_list_append_value (&arr, &item);
> -+        g_value_set_string (&item, "adts");
> -+        gst_value_list_append_value (&arr, &item);
> -+        g_value_set_string (&item, "adif");
> -+        gst_value_list_append_value (&arr, &item);
> -+        g_value_unset (&item);
> -+
> -+        gst_caps_set_value (caps, "stream-format", &arr);
> -+        g_value_unset (&arr);
> -+      } else {
> -+        gst_caps_set_simple (caps, "mpegversion", G_TYPE_INT, 4,
> -+            "stream-format", G_TYPE_STRING, "raw",
> -+            "base-profile", G_TYPE_STRING, "lc", NULL);
> -+
> -+        if (context && context->extradata_size > 0)
> -+          gst_codec_utils_aac_caps_set_level_and_profile (caps,
> -+              context->extradata, context->extradata_size);
> -+      }
> -+
> -+      break;
> -+    }
> -+    case CODEC_ID_AAC_LATM:    /* LATM/LOAS AAC syntax */
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
> -+          "mpegversion", G_TYPE_INT, 4, "stream-format", G_TYPE_STRING, "loas",
> -+          NULL);
> -+      break;
> -+
> -+    case CODEC_ID_ASV1:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-asus",
> -+          "asusversion", G_TYPE_INT, 1, NULL);
> -+      break;
> -+    case CODEC_ID_ASV2:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-asus",
> -+          "asusversion", G_TYPE_INT, 2, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_FFV1:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ffv",
> -+          "ffvversion", G_TYPE_INT, 1, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_4XM:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-4xm", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_XAN_WC3:
> -+    case CODEC_ID_XAN_WC4:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-xan",
> -+          "wcversion", G_TYPE_INT, 3 - CODEC_ID_XAN_WC3 + codec_id, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_CLJR:
> -+      caps =
> -+          gst_ff_vid_caps_new (context, codec_id,
> -+          "video/x-cirrus-logic-accupak", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_FRAPS:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-fraps", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_MDEC:
> -+    case CODEC_ID_ROQ:
> -+    case CODEC_ID_INTERPLAY_VIDEO:
> -+      buildcaps = TRUE;
> -+      break;
> -+
> -+    case CODEC_ID_VCR1:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ati-vcr",
> -+          "vcrversion", G_TYPE_INT, 1, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_RPZA:
> -+      caps =
> -+          gst_ff_vid_caps_new (context, codec_id, "video/x-apple-video", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_CINEPAK:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-cinepak", NULL);
> -+      break;
> -+
> -+      /* WS_VQA belogns here (order) */
> -+
> -+    case CODEC_ID_MSRLE:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-rle",
> -+          "layout", G_TYPE_STRING, "microsoft", NULL);
> -+      if (context) {
> -+        gst_caps_set_simple (caps,
> -+            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
> -+      } else {
> -+        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 1, 64, NULL);
> -+      }
> -+      break;
> -+
> -+    case CODEC_ID_QTRLE:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-rle",
> -+          "layout", G_TYPE_STRING, "quicktime", NULL);
> -+      if (context) {
> -+        gst_caps_set_simple (caps,
> -+            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
> -+      } else {
> -+        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 1, 64, NULL);
> -+      }
> -+      break;
> -+
> -+    case CODEC_ID_MSVIDEO1:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-msvideocodec",
> -+          "msvideoversion", G_TYPE_INT, 1, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_WMV3:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
> -+          "wmvversion", G_TYPE_INT, 3, NULL);
> -+      break;
> -+    case CODEC_ID_VC1:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
> -+          "wmvversion", G_TYPE_INT, 3, "format", GST_TYPE_FOURCC,
> -+          GST_MAKE_FOURCC ('W', 'V', 'C', '1'), NULL);
> -+      break;
> -+    case CODEC_ID_QDM2:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-qdm2", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_MSZH:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mszh", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_ZLIB:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-zlib", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_TRUEMOTION1:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-truemotion",
> -+          "trueversion", G_TYPE_INT, 1, NULL);
> -+      break;
> -+    case CODEC_ID_TRUEMOTION2:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-truemotion",
> -+          "trueversion", G_TYPE_INT, 2, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_ULTI:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ultimotion",
> -+          NULL);
> -+      break;
> -+
> -+    case CODEC_ID_TSCC:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-camtasia", NULL);
> -+      if (context) {
> -+        gst_caps_set_simple (caps,
> -+            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
> -+      } else {
> -+        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 8, 32, NULL);
> -+      }
> -+      break;
> -+
> -+    case CODEC_ID_KMVC:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-kmvc", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_NUV:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-nuv", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_GIF:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "image/gif", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_PNG:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "image/png", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_PPM:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "image/ppm", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_PBM:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "image/pbm", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_PAM:
> -+      caps =
> -+          gst_ff_vid_caps_new (context, codec_id, "image/x-portable-anymap",
> -+          NULL);
> -+      break;
> -+
> -+    case CODEC_ID_PGM:
> -+      caps =
> -+          gst_ff_vid_caps_new (context, codec_id, "image/x-portable-graymap",
> -+          NULL);
> -+      break;
> -+
> -+    case CODEC_ID_PCX:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-pcx", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_SGI:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-sgi", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_TARGA:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "image/x-tga", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_TIFF:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "image/tiff", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_SUNRAST:
> -+      caps =
> -+          gst_ff_vid_caps_new (context, codec_id, "image/x-sun-raster", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_SMC:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-smc", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_QDRAW:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-qdrw", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_DNXHD:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dnxhd", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_MIMIC:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mimic", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_VMNC:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vmnc", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_TRUESPEECH:
> -+      caps =
> -+          gst_ff_aud_caps_new (context, codec_id, "audio/x-truespeech", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_QCELP:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/qcelp", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_AMV:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-amv", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_AASC:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-aasc", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_LOCO:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-loco", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_ZMBV:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-zmbv", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_LAGARITH:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-lagarith", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_CSCD:
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-camstudio", NULL);
> -+      if (context) {
> -+        gst_caps_set_simple (caps,
> -+            "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
> -+      } else {
> -+        gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 8, 32, NULL);
> -+      }
> -+      break;
> -+
> -+    case CODEC_ID_WS_VQA:
> -+    case CODEC_ID_IDCIN:
> -+    case CODEC_ID_8BPS:
> -+    case CODEC_ID_FLIC:
> -+    case CODEC_ID_VMDVIDEO:
> -+    case CODEC_ID_VMDAUDIO:
> -+    case CODEC_ID_SNOW:
> -+    case CODEC_ID_VIXL:
> -+    case CODEC_ID_QPEG:
> -+    case CODEC_ID_PGMYUV:
> -+    case CODEC_ID_FFVHUFF:
> -+    case CODEC_ID_WNV1:
> -+    case CODEC_ID_MP3ADU:
> -+    case CODEC_ID_MP3ON4:
> -+    case CODEC_ID_WESTWOOD_SND1:
> -+    case CODEC_ID_MMVIDEO:
> -+    case CODEC_ID_AVS:
> -+    case CODEC_ID_CAVS:
> -+      buildcaps = TRUE;
> -+      break;
> -+
> -+      /* weird quasi-codecs for the demuxers only */
> -+    case CODEC_ID_PCM_S16LE:
> -+    case CODEC_ID_PCM_S16BE:
> -+    case CODEC_ID_PCM_U16LE:
> -+    case CODEC_ID_PCM_U16BE:
> -+    case CODEC_ID_PCM_S8:
> -+    case CODEC_ID_PCM_U8:
> -+    {
> -+      gint width = 0, depth = 0, endianness = 0;
> -+      gboolean signedness = FALSE;      /* blabla */
> -+
> -+      switch (codec_id) {
> -+        case CODEC_ID_PCM_S16LE:
> -+          width = 16;
> -+          depth = 16;
> -+          endianness = G_LITTLE_ENDIAN;
> -+          signedness = TRUE;
> -+          break;
> -+        case CODEC_ID_PCM_S16BE:
> -+          width = 16;
> -+          depth = 16;
> -+          endianness = G_BIG_ENDIAN;
> -+          signedness = TRUE;
> -+          break;
> -+        case CODEC_ID_PCM_U16LE:
> -+          width = 16;
> -+          depth = 16;
> -+          endianness = G_LITTLE_ENDIAN;
> -+          signedness = FALSE;
> -+          break;
> -+        case CODEC_ID_PCM_U16BE:
> -+          width = 16;
> -+          depth = 16;
> -+          endianness = G_BIG_ENDIAN;
> -+          signedness = FALSE;
> -+          break;
> -+        case CODEC_ID_PCM_S8:
> -+          width = 8;
> -+          depth = 8;
> -+          endianness = G_BYTE_ORDER;
> -+          signedness = TRUE;
> -+          break;
> -+        case CODEC_ID_PCM_U8:
> -+          width = 8;
> -+          depth = 8;
> -+          endianness = G_BYTE_ORDER;
> -+          signedness = FALSE;
> -+          break;
> -+        default:
> -+          g_assert (0);         /* don't worry, we never get here */
> -+          break;
> -+      }
> -+
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-int",
> -+          "width", G_TYPE_INT, width,
> -+          "depth", G_TYPE_INT, depth,
> -+          "endianness", G_TYPE_INT, endianness,
> -+          "signed", G_TYPE_BOOLEAN, signedness, NULL);
> -+    }
> -+      break;
> -+
> -+    case CODEC_ID_PCM_MULAW:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mulaw", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_PCM_ALAW:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-alaw", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_ADPCM_G722:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/G722", NULL);
> -+      if (context)
> -+        gst_caps_set_simple (caps,
> -+            "block_align", G_TYPE_INT, context->block_align,
> -+            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> -+      break;
> -+
> -+    case CODEC_ID_ADPCM_G726:
> -+    {
> -+      /* the G726 decoder can also handle G721 */
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-adpcm",
> -+          "layout", G_TYPE_STRING, "g726", NULL);
> -+      if (context)
> -+        gst_caps_set_simple (caps,
> -+            "block_align", G_TYPE_INT, context->block_align,
> -+            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> -+
> -+      if (!encode) {
> -+        gst_caps_append (caps, gst_caps_new_simple ("audio/x-adpcm",
> -+                "layout", G_TYPE_STRING, "g721",
> -+                "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL));
> -+      }
> -+      break;
> -+    }
> -+    case CODEC_ID_ADPCM_IMA_QT:
> -+    case CODEC_ID_ADPCM_IMA_WAV:
> -+    case CODEC_ID_ADPCM_IMA_DK3:
> -+    case CODEC_ID_ADPCM_IMA_DK4:
> -+    case CODEC_ID_ADPCM_IMA_WS:
> -+    case CODEC_ID_ADPCM_IMA_SMJPEG:
> -+    case CODEC_ID_ADPCM_IMA_AMV:
> -+    case CODEC_ID_ADPCM_IMA_ISS:
> -+    case CODEC_ID_ADPCM_IMA_EA_EACS:
> -+    case CODEC_ID_ADPCM_IMA_EA_SEAD:
> -+    case CODEC_ID_ADPCM_MS:
> -+    case CODEC_ID_ADPCM_4XM:
> -+    case CODEC_ID_ADPCM_XA:
> -+    case CODEC_ID_ADPCM_ADX:
> -+    case CODEC_ID_ADPCM_EA:
> -+    case CODEC_ID_ADPCM_CT:
> -+    case CODEC_ID_ADPCM_SWF:
> -+    case CODEC_ID_ADPCM_YAMAHA:
> -+    case CODEC_ID_ADPCM_SBPRO_2:
> -+    case CODEC_ID_ADPCM_SBPRO_3:
> -+    case CODEC_ID_ADPCM_SBPRO_4:
> -+    case CODEC_ID_ADPCM_EA_R1:
> -+    case CODEC_ID_ADPCM_EA_R2:
> -+    case CODEC_ID_ADPCM_EA_R3:
> -+    case CODEC_ID_ADPCM_EA_MAXIS_XA:
> -+    case CODEC_ID_ADPCM_EA_XAS:
> -+    case CODEC_ID_ADPCM_THP:
> -+    {
> -+      const gchar *layout = NULL;
> -+
> -+      switch (codec_id) {
> -+        case CODEC_ID_ADPCM_IMA_QT:
> -+          layout = "quicktime";
> -+          break;
> -+        case CODEC_ID_ADPCM_IMA_WAV:
> -+          layout = "dvi";
> -+          break;
> -+        case CODEC_ID_ADPCM_IMA_DK3:
> -+          layout = "dk3";
> -+          break;
> -+        case CODEC_ID_ADPCM_IMA_DK4:
> -+          layout = "dk4";
> -+          break;
> -+        case CODEC_ID_ADPCM_IMA_WS:
> -+          layout = "westwood";
> -+          break;
> -+        case CODEC_ID_ADPCM_IMA_SMJPEG:
> -+          layout = "smjpeg";
> -+          break;
> -+        case CODEC_ID_ADPCM_IMA_AMV:
> -+          layout = "amv";
> -+          break;
> -+        case CODEC_ID_ADPCM_IMA_ISS:
> -+          layout = "iss";
> -+          break;
> -+        case CODEC_ID_ADPCM_IMA_EA_EACS:
> -+          layout = "ea-eacs";
> -+          break;
> -+        case CODEC_ID_ADPCM_IMA_EA_SEAD:
> -+          layout = "ea-sead";
> -+          break;
> -+        case CODEC_ID_ADPCM_MS:
> -+          layout = "microsoft";
> -+          break;
> -+        case CODEC_ID_ADPCM_4XM:
> -+          layout = "4xm";
> -+          break;
> -+        case CODEC_ID_ADPCM_XA:
> -+          layout = "xa";
> -+          break;
> -+        case CODEC_ID_ADPCM_ADX:
> -+          layout = "adx";
> -+          break;
> -+        case CODEC_ID_ADPCM_EA:
> -+          layout = "ea";
> -+          break;
> -+        case CODEC_ID_ADPCM_CT:
> -+          layout = "ct";
> -+          break;
> -+        case CODEC_ID_ADPCM_SWF:
> -+          layout = "swf";
> -+          break;
> -+        case CODEC_ID_ADPCM_YAMAHA:
> -+          layout = "yamaha";
> -+          break;
> -+        case CODEC_ID_ADPCM_SBPRO_2:
> -+          layout = "sbpro2";
> -+          break;
> -+        case CODEC_ID_ADPCM_SBPRO_3:
> -+          layout = "sbpro3";
> -+          break;
> -+        case CODEC_ID_ADPCM_SBPRO_4:
> -+          layout = "sbpro4";
> -+          break;
> -+        case CODEC_ID_ADPCM_EA_R1:
> -+          layout = "ea-r1";
> -+          break;
> -+        case CODEC_ID_ADPCM_EA_R2:
> -+          layout = "ea-r3";
> -+          break;
> -+        case CODEC_ID_ADPCM_EA_R3:
> -+          layout = "ea-r3";
> -+          break;
> -+        case CODEC_ID_ADPCM_EA_MAXIS_XA:
> -+          layout = "ea-maxis-xa";
> -+          break;
> -+        case CODEC_ID_ADPCM_EA_XAS:
> -+          layout = "ea-xas";
> -+          break;
> -+        case CODEC_ID_ADPCM_THP:
> -+          layout = "thp";
> -+          break;
> -+        default:
> -+          g_assert (0);         /* don't worry, we never get here */
> -+          break;
> -+      }
> -+
> -+      /* FIXME: someone please check whether we need additional properties
> -+       * in this caps definition. */
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-adpcm",
> -+          "layout", G_TYPE_STRING, layout, NULL);
> -+      if (context)
> -+        gst_caps_set_simple (caps,
> -+            "block_align", G_TYPE_INT, context->block_align,
> -+            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> -+    }
> -+      break;
> -+
> -+    case CODEC_ID_AMR_NB:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/AMR", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_AMR_WB:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/AMR-WB", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_GSM:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-gsm", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_GSM_MS:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/ms-gsm", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_NELLYMOSER:
> -+      caps =
> -+          gst_ff_aud_caps_new (context, codec_id, "audio/x-nellymoser", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_SIPR:
> -+    {
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-sipro", NULL);
> -+      if (context) {
> -+        gst_caps_set_simple (caps,
> -+            "leaf_size", G_TYPE_INT, context->block_align,
> -+            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> -+      }
> -+    }
> -+      break;
> -+
> -+    case CODEC_ID_RA_144:
> -+    case CODEC_ID_RA_288:
> -+    case CODEC_ID_COOK:
> -+    {
> -+      gint version = 0;
> -+
> -+      switch (codec_id) {
> -+        case CODEC_ID_RA_144:
> -+          version = 1;
> -+          break;
> -+        case CODEC_ID_RA_288:
> -+          version = 2;
> -+          break;
> -+        case CODEC_ID_COOK:
> -+          version = 8;
> -+          break;
> -+        default:
> -+          break;
> -+      }
> -+
> -+      /* FIXME: properties? */
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-pn-realaudio",
> -+          "raversion", G_TYPE_INT, version, NULL);
> -+      if (context) {
> -+        gst_caps_set_simple (caps,
> -+            "leaf_size", G_TYPE_INT, context->block_align,
> -+            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> -+      }
> -+    }
> -+      break;
> -+
> -+    case CODEC_ID_ROQ_DPCM:
> -+    case CODEC_ID_INTERPLAY_DPCM:
> -+    case CODEC_ID_XAN_DPCM:
> -+    case CODEC_ID_SOL_DPCM:
> -+    {
> -+      const gchar *layout = NULL;
> -+
> -+      switch (codec_id) {
> -+        case CODEC_ID_ROQ_DPCM:
> -+          layout = "roq";
> -+          break;
> -+        case CODEC_ID_INTERPLAY_DPCM:
> -+          layout = "interplay";
> -+          break;
> -+        case CODEC_ID_XAN_DPCM:
> -+          layout = "xan";
> -+          break;
> -+        case CODEC_ID_SOL_DPCM:
> -+          layout = "sol";
> -+          break;
> -+        default:
> -+          g_assert (0);         /* don't worry, we never get here */
> -+          break;
> -+      }
> -+
> -+      /* FIXME: someone please check whether we need additional properties
> -+       * in this caps definition. */
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dpcm",
> -+          "layout", G_TYPE_STRING, layout, NULL);
> -+      if (context)
> -+        gst_caps_set_simple (caps,
> -+            "block_align", G_TYPE_INT, context->block_align,
> -+            "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> -+    }
> -+      break;
> -+
> -+    case CODEC_ID_SHORTEN:
> -+      caps = gst_caps_new_simple ("audio/x-shorten", NULL);
> -+      break;
> -+
> -+    case CODEC_ID_ALAC:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-alac", NULL);
> -+      if (context) {
> -+        gst_caps_set_simple (caps,
> -+            "samplesize", G_TYPE_INT, context->bits_per_coded_sample, NULL);
> -+      }
> -+      break;
> -+
> -+    case CODEC_ID_FLAC:
> -+      /* Note that ffmpeg has no encoder yet, but just for safety. In the
> -+       * encoder case, we want to add things like samplerate, channels... */
> -+      if (!encode) {
> -+        caps = gst_caps_new_simple ("audio/x-flac", NULL);
> -+      }
> -+      break;
> -+
> -+    case CODEC_ID_DVD_SUBTITLE:
> -+    case CODEC_ID_DVB_SUBTITLE:
> -+      caps = NULL;
> -+      break;
> -+    case CODEC_ID_BMP:
> -+      caps = gst_caps_new_simple ("image/bmp", NULL);
> -+      break;
> -+    case CODEC_ID_TTA:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-tta", NULL);
> -+      if (context) {
> -+        gst_caps_set_simple (caps,
> -+            "samplesize", G_TYPE_INT, context->bits_per_coded_sample, NULL);
> -+      }
> -+      break;
> -+    case CODEC_ID_TWINVQ:
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-twin-vq", NULL);
> -+      break;
> -+    default:
> -+      GST_DEBUG ("Unknown codec ID %d, please add mapping here", codec_id);
> -+      break;
> -+  }
> -+
> -+  if (buildcaps) {
> -+    AVCodec *codec;
> -+
> -+    if ((codec = avcodec_find_decoder (codec_id)) ||
> -+        (codec = avcodec_find_encoder (codec_id))) {
> -+      gchar *mime = NULL;
> -+
> -+      GST_LOG ("Could not create stream format caps for %s", codec->name);
> -+
> -+      switch (codec->type) {
> -+        case AVMEDIA_TYPE_VIDEO:
> -+          mime = g_strdup_printf ("video/x-gst_ff-%s", codec->name);
> -+          caps = gst_ff_vid_caps_new (context, codec_id, mime, NULL);
> -+          g_free (mime);
> -+          break;
> -+        case AVMEDIA_TYPE_AUDIO:
> -+          mime = g_strdup_printf ("audio/x-gst_ff-%s", codec->name);
> -+          caps = gst_ff_aud_caps_new (context, codec_id, mime, NULL);
> -+          if (context)
> -+            gst_caps_set_simple (caps,
> -+                "block_align", G_TYPE_INT, context->block_align,
> -+                "bitrate", G_TYPE_INT, context->bit_rate, NULL);
> -+          g_free (mime);
> -+          break;
> -+        default:
> -+          break;
> -+      }
> -+    }
> -+  }
> -+
> -+  if (caps != NULL) {
> -+
> -+    /* set private data */
> -+    if (context && context->extradata_size > 0) {
> -+      GstBuffer *data = gst_buffer_new_and_alloc (context->extradata_size);
> -+
> -+      memcpy (GST_BUFFER_DATA (data), context->extradata,
> -+          context->extradata_size);
> -+      gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, data, NULL);
> -+      gst_buffer_unref (data);
> -+    }
> -+
> -+    /* palette */
> -+    if (context) {
> -+      gst_ffmpeg_set_palette (caps, context);
> -+    }
> -+
> -+    GST_LOG ("caps for codec_id=%d: %" GST_PTR_FORMAT, codec_id, caps);
> -+
> -+  } else {
> -+    GST_LOG ("No caps found for codec_id=%d", codec_id);
> -+  }
> -+
> -+  return caps;
> -+}
> -+
> -+/* Convert a FFMPEG Pixel Format and optional AVCodecContext
> -+ * to a GstCaps. If the context is ommitted, no fixed values
> -+ * for video/audio size will be included in the GstCaps
> -+ *
> -+ * See below for usefullness
> -+ */
> -+
> -+GstCaps *
> -+gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context,
> -+    enum CodecID codec_id)
> -+{
> -+  GstCaps *caps = NULL;
> -+
> -+  int bpp = 0, depth = 0, endianness = 0;
> -+  gulong g_mask = 0, r_mask = 0, b_mask = 0, a_mask = 0;
> -+  guint32 fmt = 0;
> -+
> -+  switch (pix_fmt) {
> -+    case PIX_FMT_YUVJ420P:
> -+    case PIX_FMT_YUV420P:
> -+      fmt = GST_MAKE_FOURCC ('I', '4', '2', '0');
> -+      break;
> -+    case PIX_FMT_YUVA420P:
> -+      fmt = GST_MAKE_FOURCC ('A', '4', '2', '0');
> -+      break;
> -+    case PIX_FMT_YUYV422:
> -+      fmt = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
> -+      break;
> -+    case PIX_FMT_RGB24:
> -+      bpp = depth = 24;
> -+      endianness = G_BIG_ENDIAN;
> -+      r_mask = 0xff0000;
> -+      g_mask = 0x00ff00;
> -+      b_mask = 0x0000ff;
> -+      break;
> -+    case PIX_FMT_BGR24:
> -+      bpp = depth = 24;
> -+      endianness = G_BIG_ENDIAN;
> -+      r_mask = 0x0000ff;
> -+      g_mask = 0x00ff00;
> -+      b_mask = 0xff0000;
> -+      break;
> -+    case PIX_FMT_YUVJ422P:
> -+    case PIX_FMT_YUV422P:
> -+      fmt = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
> -+      break;
> -+    case PIX_FMT_YUVJ444P:
> -+    case PIX_FMT_YUV444P:
> -+      fmt = GST_MAKE_FOURCC ('Y', '4', '4', '4');
> -+      break;
> -+    case PIX_FMT_RGB32:
> -+      bpp = 32;
> -+      depth = 32;
> -+      endianness = G_BIG_ENDIAN;
> -+#if (G_BYTE_ORDER == G_BIG_ENDIAN)
> -+      r_mask = 0x00ff0000;
> -+      g_mask = 0x0000ff00;
> -+      b_mask = 0x000000ff;
> -+      a_mask = 0xff000000;
> -+#else
> -+      r_mask = 0x0000ff00;
> -+      g_mask = 0x00ff0000;
> -+      b_mask = 0xff000000;
> -+      a_mask = 0x000000ff;
> -+#endif
> -+      break;
> -+    case PIX_FMT_YUV410P:
> -+      fmt = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
> -+      break;
> -+    case PIX_FMT_YUV411P:
> -+      fmt = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
> -+      break;
> -+    case PIX_FMT_RGB565:
> -+      bpp = depth = 16;
> -+      endianness = G_BYTE_ORDER;
> -+      r_mask = 0xf800;
> -+      g_mask = 0x07e0;
> -+      b_mask = 0x001f;
> -+      break;
> -+    case PIX_FMT_RGB555:
> -+      bpp = 16;
> -+      depth = 15;
> -+      endianness = G_BYTE_ORDER;
> -+      r_mask = 0x7c00;
> -+      g_mask = 0x03e0;
> -+      b_mask = 0x001f;
> -+      break;
> -+    case PIX_FMT_PAL8:
> -+      bpp = depth = 8;
> -+      endianness = G_BYTE_ORDER;
> -+      break;
> -+    case PIX_FMT_GRAY8:
> -+      bpp = depth = 8;
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-gray",
> -+          "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, NULL);
> -+      break;
> -+    default:
> -+      /* give up ... */
> -+      break;
> -+  }
> -+
> -+  if (caps == NULL) {
> -+    if (bpp != 0) {
> -+      if (r_mask != 0) {
> -+        if (a_mask) {
> -+          caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
> -+              "bpp", G_TYPE_INT, bpp,
> -+              "depth", G_TYPE_INT, depth,
> -+              "red_mask", G_TYPE_INT, r_mask,
> -+              "green_mask", G_TYPE_INT, g_mask,
> -+              "blue_mask", G_TYPE_INT, b_mask,
> -+              "alpha_mask", G_TYPE_INT, a_mask,
> -+              "endianness", G_TYPE_INT, endianness, NULL);
> -+        } else {
> -+          caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
> -+              "bpp", G_TYPE_INT, bpp,
> -+              "depth", G_TYPE_INT, depth,
> -+              "red_mask", G_TYPE_INT, r_mask,
> -+              "green_mask", G_TYPE_INT, g_mask,
> -+              "blue_mask", G_TYPE_INT, b_mask,
> -+              "endianness", G_TYPE_INT, endianness, NULL);
> -+        }
> -+      } else {
> -+        caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
> -+            "bpp", G_TYPE_INT, bpp,
> -+            "depth", G_TYPE_INT, depth,
> -+            "endianness", G_TYPE_INT, endianness, NULL);
> -+        if (caps && context) {
> -+          gst_ffmpeg_set_palette (caps, context);
> -+        }
> -+      }
> -+    } else if (fmt) {
> -+      caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-yuv",
> -+          "format", GST_TYPE_FOURCC, fmt, NULL);
> -+    }
> -+  }
> -+
> -+  if (caps != NULL) {
> -+    GST_DEBUG ("caps for pix_fmt=%d: %" GST_PTR_FORMAT, pix_fmt, caps);
> -+  } else {
> -+    GST_LOG ("No caps found for pix_fmt=%d", pix_fmt);
> -+  }
> -+
> -+  return caps;
> -+}
> -+
> -+/* Convert a FFMPEG Sample Format and optional AVCodecContext
> -+ * to a GstCaps. If the context is ommitted, no fixed values
> -+ * for video/audio size will be included in the GstCaps
> -+ *
> -+ * See below for usefullness
> -+ */
> -+
> -+static GstCaps *
> -+gst_ffmpeg_smpfmt_to_caps (enum AVSampleFormat sample_fmt,
> -+    AVCodecContext * context, enum CodecID codec_id)
> -+{
> -+  GstCaps *caps = NULL;
> -+
> -+  int bpp = 0;
> -+  gboolean integer = TRUE;
> -+  gboolean signedness = FALSE;
> -+
> -+  switch (sample_fmt) {
> -+    case AV_SAMPLE_FMT_S16:
> -+      signedness = TRUE;
> -+      bpp = 16;
> -+      break;
> -+
> -+    case AV_SAMPLE_FMT_S32:
> -+      signedness = TRUE;
> -+      bpp = 32;
> -+      break;
> -+
> -+    case AV_SAMPLE_FMT_FLT:
> -+      integer = FALSE;
> -+      bpp = 32;
> -+      break;
> -+
> -+    case AV_SAMPLE_FMT_DBL:
> -+      integer = FALSE;
> -+      bpp = 64;
> -+      break;
> -+    default:
> -+      /* .. */
> -+      break;
> -+  }
> -+
> -+  if (bpp) {
> -+    if (integer) {
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-int",
> -+          "signed", G_TYPE_BOOLEAN, signedness,
> -+          "endianness", G_TYPE_INT, G_BYTE_ORDER,
> -+          "width", G_TYPE_INT, bpp, "depth", G_TYPE_INT, bpp, NULL);
> -+    } else {
> -+      caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-float",
> -+          "endianness", G_TYPE_INT, G_BYTE_ORDER,
> -+          "width", G_TYPE_INT, bpp, NULL);
> -+    }
> -+  }
> -+
> -+  if (caps != NULL) {
> -+    GST_LOG ("caps for sample_fmt=%d: %" GST_PTR_FORMAT, sample_fmt, caps);
> -+  } else {
> -+    GST_LOG ("No caps found for sample_fmt=%d", sample_fmt);
> -+  }
> -+
> -+  return caps;
> -+}
> -+
> -+GstCaps *
> -+gst_ffmpeg_codectype_to_audio_caps (AVCodecContext * context,
> -+    enum CodecID codec_id, gboolean encode, AVCodec * codec)
> -+{
> -+  GstCaps *caps = NULL;
> -+
> -+  GST_DEBUG ("context:%p, codec_id:%d, encode:%d, codec:%p",
> -+      context, codec_id, encode, codec);
> -+  if (codec)
> -+    GST_DEBUG ("sample_fmts:%p, samplerates:%p",
> -+        codec->sample_fmts, codec->supported_samplerates);
> -+
> -+  if (context) {
> -+    /* Specific codec context */
> -+    caps = gst_ffmpeg_smpfmt_to_caps (context->sample_fmt, context, codec_id);
> -+  } else if (codec && codec->sample_fmts) {
> -+    GstCaps *temp;
> -+    int i;
> -+
> -+    caps = gst_caps_new_empty ();
> -+    for (i = 0; codec->sample_fmts[i] != -1; i++) {
> -+      temp =
> -+          gst_ffmpeg_smpfmt_to_caps (codec->sample_fmts[i], context, codec_id);
> -+      if (temp != NULL)
> -+        gst_caps_append (caps, temp);
> -+    }
> -+  } else {
> -+    GstCaps *temp;
> -+    enum AVSampleFormat i;
> -+    AVCodecContext ctx = { 0, };
> -+
> -+    ctx.channels = -1;
> -+    caps = gst_caps_new_empty ();
> -+    for (i = 0; i <= AV_SAMPLE_FMT_DBL; i++) {
> -+      temp = gst_ffmpeg_smpfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
> -+      if (temp != NULL) {
> -+        gst_caps_append (caps, temp);
> -+      }
> -+    }
> -+  }
> -+  return caps;
> -+}
> -+
> -+GstCaps *
> -+gst_ffmpeg_codectype_to_video_caps (AVCodecContext * context,
> -+    enum CodecID codec_id, gboolean encode, AVCodec * codec)
> -+{
> -+  GstCaps *caps;
> -+
> -+  GST_LOG ("context:%p, codec_id:%d, encode:%d, codec:%p",
> -+      context, codec_id, encode, codec);
> -+
> -+  if (context) {
> -+    caps = gst_ffmpeg_pixfmt_to_caps (context->pix_fmt, context, codec_id);
> -+  } else {
> -+    GstCaps *temp;
> -+    enum PixelFormat i;
> -+    AVCodecContext ctx = { 0, };
> -+
> -+    caps = gst_caps_new_empty ();
> -+    for (i = 0; i < PIX_FMT_NB; i++) {
> -+      ctx.width = -1;
> -+      ctx.pix_fmt = i;
> -+      temp = gst_ffmpeg_pixfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
> -+      if (temp != NULL) {
> -+        gst_caps_append (caps, temp);
> -+      }
> -+    }
> -+  }
> -+  return caps;
> -+}
> -+
> -+/* Convert a FFMPEG codec Type and optional AVCodecContext
> -+ * to a GstCaps. If the context is ommitted, no fixed values
> -+ * for video/audio size will be included in the GstCaps
> -+ *
> -+ * AVMediaType is primarily meant for uncompressed data GstCaps!
> -+ */
> -+
> -+GstCaps *
> -+gst_ffmpeg_codectype_to_caps (enum AVMediaType codec_type,
> -+    AVCodecContext * context, enum CodecID codec_id, gboolean encode)
> -+{
> -+  GstCaps *caps;
> -+
> -+  switch (codec_type) {
> -+    case AVMEDIA_TYPE_VIDEO:
> -+      caps =
> -+          gst_ffmpeg_codectype_to_video_caps (context, codec_id, encode, NULL);
> -+      break;
> -+    case AVMEDIA_TYPE_AUDIO:
> -+      caps =
> -+          gst_ffmpeg_codectype_to_audio_caps (context, codec_id, encode, NULL);
> -+      break;
> -+    default:
> -+      caps = NULL;
> -+      break;
> -+  }
> -+
> -+  return caps;
> -+}
> -+
> -+/* Convert a GstCaps (audio/raw) to a FFMPEG SampleFmt
> -+ * and other audio properties in a AVCodecContext.
> -+ *
> -+ * For usefullness, see below
> -+ */
> -+
> -+static void
> -+gst_ffmpeg_caps_to_smpfmt (const GstCaps * caps,
> -+    AVCodecContext * context, gboolean raw)
> -+{
> -+  GstStructure *structure;
> -+  gint depth = 0, width = 0, endianness = 0;
> -+  gboolean signedness = FALSE;
> -+  const gchar *name;
> -+
> -+  g_return_if_fail (gst_caps_get_size (caps) == 1);
> -+  structure = gst_caps_get_structure (caps, 0);
> -+
> -+  gst_structure_get_int (structure, "channels", &context->channels);
> -+  gst_structure_get_int (structure, "rate", &context->sample_rate);
> -+  gst_structure_get_int (structure, "block_align", &context->block_align);
> -+  gst_structure_get_int (structure, "bitrate", &context->bit_rate);
> -+
> -+  if (!raw)
> -+    return;
> -+
> -+  name = gst_structure_get_name (structure);
> -+
> -+  if (!strcmp (name, "audio/x-raw-float")) {
> -+    /* FLOAT */
> -+    if (gst_structure_get_int (structure, "width", &width) &&
> -+        gst_structure_get_int (structure, "endianness", &endianness)) {
> -+      if (endianness == G_BYTE_ORDER) {
> -+        if (width == 32)
> -+          context->sample_fmt = AV_SAMPLE_FMT_FLT;
> -+        else if (width == 64)
> -+          context->sample_fmt = AV_SAMPLE_FMT_DBL;
> -+      }
> -+    }
> -+  } else {
> -+    /* INT */
> -+    if (gst_structure_get_int (structure, "width", &width) &&
> -+        gst_structure_get_int (structure, "depth", &depth) &&
> -+        gst_structure_get_boolean (structure, "signed", &signedness) &&
> -+        gst_structure_get_int (structure, "endianness", &endianness)) {
> -+      if ((endianness == G_BYTE_ORDER) && (signedness == TRUE)) {
> -+        if ((width == 16) && (depth == 16))
> -+          context->sample_fmt = AV_SAMPLE_FMT_S16;
> -+        else if ((width == 32) && (depth == 32))
> -+          context->sample_fmt = AV_SAMPLE_FMT_S32;
> -+      }
> -+    }
> -+  }
> -+}
> -+
> -+
> -+/* Convert a GstCaps (video/raw) to a FFMPEG PixFmt
> -+ * and other video properties in a AVCodecContext.
> -+ *
> -+ * For usefullness, see below
> -+ */
> -+
> -+static void
> -+gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
> -+    AVCodecContext * context, gboolean raw)
> -+{
> -+  GstStructure *structure;
> -+  const GValue *fps;
> -+  const GValue *par = NULL;
> -+
> -+  GST_DEBUG ("converting caps %" GST_PTR_FORMAT, caps);
> -+  g_return_if_fail (gst_caps_get_size (caps) == 1);
> -+  structure = gst_caps_get_structure (caps, 0);
> -+
> -+  gst_structure_get_int (structure, "width", &context->width);
> -+  gst_structure_get_int (structure, "height", &context->height);
> -+  gst_structure_get_int (structure, "bpp", &context->bits_per_coded_sample);
> -+
> -+  fps = gst_structure_get_value (structure, "framerate");
> -+  if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
> -+
> -+    /* somehow these seem mixed up.. */
> -+    context->time_base.den = gst_value_get_fraction_numerator (fps);
> -+    context->time_base.num = gst_value_get_fraction_denominator (fps);
> -+    context->ticks_per_frame = 1;
> -+
> -+    GST_DEBUG ("setting framerate %d/%d = %lf",
> -+        context->time_base.den, context->time_base.num,
> -+        1. * context->time_base.den / context->time_base.num);
> -+  }
> -+
> -+  par = gst_structure_get_value (structure, "pixel-aspect-ratio");
> -+  if (par && GST_VALUE_HOLDS_FRACTION (par)) {
> -+
> -+    context->sample_aspect_ratio.num = gst_value_get_fraction_numerator (par);
> -+    context->sample_aspect_ratio.den = gst_value_get_fraction_denominator (par);
> -+
> -+    GST_DEBUG ("setting pixel-aspect-ratio %d/%d = %lf",
> -+        context->sample_aspect_ratio.den, context->sample_aspect_ratio.num,
> -+        1. * context->sample_aspect_ratio.den /
> -+        context->sample_aspect_ratio.num);
> -+  }
> -+
> -+  if (!raw)
> -+    return;
> -+
> -+  g_return_if_fail (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps));
> -+
> -+  if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
> -+    guint32 fourcc;
> -+
> -+    if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
> -+      switch (fourcc) {
> -+        case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
> -+          context->pix_fmt = PIX_FMT_YUYV422;
> -+          break;
> -+        case GST_MAKE_FOURCC ('I', '4', '2', '0'):
> -+          context->pix_fmt = PIX_FMT_YUV420P;
> -+          break;
> -+        case GST_MAKE_FOURCC ('A', '4', '2', '0'):
> -+          context->pix_fmt = PIX_FMT_YUVA420P;
> -+          break;
> -+        case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
> -+          context->pix_fmt = PIX_FMT_YUV411P;
> -+          break;
> -+        case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
> -+          context->pix_fmt = PIX_FMT_YUV422P;
> -+          break;
> -+        case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
> -+          context->pix_fmt = PIX_FMT_YUV410P;
> -+          break;
> -+#if 0
> -+        case FIXME:
> -+          context->pix_fmt = PIX_FMT_YUV444P;
> -+          break;
> -+#endif
> -+      }
> -+    }
> -+  } else if (strcmp (gst_structure_get_name (structure),
> -+          "video/x-raw-rgb") == 0) {
> -+    gint bpp = 0, rmask = 0, endianness = 0;
> -+
> -+    if (gst_structure_get_int (structure, "bpp", &bpp) &&
> -+        gst_structure_get_int (structure, "endianness", &endianness)) {
> -+      if (gst_structure_get_int (structure, "red_mask", &rmask)) {
> -+        switch (bpp) {
> -+          case 32:
> -+#if (G_BYTE_ORDER == G_BIG_ENDIAN)
> -+            if (rmask == 0x00ff0000)
> -+#else
> -+            if (rmask == 0x0000ff00)
> -+#endif
> -+              context->pix_fmt = PIX_FMT_RGB32;
> -+            break;
> -+          case 24:
> -+            if (rmask == 0x0000FF)
> -+              context->pix_fmt = PIX_FMT_BGR24;
> -+            else
> -+              context->pix_fmt = PIX_FMT_RGB24;
> -+            break;
> -+          case 16:
> -+            if (endianness == G_BYTE_ORDER)
> -+              context->pix_fmt = PIX_FMT_RGB565;
> -+            break;
> -+          case 15:
> -+            if (endianness == G_BYTE_ORDER)
> -+              context->pix_fmt = PIX_FMT_RGB555;
> -+            break;
> -+          default:
> -+            /* nothing */
> -+            break;
> -+        }
> -+      } else {
> -+        if (bpp == 8) {
> -+          context->pix_fmt = PIX_FMT_PAL8;
> -+          gst_ffmpeg_get_palette (caps, context);
> -+        }
> -+      }
> -+    }
> -+  } else if (strcmp (gst_structure_get_name (structure),
> -+          "video/x-raw-gray") == 0) {
> -+    gint bpp = 0;
> -+
> -+    if (gst_structure_get_int (structure, "bpp", &bpp)) {
> -+      switch (bpp) {
> -+        case 8:
> -+          context->pix_fmt = PIX_FMT_GRAY8;
> -+          break;
> -+      }
> -+    }
> -+  }
> -+}
> -+
> -+/* Convert a GstCaps and a FFMPEG codec Type to a
> -+ * AVCodecContext. If the context is ommitted, no fixed values
> -+ * for video/audio size will be included in the context
> -+ *
> -+ * AVMediaType is primarily meant for uncompressed data GstCaps!
> -+ */
> -+
> -+void
> -+gst_ffmpeg_caps_with_codectype (enum AVMediaType type,
> -+    const GstCaps * caps, AVCodecContext * context)
> -+{
> -+  if (context == NULL)
> -+    return;
> -+
> -+  switch (type) {
> -+    case AVMEDIA_TYPE_VIDEO:
> -+      gst_ffmpeg_caps_to_pixfmt (caps, context, TRUE);
> -+      break;
> -+
> -+    case AVMEDIA_TYPE_AUDIO:
> -+      gst_ffmpeg_caps_to_smpfmt (caps, context, TRUE);
> -+      break;
> -+
> -+    default:
> -+      /* unknown */
> -+      break;
> -+  }
> -+}
> -+
> -+#if 0
> -+static void
> -+nal_escape (guint8 * dst, guint8 * src, guint size, guint * destsize)
> -+{
> -+  guint8 *dstp = dst;
> -+  guint8 *srcp = src;
> -+  guint8 *end = src + size;
> -+  gint count = 0;
> -+
> -+  while (srcp < end) {
> -+    if (count == 2 && *srcp <= 0x03) {
> -+      GST_DEBUG ("added escape code");
> -+      *dstp++ = 0x03;
> -+      count = 0;
> -+    }
> -+    if (*srcp == 0)
> -+      count++;
> -+    else
> -+      count = 0;
> -+
> -+    GST_DEBUG ("copy %02x, count %d", *srcp, count);
> -+    *dstp++ = *srcp++;
> -+  }
> -+  *destsize = dstp - dst;
> -+}
> -+
> -+/* copy the config, escaping NAL units as we iterate them, if something fails we
> -+ * copy everything and hope for the best. */
> -+static void
> -+copy_config (guint8 * dst, guint8 * src, guint size, guint * destsize)
> -+{
> -+  guint8 *dstp = dst;
> -+  guint8 *srcp = src;
> -+  gint cnt, i;
> -+  guint nalsize, esize;
> -+
> -+  /* check size */
> -+  if (size < 7)
> -+    goto full_copy;
> -+
> -+  /* check version */
> -+  if (*srcp != 1)
> -+    goto full_copy;
> -+
> -+  cnt = *(srcp + 5) & 0x1f;     /* Number of sps */
> -+
> -+  GST_DEBUG ("num SPS %d", cnt);
> -+
> -+  memcpy (dstp, srcp, 6);
> -+  srcp += 6;
> -+  dstp += 6;
> -+
> -+  for (i = 0; i < cnt; i++) {
> -+    GST_DEBUG ("copy SPS %d", i);
> -+    nalsize = (srcp[0] << 8) | srcp[1];
> -+    nal_escape (dstp + 2, srcp + 2, nalsize, &esize);
> -+    dstp[0] = esize >> 8;
> -+    dstp[1] = esize & 0xff;
> -+    dstp += esize + 2;
> -+    srcp += nalsize + 2;
> -+  }
> -+
> -+  cnt = *(dstp++) = *(srcp++);  /* Number of pps */
> -+
> -+  GST_DEBUG ("num PPS %d", cnt);
> -+
> -+  for (i = 0; i < cnt; i++) {
> -+    GST_DEBUG ("copy PPS %d", i);
> -+    nalsize = (srcp[0] << 8) | srcp[1];
> -+    nal_escape (dstp + 2, srcp + 2, nalsize, &esize);
> -+    dstp[0] = esize >> 8;
> -+    dstp[1] = esize & 0xff;
> -+    dstp += esize + 2;
> -+    srcp += nalsize + 2;
> -+  }
> -+  *destsize = dstp - dst;
> -+
> -+  return;
> -+
> -+full_copy:
> -+  {
> -+    GST_DEBUG ("something unexpected, doing full copy");
> -+    memcpy (dst, src, size);
> -+    *destsize = size;
> -+    return;
> -+  }
> -+}
> -+#endif
> -+
> -+/*
> -+ * caps_with_codecid () transforms a GstCaps for a known codec
> -+ * ID into a filled-in context.
> -+ * codec_data from caps will override possible extradata already in the context
> -+ */
> -+
> -+void
> -+gst_ffmpeg_caps_with_codecid (enum CodecID codec_id,
> -+    enum AVMediaType codec_type, const GstCaps * caps, AVCodecContext * context)
> -+{
> -+  GstStructure *str;
> -+  const GValue *value;
> -+  const GstBuffer *buf;
> -+
> -+  GST_LOG ("codec_id:%d, codec_type:%d, caps:%" GST_PTR_FORMAT " context:%p",
> -+      codec_id, codec_type, caps, context);
> -+
> -+  if (!context || !gst_caps_get_size (caps))
> -+    return;
> -+
> -+  str = gst_caps_get_structure (caps, 0);
> -+
> -+  /* extradata parsing (esds [mpeg4], wma/wmv, msmpeg4v1/2/3, etc.) */
> -+  if ((value = gst_structure_get_value (str, "codec_data"))) {
> -+    guint size;
> -+    guint8 *data;
> -+
> -+    buf = GST_BUFFER_CAST (gst_value_get_mini_object (value));
> -+    size = GST_BUFFER_SIZE (buf);
> -+    data = GST_BUFFER_DATA (buf);
> -+
> -+    /* free the old one if it is there */
> -+    if (context->extradata)
> -+      av_free (context->extradata);
> -+
> -+#if 0
> -+    if (codec_id == CODEC_ID_H264) {
> -+      guint extrasize;
> -+
> -+      GST_DEBUG ("copy, escaping codec_data %d", size);
> -+      /* ffmpeg h264 expects the codec_data to be escaped, there is no real
> -+       * reason for this but let's just escape it for now. Start by allocating
> -+       * enough space, x2 is more than enough.
> -+       *
> -+       * FIXME, we disabled escaping because some file already contain escaped
> -+       * codec_data and then we escape twice and fail. It's better to leave it
> -+       * as is, as that is what most players do. */
> -+      context->extradata =
> -+          av_mallocz (GST_ROUND_UP_16 (size * 2 +
> -+              FF_INPUT_BUFFER_PADDING_SIZE));
> -+      copy_config (context->extradata, data, size, &extrasize);
> -+      GST_DEBUG ("escaped size: %d", extrasize);
> -+      context->extradata_size = extrasize;
> -+    } else
> -+#endif
> -+    {
> -+      /* allocate with enough padding */
> -+      GST_DEBUG ("copy codec_data");
> -+      context->extradata =
> -+          av_mallocz (GST_ROUND_UP_16 (size + FF_INPUT_BUFFER_PADDING_SIZE));
> -+      memcpy (context->extradata, data, size);
> -+      context->extradata_size = size;
> -+    }
> -+
> -+    /* Hack for VC1. Sometimes the first (length) byte is 0 for some files */
> -+    if (codec_id == CODEC_ID_VC1 && size > 0 && data[0] == 0) {
> -+      context->extradata[0] = (guint8) size;
> -+    }
> -+
> -+    GST_DEBUG ("have codec data of size %d", size);
> -+  } else if (context->extradata == NULL && codec_id != CODEC_ID_AAC_LATM &&
> -+      codec_id != CODEC_ID_FLAC) {
> -+    /* no extradata, alloc dummy with 0 sized, some codecs insist on reading
> -+     * extradata anyway which makes then segfault. */
> -+    context->extradata =
> -+        av_mallocz (GST_ROUND_UP_16 (FF_INPUT_BUFFER_PADDING_SIZE));
> -+    context->extradata_size = 0;
> -+    GST_DEBUG ("no codec data");
> -+  }
> -+
> -+  switch (codec_id) {
> -+    case CODEC_ID_MPEG4:
> -+    {
> -+      const gchar *mime = gst_structure_get_name (str);
> -+
> -+      if (!strcmp (mime, "video/x-divx"))
> -+        context->codec_tag = GST_MAKE_FOURCC ('D', 'I', 'V', 'X');
> -+      else if (!strcmp (mime, "video/x-xvid"))
> -+        context->codec_tag = GST_MAKE_FOURCC ('X', 'V', 'I', 'D');
> -+      else if (!strcmp (mime, "video/x-3ivx"))
> -+        context->codec_tag = GST_MAKE_FOURCC ('3', 'I', 'V', '1');
> -+      else if (!strcmp (mime, "video/mpeg"))
> -+        context->codec_tag = GST_MAKE_FOURCC ('m', 'p', '4', 'v');
> -+    }
> -+      break;
> -+
> -+    case CODEC_ID_SVQ3:
> -+      /* FIXME: this is a workaround for older gst-plugins releases
> -+       * (<= 0.8.9). This should be removed at some point, because
> -+       * it causes wrong decoded frame order. */
> -+      if (!context->extradata) {
> -+        gint halfpel_flag, thirdpel_flag, low_delay, unknown_svq3_flag;
> -+        guint16 flags;
> -+
> -+        if (gst_structure_get_int (str, "halfpel_flag", &halfpel_flag) ||
> -+            gst_structure_get_int (str, "thirdpel_flag", &thirdpel_flag) ||
> -+            gst_structure_get_int (str, "low_delay", &low_delay) ||
> -+            gst_structure_get_int (str, "unknown_svq3_flag",
> -+                &unknown_svq3_flag)) {
> -+          context->extradata = (guint8 *) av_mallocz (0x64);
> -+          g_stpcpy ((gchar *) context->extradata, "SVQ3");
> -+          flags = 1 << 3;
> -+          flags |= low_delay;
> -+          flags = flags << 2;
> -+          flags |= unknown_svq3_flag;
> -+          flags = flags << 6;
> -+          flags |= halfpel_flag;
> -+          flags = flags << 1;
> -+          flags |= thirdpel_flag;
> -+          flags = flags << 3;
> -+
> -+          flags = GUINT16_FROM_LE (flags);
> -+
> -+          memcpy ((gchar *) context->extradata + 0x62, &flags, 2);
> -+          context->extradata_size = 0x64;
> -+        }
> -+      }
> -+      break;
> -+
> -+    case CODEC_ID_MSRLE:
> -+    case CODEC_ID_QTRLE:
> -+    case CODEC_ID_TSCC:
> -+    case CODEC_ID_CSCD:
> -+    case CODEC_ID_APE:
> -+    {
> -+      gint depth;
> -+
> -+      if (gst_structure_get_int (str, "depth", &depth)) {
> -+        context->bits_per_coded_sample = depth;
> -+      } else {
> -+        GST_WARNING ("No depth field in caps %" GST_PTR_FORMAT, caps);
> -+      }
> -+
> -+    }
> -+      break;
> -+
> -+    case CODEC_ID_RV10:
> -+    case CODEC_ID_RV20:
> -+    case CODEC_ID_RV30:
> -+    case CODEC_ID_RV40:
> -+    {
> -+      gint format;
> -+
> -+      if (gst_structure_get_int (str, "format", &format))
> -+        context->sub_id = format;
> -+
> -+      break;
> -+    }
> -+    case CODEC_ID_COOK:
> -+    case CODEC_ID_RA_288:
> -+    case CODEC_ID_RA_144:
> -+    case CODEC_ID_SIPR:
> -+    {
> -+      gint leaf_size;
> -+      gint bitrate;
> -+
> -+      if (gst_structure_get_int (str, "leaf_size", &leaf_size))
> -+        context->block_align = leaf_size;
> -+      if (gst_structure_get_int (str, "bitrate", &bitrate))
> -+        context->bit_rate = bitrate;
> -+    }
> -+    case CODEC_ID_ALAC:
> -+      gst_structure_get_int (str, "samplesize",
> -+          &context->bits_per_coded_sample);
> -+      break;
> -+
> -+    case CODEC_ID_DVVIDEO:
> -+    {
> -+      guint32 fourcc;
> -+
> -+      if (gst_structure_get_fourcc (str, "format", &fourcc))
> -+        switch (fourcc) {
> -+          case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
> -+            context->pix_fmt = PIX_FMT_YUYV422;
> -+            break;
> -+          case GST_MAKE_FOURCC ('I', '4', '2', '0'):
> -+            context->pix_fmt = PIX_FMT_YUV420P;
> -+            break;
> -+          case GST_MAKE_FOURCC ('A', '4', '2', '0'):
> -+            context->pix_fmt = PIX_FMT_YUVA420P;
> -+            break;
> -+          case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
> -+            context->pix_fmt = PIX_FMT_YUV411P;
> -+            break;
> -+          case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
> -+            context->pix_fmt = PIX_FMT_YUV422P;
> -+            break;
> -+          case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
> -+            context->pix_fmt = PIX_FMT_YUV410P;
> -+            break;
> -+          default:
> -+            GST_WARNING ("couldn't convert fourcc %" GST_FOURCC_FORMAT
> -+                " to a pixel format", GST_FOURCC_ARGS (fourcc));
> -+            break;
> -+        }
> -+      break;
> -+    }
> -+    case CODEC_ID_H263P:
> -+    {
> -+      gboolean val;
> -+
> -+      if (!gst_structure_get_boolean (str, "annex-f", &val) || val)
> -+        context->flags |= CODEC_FLAG_4MV;
> -+      else
> -+        context->flags &= ~CODEC_FLAG_4MV;
> -+      if ((!gst_structure_get_boolean (str, "annex-i", &val) || val) &&
> -+          (!gst_structure_get_boolean (str, "annex-t", &val) || val))
> -+        context->flags |= CODEC_FLAG_AC_PRED;
> -+      else
> -+        context->flags &= ~CODEC_FLAG_AC_PRED;
> -+      if (!gst_structure_get_boolean (str, "annex-j", &val) || val)
> -+        context->flags |= CODEC_FLAG_LOOP_FILTER;
> -+      else
> -+        context->flags &= ~CODEC_FLAG_LOOP_FILTER;
> -+      break;
> -+    }
> -+    case CODEC_ID_ADPCM_G726:
> -+    {
> -+      const gchar *layout;
> -+
> -+      if ((layout = gst_structure_get_string (str, "layout"))) {
> -+        if (!strcmp (layout, "g721")) {
> -+          context->sample_rate = 8000;
> -+          context->channels = 1;
> -+          context->bit_rate = 32000;
> -+        }
> -+      }
> -+      break;
> -+    }
> -+    default:
> -+      break;
> -+  }
> -+
> -+  if (!gst_caps_is_fixed (caps))
> -+    return;
> -+
> -+  /* common properties (width, height, fps) */
> -+  switch (codec_type) {
> -+    case AVMEDIA_TYPE_VIDEO:
> -+      gst_ffmpeg_caps_to_pixfmt (caps, context, codec_id == CODEC_ID_RAWVIDEO);
> -+      gst_ffmpeg_get_palette (caps, context);
> -+      break;
> -+    case AVMEDIA_TYPE_AUDIO:
> -+      gst_ffmpeg_caps_to_smpfmt (caps, context, FALSE);
> -+      break;
> -+    default:
> -+      break;
> -+  }
> -+
> -+  /* fixup of default settings */
> -+  switch (codec_id) {
> -+    case CODEC_ID_QCELP:
> -+      /* QCELP is always mono, no matter what the caps say */
> -+      context->channels = 1;
> -+      break;
> -+    default:
> -+      break;
> -+  }
> -+}
> -+
> -+/* _formatid_to_caps () is meant for muxers/demuxers, it
> -+ * transforms a name (ffmpeg way of ID'ing these, why don't
> -+ * they have unique numerical IDs?) to the corresponding
> -+ * caps belonging to that mux-format
> -+ *
> -+ * Note: we don't need any additional info because the caps
> -+ * isn't supposed to contain any useful info besides the
> -+ * media type anyway
> -+ */
> -+
> -+GstCaps *
> -+gst_ffmpeg_formatid_to_caps (const gchar * format_name)
> -+{
> -+  GstCaps *caps = NULL;
> -+
> -+  if (!strcmp (format_name, "mpeg")) {
> -+    caps = gst_caps_new_simple ("video/mpeg",
> -+        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
> -+  } else if (!strcmp (format_name, "mpegts")) {
> -+    caps = gst_caps_new_simple ("video/mpegts",
> -+        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
> -+  } else if (!strcmp (format_name, "rm")) {
> -+    caps = gst_caps_new_simple ("application/x-pn-realmedia",
> -+        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
> -+  } else if (!strcmp (format_name, "asf")) {
> -+    caps = gst_caps_new_simple ("video/x-ms-asf", NULL);
> -+  } else if (!strcmp (format_name, "avi")) {
> -+    caps = gst_caps_new_simple ("video/x-msvideo", NULL);
> -+  } else if (!strcmp (format_name, "wav")) {
> -+    caps = gst_caps_new_simple ("audio/x-wav", NULL);
> -+  } else if (!strcmp (format_name, "ape")) {
> -+    caps = gst_caps_new_simple ("application/x-ape", NULL);
> -+  } else if (!strcmp (format_name, "swf")) {
> -+    caps = gst_caps_new_simple ("application/x-shockwave-flash", NULL);
> -+  } else if (!strcmp (format_name, "au")) {
> -+    caps = gst_caps_new_simple ("audio/x-au", NULL);
> -+  } else if (!strcmp (format_name, "dv")) {
> -+    caps = gst_caps_new_simple ("video/x-dv",
> -+        "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
> -+  } else if (!strcmp (format_name, "4xm")) {
> -+    caps = gst_caps_new_simple ("video/x-4xm", NULL);
> -+  } else if (!strcmp (format_name, "matroska")) {
> -+    caps = gst_caps_new_simple ("video/x-matroska", NULL);
> -+  } else if (!strcmp (format_name, "mp3")) {
> -+    caps = gst_caps_new_simple ("application/x-id3", NULL);
> -+  } else if (!strcmp (format_name, "flic")) {
> -+    caps = gst_caps_new_simple ("video/x-fli", NULL);
> -+  } else if (!strcmp (format_name, "flv")) {
> -+    caps = gst_caps_new_simple ("video/x-flv", NULL);
> -+  } else if (!strcmp (format_name, "tta")) {
> -+    caps = gst_caps_new_simple ("audio/x-ttafile", NULL);
> -+  } else if (!strcmp (format_name, "aiff")) {
> -+    caps = gst_caps_new_simple ("audio/x-aiff", NULL);
> -+  } else if (!strcmp (format_name, "mov_mp4_m4a_3gp_3g2")) {
> -+    caps =
> -+        gst_caps_from_string
> -+        ("application/x-3gp; video/quicktime; audio/x-m4a");
> -+  } else if (!strcmp (format_name, "mov")) {
> -+    caps = gst_caps_from_string ("video/quicktime,variant=(string)apple");
> -+  } else if (!strcmp (format_name, "mp4")) {
> -+    caps = gst_caps_from_string ("video/quicktime,variant=(string)iso");
> -+  } else if (!strcmp (format_name, "3gp")) {
> -+    caps = gst_caps_from_string ("video/quicktime,variant=(string)3gpp");
> -+  } else if (!strcmp (format_name, "3g2")) {
> -+    caps = gst_caps_from_string ("video/quicktime,variant=(string)3g2");
> -+  } else if (!strcmp (format_name, "psp")) {
> -+    caps = gst_caps_from_string ("video/quicktime,variant=(string)psp");
> -+  } else if (!strcmp (format_name, "ipod")) {
> -+    caps = gst_caps_from_string ("video/quicktime,variant=(string)ipod");
> -+  } else if (!strcmp (format_name, "aac")) {
> -+    caps = gst_caps_new_simple ("audio/mpeg",
> -+        "mpegversion", G_TYPE_INT, 4, NULL);
> -+  } else if (!strcmp (format_name, "gif")) {
> -+    caps = gst_caps_from_string ("image/gif");
> -+  } else if (!strcmp (format_name, "ogg")) {
> -+    caps = gst_caps_from_string ("application/ogg");
> -+  } else if (!strcmp (format_name, "mxf") || !strcmp (format_name, "mxf_d10")) {
> -+    caps = gst_caps_from_string ("application/mxf");
> -+  } else if (!strcmp (format_name, "gxf")) {
> -+    caps = gst_caps_from_string ("application/gxf");
> -+  } else if (!strcmp (format_name, "yuv4mpegpipe")) {
> -+    caps = gst_caps_new_simple ("application/x-yuv4mpeg",
> -+        "y4mversion", G_TYPE_INT, 2, NULL);
> -+  } else if (!strcmp (format_name, "mpc")) {
> -+    caps = gst_caps_from_string ("audio/x-musepack, streamversion = (int) 7");
> -+  } else if (!strcmp (format_name, "vqf")) {
> -+    caps = gst_caps_from_string ("audio/x-vqf");
> -+  } else if (!strcmp (format_name, "nsv")) {
> -+    caps = gst_caps_from_string ("video/x-nsv");
> -+  } else if (!strcmp (format_name, "amr")) {
> -+    caps = gst_caps_from_string ("audio/x-amr-nb-sh");
> -+  } else if (!strcmp (format_name, "webm")) {
> -+    caps = gst_caps_from_string ("video/webm");
> -+  } else {
> -+    gchar *name;
> -+
> -+    GST_LOG ("Could not create stream format caps for %s", format_name);
> -+    name = g_strdup_printf ("application/x-gst_ff-%s", format_name);
> -+    caps = gst_caps_new_simple (name, NULL);
> -+    g_free (name);
> -+  }
> -+
> -+  return caps;
> -+}
> -+
> -+gboolean
> -+gst_ffmpeg_formatid_get_codecids (const gchar * format_name,
> -+    enum CodecID ** video_codec_list, enum CodecID ** audio_codec_list,
> -+    AVOutputFormat * plugin)
> -+{
> -+  static enum CodecID tmp_vlist[] = {
> -+    CODEC_ID_NONE,
> -+    CODEC_ID_NONE
> -+  };
> -+  static enum CodecID tmp_alist[] = {
> -+    CODEC_ID_NONE,
> -+    CODEC_ID_NONE
> -+  };
> -+
> -+  GST_LOG ("format_name : %s", format_name);
> -+
> -+  if (!strcmp (format_name, "mp4")) {
> -+    static enum CodecID mp4_video_list[] = {
> -+      CODEC_ID_MPEG4, CODEC_ID_H264,
> -+      CODEC_ID_MJPEG,
> -+      CODEC_ID_NONE
> -+    };
> -+    static enum CodecID mp4_audio_list[] = {
> -+      CODEC_ID_AAC, CODEC_ID_MP3,
> -+      CODEC_ID_NONE
> -+    };
> -+
> -+    *video_codec_list = mp4_video_list;
> -+    *audio_codec_list = mp4_audio_list;
> -+  } else if (!strcmp (format_name, "mpeg")) {
> -+    static enum CodecID mpeg_video_list[] = { CODEC_ID_MPEG1VIDEO,
> -+      CODEC_ID_MPEG2VIDEO,
> -+      CODEC_ID_H264,
> -+      CODEC_ID_NONE
> -+    };
> -+    static enum CodecID mpeg_audio_list[] = { CODEC_ID_MP1,
> -+      CODEC_ID_MP2,
> -+      CODEC_ID_MP3,
> -+      CODEC_ID_NONE
> -+    };
> -+
> -+    *video_codec_list = mpeg_video_list;
> -+    *audio_codec_list = mpeg_audio_list;
> -+  } else if (!strcmp (format_name, "dvd")) {
> -+    static enum CodecID mpeg_video_list[] = { CODEC_ID_MPEG2VIDEO,
> -+      CODEC_ID_NONE
> -+    };
> -+    static enum CodecID mpeg_audio_list[] = { CODEC_ID_MP2,
> -+      CODEC_ID_AC3,
> -+      CODEC_ID_DTS,
> -+      CODEC_ID_PCM_S16BE,
> -+      CODEC_ID_NONE
> -+    };
> -+
> -+    *video_codec_list = mpeg_video_list;
> -+    *audio_codec_list = mpeg_audio_list;
> -+  } else if (!strcmp (format_name, "mpegts")) {
> -+    static enum CodecID mpegts_video_list[] = { CODEC_ID_MPEG1VIDEO,
> -+      CODEC_ID_MPEG2VIDEO,
> -+      CODEC_ID_H264,
> -+      CODEC_ID_NONE
> -+    };
> -+    static enum CodecID mpegts_audio_list[] = { CODEC_ID_MP2,
> -+      CODEC_ID_MP3,
> -+      CODEC_ID_AC3,
> -+      CODEC_ID_DTS,
> -+      CODEC_ID_AAC,
> -+      CODEC_ID_NONE
> -+    };
> -+
> -+    *video_codec_list = mpegts_video_list;
> -+    *audio_codec_list = mpegts_audio_list;
> -+  } else if (!strcmp (format_name, "vob")) {
> -+    static enum CodecID vob_video_list[] =
> -+        { CODEC_ID_MPEG2VIDEO, CODEC_ID_NONE };
> -+    static enum CodecID vob_audio_list[] = { CODEC_ID_MP2, CODEC_ID_AC3,
> -+      CODEC_ID_DTS, CODEC_ID_NONE
> -+    };
> -+
> -+    *video_codec_list = vob_video_list;
> -+    *audio_codec_list = vob_audio_list;
> -+  } else if (!strcmp (format_name, "flv")) {
> -+    static enum CodecID flv_video_list[] = { CODEC_ID_FLV1, CODEC_ID_NONE };
> -+    static enum CodecID flv_audio_list[] = { CODEC_ID_MP3, CODEC_ID_NONE };
> -+
> -+    *video_codec_list = flv_video_list;
> -+    *audio_codec_list = flv_audio_list;
> -+  } else if (!strcmp (format_name, "asf")) {
> -+    static enum CodecID asf_video_list[] =
> -+        { CODEC_ID_WMV1, CODEC_ID_WMV2, CODEC_ID_MSMPEG4V3, CODEC_ID_NONE };
> -+    static enum CodecID asf_audio_list[] =
> -+        { CODEC_ID_WMAV1, CODEC_ID_WMAV2, CODEC_ID_MP3, CODEC_ID_NONE };
> -+
> -+    *video_codec_list = asf_video_list;
> -+    *audio_codec_list = asf_audio_list;
> -+  } else if (!strcmp (format_name, "dv")) {
> -+    static enum CodecID dv_video_list[] = { CODEC_ID_DVVIDEO, CODEC_ID_NONE };
> -+    static enum CodecID dv_audio_list[] = { CODEC_ID_PCM_S16LE, CODEC_ID_NONE };
> -+
> -+    *video_codec_list = dv_video_list;
> -+    *audio_codec_list = dv_audio_list;
> -+  } else if (!strcmp (format_name, "mov")) {
> -+    static enum CodecID mov_video_list[] = {
> -+      CODEC_ID_SVQ1, CODEC_ID_SVQ3, CODEC_ID_MPEG4,
> -+      CODEC_ID_H263, CODEC_ID_H263P,
> -+      CODEC_ID_H264, CODEC_ID_DVVIDEO,
> -+      CODEC_ID_MJPEG,
> -+      CODEC_ID_NONE
> -+    };
> -+    static enum CodecID mov_audio_list[] = {
> -+      CODEC_ID_PCM_MULAW, CODEC_ID_PCM_ALAW, CODEC_ID_ADPCM_IMA_QT,
> -+      CODEC_ID_MACE3, CODEC_ID_MACE6, CODEC_ID_AAC,
> -+      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
> -+      CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE,
> -+      CODEC_ID_MP3, CODEC_ID_NONE
> -+    };
> -+
> -+    *video_codec_list = mov_video_list;
> -+    *audio_codec_list = mov_audio_list;
> -+  } else if ((!strcmp (format_name, "3gp") || !strcmp (format_name, "3g2"))) {
> -+    static enum CodecID tgp_video_list[] = {
> -+      CODEC_ID_MPEG4, CODEC_ID_H263, CODEC_ID_H263P, CODEC_ID_H264,
> -+      CODEC_ID_NONE
> -+    };
> -+    static enum CodecID tgp_audio_list[] = {
> -+      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
> -+      CODEC_ID_AAC,
> -+      CODEC_ID_NONE
> -+    };
> -+
> -+    *video_codec_list = tgp_video_list;
> -+    *audio_codec_list = tgp_audio_list;
> -+  } else if (!strcmp (format_name, "mmf")) {
> -+    static enum CodecID mmf_audio_list[] = {
> -+      CODEC_ID_ADPCM_YAMAHA, CODEC_ID_NONE
> -+    };
> -+    *video_codec_list = NULL;
> -+    *audio_codec_list = mmf_audio_list;
> -+  } else if (!strcmp (format_name, "amr")) {
> -+    static enum CodecID amr_audio_list[] = {
> -+      CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
> -+      CODEC_ID_NONE
> -+    };
> -+    *video_codec_list = NULL;
> -+    *audio_codec_list = amr_audio_list;
> -+  } else if (!strcmp (format_name, "gif")) {
> -+    static enum CodecID gif_image_list[] = {
> -+      CODEC_ID_RAWVIDEO, CODEC_ID_NONE
> -+    };
> -+    *video_codec_list = gif_image_list;
> -+    *audio_codec_list = NULL;
> -+  } else if ((plugin->audio_codec != CODEC_ID_NONE) ||
> -+      (plugin->video_codec != CODEC_ID_NONE)) {
> -+    tmp_vlist[0] = plugin->video_codec;
> -+    tmp_alist[0] = plugin->audio_codec;
> -+
> -+    *video_codec_list = tmp_vlist;
> -+    *audio_codec_list = tmp_alist;
> -+  } else {
> -+    GST_LOG ("Format %s not found", format_name);
> -+    return FALSE;
> -+  }
> -+
> -+  return TRUE;
> -+}
> -+
> -+/* Convert a GstCaps to a FFMPEG codec ID. Size et all
> -+ * are omitted, that can be queried by the user itself,
> -+ * we're not eating the GstCaps or anything
> -+ * A pointer to an allocated context is also needed for
> -+ * optional extra info
> -+ */
> -+
> -+enum CodecID
> -+gst_ffmpeg_caps_to_codecid (const GstCaps * caps, AVCodecContext * context)
> -+{
> -+  enum CodecID id = CODEC_ID_NONE;
> -+  const gchar *mimetype;
> -+  const GstStructure *structure;
> -+  gboolean video = FALSE, audio = FALSE;        /* we want to be sure! */
> -+
> -+  g_return_val_if_fail (caps != NULL, CODEC_ID_NONE);
> -+  g_return_val_if_fail (gst_caps_get_size (caps) == 1, CODEC_ID_NONE);
> -+  structure = gst_caps_get_structure (caps, 0);
> -+
> -+  mimetype = gst_structure_get_name (structure);
> -+
> -+  if (!strcmp (mimetype, "video/x-raw-rgb") ||
> -+      !strcmp (mimetype, "video/x-raw-yuv")) {
> -+    id = CODEC_ID_RAWVIDEO;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-raw-int")) {
> -+    gint depth, width, endianness;
> -+    gboolean signedness;
> -+
> -+    if (gst_structure_get_int (structure, "endianness", &endianness) &&
> -+        gst_structure_get_boolean (structure, "signed", &signedness) &&
> -+        gst_structure_get_int (structure, "width", &width) &&
> -+        gst_structure_get_int (structure, "depth", &depth) && depth == width) {
> -+      switch (depth) {
> -+        case 8:
> -+          if (signedness) {
> -+            id = CODEC_ID_PCM_S8;
> -+          } else {
> -+            id = CODEC_ID_PCM_U8;
> -+          }
> -+          break;
> -+        case 16:
> -+          switch (endianness) {
> -+            case G_BIG_ENDIAN:
> -+              if (signedness) {
> -+                id = CODEC_ID_PCM_S16BE;
> -+              } else {
> -+                id = CODEC_ID_PCM_U16BE;
> -+              }
> -+              break;
> -+            case G_LITTLE_ENDIAN:
> -+              if (signedness) {
> -+                id = CODEC_ID_PCM_S16LE;
> -+              } else {
> -+                id = CODEC_ID_PCM_U16LE;
> -+              }
> -+              break;
> -+          }
> -+          break;
> -+      }
> -+      if (id != CODEC_ID_NONE)
> -+        audio = TRUE;
> -+    }
> -+  } else if (!strcmp (mimetype, "audio/x-mulaw")) {
> -+    id = CODEC_ID_PCM_MULAW;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-alaw")) {
> -+    id = CODEC_ID_PCM_ALAW;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-dv")) {
> -+    gboolean sys_strm;
> -+
> -+    if (gst_structure_get_boolean (structure, "systemstream", &sys_strm) &&
> -+        !sys_strm) {
> -+      id = CODEC_ID_DVVIDEO;
> -+      video = TRUE;
> -+    }
> -+  } else if (!strcmp (mimetype, "audio/x-dv")) {        /* ??? */
> -+    id = CODEC_ID_DVAUDIO;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-h263")) {
> -+    const gchar *h263version =
> -+        gst_structure_get_string (structure, "h263version");
> -+    if (h263version && !strcmp (h263version, "h263p"))
> -+      id = CODEC_ID_H263P;
> -+    else
> -+      id = CODEC_ID_H263;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-intel-h263")) {
> -+    id = CODEC_ID_H263I;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-h261")) {
> -+    id = CODEC_ID_H261;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/mpeg")) {
> -+    gboolean sys_strm;
> -+    gint mpegversion;
> -+
> -+    if (gst_structure_get_boolean (structure, "systemstream", &sys_strm) &&
> -+        gst_structure_get_int (structure, "mpegversion", &mpegversion) &&
> -+        !sys_strm) {
> -+      switch (mpegversion) {
> -+        case 1:
> -+          id = CODEC_ID_MPEG1VIDEO;
> -+          break;
> -+        case 2:
> -+          id = CODEC_ID_MPEG2VIDEO;
> -+          break;
> -+        case 4:
> -+          id = CODEC_ID_MPEG4;
> -+          break;
> -+      }
> -+    }
> -+    if (id != CODEC_ID_NONE)
> -+      video = TRUE;
> -+  } else if (!strcmp (mimetype, "image/jpeg")) {
> -+    id = CODEC_ID_MJPEG;        /* A... B... */
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-jpeg-b")) {
> -+    id = CODEC_ID_MJPEGB;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-wmv")) {
> -+    gint wmvversion = 0;
> -+
> -+    if (gst_structure_get_int (structure, "wmvversion", &wmvversion)) {
> -+      switch (wmvversion) {
> -+        case 1:
> -+          id = CODEC_ID_WMV1;
> -+          break;
> -+        case 2:
> -+          id = CODEC_ID_WMV2;
> -+          break;
> -+        case 3:
> -+        {
> -+          guint32 fourcc;
> -+
> -+          /* WMV3 unless the fourcc exists and says otherwise */
> -+          id = CODEC_ID_WMV3;
> -+
> -+          if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
> -+            if ((fourcc == GST_MAKE_FOURCC ('W', 'V', 'C', '1')) ||
> -+                (fourcc == GST_MAKE_FOURCC ('W', 'M', 'V', 'A'))) {
> -+              id = CODEC_ID_VC1;
> -+            }
> -+          }
> -+        }
> -+          break;
> -+      }
> -+    }
> -+    if (id != CODEC_ID_NONE)
> -+      video = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-vorbis")) {
> -+    id = CODEC_ID_VORBIS;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-qdm2")) {
> -+    id = CODEC_ID_QDM2;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/mpeg")) {
> -+    gint layer = 0;
> -+    gint mpegversion = 0;
> -+
> -+    if (gst_structure_get_int (structure, "mpegversion", &mpegversion)) {
> -+      switch (mpegversion) {
> -+        case 2:                /* ffmpeg uses faad for both... */
> -+        case 4:
> -+          id = CODEC_ID_AAC;
> -+          break;
> -+        case 1:
> -+          if (gst_structure_get_int (structure, "layer", &layer)) {
> -+            switch (layer) {
> -+              case 1:
> -+                id = CODEC_ID_MP1;
> -+                break;
> -+              case 2:
> -+                id = CODEC_ID_MP2;
> -+                break;
> -+              case 3:
> -+                id = CODEC_ID_MP3;
> -+                break;
> -+            }
> -+          }
> -+      }
> -+    }
> -+    if (id != CODEC_ID_NONE)
> -+      audio = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-musepack")) {
> -+    gint streamversion = -1;
> -+
> -+    if (gst_structure_get_int (structure, "streamversion", &streamversion)) {
> -+      if (streamversion == 7)
> -+        id = CODEC_ID_MUSEPACK7;
> -+    } else {
> -+      id = CODEC_ID_MUSEPACK7;
> -+    }
> -+  } else if (!strcmp (mimetype, "audio/x-wma")) {
> -+    gint wmaversion = 0;
> -+
> -+    if (gst_structure_get_int (structure, "wmaversion", &wmaversion)) {
> -+      switch (wmaversion) {
> -+        case 1:
> -+          id = CODEC_ID_WMAV1;
> -+          break;
> -+        case 2:
> -+          id = CODEC_ID_WMAV2;
> -+          break;
> -+        case 3:
> -+          id = CODEC_ID_WMAPRO;
> -+          break;
> -+      }
> -+    }
> -+    if (id != CODEC_ID_NONE)
> -+      audio = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-wms")) {
> -+    id = CODEC_ID_WMAVOICE;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-ac3")) {
> -+    id = CODEC_ID_AC3;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-eac3")) {
> -+    id = CODEC_ID_EAC3;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-vnd.sony.atrac3") ||
> -+      !strcmp (mimetype, "audio/atrac3")) {
> -+    id = CODEC_ID_ATRAC3;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-dts")) {
> -+    id = CODEC_ID_DTS;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "application/x-ape")) {
> -+    id = CODEC_ID_APE;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-msmpeg")) {
> -+    gint msmpegversion = 0;
> -+
> -+    if (gst_structure_get_int (structure, "msmpegversion", &msmpegversion)) {
> -+      switch (msmpegversion) {
> -+        case 41:
> -+          id = CODEC_ID_MSMPEG4V1;
> -+          break;
> -+        case 42:
> -+          id = CODEC_ID_MSMPEG4V2;
> -+          break;
> -+        case 43:
> -+          id = CODEC_ID_MSMPEG4V3;
> -+          break;
> -+      }
> -+    }
> -+    if (id != CODEC_ID_NONE)
> -+      video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-svq")) {
> -+    gint svqversion = 0;
> -+
> -+    if (gst_structure_get_int (structure, "svqversion", &svqversion)) {
> -+      switch (svqversion) {
> -+        case 1:
> -+          id = CODEC_ID_SVQ1;
> -+          break;
> -+        case 3:
> -+          id = CODEC_ID_SVQ3;
> -+          break;
> -+      }
> -+    }
> -+    if (id != CODEC_ID_NONE)
> -+      video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-huffyuv")) {
> -+    id = CODEC_ID_HUFFYUV;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-mace")) {
> -+    gint maceversion = 0;
> -+
> -+    if (gst_structure_get_int (structure, "maceversion", &maceversion)) {
> -+      switch (maceversion) {
> -+        case 3:
> -+          id = CODEC_ID_MACE3;
> -+          break;
> -+        case 6:
> -+          id = CODEC_ID_MACE6;
> -+          break;
> -+      }
> -+    }
> -+    if (id != CODEC_ID_NONE)
> -+      audio = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-theora")) {
> -+    id = CODEC_ID_THEORA;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-vp3")) {
> -+    id = CODEC_ID_VP3;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-vp5")) {
> -+    id = CODEC_ID_VP5;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-vp6")) {
> -+    id = CODEC_ID_VP6;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-vp6-flash")) {
> -+    id = CODEC_ID_VP6F;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-vp6-alpha")) {
> -+    id = CODEC_ID_VP6A;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-vp8")) {
> -+    id = CODEC_ID_VP8;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-flash-screen")) {
> -+    id = CODEC_ID_FLASHSV;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-indeo")) {
> -+    gint indeoversion = 0;
> -+
> -+    if (gst_structure_get_int (structure, "indeoversion", &indeoversion)) {
> -+      switch (indeoversion) {
> -+        case 5:
> -+          id = CODEC_ID_INDEO5;
> -+          break;
> -+        case 3:
> -+          id = CODEC_ID_INDEO3;
> -+          break;
> -+        case 2:
> -+          id = CODEC_ID_INDEO2;
> -+          break;
> -+      }
> -+      if (id != CODEC_ID_NONE)
> -+        video = TRUE;
> -+    }
> -+  } else if (!strcmp (mimetype, "video/x-divx")) {
> -+    gint divxversion = 0;
> -+
> -+    if (gst_structure_get_int (structure, "divxversion", &divxversion)) {
> -+      switch (divxversion) {
> -+        case 3:
> -+          id = CODEC_ID_MSMPEG4V3;
> -+          break;
> -+        case 4:
> -+        case 5:
> -+          id = CODEC_ID_MPEG4;
> -+          break;
> -+      }
> -+    }
> -+    if (id != CODEC_ID_NONE)
> -+      video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-3ivx")) {
> -+    id = CODEC_ID_MPEG4;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-xvid")) {
> -+    id = CODEC_ID_MPEG4;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-ffv")) {
> -+    gint ffvversion = 0;
> -+
> -+    if (gst_structure_get_int (structure, "ffvversion", &ffvversion) &&
> -+        ffvversion == 1) {
> -+      id = CODEC_ID_FFV1;
> -+      video = TRUE;
> -+    }
> -+  } else if (!strcmp (mimetype, "audio/x-adpcm")) {
> -+    const gchar *layout;
> -+
> -+    layout = gst_structure_get_string (structure, "layout");
> -+    if (layout == NULL) {
> -+      /* break */
> -+    } else if (!strcmp (layout, "quicktime")) {
> -+      id = CODEC_ID_ADPCM_IMA_QT;
> -+    } else if (!strcmp (layout, "microsoft")) {
> -+      id = CODEC_ID_ADPCM_MS;
> -+    } else if (!strcmp (layout, "dvi")) {
> -+      id = CODEC_ID_ADPCM_IMA_WAV;
> -+    } else if (!strcmp (layout, "4xm")) {
> -+      id = CODEC_ID_ADPCM_4XM;
> -+    } else if (!strcmp (layout, "smjpeg")) {
> -+      id = CODEC_ID_ADPCM_IMA_SMJPEG;
> -+    } else if (!strcmp (layout, "dk3")) {
> -+      id = CODEC_ID_ADPCM_IMA_DK3;
> -+    } else if (!strcmp (layout, "dk4")) {
> -+      id = CODEC_ID_ADPCM_IMA_DK4;
> -+    } else if (!strcmp (layout, "westwood")) {
> -+      id = CODEC_ID_ADPCM_IMA_WS;
> -+    } else if (!strcmp (layout, "iss")) {
> -+      id = CODEC_ID_ADPCM_IMA_ISS;
> -+    } else if (!strcmp (layout, "xa")) {
> -+      id = CODEC_ID_ADPCM_XA;
> -+    } else if (!strcmp (layout, "adx")) {
> -+      id = CODEC_ID_ADPCM_ADX;
> -+    } else if (!strcmp (layout, "ea")) {
> -+      id = CODEC_ID_ADPCM_EA;
> -+    } else if (!strcmp (layout, "g726")) {
> -+      id = CODEC_ID_ADPCM_G726;
> -+    } else if (!strcmp (layout, "g721")) {
> -+      id = CODEC_ID_ADPCM_G726;
> -+    } else if (!strcmp (layout, "ct")) {
> -+      id = CODEC_ID_ADPCM_CT;
> -+    } else if (!strcmp (layout, "swf")) {
> -+      id = CODEC_ID_ADPCM_SWF;
> -+    } else if (!strcmp (layout, "yamaha")) {
> -+      id = CODEC_ID_ADPCM_YAMAHA;
> -+    } else if (!strcmp (layout, "sbpro2")) {
> -+      id = CODEC_ID_ADPCM_SBPRO_2;
> -+    } else if (!strcmp (layout, "sbpro3")) {
> -+      id = CODEC_ID_ADPCM_SBPRO_3;
> -+    } else if (!strcmp (layout, "sbpro4")) {
> -+      id = CODEC_ID_ADPCM_SBPRO_4;
> -+    }
> -+    if (id != CODEC_ID_NONE)
> -+      audio = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-4xm")) {
> -+    id = CODEC_ID_4XM;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-dpcm")) {
> -+    const gchar *layout;
> -+
> -+    layout = gst_structure_get_string (structure, "layout");
> -+    if (!layout) {
> -+      /* .. */
> -+    } else if (!strcmp (layout, "roq")) {
> -+      id = CODEC_ID_ROQ_DPCM;
> -+    } else if (!strcmp (layout, "interplay")) {
> -+      id = CODEC_ID_INTERPLAY_DPCM;
> -+    } else if (!strcmp (layout, "xan")) {
> -+      id = CODEC_ID_XAN_DPCM;
> -+    } else if (!strcmp (layout, "sol")) {
> -+      id = CODEC_ID_SOL_DPCM;
> -+    }
> -+    if (id != CODEC_ID_NONE)
> -+      audio = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-flac")) {
> -+    id = CODEC_ID_FLAC;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-shorten")) {
> -+    id = CODEC_ID_SHORTEN;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-alac")) {
> -+    id = CODEC_ID_ALAC;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-cinepak")) {
> -+    id = CODEC_ID_CINEPAK;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-pn-realvideo")) {
> -+    gint rmversion;
> -+
> -+    if (gst_structure_get_int (structure, "rmversion", &rmversion)) {
> -+      switch (rmversion) {
> -+        case 1:
> -+          id = CODEC_ID_RV10;
> -+          break;
> -+        case 2:
> -+          id = CODEC_ID_RV20;
> -+          break;
> -+        case 3:
> -+          id = CODEC_ID_RV30;
> -+          break;
> -+        case 4:
> -+          id = CODEC_ID_RV40;
> -+          break;
> -+      }
> -+    }
> -+    if (id != CODEC_ID_NONE)
> -+      video = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-sipro")) {
> -+    id = CODEC_ID_SIPR;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/x-pn-realaudio")) {
> -+    gint raversion;
> -+
> -+    if (gst_structure_get_int (structure, "raversion", &raversion)) {
> -+      switch (raversion) {
> -+        case 1:
> -+          id = CODEC_ID_RA_144;
> -+          break;
> -+        case 2:
> -+          id = CODEC_ID_RA_288;
> -+          break;
> -+        case 8:
> -+          id = CODEC_ID_COOK;
> -+          break;
> -+      }
> -+    }
> -+    if (id != CODEC_ID_NONE)
> -+      audio = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-rle")) {
> -+    const gchar *layout;
> -+
> -+    if ((layout = gst_structure_get_string (structure, "layout"))) {
> -+      if (!strcmp (layout, "microsoft")) {
> -+        id = CODEC_ID_MSRLE;
> -+        video = TRUE;
> -+      }
> -+    }
> -+  } else if (!strcmp (mimetype, "video/x-xan")) {
> -+    gint wcversion = 0;
> -+
> -+    if ((gst_structure_get_int (structure, "wcversion", &wcversion))) {
> -+      switch (wcversion) {
> -+        case 3:
> -+          id = CODEC_ID_XAN_WC3;
> -+          video = TRUE;
> -+          break;
> -+        case 4:
> -+          id = CODEC_ID_XAN_WC4;
> -+          video = TRUE;
> -+          break;
> -+        default:
> -+          break;
> -+      }
> -+    }
> -+  } else if (!strcmp (mimetype, "audio/AMR")) {
> -+    audio = TRUE;
> -+    id = CODEC_ID_AMR_NB;
> -+  } else if (!strcmp (mimetype, "audio/AMR-WB")) {
> -+    id = CODEC_ID_AMR_WB;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "audio/qcelp")) {
> -+    id = CODEC_ID_QCELP;
> -+    audio = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-h264")) {
> -+    id = CODEC_ID_H264;
> -+    video = TRUE;
> -+  } else if (!strcmp (mimetype, "video/x-flash-video")) {
> -+    gint flvversion = 0;
> -+
> -+    if ((gst_structure_get_int (structure, "flvversion", &flvversion))) {
> -+      switch (flvversion) {
> -+        case 1:
> -+          id = CODEC_ID_FLV1;
> -+          video = TRUE;
> -+          break;
> -+        default:
> -+          break;
> -+      }
> -+    }
> -+
> -+  } else if (!strcmp (mimetype, "audio/x-nellymoser")) {
> -+    id = CODEC_ID_NELLYMOSER;
> -+    audio = TRUE;
> -+  } else if (!strncmp (mimetype, "audio/x-gst_ff-", 15)) {
> -+    gchar ext[16];
> -+    AVCodec *codec;
> -+
> -+    if (strlen (mimetype) <= 30 &&
> -+        sscanf (mimetype, "audio/x-gst_ff-%s", ext) == 1) {
> -+      if ((codec = avcodec_find_decoder_by_name (ext)) ||
> -+          (codec = avcodec_find_encoder_by_name (ext))) {
> -+        id = codec->id;
> -+        audio = TRUE;
> -+      }
> -+    }
> -+  } else if (!strncmp (mimetype, "video/x-gst_ff-", 15)) {
> -+    gchar ext[16];
> -+    AVCodec *codec;
> -+
> -+    if (strlen (mimetype) <= 30 &&
> -+        sscanf (mimetype, "video/x-gst_ff-%s", ext) == 1) {
> -+      if ((codec = avcodec_find_decoder_by_name (ext)) ||
> -+          (codec = avcodec_find_encoder_by_name (ext))) {
> -+        id = codec->id;
> -+        video = TRUE;
> -+      }
> -+    }
> -+  }
> -+
> -+  if (context != NULL) {
> -+    if (video == TRUE) {
> -+      context->codec_type = AVMEDIA_TYPE_VIDEO;
> -+    } else if (audio == TRUE) {
> -+      context->codec_type = AVMEDIA_TYPE_AUDIO;
> -+    } else {
> -+      context->codec_type = AVMEDIA_TYPE_UNKNOWN;
> -+    }
> -+    context->codec_id = id;
> -+    gst_ffmpeg_caps_with_codecid (id, context->codec_type, caps, context);
> -+  }
> -+
> -+  if (id != CODEC_ID_NONE) {
> -+    GST_DEBUG ("The id=%d belongs to the caps %" GST_PTR_FORMAT, id, caps);
> -+  } else {
> -+    GST_WARNING ("Couldn't figure out the id for caps %" GST_PTR_FORMAT, caps);
> -+  }
> -+
> -+  return id;
> -+}
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.rej gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.rej
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.rej	1970-01-01 01:00:00.000000000 +0100
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.rej	2014-08-08 15:31:06.055868246 +0200
> -@@ -0,0 +1,12 @@
> -+--- ext/ffmpeg/gstffmpegcodecmap.c
> -++++ ext/ffmpeg/gstffmpegcodecmap.c
> -+@@ -1884,9 +1842,6 @@
> -+             gst_ff_vid_caps_new (context, codec_id, encode, "video/x-raw-rgb",
> -+             "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, "endianness",
> -+             G_TYPE_INT, endianness, NULL);
> -+-        if (caps && context) {
> -+-          gst_ffmpeg_set_palette (caps, context);
> -+-        }
> -+       }
> -+     } else if (fmt) {
> -+       caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-raw-yuv",
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c	2014-08-08 14:46:31.462772351 +0200
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c	2014-08-08 15:32:18.608870847 +0200
> -@@ -88,7 +88,6 @@
> -       gint depth;
> -     } audio;
> -   } format;
> --  gboolean waiting_for_key;
> -   gboolean discont;
> -   gboolean clear_ts;
> -
> -@@ -438,7 +437,6 @@
> -   ffmpegdec->pcache = NULL;
> -   ffmpegdec->par = NULL;
> -   ffmpegdec->opened = FALSE;
> --  ffmpegdec->waiting_for_key = TRUE;
> -   ffmpegdec->skip_frame = ffmpegdec->lowres = 0;
> -   ffmpegdec->direct_rendering = DEFAULT_DIRECT_RENDERING;
> -   ffmpegdec->do_padding = DEFAULT_DO_PADDING;
> -@@ -608,11 +606,6 @@
> -     gst_ffmpeg_avcodec_close (ffmpegdec->context);
> -   ffmpegdec->opened = FALSE;
> -
> --  if (ffmpegdec->context->palctrl) {
> --    av_free (ffmpegdec->context->palctrl);
> --    ffmpegdec->context->palctrl = NULL;
> --  }
> --
> -   if (ffmpegdec->context->extradata) {
> -     av_free (ffmpegdec->context->extradata);
> -     ffmpegdec->context->extradata = NULL;
> -@@ -864,7 +857,7 @@
> -
> -   /* workaround encoder bugs */
> -   ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
> --  ffmpegdec->context->error_recognition = 1;
> -+  ffmpegdec->context->err_recognition = 1;
> -
> -   /* for slow cpus */
> -   ffmpegdec->context->lowres = ffmpegdec->lowres;
> -@@ -944,7 +937,7 @@
> -   fsize = gst_ffmpeg_avpicture_get_size (ffmpegdec->context->pix_fmt,
> -       width, height);
> -
> --  if (!ffmpegdec->context->palctrl && ffmpegdec->can_allocate_aligned) {
> -+  if (ffmpegdec->can_allocate_aligned) {
> -     GST_LOG_OBJECT (ffmpegdec, "calling pad_alloc");
> -     /* no pallete, we can use the buffer size to alloc */
> -     ret = gst_pad_alloc_buffer_and_set_caps (ffmpegdec->srcpad,
> -@@ -1083,7 +1076,6 @@
> -   /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to
> -    * the opaque data. */
> -   picture->type = FF_BUFFER_TYPE_USER;
> --  picture->age = 256 * 256 * 256 * 64;
> -   picture->opaque = buf;
> -
> - #ifdef EXTRA_REF
> -@@ -1414,10 +1406,6 @@
> -   } else {
> -     if (diff >= 0) {
> -       /* we're too slow, try to speed up */
> --      if (ffmpegdec->waiting_for_key) {
> --        /* we were waiting for a keyframe, that's ok */
> --        goto skipping;
> --      }
> -       /* switch to skip_frame mode */
> -       goto skip_frame;
> -     }
> -@@ -1427,11 +1415,6 @@
> -   ffmpegdec->processed++;
> -   return TRUE;
> -
> --skipping:
> --  {
> --    res = FALSE;
> --    goto drop_qos;
> --  }
> - normal_mode:
> -   {
> -     if (ffmpegdec->context->skip_frame != AVDISCARD_DEFAULT) {
> -@@ -1528,43 +1511,6 @@
> - }
> -
> -
> --/* figure out if the current picture is a keyframe, return TRUE if that is
> -- * the case. */
> --static gboolean
> --check_keyframe (GstFFMpegDec * ffmpegdec)
> --{
> --  GstFFMpegDecClass *oclass;
> --  gboolean is_itype = FALSE;
> --  gboolean is_reference = FALSE;
> --  gboolean iskeyframe;
> --
> --  /* figure out if we are dealing with a keyframe */
> --  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> --
> --  /* remember that we have B frames, we need this for the DTS -> PTS conversion
> --   * code */
> --  if (!ffmpegdec->has_b_frames && ffmpegdec->picture->pict_type == FF_B_TYPE) {
> --    GST_DEBUG_OBJECT (ffmpegdec, "we have B frames");
> --    ffmpegdec->has_b_frames = TRUE;
> --  }
> --
> --  is_itype = (ffmpegdec->picture->pict_type == FF_I_TYPE);
> --  is_reference = (ffmpegdec->picture->reference == 1);
> --
> --  iskeyframe = (is_itype || is_reference || ffmpegdec->picture->key_frame)
> --      || (oclass->in_plugin->id == CODEC_ID_INDEO3)
> --      || (oclass->in_plugin->id == CODEC_ID_MSZH)
> --      || (oclass->in_plugin->id == CODEC_ID_ZLIB)
> --      || (oclass->in_plugin->id == CODEC_ID_VP3)
> --      || (oclass->in_plugin->id == CODEC_ID_HUFFYUV);
> --
> --  GST_LOG_OBJECT (ffmpegdec,
> --      "current picture: type: %d, is_keyframe:%d, is_itype:%d, is_reference:%d",
> --      ffmpegdec->picture->pict_type, iskeyframe, is_itype, is_reference);
> --
> --  return iskeyframe;
> --}
> --
> - /* get an outbuf buffer with the current picture */
> - static GstFlowReturn
> - get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
> -@@ -1694,7 +1640,6 @@
> - {
> -   gint len = -1;
> -   gint have_data;
> --  gboolean iskeyframe;
> -   gboolean mode_switch;
> -   gboolean decode;
> -   gint skip_frame = AVDISCARD_DEFAULT;
> -@@ -1809,7 +1754,6 @@
> -     gst_ffmpegdec_negotiate (ffmpegdec, TRUE);
> -   }
> -
> --
> -   /* Whether a frame is interlaced or not is unknown at the time of
> -      buffer allocation, so caps on the buffer in opaque will have
> -      the previous frame's interlaced flag set. So if interlacedness
> -@@ -1831,10 +1775,6 @@
> -     }
> -   }
> -
> --  /* check if we are dealing with a keyframe here, this will also check if we
> --   * are dealing with B frames. */
> --  iskeyframe = check_keyframe (ffmpegdec);
> --
> -   /* check that the timestamps go upwards */
> -   if (ffmpegdec->last_out != -1 && ffmpegdec->last_out > out_pts) {
> -     /* timestamps go backwards, this means frames were reordered and we must
> -@@ -1865,7 +1805,7 @@
> -    * timestamps */
> -   if (!ffmpegdec->reordered_in && ffmpegdec->reordered_out) {
> -     /* PTS and DTS are the same for keyframes */
> --    if (!iskeyframe && ffmpegdec->next_out != -1) {
> -+    if (ffmpegdec->next_out != -1) {
> -       /* interpolate all timestamps except for keyframes, FIXME, this is
> -        * wrong when QoS is active. */
> -       GST_DEBUG_OBJECT (ffmpegdec, "interpolate timestamps");
> -@@ -1874,16 +1814,6 @@
> -     }
> -   }
> -
> --  /* when we're waiting for a keyframe, see if we have one or drop the current
> --   * non-keyframe */
> --  if (G_UNLIKELY (ffmpegdec->waiting_for_key)) {
> --    if (G_LIKELY (!iskeyframe))
> --      goto drop_non_keyframe;
> --
> --    /* we have a keyframe, we can stop waiting for one */
> --    ffmpegdec->waiting_for_key = FALSE;
> --  }
> --
> -   /* get a handle to the output buffer */
> -   *ret = get_output_buffer (ffmpegdec, outbuf);
> -   if (G_UNLIKELY (*ret != GST_FLOW_OK))
> -@@ -2000,20 +1930,11 @@
> -   else
> -     ffmpegdec->next_out = -1;
> -
> --  /* palette is not part of raw video frame in gst and the size
> --   * of the outgoing buffer needs to be adjusted accordingly */
> --  if (ffmpegdec->context->palctrl != NULL)
> --    GST_BUFFER_SIZE (*outbuf) -= AVPALETTE_SIZE;
> --
> -   /* now see if we need to clip the buffer against the segment boundaries. */
> -   if (G_UNLIKELY (!clip_video_buffer (ffmpegdec, *outbuf, out_timestamp,
> -               out_duration)))
> -     goto clipped;
> -
> --  /* mark as keyframe or delta unit */
> --  if (!iskeyframe)
> --    GST_BUFFER_FLAG_SET (*outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
> --
> -   if (ffmpegdec->picture->top_field_first)
> -     GST_BUFFER_FLAG_SET (*outbuf, GST_VIDEO_BUFFER_TFF);
> -
> -@@ -2024,11 +1945,6 @@
> -   return len;
> -
> -   /* special cases */
> --drop_non_keyframe:
> --  {
> --    GST_WARNING_OBJECT (ffmpegdec, "Dropping non-keyframe (seek/init)");
> --    goto beach;
> --  }
> - no_output:
> -   {
> -     GST_DEBUG_OBJECT (ffmpegdec, "no output buffer");
> -@@ -2422,7 +2338,6 @@
> -       gst_ffmpegdec_reset_ts (ffmpegdec);
> -       gst_ffmpegdec_reset_qos (ffmpegdec);
> -       gst_ffmpegdec_flush_pcache (ffmpegdec);
> --      ffmpegdec->waiting_for_key = TRUE;
> -       gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
> -       clear_queued (ffmpegdec);
> -       break;
> -@@ -2560,17 +2475,6 @@
> -
> -   oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> -
> --  /* do early keyframe check pretty bad to rely on the keyframe flag in the
> --   * source for this as it might not even be parsed (UDP/file/..).  */
> --  if (G_UNLIKELY (ffmpegdec->waiting_for_key)) {
> --    GST_DEBUG_OBJECT (ffmpegdec, "waiting for keyframe");
> --    if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_DELTA_UNIT) &&
> --        oclass->in_plugin->type != AVMEDIA_TYPE_AUDIO)
> --      goto skip_keyframe;
> --
> --    GST_DEBUG_OBJECT (ffmpegdec, "got keyframe");
> --    ffmpegdec->waiting_for_key = FALSE;
> --  }
> -   /* parse cache joining. If there is cached data */
> -   if (ffmpegdec->pcache) {
> -     /* join with previous data */
> -@@ -2805,12 +2709,6 @@
> -     gst_buffer_unref (inbuf);
> -     return GST_FLOW_NOT_NEGOTIATED;
> -   }
> --skip_keyframe:
> --  {
> --    GST_DEBUG_OBJECT (ffmpegdec, "skipping non keyframe");
> --    gst_buffer_unref (inbuf);
> --    return GST_FLOW_OK;
> --  }
> - }
> -
> - static GstStateChangeReturn
> -@@ -2936,7 +2834,7 @@
> -     gchar *plugin_name;
> -
> -     /* only decoders */
> --    if (!in_plugin->decode) {
> -+    if (!av_codec_is_decoder (in_plugin)) {
> -       goto next;
> -     }
> -
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.orig
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.orig	1970-01-01 01:00:00.000000000 +0100
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.orig	2014-08-08 15:31:06.057868246 +0200
> -@@ -0,0 +1,2973 @@
> -+/* 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 <assert.h>
> -+#include <string.h>
> -+
> -+#ifdef HAVE_FFMPEG_UNINSTALLED
> -+#include <avcodec.h>
> -+#else
> -+#include <libavcodec/avcodec.h>
> -+#endif
> -+
> -+#include <gst/gst.h>
> -+#include <gst/video/video.h>
> -+
> -+#include "gstffmpeg.h"
> -+#include "gstffmpegcodecmap.h"
> -+#include "gstffmpegutils.h"
> -+
> -+/* define to enable alternative buffer refcounting algorithm */
> -+#undef EXTRA_REF
> -+
> -+typedef struct _GstFFMpegDec GstFFMpegDec;
> -+
> -+#define MAX_TS_MASK 0xff
> -+
> -+/* for each incomming buffer we keep all timing info in a structure like this.
> -+ * We keep a circular array of these structures around to store the timing info.
> -+ * The index in the array is what we pass as opaque data (to pictures) and
> -+ * pts (to parsers) so that ffmpeg can remember them for us. */
> -+typedef struct
> -+{
> -+  gint idx;
> -+  GstClockTime timestamp;
> -+  GstClockTime duration;
> -+  gint64 offset;
> -+} GstTSInfo;
> -+
> -+struct _GstFFMpegDec
> -+{
> -+  GstElement element;
> -+
> -+  /* We need to keep track of our pads, so we do so here. */
> -+  GstPad *srcpad;
> -+  GstPad *sinkpad;
> -+
> -+  /* decoding */
> -+  AVCodecContext *context;
> -+  AVFrame *picture;
> -+  gboolean opened;
> -+  union
> -+  {
> -+    struct
> -+    {
> -+      gint width, height;
> -+      gint clip_width, clip_height;
> -+      gint par_n, par_d;
> -+      gint fps_n, fps_d;
> -+      gint old_fps_n, old_fps_d;
> -+      gboolean interlaced;
> -+
> -+      enum PixelFormat pix_fmt;
> -+    } video;
> -+    struct
> -+    {
> -+      gint channels;
> -+      gint samplerate;
> -+      gint depth;
> -+    } audio;
> -+  } format;
> -+  gboolean discont;
> -+  gboolean clear_ts;
> -+
> -+  /* for tracking DTS/PTS */
> -+  gboolean has_b_frames;
> -+  gboolean reordered_in;
> -+  GstClockTime last_in;
> -+  GstClockTime last_diff;
> -+  guint last_frames;
> -+  gboolean reordered_out;
> -+  GstClockTime last_out;
> -+  GstClockTime next_out;
> -+
> -+  /* parsing */
> -+  gboolean turnoff_parser;      /* used for turning off aac raw parsing
> -+                                 * See bug #566250 */
> -+  AVCodecParserContext *pctx;
> -+  GstBuffer *pcache;
> -+  guint8 *padded;
> -+  guint padded_size;
> -+
> -+  GValue *par;                  /* pixel aspect ratio of incoming data */
> -+  gboolean current_dr;          /* if direct rendering is enabled */
> -+  gboolean extra_ref;           /* keep extra ref around in get/release */
> -+
> -+  /* some properties */
> -+  enum AVDiscard skip_frame;
> -+  gint lowres;
> -+  gboolean direct_rendering;
> -+  gboolean do_padding;
> -+  gboolean debug_mv;
> -+  gboolean crop;
> -+  int max_threads;
> -+
> -+  /* QoS stuff *//* with LOCK */
> -+  gdouble proportion;
> -+  GstClockTime earliest_time;
> -+  gint64 processed;
> -+  gint64 dropped;
> -+
> -+  /* clipping segment */
> -+  GstSegment segment;
> -+
> -+  gboolean is_realvideo;
> -+
> -+  GstTSInfo ts_info[MAX_TS_MASK + 1];
> -+  gint ts_idx;
> -+
> -+  /* reverse playback queue */
> -+  GList *queued;
> -+
> -+  /* Can downstream allocate 16bytes aligned data. */
> -+  gboolean can_allocate_aligned;
> -+};
> -+
> -+typedef struct _GstFFMpegDecClass GstFFMpegDecClass;
> -+
> -+struct _GstFFMpegDecClass
> -+{
> -+  GstElementClass parent_class;
> -+
> -+  AVCodec *in_plugin;
> -+  GstPadTemplate *srctempl, *sinktempl;
> -+};
> -+
> -+#define GST_TS_INFO_NONE &ts_info_none
> -+static const GstTSInfo ts_info_none = { -1, -1, -1, -1 };
> -+
> -+static const GstTSInfo *
> -+gst_ts_info_store (GstFFMpegDec * dec, GstClockTime timestamp,
> -+    GstClockTime duration, gint64 offset)
> -+{
> -+  gint idx = dec->ts_idx;
> -+  dec->ts_info[idx].idx = idx;
> -+  dec->ts_info[idx].timestamp = timestamp;
> -+  dec->ts_info[idx].duration = duration;
> -+  dec->ts_info[idx].offset = offset;
> -+  dec->ts_idx = (idx + 1) & MAX_TS_MASK;
> -+
> -+  return &dec->ts_info[idx];
> -+}
> -+
> -+static const GstTSInfo *
> -+gst_ts_info_get (GstFFMpegDec * dec, gint idx)
> -+{
> -+  if (G_UNLIKELY (idx < 0 || idx > MAX_TS_MASK))
> -+    return GST_TS_INFO_NONE;
> -+
> -+  return &dec->ts_info[idx];
> -+}
> -+
> -+#define GST_TYPE_FFMPEGDEC \
> -+  (gst_ffmpegdec_get_type())
> -+#define GST_FFMPEGDEC(obj) \
> -+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGDEC,GstFFMpegDec))
> -+#define GST_FFMPEGDEC_CLASS(klass) \
> -+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGDEC,GstFFMpegDecClass))
> -+#define GST_IS_FFMPEGDEC(obj) \
> -+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGDEC))
> -+#define GST_IS_FFMPEGDEC_CLASS(klass) \
> -+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGDEC))
> -+
> -+#define DEFAULT_LOWRES			0
> -+#define DEFAULT_SKIPFRAME		0
> -+#define DEFAULT_DIRECT_RENDERING	TRUE
> -+#define DEFAULT_DO_PADDING		TRUE
> -+#define DEFAULT_DEBUG_MV		FALSE
> -+#define DEFAULT_CROP			TRUE
> -+#define DEFAULT_MAX_THREADS		1
> -+
> -+enum
> -+{
> -+  PROP_0,
> -+  PROP_LOWRES,
> -+  PROP_SKIPFRAME,
> -+  PROP_DIRECT_RENDERING,
> -+  PROP_DO_PADDING,
> -+  PROP_DEBUG_MV,
> -+  PROP_CROP,
> -+  PROP_MAX_THREADS,
> -+  PROP_LAST
> -+};
> -+
> -+/* A number of function prototypes are given so we can refer to them later. */
> -+static void gst_ffmpegdec_base_init (GstFFMpegDecClass * klass);
> -+static void gst_ffmpegdec_class_init (GstFFMpegDecClass * klass);
> -+static void gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec);
> -+static void gst_ffmpegdec_finalize (GObject * object);
> -+
> -+static gboolean gst_ffmpegdec_query (GstPad * pad, GstQuery * query);
> -+static gboolean gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event);
> -+
> -+static gboolean gst_ffmpegdec_setcaps (GstPad * pad, GstCaps * caps);
> -+static gboolean gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event);
> -+static GstFlowReturn gst_ffmpegdec_chain (GstPad * pad, GstBuffer * buf);
> -+
> -+static GstStateChangeReturn gst_ffmpegdec_change_state (GstElement * element,
> -+    GstStateChange transition);
> -+
> -+static void gst_ffmpegdec_set_property (GObject * object,
> -+    guint prop_id, const GValue * value, GParamSpec * pspec);
> -+static void gst_ffmpegdec_get_property (GObject * object,
> -+    guint prop_id, GValue * value, GParamSpec * pspec);
> -+
> -+static gboolean gst_ffmpegdec_negotiate (GstFFMpegDec * ffmpegdec,
> -+    gboolean force);
> -+
> -+/* some sort of bufferpool handling, but different */
> -+static int gst_ffmpegdec_get_buffer (AVCodecContext * context,
> -+    AVFrame * picture);
> -+static void gst_ffmpegdec_release_buffer (AVCodecContext * context,
> -+    AVFrame * picture);
> -+
> -+static void gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec);
> -+
> -+#define GST_FFDEC_PARAMS_QDATA g_quark_from_static_string("ffdec-params")
> -+
> -+static GstElementClass *parent_class = NULL;
> -+
> -+#define GST_FFMPEGDEC_TYPE_LOWRES (gst_ffmpegdec_lowres_get_type())
> -+static GType
> -+gst_ffmpegdec_lowres_get_type (void)
> -+{
> -+  static GType ffmpegdec_lowres_type = 0;
> -+
> -+  if (!ffmpegdec_lowres_type) {
> -+    static const GEnumValue ffmpegdec_lowres[] = {
> -+      {0, "0", "full"},
> -+      {1, "1", "1/2-size"},
> -+      {2, "2", "1/4-size"},
> -+      {0, NULL, NULL},
> -+    };
> -+
> -+    ffmpegdec_lowres_type =
> -+        g_enum_register_static ("GstFFMpegDecLowres", ffmpegdec_lowres);
> -+  }
> -+
> -+  return ffmpegdec_lowres_type;
> -+}
> -+
> -+#define GST_FFMPEGDEC_TYPE_SKIPFRAME (gst_ffmpegdec_skipframe_get_type())
> -+static GType
> -+gst_ffmpegdec_skipframe_get_type (void)
> -+{
> -+  static GType ffmpegdec_skipframe_type = 0;
> -+
> -+  if (!ffmpegdec_skipframe_type) {
> -+    static const GEnumValue ffmpegdec_skipframe[] = {
> -+      {0, "0", "Skip nothing"},
> -+      {1, "1", "Skip B-frames"},
> -+      {2, "2", "Skip IDCT/Dequantization"},
> -+      {5, "5", "Skip everything"},
> -+      {0, NULL, NULL},
> -+    };
> -+
> -+    ffmpegdec_skipframe_type =
> -+        g_enum_register_static ("GstFFMpegDecSkipFrame", ffmpegdec_skipframe);
> -+  }
> -+
> -+  return ffmpegdec_skipframe_type;
> -+}
> -+
> -+static void
> -+gst_ffmpegdec_base_init (GstFFMpegDecClass * klass)
> -+{
> -+  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
> -+  GstPadTemplate *sinktempl, *srctempl;
> -+  GstCaps *sinkcaps, *srccaps;
> -+  AVCodec *in_plugin;
> -+  gchar *longname, *classification, *description;
> -+
> -+  in_plugin =
> -+      (AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
> -+      GST_FFDEC_PARAMS_QDATA);
> -+  g_assert (in_plugin != NULL);
> -+
> -+  /* construct the element details struct */
> -+  longname = g_strdup_printf ("FFmpeg %s decoder", in_plugin->long_name);
> -+  classification = g_strdup_printf ("Codec/Decoder/%s",
> -+      (in_plugin->type == AVMEDIA_TYPE_VIDEO) ? "Video" : "Audio");
> -+  description = g_strdup_printf ("FFmpeg %s decoder", in_plugin->name);
> -+  gst_element_class_set_details_simple (element_class, longname, classification,
> -+      description,
> -+      "Wim Taymans <wim.taymans@gmail.com>, "
> -+      "Ronald Bultje <rbultje@ronald.bitfreak.net>, "
> -+      "Edward Hervey <bilboed@bilboed.com>");
> -+  g_free (longname);
> -+  g_free (classification);
> -+  g_free (description);
> -+
> -+  /* get the caps */
> -+  sinkcaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, FALSE);
> -+  if (!sinkcaps) {
> -+    GST_DEBUG ("Couldn't get sink caps for decoder '%s'", in_plugin->name);
> -+    sinkcaps = gst_caps_from_string ("unknown/unknown");
> -+  }
> -+  if (in_plugin->type == AVMEDIA_TYPE_VIDEO) {
> -+    srccaps = gst_caps_from_string ("video/x-raw-rgb; video/x-raw-yuv");
> -+  } else {
> -+    srccaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
> -+        in_plugin->id, FALSE, in_plugin);
> -+  }
> -+  if (!srccaps) {
> -+    GST_DEBUG ("Couldn't get source caps for decoder '%s'", in_plugin->name);
> -+    srccaps = gst_caps_from_string ("unknown/unknown");
> -+  }
> -+
> -+  /* pad templates */
> -+  sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
> -+      GST_PAD_ALWAYS, sinkcaps);
> -+  srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
> -+
> -+  gst_element_class_add_pad_template (element_class, srctempl);
> -+  gst_element_class_add_pad_template (element_class, sinktempl);
> -+
> -+  klass->in_plugin = in_plugin;
> -+  klass->srctempl = srctempl;
> -+  klass->sinktempl = sinktempl;
> -+}
> -+
> -+static void
> -+gst_ffmpegdec_class_init (GstFFMpegDecClass * klass)
> -+{
> -+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
> -+  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
> -+
> -+  parent_class = g_type_class_peek_parent (klass);
> -+
> -+  gobject_class->finalize = gst_ffmpegdec_finalize;
> -+
> -+  gobject_class->set_property = gst_ffmpegdec_set_property;
> -+  gobject_class->get_property = gst_ffmpegdec_get_property;
> -+
> -+  if (klass->in_plugin->type == AVMEDIA_TYPE_VIDEO) {
> -+    int caps;
> -+
> -+    g_object_class_install_property (gobject_class, PROP_SKIPFRAME,
> -+        g_param_spec_enum ("skip-frame", "Skip frames",
> -+            "Which types of frames to skip during decoding",
> -+            GST_FFMPEGDEC_TYPE_SKIPFRAME, 0,
> -+            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> -+    g_object_class_install_property (gobject_class, PROP_LOWRES,
> -+        g_param_spec_enum ("lowres", "Low resolution",
> -+            "At which resolution to decode images", GST_FFMPEGDEC_TYPE_LOWRES,
> -+            0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> -+    g_object_class_install_property (gobject_class, PROP_DIRECT_RENDERING,
> -+        g_param_spec_boolean ("direct-rendering", "Direct Rendering",
> -+            "Enable direct rendering", DEFAULT_DIRECT_RENDERING,
> -+            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> -+    g_object_class_install_property (gobject_class, PROP_DO_PADDING,
> -+        g_param_spec_boolean ("do-padding", "Do Padding",
> -+            "Add 0 padding before decoding data", DEFAULT_DO_PADDING,
> -+            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> -+    g_object_class_install_property (gobject_class, PROP_DEBUG_MV,
> -+        g_param_spec_boolean ("debug-mv", "Debug motion vectors",
> -+            "Whether ffmpeg should print motion vectors on top of the image",
> -+            DEFAULT_DEBUG_MV, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> -+#if 0
> -+    g_object_class_install_property (gobject_class, PROP_CROP,
> -+        g_param_spec_boolean ("crop", "Crop",
> -+            "Crop images to the display region",
> -+            DEFAULT_CROP, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> -+#endif
> -+
> -+    caps = klass->in_plugin->capabilities;
> -+    if (caps & (CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS)) {
> -+      g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_THREADS,
> -+          g_param_spec_int ("max-threads", "Maximum decode threads",
> -+              "Maximum number of worker threads to spawn. (0 = auto)",
> -+              0, G_MAXINT, DEFAULT_MAX_THREADS,
> -+              G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> -+    }
> -+  }
> -+
> -+  gstelement_class->change_state = gst_ffmpegdec_change_state;
> -+}
> -+
> -+static void
> -+gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec)
> -+{
> -+  GstFFMpegDecClass *oclass;
> -+
> -+  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> -+
> -+  /* setup pads */
> -+  ffmpegdec->sinkpad = gst_pad_new_from_template (oclass->sinktempl, "sink");
> -+  gst_pad_set_setcaps_function (ffmpegdec->sinkpad,
> -+      GST_DEBUG_FUNCPTR (gst_ffmpegdec_setcaps));
> -+  gst_pad_set_event_function (ffmpegdec->sinkpad,
> -+      GST_DEBUG_FUNCPTR (gst_ffmpegdec_sink_event));
> -+  gst_pad_set_chain_function (ffmpegdec->sinkpad,
> -+      GST_DEBUG_FUNCPTR (gst_ffmpegdec_chain));
> -+  gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->sinkpad);
> -+
> -+  ffmpegdec->srcpad = gst_pad_new_from_template (oclass->srctempl, "src");
> -+  gst_pad_use_fixed_caps (ffmpegdec->srcpad);
> -+  gst_pad_set_event_function (ffmpegdec->srcpad,
> -+      GST_DEBUG_FUNCPTR (gst_ffmpegdec_src_event));
> -+  gst_pad_set_query_function (ffmpegdec->srcpad,
> -+      GST_DEBUG_FUNCPTR (gst_ffmpegdec_query));
> -+  gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->srcpad);
> -+
> -+  /* some ffmpeg data */
> -+  ffmpegdec->context = avcodec_alloc_context ();
> -+  ffmpegdec->picture = avcodec_alloc_frame ();
> -+  ffmpegdec->pctx = NULL;
> -+  ffmpegdec->pcache = NULL;
> -+  ffmpegdec->par = NULL;
> -+  ffmpegdec->opened = FALSE;
> -+  ffmpegdec->skip_frame = ffmpegdec->lowres = 0;
> -+  ffmpegdec->direct_rendering = DEFAULT_DIRECT_RENDERING;
> -+  ffmpegdec->do_padding = DEFAULT_DO_PADDING;
> -+  ffmpegdec->debug_mv = DEFAULT_DEBUG_MV;
> -+  ffmpegdec->crop = DEFAULT_CROP;
> -+  ffmpegdec->max_threads = DEFAULT_MAX_THREADS;
> -+
> -+  ffmpegdec->format.video.par_n = -1;
> -+  ffmpegdec->format.video.fps_n = -1;
> -+  ffmpegdec->format.video.old_fps_n = -1;
> -+  gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
> -+
> -+  /* We initially assume downstream can allocate 16 bytes aligned buffers */
> -+  ffmpegdec->can_allocate_aligned = TRUE;
> -+}
> -+
> -+static void
> -+gst_ffmpegdec_finalize (GObject * object)
> -+{
> -+  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
> -+
> -+  if (ffmpegdec->context != NULL) {
> -+    av_free (ffmpegdec->context);
> -+    ffmpegdec->context = NULL;
> -+  }
> -+
> -+  if (ffmpegdec->picture != NULL) {
> -+    av_free (ffmpegdec->picture);
> -+    ffmpegdec->picture = NULL;
> -+  }
> -+
> -+  G_OBJECT_CLASS (parent_class)->finalize (object);
> -+}
> -+
> -+static gboolean
> -+gst_ffmpegdec_query (GstPad * pad, GstQuery * query)
> -+{
> -+  GstFFMpegDec *ffmpegdec;
> -+  GstPad *peer;
> -+  gboolean res;
> -+
> -+  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
> -+
> -+  res = FALSE;
> -+
> -+  if ((peer = gst_pad_get_peer (ffmpegdec->sinkpad))) {
> -+    /* just forward to peer */
> -+    res = gst_pad_query (peer, query);
> -+    gst_object_unref (peer);
> -+  }
> -+#if 0
> -+  {
> -+    GstFormat bfmt;
> -+
> -+    bfmt = GST_FORMAT_BYTES;
> -+
> -+    /* ok, do bitrate calc... */
> -+    if ((type != GST_QUERY_POSITION && type != GST_QUERY_TOTAL) ||
> -+        *fmt != GST_FORMAT_TIME || ffmpegdec->context->bit_rate == 0 ||
> -+        !gst_pad_query (peer, type, &bfmt, value))
> -+      return FALSE;
> -+
> -+    if (ffmpegdec->pcache && type == GST_QUERY_POSITION)
> -+      *value -= GST_BUFFER_SIZE (ffmpegdec->pcache);
> -+    *value *= GST_SECOND / ffmpegdec->context->bit_rate;
> -+  }
> -+#endif
> -+
> -+  gst_object_unref (ffmpegdec);
> -+
> -+  return res;
> -+}
> -+
> -+static void
> -+gst_ffmpegdec_reset_ts (GstFFMpegDec * ffmpegdec)
> -+{
> -+  ffmpegdec->last_in = GST_CLOCK_TIME_NONE;
> -+  ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
> -+  ffmpegdec->last_frames = 0;
> -+  ffmpegdec->last_out = GST_CLOCK_TIME_NONE;
> -+  ffmpegdec->next_out = GST_CLOCK_TIME_NONE;
> -+  ffmpegdec->reordered_in = FALSE;
> -+  ffmpegdec->reordered_out = FALSE;
> -+}
> -+
> -+static void
> -+gst_ffmpegdec_update_qos (GstFFMpegDec * ffmpegdec, gdouble proportion,
> -+    GstClockTime timestamp)
> -+{
> -+  GST_LOG_OBJECT (ffmpegdec, "update QOS: %f, %" GST_TIME_FORMAT,
> -+      proportion, GST_TIME_ARGS (timestamp));
> -+
> -+  GST_OBJECT_LOCK (ffmpegdec);
> -+  ffmpegdec->proportion = proportion;
> -+  ffmpegdec->earliest_time = timestamp;
> -+  GST_OBJECT_UNLOCK (ffmpegdec);
> -+}
> -+
> -+static void
> -+gst_ffmpegdec_reset_qos (GstFFMpegDec * ffmpegdec)
> -+{
> -+  gst_ffmpegdec_update_qos (ffmpegdec, 0.5, GST_CLOCK_TIME_NONE);
> -+  ffmpegdec->processed = 0;
> -+  ffmpegdec->dropped = 0;
> -+}
> -+
> -+static void
> -+gst_ffmpegdec_read_qos (GstFFMpegDec * ffmpegdec, gdouble * proportion,
> -+    GstClockTime * timestamp)
> -+{
> -+  GST_OBJECT_LOCK (ffmpegdec);
> -+  *proportion = ffmpegdec->proportion;
> -+  *timestamp = ffmpegdec->earliest_time;
> -+  GST_OBJECT_UNLOCK (ffmpegdec);
> -+}
> -+
> -+static gboolean
> -+gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event)
> -+{
> -+  GstFFMpegDec *ffmpegdec;
> -+  gboolean res;
> -+
> -+  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
> -+
> -+  switch (GST_EVENT_TYPE (event)) {
> -+    case GST_EVENT_QOS:
> -+    {
> -+      gdouble proportion;
> -+      GstClockTimeDiff diff;
> -+      GstClockTime timestamp;
> -+
> -+      gst_event_parse_qos (event, &proportion, &diff, &timestamp);
> -+
> -+      /* update our QoS values */
> -+      gst_ffmpegdec_update_qos (ffmpegdec, proportion, timestamp + diff);
> -+
> -+      /* forward upstream */
> -+      res = gst_pad_push_event (ffmpegdec->sinkpad, event);
> -+      break;
> -+    }
> -+    default:
> -+      /* forward upstream */
> -+      res = gst_pad_push_event (ffmpegdec->sinkpad, event);
> -+      break;
> -+  }
> -+
> -+  gst_object_unref (ffmpegdec);
> -+
> -+  return res;
> -+}
> -+
> -+/* with LOCK */
> -+static void
> -+gst_ffmpegdec_close (GstFFMpegDec * ffmpegdec)
> -+{
> -+  if (!ffmpegdec->opened)
> -+    return;
> -+
> -+  GST_LOG_OBJECT (ffmpegdec, "closing ffmpeg codec");
> -+
> -+  if (ffmpegdec->par) {
> -+    g_free (ffmpegdec->par);
> -+    ffmpegdec->par = NULL;
> -+  }
> -+
> -+  if (ffmpegdec->context->priv_data)
> -+    gst_ffmpeg_avcodec_close (ffmpegdec->context);
> -+  ffmpegdec->opened = FALSE;
> -+
> -+  if (ffmpegdec->context->extradata) {
> -+    av_free (ffmpegdec->context->extradata);
> -+    ffmpegdec->context->extradata = NULL;
> -+  }
> -+
> -+  if (ffmpegdec->pctx) {
> -+    if (ffmpegdec->pcache) {
> -+      gst_buffer_unref (ffmpegdec->pcache);
> -+      ffmpegdec->pcache = NULL;
> -+    }
> -+    av_parser_close (ffmpegdec->pctx);
> -+    ffmpegdec->pctx = NULL;
> -+  }
> -+
> -+  ffmpegdec->format.video.par_n = -1;
> -+  ffmpegdec->format.video.fps_n = -1;
> -+  ffmpegdec->format.video.old_fps_n = -1;
> -+  ffmpegdec->format.video.interlaced = FALSE;
> -+}
> -+
> -+/* with LOCK */
> -+static gboolean
> -+gst_ffmpegdec_open (GstFFMpegDec * ffmpegdec)
> -+{
> -+  GstFFMpegDecClass *oclass;
> -+
> -+  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> -+
> -+  if (gst_ffmpeg_avcodec_open (ffmpegdec->context, oclass->in_plugin) < 0)
> -+    goto could_not_open;
> -+
> -+  ffmpegdec->opened = TRUE;
> -+  ffmpegdec->is_realvideo = FALSE;
> -+
> -+  GST_LOG_OBJECT (ffmpegdec, "Opened ffmpeg codec %s, id %d",
> -+      oclass->in_plugin->name, oclass->in_plugin->id);
> -+
> -+  /* open a parser if we can */
> -+  switch (oclass->in_plugin->id) {
> -+    case CODEC_ID_MPEG4:
> -+    case CODEC_ID_MJPEG:
> -+    case CODEC_ID_VC1:
> -+      GST_LOG_OBJECT (ffmpegdec, "not using parser, blacklisted codec");
> -+      ffmpegdec->pctx = NULL;
> -+      break;
> -+    case CODEC_ID_H264:
> -+      /* For H264, only use a parser if there is no context data, if there is,
> -+       * we're talking AVC */
> -+      if (ffmpegdec->context->extradata_size == 0) {
> -+        GST_LOG_OBJECT (ffmpegdec, "H264 with no extradata, creating parser");
> -+        ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
> -+      } else {
> -+        GST_LOG_OBJECT (ffmpegdec,
> -+            "H264 with extradata implies framed data - not using parser");
> -+        ffmpegdec->pctx = NULL;
> -+      }
> -+      break;
> -+    case CODEC_ID_RV10:
> -+    case CODEC_ID_RV30:
> -+    case CODEC_ID_RV20:
> -+    case CODEC_ID_RV40:
> -+      ffmpegdec->is_realvideo = TRUE;
> -+      break;
> -+    default:
> -+      if (!ffmpegdec->turnoff_parser) {
> -+        ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
> -+        if (ffmpegdec->pctx)
> -+          GST_LOG_OBJECT (ffmpegdec, "Using parser %p", ffmpegdec->pctx);
> -+        else
> -+          GST_LOG_OBJECT (ffmpegdec, "No parser for codec");
> -+      } else {
> -+        GST_LOG_OBJECT (ffmpegdec, "Parser deactivated for format");
> -+      }
> -+      break;
> -+  }
> -+
> -+  switch (oclass->in_plugin->type) {
> -+    case AVMEDIA_TYPE_VIDEO:
> -+      ffmpegdec->format.video.width = 0;
> -+      ffmpegdec->format.video.height = 0;
> -+      ffmpegdec->format.video.clip_width = -1;
> -+      ffmpegdec->format.video.clip_height = -1;
> -+      ffmpegdec->format.video.pix_fmt = PIX_FMT_NB;
> -+      ffmpegdec->format.video.interlaced = FALSE;
> -+      break;
> -+    case AVMEDIA_TYPE_AUDIO:
> -+      ffmpegdec->format.audio.samplerate = 0;
> -+      ffmpegdec->format.audio.channels = 0;
> -+      ffmpegdec->format.audio.depth = 0;
> -+      break;
> -+    default:
> -+      break;
> -+  }
> -+
> -+  gst_ffmpegdec_reset_ts (ffmpegdec);
> -+  /* FIXME, reset_qos holds the LOCK */
> -+  ffmpegdec->proportion = 0.0;
> -+  ffmpegdec->earliest_time = -1;
> -+
> -+  return TRUE;
> -+
> -+  /* ERRORS */
> -+could_not_open:
> -+  {
> -+    gst_ffmpegdec_close (ffmpegdec);
> -+    GST_DEBUG_OBJECT (ffmpegdec, "ffdec_%s: Failed to open FFMPEG codec",
> -+        oclass->in_plugin->name);
> -+    return FALSE;
> -+  }
> -+}
> -+
> -+static gboolean
> -+gst_ffmpegdec_setcaps (GstPad * pad, GstCaps * caps)
> -+{
> -+  GstFFMpegDec *ffmpegdec;
> -+  GstFFMpegDecClass *oclass;
> -+  GstStructure *structure;
> -+  const GValue *par;
> -+  const GValue *fps;
> -+  gboolean ret = TRUE;
> -+
> -+  ffmpegdec = (GstFFMpegDec *) (gst_pad_get_parent (pad));
> -+  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> -+
> -+  GST_DEBUG_OBJECT (pad, "setcaps called");
> -+
> -+  GST_OBJECT_LOCK (ffmpegdec);
> -+
> -+  /* stupid check for VC1 */
> -+  if ((oclass->in_plugin->id == CODEC_ID_WMV3) ||
> -+      (oclass->in_plugin->id == CODEC_ID_VC1))
> -+    oclass->in_plugin->id = gst_ffmpeg_caps_to_codecid (caps, NULL);
> -+
> -+  /* close old session */
> -+  if (ffmpegdec->opened) {
> -+    GST_OBJECT_UNLOCK (ffmpegdec);
> -+    gst_ffmpegdec_drain (ffmpegdec);
> -+    GST_OBJECT_LOCK (ffmpegdec);
> -+    gst_ffmpegdec_close (ffmpegdec);
> -+
> -+    /* and reset the defaults that were set when a context is created */
> -+    avcodec_get_context_defaults (ffmpegdec->context);
> -+  }
> -+
> -+  /* set buffer functions */
> -+  ffmpegdec->context->get_buffer = gst_ffmpegdec_get_buffer;
> -+  ffmpegdec->context->release_buffer = gst_ffmpegdec_release_buffer;
> -+  ffmpegdec->context->draw_horiz_band = NULL;
> -+
> -+  /* default is to let format decide if it needs a parser */
> -+  ffmpegdec->turnoff_parser = FALSE;
> -+
> -+  ffmpegdec->has_b_frames = FALSE;
> -+
> -+  GST_LOG_OBJECT (ffmpegdec, "size %dx%d", ffmpegdec->context->width,
> -+      ffmpegdec->context->height);
> -+
> -+  /* get size and so */
> -+  gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
> -+      oclass->in_plugin->type, caps, ffmpegdec->context);
> -+
> -+  GST_LOG_OBJECT (ffmpegdec, "size after %dx%d", ffmpegdec->context->width,
> -+      ffmpegdec->context->height);
> -+
> -+  if (!ffmpegdec->context->time_base.den || !ffmpegdec->context->time_base.num) {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "forcing 25/1 framerate");
> -+    ffmpegdec->context->time_base.num = 1;
> -+    ffmpegdec->context->time_base.den = 25;
> -+  }
> -+
> -+  /* get pixel aspect ratio if it's set */
> -+  structure = gst_caps_get_structure (caps, 0);
> -+
> -+  par = gst_structure_get_value (structure, "pixel-aspect-ratio");
> -+  if (par) {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "sink caps have pixel-aspect-ratio of %d:%d",
> -+        gst_value_get_fraction_numerator (par),
> -+        gst_value_get_fraction_denominator (par));
> -+    /* should be NULL */
> -+    if (ffmpegdec->par)
> -+      g_free (ffmpegdec->par);
> -+    ffmpegdec->par = g_new0 (GValue, 1);
> -+    gst_value_init_and_copy (ffmpegdec->par, par);
> -+  }
> -+
> -+  /* get the framerate from incoming caps. fps_n is set to -1 when
> -+   * there is no valid framerate */
> -+  fps = gst_structure_get_value (structure, "framerate");
> -+  if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
> -+    ffmpegdec->format.video.fps_n = gst_value_get_fraction_numerator (fps);
> -+    ffmpegdec->format.video.fps_d = gst_value_get_fraction_denominator (fps);
> -+    GST_DEBUG_OBJECT (ffmpegdec, "Using framerate %d/%d from incoming caps",
> -+        ffmpegdec->format.video.fps_n, ffmpegdec->format.video.fps_d);
> -+  } else {
> -+    ffmpegdec->format.video.fps_n = -1;
> -+    GST_DEBUG_OBJECT (ffmpegdec, "Using framerate from codec");
> -+  }
> -+
> -+  /* figure out if we can use direct rendering */
> -+  ffmpegdec->current_dr = FALSE;
> -+  ffmpegdec->extra_ref = FALSE;
> -+  if (ffmpegdec->direct_rendering) {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "trying to enable direct rendering");
> -+    if (oclass->in_plugin->capabilities & CODEC_CAP_DR1) {
> -+      if (oclass->in_plugin->id == CODEC_ID_H264) {
> -+        GST_DEBUG_OBJECT (ffmpegdec, "disable direct rendering setup for H264");
> -+        /* does not work, many stuff reads outside of the planes */
> -+        ffmpegdec->current_dr = FALSE;
> -+        ffmpegdec->extra_ref = TRUE;
> -+      } else if ((oclass->in_plugin->id == CODEC_ID_SVQ1) ||
> -+          (oclass->in_plugin->id == CODEC_ID_VP5) ||
> -+          (oclass->in_plugin->id == CODEC_ID_VP6) ||
> -+          (oclass->in_plugin->id == CODEC_ID_VP6F) ||
> -+          (oclass->in_plugin->id == CODEC_ID_VP6A)) {
> -+        GST_DEBUG_OBJECT (ffmpegdec,
> -+            "disable direct rendering setup for broken stride support");
> -+        /* does not work, uses a incompatible stride. See #610613 */
> -+        ffmpegdec->current_dr = FALSE;
> -+        ffmpegdec->extra_ref = TRUE;
> -+      } else {
> -+        GST_DEBUG_OBJECT (ffmpegdec, "enabled direct rendering");
> -+        ffmpegdec->current_dr = TRUE;
> -+      }
> -+    } else {
> -+      GST_DEBUG_OBJECT (ffmpegdec, "direct rendering not supported");
> -+    }
> -+  }
> -+  if (ffmpegdec->current_dr) {
> -+    /* do *not* draw edges when in direct rendering, for some reason it draws
> -+     * outside of the memory. */
> -+    ffmpegdec->context->flags |= CODEC_FLAG_EMU_EDGE;
> -+  }
> -+
> -+  /* for AAC we only use av_parse if not on stream-format==raw or ==loas */
> -+  if (oclass->in_plugin->id == CODEC_ID_AAC
> -+      || oclass->in_plugin->id == CODEC_ID_AAC_LATM) {
> -+    const gchar *format = gst_structure_get_string (structure, "stream-format");
> -+
> -+    if (format == NULL || strcmp (format, "raw") == 0) {
> -+      ffmpegdec->turnoff_parser = TRUE;
> -+    }
> -+  }
> -+
> -+  /* for FLAC, don't parse if it's already parsed */
> -+  if (oclass->in_plugin->id == CODEC_ID_FLAC) {
> -+    if (gst_structure_has_field (structure, "streamheader"))
> -+      ffmpegdec->turnoff_parser = TRUE;
> -+  }
> -+
> -+  /* workaround encoder bugs */
> -+  ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
> -+  ffmpegdec->context->err_recognition = 1;
> -+
> -+  /* for slow cpus */
> -+  ffmpegdec->context->lowres = ffmpegdec->lowres;
> -+  ffmpegdec->context->skip_frame = ffmpegdec->skip_frame;
> -+
> -+  /* ffmpeg can draw motion vectors on top of the image (not every decoder
> -+   * supports it) */
> -+  ffmpegdec->context->debug_mv = ffmpegdec->debug_mv;
> -+
> -+  if (ffmpegdec->max_threads == 0)
> -+    ffmpegdec->context->thread_count = gst_ffmpeg_auto_max_threads ();
> -+  else
> -+    ffmpegdec->context->thread_count = ffmpegdec->max_threads;
> -+
> -+  /* open codec - we don't select an output pix_fmt yet,
> -+   * simply because we don't know! We only get it
> -+   * during playback... */
> -+  if (!gst_ffmpegdec_open (ffmpegdec))
> -+    goto open_failed;
> -+
> -+  /* clipping region */
> -+  gst_structure_get_int (structure, "width",
> -+      &ffmpegdec->format.video.clip_width);
> -+  gst_structure_get_int (structure, "height",
> -+      &ffmpegdec->format.video.clip_height);
> -+
> -+  GST_DEBUG_OBJECT (pad, "clipping to %dx%d",
> -+      ffmpegdec->format.video.clip_width, ffmpegdec->format.video.clip_height);
> -+
> -+  /* take into account the lowres property */
> -+  if (ffmpegdec->format.video.clip_width != -1)
> -+    ffmpegdec->format.video.clip_width >>= ffmpegdec->lowres;
> -+  if (ffmpegdec->format.video.clip_height != -1)
> -+    ffmpegdec->format.video.clip_height >>= ffmpegdec->lowres;
> -+
> -+  GST_DEBUG_OBJECT (pad, "final clipping to %dx%d",
> -+      ffmpegdec->format.video.clip_width, ffmpegdec->format.video.clip_height);
> -+
> -+done:
> -+  GST_OBJECT_UNLOCK (ffmpegdec);
> -+
> -+  gst_object_unref (ffmpegdec);
> -+
> -+  return ret;
> -+
> -+  /* ERRORS */
> -+open_failed:
> -+  {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "Failed to open");
> -+    if (ffmpegdec->par) {
> -+      g_free (ffmpegdec->par);
> -+      ffmpegdec->par = NULL;
> -+    }
> -+    ret = FALSE;
> -+    goto done;
> -+  }
> -+}
> -+
> -+static GstFlowReturn
> -+alloc_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf,
> -+    gint width, gint height)
> -+{
> -+  GstFlowReturn ret;
> -+  gint fsize;
> -+
> -+  ret = GST_FLOW_ERROR;
> -+  *outbuf = NULL;
> -+
> -+  GST_LOG_OBJECT (ffmpegdec, "alloc output buffer");
> -+
> -+  /* see if we need renegotiation */
> -+  if (G_UNLIKELY (!gst_ffmpegdec_negotiate (ffmpegdec, FALSE)))
> -+    goto negotiate_failed;
> -+
> -+  /* get the size of the gstreamer output buffer given a
> -+   * width/height/format */
> -+  fsize = gst_ffmpeg_avpicture_get_size (ffmpegdec->context->pix_fmt,
> -+      width, height);
> -+
> -+  if (ffmpegdec->can_allocate_aligned) {
> -+    GST_LOG_OBJECT (ffmpegdec, "calling pad_alloc");
> -+    /* no pallete, we can use the buffer size to alloc */
> -+    ret = gst_pad_alloc_buffer_and_set_caps (ffmpegdec->srcpad,
> -+        GST_BUFFER_OFFSET_NONE, fsize,
> -+        GST_PAD_CAPS (ffmpegdec->srcpad), outbuf);
> -+    if (G_UNLIKELY (ret != GST_FLOW_OK))
> -+      goto alloc_failed;
> -+
> -+    /* If buffer isn't 128-bit aligned, create a memaligned one ourselves */
> -+    if (((uintptr_t) GST_BUFFER_DATA (*outbuf)) % 16) {
> -+      GST_DEBUG_OBJECT (ffmpegdec,
> -+          "Downstream can't allocate aligned buffers.");
> -+      ffmpegdec->can_allocate_aligned = FALSE;
> -+      gst_buffer_unref (*outbuf);
> -+      *outbuf = new_aligned_buffer (fsize, GST_PAD_CAPS (ffmpegdec->srcpad));
> -+    }
> -+  } else {
> -+    GST_LOG_OBJECT (ffmpegdec,
> -+        "not calling pad_alloc, we have a pallete or downstream can't give 16 byte aligned buffers.");
> -+    /* for paletted data we can't use pad_alloc_buffer(), because
> -+     * fsize contains the size of the palette, so the overall size
> -+     * is bigger than ffmpegcolorspace's unit size, which will
> -+     * prompt GstBaseTransform to complain endlessly ... */
> -+    *outbuf = new_aligned_buffer (fsize, GST_PAD_CAPS (ffmpegdec->srcpad));
> -+    ret = GST_FLOW_OK;
> -+  }
> -+  /* set caps, we do this here because the buffer is still writable here and we
> -+   * are sure to be negotiated */
> -+  gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (ffmpegdec->srcpad));
> -+
> -+  return ret;
> -+
> -+  /* special cases */
> -+negotiate_failed:
> -+  {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "negotiate failed");
> -+    return GST_FLOW_NOT_NEGOTIATED;
> -+  }
> -+alloc_failed:
> -+  {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "pad_alloc failed %d (%s)", ret,
> -+        gst_flow_get_name (ret));
> -+    return ret;
> -+  }
> -+}
> -+
> -+static int
> -+gst_ffmpegdec_get_buffer (AVCodecContext * context, AVFrame * picture)
> -+{
> -+  GstBuffer *buf = NULL;
> -+  GstFFMpegDec *ffmpegdec;
> -+  gint width, height;
> -+  gint coded_width, coded_height;
> -+  gint res;
> -+
> -+  ffmpegdec = (GstFFMpegDec *) context->opaque;
> -+
> -+  GST_DEBUG_OBJECT (ffmpegdec, "getting buffer");
> -+
> -+  /* apply the last info we have seen to this picture, when we get the
> -+   * picture back from ffmpeg we can use this to correctly timestamp the output
> -+   * buffer */
> -+  picture->reordered_opaque = context->reordered_opaque;
> -+  /* make sure we don't free the buffer when it's not ours */
> -+  picture->opaque = NULL;
> -+
> -+  /* take width and height before clipping */
> -+  width = context->width;
> -+  height = context->height;
> -+  coded_width = context->coded_width;
> -+  coded_height = context->coded_height;
> -+
> -+  GST_LOG_OBJECT (ffmpegdec, "dimension %dx%d, coded %dx%d", width, height,
> -+      coded_width, coded_height);
> -+  if (!ffmpegdec->current_dr) {
> -+    GST_LOG_OBJECT (ffmpegdec, "direct rendering disabled, fallback alloc");
> -+    res = avcodec_default_get_buffer (context, picture);
> -+
> -+    GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", picture->linesize[0],
> -+        picture->linesize[1], picture->linesize[2]);
> -+    GST_LOG_OBJECT (ffmpegdec, "data %u %u %u", 0,
> -+        (guint) (picture->data[1] - picture->data[0]),
> -+        (guint) (picture->data[2] - picture->data[0]));
> -+    return res;
> -+  }
> -+
> -+  switch (context->codec_type) {
> -+    case AVMEDIA_TYPE_VIDEO:
> -+      /* some ffmpeg video plugins don't see the point in setting codec_type ... */
> -+    case AVMEDIA_TYPE_UNKNOWN:
> -+    {
> -+      GstFlowReturn ret;
> -+      gint clip_width, clip_height;
> -+
> -+      /* take final clipped output size */
> -+      if ((clip_width = ffmpegdec->format.video.clip_width) == -1)
> -+        clip_width = width;
> -+      if ((clip_height = ffmpegdec->format.video.clip_height) == -1)
> -+        clip_height = height;
> -+
> -+      GST_LOG_OBJECT (ffmpegdec, "raw outsize %d/%d", width, height);
> -+
> -+      /* this is the size ffmpeg needs for the buffer */
> -+      avcodec_align_dimensions (context, &width, &height);
> -+
> -+      GST_LOG_OBJECT (ffmpegdec, "aligned outsize %d/%d, clip %d/%d",
> -+          width, height, clip_width, clip_height);
> -+
> -+      if (width != clip_width || height != clip_height) {
> -+        /* We can't alloc if we need to clip the output buffer later */
> -+        GST_LOG_OBJECT (ffmpegdec, "we need clipping, fallback alloc");
> -+        return avcodec_default_get_buffer (context, picture);
> -+      }
> -+
> -+      /* alloc with aligned dimensions for ffmpeg */
> -+      ret = alloc_output_buffer (ffmpegdec, &buf, width, height);
> -+      if (G_UNLIKELY (ret != GST_FLOW_OK)) {
> -+        /* alloc default buffer when we can't get one from downstream */
> -+        GST_LOG_OBJECT (ffmpegdec, "alloc failed, fallback alloc");
> -+        return avcodec_default_get_buffer (context, picture);
> -+      }
> -+
> -+      /* copy the right pointers and strides in the picture object */
> -+      gst_ffmpeg_avpicture_fill ((AVPicture *) picture,
> -+          GST_BUFFER_DATA (buf), context->pix_fmt, width, height);
> -+      break;
> -+    }
> -+    case AVMEDIA_TYPE_AUDIO:
> -+    default:
> -+      GST_ERROR_OBJECT (ffmpegdec,
> -+          "_get_buffer() should never get called for non-video buffers !");
> -+      g_assert_not_reached ();
> -+      break;
> -+  }
> -+
> -+  /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to
> -+   * the opaque data. */
> -+  picture->type = FF_BUFFER_TYPE_USER;
> -+  picture->opaque = buf;
> -+
> -+#ifdef EXTRA_REF
> -+  if (picture->reference != 0 || ffmpegdec->extra_ref) {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "adding extra ref");
> -+    gst_buffer_ref (buf);
> -+  }
> -+#endif
> -+
> -+  GST_LOG_OBJECT (ffmpegdec, "returned buffer %p", buf);
> -+
> -+  return 0;
> -+}
> -+
> -+static void
> -+gst_ffmpegdec_release_buffer (AVCodecContext * context, AVFrame * picture)
> -+{
> -+  gint i;
> -+  GstBuffer *buf;
> -+  GstFFMpegDec *ffmpegdec;
> -+
> -+  ffmpegdec = (GstFFMpegDec *) context->opaque;
> -+
> -+  /* check if it was our buffer */
> -+  if (picture->opaque == NULL) {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "default release buffer");
> -+    avcodec_default_release_buffer (context, picture);
> -+    return;
> -+  }
> -+
> -+  /* we remove the opaque data now */
> -+  buf = GST_BUFFER_CAST (picture->opaque);
> -+  GST_DEBUG_OBJECT (ffmpegdec, "release buffer %p", buf);
> -+  picture->opaque = NULL;
> -+
> -+#ifdef EXTRA_REF
> -+  if (picture->reference != 0 || ffmpegdec->extra_ref) {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "remove extra ref");
> -+    gst_buffer_unref (buf);
> -+  }
> -+#else
> -+  gst_buffer_unref (buf);
> -+#endif
> -+
> -+  /* zero out the reference in ffmpeg */
> -+  for (i = 0; i < 4; i++) {
> -+    picture->data[i] = NULL;
> -+    picture->linesize[i] = 0;
> -+  }
> -+}
> -+
> -+static void
> -+gst_ffmpegdec_add_pixel_aspect_ratio (GstFFMpegDec * ffmpegdec,
> -+    GstStructure * s)
> -+{
> -+  gboolean demuxer_par_set = FALSE;
> -+  gboolean decoder_par_set = FALSE;
> -+  gint demuxer_num = 1, demuxer_denom = 1;
> -+  gint decoder_num = 1, decoder_denom = 1;
> -+
> -+  GST_OBJECT_LOCK (ffmpegdec);
> -+
> -+  if (ffmpegdec->par) {
> -+    demuxer_num = gst_value_get_fraction_numerator (ffmpegdec->par);
> -+    demuxer_denom = gst_value_get_fraction_denominator (ffmpegdec->par);
> -+    demuxer_par_set = TRUE;
> -+    GST_DEBUG_OBJECT (ffmpegdec, "Demuxer PAR: %d:%d", demuxer_num,
> -+        demuxer_denom);
> -+  }
> -+
> -+  if (ffmpegdec->context->sample_aspect_ratio.num &&
> -+      ffmpegdec->context->sample_aspect_ratio.den) {
> -+    decoder_num = ffmpegdec->context->sample_aspect_ratio.num;
> -+    decoder_denom = ffmpegdec->context->sample_aspect_ratio.den;
> -+    decoder_par_set = TRUE;
> -+    GST_DEBUG_OBJECT (ffmpegdec, "Decoder PAR: %d:%d", decoder_num,
> -+        decoder_denom);
> -+  }
> -+
> -+  GST_OBJECT_UNLOCK (ffmpegdec);
> -+
> -+  if (!demuxer_par_set && !decoder_par_set)
> -+    goto no_par;
> -+
> -+  if (demuxer_par_set && !decoder_par_set)
> -+    goto use_demuxer_par;
> -+
> -+  if (decoder_par_set && !demuxer_par_set)
> -+    goto use_decoder_par;
> -+
> -+  /* Both the demuxer and the decoder provide a PAR. If one of
> -+   * the two PARs is 1:1 and the other one is not, use the one
> -+   * that is not 1:1. */
> -+  if (demuxer_num == demuxer_denom && decoder_num != decoder_denom)
> -+    goto use_decoder_par;
> -+
> -+  if (decoder_num == decoder_denom && demuxer_num != demuxer_denom)
> -+    goto use_demuxer_par;
> -+
> -+  /* Both PARs are non-1:1, so use the PAR provided by the demuxer */
> -+  goto use_demuxer_par;
> -+
> -+use_decoder_par:
> -+  {
> -+    GST_DEBUG_OBJECT (ffmpegdec,
> -+        "Setting decoder provided pixel-aspect-ratio of %u:%u", decoder_num,
> -+        decoder_denom);
> -+    gst_structure_set (s, "pixel-aspect-ratio", GST_TYPE_FRACTION, decoder_num,
> -+        decoder_denom, NULL);
> -+    return;
> -+  }
> -+
> -+use_demuxer_par:
> -+  {
> -+    GST_DEBUG_OBJECT (ffmpegdec,
> -+        "Setting demuxer provided pixel-aspect-ratio of %u:%u", demuxer_num,
> -+        demuxer_denom);
> -+    gst_structure_set (s, "pixel-aspect-ratio", GST_TYPE_FRACTION, demuxer_num,
> -+        demuxer_denom, NULL);
> -+    return;
> -+  }
> -+no_par:
> -+  {
> -+    GST_DEBUG_OBJECT (ffmpegdec,
> -+        "Neither demuxer nor codec provide a pixel-aspect-ratio");
> -+    return;
> -+  }
> -+}
> -+
> -+static gboolean
> -+gst_ffmpegdec_negotiate (GstFFMpegDec * ffmpegdec, gboolean force)
> -+{
> -+  GstFFMpegDecClass *oclass;
> -+  GstCaps *caps;
> -+
> -+  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> -+
> -+  switch (oclass->in_plugin->type) {
> -+    case AVMEDIA_TYPE_VIDEO:
> -+      if (!force && ffmpegdec->format.video.width == ffmpegdec->context->width
> -+          && ffmpegdec->format.video.height == ffmpegdec->context->height
> -+          && ffmpegdec->format.video.fps_n == ffmpegdec->format.video.old_fps_n
> -+          && ffmpegdec->format.video.fps_d == ffmpegdec->format.video.old_fps_d
> -+          && ffmpegdec->format.video.pix_fmt == ffmpegdec->context->pix_fmt
> -+          && ffmpegdec->format.video.par_n ==
> -+          ffmpegdec->context->sample_aspect_ratio.num
> -+          && ffmpegdec->format.video.par_d ==
> -+          ffmpegdec->context->sample_aspect_ratio.den)
> -+        return TRUE;
> -+      GST_DEBUG_OBJECT (ffmpegdec,
> -+          "Renegotiating video from %dx%d@ %d:%d PAR %d/%d fps to %dx%d@ %d:%d PAR %d/%d fps",
> -+          ffmpegdec->format.video.width, ffmpegdec->format.video.height,
> -+          ffmpegdec->format.video.par_n, ffmpegdec->format.video.par_d,
> -+          ffmpegdec->format.video.old_fps_n, ffmpegdec->format.video.old_fps_n,
> -+          ffmpegdec->context->width, ffmpegdec->context->height,
> -+          ffmpegdec->context->sample_aspect_ratio.num,
> -+          ffmpegdec->context->sample_aspect_ratio.den,
> -+          ffmpegdec->format.video.fps_n, ffmpegdec->format.video.fps_d);
> -+      ffmpegdec->format.video.width = ffmpegdec->context->width;
> -+      ffmpegdec->format.video.height = ffmpegdec->context->height;
> -+      ffmpegdec->format.video.old_fps_n = ffmpegdec->format.video.fps_n;
> -+      ffmpegdec->format.video.old_fps_d = ffmpegdec->format.video.fps_d;
> -+      ffmpegdec->format.video.pix_fmt = ffmpegdec->context->pix_fmt;
> -+      ffmpegdec->format.video.par_n =
> -+          ffmpegdec->context->sample_aspect_ratio.num;
> -+      ffmpegdec->format.video.par_d =
> -+          ffmpegdec->context->sample_aspect_ratio.den;
> -+      break;
> -+    case AVMEDIA_TYPE_AUDIO:
> -+    {
> -+      gint depth = av_smp_format_depth (ffmpegdec->context->sample_fmt);
> -+      if (!force && ffmpegdec->format.audio.samplerate ==
> -+          ffmpegdec->context->sample_rate &&
> -+          ffmpegdec->format.audio.channels == ffmpegdec->context->channels &&
> -+          ffmpegdec->format.audio.depth == depth)
> -+        return TRUE;
> -+      GST_DEBUG_OBJECT (ffmpegdec,
> -+          "Renegotiating audio from %dHz@%dchannels (%d) to %dHz@%dchannels (%d)",
> -+          ffmpegdec->format.audio.samplerate, ffmpegdec->format.audio.channels,
> -+          ffmpegdec->format.audio.depth,
> -+          ffmpegdec->context->sample_rate, ffmpegdec->context->channels, depth);
> -+      ffmpegdec->format.audio.samplerate = ffmpegdec->context->sample_rate;
> -+      ffmpegdec->format.audio.channels = ffmpegdec->context->channels;
> -+      ffmpegdec->format.audio.depth = depth;
> -+    }
> -+      break;
> -+    default:
> -+      break;
> -+  }
> -+
> -+  caps = gst_ffmpeg_codectype_to_caps (oclass->in_plugin->type,
> -+      ffmpegdec->context, oclass->in_plugin->id, FALSE);
> -+
> -+  if (caps == NULL)
> -+    goto no_caps;
> -+
> -+  switch (oclass->in_plugin->type) {
> -+    case AVMEDIA_TYPE_VIDEO:
> -+    {
> -+      gint width, height;
> -+      gboolean interlaced;
> -+
> -+      width = ffmpegdec->format.video.clip_width;
> -+      height = ffmpegdec->format.video.clip_height;
> -+      interlaced = ffmpegdec->format.video.interlaced;
> -+
> -+      if (width != -1 && height != -1) {
> -+        /* overwrite the output size with the dimension of the
> -+         * clipping region but only if they are smaller. */
> -+        if (width < ffmpegdec->context->width)
> -+          gst_caps_set_simple (caps, "width", G_TYPE_INT, width, NULL);
> -+        if (height < ffmpegdec->context->height)
> -+          gst_caps_set_simple (caps, "height", G_TYPE_INT, height, NULL);
> -+      }
> -+      gst_caps_set_simple (caps, "interlaced", G_TYPE_BOOLEAN, interlaced,
> -+          NULL);
> -+
> -+      /* If a demuxer provided a framerate then use it (#313970) */
> -+      if (ffmpegdec->format.video.fps_n != -1) {
> -+        gst_caps_set_simple (caps, "framerate",
> -+            GST_TYPE_FRACTION, ffmpegdec->format.video.fps_n,
> -+            ffmpegdec->format.video.fps_d, NULL);
> -+      }
> -+      gst_ffmpegdec_add_pixel_aspect_ratio (ffmpegdec,
> -+          gst_caps_get_structure (caps, 0));
> -+      break;
> -+    }
> -+    case AVMEDIA_TYPE_AUDIO:
> -+    {
> -+      break;
> -+    }
> -+    default:
> -+      break;
> -+  }
> -+
> -+  if (!gst_pad_set_caps (ffmpegdec->srcpad, caps))
> -+    goto caps_failed;
> -+
> -+  gst_caps_unref (caps);
> -+
> -+  return TRUE;
> -+
> -+  /* ERRORS */
> -+no_caps:
> -+  {
> -+#ifdef HAVE_FFMPEG_UNINSTALLED
> -+    /* using internal ffmpeg snapshot */
> -+    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
> -+        ("Could not find GStreamer caps mapping for FFmpeg codec '%s'.",
> -+            oclass->in_plugin->name), (NULL));
> -+#else
> -+    /* using external ffmpeg */
> -+    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
> -+        ("Could not find GStreamer caps mapping for FFmpeg codec '%s', and "
> -+            "you are using an external libavcodec. This is most likely due to "
> -+            "a packaging problem and/or libavcodec having been upgraded to a "
> -+            "version that is not compatible with this version of "
> -+            "gstreamer-ffmpeg. Make sure your gstreamer-ffmpeg and libavcodec "
> -+            "packages come from the same source/repository.",
> -+            oclass->in_plugin->name), (NULL));
> -+#endif
> -+    return FALSE;
> -+  }
> -+caps_failed:
> -+  {
> -+    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
> -+        ("Could not set caps for ffmpeg decoder (%s), not fixed?",
> -+            oclass->in_plugin->name));
> -+    gst_caps_unref (caps);
> -+
> -+    return FALSE;
> -+  }
> -+}
> -+
> -+/* perform qos calculations before decoding the next frame.
> -+ *
> -+ * Sets the skip_frame flag and if things are really bad, skips to the next
> -+ * keyframe.
> -+ *
> -+ * Returns TRUE if the frame should be decoded, FALSE if the frame can be dropped
> -+ * entirely.
> -+ */
> -+static gboolean
> -+gst_ffmpegdec_do_qos (GstFFMpegDec * ffmpegdec, GstClockTime timestamp,
> -+    gboolean * mode_switch)
> -+{
> -+  GstClockTimeDiff diff;
> -+  gdouble proportion;
> -+  GstClockTime qostime, earliest_time;
> -+  gboolean res = TRUE;
> -+
> -+  *mode_switch = FALSE;
> -+
> -+  /* no timestamp, can't do QoS */
> -+  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (timestamp)))
> -+    goto no_qos;
> -+
> -+  /* get latest QoS observation values */
> -+  gst_ffmpegdec_read_qos (ffmpegdec, &proportion, &earliest_time);
> -+
> -+  /* skip qos if we have no observation (yet) */
> -+  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (earliest_time))) {
> -+    /* no skip_frame initialy */
> -+    ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
> -+    goto no_qos;
> -+  }
> -+
> -+  /* qos is done on running time of the timestamp */
> -+  qostime = gst_segment_to_running_time (&ffmpegdec->segment, GST_FORMAT_TIME,
> -+      timestamp);
> -+
> -+  /* timestamp can be out of segment, then we don't do QoS */
> -+  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (qostime)))
> -+    goto no_qos;
> -+
> -+  /* see how our next timestamp relates to the latest qos timestamp. negative
> -+   * values mean we are early, positive values mean we are too late. */
> -+  diff = GST_CLOCK_DIFF (qostime, earliest_time);
> -+
> -+  GST_DEBUG_OBJECT (ffmpegdec, "QOS: qostime %" GST_TIME_FORMAT
> -+      ", earliest %" GST_TIME_FORMAT, GST_TIME_ARGS (qostime),
> -+      GST_TIME_ARGS (earliest_time));
> -+
> -+  /* if we using less than 40% of the available time, we can try to
> -+   * speed up again when we were slow. */
> -+  if (proportion < 0.4 && diff < 0) {
> -+    goto normal_mode;
> -+  } else {
> -+    if (diff >= 0) {
> -+      /* we're too slow, try to speed up */
> -+      /* switch to skip_frame mode */
> -+      goto skip_frame;
> -+    }
> -+  }
> -+
> -+no_qos:
> -+  ffmpegdec->processed++;
> -+  return TRUE;
> -+
> -+normal_mode:
> -+  {
> -+    if (ffmpegdec->context->skip_frame != AVDISCARD_DEFAULT) {
> -+      ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
> -+      *mode_switch = TRUE;
> -+      GST_DEBUG_OBJECT (ffmpegdec, "QOS: normal mode %g < 0.4", proportion);
> -+    }
> -+    ffmpegdec->processed++;
> -+    return TRUE;
> -+  }
> -+skip_frame:
> -+  {
> -+    if (ffmpegdec->context->skip_frame != AVDISCARD_NONREF) {
> -+      ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
> -+      *mode_switch = TRUE;
> -+      GST_DEBUG_OBJECT (ffmpegdec,
> -+          "QOS: hurry up, diff %" G_GINT64_FORMAT " >= 0", diff);
> -+    }
> -+    goto drop_qos;
> -+  }
> -+drop_qos:
> -+  {
> -+    GstClockTime stream_time, jitter;
> -+    GstMessage *qos_msg;
> -+
> -+    ffmpegdec->dropped++;
> -+    stream_time =
> -+        gst_segment_to_stream_time (&ffmpegdec->segment, GST_FORMAT_TIME,
> -+        timestamp);
> -+    jitter = GST_CLOCK_DIFF (qostime, earliest_time);
> -+    qos_msg =
> -+        gst_message_new_qos (GST_OBJECT_CAST (ffmpegdec), FALSE, qostime,
> -+        stream_time, timestamp, GST_CLOCK_TIME_NONE);
> -+    gst_message_set_qos_values (qos_msg, jitter, proportion, 1000000);
> -+    gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
> -+        ffmpegdec->processed, ffmpegdec->dropped);
> -+    gst_element_post_message (GST_ELEMENT_CAST (ffmpegdec), qos_msg);
> -+
> -+    return res;
> -+  }
> -+}
> -+
> -+/* returns TRUE if buffer is within segment, else FALSE.
> -+ * if Buffer is on segment border, it's timestamp and duration will be clipped */
> -+static gboolean
> -+clip_video_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
> -+    GstClockTime in_dur)
> -+{
> -+  gboolean res = TRUE;
> -+  gint64 cstart, cstop;
> -+  GstClockTime stop;
> -+
> -+  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 (G_UNLIKELY (dec->segment.format != GST_FORMAT_TIME))
> -+    goto beach;
> -+
> -+  /* we need a start time */
> -+  if (G_UNLIKELY (!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 */
> -+  res =
> -+      gst_segment_clip (&dec->segment, GST_FORMAT_TIME, in_ts, stop, &cstart,
> -+      &cstop);
> -+  if (G_UNLIKELY (!res))
> -+    goto beach;
> -+
> -+  /* we're pretty sure the duration of this buffer is not till the end of this
> -+   * segment (which _clip will assume when the stop is -1) */
> -+  if (stop == GST_CLOCK_TIME_NONE)
> -+    cstop = GST_CLOCK_TIME_NONE;
> -+
> -+  /* 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;
> -+
> -+  GST_LOG_OBJECT (dec,
> -+      "clipped timestamp:%" GST_TIME_FORMAT " , duration:%" GST_TIME_FORMAT,
> -+      GST_TIME_ARGS (cstart), GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
> -+
> -+beach:
> -+  GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
> -+  return res;
> -+}
> -+
> -+
> -+/* get an outbuf buffer with the current picture */
> -+static GstFlowReturn
> -+get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
> -+{
> -+  GstFlowReturn ret;
> -+
> -+  ret = GST_FLOW_OK;
> -+  *outbuf = NULL;
> -+
> -+  if (ffmpegdec->picture->opaque != NULL) {
> -+    /* we allocated a picture already for ffmpeg to decode into, let's pick it
> -+     * up and use it now. */
> -+    *outbuf = (GstBuffer *) ffmpegdec->picture->opaque;
> -+    GST_LOG_OBJECT (ffmpegdec, "using opaque buffer %p", *outbuf);
> -+#ifndef EXTRA_REF
> -+    gst_buffer_ref (*outbuf);
> -+#endif
> -+  } else {
> -+    AVPicture pic, *outpic;
> -+    gint width, height;
> -+
> -+    GST_LOG_OBJECT (ffmpegdec, "get output buffer");
> -+
> -+    /* figure out size of output buffer, this is the clipped output size because
> -+     * we will copy the picture into it but only when the clipping region is
> -+     * smaller than the actual picture size. */
> -+    if ((width = ffmpegdec->format.video.clip_width) == -1)
> -+      width = ffmpegdec->context->width;
> -+    else if (width > ffmpegdec->context->width)
> -+      width = ffmpegdec->context->width;
> -+
> -+    if ((height = ffmpegdec->format.video.clip_height) == -1)
> -+      height = ffmpegdec->context->height;
> -+    else if (height > ffmpegdec->context->height)
> -+      height = ffmpegdec->context->height;
> -+
> -+    GST_LOG_OBJECT (ffmpegdec, "clip width %d/height %d", width, height);
> -+
> -+    ret = alloc_output_buffer (ffmpegdec, outbuf, width, height);
> -+    if (G_UNLIKELY (ret != GST_FLOW_OK))
> -+      goto alloc_failed;
> -+
> -+    /* original ffmpeg code does not handle odd sizes correctly.
> -+     * This patched up version does */
> -+    gst_ffmpeg_avpicture_fill (&pic, GST_BUFFER_DATA (*outbuf),
> -+        ffmpegdec->context->pix_fmt, width, height);
> -+
> -+    outpic = (AVPicture *) ffmpegdec->picture;
> -+
> -+    GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", outpic->linesize[0],
> -+        outpic->linesize[1], outpic->linesize[2]);
> -+    GST_LOG_OBJECT (ffmpegdec, "data %u %u %u", 0,
> -+        (guint) (outpic->data[1] - outpic->data[0]),
> -+        (guint) (outpic->data[2] - outpic->data[0]));
> -+
> -+    av_picture_copy (&pic, outpic, ffmpegdec->context->pix_fmt, width, height);
> -+  }
> -+  ffmpegdec->picture->reordered_opaque = -1;
> -+
> -+  return ret;
> -+
> -+  /* special cases */
> -+alloc_failed:
> -+  {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "pad_alloc failed");
> -+    return ret;
> -+  }
> -+}
> -+
> -+static void
> -+clear_queued (GstFFMpegDec * ffmpegdec)
> -+{
> -+  g_list_foreach (ffmpegdec->queued, (GFunc) gst_mini_object_unref, NULL);
> -+  g_list_free (ffmpegdec->queued);
> -+  ffmpegdec->queued = NULL;
> -+}
> -+
> -+static GstFlowReturn
> -+flush_queued (GstFFMpegDec * ffmpegdec)
> -+{
> -+  GstFlowReturn res = GST_FLOW_OK;
> -+
> -+  while (ffmpegdec->queued) {
> -+    GstBuffer *buf = GST_BUFFER_CAST (ffmpegdec->queued->data);
> -+
> -+    GST_LOG_OBJECT (ffmpegdec, "pushing buffer %p, offset %"
> -+        G_GUINT64_FORMAT ", timestamp %"
> -+        GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT, buf,
> -+        GST_BUFFER_OFFSET (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 (ffmpegdec->srcpad, buf);
> -+
> -+    ffmpegdec->queued =
> -+        g_list_delete_link (ffmpegdec->queued, ffmpegdec->queued);
> -+  }
> -+  return res;
> -+}
> -+
> -+static void
> -+gst_avpacket_init (AVPacket * packet, guint8 * data, guint size)
> -+{
> -+  memset (packet, 0, sizeof (AVPacket));
> -+  packet->data = data;
> -+  packet->size = size;
> -+}
> -+
> -+/* gst_ffmpegdec_[video|audio]_frame:
> -+ * ffmpegdec:
> -+ * data: pointer to the data to decode
> -+ * size: size of data in bytes
> -+ * in_timestamp: incoming timestamp.
> -+ * in_duration: incoming duration.
> -+ * in_offset: incoming offset (frame number).
> -+ * outbuf: outgoing buffer. Different from NULL ONLY if it contains decoded data.
> -+ * ret: Return flow.
> -+ *
> -+ * Returns: number of bytes used in decoding. The check for successful decode is
> -+ *   outbuf being non-NULL.
> -+ */
> -+static gint
> -+gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
> -+    guint8 * data, guint size,
> -+    const GstTSInfo * dec_info, GstBuffer ** outbuf, GstFlowReturn * ret)
> -+{
> -+  gint len = -1;
> -+  gint have_data;
> -+  gboolean mode_switch;
> -+  gboolean decode;
> -+  gint skip_frame = AVDISCARD_DEFAULT;
> -+  GstClockTime out_timestamp, out_duration, out_pts;
> -+  gint64 out_offset;
> -+  const GstTSInfo *out_info;
> -+  AVPacket packet;
> -+
> -+  *ret = GST_FLOW_OK;
> -+  *outbuf = NULL;
> -+
> -+  ffmpegdec->context->opaque = ffmpegdec;
> -+
> -+  /* in case we skip frames */
> -+  ffmpegdec->picture->pict_type = -1;
> -+
> -+  /* run QoS code, we don't stop decoding the frame when we are late because
> -+   * else we might skip a reference frame */
> -+  decode = gst_ffmpegdec_do_qos (ffmpegdec, dec_info->timestamp, &mode_switch);
> -+
> -+  if (ffmpegdec->is_realvideo && data != NULL) {
> -+    gint slice_count;
> -+    gint i;
> -+
> -+    /* setup the slice table for realvideo */
> -+    if (ffmpegdec->context->slice_offset == NULL)
> -+      ffmpegdec->context->slice_offset = g_malloc (sizeof (guint32) * 1000);
> -+
> -+    slice_count = (*data++) + 1;
> -+    ffmpegdec->context->slice_count = slice_count;
> -+
> -+    for (i = 0; i < slice_count; i++) {
> -+      data += 4;
> -+      ffmpegdec->context->slice_offset[i] = GST_READ_UINT32_LE (data);
> -+      data += 4;
> -+    }
> -+  }
> -+
> -+  if (!decode) {
> -+    /* no decoding needed, save previous skip_frame value and brutely skip
> -+     * decoding everything */
> -+    skip_frame = ffmpegdec->context->skip_frame;
> -+    ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
> -+  }
> -+
> -+  /* save reference to the timing info */
> -+  ffmpegdec->context->reordered_opaque = (gint64) dec_info->idx;
> -+  ffmpegdec->picture->reordered_opaque = (gint64) dec_info->idx;
> -+
> -+  GST_DEBUG_OBJECT (ffmpegdec, "stored opaque values idx %d", dec_info->idx);
> -+
> -+  /* now decode the frame */
> -+  gst_avpacket_init (&packet, data, size);
> -+  len = avcodec_decode_video2 (ffmpegdec->context,
> -+      ffmpegdec->picture, &have_data, &packet);
> -+
> -+  /* restore previous state */
> -+  if (!decode)
> -+    ffmpegdec->context->skip_frame = skip_frame;
> -+
> -+  GST_DEBUG_OBJECT (ffmpegdec, "after decode: len %d, have_data %d",
> -+      len, have_data);
> -+
> -+  /* when we are in skip_frame mode, don't complain when ffmpeg returned
> -+   * no data because we told it to skip stuff. */
> -+  if (len < 0 && (mode_switch || ffmpegdec->context->skip_frame))
> -+    len = 0;
> -+
> -+  if (len > 0 && have_data <= 0 && (mode_switch
> -+          || ffmpegdec->context->skip_frame)) {
> -+    /* we consumed some bytes but nothing decoded and we are skipping frames,
> -+     * disable the interpollation of DTS timestamps */
> -+    ffmpegdec->last_out = -1;
> -+  }
> -+
> -+  /* no data, we're done */
> -+  if (len < 0 || have_data <= 0)
> -+    goto beach;
> -+
> -+  /* get the output picture timing info again */
> -+  out_info = gst_ts_info_get (ffmpegdec, ffmpegdec->picture->reordered_opaque);
> -+  out_pts = out_info->timestamp;
> -+  out_duration = out_info->duration;
> -+  out_offset = out_info->offset;
> -+
> -+  GST_DEBUG_OBJECT (ffmpegdec,
> -+      "pts %" G_GUINT64_FORMAT " duration %" G_GUINT64_FORMAT " offset %"
> -+      G_GINT64_FORMAT, out_pts, out_duration, out_offset);
> -+  GST_DEBUG_OBJECT (ffmpegdec, "picture: pts %" G_GUINT64_FORMAT,
> -+      (guint64) ffmpegdec->picture->pts);
> -+  GST_DEBUG_OBJECT (ffmpegdec, "picture: num %d",
> -+      ffmpegdec->picture->coded_picture_number);
> -+  GST_DEBUG_OBJECT (ffmpegdec, "picture: ref %d",
> -+      ffmpegdec->picture->reference);
> -+  GST_DEBUG_OBJECT (ffmpegdec, "picture: display %d",
> -+      ffmpegdec->picture->display_picture_number);
> -+  GST_DEBUG_OBJECT (ffmpegdec, "picture: opaque %p",
> -+      ffmpegdec->picture->opaque);
> -+  GST_DEBUG_OBJECT (ffmpegdec, "picture: reordered opaque %" G_GUINT64_FORMAT,
> -+      (guint64) ffmpegdec->picture->reordered_opaque);
> -+  GST_DEBUG_OBJECT (ffmpegdec, "repeat_pict:%d",
> -+      ffmpegdec->picture->repeat_pict);
> -+  GST_DEBUG_OBJECT (ffmpegdec, "interlaced_frame:%d",
> -+      ffmpegdec->picture->interlaced_frame);
> -+
> -+  if (G_UNLIKELY (ffmpegdec->picture->interlaced_frame !=
> -+          ffmpegdec->format.video.interlaced)) {
> -+    GST_WARNING ("Change in interlacing ! picture:%d, recorded:%d",
> -+        ffmpegdec->picture->interlaced_frame,
> -+        ffmpegdec->format.video.interlaced);
> -+    ffmpegdec->format.video.interlaced = ffmpegdec->picture->interlaced_frame;
> -+    gst_ffmpegdec_negotiate (ffmpegdec, TRUE);
> -+  }
> -+
> -+  /* Whether a frame is interlaced or not is unknown at the time of
> -+     buffer allocation, so caps on the buffer in opaque will have
> -+     the previous frame's interlaced flag set. So if interlacedness
> -+     has changed since allocation, we update the buffer (if any)
> -+     caps now with the correct interlaced flag. */
> -+  if (ffmpegdec->picture->opaque != NULL) {
> -+    GstBuffer *buffer = ffmpegdec->picture->opaque;
> -+    if (GST_BUFFER_CAPS (buffer) && GST_PAD_CAPS (ffmpegdec->srcpad)) {
> -+      GstStructure *s = gst_caps_get_structure (GST_BUFFER_CAPS (buffer), 0);
> -+      gboolean interlaced;
> -+      gboolean found = gst_structure_get_boolean (s, "interlaced", &interlaced);
> -+      if (!found || (!!interlaced != !!ffmpegdec->format.video.interlaced)) {
> -+        GST_DEBUG_OBJECT (ffmpegdec,
> -+            "Buffer interlacing does not match pad, updating");
> -+        buffer = gst_buffer_make_metadata_writable (buffer);
> -+        gst_buffer_set_caps (buffer, GST_PAD_CAPS (ffmpegdec->srcpad));
> -+        ffmpegdec->picture->opaque = buffer;
> -+      }
> -+    }
> -+  }
> -+
> -+  /* check that the timestamps go upwards */
> -+  if (ffmpegdec->last_out != -1 && ffmpegdec->last_out > out_pts) {
> -+    /* timestamps go backwards, this means frames were reordered and we must
> -+     * be dealing with DTS as the buffer timestamps */
> -+    if (!ffmpegdec->reordered_out) {
> -+      GST_DEBUG_OBJECT (ffmpegdec, "detected reordered out timestamps");
> -+      ffmpegdec->reordered_out = TRUE;
> -+    }
> -+    if (ffmpegdec->reordered_in) {
> -+      /* we reset the input reordering here because we want to recover from an
> -+       * occasionally wrong reordered input timestamp */
> -+      GST_DEBUG_OBJECT (ffmpegdec, "assuming DTS input timestamps");
> -+      ffmpegdec->reordered_in = FALSE;
> -+    }
> -+  }
> -+
> -+  if (out_pts == 0 && out_pts == ffmpegdec->last_out) {
> -+    GST_LOG_OBJECT (ffmpegdec, "ffmpeg returns 0 timestamps, ignoring");
> -+    /* some codecs only output 0 timestamps, when that happens, make us select an
> -+     * output timestamp based on the input timestamp. We do this by making the
> -+     * ffmpeg timestamp and the interpollated next timestamp invalid. */
> -+    out_pts = -1;
> -+    ffmpegdec->next_out = -1;
> -+  } else
> -+    ffmpegdec->last_out = out_pts;
> -+
> -+  /* we assume DTS as input timestamps unless we see reordered input
> -+   * timestamps */
> -+  if (!ffmpegdec->reordered_in && ffmpegdec->reordered_out) {
> -+    /* PTS and DTS are the same for keyframes */
> -+    if (ffmpegdec->next_out != -1) {
> -+      /* interpolate all timestamps except for keyframes, FIXME, this is
> -+       * wrong when QoS is active. */
> -+      GST_DEBUG_OBJECT (ffmpegdec, "interpolate timestamps");
> -+      out_pts = -1;
> -+      out_offset = -1;
> -+    }
> -+  }
> -+
> -+  /* get a handle to the output buffer */
> -+  *ret = get_output_buffer (ffmpegdec, outbuf);
> -+  if (G_UNLIKELY (*ret != GST_FLOW_OK))
> -+    goto no_output;
> -+
> -+  /*
> -+   * Timestamps:
> -+   *
> -+   *  1) Copy picture timestamp if valid
> -+   *  2) else interpolate from previous output timestamp
> -+   *  3) else copy input timestamp
> -+   */
> -+  out_timestamp = -1;
> -+  if (out_pts != -1) {
> -+    /* Get (interpolated) timestamp from FFMPEG */
> -+    out_timestamp = (GstClockTime) out_pts;
> -+    GST_LOG_OBJECT (ffmpegdec, "using timestamp %" GST_TIME_FORMAT
> -+        " returned by ffmpeg", GST_TIME_ARGS (out_timestamp));
> -+  }
> -+  if (!GST_CLOCK_TIME_IS_VALID (out_timestamp) && ffmpegdec->next_out != -1) {
> -+    out_timestamp = ffmpegdec->next_out;
> -+    GST_LOG_OBJECT (ffmpegdec, "using next timestamp %" GST_TIME_FORMAT,
> -+        GST_TIME_ARGS (out_timestamp));
> -+  }
> -+  if (!GST_CLOCK_TIME_IS_VALID (out_timestamp)) {
> -+    out_timestamp = dec_info->timestamp;
> -+    GST_LOG_OBJECT (ffmpegdec, "using in timestamp %" GST_TIME_FORMAT,
> -+        GST_TIME_ARGS (out_timestamp));
> -+  }
> -+  GST_BUFFER_TIMESTAMP (*outbuf) = out_timestamp;
> -+
> -+  /*
> -+   * Offset:
> -+   *  0) Use stored input offset (from opaque)
> -+   *  1) Use value converted from timestamp if valid
> -+   *  2) Use input offset if valid
> -+   */
> -+  if (out_offset != GST_BUFFER_OFFSET_NONE) {
> -+    /* out_offset already contains the offset from ts_info */
> -+    GST_LOG_OBJECT (ffmpegdec, "Using offset returned by ffmpeg");
> -+  } else if (out_timestamp != GST_CLOCK_TIME_NONE) {
> -+    GstFormat out_fmt = GST_FORMAT_DEFAULT;
> -+    GST_LOG_OBJECT (ffmpegdec, "Using offset converted from timestamp");
> -+    /* FIXME, we should really remove this as it's not nice at all to do
> -+     * upstream queries for each frame to get the frame offset. We also can't
> -+     * really remove this because it is the only way of setting frame offsets
> -+     * on outgoing buffers. We should have metadata so that the upstream peer
> -+     * can set a frame number on the encoded data. */
> -+    gst_pad_query_peer_convert (ffmpegdec->sinkpad,
> -+        GST_FORMAT_TIME, out_timestamp, &out_fmt, &out_offset);
> -+  } else if (dec_info->offset != GST_BUFFER_OFFSET_NONE) {
> -+    /* FIXME, the input offset is input media specific and might not
> -+     * be the same for the output media. (byte offset as input, frame number
> -+     * as output, for example) */
> -+    GST_LOG_OBJECT (ffmpegdec, "using in_offset %" G_GINT64_FORMAT,
> -+        dec_info->offset);
> -+    out_offset = dec_info->offset;
> -+  } else {
> -+    GST_LOG_OBJECT (ffmpegdec, "no valid offset found");
> -+    out_offset = GST_BUFFER_OFFSET_NONE;
> -+  }
> -+  GST_BUFFER_OFFSET (*outbuf) = out_offset;
> -+
> -+  /*
> -+   * Duration:
> -+   *
> -+   *  1) Use reordered input duration if valid
> -+   *  2) Else use input duration
> -+   *  3) else use input framerate
> -+   *  4) else use ffmpeg framerate
> -+   */
> -+  if (GST_CLOCK_TIME_IS_VALID (out_duration)) {
> -+    /* We have a valid (reordered) duration */
> -+    GST_LOG_OBJECT (ffmpegdec, "Using duration returned by ffmpeg");
> -+  } else if (GST_CLOCK_TIME_IS_VALID (dec_info->duration)) {
> -+    GST_LOG_OBJECT (ffmpegdec, "using in_duration");
> -+    out_duration = dec_info->duration;
> -+  } else if (GST_CLOCK_TIME_IS_VALID (ffmpegdec->last_diff)) {
> -+    GST_LOG_OBJECT (ffmpegdec, "using last-diff");
> -+    out_duration = ffmpegdec->last_diff;
> -+  } else {
> -+    /* if we have an input framerate, use that */
> -+    if (ffmpegdec->format.video.fps_n != -1 &&
> -+        (ffmpegdec->format.video.fps_n != 1000 &&
> -+            ffmpegdec->format.video.fps_d != 1)) {
> -+      GST_LOG_OBJECT (ffmpegdec, "using input framerate for duration");
> -+      out_duration = gst_util_uint64_scale_int (GST_SECOND,
> -+          ffmpegdec->format.video.fps_d, ffmpegdec->format.video.fps_n);
> -+    } else {
> -+      /* don't try to use the decoder's framerate when it seems a bit abnormal,
> -+       * which we assume when den >= 1000... */
> -+      if (ffmpegdec->context->time_base.num != 0 &&
> -+          (ffmpegdec->context->time_base.den > 0 &&
> -+              ffmpegdec->context->time_base.den < 1000)) {
> -+        GST_LOG_OBJECT (ffmpegdec, "using decoder's framerate for duration");
> -+        out_duration = gst_util_uint64_scale_int (GST_SECOND,
> -+            ffmpegdec->context->time_base.num *
> -+            ffmpegdec->context->ticks_per_frame,
> -+            ffmpegdec->context->time_base.den);
> -+      } else {
> -+        GST_LOG_OBJECT (ffmpegdec, "no valid duration found");
> -+      }
> -+    }
> -+  }
> -+
> -+  /* Take repeat_pict into account */
> -+  if (GST_CLOCK_TIME_IS_VALID (out_duration)) {
> -+    out_duration += out_duration * ffmpegdec->picture->repeat_pict / 2;
> -+  }
> -+  GST_BUFFER_DURATION (*outbuf) = out_duration;
> -+
> -+  if (out_timestamp != -1 && out_duration != -1 && out_duration != 0)
> -+    ffmpegdec->next_out = out_timestamp + out_duration;
> -+  else
> -+    ffmpegdec->next_out = -1;
> -+
> -+  /* now see if we need to clip the buffer against the segment boundaries. */
> -+  if (G_UNLIKELY (!clip_video_buffer (ffmpegdec, *outbuf, out_timestamp,
> -+              out_duration)))
> -+    goto clipped;
> -+
> -+  if (ffmpegdec->picture->top_field_first)
> -+    GST_BUFFER_FLAG_SET (*outbuf, GST_VIDEO_BUFFER_TFF);
> -+
> -+
> -+beach:
> -+  GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
> -+      *ret, *outbuf, len);
> -+  return len;
> -+
> -+  /* special cases */
> -+no_output:
> -+  {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "no output buffer");
> -+    len = -1;
> -+    goto beach;
> -+  }
> -+clipped:
> -+  {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "buffer clipped");
> -+    gst_buffer_unref (*outbuf);
> -+    *outbuf = NULL;
> -+    goto beach;
> -+  }
> -+}
> -+
> -+/* returns TRUE if buffer is within segment, else FALSE.
> -+ * if Buffer is on segment border, it's timestamp and duration will be clipped */
> -+static gboolean
> -+clip_audio_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
> -+    GstClockTime in_dur)
> -+{
> -+  GstClockTime stop;
> -+  gint64 diff, ctime, cstop;
> -+  gboolean res = TRUE;
> -+
> -+  GST_LOG_OBJECT (dec,
> -+      "timestamp:%" GST_TIME_FORMAT ", duration:%" GST_TIME_FORMAT
> -+      ", size %u", GST_TIME_ARGS (in_ts), GST_TIME_ARGS (in_dur),
> -+      GST_BUFFER_SIZE (buf));
> -+
> -+  /* can't clip without TIME segment */
> -+  if (G_UNLIKELY (dec->segment.format != GST_FORMAT_TIME))
> -+    goto beach;
> -+
> -+  /* we need a start time */
> -+  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (in_ts)))
> -+    goto beach;
> -+
> -+  /* trust duration */
> -+  stop = in_ts + in_dur;
> -+
> -+  res = gst_segment_clip (&dec->segment, GST_FORMAT_TIME, in_ts, stop, &ctime,
> -+      &cstop);
> -+  if (G_UNLIKELY (!res))
> -+    goto out_of_segment;
> -+
> -+  /* see if some clipping happened */
> -+  if (G_UNLIKELY ((diff = ctime - in_ts) > 0)) {
> -+    /* bring clipped time to bytes */
> -+    diff =
> -+        gst_util_uint64_scale_int (diff, dec->format.audio.samplerate,
> -+        GST_SECOND) * (dec->format.audio.depth * dec->format.audio.channels);
> -+
> -+    GST_DEBUG_OBJECT (dec, "clipping start to %" GST_TIME_FORMAT " %"
> -+        G_GINT64_FORMAT " bytes", GST_TIME_ARGS (ctime), diff);
> -+
> -+    GST_BUFFER_SIZE (buf) -= diff;
> -+    GST_BUFFER_DATA (buf) += diff;
> -+  }
> -+  if (G_UNLIKELY ((diff = stop - cstop) > 0)) {
> -+    /* bring clipped time to bytes */
> -+    diff =
> -+        gst_util_uint64_scale_int (diff, dec->format.audio.samplerate,
> -+        GST_SECOND) * (dec->format.audio.depth * dec->format.audio.channels);
> -+
> -+    GST_DEBUG_OBJECT (dec, "clipping stop to %" GST_TIME_FORMAT " %"
> -+        G_GINT64_FORMAT " bytes", GST_TIME_ARGS (cstop), diff);
> -+
> -+    GST_BUFFER_SIZE (buf) -= diff;
> -+  }
> -+  GST_BUFFER_TIMESTAMP (buf) = ctime;
> -+  GST_BUFFER_DURATION (buf) = cstop - ctime;
> -+
> -+beach:
> -+  GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
> -+  return res;
> -+
> -+  /* ERRORS */
> -+out_of_segment:
> -+  {
> -+    GST_LOG_OBJECT (dec, "out of segment");
> -+    goto beach;
> -+  }
> -+}
> -+
> -+static gint
> -+gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec,
> -+    AVCodec * in_plugin, guint8 * data, guint size,
> -+    const GstTSInfo * dec_info, GstBuffer ** outbuf, GstFlowReturn * ret)
> -+{
> -+  gint len = -1;
> -+  gint have_data = AVCODEC_MAX_AUDIO_FRAME_SIZE;
> -+  GstClockTime out_timestamp, out_duration;
> -+  gint64 out_offset;
> -+  AVPacket packet;
> -+
> -+  GST_DEBUG_OBJECT (ffmpegdec,
> -+      "size:%d, offset:%" G_GINT64_FORMAT ", ts:%" GST_TIME_FORMAT ", dur:%"
> -+      GST_TIME_FORMAT ", ffmpegdec->next_out:%" GST_TIME_FORMAT, size,
> -+      dec_info->offset, GST_TIME_ARGS (dec_info->timestamp),
> -+      GST_TIME_ARGS (dec_info->duration), GST_TIME_ARGS (ffmpegdec->next_out));
> -+
> -+  *outbuf =
> -+      new_aligned_buffer (AVCODEC_MAX_AUDIO_FRAME_SIZE,
> -+      GST_PAD_CAPS (ffmpegdec->srcpad));
> -+
> -+  gst_avpacket_init (&packet, data, size);
> -+  len = avcodec_decode_audio3 (ffmpegdec->context,
> -+      (int16_t *) GST_BUFFER_DATA (*outbuf), &have_data, &packet);
> -+  GST_DEBUG_OBJECT (ffmpegdec,
> -+      "Decode audio: len=%d, have_data=%d", len, have_data);
> -+
> -+  if (len >= 0 && have_data > 0) {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "Creating output buffer");
> -+    if (!gst_ffmpegdec_negotiate (ffmpegdec, FALSE)) {
> -+      gst_buffer_unref (*outbuf);
> -+      *outbuf = NULL;
> -+      len = -1;
> -+      goto beach;
> -+    }
> -+
> -+    /* Buffer size */
> -+    GST_BUFFER_SIZE (*outbuf) = have_data;
> -+
> -+    /*
> -+     * Timestamps:
> -+     *
> -+     *  1) Copy input timestamp if valid
> -+     *  2) else interpolate from previous input timestamp
> -+     */
> -+    /* always take timestamps from the input buffer if any */
> -+    if (GST_CLOCK_TIME_IS_VALID (dec_info->timestamp)) {
> -+      out_timestamp = dec_info->timestamp;
> -+    } else {
> -+      out_timestamp = ffmpegdec->next_out;
> -+    }
> -+
> -+    /*
> -+     * Duration:
> -+     *
> -+     *  1) calculate based on number of samples
> -+     */
> -+    out_duration = gst_util_uint64_scale (have_data, GST_SECOND,
> -+        ffmpegdec->format.audio.depth * ffmpegdec->format.audio.channels *
> -+        ffmpegdec->format.audio.samplerate);
> -+
> -+    /* offset:
> -+     *
> -+     * Just copy
> -+     */
> -+    out_offset = dec_info->offset;
> -+
> -+    GST_DEBUG_OBJECT (ffmpegdec,
> -+        "Buffer created. Size:%d , timestamp:%" GST_TIME_FORMAT " , duration:%"
> -+        GST_TIME_FORMAT, have_data,
> -+        GST_TIME_ARGS (out_timestamp), GST_TIME_ARGS (out_duration));
> -+
> -+    GST_BUFFER_TIMESTAMP (*outbuf) = out_timestamp;
> -+    GST_BUFFER_DURATION (*outbuf) = out_duration;
> -+    GST_BUFFER_OFFSET (*outbuf) = out_offset;
> -+    gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (ffmpegdec->srcpad));
> -+
> -+    /* the next timestamp we'll use when interpolating */
> -+    if (GST_CLOCK_TIME_IS_VALID (out_timestamp))
> -+      ffmpegdec->next_out = out_timestamp + out_duration;
> -+
> -+    /* now see if we need to clip the buffer against the segment boundaries. */
> -+    if (G_UNLIKELY (!clip_audio_buffer (ffmpegdec, *outbuf, out_timestamp,
> -+                out_duration)))
> -+      goto clipped;
> -+
> -+  } else {
> -+    gst_buffer_unref (*outbuf);
> -+    *outbuf = NULL;
> -+  }
> -+
> -+  /* If we don't error out after the first failed read with the AAC decoder,
> -+   * we must *not* carry on pushing data, else we'll cause segfaults... */
> -+  if (len == -1 && (in_plugin->id == CODEC_ID_AAC
> -+          || in_plugin->id == CODEC_ID_AAC_LATM)) {
> -+    GST_ELEMENT_ERROR (ffmpegdec, STREAM, DECODE, (NULL),
> -+        ("Decoding of AAC stream by FFMPEG failed."));
> -+    *ret = GST_FLOW_ERROR;
> -+  }
> -+
> -+beach:
> -+  GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
> -+      *ret, *outbuf, len);
> -+  return len;
> -+
> -+  /* ERRORS */
> -+clipped:
> -+  {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "buffer clipped");
> -+    gst_buffer_unref (*outbuf);
> -+    *outbuf = NULL;
> -+    goto beach;
> -+  }
> -+}
> -+
> -+/* gst_ffmpegdec_frame:
> -+ * ffmpegdec:
> -+ * data: pointer to the data to decode
> -+ * size: size of data in bytes
> -+ * got_data: 0 if no data was decoded, != 0 otherwise.
> -+ * in_time: timestamp of data
> -+ * in_duration: duration of data
> -+ * ret: GstFlowReturn to return in the chain function
> -+ *
> -+ * Decode the given frame and pushes it downstream.
> -+ *
> -+ * Returns: Number of bytes used in decoding, -1 on error/failure.
> -+ */
> -+
> -+static gint
> -+gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec,
> -+    guint8 * data, guint size, gint * got_data, const GstTSInfo * dec_info,
> -+    GstFlowReturn * ret)
> -+{
> -+  GstFFMpegDecClass *oclass;
> -+  GstBuffer *outbuf = NULL;
> -+  gint have_data = 0, len = 0;
> -+
> -+  if (G_UNLIKELY (ffmpegdec->context->codec == NULL))
> -+    goto no_codec;
> -+
> -+  GST_LOG_OBJECT (ffmpegdec, "data:%p, size:%d, id:%d", data, size,
> -+      dec_info->idx);
> -+
> -+  *ret = GST_FLOW_OK;
> -+  ffmpegdec->context->frame_number++;
> -+
> -+  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> -+
> -+  switch (oclass->in_plugin->type) {
> -+    case AVMEDIA_TYPE_VIDEO:
> -+      len =
> -+          gst_ffmpegdec_video_frame (ffmpegdec, data, size, dec_info, &outbuf,
> -+          ret);
> -+      break;
> -+    case AVMEDIA_TYPE_AUDIO:
> -+      len =
> -+          gst_ffmpegdec_audio_frame (ffmpegdec, oclass->in_plugin, data, size,
> -+          dec_info, &outbuf, ret);
> -+
> -+      /* if we did not get an output buffer and we have a pending discont, don't
> -+       * clear the input timestamps, we will put them on the next buffer because
> -+       * else we might create the first buffer with a very big timestamp gap. */
> -+      if (outbuf == NULL && ffmpegdec->discont) {
> -+        GST_DEBUG_OBJECT (ffmpegdec, "no buffer but keeping timestamp");
> -+        ffmpegdec->clear_ts = FALSE;
> -+      }
> -+      break;
> -+    default:
> -+      GST_ERROR_OBJECT (ffmpegdec, "Asked to decode non-audio/video frame !");
> -+      g_assert_not_reached ();
> -+      break;
> -+  }
> -+
> -+  if (outbuf)
> -+    have_data = 1;
> -+
> -+  if (len < 0 || have_data < 0) {
> -+    GST_WARNING_OBJECT (ffmpegdec,
> -+        "ffdec_%s: decoding error (len: %d, have_data: %d)",
> -+        oclass->in_plugin->name, len, have_data);
> -+    *got_data = 0;
> -+    goto beach;
> -+  } else if (len == 0 && have_data == 0) {
> -+    *got_data = 0;
> -+    goto beach;
> -+  } else {
> -+    /* this is where I lost my last clue on ffmpeg... */
> -+    *got_data = 1;
> -+  }
> -+
> -+  if (outbuf) {
> -+    GST_LOG_OBJECT (ffmpegdec,
> -+        "Decoded data, now pushing buffer %p with offset %" G_GINT64_FORMAT
> -+        ", timestamp %" GST_TIME_FORMAT " and duration %" GST_TIME_FORMAT,
> -+        outbuf, GST_BUFFER_OFFSET (outbuf),
> -+        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
> -+        GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)));
> -+
> -+    /* mark pending discont */
> -+    if (ffmpegdec->discont) {
> -+      GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
> -+      ffmpegdec->discont = FALSE;
> -+    }
> -+
> -+    if (ffmpegdec->segment.rate > 0.0) {
> -+      /* and off we go */
> -+      *ret = gst_pad_push (ffmpegdec->srcpad, outbuf);
> -+    } else {
> -+      /* reverse playback, queue frame till later when we get a discont. */
> -+      GST_DEBUG_OBJECT (ffmpegdec, "queued frame");
> -+      ffmpegdec->queued = g_list_prepend (ffmpegdec->queued, outbuf);
> -+      *ret = GST_FLOW_OK;
> -+    }
> -+  } else {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "We didn't get a decoded buffer");
> -+  }
> -+
> -+beach:
> -+  return len;
> -+
> -+  /* ERRORS */
> -+no_codec:
> -+  {
> -+    GST_ERROR_OBJECT (ffmpegdec, "no codec context");
> -+    return -1;
> -+  }
> -+}
> -+
> -+static void
> -+gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec)
> -+{
> -+  GstFFMpegDecClass *oclass;
> -+
> -+  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> -+
> -+  if (oclass->in_plugin->capabilities & CODEC_CAP_DELAY) {
> -+    gint have_data, len, try = 0;
> -+
> -+    GST_LOG_OBJECT (ffmpegdec,
> -+        "codec has delay capabilities, calling until ffmpeg has drained everything");
> -+
> -+    do {
> -+      GstFlowReturn ret;
> -+
> -+      len =
> -+          gst_ffmpegdec_frame (ffmpegdec, NULL, 0, &have_data, &ts_info_none,
> -+          &ret);
> -+      if (len < 0 || have_data == 0)
> -+        break;
> -+    } while (try++ < 10);
> -+  }
> -+  if (ffmpegdec->segment.rate < 0.0) {
> -+    /* if we have some queued frames for reverse playback, flush them now */
> -+    flush_queued (ffmpegdec);
> -+  }
> -+}
> -+
> -+static void
> -+gst_ffmpegdec_flush_pcache (GstFFMpegDec * ffmpegdec)
> -+{
> -+  if (ffmpegdec->pctx) {
> -+    gint size, bsize;
> -+    guint8 *data;
> -+    guint8 bdata[FF_INPUT_BUFFER_PADDING_SIZE];
> -+
> -+    bsize = FF_INPUT_BUFFER_PADDING_SIZE;
> -+    memset (bdata, 0, bsize);
> -+
> -+    /* parse some dummy data to work around some ffmpeg weirdness where it keeps
> -+     * the previous pts around */
> -+    av_parser_parse2 (ffmpegdec->pctx, ffmpegdec->context,
> -+        &data, &size, bdata, bsize, -1, -1, -1);
> -+    ffmpegdec->pctx->pts = -1;
> -+    ffmpegdec->pctx->dts = -1;
> -+  }
> -+
> -+  if (ffmpegdec->pcache) {
> -+    gst_buffer_unref (ffmpegdec->pcache);
> -+    ffmpegdec->pcache = NULL;
> -+  }
> -+}
> -+
> -+static gboolean
> -+gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event)
> -+{
> -+  GstFFMpegDec *ffmpegdec;
> -+  gboolean ret = FALSE;
> -+
> -+  ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
> -+
> -+  GST_DEBUG_OBJECT (ffmpegdec, "Handling %s event",
> -+      GST_EVENT_TYPE_NAME (event));
> -+
> -+  switch (GST_EVENT_TYPE (event)) {
> -+    case GST_EVENT_EOS:
> -+    {
> -+      gst_ffmpegdec_drain (ffmpegdec);
> -+      break;
> -+    }
> -+    case GST_EVENT_FLUSH_STOP:
> -+    {
> -+      if (ffmpegdec->opened) {
> -+        avcodec_flush_buffers (ffmpegdec->context);
> -+      }
> -+      gst_ffmpegdec_reset_ts (ffmpegdec);
> -+      gst_ffmpegdec_reset_qos (ffmpegdec);
> -+      gst_ffmpegdec_flush_pcache (ffmpegdec);
> -+      gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
> -+      clear_queued (ffmpegdec);
> -+      break;
> -+    }
> -+    case GST_EVENT_NEWSEGMENT:
> -+    {
> -+      gboolean update;
> -+      GstFormat fmt;
> -+      gint64 start, stop, time;
> -+      gdouble rate, arate;
> -+
> -+      gst_event_parse_new_segment_full (event, &update, &rate, &arate, &fmt,
> -+          &start, &stop, &time);
> -+
> -+      switch (fmt) {
> -+        case GST_FORMAT_TIME:
> -+          /* fine, our native segment format */
> -+          break;
> -+        case GST_FORMAT_BYTES:
> -+        {
> -+          gint bit_rate;
> -+
> -+          bit_rate = ffmpegdec->context->bit_rate;
> -+
> -+          /* convert to time or fail */
> -+          if (!bit_rate)
> -+            goto no_bitrate;
> -+
> -+          GST_DEBUG_OBJECT (ffmpegdec, "bitrate: %d", bit_rate);
> -+
> -+          /* convert values to TIME */
> -+          if (start != -1)
> -+            start = gst_util_uint64_scale_int (start, GST_SECOND, bit_rate);
> -+          if (stop != -1)
> -+            stop = gst_util_uint64_scale_int (stop, GST_SECOND, bit_rate);
> -+          if (time != -1)
> -+            time = gst_util_uint64_scale_int (time, GST_SECOND, bit_rate);
> -+
> -+          /* unref old event */
> -+          gst_event_unref (event);
> -+
> -+          /* create new converted time segment */
> -+          fmt = GST_FORMAT_TIME;
> -+          /* FIXME, bitrate is not good enough too find a good stop, let's
> -+           * hope start and time were 0... meh. */
> -+          stop = -1;
> -+          event = gst_event_new_new_segment (update, rate, fmt,
> -+              start, stop, time);
> -+          break;
> -+        }
> -+        default:
> -+          /* invalid format */
> -+          goto invalid_format;
> -+      }
> -+
> -+      /* drain pending frames before trying to use the new segment, queued
> -+       * buffers belonged to the previous segment. */
> -+      if (ffmpegdec->context->codec)
> -+        gst_ffmpegdec_drain (ffmpegdec);
> -+
> -+      GST_DEBUG_OBJECT (ffmpegdec,
> -+          "NEWSEGMENT in time start %" GST_TIME_FORMAT " -- stop %"
> -+          GST_TIME_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
> -+
> -+      /* and store the values */
> -+      gst_segment_set_newsegment_full (&ffmpegdec->segment, update,
> -+          rate, arate, fmt, start, stop, time);
> -+      break;
> -+    }
> -+    default:
> -+      break;
> -+  }
> -+
> -+  /* and push segment downstream */
> -+  ret = gst_pad_push_event (ffmpegdec->srcpad, event);
> -+
> -+done:
> -+  gst_object_unref (ffmpegdec);
> -+
> -+  return ret;
> -+
> -+  /* ERRORS */
> -+no_bitrate:
> -+  {
> -+    GST_WARNING_OBJECT (ffmpegdec, "no bitrate to convert BYTES to TIME");
> -+    gst_event_unref (event);
> -+    goto done;
> -+  }
> -+invalid_format:
> -+  {
> -+    GST_WARNING_OBJECT (ffmpegdec, "unknown format received in NEWSEGMENT");
> -+    gst_event_unref (event);
> -+    goto done;
> -+  }
> -+}
> -+
> -+static GstFlowReturn
> -+gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
> -+{
> -+  GstFFMpegDec *ffmpegdec;
> -+  GstFFMpegDecClass *oclass;
> -+  guint8 *data, *bdata;
> -+  gint size, bsize, len, have_data;
> -+  GstFlowReturn ret = GST_FLOW_OK;
> -+  GstClockTime in_timestamp;
> -+  GstClockTime in_duration;
> -+  gboolean discont;
> -+  gint64 in_offset;
> -+  const GstTSInfo *in_info;
> -+  const GstTSInfo *dec_info;
> -+
> -+  ffmpegdec = (GstFFMpegDec *) (GST_PAD_PARENT (pad));
> -+
> -+  if (G_UNLIKELY (!ffmpegdec->opened))
> -+    goto not_negotiated;
> -+
> -+  discont = GST_BUFFER_IS_DISCONT (inbuf);
> -+
> -+  /* The discont flags marks a buffer that is not continuous with the previous
> -+   * buffer. This means we need to clear whatever data we currently have. We
> -+   * currently also wait for a new keyframe, which might be suboptimal in the
> -+   * case of a network error, better show the errors than to drop all data.. */
> -+  if (G_UNLIKELY (discont)) {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "received DISCONT");
> -+    /* drain what we have queued */
> -+    gst_ffmpegdec_drain (ffmpegdec);
> -+    gst_ffmpegdec_flush_pcache (ffmpegdec);
> -+    avcodec_flush_buffers (ffmpegdec->context);
> -+    ffmpegdec->discont = TRUE;
> -+    gst_ffmpegdec_reset_ts (ffmpegdec);
> -+  }
> -+  /* by default we clear the input timestamp after decoding each frame so that
> -+   * interpollation can work. */
> -+  ffmpegdec->clear_ts = TRUE;
> -+
> -+  oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> -+
> -+  /* parse cache joining. If there is cached data */
> -+  if (ffmpegdec->pcache) {
> -+    /* join with previous data */
> -+    GST_LOG_OBJECT (ffmpegdec, "join parse cache");
> -+    inbuf = gst_buffer_join (ffmpegdec->pcache, inbuf);
> -+    /* no more cached data, we assume we can consume the complete cache */
> -+    ffmpegdec->pcache = NULL;
> -+  }
> -+
> -+  in_timestamp = GST_BUFFER_TIMESTAMP (inbuf);
> -+  in_duration = GST_BUFFER_DURATION (inbuf);
> -+  in_offset = GST_BUFFER_OFFSET (inbuf);
> -+
> -+  /* get handle to timestamp info, we can pass this around to ffmpeg */
> -+  in_info = gst_ts_info_store (ffmpegdec, in_timestamp, in_duration, in_offset);
> -+
> -+  if (in_timestamp != -1) {
> -+    /* check for increasing timestamps if they are jumping backwards, we
> -+     * probably are dealing with PTS as timestamps */
> -+    if (!ffmpegdec->reordered_in && ffmpegdec->last_in != -1) {
> -+      if (in_timestamp < ffmpegdec->last_in) {
> -+        GST_LOG_OBJECT (ffmpegdec, "detected reordered input timestamps");
> -+        ffmpegdec->reordered_in = TRUE;
> -+        ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
> -+      } else if (in_timestamp > ffmpegdec->last_in) {
> -+        GstClockTime diff;
> -+        /* keep track of timestamp diff to estimate duration */
> -+        diff = in_timestamp - ffmpegdec->last_in;
> -+        /* need to scale with amount of frames in the interval */
> -+        if (ffmpegdec->last_frames)
> -+          diff /= ffmpegdec->last_frames;
> -+
> -+        GST_LOG_OBJECT (ffmpegdec, "estimated duration %" GST_TIME_FORMAT " %u",
> -+            GST_TIME_ARGS (diff), ffmpegdec->last_frames);
> -+
> -+        ffmpegdec->last_diff = diff;
> -+      }
> -+    }
> -+    ffmpegdec->last_in = in_timestamp;
> -+    ffmpegdec->last_frames = 0;
> -+  }
> -+
> -+  GST_LOG_OBJECT (ffmpegdec,
> -+      "Received new data of size %u, offset:%" G_GUINT64_FORMAT ", ts:%"
> -+      GST_TIME_FORMAT ", dur:%" GST_TIME_FORMAT ", info %d",
> -+      GST_BUFFER_SIZE (inbuf), GST_BUFFER_OFFSET (inbuf),
> -+      GST_TIME_ARGS (in_timestamp), GST_TIME_ARGS (in_duration), in_info->idx);
> -+
> -+  /* workarounds, functions write to buffers:
> -+   *  libavcodec/svq1.c:svq1_decode_frame writes to the given buffer.
> -+   *  libavcodec/svq3.c:svq3_decode_slice_header too.
> -+   * ffmpeg devs know about it and will fix it (they said). */
> -+  if (oclass->in_plugin->id == CODEC_ID_SVQ1 ||
> -+      oclass->in_plugin->id == CODEC_ID_SVQ3) {
> -+    inbuf = gst_buffer_make_writable (inbuf);
> -+  }
> -+
> -+  bdata = GST_BUFFER_DATA (inbuf);
> -+  bsize = GST_BUFFER_SIZE (inbuf);
> -+
> -+  if (ffmpegdec->do_padding) {
> -+    /* add padding */
> -+    if (ffmpegdec->padded_size < bsize + FF_INPUT_BUFFER_PADDING_SIZE) {
> -+      ffmpegdec->padded_size = bsize + FF_INPUT_BUFFER_PADDING_SIZE;
> -+      ffmpegdec->padded = g_realloc (ffmpegdec->padded, ffmpegdec->padded_size);
> -+      GST_LOG_OBJECT (ffmpegdec, "resized padding buffer to %d",
> -+          ffmpegdec->padded_size);
> -+    }
> -+    memcpy (ffmpegdec->padded, bdata, bsize);
> -+    memset (ffmpegdec->padded + bsize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
> -+
> -+    bdata = ffmpegdec->padded;
> -+  }
> -+
> -+  do {
> -+    guint8 tmp_padding[FF_INPUT_BUFFER_PADDING_SIZE];
> -+
> -+    /* parse, if at all possible */
> -+    if (ffmpegdec->pctx) {
> -+      gint res;
> -+
> -+      GST_LOG_OBJECT (ffmpegdec,
> -+          "Calling av_parser_parse2 with offset %" G_GINT64_FORMAT ", ts:%"
> -+          GST_TIME_FORMAT " size %d", in_offset, GST_TIME_ARGS (in_timestamp),
> -+          bsize);
> -+
> -+      /* feed the parser. We pass the timestamp info so that we can recover all
> -+       * info again later */
> -+      res = av_parser_parse2 (ffmpegdec->pctx, ffmpegdec->context,
> -+          &data, &size, bdata, bsize, in_info->idx, in_info->idx, in_offset);
> -+
> -+      GST_LOG_OBJECT (ffmpegdec,
> -+          "parser returned res %d and size %d, id %" G_GINT64_FORMAT, res, size,
> -+          ffmpegdec->pctx->pts);
> -+
> -+      /* store pts for decoding */
> -+      if (ffmpegdec->pctx->pts != AV_NOPTS_VALUE && ffmpegdec->pctx->pts != -1)
> -+        dec_info = gst_ts_info_get (ffmpegdec, ffmpegdec->pctx->pts);
> -+      else {
> -+        /* ffmpeg sometimes loses track after a flush, help it by feeding a
> -+         * valid start time */
> -+        ffmpegdec->pctx->pts = in_info->idx;
> -+        ffmpegdec->pctx->dts = in_info->idx;
> -+        dec_info = in_info;
> -+      }
> -+
> -+      GST_LOG_OBJECT (ffmpegdec, "consuming %d bytes. id %d", size,
> -+          dec_info->idx);
> -+
> -+      if (res) {
> -+        /* there is output, set pointers for next round. */
> -+        bsize -= res;
> -+        bdata += res;
> -+      } else {
> -+        /* Parser did not consume any data, make sure we don't clear the
> -+         * timestamp for the next round */
> -+        ffmpegdec->clear_ts = FALSE;
> -+      }
> -+
> -+      /* if there is no output, we must break and wait for more data. also the
> -+       * timestamp in the context is not updated. */
> -+      if (size == 0) {
> -+        if (bsize > 0)
> -+          continue;
> -+        else
> -+          break;
> -+      }
> -+    } else {
> -+      data = bdata;
> -+      size = bsize;
> -+
> -+      dec_info = in_info;
> -+    }
> -+
> -+    if (ffmpegdec->do_padding) {
> -+      /* add temporary padding */
> -+      memcpy (tmp_padding, data + size, FF_INPUT_BUFFER_PADDING_SIZE);
> -+      memset (data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
> -+    }
> -+
> -+    /* decode a frame of audio/video now */
> -+    len =
> -+        gst_ffmpegdec_frame (ffmpegdec, data, size, &have_data, dec_info, &ret);
> -+
> -+    if (ffmpegdec->do_padding) {
> -+      memcpy (data + size, tmp_padding, FF_INPUT_BUFFER_PADDING_SIZE);
> -+    }
> -+
> -+    if (ret != GST_FLOW_OK) {
> -+      GST_LOG_OBJECT (ffmpegdec, "breaking because of flow ret %s",
> -+          gst_flow_get_name (ret));
> -+      /* bad flow retun, make sure we discard all data and exit */
> -+      bsize = 0;
> -+      break;
> -+    }
> -+    if (!ffmpegdec->pctx) {
> -+      if (len == 0 && !have_data) {
> -+        /* nothing was decoded, this could be because no data was available or
> -+         * because we were skipping frames.
> -+         * If we have no context we must exit and wait for more data, we keep the
> -+         * data we tried. */
> -+        GST_LOG_OBJECT (ffmpegdec, "Decoding didn't return any data, breaking");
> -+        break;
> -+      } else if (len < 0) {
> -+        /* a decoding error happened, we must break and try again with next data. */
> -+        GST_LOG_OBJECT (ffmpegdec, "Decoding error, breaking");
> -+        bsize = 0;
> -+        break;
> -+      }
> -+      /* prepare for the next round, for codecs with a context we did this
> -+       * already when using the parser. */
> -+      bsize -= len;
> -+      bdata += len;
> -+    } else {
> -+      if (len == 0) {
> -+        /* nothing was decoded, this could be because no data was available or
> -+         * because we were skipping frames. Since we have a parser we can
> -+         * continue with the next frame */
> -+        GST_LOG_OBJECT (ffmpegdec,
> -+            "Decoding didn't return any data, trying next");
> -+      } else if (len < 0) {
> -+        /* we have a context that will bring us to the next frame */
> -+        GST_LOG_OBJECT (ffmpegdec, "Decoding error, trying next");
> -+      }
> -+    }
> -+
> -+    /* make sure we don't use the same old timestamp for the next frame and let
> -+     * the interpollation take care of it. */
> -+    if (ffmpegdec->clear_ts) {
> -+      in_timestamp = GST_CLOCK_TIME_NONE;
> -+      in_duration = GST_CLOCK_TIME_NONE;
> -+      in_offset = GST_BUFFER_OFFSET_NONE;
> -+      in_info = GST_TS_INFO_NONE;
> -+    } else {
> -+      ffmpegdec->clear_ts = TRUE;
> -+    }
> -+    ffmpegdec->last_frames++;
> -+
> -+    GST_LOG_OBJECT (ffmpegdec, "Before (while bsize>0).  bsize:%d , bdata:%p",
> -+        bsize, bdata);
> -+  } while (bsize > 0);
> -+
> -+  /* keep left-over */
> -+  if (ffmpegdec->pctx && bsize > 0) {
> -+    in_timestamp = GST_BUFFER_TIMESTAMP (inbuf);
> -+    in_offset = GST_BUFFER_OFFSET (inbuf);
> -+
> -+    GST_LOG_OBJECT (ffmpegdec,
> -+        "Keeping %d bytes of data with offset %" G_GINT64_FORMAT ", timestamp %"
> -+        GST_TIME_FORMAT, bsize, in_offset, GST_TIME_ARGS (in_timestamp));
> -+
> -+    ffmpegdec->pcache = gst_buffer_create_sub (inbuf,
> -+        GST_BUFFER_SIZE (inbuf) - bsize, bsize);
> -+    /* we keep timestamp, even though all we really know is that the correct
> -+     * timestamp is not below the one from inbuf */
> -+    GST_BUFFER_TIMESTAMP (ffmpegdec->pcache) = in_timestamp;
> -+    GST_BUFFER_OFFSET (ffmpegdec->pcache) = in_offset;
> -+  } else if (bsize > 0) {
> -+    GST_DEBUG_OBJECT (ffmpegdec, "Dropping %d bytes of data", bsize);
> -+  }
> -+  gst_buffer_unref (inbuf);
> -+
> -+  return ret;
> -+
> -+  /* ERRORS */
> -+not_negotiated:
> -+  {
> -+    oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
> -+    GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
> -+        ("ffdec_%s: input format was not set before data start",
> -+            oclass->in_plugin->name));
> -+    gst_buffer_unref (inbuf);
> -+    return GST_FLOW_NOT_NEGOTIATED;
> -+  }
> -+}
> -+
> -+static GstStateChangeReturn
> -+gst_ffmpegdec_change_state (GstElement * element, GstStateChange transition)
> -+{
> -+  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) element;
> -+  GstStateChangeReturn ret;
> -+
> -+  ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
> -+
> -+  switch (transition) {
> -+    case GST_STATE_CHANGE_PAUSED_TO_READY:
> -+      GST_OBJECT_LOCK (ffmpegdec);
> -+      gst_ffmpegdec_close (ffmpegdec);
> -+      GST_OBJECT_UNLOCK (ffmpegdec);
> -+      clear_queued (ffmpegdec);
> -+      g_free (ffmpegdec->padded);
> -+      ffmpegdec->padded = NULL;
> -+      ffmpegdec->padded_size = 0;
> -+      ffmpegdec->can_allocate_aligned = TRUE;
> -+      break;
> -+    default:
> -+      break;
> -+  }
> -+
> -+  return ret;
> -+}
> -+
> -+static void
> -+gst_ffmpegdec_set_property (GObject * object,
> -+    guint prop_id, const GValue * value, GParamSpec * pspec)
> -+{
> -+  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
> -+
> -+  switch (prop_id) {
> -+    case PROP_LOWRES:
> -+      ffmpegdec->lowres = ffmpegdec->context->lowres = g_value_get_enum (value);
> -+      break;
> -+    case PROP_SKIPFRAME:
> -+      ffmpegdec->skip_frame = ffmpegdec->context->skip_frame =
> -+          g_value_get_enum (value);
> -+      break;
> -+    case PROP_DIRECT_RENDERING:
> -+      ffmpegdec->direct_rendering = g_value_get_boolean (value);
> -+      break;
> -+    case PROP_DO_PADDING:
> -+      ffmpegdec->do_padding = g_value_get_boolean (value);
> -+      break;
> -+    case PROP_DEBUG_MV:
> -+      ffmpegdec->debug_mv = ffmpegdec->context->debug_mv =
> -+          g_value_get_boolean (value);
> -+      break;
> -+    case PROP_CROP:
> -+      ffmpegdec->crop = g_value_get_boolean (value);
> -+      break;
> -+    case PROP_MAX_THREADS:
> -+      ffmpegdec->max_threads = g_value_get_int (value);
> -+      break;
> -+    default:
> -+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
> -+      break;
> -+  }
> -+}
> -+
> -+static void
> -+gst_ffmpegdec_get_property (GObject * object,
> -+    guint prop_id, GValue * value, GParamSpec * pspec)
> -+{
> -+  GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
> -+
> -+  switch (prop_id) {
> -+    case PROP_LOWRES:
> -+      g_value_set_enum (value, ffmpegdec->context->lowres);
> -+      break;
> -+    case PROP_SKIPFRAME:
> -+      g_value_set_enum (value, ffmpegdec->context->skip_frame);
> -+      break;
> -+    case PROP_DIRECT_RENDERING:
> -+      g_value_set_boolean (value, ffmpegdec->direct_rendering);
> -+      break;
> -+    case PROP_DO_PADDING:
> -+      g_value_set_boolean (value, ffmpegdec->do_padding);
> -+      break;
> -+    case PROP_DEBUG_MV:
> -+      g_value_set_boolean (value, ffmpegdec->context->debug_mv);
> -+      break;
> -+    case PROP_CROP:
> -+      g_value_set_boolean (value, ffmpegdec->crop);
> -+      break;
> -+    case PROP_MAX_THREADS:
> -+      g_value_set_int (value, ffmpegdec->max_threads);
> -+      break;
> -+    default:
> -+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
> -+      break;
> -+  }
> -+}
> -+
> -+gboolean
> -+gst_ffmpegdec_register (GstPlugin * plugin)
> -+{
> -+  GTypeInfo typeinfo = {
> -+    sizeof (GstFFMpegDecClass),
> -+    (GBaseInitFunc) gst_ffmpegdec_base_init,
> -+    NULL,
> -+    (GClassInitFunc) gst_ffmpegdec_class_init,
> -+    NULL,
> -+    NULL,
> -+    sizeof (GstFFMpegDec),
> -+    0,
> -+    (GInstanceInitFunc) gst_ffmpegdec_init,
> -+  };
> -+  GType type;
> -+  AVCodec *in_plugin;
> -+  gint rank;
> -+
> -+  in_plugin = av_codec_next (NULL);
> -+
> -+  GST_LOG ("Registering decoders");
> -+
> -+  while (in_plugin) {
> -+    gchar *type_name;
> -+    gchar *plugin_name;
> -+
> -+    /* only decoders */
> -+    if (!in_plugin->decode) {
> -+      goto next;
> -+    }
> -+
> -+    /* no quasi-codecs, please */
> -+    if (in_plugin->id == CODEC_ID_RAWVIDEO ||
> -+        in_plugin->id == CODEC_ID_V210 ||
> -+        in_plugin->id == CODEC_ID_V210X ||
> -+        in_plugin->id == CODEC_ID_R210 ||
> -+        (in_plugin->id >= CODEC_ID_PCM_S16LE &&
> -+            in_plugin->id <= CODEC_ID_PCM_BLURAY)) {
> -+      goto next;
> -+    }
> -+
> -+    /* No decoders depending on external libraries (we don't build them, but
> -+     * people who build against an external ffmpeg might have them.
> -+     * We have native gstreamer plugins for all of those libraries anyway. */
> -+    if (!strncmp (in_plugin->name, "lib", 3)) {
> -+      GST_DEBUG
> -+          ("Not using external library decoder %s. Use the gstreamer-native ones instead.",
> -+          in_plugin->name);
> -+      goto next;
> -+    }
> -+
> -+    /* No vdpau plugins until we can figure out how to properly use them
> -+     * outside of ffmpeg. */
> -+    if (g_str_has_suffix (in_plugin->name, "_vdpau")) {
> -+      GST_DEBUG
> -+          ("Ignoring VDPAU decoder %s. We can't handle this outside of ffmpeg",
> -+          in_plugin->name);
> -+      goto next;
> -+    }
> -+
> -+    if (g_str_has_suffix (in_plugin->name, "_xvmc")) {
> -+      GST_DEBUG
> -+          ("Ignoring XVMC decoder %s. We can't handle this outside of ffmpeg",
> -+          in_plugin->name);
> -+      goto next;
> -+    }
> -+
> -+    GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name);
> -+
> -+    /* no codecs for which we're GUARANTEED to have better alternatives */
> -+    /* MPEG1VIDEO : the mpeg2video decoder is preferred */
> -+    /* MP1 : Use MP3 for decoding */
> -+    /* MP2 : Use MP3 for decoding */
> -+    /* Theora: Use libtheora based theoradec */
> -+    if (!strcmp (in_plugin->name, "gif") ||
> -+        !strcmp (in_plugin->name, "vorbis") ||
> -+        !strcmp (in_plugin->name, "theora") ||
> -+        !strcmp (in_plugin->name, "mpeg1video") ||
> -+        !strcmp (in_plugin->name, "wavpack") ||
> -+        !strcmp (in_plugin->name, "mp1") ||
> -+        !strcmp (in_plugin->name, "mp2") ||
> -+        !strcmp (in_plugin->name, "libfaad") ||
> -+        !strcmp (in_plugin->name, "mpeg4aac") ||
> -+        !strcmp (in_plugin->name, "ass") ||
> -+        !strcmp (in_plugin->name, "srt") ||
> -+        !strcmp (in_plugin->name, "pgssub") ||
> -+        !strcmp (in_plugin->name, "dvdsub") ||
> -+        !strcmp (in_plugin->name, "dvbsub")) {
> -+      GST_LOG ("Ignoring decoder %s", in_plugin->name);
> -+      goto next;
> -+    }
> -+
> -+    /* construct the type */
> -+    plugin_name = g_strdup ((gchar *) in_plugin->name);
> -+    g_strdelimit (plugin_name, NULL, '_');
> -+    type_name = g_strdup_printf ("ffdec_%s", plugin_name);
> -+    g_free (plugin_name);
> -+
> -+    type = g_type_from_name (type_name);
> -+
> -+    if (!type) {
> -+      /* create the gtype now */
> -+      type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
> -+      g_type_set_qdata (type, GST_FFDEC_PARAMS_QDATA, (gpointer) in_plugin);
> -+    }
> -+
> -+    /* (Ronald) MPEG-4 gets a higher priority because it has been well-
> -+     * tested and by far outperforms divxdec/xviddec - so we prefer it.
> -+     * msmpeg4v3 same, as it outperforms divxdec for divx3 playback.
> -+     * VC1/WMV3 are not working and thus unpreferred for now. */
> -+    switch (in_plugin->id) {
> -+      case CODEC_ID_MPEG4:
> -+      case CODEC_ID_MSMPEG4V3:
> -+      case CODEC_ID_H264:
> -+      case CODEC_ID_RA_144:
> -+      case CODEC_ID_RA_288:
> -+      case CODEC_ID_RV10:
> -+      case CODEC_ID_RV20:
> -+      case CODEC_ID_RV30:
> -+      case CODEC_ID_RV40:
> -+      case CODEC_ID_COOK:
> -+        rank = GST_RANK_SECONDARY;
> -+        break;
> -+        /* DVVIDEO: we have a good dv decoder, fast on both ppc as well as x86.
> -+         * They say libdv's quality is better though. leave as secondary.
> -+         * note: if you change this, see the code in gstdv.c in good/ext/dv.
> -+         *
> -+         * SIPR: decoder should have a higher rank than realaudiodec.
> -+         */
> -+      case CODEC_ID_DVVIDEO:
> -+      case CODEC_ID_SIPR:
> -+        rank = GST_RANK_SECONDARY;
> -+        break;
> -+      case CODEC_ID_MP3:
> -+        rank = GST_RANK_NONE;
> -+        break;
> -+        /* TEMPORARILY DISABLING AC3/EAC3/DTS for 0.10.12 release
> -+         * due to downmixing failure.
> -+         * See Bug #608892 for more details */
> -+      case CODEC_ID_EAC3:
> -+      case CODEC_ID_AC3:
> -+      case CODEC_ID_DTS:
> -+        rank = GST_RANK_NONE;
> -+        break;
> -+      default:
> -+        rank = GST_RANK_MARGINAL;
> -+        break;
> -+    }
> -+    if (!gst_element_register (plugin, type_name, rank, type)) {
> -+      g_warning ("Failed to register %s", type_name);
> -+      g_free (type_name);
> -+      return FALSE;
> -+    }
> -+
> -+    g_free (type_name);
> -+
> -+  next:
> -+    in_plugin = av_codec_next (in_plugin);
> -+  }
> -+
> -+  GST_LOG ("Finished Registering decoders");
> -+
> -+  return TRUE;
> -+}
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.rej gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.rej
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.rej	1970-01-01 01:00:00.000000000 +0100
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.rej	2014-08-08 15:26:38.471858652 +0200
> -@@ -0,0 +1,11 @@
> -+--- ext/ffmpeg/gstffmpegdec.c
> -++++ ext/ffmpeg/gstffmpegdec.c
> -+@@ -1565,7 +1564,7 @@
> -+         gst_message_new_latency (GST_OBJECT_CAST (ffmpegdec)));
> -+   }
> -+
> -+-  is_itype = (ffmpegdec->picture->pict_type == FF_I_TYPE);
> -++  is_itype = (ffmpegdec->picture->pict_type == AV_PICTURE_TYPE_I);
> -+   is_reference = (ffmpegdec->picture->reference == 1);
> -+
> -+   iskeyframe = (is_itype || is_reference || ffmpegdec->picture->key_frame)
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdemux.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdemux.c
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdemux.c	2011-07-13 11:07:28.000000000 +0200
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdemux.c	2014-08-08 15:26:07.874857555 +0200
> -@@ -343,8 +343,11 @@
> -   demux->audiopads = 0;
> -
> -   /* close demuxer context from ffmpeg */
> --  av_close_input_file (demux->context);
> --  demux->context = NULL;
> -+  if (demux->seekable)
> -+    gst_ffmpegdata_close (demux->context->pb);
> -+  else
> -+    gst_ffmpeg_pipe_close (demux->context->pb);
> -+  avformat_close_input (&demux->context);
> -
> -   GST_OBJECT_LOCK (demux);
> -   demux->opened = FALSE;
> -@@ -1146,9 +1149,9 @@
> - static gboolean
> - gst_ffmpegdemux_open (GstFFMpegDemux * demux)
> - {
> -+  AVIOContext *iocontext = NULL;
> -   GstFFMpegDemuxClass *oclass =
> -       (GstFFMpegDemuxClass *) G_OBJECT_GET_CLASS (demux);
> --  gchar *location;
> -   gint res, n_streams, i;
> - #if 0
> -   /* Re-enable once converted to new AVMetaData API
> -@@ -1164,15 +1167,14 @@
> -
> -   /* open via our input protocol hack */
> -   if (demux->seekable)
> --    location = g_strdup_printf ("gstreamer://%p", demux->sinkpad);
> -+    res = gst_ffmpegdata_open (demux->sinkpad, AVIO_FLAG_READ, &iocontext);
> -   else
> --    location = g_strdup_printf ("gstpipe://%p", &demux->ffpipe);
> --  GST_DEBUG_OBJECT (demux, "about to call av_open_input_file %s", location);
> -+    res = gst_ffmpeg_pipe_open (&demux->ffpipe, AVIO_FLAG_READ, &iocontext);
> -
> --  res = av_open_input_file (&demux->context, location,
> --      oclass->in_plugin, 0, NULL);
> -+  demux->context = avformat_alloc_context ();
> -+  demux->context->pb = iocontext;
> -+  res = avformat_open_input (&demux->context, NULL, oclass->in_plugin, NULL);
> -
> --  g_free (location);
> -   GST_DEBUG_OBJECT (demux, "av_open_input returned %d", res);
> -   if (res < 0)
> -     goto open_failed;
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegenc.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegenc.c
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegenc.c	2011-10-31 11:14:03.000000000 +0100
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegenc.c	2014-08-08 15:32:18.608870847 +0200
> -@@ -770,7 +770,7 @@
> -   GST_OBJECT_UNLOCK (ffmpegenc);
> -
> -   if (force_keyframe)
> --    ffmpegenc->picture->pict_type = FF_I_TYPE;
> -+    ffmpegenc->picture->pict_type = AV_PICTURE_TYPE_I;
> -
> -   frame_size = gst_ffmpeg_avpicture_fill ((AVPicture *) ffmpegenc->picture,
> -       GST_BUFFER_DATA (inbuf),
> -@@ -1136,7 +1136,7 @@
> -       const GstStructure *s;
> -       s = gst_event_get_structure (event);
> -       if (gst_structure_has_name (s, "GstForceKeyUnit")) {
> --        ffmpegenc->picture->pict_type = FF_I_TYPE;
> -+        ffmpegenc->picture->pict_type = AV_PICTURE_TYPE_I;
> -       }
> -       break;
> -     }
> -@@ -1339,7 +1339,7 @@
> -     }
> -
> -     /* only encoders */
> --    if (!in_plugin->encode) {
> -+    if (!av_codec_is_encoder (in_plugin)) {
> -       goto next;
> -     }
> -
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c	2011-07-13 11:07:28.000000000 +0200
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c	2014-08-08 15:26:07.874857555 +0200
> -@@ -24,8 +24,10 @@
> - #include <string.h>
> - #ifdef HAVE_FFMPEG_UNINSTALLED
> - #include <avformat.h>
> -+#include <opt.h>
> - #else
> - #include <libavformat/avformat.h>
> -+#include <libavutil/opt.h>
> - #endif
> -
> - #include <gst/gst.h>
> -@@ -336,9 +338,6 @@
> -   ffmpegmux->context = g_new0 (AVFormatContext, 1);
> -   ffmpegmux->context->oformat = oclass->in_plugin;
> -   ffmpegmux->context->nb_streams = 0;
> --  g_snprintf (ffmpegmux->context->filename,
> --      sizeof (ffmpegmux->context->filename),
> --      "gstreamer://%p", ffmpegmux->srcpad);
> -   ffmpegmux->opened = FALSE;
> -
> -   ffmpegmux->videopads = 0;
> -@@ -450,10 +449,10 @@
> -   gst_element_add_pad (element, pad);
> -
> -   /* AVStream needs to be created */
> --  st = av_new_stream (ffmpegmux->context, collect_pad->padnum);
> -+  st = avformat_new_stream (ffmpegmux->context, NULL);
> -+  st->id = collect_pad->padnum;
> -   st->codec->codec_type = type;
> -   st->codec->codec_id = CODEC_ID_NONE;  /* this is a check afterwards */
> --  st->stream_copy = 1;          /* we're not the actual encoder */
> -   st->codec->bit_rate = bitrate;
> -   st->codec->frame_size = framesize;
> -   /* we fill in codec during capsnego */
> -@@ -485,7 +484,7 @@
> -   collect_pad = (GstFFMpegMuxPad *) gst_pad_get_element_private (pad);
> -
> -   st = ffmpegmux->context->streams[collect_pad->padnum];
> --  ffmpegmux->context->preload = ffmpegmux->preload;
> -+  av_opt_set_int (&ffmpegmux->context, "preload", ffmpegmux->preload, 0);
> -   ffmpegmux->context->max_delay = ffmpegmux->max_delay;
> -
> -   /* for the format-specific guesses, we'll go to
> -@@ -552,7 +551,7 @@
> -
> -   /* open "file" (gstreamer protocol to next element) */
> -   if (!ffmpegmux->opened) {
> --    int open_flags = URL_WRONLY;
> -+    int open_flags = AVIO_FLAG_WRITE;
> -
> -     /* we do need all streams to have started capsnego,
> -      * or things will go horribly wrong */
> -@@ -646,19 +645,13 @@
> -       open_flags |= GST_FFMPEG_URL_STREAMHEADER;
> -     }
> -
> --    if (url_fopen (&ffmpegmux->context->pb,
> --            ffmpegmux->context->filename, open_flags) < 0) {
> -+    if (gst_ffmpegdata_open (ffmpegmux->srcpad, open_flags,
> -+            &ffmpegmux->context->pb) < 0) {
> -       GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, TOO_LAZY, (NULL),
> -           ("Failed to open stream context in ffmux"));
> -       return GST_FLOW_ERROR;
> -     }
> -
> --    if (av_set_parameters (ffmpegmux->context, NULL) < 0) {
> --      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, INIT, (NULL),
> --          ("Failed to initialize muxer"));
> --      return GST_FLOW_ERROR;
> --    }
> --
> -     /* now open the mux format */
> -     if (av_write_header (ffmpegmux->context) < 0) {
> -       GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, SETTINGS, (NULL),
> -@@ -670,7 +663,7 @@
> -     ffmpegmux->opened = TRUE;
> -
> -     /* flush the header so it will be used as streamheader */
> --    put_flush_packet (ffmpegmux->context->pb);
> -+    avio_flush (ffmpegmux->context->pb);
> -   }
> -
> -   /* take the one with earliest timestamp,
> -@@ -770,8 +763,8 @@
> -     /* close down */
> -     av_write_trailer (ffmpegmux->context);
> -     ffmpegmux->opened = FALSE;
> --    put_flush_packet (ffmpegmux->context->pb);
> --    url_fclose (ffmpegmux->context->pb);
> -+    avio_flush (ffmpegmux->context->pb);
> -+    gst_ffmpegdata_close (ffmpegmux->context->pb);
> -     gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_eos ());
> -     return GST_FLOW_UNEXPECTED;
> -   }
> -@@ -795,6 +788,10 @@
> -       break;
> -     case GST_STATE_CHANGE_PAUSED_TO_READY:
> -       gst_collect_pads_stop (ffmpegmux->collect);
> -+      if (ffmpegmux->opened) {
> -+        ffmpegmux->opened = FALSE;
> -+        gst_ffmpegdata_close (ffmpegmux->context->pb);
> -+      }
> -       break;
> -     default:
> -       break;
> -@@ -809,7 +806,7 @@
> -       gst_tag_setter_reset_tags (GST_TAG_SETTER (ffmpegmux));
> -       if (ffmpegmux->opened) {
> -         ffmpegmux->opened = FALSE;
> --        url_fclose (ffmpegmux->context->pb);
> -+        avio_close (ffmpegmux->context->pb);
> -       }
> -       break;
> -     case GST_STATE_CHANGE_READY_TO_NULL:
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c.orig
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c.orig	1970-01-01 01:00:00.000000000 +0100
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c.orig	2011-07-13 11:07:28.000000000 +0200
> -@@ -0,0 +1,970 @@
> -+/* 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>
> -+#ifdef HAVE_FFMPEG_UNINSTALLED
> -+#include <avformat.h>
> -+#else
> -+#include <libavformat/avformat.h>
> -+#endif
> -+
> -+#include <gst/gst.h>
> -+#include <gst/base/gstcollectpads.h>
> -+
> -+#include "gstffmpeg.h"
> -+#include "gstffmpegcodecmap.h"
> -+#include "gstffmpegutils.h"
> -+
> -+typedef struct _GstFFMpegMux GstFFMpegMux;
> -+typedef struct _GstFFMpegMuxPad GstFFMpegMuxPad;
> -+
> -+struct _GstFFMpegMuxPad
> -+{
> -+  GstCollectData collect;       /* we extend the CollectData */
> -+
> -+  gint padnum;
> -+};
> -+
> -+struct _GstFFMpegMux
> -+{
> -+  GstElement element;
> -+
> -+  GstCollectPads *collect;
> -+  /* We need to keep track of our pads, so we do so here. */
> -+  GstPad *srcpad;
> -+
> -+  AVFormatContext *context;
> -+  gboolean opened;
> -+
> -+  gint videopads, audiopads;
> -+
> -+  /*< private > */
> -+  /* event_function is the collectpads default eventfunction */
> -+  GstPadEventFunction event_function;
> -+  int preload;
> -+  int max_delay;
> -+};
> -+
> -+typedef struct _GstFFMpegMuxClass GstFFMpegMuxClass;
> -+
> -+struct _GstFFMpegMuxClass
> -+{
> -+  GstElementClass parent_class;
> -+
> -+  AVOutputFormat *in_plugin;
> -+};
> -+
> -+#define GST_TYPE_FFMPEGMUX \
> -+  (gst_ffmpegdec_get_type())
> -+#define GST_FFMPEGMUX(obj) \
> -+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGMUX,GstFFMpegMux))
> -+#define GST_FFMPEGMUX_CLASS(klass) \
> -+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGMUX,GstFFMpegMuxClass))
> -+#define GST_IS_FFMPEGMUX(obj) \
> -+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGMUX))
> -+#define GST_IS_FFMPEGMUX_CLASS(klass) \
> -+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGMUX))
> -+
> -+enum
> -+{
> -+  /* FILL ME */
> -+  LAST_SIGNAL
> -+};
> -+
> -+enum
> -+{
> -+  ARG_0,
> -+  /* FILL ME */
> -+};
> -+
> -+enum
> -+{
> -+  PROP_0,
> -+  PROP_PRELOAD,
> -+  PROP_MAXDELAY
> -+};
> -+
> -+/* A number of function prototypes are given so we can refer to them later. */
> -+static void gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass);
> -+static void gst_ffmpegmux_base_init (gpointer g_class);
> -+static void gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux,
> -+    GstFFMpegMuxClass * g_class);
> -+static void gst_ffmpegmux_finalize (GObject * object);
> -+
> -+static gboolean gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps);
> -+static GstPad *gst_ffmpegmux_request_new_pad (GstElement * element,
> -+    GstPadTemplate * templ, const gchar * name);
> -+static GstFlowReturn gst_ffmpegmux_collected (GstCollectPads * pads,
> -+    gpointer user_data);
> -+
> -+static gboolean gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event);
> -+
> -+static GstStateChangeReturn gst_ffmpegmux_change_state (GstElement * element,
> -+    GstStateChange transition);
> -+
> -+static void gst_ffmpegmux_set_property (GObject * object, guint prop_id,
> -+    const GValue * value, GParamSpec * pspec);
> -+static void gst_ffmpegmux_get_property (GObject * object, guint prop_id,
> -+    GValue * value, GParamSpec * pspec);
> -+
> -+static GstCaps *gst_ffmpegmux_get_id_caps (enum CodecID *id_list);
> -+static void gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * caps,
> -+    const gchar * field, guint num, const gint * values);
> -+
> -+#define GST_FFMUX_PARAMS_QDATA g_quark_from_static_string("ffmux-params")
> -+
> -+static GstElementClass *parent_class = NULL;
> -+
> -+/*static guint gst_ffmpegmux_signals[LAST_SIGNAL] = { 0 }; */
> -+
> -+typedef struct
> -+{
> -+  const char *name;
> -+  const char *replacement;
> -+} GstFFMpegMuxReplacement;
> -+
> -+static const char *
> -+gst_ffmpegmux_get_replacement (const char *name)
> -+{
> -+  static const GstFFMpegMuxReplacement blacklist[] = {
> -+    {"avi", "avimux"},
> -+    {"matroska", "matroskamux"},
> -+    {"mov", "qtmux"},
> -+    {"mpegts", "mpegtsmux"},
> -+    {"mp4", "mp4mux"},
> -+    {"mpjpeg", "multipartmux"},
> -+    {"ogg", "oggmux"},
> -+    {"wav", "wavenc"},
> -+    {"webm", "webmmux"},
> -+    {"mxf", "mxfmux"},
> -+    {"3gp", "gppmux"},
> -+    {"yuv4mpegpipe", "y4menc"},
> -+    {"aiff", "aiffmux"},
> -+    {"adts", "aacparse"},
> -+    {"asf", "asfmux"},
> -+    {"asf_stream", "asfmux"},
> -+    {"flv", "flvmux"},
> -+    {"mp3", "id3v2mux"},
> -+    {"mp2", "id3v2mux"}
> -+  };
> -+  int i;
> -+
> -+  for (i = 0; i < sizeof (blacklist) / sizeof (blacklist[0]); i++) {
> -+    if (strcmp (blacklist[i].name, name) == 0) {
> -+      return blacklist[i].replacement;
> -+    }
> -+  }
> -+
> -+  return NULL;
> -+}
> -+
> -+static gboolean
> -+gst_ffmpegmux_is_formatter (const char *name)
> -+{
> -+  static const char *replace[] = {
> -+    "mp2", "mp3", NULL
> -+  };
> -+  int i;
> -+
> -+  for (i = 0; replace[i]; i++)
> -+    if (strcmp (replace[i], name) == 0)
> -+      return TRUE;
> -+  return FALSE;
> -+}
> -+
> -+static void
> -+gst_ffmpegmux_base_init (gpointer g_class)
> -+{
> -+  GstFFMpegMuxClass *klass = (GstFFMpegMuxClass *) g_class;
> -+  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
> -+  GstPadTemplate *videosinktempl, *audiosinktempl, *srctempl;
> -+  AVOutputFormat *in_plugin;
> -+  GstCaps *srccaps, *audiosinkcaps, *videosinkcaps;
> -+  enum CodecID *video_ids = NULL, *audio_ids = NULL;
> -+  gchar *longname, *description;
> -+  const char *replacement;
> -+  gboolean is_formatter;
> -+
> -+  in_plugin =
> -+      (AVOutputFormat *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
> -+      GST_FFMUX_PARAMS_QDATA);
> -+  g_assert (in_plugin != NULL);
> -+
> -+  /* construct the element details struct */
> -+  replacement = gst_ffmpegmux_get_replacement (in_plugin->name);
> -+  is_formatter = gst_ffmpegmux_is_formatter (in_plugin->name);
> -+  if (replacement != NULL) {
> -+    longname =
> -+        g_strdup_printf ("FFmpeg %s %s (not recommended, use %s instead)",
> -+        in_plugin->long_name, is_formatter ? "formatter" : "muxer",
> -+        replacement);
> -+    description =
> -+        g_strdup_printf ("FFmpeg %s %s (not recommended, use %s instead)",
> -+        in_plugin->long_name, is_formatter ? "formatter" : "muxer",
> -+        replacement);
> -+  } else {
> -+    longname = g_strdup_printf ("FFmpeg %s %s", in_plugin->long_name,
> -+        is_formatter ? "formatter" : "muxer");
> -+    description = g_strdup_printf ("FFmpeg %s %s", in_plugin->long_name,
> -+        is_formatter ? "formatter" : "muxer");
> -+  }
> -+  gst_element_class_set_details_simple (element_class, longname,
> -+      is_formatter ? "Formatter/Metadata" : "Codec/Muxer", description,
> -+      "Wim Taymans <wim.taymans@chello.be>, "
> -+      "Ronald Bultje <rbultje@ronald.bitfreak.net>");
> -+  g_free (longname);
> -+  g_free (description);
> -+
> -+  /* Try to find the caps that belongs here */
> -+  srccaps = gst_ffmpeg_formatid_to_caps (in_plugin->name);
> -+  if (!srccaps) {
> -+    GST_DEBUG ("Couldn't get source caps for muxer '%s', skipping format",
> -+        in_plugin->name);
> -+    goto beach;
> -+  }
> -+
> -+  if (!gst_ffmpeg_formatid_get_codecids (in_plugin->name,
> -+          &video_ids, &audio_ids, in_plugin)) {
> -+    gst_caps_unref (srccaps);
> -+    GST_DEBUG
> -+        ("Couldn't get sink caps for muxer '%s'. Most likely because no input format mapping exists.",
> -+        in_plugin->name);
> -+    goto beach;
> -+  }
> -+
> -+  videosinkcaps = video_ids ? gst_ffmpegmux_get_id_caps (video_ids) : NULL;
> -+  audiosinkcaps = audio_ids ? gst_ffmpegmux_get_id_caps (audio_ids) : NULL;
> -+
> -+  /* fix up allowed caps for some muxers */
> -+  /* FIXME : This should be in gstffmpegcodecmap.c ! */
> -+  if (strcmp (in_plugin->name, "flv") == 0) {
> -+    const gint rates[] = { 44100, 22050, 11025 };
> -+
> -+    gst_ffmpeg_mux_simple_caps_set_int_list (audiosinkcaps, "rate", 3, rates);
> -+  } else if (strcmp (in_plugin->name, "gif") == 0) {
> -+    if (videosinkcaps)
> -+      gst_caps_unref (videosinkcaps);
> -+
> -+    videosinkcaps =
> -+        gst_caps_from_string ("video/x-raw-rgb, bpp=(int)24, depth=(int)24");
> -+  }
> -+
> -+  /* pad templates */
> -+  srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
> -+  gst_element_class_add_pad_template (element_class, srctempl);
> -+
> -+  if (audiosinkcaps) {
> -+    audiosinktempl = gst_pad_template_new ("audio_%d",
> -+        GST_PAD_SINK, GST_PAD_REQUEST, audiosinkcaps);
> -+    gst_element_class_add_pad_template (element_class, audiosinktempl);
> -+  }
> -+
> -+  if (videosinkcaps) {
> -+    videosinktempl = gst_pad_template_new ("video_%d",
> -+        GST_PAD_SINK, GST_PAD_REQUEST, videosinkcaps);
> -+    gst_element_class_add_pad_template (element_class, videosinktempl);
> -+  }
> -+
> -+beach:
> -+  klass->in_plugin = in_plugin;
> -+}
> -+
> -+static void
> -+gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass)
> -+{
> -+  GObjectClass *gobject_class;
> -+  GstElementClass *gstelement_class;
> -+
> -+  gobject_class = (GObjectClass *) klass;
> -+  gstelement_class = (GstElementClass *) klass;
> -+
> -+  parent_class = g_type_class_peek_parent (klass);
> -+
> -+  gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_ffmpegmux_set_property);
> -+  gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_ffmpegmux_get_property);
> -+
> -+  g_object_class_install_property (gobject_class, PROP_PRELOAD,
> -+      g_param_spec_int ("preload", "preload",
> -+          "Set the initial demux-decode delay (in microseconds)", 0, G_MAXINT,
> -+          0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> -+
> -+  g_object_class_install_property (gobject_class, PROP_MAXDELAY,
> -+      g_param_spec_int ("maxdelay", "maxdelay",
> -+          "Set the maximum demux-decode delay (in microseconds)", 0, G_MAXINT,
> -+          0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
> -+
> -+  gstelement_class->request_new_pad = gst_ffmpegmux_request_new_pad;
> -+  gstelement_class->change_state = gst_ffmpegmux_change_state;
> -+  gobject_class->finalize = gst_ffmpegmux_finalize;
> -+}
> -+
> -+static void
> -+gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux, GstFFMpegMuxClass * g_class)
> -+{
> -+  GstElementClass *klass = GST_ELEMENT_CLASS (g_class);
> -+  GstFFMpegMuxClass *oclass = (GstFFMpegMuxClass *) klass;
> -+  GstPadTemplate *templ = gst_element_class_get_pad_template (klass, "src");
> -+
> -+  ffmpegmux->srcpad = gst_pad_new_from_template (templ, "src");
> -+  gst_pad_set_caps (ffmpegmux->srcpad, gst_pad_template_get_caps (templ));
> -+  gst_element_add_pad (GST_ELEMENT (ffmpegmux), ffmpegmux->srcpad);
> -+
> -+  ffmpegmux->collect = gst_collect_pads_new ();
> -+  gst_collect_pads_set_function (ffmpegmux->collect,
> -+      (GstCollectPadsFunction) gst_ffmpegmux_collected, ffmpegmux);
> -+
> -+  ffmpegmux->context = g_new0 (AVFormatContext, 1);
> -+  ffmpegmux->context->oformat = oclass->in_plugin;
> -+  ffmpegmux->context->nb_streams = 0;
> -+  g_snprintf (ffmpegmux->context->filename,
> -+      sizeof (ffmpegmux->context->filename),
> -+      "gstreamer://%p", ffmpegmux->srcpad);
> -+  ffmpegmux->opened = FALSE;
> -+
> -+  ffmpegmux->videopads = 0;
> -+  ffmpegmux->audiopads = 0;
> -+  ffmpegmux->preload = 0;
> -+  ffmpegmux->max_delay = 0;
> -+}
> -+
> -+static void
> -+gst_ffmpegmux_set_property (GObject * object, guint prop_id,
> -+    const GValue * value, GParamSpec * pspec)
> -+{
> -+  GstFFMpegMux *src;
> -+
> -+  src = (GstFFMpegMux *) object;
> -+
> -+  switch (prop_id) {
> -+    case PROP_PRELOAD:
> -+      src->preload = g_value_get_int (value);
> -+      break;
> -+    case PROP_MAXDELAY:
> -+      src->max_delay = g_value_get_int (value);
> -+      break;
> -+    default:
> -+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
> -+      break;
> -+  }
> -+}
> -+
> -+static void
> -+gst_ffmpegmux_get_property (GObject * object, guint prop_id, GValue * value,
> -+    GParamSpec * pspec)
> -+{
> -+  GstFFMpegMux *src;
> -+
> -+  src = (GstFFMpegMux *) object;
> -+
> -+  switch (prop_id) {
> -+    case PROP_PRELOAD:
> -+      g_value_set_int (value, src->preload);
> -+      break;
> -+    case PROP_MAXDELAY:
> -+      g_value_set_int (value, src->max_delay);
> -+      break;
> -+    default:
> -+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
> -+      break;
> -+  }
> -+}
> -+
> -+
> -+static void
> -+gst_ffmpegmux_finalize (GObject * object)
> -+{
> -+  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) object;
> -+
> -+  g_free (ffmpegmux->context);
> -+  gst_object_unref (ffmpegmux->collect);
> -+
> -+  if (G_OBJECT_CLASS (parent_class)->finalize)
> -+    G_OBJECT_CLASS (parent_class)->finalize (object);
> -+}
> -+
> -+static GstPad *
> -+gst_ffmpegmux_request_new_pad (GstElement * element,
> -+    GstPadTemplate * templ, const gchar * name)
> -+{
> -+  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) element;
> -+  GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
> -+  GstFFMpegMuxPad *collect_pad;
> -+  gchar *padname;
> -+  GstPad *pad;
> -+  AVStream *st;
> -+  enum AVMediaType type;
> -+  gint bitrate = 0, framesize = 0;
> -+
> -+  g_return_val_if_fail (templ != NULL, NULL);
> -+  g_return_val_if_fail (templ->direction == GST_PAD_SINK, NULL);
> -+  g_return_val_if_fail (ffmpegmux->opened == FALSE, NULL);
> -+
> -+  /* figure out a name that *we* like */
> -+  if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
> -+    padname = g_strdup_printf ("video_%d", ffmpegmux->videopads++);
> -+    type = AVMEDIA_TYPE_VIDEO;
> -+    bitrate = 64 * 1024;
> -+    framesize = 1152;
> -+  } else if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
> -+    padname = g_strdup_printf ("audio_%d", ffmpegmux->audiopads++);
> -+    type = AVMEDIA_TYPE_AUDIO;
> -+    bitrate = 285 * 1024;
> -+  } else {
> -+    g_warning ("ffmux: unknown pad template!");
> -+    return NULL;
> -+  }
> -+
> -+  /* create pad */
> -+  pad = gst_pad_new_from_template (templ, padname);
> -+  collect_pad = (GstFFMpegMuxPad *)
> -+      gst_collect_pads_add_pad (ffmpegmux->collect, pad,
> -+      sizeof (GstFFMpegMuxPad));
> -+  collect_pad->padnum = ffmpegmux->context->nb_streams;
> -+
> -+  /* small hack to put our own event pad function and chain up to collect pad */
> -+  ffmpegmux->event_function = GST_PAD_EVENTFUNC (pad);
> -+  gst_pad_set_event_function (pad,
> -+      GST_DEBUG_FUNCPTR (gst_ffmpegmux_sink_event));
> -+
> -+  gst_pad_set_setcaps_function (pad, GST_DEBUG_FUNCPTR (gst_ffmpegmux_setcaps));
> -+  gst_element_add_pad (element, pad);
> -+
> -+  /* AVStream needs to be created */
> -+  st = av_new_stream (ffmpegmux->context, collect_pad->padnum);
> -+  st->codec->codec_type = type;
> -+  st->codec->codec_id = CODEC_ID_NONE;  /* this is a check afterwards */
> -+  st->stream_copy = 1;          /* we're not the actual encoder */
> -+  st->codec->bit_rate = bitrate;
> -+  st->codec->frame_size = framesize;
> -+  /* we fill in codec during capsnego */
> -+
> -+  /* we love debug output (c) (tm) (r) */
> -+  GST_DEBUG ("Created %s pad for ffmux_%s element",
> -+      padname, ((GstFFMpegMuxClass *) klass)->in_plugin->name);
> -+  g_free (padname);
> -+
> -+  return pad;
> -+}
> -+
> -+/**
> -+ * gst_ffmpegmux_setcaps
> -+ * @pad: #GstPad
> -+ * @caps: New caps.
> -+ *
> -+ * Set caps to pad.
> -+ *
> -+ * Returns: #TRUE on success.
> -+ */
> -+static gboolean
> -+gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps)
> -+{
> -+  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (gst_pad_get_parent (pad));
> -+  GstFFMpegMuxPad *collect_pad;
> -+  AVStream *st;
> -+
> -+  collect_pad = (GstFFMpegMuxPad *) gst_pad_get_element_private (pad);
> -+
> -+  st = ffmpegmux->context->streams[collect_pad->padnum];
> -+  ffmpegmux->context->preload = ffmpegmux->preload;
> -+  ffmpegmux->context->max_delay = ffmpegmux->max_delay;
> -+
> -+  /* for the format-specific guesses, we'll go to
> -+   * our famous codec mapper */
> -+  if (gst_ffmpeg_caps_to_codecid (caps, st->codec) == CODEC_ID_NONE)
> -+    goto not_accepted;
> -+
> -+  /* copy over the aspect ratios, ffmpeg expects the stream aspect to match the
> -+   * codec aspect. */
> -+  st->sample_aspect_ratio = st->codec->sample_aspect_ratio;
> -+
> -+  GST_LOG_OBJECT (pad, "accepted caps %" GST_PTR_FORMAT, caps);
> -+  return TRUE;
> -+
> -+  /* ERRORS */
> -+not_accepted:
> -+  {
> -+    GST_LOG_OBJECT (pad, "rejecting caps %" GST_PTR_FORMAT, caps);
> -+    return FALSE;
> -+  }
> -+}
> -+
> -+
> -+static gboolean
> -+gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event)
> -+{
> -+  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) gst_pad_get_parent (pad);
> -+  gboolean res = TRUE;
> -+
> -+  switch (GST_EVENT_TYPE (event)) {
> -+    case GST_EVENT_TAG:{
> -+      GstTagList *taglist;
> -+      GstTagSetter *setter = GST_TAG_SETTER (ffmpegmux);
> -+      const GstTagMergeMode mode = gst_tag_setter_get_tag_merge_mode (setter);
> -+
> -+      gst_event_parse_tag (event, &taglist);
> -+      gst_tag_setter_merge_tags (setter, taglist, mode);
> -+      break;
> -+    }
> -+    default:
> -+      break;
> -+  }
> -+
> -+  /* chaining up to collectpads default event function */
> -+  res = ffmpegmux->event_function (pad, event);
> -+
> -+  gst_object_unref (ffmpegmux);
> -+  return res;
> -+}
> -+
> -+static GstFlowReturn
> -+gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
> -+{
> -+  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) user_data;
> -+  GSList *collected;
> -+  GstFFMpegMuxPad *best_pad;
> -+  GstClockTime best_time;
> -+#if 0
> -+  /* Re-enable once converted to new AVMetaData API
> -+   * See #566605
> -+   */
> -+  const GstTagList *tags;
> -+#endif
> -+
> -+  /* open "file" (gstreamer protocol to next element) */
> -+  if (!ffmpegmux->opened) {
> -+    int open_flags = URL_WRONLY;
> -+
> -+    /* we do need all streams to have started capsnego,
> -+     * or things will go horribly wrong */
> -+    for (collected = ffmpegmux->collect->data; collected;
> -+        collected = g_slist_next (collected)) {
> -+      GstFFMpegMuxPad *collect_pad = (GstFFMpegMuxPad *) collected->data;
> -+      AVStream *st = ffmpegmux->context->streams[collect_pad->padnum];
> -+
> -+      /* check whether the pad has successfully completed capsnego */
> -+      if (st->codec->codec_id == CODEC_ID_NONE) {
> -+        GST_ELEMENT_ERROR (ffmpegmux, CORE, NEGOTIATION, (NULL),
> -+            ("no caps set on stream %d (%s)", collect_pad->padnum,
> -+                (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ?
> -+                "video" : "audio"));
> -+        return GST_FLOW_ERROR;
> -+      }
> -+      /* set framerate for audio */
> -+      if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
> -+        switch (st->codec->codec_id) {
> -+          case CODEC_ID_PCM_S16LE:
> -+          case CODEC_ID_PCM_S16BE:
> -+          case CODEC_ID_PCM_U16LE:
> -+          case CODEC_ID_PCM_U16BE:
> -+          case CODEC_ID_PCM_S8:
> -+          case CODEC_ID_PCM_U8:
> -+            st->codec->frame_size = 1;
> -+            break;
> -+          default:
> -+          {
> -+            GstBuffer *buffer;
> -+
> -+            /* FIXME : This doesn't work for RAW AUDIO...
> -+             * in fact I'm wondering if it even works for any kind of audio... */
> -+            buffer = gst_collect_pads_peek (ffmpegmux->collect,
> -+                (GstCollectData *) collect_pad);
> -+            if (buffer) {
> -+              st->codec->frame_size =
> -+                  st->codec->sample_rate *
> -+                  GST_BUFFER_DURATION (buffer) / GST_SECOND;
> -+              gst_buffer_unref (buffer);
> -+            }
> -+          }
> -+        }
> -+      }
> -+    }
> -+
> -+#if 0
> -+    /* Re-enable once converted to new AVMetaData API
> -+     * See #566605
> -+     */
> -+
> -+    /* tags */
> -+    tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (ffmpegmux));
> -+    if (tags) {
> -+      gint i;
> -+      gchar *s;
> -+
> -+      /* get the interesting ones */
> -+      if (gst_tag_list_get_string (tags, GST_TAG_TITLE, &s)) {
> -+        strncpy (ffmpegmux->context->title, s,
> -+            sizeof (ffmpegmux->context->title));
> -+      }
> -+      if (gst_tag_list_get_string (tags, GST_TAG_ARTIST, &s)) {
> -+        strncpy (ffmpegmux->context->author, s,
> -+            sizeof (ffmpegmux->context->author));
> -+      }
> -+      if (gst_tag_list_get_string (tags, GST_TAG_COPYRIGHT, &s)) {
> -+        strncpy (ffmpegmux->context->copyright, s,
> -+            sizeof (ffmpegmux->context->copyright));
> -+      }
> -+      if (gst_tag_list_get_string (tags, GST_TAG_COMMENT, &s)) {
> -+        strncpy (ffmpegmux->context->comment, s,
> -+            sizeof (ffmpegmux->context->comment));
> -+      }
> -+      if (gst_tag_list_get_string (tags, GST_TAG_ALBUM, &s)) {
> -+        strncpy (ffmpegmux->context->album, s,
> -+            sizeof (ffmpegmux->context->album));
> -+      }
> -+      if (gst_tag_list_get_string (tags, GST_TAG_GENRE, &s)) {
> -+        strncpy (ffmpegmux->context->genre, s,
> -+            sizeof (ffmpegmux->context->genre));
> -+      }
> -+      if (gst_tag_list_get_int (tags, GST_TAG_TRACK_NUMBER, &i)) {
> -+        ffmpegmux->context->track = i;
> -+      }
> -+    }
> -+#endif
> -+
> -+    /* set the streamheader flag for gstffmpegprotocol if codec supports it */
> -+    if (!strcmp (ffmpegmux->context->oformat->name, "flv")) {
> -+      open_flags |= GST_FFMPEG_URL_STREAMHEADER;
> -+    }
> -+
> -+    if (url_fopen (&ffmpegmux->context->pb,
> -+            ffmpegmux->context->filename, open_flags) < 0) {
> -+      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, TOO_LAZY, (NULL),
> -+          ("Failed to open stream context in ffmux"));
> -+      return GST_FLOW_ERROR;
> -+    }
> -+
> -+    if (av_set_parameters (ffmpegmux->context, NULL) < 0) {
> -+      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, INIT, (NULL),
> -+          ("Failed to initialize muxer"));
> -+      return GST_FLOW_ERROR;
> -+    }
> -+
> -+    /* now open the mux format */
> -+    if (av_write_header (ffmpegmux->context) < 0) {
> -+      GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, SETTINGS, (NULL),
> -+          ("Failed to write file header - check codec settings"));
> -+      return GST_FLOW_ERROR;
> -+    }
> -+
> -+    /* we're now opened */
> -+    ffmpegmux->opened = TRUE;
> -+
> -+    /* flush the header so it will be used as streamheader */
> -+    put_flush_packet (ffmpegmux->context->pb);
> -+  }
> -+
> -+  /* take the one with earliest timestamp,
> -+   * and push it forward */
> -+  best_pad = NULL;
> -+  best_time = GST_CLOCK_TIME_NONE;
> -+  for (collected = ffmpegmux->collect->data; collected;
> -+      collected = g_slist_next (collected)) {
> -+    GstFFMpegMuxPad *collect_pad = (GstFFMpegMuxPad *) collected->data;
> -+    GstBuffer *buffer = gst_collect_pads_peek (ffmpegmux->collect,
> -+        (GstCollectData *) collect_pad);
> -+
> -+    /* if there's no buffer, just continue */
> -+    if (buffer == NULL) {
> -+      continue;
> -+    }
> -+
> -+    /* if we have no buffer yet, just use the first one */
> -+    if (best_pad == NULL) {
> -+      best_pad = collect_pad;
> -+      best_time = GST_BUFFER_TIMESTAMP (buffer);
> -+      goto next_pad;
> -+    }
> -+
> -+    /* if we do have one, only use this one if it's older */
> -+    if (GST_BUFFER_TIMESTAMP (buffer) < best_time) {
> -+      best_time = GST_BUFFER_TIMESTAMP (buffer);
> -+      best_pad = collect_pad;
> -+    }
> -+
> -+  next_pad:
> -+    gst_buffer_unref (buffer);
> -+
> -+    /* Mux buffers with invalid timestamp first */
> -+    if (!GST_CLOCK_TIME_IS_VALID (best_time))
> -+      break;
> -+  }
> -+
> -+  /* now handle the buffer, or signal EOS if we have
> -+   * no buffers left */
> -+  if (best_pad != NULL) {
> -+    GstBuffer *buf;
> -+    AVPacket pkt;
> -+    gboolean need_free = FALSE;
> -+
> -+    /* push out current buffer */
> -+    buf = gst_collect_pads_pop (ffmpegmux->collect,
> -+        (GstCollectData *) best_pad);
> -+
> -+    ffmpegmux->context->streams[best_pad->padnum]->codec->frame_number++;
> -+
> -+    /* set time */
> -+    pkt.pts = gst_ffmpeg_time_gst_to_ff (GST_BUFFER_TIMESTAMP (buf),
> -+        ffmpegmux->context->streams[best_pad->padnum]->time_base);
> -+    pkt.dts = pkt.pts;
> -+
> -+    if (strcmp (ffmpegmux->context->oformat->name, "gif") == 0) {
> -+      AVStream *st = ffmpegmux->context->streams[best_pad->padnum];
> -+      AVPicture src, dst;
> -+
> -+      need_free = TRUE;
> -+      pkt.size = st->codec->width * st->codec->height * 3;
> -+      pkt.data = g_malloc (pkt.size);
> -+
> -+      dst.data[0] = pkt.data;
> -+      dst.data[1] = NULL;
> -+      dst.data[2] = NULL;
> -+      dst.linesize[0] = st->codec->width * 3;
> -+
> -+      gst_ffmpeg_avpicture_fill (&src, GST_BUFFER_DATA (buf),
> -+          PIX_FMT_RGB24, st->codec->width, st->codec->height);
> -+
> -+      av_picture_copy (&dst, &src, PIX_FMT_RGB24,
> -+          st->codec->width, st->codec->height);
> -+    } else {
> -+      pkt.data = GST_BUFFER_DATA (buf);
> -+      pkt.size = GST_BUFFER_SIZE (buf);
> -+    }
> -+
> -+    pkt.stream_index = best_pad->padnum;
> -+    pkt.flags = 0;
> -+
> -+    if (!GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT))
> -+      pkt.flags |= AV_PKT_FLAG_KEY;
> -+
> -+    if (GST_BUFFER_DURATION_IS_VALID (buf))
> -+      pkt.duration =
> -+          gst_ffmpeg_time_gst_to_ff (GST_BUFFER_DURATION (buf),
> -+          ffmpegmux->context->streams[best_pad->padnum]->time_base);
> -+    else
> -+      pkt.duration = 0;
> -+    av_write_frame (ffmpegmux->context, &pkt);
> -+    gst_buffer_unref (buf);
> -+    if (need_free)
> -+      g_free (pkt.data);
> -+  } else {
> -+    /* close down */
> -+    av_write_trailer (ffmpegmux->context);
> -+    ffmpegmux->opened = FALSE;
> -+    put_flush_packet (ffmpegmux->context->pb);
> -+    url_fclose (ffmpegmux->context->pb);
> -+    gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_eos ());
> -+    return GST_FLOW_UNEXPECTED;
> -+  }
> -+
> -+  return GST_FLOW_OK;
> -+}
> -+
> -+static GstStateChangeReturn
> -+gst_ffmpegmux_change_state (GstElement * element, GstStateChange transition)
> -+{
> -+  GstFlowReturn ret;
> -+  GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (element);
> -+
> -+  switch (transition) {
> -+    case GST_STATE_CHANGE_NULL_TO_READY:
> -+      break;
> -+    case GST_STATE_CHANGE_READY_TO_PAUSED:
> -+      gst_collect_pads_start (ffmpegmux->collect);
> -+      break;
> -+    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
> -+      break;
> -+    case GST_STATE_CHANGE_PAUSED_TO_READY:
> -+      gst_collect_pads_stop (ffmpegmux->collect);
> -+      break;
> -+    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_tag_setter_reset_tags (GST_TAG_SETTER (ffmpegmux));
> -+      if (ffmpegmux->opened) {
> -+        ffmpegmux->opened = FALSE;
> -+        url_fclose (ffmpegmux->context->pb);
> -+      }
> -+      break;
> -+    case GST_STATE_CHANGE_READY_TO_NULL:
> -+      break;
> -+    default:
> -+      break;
> -+  }
> -+
> -+  return ret;
> -+}
> -+
> -+static GstCaps *
> -+gst_ffmpegmux_get_id_caps (enum CodecID *id_list)
> -+{
> -+  GstCaps *caps, *t;
> -+  gint i;
> -+
> -+  caps = gst_caps_new_empty ();
> -+  for (i = 0; id_list[i] != CODEC_ID_NONE; i++) {
> -+    if ((t = gst_ffmpeg_codecid_to_caps (id_list[i], NULL, TRUE)))
> -+      gst_caps_append (caps, t);
> -+  }
> -+  if (gst_caps_is_empty (caps)) {
> -+    gst_caps_unref (caps);
> -+    return NULL;
> -+  }
> -+
> -+  return caps;
> -+}
> -+
> -+/* set a list of integer values on the caps, e.g. for sample rates */
> -+static void
> -+gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * caps, const gchar * field,
> -+    guint num, const gint * values)
> -+{
> -+  GValue list = { 0, };
> -+  GValue val = { 0, };
> -+  gint i;
> -+
> -+  g_return_if_fail (GST_CAPS_IS_SIMPLE (caps));
> -+
> -+  g_value_init (&list, GST_TYPE_LIST);
> -+  g_value_init (&val, G_TYPE_INT);
> -+
> -+  for (i = 0; i < num; ++i) {
> -+    g_value_set_int (&val, values[i]);
> -+    gst_value_list_append_value (&list, &val);
> -+  }
> -+
> -+  gst_structure_set_value (gst_caps_get_structure (caps, 0), field, &list);
> -+
> -+  g_value_unset (&val);
> -+  g_value_unset (&list);
> -+}
> -+
> -+gboolean
> -+gst_ffmpegmux_register (GstPlugin * plugin)
> -+{
> -+  GTypeInfo typeinfo = {
> -+    sizeof (GstFFMpegMuxClass),
> -+    (GBaseInitFunc) gst_ffmpegmux_base_init,
> -+    NULL,
> -+    (GClassInitFunc) gst_ffmpegmux_class_init,
> -+    NULL,
> -+    NULL,
> -+    sizeof (GstFFMpegMux),
> -+    0,
> -+    (GInstanceInitFunc) gst_ffmpegmux_init,
> -+  };
> -+  static const GInterfaceInfo tag_setter_info = {
> -+    NULL, NULL, NULL
> -+  };
> -+  GType type;
> -+  AVOutputFormat *in_plugin;
> -+
> -+  in_plugin = av_oformat_next (NULL);
> -+
> -+  GST_LOG ("Registering muxers");
> -+
> -+  while (in_plugin) {
> -+    gchar *type_name;
> -+    gchar *p;
> -+    GstRank rank = GST_RANK_MARGINAL;
> -+
> -+    if ((!strncmp (in_plugin->name, "u16", 3)) ||
> -+        (!strncmp (in_plugin->name, "s16", 3)) ||
> -+        (!strncmp (in_plugin->name, "u24", 3)) ||
> -+        (!strncmp (in_plugin->name, "s24", 3)) ||
> -+        (!strncmp (in_plugin->name, "u8", 2)) ||
> -+        (!strncmp (in_plugin->name, "s8", 2)) ||
> -+        (!strncmp (in_plugin->name, "u32", 3)) ||
> -+        (!strncmp (in_plugin->name, "s32", 3)) ||
> -+        (!strncmp (in_plugin->name, "f32", 3)) ||
> -+        (!strncmp (in_plugin->name, "f64", 3)) ||
> -+        (!strncmp (in_plugin->name, "raw", 3)) ||
> -+        (!strncmp (in_plugin->name, "crc", 3)) ||
> -+        (!strncmp (in_plugin->name, "null", 4)) ||
> -+        (!strncmp (in_plugin->name, "gif", 3)) ||
> -+        (!strncmp (in_plugin->name, "frame", 5)) ||
> -+        (!strncmp (in_plugin->name, "image", 5)) ||
> -+        (!strncmp (in_plugin->name, "mulaw", 5)) ||
> -+        (!strncmp (in_plugin->name, "alaw", 4)) ||
> -+        (!strncmp (in_plugin->name, "h26", 3)) ||
> -+        (!strncmp (in_plugin->name, "rtp", 3)) ||
> -+        (!strncmp (in_plugin->name, "ass", 3)) ||
> -+        (!strncmp (in_plugin->name, "ffmetadata", 10)) ||
> -+        (!strncmp (in_plugin->name, "srt", 3))
> -+        ) {
> -+      GST_LOG ("Ignoring muxer %s", in_plugin->name);
> -+      goto next;
> -+    }
> -+
> -+    if ((!strncmp (in_plugin->long_name, "raw ", 4))) {
> -+      GST_LOG ("Ignoring raw muxer %s", in_plugin->name);
> -+      goto next;
> -+    }
> -+
> -+    if (gst_ffmpegmux_get_replacement (in_plugin->name))
> -+      rank = GST_RANK_NONE;
> -+
> -+    /* FIXME : We need a fast way to know whether we have mappings for this
> -+     * muxer type. */
> -+
> -+    /* construct the type */
> -+    type_name = g_strdup_printf ("ffmux_%s", in_plugin->name);
> -+
> -+    p = type_name;
> -+
> -+    while (*p) {
> -+      if (*p == '.')
> -+        *p = '_';
> -+      p++;
> -+    }
> -+
> -+    type = g_type_from_name (type_name);
> -+
> -+    if (!type) {
> -+      /* create the type now */
> -+      type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
> -+      g_type_set_qdata (type, GST_FFMUX_PARAMS_QDATA, (gpointer) in_plugin);
> -+      g_type_add_interface_static (type, GST_TYPE_TAG_SETTER, &tag_setter_info);
> -+    }
> -+
> -+    if (!gst_element_register (plugin, type_name, rank, type)) {
> -+      g_free (type_name);
> -+      return FALSE;
> -+    }
> -+
> -+    g_free (type_name);
> -+
> -+  next:
> -+    in_plugin = av_oformat_next (in_plugin);
> -+  }
> -+
> -+  GST_LOG ("Finished registering muxers");
> -+
> -+  return TRUE;
> -+}
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegprotocol.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegprotocol.c
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegprotocol.c	2011-07-12 16:35:28.000000000 +0200
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegprotocol.c	2014-08-08 15:26:07.875857555 +0200
> -@@ -46,63 +46,14 @@
> - };
> -
> - static int
> --gst_ffmpegdata_open (URLContext * h, const char *filename, int flags)
> --{
> --  GstProtocolInfo *info;
> --  GstPad *pad;
> --
> --  GST_LOG ("Opening %s", filename);
> --
> --  info = g_new0 (GstProtocolInfo, 1);
> --
> --  info->set_streamheader = flags & GST_FFMPEG_URL_STREAMHEADER;
> --  flags &= ~GST_FFMPEG_URL_STREAMHEADER;
> --  h->flags &= ~GST_FFMPEG_URL_STREAMHEADER;
> --
> --  /* we don't support R/W together */
> --  if (flags != URL_RDONLY && flags != URL_WRONLY) {
> --    GST_WARNING ("Only read-only or write-only are supported");
> --    return -EINVAL;
> --  }
> --
> --  if (sscanf (&filename[12], "%p", &pad) != 1) {
> --    GST_WARNING ("could not decode pad from %s", filename);
> --    return -EIO;
> --  }
> --
> --  /* make sure we're a pad and that we're of the right type */
> --  g_return_val_if_fail (GST_IS_PAD (pad), -EINVAL);
> --
> --  switch (flags) {
> --    case URL_RDONLY:
> --      g_return_val_if_fail (GST_PAD_IS_SINK (pad), -EINVAL);
> --      break;
> --    case URL_WRONLY:
> --      g_return_val_if_fail (GST_PAD_IS_SRC (pad), -EINVAL);
> --      break;
> --  }
> --
> --  info->eos = FALSE;
> --  info->pad = pad;
> --  info->offset = 0;
> --
> --  h->priv_data = (void *) info;
> --  h->is_streamed = FALSE;
> --  h->max_packet_size = 0;
> --
> --  return 0;
> --}
> --
> --static int
> --gst_ffmpegdata_peek (URLContext * h, unsigned char *buf, int size)
> -+gst_ffmpegdata_peek (void *priv_data, unsigned char *buf, int size)
> - {
> -   GstProtocolInfo *info;
> -   GstBuffer *inbuf = NULL;
> -   GstFlowReturn ret;
> -   int total = 0;
> -
> --  g_return_val_if_fail (h->flags == URL_RDONLY, AVERROR (EIO));
> --  info = (GstProtocolInfo *) h->priv_data;
> -+  info = (GstProtocolInfo *) priv_data;
> -
> -   GST_DEBUG ("Pulling %d bytes at position %" G_GUINT64_FORMAT, size,
> -       info->offset);
> -@@ -134,17 +85,17 @@
> - }
> -
> - static int
> --gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size)
> -+gst_ffmpegdata_read (void *priv_data, unsigned char *buf, int size)
> - {
> -   gint res;
> -   GstProtocolInfo *info;
> -
> --  info = (GstProtocolInfo *) h->priv_data;
> -+  info = (GstProtocolInfo *) priv_data;
> -
> -   GST_DEBUG ("Reading %d bytes of data at position %" G_GUINT64_FORMAT, size,
> -       info->offset);
> -
> --  res = gst_ffmpegdata_peek (h, buf, size);
> -+  res = gst_ffmpegdata_peek (priv_data, buf, size);
> -   if (res >= 0)
> -     info->offset += res;
> -
> -@@ -154,15 +105,13 @@
> - }
> -
> - static int
> --gst_ffmpegdata_write (URLContext * h, const unsigned char *buf, int size)
> -+gst_ffmpegdata_write (void *priv_data, const unsigned char *buf, int size)
> - {
> -   GstProtocolInfo *info;
> -   GstBuffer *outbuf;
> -
> -   GST_DEBUG ("Writing %d bytes", size);
> --  info = (GstProtocolInfo *) h->priv_data;
> --
> --  g_return_val_if_fail (h->flags != URL_RDONLY, -EIO);
> -+  info = (GstProtocolInfo *) priv_data;
> -
> -   /* create buffer and push data further */
> -   if (gst_pad_alloc_buffer_and_set_caps (info->pad,
> -@@ -179,7 +128,7 @@
> - }
> -
> - static int64_t
> --gst_ffmpegdata_seek (URLContext * h, int64_t pos, int whence)
> -+gst_ffmpegdata_seek (void *priv_data, int64_t pos, int whence)
> - {
> -   GstProtocolInfo *info;
> -   guint64 newpos = 0;
> -@@ -187,70 +136,62 @@
> -   GST_DEBUG ("Seeking to %" G_GINT64_FORMAT ", whence=%d",
> -       (gint64) pos, whence);
> -
> --  info = (GstProtocolInfo *) h->priv_data;
> -+  info = (GstProtocolInfo *) priv_data;
> -
> -   /* TODO : if we are push-based, we need to return sensible info */
> -
> --  switch (h->flags) {
> --    case URL_RDONLY:
> --    {
> --      /* sinkpad */
> --      switch (whence) {
> --        case SEEK_SET:
> --          newpos = (guint64) pos;
> --          break;
> --        case SEEK_CUR:
> --          newpos = info->offset + pos;
> --          break;
> --        case SEEK_END:
> --        case AVSEEK_SIZE:
> --          /* ffmpeg wants to know the current end position in bytes ! */
> --        {
> --          GstFormat format = GST_FORMAT_BYTES;
> --          gint64 duration;
> --
> --          GST_DEBUG ("Seek end");
> --
> --          if (gst_pad_is_linked (info->pad))
> --            if (gst_pad_query_duration (GST_PAD_PEER (info->pad), &format,
> --                    &duration))
> --              newpos = ((guint64) duration) + pos;
> --        }
> --          break;
> --        default:
> --          g_assert (0);
> --          break;
> -+  if (GST_PAD_IS_SINK (info->pad)) {
> -+    /* sinkpad */
> -+    switch (whence) {
> -+      case SEEK_SET:
> -+        newpos = (guint64) pos;
> -+        break;
> -+      case SEEK_CUR:
> -+        newpos = info->offset + pos;
> -+        break;
> -+      case SEEK_END:
> -+      case AVSEEK_SIZE:
> -+        /* ffmpeg wants to know the current end position in bytes ! */
> -+      {
> -+        GstFormat format = GST_FORMAT_BYTES;
> -+        gint64 duration;
> -+
> -+        GST_DEBUG ("Seek end");
> -+
> -+        if (gst_pad_is_linked (info->pad))
> -+          if (gst_pad_query_duration (GST_PAD_PEER (info->pad), &format,
> -+                  &duration))
> -+            newpos = ((guint64) duration) + pos;
> -       }
> --      /* FIXME : implement case for push-based behaviour */
> --      if (whence != AVSEEK_SIZE)
> --        info->offset = newpos;
> -+        break;
> -+      default:
> -+        g_assert (0);
> -+        break;
> -     }
> --      break;
> --    case URL_WRONLY:
> --    {
> --      /* srcpad */
> --      switch (whence) {
> --        case SEEK_SET:
> --          info->offset = (guint64) pos;
> --          gst_pad_push_event (info->pad, gst_event_new_new_segment
> --              (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
> --                  GST_CLOCK_TIME_NONE, info->offset));
> --          break;
> --        case SEEK_CUR:
> --          info->offset += pos;
> --          gst_pad_push_event (info->pad, gst_event_new_new_segment
> --              (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
> --                  GST_CLOCK_TIME_NONE, info->offset));
> --          break;
> --        default:
> --          break;
> --      }
> --      newpos = info->offset;
> -+    /* FIXME : implement case for push-based behaviour */
> -+    if (whence != AVSEEK_SIZE)
> -+      info->offset = newpos;
> -+  } else if (GST_PAD_IS_SRC (info->pad)) {
> -+    /* srcpad */
> -+    switch (whence) {
> -+      case SEEK_SET:
> -+        info->offset = (guint64) pos;
> -+        gst_pad_push_event (info->pad, gst_event_new_new_segment
> -+            (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
> -+                GST_CLOCK_TIME_NONE, info->offset));
> -+        break;
> -+      case SEEK_CUR:
> -+        info->offset += pos;
> -+        gst_pad_push_event (info->pad, gst_event_new_new_segment
> -+            (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
> -+                GST_CLOCK_TIME_NONE, info->offset));
> -+        break;
> -+      default:
> -+        break;
> -     }
> --      break;
> --    default:
> --      g_assert (0);
> --      break;
> -+    newpos = info->offset;
> -+  } else {
> -+    g_assert_not_reached ();
> -   }
> -
> -   GST_DEBUG ("Now at offset %" G_GUINT64_FORMAT " (returning %" G_GUINT64_FORMAT
> -@@ -258,85 +199,91 @@
> -   return newpos;
> - }
> -
> --static int
> --gst_ffmpegdata_close (URLContext * h)
> -+int
> -+gst_ffmpegdata_close (AVIOContext * h)
> - {
> -   GstProtocolInfo *info;
> -
> --  info = (GstProtocolInfo *) h->priv_data;
> -+  info = (GstProtocolInfo *) h->opaque;
> -   if (info == NULL)
> -     return 0;
> -
> -   GST_LOG ("Closing file");
> -
> --  switch (h->flags) {
> --    case URL_WRONLY:
> --    {
> --      /* send EOS - that closes down the stream */
> --      gst_pad_push_event (info->pad, gst_event_new_eos ());
> --      break;
> --    }
> --    default:
> --      break;
> -+  if (GST_PAD_IS_SRC (info->pad)) {
> -+    /* send EOS - that closes down the stream */
> -+    gst_pad_push_event (info->pad, gst_event_new_eos ());
> -   }
> -
> -   /* clean up data */
> -   g_free (info);
> --  h->priv_data = NULL;
> -+  h->opaque = NULL;
> -+
> -+  av_freep (&h->buffer);
> -+  av_free (h);
> -
> -   return 0;
> - }
> -
> -+int
> -+gst_ffmpegdata_open (GstPad * pad, int flags, AVIOContext ** context)
> -+{
> -+  GstProtocolInfo *info;
> -+  static const int buffer_size = 4096;
> -+  unsigned char *buffer = NULL;
> -
> --URLProtocol gstreamer_protocol = {
> --  /*.name = */ "gstreamer",
> --  /*.url_open = */ gst_ffmpegdata_open,
> --  /*.url_read = */ gst_ffmpegdata_read,
> --  /*.url_write = */ gst_ffmpegdata_write,
> --  /*.url_seek = */ gst_ffmpegdata_seek,
> --  /*.url_close = */ gst_ffmpegdata_close,
> --};
> -+  info = g_new0 (GstProtocolInfo, 1);
> -
> -+  info->set_streamheader = flags & GST_FFMPEG_URL_STREAMHEADER;
> -+  flags &= ~GST_FFMPEG_URL_STREAMHEADER;
> -
> --/* specialized protocol for cross-thread pushing,
> -- * based on ffmpeg's pipe protocol */
> -+  /* we don't support R/W together */
> -+  if ((flags & AVIO_FLAG_WRITE) && (flags & AVIO_FLAG_READ)) {
> -+    GST_WARNING ("Only read-only or write-only are supported");
> -+    return -EINVAL;
> -+  }
> -
> --static int
> --gst_ffmpeg_pipe_open (URLContext * h, const char *filename, int flags)
> --{
> --  GstFFMpegPipe *ffpipe;
> -+  /* make sure we're a pad and that we're of the right type */
> -+  g_return_val_if_fail (GST_IS_PAD (pad), -EINVAL);
> -
> --  GST_LOG ("Opening %s", filename);
> -+  if ((flags & AVIO_FLAG_READ))
> -+    g_return_val_if_fail (GST_PAD_IS_SINK (pad), -EINVAL);
> -+  if ((flags & AVIO_FLAG_WRITE))
> -+    g_return_val_if_fail (GST_PAD_IS_SRC (pad), -EINVAL);
> -
> --  /* we don't support W together */
> --  if (flags != URL_RDONLY) {
> --    GST_WARNING ("Only read-only is supported");
> --    return -EINVAL;
> --  }
> -+  info->eos = FALSE;
> -+  info->pad = pad;
> -+  info->offset = 0;
> -
> --  if (sscanf (&filename[10], "%p", &ffpipe) != 1) {
> --    GST_WARNING ("could not decode pipe info from %s", filename);
> --    return -EIO;
> -+  buffer = av_malloc (buffer_size);
> -+  if (buffer == NULL) {
> -+    GST_WARNING ("Failed to allocate buffer");
> -+    return -ENOMEM;
> -   }
> -
> --  /* sanity check */
> --  g_return_val_if_fail (GST_IS_ADAPTER (ffpipe->adapter), -EINVAL);
> --
> --  h->priv_data = (void *) ffpipe;
> --  h->is_streamed = TRUE;
> --  h->max_packet_size = 0;
> -+  *context =
> -+      avio_alloc_context (buffer, buffer_size, flags, (void *) info,
> -+      gst_ffmpegdata_read, gst_ffmpegdata_write, gst_ffmpegdata_seek);
> -+  (*context)->seekable = AVIO_SEEKABLE_NORMAL;
> -+  if (!(flags & AVIO_FLAG_WRITE)) {
> -+    (*context)->buf_ptr = (*context)->buf_end;
> -+    (*context)->write_flag = 0;
> -+  }
> -
> -   return 0;
> - }
> -
> -+/* specialized protocol for cross-thread pushing,
> -+ * based on ffmpeg's pipe protocol */
> -+
> - static int
> --gst_ffmpeg_pipe_read (URLContext * h, unsigned char *buf, int size)
> -+gst_ffmpeg_pipe_read (void *priv_data, unsigned char *buf, int size)
> - {
> -   GstFFMpegPipe *ffpipe;
> -   const guint8 *data;
> -   guint available;
> -
> --  ffpipe = (GstFFMpegPipe *) h->priv_data;
> -+  ffpipe = (GstFFMpegPipe *) priv_data;
> -
> -   GST_LOG ("requested size %d", size);
> -
> -@@ -367,21 +314,38 @@
> -   return size;
> - }
> -
> --static int
> --gst_ffmpeg_pipe_close (URLContext * h)
> -+int
> -+gst_ffmpeg_pipe_close (AVIOContext * h)
> - {
> -   GST_LOG ("Closing pipe");
> -
> --  h->priv_data = NULL;
> -+  h->opaque = NULL;
> -+  av_freep (&h->buffer);
> -+  av_free (h);
> -
> -   return 0;
> - }
> -
> --URLProtocol gstpipe_protocol = {
> --  "gstpipe",
> --  gst_ffmpeg_pipe_open,
> --  gst_ffmpeg_pipe_read,
> --  NULL,
> --  NULL,
> --  gst_ffmpeg_pipe_close,
> --};
> -+int
> -+gst_ffmpeg_pipe_open (GstFFMpegPipe * ffpipe, int flags, AVIOContext ** context)
> -+{
> -+  static const int buffer_size = 4096;
> -+  unsigned char *buffer = NULL;
> -+
> -+  /* sanity check */
> -+  g_return_val_if_fail (GST_IS_ADAPTER (ffpipe->adapter), -EINVAL);
> -+
> -+  buffer = av_malloc (buffer_size);
> -+  if (buffer == NULL) {
> -+    GST_WARNING ("Failed to allocate buffer");
> -+    return -ENOMEM;
> -+  }
> -+
> -+  *context =
> -+      avio_alloc_context (buffer, buffer_size, 0, (void *) ffpipe,
> -+      gst_ffmpeg_pipe_read, NULL, NULL);
> -+  (*context)->seekable = 0;
> -+  (*context)->buf_ptr = (*context)->buf_end;
> -+
> -+  return 0;
> -+}
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c	2011-07-13 11:07:28.000000000 +0200
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c	2014-08-08 15:34:04.007874626 +0200
> -@@ -25,6 +25,11 @@
> - #ifdef __APPLE__
> - #include <sys/sysctl.h>
> - #endif
> -+#ifdef HAVE_FFMPEG_UNINSTALLED
> -+#include <avformat.h>
> -+#else
> -+#include <libavformat/avformat.h>
> -+#endif
> -
> - G_CONST_RETURN gchar *
> - gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
> -@@ -39,21 +44,21 @@
> - }
> -
> - gint
> --av_smp_format_depth (enum SampleFormat smp_fmt)
> -+av_smp_format_depth (enum AVSampleFormat smp_fmt)
> - {
> -   gint depth = -1;
> -   switch (smp_fmt) {
> --    case SAMPLE_FMT_U8:
> -+    case AV_SAMPLE_FMT_U8:
> -       depth = 1;
> -       break;
> --    case SAMPLE_FMT_S16:
> -+    case AV_SAMPLE_FMT_S16:
> -       depth = 2;
> -       break;
> --    case SAMPLE_FMT_S32:
> --    case SAMPLE_FMT_FLT:
> -+    case AV_SAMPLE_FMT_S32:
> -+    case AV_SAMPLE_FMT_FLT:
> -       depth = 4;
> -       break;
> --    case SAMPLE_FMT_DBL:
> -+    case AV_SAMPLE_FMT_DBL:
> -       depth = 8;
> -       break;
> -     default:
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c.orig
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c.orig	1970-01-01 01:00:00.000000000 +0100
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c.orig	2011-07-13 11:07:28.000000000 +0200
> -@@ -0,0 +1,483 @@
> -+/* GStreamer
> -+ * Copyright (c) 2009 Edward Hervey <bilboed@bilboed.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.
> -+ */
> -+
> -+#ifdef HAVE_CONFIG_H
> -+#include "config.h"
> -+#endif
> -+#include "gstffmpegutils.h"
> -+#include <unistd.h>
> -+#ifdef __APPLE__
> -+#include <sys/sysctl.h>
> -+#endif
> -+
> -+G_CONST_RETURN gchar *
> -+gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
> -+{
> -+  AVCodec *codec;
> -+  /* Let's use what ffmpeg can provide us */
> -+
> -+  if ((codec = avcodec_find_decoder (codec_id)) ||
> -+      (codec = avcodec_find_encoder (codec_id)))
> -+    return codec->long_name;
> -+  return NULL;
> -+}
> -+
> -+gint
> -+av_smp_format_depth (enum SampleFormat smp_fmt)
> -+{
> -+  gint depth = -1;
> -+  switch (smp_fmt) {
> -+    case SAMPLE_FMT_U8:
> -+      depth = 1;
> -+      break;
> -+    case SAMPLE_FMT_S16:
> -+      depth = 2;
> -+      break;
> -+    case SAMPLE_FMT_S32:
> -+    case SAMPLE_FMT_FLT:
> -+      depth = 4;
> -+      break;
> -+    case SAMPLE_FMT_DBL:
> -+      depth = 8;
> -+      break;
> -+    default:
> -+      GST_ERROR ("UNHANDLED SAMPLE FORMAT !");
> -+      break;
> -+  }
> -+  return depth;
> -+}
> -+
> -+
> -+/*
> -+ * Fill in pointers to memory in a AVPicture, where
> -+ * everything is aligned by 4 (as required by X).
> -+ * This is mostly a copy from imgconvert.c with some
> -+ * small changes.
> -+ */
> -+
> -+#define FF_COLOR_RGB      0     /* RGB color space */
> -+#define FF_COLOR_GRAY     1     /* gray color space */
> -+#define FF_COLOR_YUV      2     /* YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */
> -+#define FF_COLOR_YUV_JPEG 3     /* YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */
> -+
> -+#define FF_PIXEL_PLANAR   0     /* each channel has one component in AVPicture */
> -+#define FF_PIXEL_PACKED   1     /* only one components containing all the channels */
> -+#define FF_PIXEL_PALETTE  2     /* one components containing indexes for a palette */
> -+
> -+typedef struct PixFmtInfo
> -+{
> -+  const char *name;
> -+  uint8_t nb_channels;          /* number of channels (including alpha) */
> -+  uint8_t color_type;           /* color type (see FF_COLOR_xxx constants) */
> -+  uint8_t pixel_type;           /* pixel storage type (see FF_PIXEL_xxx constants) */
> -+  uint8_t is_alpha:1;           /* true if alpha can be specified */
> -+  uint8_t x_chroma_shift;       /* X chroma subsampling factor is 2 ^ shift */
> -+  uint8_t y_chroma_shift;       /* Y chroma subsampling factor is 2 ^ shift */
> -+  uint8_t depth;                /* bit depth of the color components */
> -+} PixFmtInfo;
> -+
> -+
> -+/* this table gives more information about formats */
> -+static PixFmtInfo pix_fmt_info[PIX_FMT_NB];
> -+void
> -+gst_ffmpeg_init_pix_fmt_info (void)
> -+{
> -+  /* YUV formats */
> -+  pix_fmt_info[PIX_FMT_YUV420P].name = g_strdup ("yuv420p");
> -+  pix_fmt_info[PIX_FMT_YUV420P].nb_channels = 3;
> -+  pix_fmt_info[PIX_FMT_YUV420P].color_type = FF_COLOR_YUV;
> -+  pix_fmt_info[PIX_FMT_YUV420P].pixel_type = FF_PIXEL_PLANAR;
> -+  pix_fmt_info[PIX_FMT_YUV420P].depth = 8,
> -+      pix_fmt_info[PIX_FMT_YUV420P].x_chroma_shift = 1,
> -+      pix_fmt_info[PIX_FMT_YUV420P].y_chroma_shift = 1;
> -+
> -+  pix_fmt_info[PIX_FMT_YUV422P].name = g_strdup ("yuv422p");
> -+  pix_fmt_info[PIX_FMT_YUV422P].nb_channels = 3;
> -+  pix_fmt_info[PIX_FMT_YUV422P].color_type = FF_COLOR_YUV;
> -+  pix_fmt_info[PIX_FMT_YUV422P].pixel_type = FF_PIXEL_PLANAR;
> -+  pix_fmt_info[PIX_FMT_YUV422P].depth = 8;
> -+  pix_fmt_info[PIX_FMT_YUV422P].x_chroma_shift = 1;
> -+  pix_fmt_info[PIX_FMT_YUV422P].y_chroma_shift = 0;
> -+
> -+  pix_fmt_info[PIX_FMT_YUV444P].name = g_strdup ("yuv444p");
> -+  pix_fmt_info[PIX_FMT_YUV444P].nb_channels = 3;
> -+  pix_fmt_info[PIX_FMT_YUV444P].color_type = FF_COLOR_YUV;
> -+  pix_fmt_info[PIX_FMT_YUV444P].pixel_type = FF_PIXEL_PLANAR;
> -+  pix_fmt_info[PIX_FMT_YUV444P].depth = 8;
> -+  pix_fmt_info[PIX_FMT_YUV444P].x_chroma_shift = 0;
> -+  pix_fmt_info[PIX_FMT_YUV444P].y_chroma_shift = 0;
> -+
> -+  pix_fmt_info[PIX_FMT_YUYV422].name = g_strdup ("yuv422");
> -+  pix_fmt_info[PIX_FMT_YUYV422].nb_channels = 1;
> -+  pix_fmt_info[PIX_FMT_YUYV422].color_type = FF_COLOR_YUV;
> -+  pix_fmt_info[PIX_FMT_YUYV422].pixel_type = FF_PIXEL_PACKED;
> -+  pix_fmt_info[PIX_FMT_YUYV422].depth = 8;
> -+  pix_fmt_info[PIX_FMT_YUYV422].x_chroma_shift = 1;
> -+  pix_fmt_info[PIX_FMT_YUYV422].y_chroma_shift = 0;
> -+
> -+  pix_fmt_info[PIX_FMT_YUV410P].name = g_strdup ("yuv410p");
> -+  pix_fmt_info[PIX_FMT_YUV410P].nb_channels = 3;
> -+  pix_fmt_info[PIX_FMT_YUV410P].color_type = FF_COLOR_YUV;
> -+  pix_fmt_info[PIX_FMT_YUV410P].pixel_type = FF_PIXEL_PLANAR;
> -+  pix_fmt_info[PIX_FMT_YUV410P].depth = 8;
> -+  pix_fmt_info[PIX_FMT_YUV410P].x_chroma_shift = 2;
> -+  pix_fmt_info[PIX_FMT_YUV410P].y_chroma_shift = 2;
> -+
> -+  pix_fmt_info[PIX_FMT_YUV411P].name = g_strdup ("yuv411p");
> -+  pix_fmt_info[PIX_FMT_YUV411P].nb_channels = 3;
> -+  pix_fmt_info[PIX_FMT_YUV411P].color_type = FF_COLOR_YUV;
> -+  pix_fmt_info[PIX_FMT_YUV411P].pixel_type = FF_PIXEL_PLANAR;
> -+  pix_fmt_info[PIX_FMT_YUV411P].depth = 8;
> -+  pix_fmt_info[PIX_FMT_YUV411P].x_chroma_shift = 2;
> -+  pix_fmt_info[PIX_FMT_YUV411P].y_chroma_shift = 0;
> -+
> -+  /* JPEG YUV */
> -+  pix_fmt_info[PIX_FMT_YUVJ420P].name = g_strdup ("yuvj420p");
> -+  pix_fmt_info[PIX_FMT_YUVJ420P].nb_channels = 3;
> -+  pix_fmt_info[PIX_FMT_YUVJ420P].color_type = FF_COLOR_YUV_JPEG;
> -+  pix_fmt_info[PIX_FMT_YUVJ420P].pixel_type = FF_PIXEL_PLANAR;
> -+  pix_fmt_info[PIX_FMT_YUVJ420P].depth = 8;
> -+  pix_fmt_info[PIX_FMT_YUVJ420P].x_chroma_shift = 1;
> -+  pix_fmt_info[PIX_FMT_YUVJ420P].y_chroma_shift = 1;
> -+
> -+  pix_fmt_info[PIX_FMT_YUVJ422P].name = g_strdup ("yuvj422p");
> -+  pix_fmt_info[PIX_FMT_YUVJ422P].nb_channels = 3;
> -+  pix_fmt_info[PIX_FMT_YUVJ422P].color_type = FF_COLOR_YUV_JPEG;
> -+  pix_fmt_info[PIX_FMT_YUVJ422P].pixel_type = FF_PIXEL_PLANAR;
> -+  pix_fmt_info[PIX_FMT_YUVJ422P].depth = 8;
> -+  pix_fmt_info[PIX_FMT_YUVJ422P].x_chroma_shift = 1;
> -+  pix_fmt_info[PIX_FMT_YUVJ422P].y_chroma_shift = 0;
> -+
> -+  pix_fmt_info[PIX_FMT_YUVJ444P].name = g_strdup ("yuvj444p");
> -+  pix_fmt_info[PIX_FMT_YUVJ444P].nb_channels = 3;
> -+  pix_fmt_info[PIX_FMT_YUVJ444P].color_type = FF_COLOR_YUV_JPEG;
> -+  pix_fmt_info[PIX_FMT_YUVJ444P].pixel_type = FF_PIXEL_PLANAR;
> -+  pix_fmt_info[PIX_FMT_YUVJ444P].depth = 8;
> -+  pix_fmt_info[PIX_FMT_YUVJ444P].x_chroma_shift = 0;
> -+  pix_fmt_info[PIX_FMT_YUVJ444P].y_chroma_shift = 0;
> -+
> -+  /* RGB formats */
> -+  pix_fmt_info[PIX_FMT_RGB24].name = g_strdup ("rgb24");
> -+  pix_fmt_info[PIX_FMT_RGB24].nb_channels = 3;
> -+  pix_fmt_info[PIX_FMT_RGB24].color_type = FF_COLOR_RGB;
> -+  pix_fmt_info[PIX_FMT_RGB24].pixel_type = FF_PIXEL_PACKED;
> -+  pix_fmt_info[PIX_FMT_RGB24].depth = 8;
> -+  pix_fmt_info[PIX_FMT_RGB24].x_chroma_shift = 0;
> -+  pix_fmt_info[PIX_FMT_RGB24].y_chroma_shift = 0;
> -+
> -+  pix_fmt_info[PIX_FMT_BGR24].name = g_strdup ("bgr24");
> -+  pix_fmt_info[PIX_FMT_BGR24].nb_channels = 3;
> -+  pix_fmt_info[PIX_FMT_BGR24].color_type = FF_COLOR_RGB;
> -+  pix_fmt_info[PIX_FMT_BGR24].pixel_type = FF_PIXEL_PACKED;
> -+  pix_fmt_info[PIX_FMT_BGR24].depth = 8;
> -+  pix_fmt_info[PIX_FMT_BGR24].x_chroma_shift = 0;
> -+  pix_fmt_info[PIX_FMT_BGR24].y_chroma_shift = 0;
> -+
> -+  pix_fmt_info[PIX_FMT_RGB32].name = g_strdup ("rgba32");
> -+  pix_fmt_info[PIX_FMT_RGB32].nb_channels = 4;
> -+  pix_fmt_info[PIX_FMT_RGB32].is_alpha = 1;
> -+  pix_fmt_info[PIX_FMT_RGB32].color_type = FF_COLOR_RGB;
> -+  pix_fmt_info[PIX_FMT_RGB32].pixel_type = FF_PIXEL_PACKED;
> -+  pix_fmt_info[PIX_FMT_RGB32].depth = 8;
> -+  pix_fmt_info[PIX_FMT_RGB32].x_chroma_shift = 0;
> -+  pix_fmt_info[PIX_FMT_RGB32].y_chroma_shift = 0;
> -+
> -+  pix_fmt_info[PIX_FMT_RGB565].name = g_strdup ("rgb565");
> -+  pix_fmt_info[PIX_FMT_RGB565].nb_channels = 3;
> -+  pix_fmt_info[PIX_FMT_RGB565].color_type = FF_COLOR_RGB;
> -+  pix_fmt_info[PIX_FMT_RGB565].pixel_type = FF_PIXEL_PACKED;
> -+  pix_fmt_info[PIX_FMT_RGB565].depth = 5;
> -+  pix_fmt_info[PIX_FMT_RGB565].x_chroma_shift = 0;
> -+  pix_fmt_info[PIX_FMT_RGB565].y_chroma_shift = 0;
> -+
> -+  pix_fmt_info[PIX_FMT_RGB555].name = g_strdup ("rgb555");
> -+  pix_fmt_info[PIX_FMT_RGB555].nb_channels = 4;
> -+  pix_fmt_info[PIX_FMT_RGB555].is_alpha = 1;
> -+  pix_fmt_info[PIX_FMT_RGB555].color_type = FF_COLOR_RGB;
> -+  pix_fmt_info[PIX_FMT_RGB555].pixel_type = FF_PIXEL_PACKED;
> -+  pix_fmt_info[PIX_FMT_RGB555].depth = 5;
> -+  pix_fmt_info[PIX_FMT_RGB555].x_chroma_shift = 0;
> -+  pix_fmt_info[PIX_FMT_RGB555].y_chroma_shift = 0;
> -+
> -+  /* gray / mono formats */
> -+  pix_fmt_info[PIX_FMT_GRAY8].name = g_strdup ("gray");
> -+  pix_fmt_info[PIX_FMT_GRAY8].nb_channels = 1;
> -+  pix_fmt_info[PIX_FMT_GRAY8].color_type = FF_COLOR_GRAY;
> -+  pix_fmt_info[PIX_FMT_GRAY8].pixel_type = FF_PIXEL_PLANAR;
> -+  pix_fmt_info[PIX_FMT_GRAY8].depth = 8;
> -+
> -+  pix_fmt_info[PIX_FMT_MONOWHITE].name = g_strdup ("monow");
> -+  pix_fmt_info[PIX_FMT_MONOWHITE].nb_channels = 1;
> -+  pix_fmt_info[PIX_FMT_MONOWHITE].color_type = FF_COLOR_GRAY;
> -+  pix_fmt_info[PIX_FMT_MONOWHITE].pixel_type = FF_PIXEL_PLANAR;
> -+  pix_fmt_info[PIX_FMT_MONOWHITE].depth = 1;
> -+
> -+  pix_fmt_info[PIX_FMT_MONOBLACK].name = g_strdup ("monob");
> -+  pix_fmt_info[PIX_FMT_MONOBLACK].nb_channels = 1;
> -+  pix_fmt_info[PIX_FMT_MONOBLACK].color_type = FF_COLOR_GRAY;
> -+  pix_fmt_info[PIX_FMT_MONOBLACK].pixel_type = FF_PIXEL_PLANAR;
> -+  pix_fmt_info[PIX_FMT_MONOBLACK].depth = 1;
> -+
> -+  /* paletted formats */
> -+  pix_fmt_info[PIX_FMT_PAL8].name = g_strdup ("pal8");
> -+  pix_fmt_info[PIX_FMT_PAL8].nb_channels = 4;
> -+  pix_fmt_info[PIX_FMT_PAL8].is_alpha = 1;
> -+  pix_fmt_info[PIX_FMT_PAL8].color_type = FF_COLOR_RGB;
> -+  pix_fmt_info[PIX_FMT_PAL8].pixel_type = FF_PIXEL_PALETTE;
> -+  pix_fmt_info[PIX_FMT_PAL8].depth = 8;
> -+
> -+  pix_fmt_info[PIX_FMT_YUVA420P].name = g_strdup ("yuva420p");
> -+  pix_fmt_info[PIX_FMT_YUVA420P].nb_channels = 4;
> -+  pix_fmt_info[PIX_FMT_YUVA420P].is_alpha = 1;
> -+  pix_fmt_info[PIX_FMT_YUVA420P].color_type = FF_COLOR_YUV;
> -+  pix_fmt_info[PIX_FMT_YUVA420P].pixel_type = FF_PIXEL_PLANAR;
> -+  pix_fmt_info[PIX_FMT_YUVA420P].depth = 8,
> -+      pix_fmt_info[PIX_FMT_YUVA420P].x_chroma_shift = 1,
> -+      pix_fmt_info[PIX_FMT_YUVA420P].y_chroma_shift = 1;
> -+};
> -+
> -+int
> -+gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height)
> -+{
> -+  AVPicture dummy_pict;
> -+
> -+  return gst_ffmpeg_avpicture_fill (&dummy_pict, NULL, pix_fmt, width, height);
> -+}
> -+
> -+#define GEN_MASK(x) ((1<<(x))-1)
> -+#define ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) & ~GEN_MASK(x))
> -+#define ROUND_UP_2(x) ROUND_UP_X (x, 1)
> -+#define ROUND_UP_4(x) ROUND_UP_X (x, 2)
> -+#define ROUND_UP_8(x) ROUND_UP_X (x, 3)
> -+#define DIV_ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) >> (x))
> -+
> -+int
> -+gst_ffmpeg_avpicture_fill (AVPicture * picture,
> -+    uint8_t * ptr, enum PixelFormat pix_fmt, int width, int height)
> -+{
> -+  int size, w2, h2, size2;
> -+  int stride, stride2;
> -+  PixFmtInfo *pinfo;
> -+
> -+  pinfo = &pix_fmt_info[pix_fmt];
> -+
> -+  switch (pix_fmt) {
> -+    case PIX_FMT_YUV420P:
> -+    case PIX_FMT_YUV422P:
> -+    case PIX_FMT_YUV444P:
> -+    case PIX_FMT_YUV410P:
> -+    case PIX_FMT_YUV411P:
> -+    case PIX_FMT_YUVJ420P:
> -+    case PIX_FMT_YUVJ422P:
> -+    case PIX_FMT_YUVJ444P:
> -+      stride = ROUND_UP_4 (width);
> -+      h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
> -+      size = stride * h2;
> -+      w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
> -+      stride2 = ROUND_UP_4 (w2);
> -+      h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift);
> -+      size2 = stride2 * h2;
> -+      picture->data[0] = ptr;
> -+      picture->data[1] = picture->data[0] + size;
> -+      picture->data[2] = picture->data[1] + size2;
> -+      picture->data[3] = NULL;
> -+      picture->linesize[0] = stride;
> -+      picture->linesize[1] = stride2;
> -+      picture->linesize[2] = stride2;
> -+      picture->linesize[3] = 0;
> -+      GST_DEBUG ("planes %d %d %d", 0, size, size + size2);
> -+      GST_DEBUG ("strides %d %d %d", stride, stride2, stride2);
> -+      return size + 2 * size2;
> -+    case PIX_FMT_YUVA420P:
> -+      stride = ROUND_UP_4 (width);
> -+      h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
> -+      size = stride * h2;
> -+      w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
> -+      stride2 = ROUND_UP_4 (w2);
> -+      h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift);
> -+      size2 = stride2 * h2;
> -+      picture->data[0] = ptr;
> -+      picture->data[1] = picture->data[0] + size;
> -+      picture->data[2] = picture->data[1] + size2;
> -+      picture->data[3] = picture->data[2] + size2;
> -+      picture->linesize[0] = stride;
> -+      picture->linesize[1] = stride2;
> -+      picture->linesize[2] = stride2;
> -+      picture->linesize[3] = stride;
> -+      GST_DEBUG ("planes %d %d %d %d", 0, size, size + size2, size + 2 * size2);
> -+      GST_DEBUG ("strides %d %d %d %d", stride, stride2, stride2, stride);
> -+      return 2 * size + 2 * size2;
> -+    case PIX_FMT_RGB24:
> -+    case PIX_FMT_BGR24:
> -+      stride = ROUND_UP_4 (width * 3);
> -+      size = stride * height;
> -+      picture->data[0] = ptr;
> -+      picture->data[1] = NULL;
> -+      picture->data[2] = NULL;
> -+      picture->data[3] = NULL;
> -+      picture->linesize[0] = stride;
> -+      picture->linesize[1] = 0;
> -+      picture->linesize[2] = 0;
> -+      picture->linesize[3] = 0;
> -+      return size;
> -+      /*case PIX_FMT_AYUV4444:
> -+         case PIX_FMT_BGR32:
> -+         case PIX_FMT_BGRA32:
> -+         case PIX_FMT_RGB32: */
> -+    case PIX_FMT_RGB32:
> -+      stride = width * 4;
> -+      size = stride * height;
> -+      picture->data[0] = ptr;
> -+      picture->data[1] = NULL;
> -+      picture->data[2] = NULL;
> -+      picture->data[3] = NULL;
> -+      picture->linesize[0] = stride;
> -+      picture->linesize[1] = 0;
> -+      picture->linesize[2] = 0;
> -+      picture->linesize[3] = 0;
> -+      return size;
> -+    case PIX_FMT_RGB555:
> -+    case PIX_FMT_RGB565:
> -+    case PIX_FMT_YUYV422:
> -+    case PIX_FMT_UYVY422:
> -+      stride = ROUND_UP_4 (width * 2);
> -+      size = stride * height;
> -+      picture->data[0] = ptr;
> -+      picture->data[1] = NULL;
> -+      picture->data[2] = NULL;
> -+      picture->data[3] = NULL;
> -+      picture->linesize[0] = stride;
> -+      picture->linesize[1] = 0;
> -+      picture->linesize[2] = 0;
> -+      picture->linesize[3] = 0;
> -+      return size;
> -+    case PIX_FMT_UYYVYY411:
> -+      /* FIXME, probably not the right stride */
> -+      stride = ROUND_UP_4 (width);
> -+      size = stride * height;
> -+      picture->data[0] = ptr;
> -+      picture->data[1] = NULL;
> -+      picture->data[2] = NULL;
> -+      picture->data[3] = NULL;
> -+      picture->linesize[0] = width + width / 2;
> -+      picture->linesize[1] = 0;
> -+      picture->linesize[2] = 0;
> -+      picture->linesize[3] = 0;
> -+      return size + size / 2;
> -+    case PIX_FMT_GRAY8:
> -+      stride = ROUND_UP_4 (width);
> -+      size = stride * height;
> -+      picture->data[0] = ptr;
> -+      picture->data[1] = NULL;
> -+      picture->data[2] = NULL;
> -+      picture->data[3] = NULL;
> -+      picture->linesize[0] = stride;
> -+      picture->linesize[1] = 0;
> -+      picture->linesize[2] = 0;
> -+      picture->linesize[3] = 0;
> -+      return size;
> -+    case PIX_FMT_MONOWHITE:
> -+    case PIX_FMT_MONOBLACK:
> -+      stride = ROUND_UP_4 ((width + 7) >> 3);
> -+      size = stride * height;
> -+      picture->data[0] = ptr;
> -+      picture->data[1] = NULL;
> -+      picture->data[2] = NULL;
> -+      picture->data[3] = NULL;
> -+      picture->linesize[0] = stride;
> -+      picture->linesize[1] = 0;
> -+      picture->linesize[2] = 0;
> -+      picture->linesize[3] = 0;
> -+      return size;
> -+    case PIX_FMT_PAL8:
> -+      /* already forced to be with stride, so same result as other function */
> -+      stride = ROUND_UP_4 (width);
> -+      size = stride * height;
> -+      picture->data[0] = ptr;
> -+      picture->data[1] = ptr + size;    /* palette is stored here as 256 32 bit words */
> -+      picture->data[2] = NULL;
> -+      picture->data[3] = NULL;
> -+      picture->linesize[0] = stride;
> -+      picture->linesize[1] = 4;
> -+      picture->linesize[2] = 0;
> -+      picture->linesize[3] = 0;
> -+      return size + 256 * 4;
> -+    default:
> -+      picture->data[0] = NULL;
> -+      picture->data[1] = NULL;
> -+      picture->data[2] = NULL;
> -+      picture->data[3] = NULL;
> -+      return -1;
> -+  }
> -+
> -+  return 0;
> -+}
> -+
> -+/* Create a GstBuffer of the requested size and caps.
> -+ * The memory will be allocated by ffmpeg, making sure it's properly aligned
> -+ * for any processing. */
> -+
> -+GstBuffer *
> -+new_aligned_buffer (gint size, GstCaps * caps)
> -+{
> -+  GstBuffer *buf;
> -+
> -+  buf = gst_buffer_new ();
> -+  GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = av_malloc (size);
> -+  GST_BUFFER_SIZE (buf) = size;
> -+  GST_BUFFER_FREE_FUNC (buf) = av_free;
> -+  if (caps)
> -+    gst_buffer_set_caps (buf, caps);
> -+
> -+  return buf;
> -+}
> -+
> -+int
> -+gst_ffmpeg_auto_max_threads (void)
> -+{
> -+  static gsize n_threads = 0;
> -+  if (g_once_init_enter (&n_threads)) {
> -+    int n = 1;
> -+#if defined(_WIN32)
> -+    {
> -+      const char *s = getenv ("NUMBER_OF_PROCESSORS");
> -+      if (s) {
> -+        n = atoi (s);
> -+      }
> -+    }
> -+#elif defined(__APPLE__)
> -+    {
> -+      int mib[] = { CTL_HW, HW_NCPU };
> -+      size_t dataSize = sizeof (int);
> -+
> -+      if (sysctl (mib, 2, &n_threads, &dataSize, NULL, 0)) {
> -+        n = 1;
> -+      }
> -+    }
> -+#else
> -+    n = sysconf (_SC_NPROCESSORS_CONF);
> -+#endif
> -+    if (n < 1)
> -+      n = 1;
> -+
> -+    g_once_init_leave (&n_threads, n);
> -+  }
> -+
> -+  return (int) (n_threads);
> -+}
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h	2011-11-02 14:04:05.000000000 +0100
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h	2014-08-08 15:34:04.007874626 +0200
> -@@ -23,6 +23,7 @@
> - #ifdef HAVE_FFMPEG_UNINSTALLED
> - #include <avcodec.h>
> - #else
> -+#include <libavutil/mathematics.h>
> - #include <libavcodec/avcodec.h>
> - #endif
> - #include <gst/gst.h>
> -@@ -87,7 +88,7 @@
> - gst_ffmpeg_get_codecid_longname (enum CodecID codec_id);
> -
> - gint
> --av_smp_format_depth(enum SampleFormat smp_fmt);
> -+av_smp_format_depth(enum AVSampleFormat smp_fmt);
> -
> - GstBuffer *
> - new_aligned_buffer (gint size, GstCaps * caps);
> -diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h.orig
> ---- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h.orig	1970-01-01 01:00:00.000000000 +0100
> -+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h.orig	2014-08-08 15:26:38.473858652 +0200
> -@@ -0,0 +1,95 @@
> -+/* GStreamer
> -+ * Copyright (C) <2009> Edward Hervey <bilboed@bilboed.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.
> -+ */
> -+
> -+#ifndef __GST_FFMPEG_UTILS_H__
> -+#define __GST_FFMPEG_UTILS_H__
> -+
> -+#ifdef HAVE_FFMPEG_UNINSTALLED
> -+#include <avcodec.h>
> -+#else
> -+#include <libavcodec/avcodec.h>
> -+#endif
> -+#include <gst/gst.h>
> -+
> -+/*
> -+ *Get the size of an picture
> -+ */
> -+int
> -+gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height);
> -+
> -+/*
> -+ * Fill in pointers in an AVPicture, aligned by 4 (required by X).
> -+ */
> -+
> -+int
> -+gst_ffmpeg_avpicture_fill (AVPicture * picture,
> -+                           uint8_t *   ptr,
> -+                           enum PixelFormat pix_fmt,
> -+                           int         width,
> -+                           int         height);
> -+
> -+/*
> -+ * Convert from/to a GStreamer <-> FFMpeg timestamp.
> -+ */
> -+static inline guint64
> -+gst_ffmpeg_time_ff_to_gst (gint64 pts, AVRational base)
> -+{
> -+  guint64 out;
> -+
> -+  if (pts == AV_NOPTS_VALUE){
> -+    out = GST_CLOCK_TIME_NONE;
> -+  } else {
> -+    AVRational bq = { 1, GST_SECOND };
> -+    out = av_rescale_q (pts, base, bq);
> -+  }
> -+
> -+  return out;
> -+}
> -+
> -+static inline gint64
> -+gst_ffmpeg_time_gst_to_ff (guint64 time, AVRational base)
> -+{
> -+  gint64 out;
> -+
> -+  if (!GST_CLOCK_TIME_IS_VALID (time) || base.num == 0) {
> -+    out = AV_NOPTS_VALUE;
> -+  } else {
> -+    AVRational bq = { 1, GST_SECOND };
> -+    out = av_rescale_q (time, bq, base);
> -+  }
> -+
> -+  return out;
> -+}
> -+
> -+void
> -+gst_ffmpeg_init_pix_fmt_info(void);
> -+
> -+int
> -+gst_ffmpeg_auto_max_threads(void);
> -+
> -+G_CONST_RETURN gchar *
> -+gst_ffmpeg_get_codecid_longname (enum CodecID codec_id);
> -+
> -+gint
> -+av_smp_format_depth(enum AVSampleFormat smp_fmt);
> -+
> -+GstBuffer *
> -+new_aligned_buffer (gint size, GstCaps * caps);
> -+
> -+#endif /* __GST_FFMPEG_UTILS_H__ */
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch
> deleted file mode 100644
> index eba4988..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch
> +++ /dev/null
> @@ -1,21 +0,0 @@
> -diff --git a/gst-libs/ext/libav/configure b/gst-libs/ext/libav/configure
> -index 8473069..4f74952 100755
> ---- a/gst-libs/ext/libav/configure
> -+++ b/gst-libs/ext/libav/configure
> -Fix gst-ffmpeg build issues for libav on e500mc (fsl-p4080)
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Yao Zhao <yao.zhao@windriver.com>
> -
> -@@ -2210,6 +2210,10 @@ elif enabled ppc; then
> -             cpuflags="-mcpu=cell"
> -             enable ldbrx
> -         ;;
> -+        e500mc)
> -+            cpuflags="-mcpu=e500mc"
> -+            disable altivec
> -+        ;;
> -         e500v2)
> -             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
> -             disable altivec
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch
> deleted file mode 100644
> index d9ea2c2..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch
> +++ /dev/null
> @@ -1,19 +0,0 @@
> -libav: Add configs for ppc e5500
> -
> -Upstream-Status: Pending
> -
> -Signed-off-by: Jesse Zhang <sen.zhang@windriver.com>
> -
> ---- gst-ffmpeg-0.10.13/gst-libs/ext/libav/configure	2013-06-20 05:18:36.073104964 -0400
> -+++ gst-ffmpeg-0.10.13/gst-libs/ext/libav/configure	2013-06-20 05:18:38.269104150 -0400
> -@@ -2222,6 +2222,10 @@
> -             cpuflags="-mcpu=8540 -mhard-float"
> -             disable altivec
> -         ;;
> -+        e5500)
> -+            cpuflags="-mcpu=e5500 -mhard-float"
> -+            disable altivec
> -+        ;;
> -     esac
> -
> - elif enabled x86; then
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff
> deleted file mode 100644
> index 5f08afe..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff
> +++ /dev/null
> @@ -1,16 +0,0 @@
> -Lower the rank of ffmpeg plugin so codecs that hook into accelerated pieces (e.g. dsp or hw engines) can get picked over this
> -Derived from OE by Dongxiao Xu <dongxiao.xu@intel.com>
> -
> -Upstream-Status: Inappropriate [embedded specific]
> -
> ---- /tmp/gstffmpegdec.c	2009-03-05 09:31:15.000000000 +0100
> -+++ gst-ffmpeg-0.10.6/ext/ffmpeg/gstffmpegdec.c	2009-03-05 09:33:09.000000000 +0100
> -@@ -2588,7 +2588,7 @@
> -       case CODEC_ID_MSMPEG4V3:
> -       case CODEC_ID_H264:
> -       case CODEC_ID_COOK:
> --        rank = GST_RANK_PRIMARY;
> -+        rank = GST_RANK_SECONDARY;
> -         break;
> -       case CODEC_ID_DVVIDEO:
> -         /* we have a good dv decoder, fast on both ppc as well as x86. they say
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb
> deleted file mode 100644
> index b5c838f..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb
> +++ /dev/null
> @@ -1,90 +0,0 @@
> -SUMMARY = "FFmpeg-based GStreamer plug-in"
> -SECTION = "multimedia"
> -LICENSE = "GPLv2+ & LGPLv2+ & ( (GPLv2+ & LGPLv2.1+) | (GPLv3+ & LGPLv3+) )"
> -LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
> -                    file://ext/libpostproc/gstpostproc.c;beginline=1;endline=18;md5=5896e445e41681324381f5869ee33d38 \
> -                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
> -                    file://ext/ffmpeg/gstffmpeg.h;beginline=1;endline=18;md5=ff65467b0c53cdfa98d0684c1bc240a9 \
> -                    file://gst-libs/ext/libav/LICENSE;md5=abc3b8cb02856aa7823bbbd162d16232 \
> -                    file://gst-libs/ext/libav/COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
> -                    file://gst-libs/ext/libav/COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \
> -                    file://gst-libs/ext/libav/COPYING.LGPLv2.1;md5=e344c8fa836c3a41c4cbd79d7bd3a379 \
> -                    file://gst-libs/ext/libav/COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02"
> -LICENSE_FLAGS = "commercial"
> -HOMEPAGE = "http://www.gstreamer.net/"
> -DEPENDS = "gstreamer gst-plugins-base zlib bzip2 yasm-native libpostproc"
> -
> -inherit autotools-brokensep pkgconfig
> -
> -SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2 \
> -           file://lower-rank.diff \
> -           file://configure-fix.patch \
> -           file://h264_qpel_mmx.patch \
> -           file://libav_e500mc.patch \
> -           file://libav_e5500.patch \
> -           file://gst-ffmpeg-CVE-2013-3674.patch \
> -           file://0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch \
> -           file://0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch \
> -           file://0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch \
> -           file://0001-huffyuvdec-Skip-len-0-cases.patch \
> -           file://0001-huffyuvdec-Check-init_vlc-return-codes.patch \
> -           file://0001-alsdec-check-block-length.patch \
> -           file://0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch \
> -           file://0001-atrac3dec-Check-coding-mode-against-channels.patch \
> -           file://0001-eamad-fix-out-of-array-accesses.patch \
> -           file://0001-mjpegdec-check-SE.patch \
> -           file://0001-alac-fix-nb_samples-order-case.patch \
> -           file://0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch \
> -           file://0001-roqvideodec-check-dimensions-validity.patch \
> -           file://0001-aacdec-check-channel-count.patch \
> -           file://0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch \
> -           file://0001-error_concealment-Check-that-the-picture-is-not-in-a.patch \
> -           file://0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch \
> -           file://0001-vp3-Copy-all-3-frames-for-thread-updates.patch \
> -           file://0001-h264_sei-Fix-infinite-loop.patch \
> -           file://0001-avcodec-parser-reset-indexes-on-realloc-failure.patch \
> -           file://0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch \
> -           file://gst-ffmpeg-CVE-2013-0855.patch \
> -           file://0001-qdm2dec-fix-buffer-overflow.patch \
> -           file://0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch \
> -           file://0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch \
> -           file://0001-error-concealment-initialize-block-index.patch \
> -           file://0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch \
> -           file://0001-lavf-compute-probe-buffer-size-more-reliably.patch \
> -           file://0001-ffserver-set-oformat.patch \
> -           file://0001-h264-set-parameters-from-SPS-whenever-it-changes.patch \
> -           file://0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch \
> -           file://0001-avcodec-smc-fix-off-by-1-error.patch \
> -           file://0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch \
> -           file://libav-9.patch \
> -"
> -
> -SRC_URI[md5sum] = "7f5beacaf1312db2db30a026b36888c4"
> -SRC_URI[sha256sum] = "76fca05b08e00134e3cb92fa347507f42cbd48ddb08ed3343a912def187fbb62"
> -
> -PR = "r8"
> -
> -GSTREAMER_DEBUG ?= "--disable-debug"
> -
> -FFMPEG_EXTRA_CONFIGURE = "--with-ffmpeg-extra-configure"
> -# pass --cpu for powerpc. get cpu name by stripping "ppc" or "ppc64"
> -# from DEFAULTTUNE
> -FFMPEG_CPU_powerpc = "--cpu=${@d.getVar('DEFAULTTUNE')[3:]}"
> -FFMPEG_CPU_powerpc64 = "--cpu=${@d.getVar('DEFAULTTUNE')[5:]}"
> -FFMPEG_EXTRA_CONFIGURE_COMMON_ARG = "--target-os=linux ${FFMPEG_CPU} \
> -  --cc='${CC}' --as='${CC}' --ld='${CC}' --nm='${NM}' --ar='${AR}' \
> -  --ranlib='${RANLIB}' \
> -  ${GSTREAMER_DEBUG}"
> -FFMPEG_EXTRA_CONFIGURE_COMMON = \
> -'${FFMPEG_EXTRA_CONFIGURE}="${FFMPEG_EXTRA_CONFIGURE_COMMON_ARG}"'
> -
> -EXTRA_OECONF = "${FFMPEG_EXTRA_CONFIGURE_COMMON}"
> -
> -PACKAGECONFIG ??= "external-libav"
> -PACKAGECONFIG[external-libav] = "--with-system-ffmpeg,,libav"
> -PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
> -
> -FILES_${PN} += "${libdir}/gstreamer-0.10/*.so"
> -FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug"
> -FILES_${PN}-dev += "${libdir}/gstreamer-0.10/*.la"
> -FILES_${PN}-staticdev += "${libdir}/gstreamer-0.10/*.a"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.31.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.31.bb
> deleted file mode 100644
> index 1e2cd2a..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.31.bb
> +++ /dev/null
> @@ -1,14 +0,0 @@
> -require gst-fluendo.inc
> -
> -SUMMARY = "Fluendo closed-format mp3 GStreamer plug-in"
> -LICENSE = "MIT"
> -LIC_FILES_CHKSUM = "file://COPYING;md5=259a43dd1c9854b71fc396f74699f4d2"
> -LICENSE_FLAGS = "commercial"
> -
> -GSTREAMER_DEBUG ?= "--disable-debug"
> -EXTRA_OECONF += "${GSTREAMER_DEBUG} --with-gstreamer-api=0.10"
> -
> -acpaths = "-I ${S}/common/m4 -I ${S}/m4"
> -
> -SRC_URI[md5sum] = "adf0390f3416bb72f91c358528be0c38"
> -SRC_URI[sha256sum] = "dae0d0559a4e159c0dd92b7e18de059a5783f8d038904c7de4ca6393f7d55c7d"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.85.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.85.bb
> deleted file mode 100644
> index 7bba41a..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.85.bb
> +++ /dev/null
> @@ -1,12 +0,0 @@
> -require gst-fluendo.inc
> -
> -SUMMARY = "Fluendo MPEG Transport Stream and Program Stream demuxer for GStreamer"
> -LICENSE = "MPLv1.1"
> -LIC_FILES_CHKSUM = "file://COPYING;md5=be282f1c3cc9a98cc0dc5c2b25dfc510 \
> -                    file://src/gstmpegdemux.h;beginline=1;endline=19;md5=a9e90033f59897b91664d9f2a2ff01dd"
> -LICENSE_FLAGS = "commercial"
> -
> -acpaths = "-I ${S}/common/m4 -I ${S}/m4"
> -
> -SRC_URI[md5sum] = "7c4fb993f80b9ae631b11897733f0970"
> -SRC_URI[sha256sum] = "df04c91cc8e5d9a892c2492ed989974b4547beaa2a3647649e85113317897424"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo.inc b/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo.inc
> deleted file mode 100644
> index 7a77d62..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-fluendo.inc
> +++ /dev/null
> @@ -1,14 +0,0 @@
> -SUMMARY = "Fluendo closed-format GStreamer plug-in"
> -SECTION = "multimedia"
> -HOMEPAGE = "https://core.fluendo.com/gstreamer/trac/wiki"
> -DEPENDS = "gstreamer gst-plugins-base zlib"
> -
> -inherit autotools pkgconfig
> -
> -SRC_URI = "http://core.fluendo.com/gstreamer/src/${BPN}/${BPN}-${PV}.tar.bz2"
> -
> -FILES_${PN} += "${libdir}/gstreamer-0.10/*.so"
> -FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug"
> -FILES_${PN}-dev += "${libdir}/gstreamer-0.10/*.la ${libdir}/gstreamer-0.10/*.a"
> -
> -EXTRA_OECONF = "--disable-valgrind"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb
> deleted file mode 100644
> index 039abe1..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb
> +++ /dev/null
> @@ -1,73 +0,0 @@
> -SUMMARY = "GStreamer package groups"
> -LICENSE = "MIT"
> -
> -COMMERCIAL_PLUGINS = "${COMMERCIAL_AUDIO_PLUGINS} ${COMMERCIAL_VIDEO_PLUGINS}"
> -DEPENDS_UGLY="${@'gst-plugins-ugly' if 'ugly' in COMMERCIAL_PLUGINS.split('-') else ''}"
> -DEPENDS_BAD="${@'gst-plugins-bad' if 'bad' in COMMERCIAL_PLUGINS.split('-') else ''}"
> -DEPENDS = "gstreamer gst-plugins-base gst-plugins-good ${DEPENDS_UGLY} ${DEPENDS_BAD}"
> -
> -LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
> -                    file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
> -
> -
> -PR = "r13"
> -
> -PACKAGES = "\
> -    gst-meta-base \
> -    gst-meta-x11-base \
> -    gst-meta-audio \
> -    gst-meta-debug \
> -    gst-meta-video"
> -
> -ALLOW_EMPTY_gst-meta-base = "1"
> -ALLOW_EMPTY_gst-meta-x11-base = "1"
> -ALLOW_EMPTY_gst-meta-audio = "1"
> -ALLOW_EMPTY_gst-meta-debug = "1"
> -ALLOW_EMPTY_gst-meta-video = "1"
> -
> -RDEPENDS_gst-meta-base = "\
> -    ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'gst-meta-x11-base', '', d)} \
> -    gstreamer \
> -    gst-plugins-base-playbin \
> -    gst-plugins-base-decodebin \
> -    gst-plugins-base-decodebin2 \
> -    gst-plugins-base-gio \
> -    gst-plugins-base-alsa \
> -    gst-plugins-base-volume \
> -    gst-plugins-base-audioconvert \
> -    gst-plugins-base-audioresample \
> -    gst-plugins-base-typefindfunctions \
> -    gst-plugins-base-videoscale \
> -    gst-plugins-base-ffmpegcolorspace \
> -    gst-plugins-good-autodetect \
> -    gst-plugins-good-souphttpsrc"
> -
> -RRECOMMENDS_gst-meta-x11-base = "\
> -    gst-plugins-base-ximagesink \
> -    gst-plugins-base-xvimagesink"
> -
> -RDEPENDS_gst-meta-audio = "\
> -    gst-meta-base \
> -    gst-plugins-base-vorbis \
> -    gst-plugins-base-ogg \
> -    gst-plugins-good-wavparse \
> -    gst-plugins-good-flac \
> -    ${COMMERCIAL_AUDIO_PLUGINS}"
> -
> -
> -RDEPENDS_gst-meta-debug = "\
> -    gst-meta-base \
> -    gst-plugins-good-debug \
> -    gst-plugins-base-audiotestsrc \
> -    gst-plugins-base-videotestsrc"
> -
> -
> -RDEPENDS_gst-meta-video = "\
> -    gst-meta-base \
> -    gst-plugins-good-avi \
> -    gst-plugins-good-matroska \
> -    gst-plugins-base-theora \
> -    ${COMMERCIAL_VIDEO_PLUGINS}"
> -
> -RRECOMMENDS_gst-meta-video = "\
> -    gst-meta-audio"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch
> deleted file mode 100644
> index 57a63b5..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch
> +++ /dev/null
> @@ -1,18 +0,0 @@
> -Upstream-Status: Pending
> -
> -Signed-off-by: Saul Wold <sgw@linux.intel.com>
> -
> -Index: gst-openmax-0.10.1/omx/gstomx.c
> -===================================================================
> ---- gst-openmax-0.10.1.orig/omx/gstomx.c	2010-09-30 18:00:24.000000000 -0700
> -+++ gst-openmax-0.10.1/omx/gstomx.c	2011-05-17 23:08:08.794535872 -0700
> -@@ -238,7 +238,8 @@
> -     const gchar *element_name = gst_structure_nth_field_name (element_table, i);
> -     GstStructure *element = get_element_entry (element_name);
> -     const gchar *type_name, *parent_type_name;
> --    const gchar *component_name, *component_role, *library_name;
> -+    const gchar *component_name, *library_name;
> -+    const gchar __attribute__((__unused__)) *component_role;
> -     GType type;
> -     gint rank;
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch
> deleted file mode 100644
> index 5965bba..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch
> +++ /dev/null
> @@ -1,46 +0,0 @@
> -Rename static functions that use GLib naming conventions as one of them
> -(g_ptr_array_insert) has now been added to GLib.
> -
> -Upstream-Status: Pending
> -Signed-off-by: Ross Burton <ross.burton@intel.com>
> -
> -diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
> -index 423e441..579dbf5 100644
> ---- a/omx/gstomx_util.c
> -+++ b/omx/gstomx_util.c
> -@@ -85,7 +85,7 @@ static gboolean initialized;
> -  */
> -
> - static void
> --g_ptr_array_clear (GPtrArray * array)
> -+omx_g_ptr_array_clear (GPtrArray * array)
> - {
> -   guint index;
> -   for (index = 0; index < array->len; index++)
> -@@ -93,7 +93,7 @@ g_ptr_array_clear (GPtrArray * array)
> - }
> -
> - static void
> --g_ptr_array_insert (GPtrArray * array, guint index, gpointer data)
> -+omx_g_ptr_array_insert (GPtrArray * array, guint index, gpointer data)
> - {
> -   if (index + 1 > array->len) {
> -     g_ptr_array_set_size (array, index + 1);
> -@@ -394,7 +394,7 @@ g_omx_core_unload (GOmxCore * core)
> -   }
> -
> -   core_for_each_port (core, g_omx_port_free);
> --  g_ptr_array_clear (core->ports);
> -+  omx_g_ptr_array_clear (core->ports);
> - }
> -
> - static inline GOmxPort *
> -@@ -418,7 +418,7 @@ g_omx_core_new_port (GOmxCore * core, guint index)
> -   }
> -
> -   port = g_omx_port_new (core, index);
> --  g_ptr_array_insert (core->ports, index, port);
> -+  omx_g_ptr_array_insert (core->ports, index, port);
> -
> -   return port;
> - }
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb
> deleted file mode 100644
> index 2e01579..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb
> +++ /dev/null
> @@ -1,35 +0,0 @@
> -SUMMARY = "GStreamer plug-in for communication with OpenMAX IL components"
> -DESCRIPTION = "GstOpenMAX is a GStreamer plug-in that allows \
> -communication with OpenMAX Integration Layer (IL) components. OpenMAX \
> -IL is an industry standard that provides an abstraction layer for \
> -computer graphics, video, and sound routines."
> -HOMEPAGE = "http://freedesktop.org/wiki/GstOpenMAX"
> -DEPENDS = "gstreamer"
> -RDEPENDS_${PN} = "libomxil"
> -LICENSE = "LGPLv2.1"
> -LICENSE_FLAGS = "commercial"
> -LIC_FILES_CHKSUM = "file://COPYING;md5=fbc093901857fcd118f065f900982c24 \
> -                    file://util/sem.h;beginline=1;endline=20;md5=accce5550d5583b839b441a0623f09fc"
> -
> -SRC_URI = "http://gstreamer.freedesktop.org/src/gst-openmax/gst-openmax-${PV}.tar.bz2 \
> -           file://gcc_4.6.patch \
> -           file://ptr-array.patch \
> -           "
> -
> -inherit autotools pkgconfig
> -
> -# Tell configure that this isn't a development snapshot so we don't want
> -# -Werror (hopefully fixed in 0.10.2)
> -export GST_CVS="no"
> -
> -EXTRA_OECONF += "--disable-valgrind"
> -
> -PR = "r4"
> -
> -FILES_${PN} += "${libdir}/gstreamer-0.10/libgstomx.so"
> -FILES_${PN}-dev += "${libdir}/gstreamer-0.10/libgstomx.la"
> -FILES_${PN}-staticdev += "${libdir}/gstreamer-0.10/libgstomx.a"
> -FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug/"
> -
> -SRC_URI[md5sum] = "4d0370bfe99dea20918c84347abadb4e"
> -SRC_URI[sha256sum] = "9074d5a0591995133d19cfb15144f19664f902c1623f996595695cf2c2070e1f"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb
> deleted file mode 100644
> index 0f64871..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb
> +++ /dev/null
> @@ -1,50 +0,0 @@
> -require gst-plugins.inc
> -
> -LICENSE = "GPLv2+ & LGPLv2+ & LGPLv2.1+ "
> -LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
> -                    file://gst/tta/filters.h;beginline=12;endline=29;md5=629b0c7a665d155a6677778f4460ec06 \
> -                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
> -                    file://gst/tta/crc32.h;beginline=12;endline=29;md5=71a904d99ce7ae0c1cf129891b98145c"
> -
> -DEPENDS += "gst-plugins-base"
> -
> -PR = "r4"
> -
> -inherit gettext gsettings
> -
> -EXTRA_OECONF += "--disable-experimental \
> -                 --disable-sdl --disable-cdaudio --disable-directfb \
> -                 --disable-vdpau --disable-apexsink"
> -
> -PACKAGECONFIG ??= "bzip curl \
> -                   ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'rsvg', '', d)}"
> -
> -PACKAGECONFIG[bzip] = "--enable-bz2,--disable-bz2,bzip2"
> -PACKAGECONFIG[curl] = "--enable-curl,--disable-curl,curl"
> -PACKAGECONFIG[rsvg] = "--enable-rsvg,--disable-rsvg,librsvg,"
> -PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
> -PACKAGECONFIG[neon] = "--enable-neon,--disable-neon,neon"
> -PACKAGECONFIG[mms] = "--enable-libmms,--disable-libmms,libmms"
> -PACKAGECONFIG[cog] = "--enable-cog,--disable-cog,libpng"
> -PACKAGECONFIG[faad] = "--enable-faad,--disable-faad,faad2"
> -PACKAGECONFIG[jp2k] = "--enable-jp2k,--disable-jp2k,jasper"
> -PACKAGECONFIG[modplug] = "--enable-modplug,--disable-modplug,libmodplug"
> -PACKAGECONFIG[opus] = "--enable-opus,--disable-opus,libopus"
> -PACKAGECONFIG[sndfile] = "--enable-sndfile,--disable-sndfile,libsndfile1"
> -PACKAGECONFIG[vp8] = "--enable-vp8,--disable-vp8,libvpx"
> -PACKAGECONFIG[ass] = "--enable-assrender,--disable-assrender,libass"
> -PACKAGECONFIG[openal] = "--enable-openal,--disable-openal,openal-soft"
> -PACKAGECONFIG[schro] = "--enable-schro,--disable-schro,schroedinger"
> -PACKAGECONFIG[dc1394] = "--enable-dc1394,--disable-dc1394,libdc1394"
> -PACKAGECONFIG[faac] = "--enable-faac,--disable-faac,faac"
> -PACKAGECONFIG[rtmp] = "--enable-rtmp,--disable-rtmp,rtmpdump"
> -
> -ARM_INSTRUCTION_SET = "arm"
> -
> -do_configure_prepend() {
> -	# This m4 file contains nastiness which conflicts with libtool 2.2.2
> -	rm ${S}/m4/lib-link.m4 || true
> -}
> -
> -SRC_URI[md5sum] = "fcb09798114461955260e4d940db5987"
> -SRC_URI[sha256sum] = "0eae7d1a1357ae8377fded6a1b42e663887beabe0e6cc336e2ef9ada42e11491"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
> deleted file mode 100644
> index 5214256..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
> +++ /dev/null
> @@ -1,37 +0,0 @@
> -audioresample: Fix build on x86 if emmintrin.h is available but can't be used
> -
> -On x86, EMMINTRIN is defined but not usable without SSE so check for
> -__SSE__ and __SSE2__ as well.
> -
> -https://bugzilla.gnome.org/show_bug.cgi?id=670690
> -
> -Upstream-Status: Backport
> -
> -Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
> ----
> - gst/audioresample/resample.c |    4 ++--
> - 1 files changed, 2 insertions(+), 2 deletions(-)
> -
> -diff --git a/gst/audioresample/resample.c b/gst/audioresample/resample.c
> -index 98d006c..481fa01 100644
> ---- a/gst/audioresample/resample.c
> -+++ b/gst/audioresample/resample.c
> -@@ -77,13 +77,13 @@
> - #define EXPORT G_GNUC_INTERNAL
> -
> - #ifdef _USE_SSE
> --#ifndef HAVE_XMMINTRIN_H
> -+#if !defined(__SSE__) || !defined(HAVE_XMMINTRIN_H)
> - #undef _USE_SSE
> - #endif
> - #endif
> -
> - #ifdef _USE_SSE2
> --#ifndef HAVE_EMMINTRIN_H
> -+#if !defined(__SSE2__) || !defined(HAVE_EMMINTRIN_H)
> - #undef _USE_SSE2
> - #endif
> - #endif
> ---
> -1.7.1
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
> deleted file mode 100644
> index b8602c8..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -Upstream-Status: Submitted [similar patch by other author, bugzilla]
> -Bugtracker-URL: https://bugzilla.gnome.org/show_bug.cgi?id=663600
> -
> -Prepend PKG_CONFIG_SYSROOT to includedir, so configure doesn't
> -search for gstconfig.h in /usr/include.
> -
> -Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
> ----
> - configure.ac |    2 +-
> - 1 files changed, 1 insertions(+), 1 deletions(-)
> -
> -diff --git a/configure.ac b/configure.ac
> -index 1901bcf..460fb0a 100644
> ---- a/configure.ac
> -+++ b/configure.ac
> -@@ -435,7 +435,7 @@ AG_GST_CHECK_PLUGIN(volume)
> - dnl check for gstreamer core features (subsystems)
> - dnl FIXME: this assumes srcdir == builddir for uninstalled setups
> - GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-0.10`"/gst/gstconfig.h"
> --AG_GST_PARSE_SUBSYSTEM_DISABLES($GST_CONFIGPATH)
> -+AG_GST_PARSE_SUBSYSTEM_DISABLES($PKG_CONFIG_SYSROOT_DIR$GST_CONFIGPATH)
> - AM_CONDITIONAL(USE_XML, test $GST_DISABLE_XML != "1")
> -
> - dnl disable plug-ins that require libxml2's HTML support if it is not available
> ---
> -1.7.5.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
> deleted file mode 100644
> index 99dbc9d..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
> +++ /dev/null
> @@ -1,20 +0,0 @@
> -Remove -DTREMOR option since Tremor has dropped its internal
> -libogg2, and gst-plugins-base has dependency on that.
> -
> -Upstream-Status: Inappropriate [configuration]
> -
> -Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
> -Signed-off-by: Shane Wang <shane.wang@intel.com>
> -
> -diff -r 70065fb4e085 ext/vorbis/Makefile.am
> ---- a/ext/vorbis/Makefile.am	Tue Mar 13 16:36:56 2012 +0800
> -+++ b/ext/vorbis/Makefile.am	Tue Mar 13 16:38:53 2012 +0800
> -@@ -30,7 +30,7 @@
> - 	gstvorbisdec.c gstvorbisdeclib.c gstvorbiscommon.c
> - libgstivorbisdec_la_CFLAGS = \
> - 	$(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \
> --	-DTREMOR $(IVORBIS_CFLAGS)
> -+	$(IVORBIS_CFLAGS)
> - libgstivorbisdec_la_LIBADD = \
> - 	$(top_builddir)/gst-libs/gst/tag/libgsttag-@GST_MAJORMINOR@.la \
> - 	$(top_builddir)/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la \
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb
> deleted file mode 100644
> index c8a9499..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb
> +++ /dev/null
> @@ -1,39 +0,0 @@
> -require gst-plugins.inc
> -
> -LICENSE = "GPLv2+ & LGPLv2+"
> -LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
> -                    file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=622921ffad8cb18ab906c56052788a3f \
> -                    file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
> -                    file://gst/ffmpegcolorspace/utils.c;beginline=1;endline=20;md5=9c83a200b8e597b26ca29df20fc6ecd0"
> -
> -DEPENDS += "alsa-lib liboil libogg libvorbis libtheora util-linux tremor glib-2.0-native"
> -
> -SRC_URI += "file://gst-plugins-base-tremor.patch \
> -            file://configure.ac-fix-subparse-plugin.patch \
> -            file://audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch \
> -"
> -
> -SRC_URI[md5sum] = "776c73883e567f67b9c4a2847d8d041a"
> -SRC_URI[sha256sum] = "2cd3b0fa8e9b595db8f514ef7c2bdbcd639a0d63d154c00f8c9b609321f49976"
> -
> -PR = "r8"
> -
> -inherit gettext
> -
> -EXTRA_OECONF += "--disable-freetypetest"
> -
> -PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}"
> -
> -PACKAGECONFIG[gnomevfs] = "--enable-gnome_vfs,--disable-gnome_vfs,gnome-vfs"
> -PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
> -PACKAGECONFIG[pango] = "--enable-pango,--disable-pango,pango"
> -PACKAGECONFIG[x11] = "--enable-x --enable-xvideo,--disable-x --disable-xvideo,virtual/libx11 libxv libsm libice"
> -
> -do_configure_prepend() {
> -	# This m4 file contains nastiness which conflicts with libtool 2.2.2
> -	rm -f ${S}/m4/lib-link.m4
> -}
> -
> -FILES_${PN} += "${datadir}/${BPN}"
> -
> -CACHED_CONFIGUREVARS_append_i586 = " ac_cv_header_emmintrin_h=no ac_cv_header_xmmintrin_h=no"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
> deleted file mode 100644
> index bc2f88b..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
> +++ /dev/null
> @@ -1,35 +0,0 @@
> -From 14d51cbefef19737e7ab2b6818ee1d3bdb248d12 Mon Sep 17 00:00:00 2001
> -From: Jeremy Stashluk <jstashluk@dekaresearch.com>
> -Date: Wed, 6 Feb 2013 09:59:48 -0500
> -Subject: [PATCH] conditional gl framebuffer undefined use
> -
> -The OpenGL extension GL_ARB_framebuffer_object defines the macro
> -GL_FRAMEBUFFER_UNDEFINED. The macro will only need to map to an error
> -string if the extension provides functions that might return the macro.
> -
> -Upstream-Status: Pending
> -
> -Signed-off-by: Jeremy Stashluk <jstashluk@dekaresearch.com>
> ----
> - gst-libs/gst/gl/gstgldisplay.c |    2 ++
> - 1 file changed, 2 insertions(+)
> -
> -diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c
> -index 3ed0b71..64c6c2c 100644
> ---- a/gst-libs/gst/gl/gstgldisplay.c
> -+++ b/gst-libs/gst/gl/gstgldisplay.c
> -@@ -2177,9 +2177,11 @@ gst_gl_display_check_framebuffer_status (void)
> -       GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
> -       break;
> -
> -+#if defined(GL_ARB_framebuffer_object)
> -     case GL_FRAMEBUFFER_UNDEFINED:
> -       GST_ERROR ("GL_FRAMEBUFFER_UNDEFINED");
> -       break;
> -+#endif
> -
> -     default:
> -       GST_ERROR ("General FBO error");
> ---
> -1.7.9.5
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb
> deleted file mode 100644
> index 90efbcc..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb
> +++ /dev/null
> @@ -1,25 +0,0 @@
> -require recipes-multimedia/gstreamer/gst-plugins.inc
> -
> -LICENSE = "GPLv2+ & LGPLv2+ & LGPLv2.1+ "
> -LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605"
> -
> -SRC_URI[md5sum] = "ac70ede13f79978d56eaed8abaa3c938"
> -SRC_URI[sha256sum] = "48340b6a4b8abce16344a7bc33e74a94fdcce4f57ef6342cdf2f941c429bf210"
> -
> -SRC_URI += " file://0001-conditional-gl-framebuffer-undefined-use.patch"
> -
> -DEPENDS += "gst-plugins-base virtual/libgles2 virtual/egl jpeg libpng glew"
> -
> -PR = "r4"
> -
> -inherit gettext
> -
> -# This package doesn't have a configure switch for EGL or GL, so forcibly tell
> -# configure that it can't find gl.h so it always uses EGL.  If/when we have some
> -# way for machines to specify their preferred GL flavour this can be
> -# automatically adapted.
> -EXTRA_OECONF += "ac_cv_header_GL_gl_h=no"
> -
> -ALLOW_EMPTY_${PN} = "1"
> -ALLOW_EMPTY_${PN}-apps = "1"
> -ALLOW_EMPTY_${PN}-glib = "1"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
> deleted file mode 100644
> index 6456d3c..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
> +++ /dev/null
> @@ -1,33 +0,0 @@
> -From 12d18fe4e98e7c232d59b56d529a0521f293fe6d Mon Sep 17 00:00:00 2001
> -From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com>
> -Date: Wed, 5 Sep 2012 18:54:42 +0200
> -Subject: [PATCH] v4l2: fix build with recent kernels, the v4l2_buffer input
> - field was removed
> -MIME-Version: 1.0
> -Content-Type: text/plain; charset=UTF-8
> -Content-Transfer-Encoding: 8bit
> -
> -Upstream-Status: Backport
> -
> -[1] http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=9f2aa8d47f835ea155aaf635f618c0fc1ca87012
> -
> -Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
> ----
> - sys/v4l2/gstv4l2bufferpool.c |    1 -
> - 1 files changed, 0 insertions(+), 1 deletions(-)
> -
> -diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c
> -index b81c6a4..51cc0ce 100644
> ---- a/sys/v4l2/gstv4l2bufferpool.c
> -+++ b/sys/v4l2/gstv4l2bufferpool.c
> -@@ -181,7 +181,6 @@ gst_v4l2_buffer_new (GstV4l2BufferPool * pool, guint index, GstCaps * caps)
> -     GST_LOG_OBJECT (pool->v4l2elem, "  MMAP offset:  %u",
> -         ret->vbuffer.m.offset);
> -   GST_LOG_OBJECT (pool->v4l2elem, "  length:    %u", ret->vbuffer.length);
> --  GST_LOG_OBJECT (pool->v4l2elem, "  input:     %u", ret->vbuffer.input);
> -
> -   data = (guint8 *) v4l2_mmap (0, ret->vbuffer.length,
> -       PROT_READ | PROT_WRITE, MAP_SHARED, pool->video_fd,
> ---
> -1.7.6.5
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
> deleted file mode 100644
> index bd0de58..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
> +++ /dev/null
> @@ -1,45 +0,0 @@
> -From ccb01de8096a32d86d47b0d92ec3416c57ee4d25 Mon Sep 17 00:00:00 2001
> -From: Bruce Ashfield <bruce.ashfield@windriver.com>
> -Date: Thu, 22 Aug 2013 12:15:54 -0400
> -Subject: [PATCH] v4l2_calls: define V4L2_CID_HCENTER and V4L2_CID_VCENTER
> -
> -kernel commit 24b9f5017 [[media] V4L: Remove deprecated image centering controls]
> -removed the definitions of V4L2_CID_HCENTER and V4L2_CID_VCENTER after three
> -years of depreciation.
> -
> -The ioctl values are still free, and the case statement which processess them
> -in v4l2 userspace falls through to the proper replacement. So in the short
> -term, we can explicitly define them using the old absolute values, and everything
> -will work.
> -
> -Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
> ----
> - sys/v4l2/v4l2_calls.c |    9 +++++++--
> - 1 file changed, 7 insertions(+), 2 deletions(-)
> -
> -diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c
> -index 309bfb6..3c64544 100644
> ---- a/sys/v4l2/v4l2_calls.c
> -+++ b/sys/v4l2/v4l2_calls.c
> -@@ -54,11 +54,16 @@
> - #include "gst/gst-i18n-plugin.h"
> -
> - /* Those are ioctl calls */
> -+
> -+/* V4L2_CID_HCENTER has been removed from the mainline kernel, but
> -+   the ioctl space is still present. Since these values fall through
> -+   to their replacement, it is safe (in the short term) to re-use the
> -+    old values explictily */
> - #ifndef V4L2_CID_HCENTER
> --#define V4L2_CID_HCENTER V4L2_CID_HCENTER_DEPRECATED
> -+#define V4L2_CID_HCENTER V4L2_CID_BASE+22
> - #endif
> - #ifndef V4L2_CID_VCENTER
> --#define V4L2_CID_VCENTER V4L2_CID_VCENTER_DEPRECATED
> -+#define V4L2_CID_VCENTER V4L2_CID_BASE+23
> - #endif
> -
> - GST_DEBUG_CATEGORY_EXTERN (v4l2_debug);
> ---
> -1.7.10.4
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
> deleted file mode 100644
> index 48b8e98..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
> +++ /dev/null
> @@ -1,47 +0,0 @@
> -From ce94b2c2b91b6db190c121860e12a6afafce7ae1 Mon Sep 17 00:00:00 2001
> -From: Roland Krikava <rkrikava@gmail.com>
> -Date: Fri, 2 Nov 2012 12:38:44 -0400
> -Subject: [PATCH 407/440] mulawdec: fix integer overrun
> -
> -There might be more than 65535 samples in a chunk of data.
> -
> -https://bugzilla.gnome.org/show_bug.cgi?id=687469
> -
> -Commit - 3be45f70220310ec1c60d819f90b5f2ae03b5d83 in 0.10 branch
> -
> -Upstream Status:  Backported
> -
> -Signed-off-by: Roland Krikava <rkrikava@gmail.com>
> ----
> - gst/law/mulaw-conversion.c |    6 ++++--
> - 1 file changed, 4 insertions(+), 2 deletions(-)
> -
> -diff --git a/gst/law/mulaw-conversion.c b/gst/law/mulaw-conversion.c
> -index 8afae80..190a9f5 100644
> ---- a/gst/law/mulaw-conversion.c
> -+++ b/gst/law/mulaw-conversion.c
> -@@ -51,9 +51,10 @@ mulaw_encode (gint16 * in, guint8 * out, gint numsamples)
> -     7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
> -     7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
> -   };
> --  gint16 sign, exponent, mantissa, i;
> -+  gint16 sign, exponent, mantissa;
> -   gint16 sample;
> -   guint8 ulawbyte;
> -+  gint i;
> -
> -   for (i = 0; i < numsamples; i++) {
> -     sample = in[i];
> -@@ -102,7 +103,8 @@ mulaw_decode (guint8 * in, gint16 * out, gint numsamples)
> -   static gint16 exp_lut[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 };
> -   gint16 sign, exponent, mantissa;
> -   guint8 ulawbyte;
> --  gint16 linear, i;
> -+  gint16 linear;
> -+  gint i;
> -
> -   for (i = 0; i < numsamples; i++) {
> -     ulawbyte = in[i];
> ---
> -1.7.9.5
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb
> deleted file mode 100644
> index af18281..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb
> +++ /dev/null
> @@ -1,47 +0,0 @@
> -require gst-plugins.inc
> -
> -LICENSE = "GPLv2+ & LGPLv2.1+"
> -LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
> -                    file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=622921ffad8cb18ab906c56052788a3f \
> -                    file://gst/replaygain/rganalysis.c;beginline=1;endline=23;md5=b60ebefd5b2f5a8e0cab6bfee391a5fe"
> -
> -PR = "r8"
> -
> -PACKAGECONFIG ?= "jpeg v4l \
> -    ${@bb.utils.contains('DISTRO_FEATURES', 'pulseaudio', 'pulseaudio', '', d)} \
> -    ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)} \
> -"
> -PACKAGECONFIG[pulseaudio] = "--enable-pulse,--disable-pulse,pulseaudio"
> -PACKAGECONFIG[jack] = "--enable-jack,--disable-jack,jack"
> -PACKAGECONFIG[jpeg] = "--enable-jpeg,--disable-jpeg,jpeg"
> -PACKAGECONFIG[wavpack] = "--enable-wavpack,--disable-wavpack,wavpack"
> -PACKAGECONFIG[gdkpixbuf] = "--enable-gdk_pixbuf,--disable-gdk_pixbuf,gdk-pixbuf"
> -PACKAGECONFIG[v4l] = "--enable-gst_v4l2 --with-gudev,--disable-gst_v4l2 --without-gudev,udev"
> -# sub-feature of v4l, but control separately since libv4l is not part of oe-core
> -PACKAGECONFIG[libv4l] = "--with-libv4l2,--without-libv4l2,libv4l"
> -PACKAGECONFIG[bzip2] = "--enable-bz2,--disable-bz2,bzip2"
> -PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
> -PACKAGECONFIG[x11] = "--enable-x,--disable-x,virtual/libx11 libxfixes libxdamage"
> -
> -DEPENDS += "gst-plugins-base gconf cairo libpng zlib libid3tag flac \
> -            speex libsoup-2.4 libcap"
> -
> -inherit gettext gconf
> -
> -SRC_URI += "file://0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch \
> -            file://0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch \
> -            file://0407-mulawdec-fix-integer-overrun.patch \
> -"
> -EXTRA_OECONF += "--disable-aalib --disable-esd --disable-shout2 --disable-libcaca --disable-hal \
> -                 --disable-examples --disable-taglib"
> -
> -do_configure_prepend() {
> -	# This m4 file contains nastiness which conflicts with libtool 2.2.2
> -	rm ${S}/m4/lib-link.m4 || true
> -}
> -
> -SRC_URI[md5sum] = "24f98a294a2b521e1b29412bdadae2e6"
> -SRC_URI[sha256sum] = "7e27840e40a7932ef2dc032d7201f9f41afcaf0b437daf5d1d44dc96d9e35ac6"
> -
> -FILES_${PN}-gconfelements += "${sysconfdir}/gconf/schemas/gstreamer-0.10.schemas"
> -FILES_${PN}-equalizer += "${datadir}/gstreamer-0.10/presets/*.prs"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb
> deleted file mode 100644
> index 2fdf03f..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -require gst-plugins.inc
> -
> -LICENSE = "GPLv2+ & LGPLv2.1+ & LGPLv2+"
> -LICENSE_FLAGS = "commercial"
> -LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
> -                    file://gst/synaesthesia/synaescope.h;beginline=1;endline=20;md5=99f301df7b80490c6ff8305fcc712838 \
> -                    file://tests/check/elements/xingmux.c;beginline=1;endline=21;md5=4c771b8af188724855cb99cadd390068 \
> -                    file://gst/mpegstream/gstmpegparse.h;beginline=1;endline=18;md5=ff65467b0c53cdfa98d0684c1bc240a9"
> -
> -DEPENDS += "gst-plugins-base libid3tag libmad mpeg2dec liba52 lame"
> -PR = "r3"
> -
> -inherit gettext
> -
> -EXTRA_OECONF += "--with-plugins=a52dec,lame,id3tag,mad,mpeg2dec,mpegstream,mpegaudioparse,asfdemux,realmedia \
> -                 --disable-orc"
> -
> -PACKAGECONFIG ??= ""
> -PACKAGECONFIG[x264] = "--enable-x264,--disable-x264,x264"
> -PACKAGECONFIG[cdio] = "--enable-cdio,--disable-cdio,libcdio"
> -PACKAGECONFIG[dvdread] = "--enable-dvdread,--disable-dvdread,libdvdread"
> -
> -do_configure_prepend() {
> -	# This m4 file contains nastiness which conflicts with libtool 2.2.2
> -	rm ${S}/m4/lib-link.m4 || true
> -}
> -
> -SRC_URI[md5sum] = "1d81c593e22a6cdf0f2b4f57eae93df2"
> -SRC_URI[sha256sum] = "1ca90059275c0f5dca71d4d1601a8f429b7852baed0723e820703b977e2c8df0"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc b/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc
> deleted file mode 100644
> index c852c53..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -SUMMARY = "Plugins for the GStreamer multimedia framework"
> -HOMEPAGE = "http://gstreamer.freedesktop.org/"
> -BUGTRACKER = "https://bugzilla.gnome.org/enter_bug.cgi?product=Gstreamer"
> -SECTION = "multimedia"
> -DEPENDS = "gstreamer"
> -
> -inherit autotools pkgconfig
> -
> -SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2"
> -
> -GSTREAMER_DEBUG ?= "--disable-debug"
> -EXTRA_OECONF = "--disable-valgrind ${GSTREAMER_DEBUG} --disable-examples "
> -
> -acpaths = "-I ${S}/common/m4 -I ${S}/m4"
> -
> -LIBV = "0.10"
> -require gst-plugins-package.inc
> -
> -PACKAGES_DYNAMIC += "^${PN}-.*"
> -
> -# apply gstreamer hack after Makefile.in.in in source is replaced by our version from
> -# ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in, but before configure is executed
> -# http://lists.linuxtogo.org/pipermail/openembedded-core/2012-November/032233.html
> -oe_runconf_prepend() {
> -	if [ -e ${S}/po/Makefile.in.in ]; then
> -		sed -i -e "1a\\" -e 'GETTEXT_PACKAGE = @GETTEXT_PACKAGE@' ${S}/po/Makefile.in.in
> -	fi
> -}
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch b/meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
> deleted file mode 100644
> index 3afca4e..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -index gst-rtsp_0.10.8/bindings/python/Makefile.am
> ---- gst-rtsp_0.10.8.orig/bindings/python/Makefile.am
> -+++ gst-rtsp_0.10.8/bindings/python/Makefile.am
> -@@ -14,7 +14,7 @@ defs_DATA = $(DEFS)
> - defsdir = $(pkgdatadir)/$(GST_MAJORMINOR)/defs
> - OVERRIDES = rtspserver.override
> -
> --INCLUDES = -I$(top_srcdir) -I$(srcdir) $(PYTHON_INCLUDES)
> -+AM_CPPFLAGS = -I$(top_srcdir) -I$(srcdir) $(PYTHON_INCLUDES)
> -
> - rtspserver_la_CFLAGS = -I$(top_srcdir)/src \
> -         $(PYGOBJECT_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
> -index gst-rtsp_0.10.8/examples/Makefile.am
> ---- gst-rtsp_0.10.8.orig/examples/Makefile.am
> -+++ gst-rtsp_0.10.8/examples/Makefile.am
> -@@ -1,6 +1,6 @@
> - noinst_PROGRAMS = test-video test-ogg test-mp4 test-readme test-launch test-sdp test-uri test-auth
> -
> --INCLUDES = -I$(top_srcdir) -I$(srcdir)
> -+AM_CPPFLAGS = -I$(top_srcdir) -I$(srcdir)
> -
> - AM_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
> - AM_LDFLAGS = \
> -index gst-rtsp_0.10.8/tests/Makefile.am
> ---- gst-rtsp_0.10.8.orig/tests/Makefile.am
> -+++ gst-rtsp_0.10.8/tests/Makefile.am
> -@@ -1,6 +1,6 @@
> - noinst_PROGRAMS = test-cleanup
> -
> --INCLUDES = -I$(top_srcdir) -I$(srcdir)
> -+AM_CPPFLAGS = -I$(top_srcdir) -I$(srcdir)
> -
> - AM_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
> - AM_LDFLAGS = \
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp_0.10.8.bb b/meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp_0.10.8.bb
> deleted file mode 100644
> index 9318656..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp_0.10.8.bb
> +++ /dev/null
> @@ -1,16 +0,0 @@
> -SUMMARY = "GStreamer RTSP server"
> -LICENSE = "LGPLv2+"
> -LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605"
> -
> -SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2 \
> -           file://0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch"
> -SRC_URI[md5sum] = "b511af07000595f63c3a705946221643"
> -SRC_URI[sha256sum] = "9915887cf8515bda87462c69738646afb715b597613edc7340477ccab63a6617"
> -
> -DEPENDS = "gst-plugins-base gstreamer"
> -
> -# Configure always checks for Python so inherit pythonnative. Better solution
> -# would be to disable the checks entirely.
> -inherit autotools pythonnative gettext
> -
> -FILES_${PN}-dev += "${datadir}/vala/vapi/"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
> deleted file mode 100644
> index d077496..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -From ed7f4802222234eef192aa3f74bc92268f338f97 Mon Sep 17 00:00:00 2001
> -From: Sebastian Droege <sebastian.droege@collabora.co.uk>
> -Date: Tue, 6 Mar 2012 12:28:02 +0100
> -Subject: [PATCH] baseparse: Fix 'self-comparison always evaluates to true'
> -
> -This was really a bug.
> -
> -Commit is ed7f4802222234eef192aa3f74bc92268f338f97 in 0.10 branch
> -
> -Upstream Status:  Backported
> -
> -Signed-off-by: Sebastian Droege <sebastian.droege@collabora.co.uk>
> ----
> - libs/gst/base/gstbaseparse.c |    2 +-
> - 1 file changed, 1 insertion(+), 1 deletion(-)
> -
> -diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c
> -index 851ec1d..108ee89 100644
> ---- a/libs/gst/base/gstbaseparse.c
> -+++ b/libs/gst/base/gstbaseparse.c
> -@@ -3899,7 +3899,7 @@ gst_base_parse_handle_seek (GstBaseParse * parse, GstEvent * event)
> -        seek event (in bytes) to upstream. Segment / flush handling happens
> -        in corresponding src event handlers */
> -     GST_DEBUG_OBJECT (parse, "seek in PUSH mode");
> --    if (seekstop >= 0 && seekpos <= seekpos)
> -+    if (seekstop >= 0 && seekstop <= seekpos)
> -       seekstop = seekpos;
> -     new_event = gst_event_new_seek (rate, GST_FORMAT_BYTES, flags,
> -         GST_SEEK_TYPE_SET, seekpos, stop_type, seekstop);
> ---
> -1.7.9.5
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch
> deleted file mode 100644
> index 5d8bb13..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch
> +++ /dev/null
> @@ -1,19 +0,0 @@
> -# gstreamer: Fix a problem with configure if check has already been built
> -# Richard Purdie <rpurdie@linux.intel.com>
> -
> -Upstream-Status: Inappropriate [configuration]
> -
> -diff -urN gstreamer-0.10.29-orig/configure.ac gstreamer-0.10.29/configure.ac
> ---- gstreamer-0.10.29-orig/configure.ac	2010-06-26 12:49:27.774930773 +0800
> -+++ gstreamer-0.10.29/configure.ac	2010-06-26 12:51:12.899200233 +0800
> -@@ -543,8 +543,10 @@
> -       *) BUILD_CHECK=yes ;;
> -     esac
> - ])
> -+
> - dnl bit of a misnomer, but keep the conditional named like this so we don't
> - dnl have to change too much elsewhere
> -+HAVE_CHECK=no
> - AM_CONDITIONAL(HAVE_CHECK, test "x$BUILD_CHECK" = "xyes")
> -
> - dnl configure the desired buffer alignment
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch
> deleted file mode 100644
> index 30be85f..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch
> +++ /dev/null
> @@ -1,16 +0,0 @@
> -# Fix crash with gst-inspect
> -# Chris Lord <chris@openedhand.com>
> -
> -Upstream-Status: Pending
> -
> ---- gstreamer-0.10.9/tools/gst-inspect.c.old	2006-09-12 11:56:53.000000000 +0100
> -+++ gstreamer-0.10.9/tools/gst-inspect.c	2006-09-12 11:57:27.000000000 +0100
> -@@ -1123,7 +1123,7 @@
> -   g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
> -   g_option_context_add_group (ctx, gst_init_get_option_group ());
> -   if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
> --    g_print ("Error initializing: %s\n", err->message);
> -+    g_print ("Error initializing: %s\n", err ? err->message : "(null)");
> -     exit (1);
> -   }
> -   g_option_context_free (ctx);
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
> deleted file mode 100644
> index bf93cb2..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
> +++ /dev/null
> @@ -1,33 +0,0 @@
> -gstreamer: change priv_gst_parse_yylex arguments
> -
> -Change priv_gst_parse_yylex to fit new bison version, else we will
> -get following error:
> -
> -| grammar.tab.c: In function 'priv_gst_parse_yyparse':
> -| grammar.tab.c:67:25: error: too few arguments to function 'priv_gst_parse_yylex'
> -|  #define yylex           priv_gst_parse_yylex
> -|                          ^
> -
> -Upstream-Status: Pending
> -
> -Signed-off-by: Chong Lu <Chong.Lu@windriver.com>
> ----
> - gst/parse/grammar.y | 2 +-
> - 1 file changed, 1 insertion(+), 1 deletion(-)
> -
> -diff --git a/gst/parse/grammar.y b/gst/parse/grammar.y
> -index 24fc87b..24fe906 100644
> ---- a/gst/parse/grammar.y
> -+++ b/gst/parse/grammar.y
> -@@ -36,7 +36,7 @@
> -
> - typedef void* yyscan_t;
> -
> --int priv_gst_parse_yylex (void * yylval_param , yyscan_t yyscanner);
> -+int priv_gst_parse_yylex (yyscan_t yyscanner);
> - int priv_gst_parse_yylex_init (yyscan_t scanner);
> - int priv_gst_parse_yylex_destroy (yyscan_t scanner);
> - struct yy_buffer_state * priv_gst_parse_yy_scan_string (char* , yyscan_t);
> ---
> -1.9.1
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c
> deleted file mode 100644
> index c1f3e71..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c
> +++ /dev/null
> @@ -1,487 +0,0 @@
> -/* GStreamer
> - * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
> - *                    2000 Wim Taymans <wtay@chello.be>
> - *                    2005 David A. Schleef <ds@schleef.org>
> - *
> - * gstregistryxml.c: GstRegistry object, support routines
> - *
> - * This library is free software; you can redistribute it and/or
> - * modify it ulnder 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.
> - */
> -
> -
> -#include <gst/gstregistrybinary.h>
> -
> -/*
> -** Simple handy function to write a memory location to the registry cache file
> -*/
> -inline static gboolean
> -gst_registry_binary_write(GstRegistry *registry, const void *mem, const ssize_t size)
> -{
> -  if (write(registry->cache_file, mem, size) != size)
> -    {
> -      GST_ERROR("Failed to write binary registry element: ptr=%p size=%u error=%s\n",
> -		mem, size, strerror(errno));
> -      return FALSE;
> -    }
> -  return TRUE;
> -}
> -
> -/*
> -** Save features GstBinary style
> -*/
> -static gboolean
> -gst_registry_binary_fill_feature(GList **list, GstPluginFeature *orig, GstBinaryPluginFeature *dest, const char *name)
> -{
> -  GstBinaryChunck *chk;
> -
> -  if ((chk = calloc(1, sizeof (GstBinaryChunck))) == NULL)
> -    return FALSE;
> -
> -  chk->data = dest;
> -  chk->size = sizeof (GstBinaryPluginFeature);
> -
> -  *list = g_list_append(*list, chk);
> -
> -  dest->rank = orig->rank;
> -  if (!strncpy(dest->typename, name, GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN) ||
> -      !strncpy(dest->name, orig->name, GST_BINARY_REGISTRY_TYPENAME_NAME_LEN))
> -    {
> -      GST_ERROR("Failed to write binary registry feature");
> -      goto fail;
> -    }
> -
> -  if (GST_IS_ELEMENT_FACTORY(orig))
> -    {
> -      GstElementFactory *factory = GST_ELEMENT_FACTORY(orig);
> -
> -      if (!strncpy(dest->longname, factory->details.longname, GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN) ||
> -	  !strncpy(dest->class, factory->details.klass, GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN) ||
> -	  !strncpy(dest->description, factory->details.description, GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN) ||
> -	  !strncpy(dest->author, factory->details.author, GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN))
> -	{
> -	  GST_ERROR("Failed to write binary registry feature");
> -	  goto fail;
> -	}
> -    }
> -
> -  dest->npadtemplates = dest->ninterfaces = dest->nuritypes = 0;
> -  return TRUE;
> -
> - fail:
> -  free(chk);
> -  return FALSE;
> -}
> -
> -
> -/*
> -** Initialize the GstBinaryRegistryMagic, setting both our magic number and gstreamer major/minor version
> -*/
> -inline static gboolean
> -gst_registry_binary_initialize_magic(GstBinaryRegistryMagic *m)
> -{
> -  if (!strncpy(m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) ||
> -      !strncpy(m->version, GST_MAJORMINOR, GST_BINARY_REGISTRY_VERSION_LEN))
> -    {
> -      GST_ERROR("Failed to write magic to the registry magic structure");
> -      return FALSE;
> -    }
> -  return TRUE;
> -}
> -
> -/*
> -** Check GstBinaryRegistryMagic validity.
> -** Return a pointer pointing right after the magic structure
> -*/
> -static gchar *
> -gst_registry_binary_check_magic(gchar *in)
> -{
> -  GstBinaryRegistryMagic *m = (GstBinaryRegistryMagic *) in;
> -
> -  if (m == NULL || m->magic == NULL || m->version == NULL)
> -    {
> -      GST_ERROR("Binary registry magic structure is broken");
> -      return NULL;
> -    }
> -  if (strncmp(m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) != 0)
> -    {
> -      GST_ERROR("Binary registry magic is different : %02x%02x%02x%02x != %02x%02x%02x%02x",
> -		GST_MAGIC_BINARY_REGISTRY_STR[0] & 0xff, GST_MAGIC_BINARY_REGISTRY_STR[1] & 0xff,
> -		GST_MAGIC_BINARY_REGISTRY_STR[2] & 0xff, GST_MAGIC_BINARY_REGISTRY_STR[3] & 0xff,
> -		m->magic[0] & 0xff, m->magic[1] & 0xff, m->magic[2] & 0xff, m->magic[3] & 0xff);
> -      return NULL;
> -    }
> -  if (strncmp(m->version, GST_MAJORMINOR, GST_BINARY_REGISTRY_VERSION_LEN))
> -    {
> -      GST_ERROR("Binary registry magic version is different : %s != %s",
> -		GST_MAJORMINOR, m->version);
> -      return NULL;
> -    }
> -  return (in + sizeof (GstBinaryRegistryMagic));
> -}
> -
> -/*
> -** Adapt a GstPlugin to our GstBinaryPluginElement structure, and write it to the
> -** registry file.
> -*/
> -static gboolean
> -gst_registry_binary_save_plugin(GList **list, GstRegistry *registry, GstPlugin *plugin)
> -{
> -  GstBinaryPluginElement *e;
> -  GstBinaryChunck *chk;
> -  GList *walk;
> -
> -  if ((e = calloc(1, sizeof (GstBinaryPluginElement))) == NULL ||
> -      (chk = calloc(1, sizeof (GstBinaryChunck))) == NULL)
> -    return FALSE;
> -
> -  chk->data = e;
> -  chk->size = sizeof (GstBinaryPluginElement);
> -  *list = g_list_append(*list, chk);
> -
> -  if (!strncpy(e->name, plugin->desc.name, GST_BINARY_REGISTRY_NAME_LEN)		       	||
> -      !strncpy(e->description, plugin->desc.description, GST_BINARY_REGISTRY_DESCRIPTION_LEN)	||
> -      !strncpy(e->filename, plugin->filename, _POSIX_PATH_MAX)					||
> -      !strncpy(e->version, plugin->desc.version, GST_BINARY_REGISTRY_VERSION_LEN)		||
> -      !strncpy(e->license, plugin->desc.license, GST_BINARY_REGISTRY_LICENSE_LEN)		||
> -      !strncpy(e->source, plugin->desc.source, GST_BINARY_REGISTRY_SOURCE_LEN)			||
> -      !strncpy(e->package, plugin->desc.package, GST_BINARY_REGISTRY_PACKAGE_LEN)		||
> -      !strncpy(e->origin, plugin->desc.origin, GST_BINARY_REGISTRY_ORIGIN_LEN))
> -    {
> -      GST_DEBUG("Can't adapt GstPlugin to GstBinaryPluginElement");
> -      goto fail;
> -    }
> -
> -  e->size = plugin->file_size;
> -  e->m32p = plugin->file_mtime;
> -
> -  GList *ft_list = gst_registry_get_feature_list_by_plugin(registry, plugin->desc.name);
> -
> -  for (walk = ft_list; walk; walk = g_list_next(walk), e->nfeatures++)
> -    {
> -      GstPluginFeature *curfeat = GST_PLUGIN_FEATURE (walk->data);
> -      GstBinaryPluginFeature *newfeat;
> -      const char *feat_name = g_type_name(G_OBJECT_TYPE(curfeat));
> -
> -      if ((newfeat = calloc(1, sizeof (GstBinaryPluginFeature))) == NULL)
> -	  goto fail;
> -
> -      if (!feat_name || !gst_registry_binary_fill_feature(list, curfeat, newfeat, feat_name))
> -	{
> -	  GST_ERROR("Can't fill plugin feature, aborting.");
> -	  goto fail;
> -	}
> -    }
> -
> -  GST_DEBUG("Found %d features in plugin \"%s\"\n", e->nfeatures, e->name);
> -  return TRUE;
> -
> - fail:
> -  free(chk);
> -  free(e);
> -  return FALSE;
> -}
> -
> -/*
> -** Write the cache to file. Part of the code was taken from gstregistryxml.c
> -*/
> -gboolean
> -gst_registry_binary_write_cache(GstRegistry *registry, const char *location)
> -{
> -  GList *walk;
> -  char *tmp_location;
> -  GstBinaryRegistryMagic *magic;
> -  GstBinaryChunck *magic_chunck;
> -  GList *to_write = NULL;
> -
> -  GST_INFO("Writing binary registry cache");
> -
> -  g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
> -  tmp_location = g_strconcat (location, ".tmpXXXXXX", NULL);
> -  registry->cache_file = g_mkstemp (tmp_location);
> -  if (registry->cache_file == -1)
> -    {
> -      char *dir;
> -
> -      /* oops, I bet the directory doesn't exist */
> -      dir = g_path_get_dirname (location);
> -      g_mkdir_with_parents (dir, 0777);
> -      g_free (dir);
> -
> -      registry->cache_file = g_mkstemp (tmp_location);
> -    }
> -
> -  if (registry->cache_file == -1)
> -    goto fail;
> -
> -  if ((magic = calloc(1, sizeof (GstBinaryRegistryMagic))) == NULL ||
> -      !gst_registry_binary_initialize_magic(magic))
> -    goto fail;
> -
> -  if ((magic_chunck = calloc(1, sizeof (GstBinaryChunck))) == NULL)
> -    goto fail;
> -
> -  magic_chunck->data = magic;
> -  magic_chunck->size = sizeof (GstBinaryRegistryMagic);
> -  to_write = g_list_append(to_write, magic_chunck);
> -
> -  /* Iterate trough the list of plugins in the GstRegistry and adapt them to our structures */
> -  for (walk = g_list_last(registry->plugins); walk; walk = g_list_previous(walk))
> -    {
> -      GstPlugin *plugin = GST_PLUGIN(walk->data);
> -
> -      if (!plugin->filename)
> -	continue;
> -	
> -      if (plugin->flags & GST_PLUGIN_FLAG_CACHED)
> -	{
> -	  int ret;
> -	  struct stat statbuf;
> -	
> -	  ret = g_stat (plugin->filename, &statbuf);
> -	  if ((ret = g_stat (plugin->filename, &statbuf)) < 0 	||
> -	      plugin->file_mtime != statbuf.st_mtime		||
> -	      plugin->file_size != statbuf.st_size)
> -	    continue;
> -	}
> -
> -      if (!gst_registry_binary_save_plugin(&to_write, registry, plugin))
> -	{
> -	  GST_ERROR("Can't write binary plugin information for \"%s\"", plugin->filename);
> -	  continue; /* Try anyway */
> -	}
> -    }
> -
> -  for (walk = g_list_first(to_write); walk; walk = g_list_next(walk))
> -    {
> -      GstBinaryChunck *cur = walk->data;
> -
> -      if (!gst_registry_binary_write(registry, cur->data, cur->size))
> -	{
> -	  free(cur->data);
> -	  free(cur);
> -	  g_list_free(to_write);
> -	  goto fail;
> -	}
> -      free(cur->data);
> -      free(cur);
> -    }
> -  g_list_free(to_write);
> -
> -  if (close(registry->cache_file) < 0)
> -    {
> -      GST_DEBUG("Can't close registry file : %s", strerror(errno));
> -      goto fail;
> -    }
> -
> -  if (g_file_test (tmp_location, G_FILE_TEST_EXISTS)) {
> -#ifdef WIN32
> -    remove (location);
> -#endif
> -    rename (tmp_location, location);
> -  }
> -
> -  g_free (tmp_location);
> -  return TRUE;
> -
> - fail:
> -  g_free(tmp_location);
> -  return FALSE;
> -}
> -
> -static GstPluginFeature*
> -gst_registry_binary_load_feature(GstBinaryPluginFeature *in)
> -{
> -  GstPluginFeature *feature;
> -  GType type;
> -
> -  if (!in->typename || !*(in->typename))
> -    return NULL;
> -
> -  /*  GST_INFO("Plugin feature typename : %s", in->typename);*/
> -
> -  if (!(type = g_type_from_name(in->typename)))
> -    {
> -      GST_ERROR("Unknown type from typename");
> -      return NULL;
> -    }
> -  feature = g_object_new (type, NULL);
> -
> -  if (!feature) {
> -    GST_ERROR("Can't create feature from type");
> -    return NULL;
> -  }
> -
> -  if (!GST_IS_PLUGIN_FEATURE (feature)) {
> -    /* don't really know what it is */
> -    if (GST_IS_OBJECT (feature))
> -      gst_object_unref (feature);
> -    else
> -      g_object_unref (feature);
> -    return NULL;
> -  }
> -
> -  feature->name = g_strdup(in->name);
> -  feature->rank = in->rank;
> -
> -  if (GST_IS_ELEMENT_FACTORY(feature))
> -    {
> -      GstElementFactory *factory = GST_ELEMENT_FACTORY(feature);
> -
> -      factory->details.longname = g_strdup(in->longname);
> -      factory->details.klass = g_strdup(in->class);
> -      factory->details.description = g_strdup(in->description);
> -      factory->details.author = g_strdup(in->author);
> -
> -      /*      GST_INFO("Element factory : %s", factory->details.longname); */
> -    }
> -
> -  GST_DEBUG("Added feature %p with name %s", feature, feature->name);
> -  return feature;
> -}
> -
> -/*
> -** Make a new plugin from current GstBinaryPluginElement structure
> -** and save it to the GstRegistry. Return an offset to the next
> -** GstBinaryPluginElement structure.
> -*/
> -static unsigned long
> -gst_registry_binary_get_binary_plugin(GstRegistry *registry, gchar *in)
> -{
> -  GstBinaryPluginElement *p = (GstBinaryPluginElement *) in;
> -  GstPlugin *plugin = NULL;
> -  GList *plugin_features = NULL;
> -  GstBinaryPluginFeature *feat;
> -  unsigned int i;
> -  unsigned long offset;
> -
> -  plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
> -
> -  plugin->flags |= GST_PLUGIN_FLAG_CACHED;
> -
> -  plugin->desc.name = g_strdup(p->name);
> -  plugin->desc.description= g_strdup(p->description);
> -  plugin->filename = g_strdup(p->filename);
> -  plugin->desc.version = g_strdup(p->version);
> -  plugin->desc.license = g_strdup(p->license);
> -  plugin->desc.source = g_strdup(p->source);
> -  plugin->desc.package = g_strdup(p->package);
> -  plugin->desc.origin = g_strdup(p->origin);
> -  plugin->file_mtime = p->m32p;
> -  plugin->file_size = p->size;
> -  plugin->basename = g_path_get_basename (plugin->filename);
> -
> -  if (plugin->file_mtime < 0 || plugin->file_size < 0)
> -    {
> -      GST_ERROR("Plugin time or file size is not valid !");
> -      g_free(plugin);
> -      return -1;
> -    }
> -
> -  if (p->nfeatures < 0)
> -    {
> -      GST_ERROR("The number of feature structure is not valid !");
> -      gst_object_unref(plugin);
> -      return -1;
> -    }
> -
> -  for (feat = (GstBinaryPluginFeature *) (in + sizeof (GstBinaryPluginElement)), i = 0;
> -       i < p->nfeatures; i++, feat++)
> -    {
> -      GstPluginFeature *gstfeat;
> -
> -      if ((gstfeat = gst_registry_binary_load_feature(feat)) == NULL)
> -	{
> -	  g_list_free(plugin_features);
> -	  g_free(plugin);
> -	  GST_ERROR("Error while loading binary feature");
> -	  return -1;
> -	}
> -      gstfeat->plugin_name = g_strdup(plugin->desc.name);
> -      plugin_features = g_list_prepend(plugin_features, gstfeat);
> -    }
> -
> -  GST_DEBUG("Added plugin \"%s\" to global registry from binary registry", plugin->desc.name);
> -  GList *g;
> -
> -  gst_registry_add_plugin (registry, plugin);
> -  for (g = plugin_features; g; g = g_list_next (g))
> -    gst_registry_add_feature (registry, GST_PLUGIN_FEATURE (g->data));
> -  /*  g_list_free(plugin_features); */
> -
> -  offset = sizeof (GstBinaryPluginElement) + p->nfeatures * sizeof (GstBinaryPluginFeature);
> -  return offset;
> -}
> -
> -
> -/*
> -** Read the cache and adapt it to fill GstRegistry
> -*/
> -gboolean
> -gst_registry_binary_read_cache(GstRegistry *registry, const char *location)
> -{
> -  GMappedFile *mapped = NULL;
> -  GTimer *timer = NULL;
> -  gchar *contents = NULL;
> -  gdouble seconds;
> -  unsigned long offset, inc;
> -  gsize size;
> -
> -  /* make sure these types exist */
> -  GST_TYPE_ELEMENT_FACTORY;
> -  GST_TYPE_TYPE_FIND_FACTORY;
> -  GST_TYPE_INDEX_FACTORY;
> -
> -  timer = g_timer_new ();
> -
> -  if ((mapped = g_mapped_file_new(location, FALSE, NULL)) == NULL ||
> -      (contents = g_mapped_file_get_contents(mapped)) == NULL)
> -    {
> -      GST_ERROR("Can't load file : %s", strerror(errno));
> -      return FALSE;
> -    }
> -  if ((contents = gst_registry_binary_check_magic(contents)) == NULL)
> -    {
> -      GST_ERROR("Binary registry type not recognized (invalid magic)");
> -      g_mapped_file_free(mapped);
> -      return FALSE;
> -    }
> -
> -  if ((size = g_mapped_file_get_length(mapped)) < sizeof (GstBinaryPluginElement))
> -    {
> -      GST_INFO("No binary plugins structure to read");
> -      return TRUE; /* This is not really an error */
> -    }
> -
> -  for (offset = inc = 0; (offset + sizeof (GstBinaryPluginElement)) < size &&
> -	 (inc = gst_registry_binary_get_binary_plugin(registry, contents + offset)) > 0;
> -       offset += inc)
> -    ; /* May want in the future to do something here */
> -  if (inc < 0)
> -    {
> -      GST_DEBUG("Problem while reading binary registry");
> -      return FALSE;
> -    }
> -
> -  g_timer_stop (timer);
> -  seconds = g_timer_elapsed (timer, NULL);
> -  g_timer_destroy (timer);
> -
> -  GST_INFO ("loaded %s in %f seconds", location, seconds);
> -
> -  if (mapped)
> -    g_mapped_file_free (mapped);
> -  return TRUE;
> -}
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h
> deleted file mode 100644
> index 2ef24d7..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h
> +++ /dev/null
> @@ -1,194 +0,0 @@
> -/* GStreamer
> - * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
> - *                    2000 Wim Taymans <wim.taymans@chello.be>
> - *
> - * gstregistry.h: Header for registry handling
> - *
> - * 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.
> - */
> -
> -/* SUGGESTIONS AND TODO :
> -** ====================
> -** - Use a compressed registry, but would induce performance loss
> -** - Encrypt the registry, for security purpose, but would also reduce performances
> -** - Also have a non-mmap based cache reading (work with file descriptors)
> -*/
> -
> -#ifndef __GST_REGISTRYBINARY_H__
> -#define __GST_REGISTRYBINARY_H__
> -
> -#ifdef HAVE_CONFIG_H
> -#  include "config.h"
> -#endif
> -
> -#include <stdio.h>
> -#include <errno.h>
> -#include <sys/types.h>
> -#include <sys/stat.h>
> -#include <dirent.h>
> -#include <fcntl.h>
> -#include <sys/mman.h>
> -#ifdef HAVE_UNISTD_H
> -#include <unistd.h>
> -#endif
> -
> -#include <gst/gst_private.h>
> -#include <gst/gstelement.h>
> -#include <gst/gsttypefind.h>
> -#include <gst/gsttypefindfactory.h>
> -#include <gst/gsturi.h>
> -#include <gst/gstinfo.h>
> -#include <gst/gstenumtypes.h>
> -#include <gst/gstregistry.h>
> -#include <gst/gstpadtemplate.h>
> -
> -#include "glib-compat-private.h"
> -#include <glib/gstdio.h>
> -
> -/* A magic, written at the beginning of the file */
> -#define GST_MAGIC_BINARY_REGISTRY_STR "\xc0\xde\xf0\x0d"
> -#define GST_MAGIC_BINARY_REGISTRY_LEN (4)
> -#define GST_MAGIC_BINARY_VERSION_LEN (64)
> -
> -typedef struct _GstBinaryRegistryMagic
> -{
> -  char magic[GST_MAGIC_BINARY_REGISTRY_LEN];
> -  char version[GST_MAGIC_BINARY_VERSION_LEN];
> -} GstBinaryRegistryMagic;
> -
> -
> -/* Used to store pointers to write */
> -typedef struct _GstBinaryChunck
> -{
> -  void *data;
> -  unsigned int size;
> -} GstBinaryChunck;
> -
> -
> -/* A structure containing (staticely) every information needed for a plugin
> -**
> -** Notes :
> -** "nfeatures" is used to say how many GstBinaryPluginFeature structures we will have
> -** right after the structure itself.
> -*/
> -
> -/* Various lenght defines for our GstBinaryPluginElement structure
> -** Note : We could eventually use smaller size
> -*/
> -#define GST_BINARY_REGISTRY_NAME_LEN (256)
> -#define GST_BINARY_REGISTRY_DESCRIPTION_LEN (1024)
> -#define GST_BINARY_REGISTRY_VERSION_LEN (64)
> -#define GST_BINARY_REGISTRY_LICENSE_LEN (256)
> -#define GST_BINARY_REGISTRY_SOURCE_LEN (256)
> -#define GST_BINARY_REGISTRY_PACKAGE_LEN (1024)
> -#define GST_BINARY_REGISTRY_ORIGIN_LEN (1024)
> -
> -typedef struct _GstBinaryPluginElement
> -{
> -  char name[GST_BINARY_REGISTRY_NAME_LEN];
> -  char description[GST_BINARY_REGISTRY_DESCRIPTION_LEN];
> -  char filename[_POSIX_PATH_MAX];
> -  char version[GST_BINARY_REGISTRY_VERSION_LEN];
> -  char license[GST_BINARY_REGISTRY_LICENSE_LEN];
> -  char source[GST_BINARY_REGISTRY_SOURCE_LEN];
> -  char package[GST_BINARY_REGISTRY_PACKAGE_LEN];
> -  char origin[GST_BINARY_REGISTRY_ORIGIN_LEN];
> -  unsigned long size;
> -  unsigned long m32p;
> -  unsigned int nfeatures;
> -} GstBinaryPluginElement;
> -
> -
> -/* A structure containing the plugin features
> -**
> -** Note :
> -** "npadtemplates" is used to store the number of GstBinaryPadTemplate structures following the structure itself.
> -** "ninterfaces" is used to store the number of GstBinaryInterface structures following the structure itself.
> -** "nuritypes" is used to store the number of GstBinaryUriType structures following the structure itself.
> -*/
> -#define GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN (256)
> -#define GST_BINARY_REGISTRY_TYPENAME_NAME_LEN (256)
> -#define GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN (1024)
> -#define GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN (512)
> -#define GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN (1024)
> -#define GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN (256)
> -
> -typedef struct _GstBinaryPluginFeature
> -{
> -  char typename[GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN];
> -  char name[GST_BINARY_REGISTRY_TYPENAME_NAME_LEN];
> -  unsigned long rank;
> -  char longname[GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN];
> -  char class[GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN];
> -  char description[GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN];
> -  char author[GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN];
> -  unsigned int npadtemplates;
> -  unsigned int ninterfaces;
> -  unsigned int nuritypes;
> -} GstBinaryPluginFeature;
> -
> -
> -/*
> -** A structure containing the static pad templates of a plugin feature
> -*/
> -#define GST_BINARY_REGISTRY_PADTEMPLATE_NAME_LEN (256)
> -#define GST_BINARY_REGISTRY_PADTEMPLATE_CAP_LEN (1024)
> -
> -typedef struct _GstBinaryPadTemplate
> -{
> -  char name[GST_BINARY_REGISTRY_PADTEMPLATE_NAME_LEN];
> -  char cap[GST_BINARY_REGISTRY_PADTEMPLATE_CAP_LEN];
> -  int direction;					/* Either 0:"sink" or 1:"src" */
> -  GstPadPresence presence;
> -} GstBinaryPadTemplate;
> -
> -/*
> -** A very simple structure defining the plugin feature interface string
> -*/
> -#define GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN (512)
> -typedef struct _GstBinaryInterface
> -{
> -  char interface[GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN];
> -  unsigned long size;
> -} GstBinaryInterface;
> -
> -/* Uri Type */
> -typedef struct _GstBinaryUriType
> -{
> -  GstURIType type;
> -  unsigned long nuriprotocols;
> -} GstBinaryUriType;
> -
> -/*
> -** Function prototypes
> -*/
> -
> -/* Local prototypes */
> -inline static gboolean gst_registry_binary_write(GstRegistry *registry, const void *mem, const ssize_t size);
> -inline static gboolean gst_registry_binary_initialize_magic(GstBinaryRegistryMagic *m);
> -static gboolean gst_registry_binary_fill_feature(GList **list, GstPluginFeature *, GstBinaryPluginFeature *, const char *);
> -static gboolean gst_registry_binary_save_plugin(GList **list, GstRegistry *registry, GstPlugin *plugin);
> -static gchar *gst_registry_binary_check_magic(gchar *in);
> -static GstPluginFeature *gst_registry_binary_load_feature(GstBinaryPluginFeature *);
> -static unsigned long gst_registry_binary_get_binary_plugin(GstRegistry *registry, gchar *in);
> -
> -/* Exportable */
> -gboolean gst_registry_binary_write_cache(GstRegistry *registry, const char *location);
> -gboolean gst_registry_binary_read_cache(GstRegistry *registry, const char *location);
> -
> -#endif /* !__GST_REGISTRYBINARY_H__ */
> -
> -
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb b/meta-multimedia/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb
> deleted file mode 100644
> index 5b30603..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb
> +++ /dev/null
> @@ -1,51 +0,0 @@
> -SUMMARY = "GStreamer multimedia framework"
> -DESCRIPTION = "GStreamer is a multimedia framework for encoding and decoding video and sound. \
> -It supports a wide range of formats including mp3, ogg, avi, mpeg and quicktime."
> -HOMEPAGE = "http://gstreamer.freedesktop.org/"
> -BUGTRACKER = "https://bugzilla.gnome.org/enter_bug.cgi?product=Gstreamer"
> -SECTION = "multimedia"
> -LICENSE = "LGPLv2+"
> -LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605 \
> -                    file://gst/gst.h;beginline=1;endline=21;md5=8e5fe5e87d33a04479fde862e238eaa4"
> -DEPENDS = "glib-2.0 libxml2 bison-native flex-native"
> -
> -PR = "r2"
> -
> -SRC_URI = "http://gstreamer.freedesktop.org/src/gstreamer/gstreamer-${PV}.tar.bz2 \
> -           file://check_fix.patch \
> -           file://gst-inspect-check-error.patch \
> -           file://0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch \
> -           file://gstreamer-change-priv_gst_parse_yylex-arguments.patch \
> -"
> -
> -SRC_URI[md5sum] = "a0cf7d6877f694a1a2ad2b4d1ecb890b"
> -SRC_URI[sha256sum] = "e556a529e0a8cf1cd0afd0cab2af5488c9524e7c3f409de29b5d82bb41ae7a30"
> -
> -inherit autotools pkgconfig gettext
> -
> -GSTREAMER_DEBUG ?= "--disable-debug"
> -EXTRA_OECONF = "--disable-docbook --disable-gtk-doc \
> -            --disable-dependency-tracking --disable-check \
> -            --disable-examples --disable-tests \
> -            --disable-valgrind ${GSTREAMER_DEBUG} \
> -            "
> -
> -CACHED_CONFIGUREVARS += "ac_cv_header_valgrind_valgrind_h=no"
> -
> -# apply gstreamer hack after Makefile.in.in in source is replaced by our version from
> -# ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in, but before configure is executed
> -# http://lists.linuxtogo.org/pipermail/openembedded-core/2012-November/032233.html
> -oe_runconf_prepend() {
> -        sed -i -e "1a\\" -e 'GETTEXT_PACKAGE = @GETTEXT_PACKAGE@' ${S}/po/Makefile.in.in
> -}
> -
> -#do_compile_prepend () {
> -#	mv ${WORKDIR}/gstregistrybinary.[ch] ${S}/gst/
> -#}
> -
> -RRECOMMENDS_${PN}_qemux86    += "kernel-module-snd-ens1370 kernel-module-snd-rawmidi"
> -RRECOMMENDS_${PN}_qemux86-64 += "kernel-module-snd-ens1370 kernel-module-snd-rawmidi"
> -
> -FILES_${PN} += " ${libdir}/gstreamer-0.10/*.so"
> -FILES_${PN}-dev += " ${libdir}/gstreamer-0.10/*.la ${libdir}/gstreamer-0.10/*.a"
> -FILES_${PN}-dbg += " ${libdir}/gstreamer-0.10/.debug/ ${libexecdir}/gstreamer-0.10/.debug/"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/python-gst/python-path.patch b/meta-multimedia/recipes-multimedia/gstreamer/python-gst/python-path.patch
> deleted file mode 100644
> index 21b5bbf..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/python-gst/python-path.patch
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -Upstream-Status:Pending
> -
> -Index: gst-python-0.10.19/acinclude.m4
> -===================================================================
> ---- gst-python-0.10.19.orig/acinclude.m4	2010-04-21 15:23:44.000000000 -0700
> -+++ gst-python-0.10.19/acinclude.m4	2010-11-15 14:43:00.642994001 -0800
> -@@ -43,6 +43,13 @@
> - [AC_REQUIRE([AM_PATH_PYTHON])
> - AC_MSG_CHECKING(for headers required to compile python extensions)
> - dnl deduce PYTHON_INCLUDES
> -+
> -+AC_ARG_WITH(python-includes,
> -+	[  --with-python-includes=DIR  path to Python includes], py_exec_prefix=$withval)
> -+if test x$py_exec_prefix != x; then
> -+PYTHON_INCLUDES="-I${py_exec_prefix}/include/python${PYTHON_VERSION}"
> -+py_prefix="${py_exec_prefix}"
> -+else
> - py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
> - py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
> - if $PYTHON-config --help 2>/dev/null; then
> -@@ -53,6 +60,7 @@
> -     PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
> -   fi
> - fi
> -+fi
> - AC_SUBST(PYTHON_INCLUDES)
> - dnl check if the headers exist:
> - save_CPPFLAGS="$CPPFLAGS"
> diff --git a/meta-multimedia/recipes-multimedia/gstreamer/python-gst_0.10.22.bb b/meta-multimedia/recipes-multimedia/gstreamer/python-gst_0.10.22.bb
> deleted file mode 100644
> index 2a5f2b3..0000000
> --- a/meta-multimedia/recipes-multimedia/gstreamer/python-gst_0.10.22.bb
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -SUMMARY = "Python bindings for the GStreamer multimedia framework"
> -SECTION = "devel/python"
> -LICENSE = "LGPLv2.1"
> -DEPENDS = "gstreamer gst-plugins-base python-pygobject"
> -RDEPENDS_${PN} += "python-pygtk"
> -PR = "r2"
> -
> -SRC_URI = "http://gstreamer.freedesktop.org/src/gst-python/gst-python-${PV}.tar.bz2 \
> -           file://python-path.patch"
> -
> -SRC_URI[md5sum] = "937152fe896241f827689f4b53e79b22"
> -SRC_URI[sha256sum] = "8f26f519a5bccd770864317e098e5e307fc5ad1201eb96329634b6508b253178"
> -S = "${WORKDIR}/gst-python-${PV}"
> -
> -LIC_FILES_CHKSUM = "file://COPYING;md5=39ff67e932b7bdfa9b78bad67151690b"
> -
> -inherit autotools distutils-base pkgconfig
> -
> -EXTRA_OECONF += "--with-python-includes=${STAGING_INCDIR}/../"
> -
> -FILES_${PN} += "${datadir}/gst-python"
> -FILES_${PN}-dev += "${datadir}/gst-python/0.10/defs"
> -FILES_${PN}-dbg += "${libdir}/${PYTHON_DIR}/site-packages/gst-0.10/gst/.debug/ ${libdir}/gstreamer-0.10/.debug/"
> -
> -do_configure_prepend() {
> -	if [ `find ${STAGING_LIBDIR} -name libpython*.so` ]; then
> -		ln -sf ${STAGING_LIBDIR}/libpython*.so `find ${STAGING_LIBDIR} -name libpython*.a -exec dirname {} \;`
> -	fi
> -}



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/4] Rename gstreamer directory to gstreamer-0.10
  2015-05-18 14:16   ` Carlos Rafael Giani
@ 2015-05-18 14:24     ` Alexander Kanavin
  2015-05-18 16:58     ` Burton, Ross
  1 sibling, 0 replies; 20+ messages in thread
From: Alexander Kanavin @ 2015-05-18 14:24 UTC (permalink / raw)
  To: openembedded-devel

On 05/18/2015 05:16 PM, Carlos Rafael Giani wrote:
> Would it be possible to rename  the recipes to match the naming
 > convention of the 1.0 ones? For example, instead of
 > "gst-plugins-bad", it would be "gstreamer0.10-plugins-bad". Is such
 > a backwards compatibility break tolerable between major OE releases?
 >

Uhm, I wouldn't want to do it:

1) The rename would break all the 3rd party BSP/application recipes.

2) GStreamer 0.10 is explicitly obsolete and unsupported, and as of 
today, provided only to ease the transition to 1.0. The 0.10 recipes 
won't be updated anymore, unless someone in the community wants to do it.


Alex



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/4] Rename gstreamer directory to gstreamer-0.10
  2015-05-18 14:16   ` Carlos Rafael Giani
  2015-05-18 14:24     ` Alexander Kanavin
@ 2015-05-18 16:58     ` Burton, Ross
  1 sibling, 0 replies; 20+ messages in thread
From: Burton, Ross @ 2015-05-18 16:58 UTC (permalink / raw)
  To: openembedded-devel

On 18 May 2015 at 15:16, Carlos Rafael Giani <dv@pseudoterminal.org> wrote:

> Would it be possible to rename the recipes to match the naming convention
> of the 1.0 ones?
> For example, instead of "gst-plugins-bad", it would be
> "gstreamer0.10-plugins-bad".
> Is such a backwards compatibility break tolerable between major OE
> releases?
>

I agree with Alex - renaming the recipes is massively invasive and you'd
need to set up a lot of RPROVIDES/RCONFLICTS to provide a migration path
for very little gain.

Ross


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core
  2015-05-18 14:12 [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core Alexander Kanavin
                   ` (3 preceding siblings ...)
  2015-05-18 14:12 ` [PATCH 4/4] Rename gstreamer directory to gstreamer-0.10 Alexander Kanavin
@ 2015-05-21 11:06 ` Martin Jansa
  2015-05-21 13:33   ` Alexander Kanavin
  2015-05-22 16:11   ` akuster808
  4 siblings, 2 replies; 20+ messages in thread
From: Martin Jansa @ 2015-05-21 11:06 UTC (permalink / raw)
  To: openembedded-devel

On Mon, May 18, 2015 at 05:12:44PM +0300, Alexander Kanavin wrote:
> These patches add GStreamer 0.10, and things that depend on it from oe-core
> 
> GStreamer 0.10 is now being removed from oe-core, but we would still like to
> provide it through meta-openembedded.
> 
> See: https://bugzilla.yoctoproject.org/show_bug.cgi?id=6294

How was this tested? Are you just throwing recipes unwanted in oe-core
to meta-oe without testing?

ERROR: ParseError at
/OE/build/shr-core/meta-openembedded/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc:17:
Could not include required file gst-plugins-package.inc

:(

> Alexander Kanavin (4):
>   python-gst: move it from oe-core to meta-multimedia
>   recipes-qt: move qt-mobility from oe-core to meta-oe
>   recipes-multimedia: add gstreamer-0.10 recipes
>   Rename gstreamer directory to gstreamer-0.10
> 
>  .../0001-aacdec-check-channel-count.patch          |   34 +
>  .../0001-alac-fix-nb_samples-order-case.patch      |   30 +
>  .../0001-alsdec-check-block-length.patch           |   61 +
>  ...ac3dec-Check-coding-mode-against-channels.patch |   37 +
>  ...util-fix-signedness-in-sizeof-comparissio.patch |   40 +
>  ...le-use-av_image_get_linesize-to-calculate.patch |   50 +
>  ...c-parser-reset-indexes-on-realloc-failure.patch |   50 +
>  ...a-Perform-pointer-advance-and-checks-befo.patch |   81 +
>  .../0001-avcodec-smc-fix-off-by-1-error.patch      |   32 +
>  ...egtsenc-Check-data-array-size-in-mpegts_w.patch |   69 +
>  .../0001-eamad-fix-out-of-array-accesses.patch     |   29 +
>  ...-error-concealment-initialize-block-index.patch |   29 +
>  ...alment-Check-that-the-picture-is-not-in-a.patch |   37 +
>  .../0001-ffserver-set-oformat.patch                |   36 +
>  ...t-ref-count-check-and-limit-fix-out-of-ar.patch |   29 +
>  ...t-parameters-from-SPS-whenever-it-changes.patch |  145 +
>  ...rror-concealment-when-SPS-and-slices-are-.patch |   33 +
>  .../0001-h264_sei-Fix-infinite-loop.patch          |   39 +
>  ...01-huffyuvdec-Check-init_vlc-return-codes.patch |   87 +
>  .../0001-huffyuvdec-Skip-len-0-cases.patch         |   61 +
>  ...f-compute-probe-buffer-size-more-reliably.patch |   45 +
>  .../0001-mjpegdec-check-SE.patch                   |   32 +
>  ...heck-RLE-size-before-copying.-Fix-out-of-.patch |   34 +
>  ...er-dont-access-out-of-array-elements-at-t.patch |   44 +
>  ...array-index-before-use-fix-out-of-array-a.patch |   30 +
>  .../0001-qdm2dec-fix-buffer-overflow.patch         |   58 +
>  ...001-roqvideodec-check-dimensions-validity.patch |   36 +
>  ...Check-that-the-last-indexes-are-within-th.patch |   32 +
>  ...-vp3-Copy-all-3-frames-for-thread-updates.patch |   32 +
>  ...-read-for-negative-tokens-and-memleaks-on.patch |  183 +
>  ...o-check-chunk-sizes-before-reading-chunks.patch |   51 +
>  ...egdec-check-bits-per-pixel-for-changes-si.patch |   68 +
>  .../gst-ffmpeg-0.10.13/configure-fix.patch         |   22 +
>  .../gst-ffmpeg-CVE-2013-0855.patch                 |  100 +
>  .../gst-ffmpeg-CVE-2013-3674.patch                 |   26 +
>  .../gst-ffmpeg-0.10.13/h264_qpel_mmx.patch         |   57 +
>  .../gst-ffmpeg-0.10.13/libav-9.patch               | 9304 ++++++++++++++++++++
>  .../gst-ffmpeg-0.10.13/libav_e500mc.patch          |   21 +
>  .../gst-ffmpeg-0.10.13/libav_e5500.patch           |   19 +
>  .../gst-ffmpeg-0.10.13/lower-rank.diff             |   16 +
>  .../gstreamer-0.10/gst-ffmpeg_0.10.13.bb           |   90 +
>  .../gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb      |   14 +
>  .../gst-fluendo-mpegdemux_0.10.85.bb               |   12 +
>  .../gstreamer-0.10/gst-fluendo.inc                 |   14 +
>  .../gstreamer-0.10/gst-meta-base_0.10.bb           |   73 +
>  .../gstreamer-0.10/gst-openmax/gcc_4.6.patch       |   18 +
>  .../gstreamer-0.10/gst-openmax/ptr-array.patch     |   46 +
>  .../gstreamer-0.10/gst-openmax_0.10.1.bb           |   35 +
>  .../gstreamer-0.10/gst-plugins-bad_0.10.23.bb      |   50 +
>  ...le-Fix-build-on-x86-if-emmintrin.h-is-ava.patch |   37 +
>  .../configure.ac-fix-subparse-plugin.patch         |   27 +
>  .../gst-plugins-base-tremor.patch                  |   20 +
>  .../gstreamer-0.10/gst-plugins-base_0.10.36.bb     |   39 +
>  ...-conditional-gl-framebuffer-undefined-use.patch |   35 +
>  .../gstreamer-0.10/gst-plugins-gl_0.10.3.bb        |   25 +
>  ...ild-with-recent-kernels-the-v4l2_buffer-i.patch |   33 +
>  ...define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch |   45 +
>  .../0407-mulawdec-fix-integer-overrun.patch        |   47 +
>  .../gstreamer-0.10/gst-plugins-good_0.10.31.bb     |   47 +
>  .../gstreamer-0.10/gst-plugins-ugly_0.10.19.bb     |   29 +
>  .../gstreamer-0.10/gst-plugins.inc                 |   28 +
>  ...ecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch |   34 +
>  .../gstreamer-0.10/gst-rtsp_0.10.8.bb              |   16 +
>  ...ix-self-comparison-always-evaluates-to-tr.patch |   32 +
>  .../gstreamer-0.10.36/check_fix.patch              |   19 +
>  .../gst-inspect-check-error.patch                  |   16 +
>  ...mer-change-priv_gst_parse_yylex-arguments.patch |   33 +
>  .../gstreamer-0.10.36/gstregistrybinary.c          |  487 +
>  .../gstreamer-0.10.36/gstregistrybinary.h          |  194 +
>  .../gstreamer-0.10/gstreamer_0.10.36.bb            |   51 +
>  .../gstreamer-0.10/python-gst/python-path.patch    |   28 +
>  .../gstreamer-0.10/python-gst_0.10.22.bb           |   29 +
>  ...ecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch |   34 -
>  .../gstreamer/gst-rtsp_0.10.8.bb                   |   16 -
>  ...embedded-usage-doesn-t-work-outside-of-Qt.patch |   73 +
>  ...stvideoconnector-fixed-buffers-allocation.patch |   34 +
>  ...nnecessary-rpaths-from-qml_device-example.patch |   28 +
>  .../fix-compile-error-no-bluez.patch               |  338 +
>  .../fix_metaobjectbuilder_build_err.patch          | 4707 ++++++++++
>  .../qt-mobility/qt-mobility-1.2.0/gcc-scope.patch  |   48 +
>  .../qt-mobility-1.2.0/qt-mobility-configure.patch  |   17 +
>  .../qt-mobility-1.2.0/qt-mobility-no-opengl.patch  |   38 +
>  .../qt-mobility-1.2.0/qt-mobility-no-xvideo.patch  |   26 +
>  .../qt-mobility/qt-mobility-embedded_1.2.0.bb      |   11 +
>  .../qt-mobility/qt-mobility-x11_1.2.0.bb           |   10 +
>  .../recipes-qt/qt-mobility/qt-mobility_1.2.0.inc   |  112 +
>  86 files changed, 18364 insertions(+), 50 deletions(-)
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/configure-fix.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav-9.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e500mc.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e5500.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/lower-rank.diff
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg_0.10.13.bb
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mpegdemux_0.10.85.bb
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo.inc
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-meta-base_0.10.bb
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/gcc_4.6.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/ptr-array.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax_0.10.1.bb
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-bad_0.10.23.bb
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base_0.10.36.bb
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl_0.10.3.bb
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good_0.10.31.bb
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-ugly_0.10.19.bb
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins.inc
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp_0.10.8.bb
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/check_fix.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gst-inspect-check-error.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.c
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.h
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer_0.10.36.bb
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst/python-path.patch
>  create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst_0.10.22.bb
>  delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
>  delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp_0.10.8.bb
>  create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0001-fix-embedded-usage-doesn-t-work-outside-of-Qt.patch
>  create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0001-gstvideoconnector-fixed-buffers-allocation.patch
>  create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0002-Remove-unnecessary-rpaths-from-qml_device-example.patch
>  create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/fix-compile-error-no-bluez.patch
>  create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/fix_metaobjectbuilder_build_err.patch
>  create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/gcc-scope.patch
>  create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-configure.patch
>  create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-no-opengl.patch
>  create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-no-xvideo.patch
>  create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-embedded_1.2.0.bb
>  create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-x11_1.2.0.bb
>  create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility_1.2.0.inc
> 
> -- 
> 2.1.4
> 
> -- 
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core
  2015-05-21 11:06 ` [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core Martin Jansa
@ 2015-05-21 13:33   ` Alexander Kanavin
  2015-05-21 13:48     ` Martin Jansa
  2015-05-22 16:11   ` akuster808
  1 sibling, 1 reply; 20+ messages in thread
From: Alexander Kanavin @ 2015-05-21 13:33 UTC (permalink / raw)
  To: openembedded-devel

On 05/21/2015 02:06 PM, Martin Jansa wrote:
> On Mon, May 18, 2015 at 05:12:44PM +0300, Alexander Kanavin wrote:
>> These patches add GStreamer 0.10, and things that depend on it from oe-core
>>
>> GStreamer 0.10 is now being removed from oe-core, but we would still like to
>> provide it through meta-openembedded.
>>
>> See: https://bugzilla.yoctoproject.org/show_bug.cgi?id=6294
> How was this tested? Are you just throwing recipes unwanted in oe-core
> to meta-oe without testing?
>
> ERROR: ParseError at
> /OE/build/shr-core/meta-openembedded/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc:17:
> Could not include required file gst-plugins-package.inc
>

My bad, it wasn't. The missing file is shared between gstreamer 1.0 and 
0.10 recipes, so it has to be copied over. I'll send updated patches.

Alex


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core
  2015-05-21 13:33   ` Alexander Kanavin
@ 2015-05-21 13:48     ` Martin Jansa
  2015-05-21 14:02       ` Alexander Kanavin
  0 siblings, 1 reply; 20+ messages in thread
From: Martin Jansa @ 2015-05-21 13:48 UTC (permalink / raw)
  To: openembedded-devel

On Thu, May 21, 2015 at 04:33:43PM +0300, Alexander Kanavin wrote:
> On 05/21/2015 02:06 PM, Martin Jansa wrote:
> > On Mon, May 18, 2015 at 05:12:44PM +0300, Alexander Kanavin wrote:
> >> These patches add GStreamer 0.10, and things that depend on it from oe-core
> >>
> >> GStreamer 0.10 is now being removed from oe-core, but we would still like to
> >> provide it through meta-openembedded.
> >>
> >> See: https://bugzilla.yoctoproject.org/show_bug.cgi?id=6294
> > How was this tested? Are you just throwing recipes unwanted in oe-core
> > to meta-oe without testing?
> >
> > ERROR: ParseError at
> > /OE/build/shr-core/meta-openembedded/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc:17:
> > Could not include required file gst-plugins-package.inc
> >
> 
> My bad, it wasn't. The missing file is shared between gstreamer 1.0 and 
> 0.10 recipes, so it has to be copied over. I'll send updated patches.

No you don't need to copy it, just use path to it, I've already fixed
it for my jenkins builds, you don't need to resend just because of
this..

meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc:require recipes-multimedia/gstreamer/gst-plugins-package.inc


> 
> Alex
> -- 
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core
  2015-05-21 13:48     ` Martin Jansa
@ 2015-05-21 14:02       ` Alexander Kanavin
  2015-05-21 14:11         ` Martin Jansa
  0 siblings, 1 reply; 20+ messages in thread
From: Alexander Kanavin @ 2015-05-21 14:02 UTC (permalink / raw)
  To: openembedded-devel

On 05/21/2015 04:48 PM, Martin Jansa wrote:
> No you don't need to copy it, just use path to it, I've already fixed 
> it for my jenkins builds, you don't need to resend just because of this..

I wanted to send an updated set, because also this recipe requires a 
file with a path, so that will break after the directory rename (to 
gstreamer-0.10) patch is applied:

gst-plugins-gl_0.10.3.bb:require 
recipes-multimedia/gstreamer/gst-plugins.inc


Here the path should be removed instead.


Alex


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core
  2015-05-21 14:02       ` Alexander Kanavin
@ 2015-05-21 14:11         ` Martin Jansa
  2015-05-21 14:19           ` Alexander Kanavin
  0 siblings, 1 reply; 20+ messages in thread
From: Martin Jansa @ 2015-05-21 14:11 UTC (permalink / raw)
  To: openembedded-devel

[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]

On Thu, May 21, 2015 at 05:02:35PM +0300, Alexander Kanavin wrote:
> On 05/21/2015 04:48 PM, Martin Jansa wrote:
> > No you don't need to copy it, just use path to it, I've already fixed 
> > it for my jenkins builds, you don't need to resend just because of this..
> 
> I wanted to send an updated set, because also this recipe requires a 
> file with a path, so that will break after the directory rename (to 
> gstreamer-0.10) patch is applied:

Are you going to rename gstreamer to gstreamer-0.10 in oe-core? I don't
think so or I misunderstood what you meant, these 2 lines look correct
to me:
$ git grep gst-plugins-package.inc
meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc:require recipes-multimedia/gstreamer/gst-plugins-package.inc
meta-oe/recipes-connectivity/bluez/gst-plugin-bluetooth_4.101.bb:require recipes-multimedia/gstreamer/gst-plugins-package.inc

and renaming the directory in meta-multimedia doesn't have any impact on
this.

> gst-plugins-gl_0.10.3.bb:require 
> recipes-multimedia/gstreamer/gst-plugins.inc
> 
> 
> Here the path should be removed instead.
> 
> 
> Alex
> -- 
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 188 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core
  2015-05-21 14:11         ` Martin Jansa
@ 2015-05-21 14:19           ` Alexander Kanavin
  0 siblings, 0 replies; 20+ messages in thread
From: Alexander Kanavin @ 2015-05-21 14:19 UTC (permalink / raw)
  To: openembedded-devel

On 05/21/2015 05:11 PM, Martin Jansa wrote:
> Are you going to rename gstreamer to gstreamer-0.10 in oe-core? I don't
> think so or I misunderstood what you meant, these 2 lines look correct
> to me:
> $ git grep gst-plugins-package.inc
> meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc:require recipes-multimedia/gstreamer/gst-plugins-package.inc
> meta-oe/recipes-connectivity/bluez/gst-plugin-bluetooth_4.101.bb:require recipes-multimedia/gstreamer/gst-plugins-package.inc
>
> and renaming the directory in meta-multimedia doesn't have any impact on
> this.

These lines above are correct. They refer to a file in oe-core.

>> gst-plugins-gl_0.10.3.bb:require
>> recipes-multimedia/gstreamer/gst-plugins.inc

This line will not be correct after the directory rename, because it 
refers to a file in meta-multimedia, and not in oe-core. This is a 
separate problem that should only show up after the directory rename 
patch is applied. The way to fix it is to remove the path to the file 
because it's in the same dir as the recipe.

Alex


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core
  2015-05-21 11:06 ` [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core Martin Jansa
  2015-05-21 13:33   ` Alexander Kanavin
@ 2015-05-22 16:11   ` akuster808
  2015-05-22 16:30     ` Burton, Ross
  1 sibling, 1 reply; 20+ messages in thread
From: akuster808 @ 2015-05-22 16:11 UTC (permalink / raw)
  To: openembedded-devel

I have noticed some breakages when building xfce, (libcanberra DEPENDS = 
'gstreamer') now needs to be "gstream1.0". I suspect some of it is do to 
gstreamer transitioning. I will give a few days to settle before sending 
patches.

- armin

On 05/21/2015 04:06 AM, Martin Jansa wrote:
> On Mon, May 18, 2015 at 05:12:44PM +0300, Alexander Kanavin wrote:
>> These patches add GStreamer 0.10, and things that depend on it from oe-core
>>
>> GStreamer 0.10 is now being removed from oe-core, but we would still like to
>> provide it through meta-openembedded.
>>
>> See: https://bugzilla.yoctoproject.org/show_bug.cgi?id=6294
>
> How was this tested? Are you just throwing recipes unwanted in oe-core
> to meta-oe without testing?
>
> ERROR: ParseError at
> /OE/build/shr-core/meta-openembedded/meta-multimedia/recipes-multimedia/gstreamer/gst-plugins.inc:17:
> Could not include required file gst-plugins-package.inc
>
> :(
>
>> Alexander Kanavin (4):
>>    python-gst: move it from oe-core to meta-multimedia
>>    recipes-qt: move qt-mobility from oe-core to meta-oe
>>    recipes-multimedia: add gstreamer-0.10 recipes
>>    Rename gstreamer directory to gstreamer-0.10
>>
>>   .../0001-aacdec-check-channel-count.patch          |   34 +
>>   .../0001-alac-fix-nb_samples-order-case.patch      |   30 +
>>   .../0001-alsdec-check-block-length.patch           |   61 +
>>   ...ac3dec-Check-coding-mode-against-channels.patch |   37 +
>>   ...util-fix-signedness-in-sizeof-comparissio.patch |   40 +
>>   ...le-use-av_image_get_linesize-to-calculate.patch |   50 +
>>   ...c-parser-reset-indexes-on-realloc-failure.patch |   50 +
>>   ...a-Perform-pointer-advance-and-checks-befo.patch |   81 +
>>   .../0001-avcodec-smc-fix-off-by-1-error.patch      |   32 +
>>   ...egtsenc-Check-data-array-size-in-mpegts_w.patch |   69 +
>>   .../0001-eamad-fix-out-of-array-accesses.patch     |   29 +
>>   ...-error-concealment-initialize-block-index.patch |   29 +
>>   ...alment-Check-that-the-picture-is-not-in-a.patch |   37 +
>>   .../0001-ffserver-set-oformat.patch                |   36 +
>>   ...t-ref-count-check-and-limit-fix-out-of-ar.patch |   29 +
>>   ...t-parameters-from-SPS-whenever-it-changes.patch |  145 +
>>   ...rror-concealment-when-SPS-and-slices-are-.patch |   33 +
>>   .../0001-h264_sei-Fix-infinite-loop.patch          |   39 +
>>   ...01-huffyuvdec-Check-init_vlc-return-codes.patch |   87 +
>>   .../0001-huffyuvdec-Skip-len-0-cases.patch         |   61 +
>>   ...f-compute-probe-buffer-size-more-reliably.patch |   45 +
>>   .../0001-mjpegdec-check-SE.patch                   |   32 +
>>   ...heck-RLE-size-before-copying.-Fix-out-of-.patch |   34 +
>>   ...er-dont-access-out-of-array-elements-at-t.patch |   44 +
>>   ...array-index-before-use-fix-out-of-array-a.patch |   30 +
>>   .../0001-qdm2dec-fix-buffer-overflow.patch         |   58 +
>>   ...001-roqvideodec-check-dimensions-validity.patch |   36 +
>>   ...Check-that-the-last-indexes-are-within-th.patch |   32 +
>>   ...-vp3-Copy-all-3-frames-for-thread-updates.patch |   32 +
>>   ...-read-for-negative-tokens-and-memleaks-on.patch |  183 +
>>   ...o-check-chunk-sizes-before-reading-chunks.patch |   51 +
>>   ...egdec-check-bits-per-pixel-for-changes-si.patch |   68 +
>>   .../gst-ffmpeg-0.10.13/configure-fix.patch         |   22 +
>>   .../gst-ffmpeg-CVE-2013-0855.patch                 |  100 +
>>   .../gst-ffmpeg-CVE-2013-3674.patch                 |   26 +
>>   .../gst-ffmpeg-0.10.13/h264_qpel_mmx.patch         |   57 +
>>   .../gst-ffmpeg-0.10.13/libav-9.patch               | 9304 ++++++++++++++++++++
>>   .../gst-ffmpeg-0.10.13/libav_e500mc.patch          |   21 +
>>   .../gst-ffmpeg-0.10.13/libav_e5500.patch           |   19 +
>>   .../gst-ffmpeg-0.10.13/lower-rank.diff             |   16 +
>>   .../gstreamer-0.10/gst-ffmpeg_0.10.13.bb           |   90 +
>>   .../gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb      |   14 +
>>   .../gst-fluendo-mpegdemux_0.10.85.bb               |   12 +
>>   .../gstreamer-0.10/gst-fluendo.inc                 |   14 +
>>   .../gstreamer-0.10/gst-meta-base_0.10.bb           |   73 +
>>   .../gstreamer-0.10/gst-openmax/gcc_4.6.patch       |   18 +
>>   .../gstreamer-0.10/gst-openmax/ptr-array.patch     |   46 +
>>   .../gstreamer-0.10/gst-openmax_0.10.1.bb           |   35 +
>>   .../gstreamer-0.10/gst-plugins-bad_0.10.23.bb      |   50 +
>>   ...le-Fix-build-on-x86-if-emmintrin.h-is-ava.patch |   37 +
>>   .../configure.ac-fix-subparse-plugin.patch         |   27 +
>>   .../gst-plugins-base-tremor.patch                  |   20 +
>>   .../gstreamer-0.10/gst-plugins-base_0.10.36.bb     |   39 +
>>   ...-conditional-gl-framebuffer-undefined-use.patch |   35 +
>>   .../gstreamer-0.10/gst-plugins-gl_0.10.3.bb        |   25 +
>>   ...ild-with-recent-kernels-the-v4l2_buffer-i.patch |   33 +
>>   ...define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch |   45 +
>>   .../0407-mulawdec-fix-integer-overrun.patch        |   47 +
>>   .../gstreamer-0.10/gst-plugins-good_0.10.31.bb     |   47 +
>>   .../gstreamer-0.10/gst-plugins-ugly_0.10.19.bb     |   29 +
>>   .../gstreamer-0.10/gst-plugins.inc                 |   28 +
>>   ...ecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch |   34 +
>>   .../gstreamer-0.10/gst-rtsp_0.10.8.bb              |   16 +
>>   ...ix-self-comparison-always-evaluates-to-tr.patch |   32 +
>>   .../gstreamer-0.10.36/check_fix.patch              |   19 +
>>   .../gst-inspect-check-error.patch                  |   16 +
>>   ...mer-change-priv_gst_parse_yylex-arguments.patch |   33 +
>>   .../gstreamer-0.10.36/gstregistrybinary.c          |  487 +
>>   .../gstreamer-0.10.36/gstregistrybinary.h          |  194 +
>>   .../gstreamer-0.10/gstreamer_0.10.36.bb            |   51 +
>>   .../gstreamer-0.10/python-gst/python-path.patch    |   28 +
>>   .../gstreamer-0.10/python-gst_0.10.22.bb           |   29 +
>>   ...ecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch |   34 -
>>   .../gstreamer/gst-rtsp_0.10.8.bb                   |   16 -
>>   ...embedded-usage-doesn-t-work-outside-of-Qt.patch |   73 +
>>   ...stvideoconnector-fixed-buffers-allocation.patch |   34 +
>>   ...nnecessary-rpaths-from-qml_device-example.patch |   28 +
>>   .../fix-compile-error-no-bluez.patch               |  338 +
>>   .../fix_metaobjectbuilder_build_err.patch          | 4707 ++++++++++
>>   .../qt-mobility/qt-mobility-1.2.0/gcc-scope.patch  |   48 +
>>   .../qt-mobility-1.2.0/qt-mobility-configure.patch  |   17 +
>>   .../qt-mobility-1.2.0/qt-mobility-no-opengl.patch  |   38 +
>>   .../qt-mobility-1.2.0/qt-mobility-no-xvideo.patch  |   26 +
>>   .../qt-mobility/qt-mobility-embedded_1.2.0.bb      |   11 +
>>   .../qt-mobility/qt-mobility-x11_1.2.0.bb           |   10 +
>>   .../recipes-qt/qt-mobility/qt-mobility_1.2.0.inc   |  112 +
>>   86 files changed, 18364 insertions(+), 50 deletions(-)
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/configure-fix.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav-9.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e500mc.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/libav_e5500.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg-0.10.13/lower-rank.diff
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-ffmpeg_0.10.13.bb
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mp3_0.10.31.bb
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo-mpegdemux_0.10.85.bb
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-fluendo.inc
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-meta-base_0.10.bb
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/gcc_4.6.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax/ptr-array.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-openmax_0.10.1.bb
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-bad_0.10.23.bb
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-base_0.10.36.bb
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-gl_0.10.3.bb
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-good_0.10.31.bb
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins-ugly_0.10.19.bb
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-plugins.inc
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gst-rtsp_0.10.8.bb
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/check_fix.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gst-inspect-check-error.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstreamer-change-priv_gst_parse_yylex-arguments.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.c
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer-0.10.36/gstregistrybinary.h
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/gstreamer_0.10.36.bb
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst/python-path.patch
>>   create mode 100644 meta-multimedia/recipes-multimedia/gstreamer-0.10/python-gst_0.10.22.bb
>>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp/0001-change-deprecated-INCLUDES-to-AM_CPPFLAGS-for-automa.patch
>>   delete mode 100644 meta-multimedia/recipes-multimedia/gstreamer/gst-rtsp_0.10.8.bb
>>   create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0001-fix-embedded-usage-doesn-t-work-outside-of-Qt.patch
>>   create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0001-gstvideoconnector-fixed-buffers-allocation.patch
>>   create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/0002-Remove-unnecessary-rpaths-from-qml_device-example.patch
>>   create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/fix-compile-error-no-bluez.patch
>>   create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/fix_metaobjectbuilder_build_err.patch
>>   create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/gcc-scope.patch
>>   create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-configure.patch
>>   create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-no-opengl.patch
>>   create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-1.2.0/qt-mobility-no-xvideo.patch
>>   create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-embedded_1.2.0.bb
>>   create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility-x11_1.2.0.bb
>>   create mode 100644 meta-oe/recipes-qt/qt-mobility/qt-mobility_1.2.0.inc
>>
>> --
>> 2.1.4
>>
>> --
>> _______________________________________________
>> Openembedded-devel mailing list
>> Openembedded-devel@lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/openembedded-devel
>


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core
  2015-05-22 16:11   ` akuster808
@ 2015-05-22 16:30     ` Burton, Ross
  2015-05-25 16:39       ` akuster808
  2015-06-05  8:40       ` Huang, Jie (Jackie)
  0 siblings, 2 replies; 20+ messages in thread
From: Burton, Ross @ 2015-05-22 16:30 UTC (permalink / raw)
  To: openembedded-devel

On 22 May 2015 at 17:11, akuster808 <akuster808@gmail.com> wrote:

> I have noticed some breakages when building xfce, (libcanberra DEPENDS =
> 'gstreamer') now needs to be "gstream1.0". I suspect some of it is do to
> gstreamer transitioning. I will give a few days to settle before sending
> patches.
>

libcanberra 0.29 only supports GStreamer 0.10, libcanberra 0.30 depends on
1.0.

I suspect the problem you're hitting is that libcanberra 0.29 depends on
gstreamer which isn't in oe-core anymore, but switching gstreamer to
gstreamer1.0 whilst letting the build run will mean libcanberra doesn't
actually support GStreamer...

Either xfce should keep with GStreamer 0.10 and so depend on
meta-multimedia, or xfce and related recipes migrate to GStreamer 1.x.

Ross


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core
  2015-05-22 16:30     ` Burton, Ross
@ 2015-05-25 16:39       ` akuster808
  2015-05-26  9:01         ` Burton, Ross
  2015-05-26 12:26         ` Alexander Kanavin
  2015-06-05  8:40       ` Huang, Jie (Jackie)
  1 sibling, 2 replies; 20+ messages in thread
From: akuster808 @ 2015-05-25 16:39 UTC (permalink / raw)
  To: openembedded-devel



On 05/22/2015 09:30 AM, Burton, Ross wrote:
> On 22 May 2015 at 17:11, akuster808 <akuster808@gmail.com> wrote:
>
>> I have noticed some breakages when building xfce, (libcanberra DEPENDS =
>> 'gstreamer') now needs to be "gstream1.0". I suspect some of it is do to
>> gstreamer transitioning. I will give a few days to settle before sending
>> patches.
>>
>
> libcanberra 0.29 only supports GStreamer 0.10, libcanberra 0.30 depends on
> 1.0.

ok, I will look into that.
>
> I suspect the problem you're hitting is that libcanberra 0.29 depends on
> gstreamer which isn't in oe-core anymore, but switching gstreamer to
> gstreamer1.0 whilst letting the build run will mean libcanberra doesn't
> actually support GStreamer...
>
> Either xfce should keep with GStreamer 0.10 and so depend on
> meta-multimedia, or xfce and related recipes migrate to GStreamer 1.x.

This is less of an xfce issue as meta-oe world wont build do to the 
above mentioned depends. Maybe we may want to move the failing packages 
to a more appropriate location, upgrade or fix the depends.

failing packages:
farsight2, pidgin, licnice, libcanberra  and qt-mobility

would creating a virtual/gstreamer help?

- armin
>
> Ross
>


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core
  2015-05-25 16:39       ` akuster808
@ 2015-05-26  9:01         ` Burton, Ross
  2015-05-26 12:26         ` Alexander Kanavin
  1 sibling, 0 replies; 20+ messages in thread
From: Burton, Ross @ 2015-05-26  9:01 UTC (permalink / raw)
  To: openembedded-devel

On 25 May 2015 at 17:39, akuster808 <akuster808@gmail.com> wrote:

> would creating a virtual/gstreamer help?
>

No, because GStreamer 0.10 and 1.x have different API/ABIs.  They are
parallel installable though.

Ross


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core
  2015-05-25 16:39       ` akuster808
  2015-05-26  9:01         ` Burton, Ross
@ 2015-05-26 12:26         ` Alexander Kanavin
  1 sibling, 0 replies; 20+ messages in thread
From: Alexander Kanavin @ 2015-05-26 12:26 UTC (permalink / raw)
  To: openembedded-devel

On 05/25/2015 07:39 PM, akuster808 wrote:

> This is less of an xfce issue as meta-oe world wont build do to the
> above mentioned depends. Maybe we may want to move the failing packages
> to a more appropriate location, upgrade or fix the depends.
>
> failing packages:
> farsight2, pidgin, licnice, libcanberra  and qt-mobility

Can I see why qt-mobility fails? It has built fine on my local machine 
after the move from oe-core.

Alex



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core
  2015-05-22 16:30     ` Burton, Ross
  2015-05-25 16:39       ` akuster808
@ 2015-06-05  8:40       ` Huang, Jie (Jackie)
  1 sibling, 0 replies; 20+ messages in thread
From: Huang, Jie (Jackie) @ 2015-06-05  8:40 UTC (permalink / raw)
  To: openembedded-devel



> -----Original Message-----
> From: openembedded-devel-bounces@lists.openembedded.org [mailto:openembedded-devel-
> bounces@lists.openembedded.org] On Behalf Of Burton, Ross
> Sent: Saturday, May 23, 2015 12:30 AM
> To: openembedded-devel@lists.openembedded.org
> Subject: Re: [oe] [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core
> 
> On 22 May 2015 at 17:11, akuster808 <akuster808@gmail.com> wrote:
> 
> > I have noticed some breakages when building xfce, (libcanberra DEPENDS
> > =
> > 'gstreamer') now needs to be "gstream1.0". I suspect some of it is do
> > to gstreamer transitioning. I will give a few days to settle before
> > sending patches.
> >
> 
> libcanberra 0.29 only supports GStreamer 0.10, libcanberra 0.30 depends on 1.0.
> 
> I suspect the problem you're hitting is that libcanberra 0.29 depends on gstreamer which isn't in oe-
> core anymore, but switching gstreamer to
> gstreamer1.0 whilst letting the build run will mean libcanberra doesn't actually support GStreamer...

We are hitting the same issue, I think we should upgrade libcanberra to version 0.30 and make it depend on
Gstream1.0,  and I think the dependency on gstreamer is not mandatory for libcanberra, it's an optional support, 
we should make it into PACKAGECONFIG and use DISTRO_FEATURES to decide if it's needed.

Thanks,
Jackie

> 
> Either xfce should keep with GStreamer 0.10 and so depend on meta-multimedia, or xfce and related
> recipes migrate to GStreamer 1.x.
> 
> Ross
> --
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2015-06-05  8:40 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-18 14:12 [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core Alexander Kanavin
2015-05-18 14:12 ` [PATCH 1/4] python-gst: move it from oe-core to meta-multimedia Alexander Kanavin
2015-05-18 14:12 ` [PATCH 2/4] recipes-qt: move qt-mobility from oe-core to meta-oe Alexander Kanavin
2015-05-18 14:12 ` [PATCH 3/4] recipes-multimedia: add gstreamer-0.10 recipes Alexander Kanavin
2015-05-18 14:12 ` [PATCH 4/4] Rename gstreamer directory to gstreamer-0.10 Alexander Kanavin
2015-05-18 14:16   ` Carlos Rafael Giani
2015-05-18 14:24     ` Alexander Kanavin
2015-05-18 16:58     ` Burton, Ross
2015-05-21 11:06 ` [PATCH 0/4] Add GStreamer 0.10 and things that depend on it from oe-core Martin Jansa
2015-05-21 13:33   ` Alexander Kanavin
2015-05-21 13:48     ` Martin Jansa
2015-05-21 14:02       ` Alexander Kanavin
2015-05-21 14:11         ` Martin Jansa
2015-05-21 14:19           ` Alexander Kanavin
2015-05-22 16:11   ` akuster808
2015-05-22 16:30     ` Burton, Ross
2015-05-25 16:39       ` akuster808
2015-05-26  9:01         ` Burton, Ross
2015-05-26 12:26         ` Alexander Kanavin
2015-06-05  8:40       ` Huang, Jie (Jackie)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.