summaryrefslogtreecommitdiffstats
path: root/meta/recipes-multimedia
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-multimedia')
-rw-r--r--meta/recipes-multimedia/alsa/alsa-fpu.inc6
-rwxr-xr-xmeta/recipes-multimedia/alsa/alsa-lib/0001-pcm-pcm_local.h-include-time.h-to-enable-CLOCK_MONOT.patch32
-rwxr-xr-xmeta/recipes-multimedia/alsa/alsa-lib/0001-pcm-rate-fix-hw_ptr-exceed-the-boundary.patch34
-rwxr-xr-xmeta/recipes-multimedia/alsa/alsa-lib/0001-pcm-route-Use-get32-for-multi-source-route-calculati.patch345
-rw-r--r--meta/recipes-multimedia/alsa/alsa-lib/Check-if-wordexp-function-is-supported.patch51
-rw-r--r--meta/recipes-multimedia/alsa/alsa-lib/fix-tstamp-declaration.patch21
-rw-r--r--meta/recipes-multimedia/alsa/alsa-lib_1.0.28.bb54
-rw-r--r--meta/recipes-multimedia/alsa/alsa-tools/autotools.patch32
-rw-r--r--meta/recipes-multimedia/alsa/alsa-tools/makefile_no_gtk.patch25
-rw-r--r--meta/recipes-multimedia/alsa/alsa-tools_1.0.28.bb35
-rw-r--r--meta/recipes-multimedia/alsa/alsa-utils-alsaconf_1.0.28.bb17
-rw-r--r--meta/recipes-multimedia/alsa/alsa-utils/0001-alsactl-don-t-let-systemd-unit-restore-the-volume-wh.patch52
-rw-r--r--meta/recipes-multimedia/alsa/alsa-utils/alsa-utils-aplay-interrupt-signal-handling.patch48
-rw-r--r--meta/recipes-multimedia/alsa/alsa-utils_1.0.28.bb95
-rw-r--r--meta/recipes-multimedia/flac/flac-1.3.0/0001-Fix-Makefile.am-altivec-logic.patch35
-rw-r--r--meta/recipes-multimedia/flac/flac_1.3.0.bb44
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch34
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch30
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch61
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch37
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch40
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch50
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch50
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch81
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch32
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch69
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch29
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch29
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch37
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch36
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch29
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch145
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch33
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch39
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch87
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch61
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-check-width-more-completely-avoid-out-of-.patch30
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch45
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch32
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch34
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch44
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch30
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch58
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch36
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch32
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch32
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch183
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch51
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch68
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch22
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch100
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch26
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch57
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch9304
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch21
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch19
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff16
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb92
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.19.bb14
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.72.bb12
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-fluendo.inc14
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb73
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch18
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch46
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb35
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb50
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch37
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch27
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch20
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb39
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch35
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb25
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch33
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch45
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch47
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb44
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-plugins-package.inc58
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb29
-rw-r--r--meta/recipes-multimedia/gstreamer/gst-plugins.inc28
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch32
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch19
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch16
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c487
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h194
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-libav.inc32
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-libav/0001-Disable-yasm-for-libav-when-disable-yasm.patch33
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-libav_1.4.1.bb24
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-libav_git.bb28
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-meta-base.bb65
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-omx.inc42
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-omx/0001-omx-fixed-type-error-in-printf-call.patch30
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-omx_1.2.0.bb12
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-omx_git.bb21
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad.inc134
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0001-gl-do-not-check-for-GL-GLU-EGL-GLES2-libs-if-disable.patch41
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/configure-allow-to-disable-libssh2.patch64
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.4.1.bb13
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_git.bb27
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base.inc40
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/do-not-change-eos-event-to-gap-event-if.patch37
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/get-caps-from-src-pad-when-query-caps.patch44
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.4.1.bb14
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_git.bb19
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good.inc57
-rwxr-xr-xmeta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good/0001-gstrtpmp4gpay-set-dafault-value-for-MPEG4-without-co.patch62
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_1.4.1.bb12
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_git.bb18
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly.inc31
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly_1.4.1.bb8
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly_git.bb17
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins.inc57
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-rtsp-server.inc14
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-rtsp-server_1.4.1.bb6
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0.inc27
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0/0001-Fix-crash-with-gst-inspect.patch28
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0_1.4.1.bb13
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0_git.bb18
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb50
-rw-r--r--meta/recipes-multimedia/lame/lame/lame-3.99.5_fix_for_automake-1.12.x.patch59
-rw-r--r--meta/recipes-multimedia/lame/lame/no-gtk1.patch20
-rw-r--r--meta/recipes-multimedia/lame/lame_3.99.5.bb30
-rw-r--r--meta/recipes-multimedia/liba52/liba52/buildcleanup.patch89
-rw-r--r--meta/recipes-multimedia/liba52/liba52_0.7.4.bb23
-rw-r--r--meta/recipes-multimedia/libav/libav.inc144
-rw-r--r--meta/recipes-multimedia/libav/libav/0001-configure-enable-pic-for-AArch64.patch23
-rw-r--r--meta/recipes-multimedia/libav/libav_0.8.15.bb18
-rw-r--r--meta/recipes-multimedia/libav/libav_9.16.bb13
-rw-r--r--meta/recipes-multimedia/libid3tag/libid3tag/addpkgconfig.patch43
-rw-r--r--meta/recipes-multimedia/libid3tag/libid3tag/obsolete_automake_macros.patch15
-rw-r--r--meta/recipes-multimedia/libid3tag/libid3tag_0.15.1b.bb22
-rw-r--r--meta/recipes-multimedia/libmad/libmad/add-pkgconfig.patch70
-rw-r--r--meta/recipes-multimedia/libmad/libmad/automake-foreign.patch12
-rw-r--r--meta/recipes-multimedia/libmad/libmad/fix_for_mips_with_gcc-4.5.0.patch33
-rw-r--r--meta/recipes-multimedia/libmad/libmad/no-force-mem.patch18
-rw-r--r--meta/recipes-multimedia/libmad/libmad/obsolete_automake_macros.patch14
-rw-r--r--meta/recipes-multimedia/libmad/libmad_0.15.1b.bb38
-rw-r--r--meta/recipes-multimedia/libogg/libogg_1.3.2.bb17
-rw-r--r--meta/recipes-multimedia/libomxil/libomxil-0.9.3/configure-fix.patch58
-rw-r--r--meta/recipes-multimedia/libomxil/libomxil-0.9.3/disable-so-versioning.patch36
-rw-r--r--meta/recipes-multimedia/libomxil/libomxil-0.9.3/dynamicloader-linking.patch20
-rw-r--r--meta/recipes-multimedia/libomxil/libomxil-0.9.3/makefile-docdir-fix.patch19
-rw-r--r--meta/recipes-multimedia/libomxil/libomxil-0.9.3/parallel-make.patch18
-rw-r--r--meta/recipes-multimedia/libomxil/libomxil_0.9.3.bb39
-rw-r--r--meta/recipes-multimedia/libpng/libpng_1.6.13.bb29
-rw-r--r--meta/recipes-multimedia/libsamplerate/libsamplerate0_0.1.8.bb18
-rw-r--r--meta/recipes-multimedia/libsndfile/files/0001-src-sd2.c-Fix-segfault-in-SD2-RSRC-parser.patch211
-rw-r--r--meta/recipes-multimedia/libsndfile/files/0001-src-sd2.c-Fix-two-potential-buffer-read-overflows.patch49
-rw-r--r--meta/recipes-multimedia/libsndfile/libsndfile1_1.0.25.bb33
-rw-r--r--meta/recipes-multimedia/libtheora/libtheora-1.1.1/no-docs.patch15
-rw-r--r--meta/recipes-multimedia/libtheora/libtheora_1.1.1.bb20
-rw-r--r--meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-1960.patch151
-rw-r--r--meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-1961.patch786
-rw-r--r--meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4231.patch44
-rw-r--r--meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4232.patch15
-rw-r--r--meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4243.patch40
-rw-r--r--meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4244.patch19
-rw-r--r--meta/recipes-multimedia/libtiff/files/libtool2.patch19
-rw-r--r--meta/recipes-multimedia/libtiff/files/tiff-CVE-2012-4564.patch99
-rw-r--r--meta/recipes-multimedia/libtiff/tiff_4.0.3.bb54
-rw-r--r--meta/recipes-multimedia/libvorbis/libvorbis_1.3.4.bb25
-rw-r--r--meta/recipes-multimedia/mpeg2dec/mpeg2dec-0.4.1/altivec_h_needed.patch43
-rw-r--r--meta/recipes-multimedia/mpeg2dec/mpeg2dec_0.4.1.bb38
-rw-r--r--meta/recipes-multimedia/pulseaudio/libatomics-ops_7.2.bb31
-rw-r--r--meta/recipes-multimedia/pulseaudio/pulseaudio.inc151
-rw-r--r--meta/recipes-multimedia/pulseaudio/pulseaudio/0001-configure.ac-Check-only-for-libsystemd-not-libsystem.patch30
-rw-r--r--meta/recipes-multimedia/pulseaudio/pulseaudio/CVE-2014-3970.patch52
-rw-r--r--meta/recipes-multimedia/pulseaudio/pulseaudio/volatiles.04_pulse2
-rw-r--r--meta/recipes-multimedia/pulseaudio/pulseaudio_5.0.bb14
-rw-r--r--meta/recipes-multimedia/sbc/sbc_1.2.bb16
-rw-r--r--meta/recipes-multimedia/speex/speex-fpu.inc4
-rw-r--r--meta/recipes-multimedia/speex/speex_1.2rc1.bb25
-rw-r--r--meta/recipes-multimedia/tremor/tremor-20120314/obsolete_automake_macros.patch15
-rw-r--r--meta/recipes-multimedia/tremor/tremor-20120314/tremor-arm-thumb2.patch104
-rw-r--r--meta/recipes-multimedia/tremor/tremor_20120314.bb22
-rw-r--r--meta/recipes-multimedia/x264/x264/don-t-default-to-cortex-a9-with-neon.patch20
-rw-r--r--meta/recipes-multimedia/x264/x264_git.bb55
176 files changed, 18022 insertions, 0 deletions
diff --git a/meta/recipes-multimedia/alsa/alsa-fpu.inc b/meta/recipes-multimedia/alsa/alsa-fpu.inc
new file mode 100644
index 0000000000..50402307c5
--- /dev/null
+++ b/meta/recipes-multimedia/alsa/alsa-fpu.inc
@@ -0,0 +1,6 @@
1
2def get_alsa_fpu_setting(bb, d):
3 if d.getVar('TARGET_FPU', True) in [ 'soft' ]:
4 return "--with-softfloat"
5 return ""
6
diff --git a/meta/recipes-multimedia/alsa/alsa-lib/0001-pcm-pcm_local.h-include-time.h-to-enable-CLOCK_MONOT.patch b/meta/recipes-multimedia/alsa/alsa-lib/0001-pcm-pcm_local.h-include-time.h-to-enable-CLOCK_MONOT.patch
new file mode 100755
index 0000000000..06cdcb9894
--- /dev/null
+++ b/meta/recipes-multimedia/alsa/alsa-lib/0001-pcm-pcm_local.h-include-time.h-to-enable-CLOCK_MONOT.patch
@@ -0,0 +1,32 @@
1From f6b879e7cc87d83343f5004369146881d1d1e335 Mon Sep 17 00:00:00 2001
2From: Shengjiu Wang <shengjiu.wang@freescale.com>
3Date: Wed, 23 Jul 2014 15:09:58 +0800
4Subject: [PATCH] pcm: pcm_local.h: include <time.h> to enable CLOCK_MONOTONIC
5
6CLOCK_MONITONIC is defined in <bits/time.h>, add <time.h> before <sys/time.h>.
7
8Commit f6b879e7cc87d83343f5004369146881d1d1e335 in master branch
9
10Upstream Status: Backported
11
12Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
13Signed-off-by: Takashi Iwai <tiwai@suse.de>
14---
15 src/pcm/pcm_local.h | 1 +
16 1 file changed, 1 insertion(+)
17
18diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h
19index 2206afe..80bbe59 100644
20--- a/src/pcm/pcm_local.h
21+++ b/src/pcm/pcm_local.h
22@@ -24,6 +24,7 @@
23 #include <stdlib.h>
24 #include <limits.h>
25 #include <sys/uio.h>
26+#include <time.h>
27 #include <sys/time.h>
28
29 #define _snd_mask sndrv_mask
30--
311.7.9.5
32
diff --git a/meta/recipes-multimedia/alsa/alsa-lib/0001-pcm-rate-fix-hw_ptr-exceed-the-boundary.patch b/meta/recipes-multimedia/alsa/alsa-lib/0001-pcm-rate-fix-hw_ptr-exceed-the-boundary.patch
new file mode 100755
index 0000000000..8be3d757a1
--- /dev/null
+++ b/meta/recipes-multimedia/alsa/alsa-lib/0001-pcm-rate-fix-hw_ptr-exceed-the-boundary.patch
@@ -0,0 +1,34 @@
1From 035f196bcdc1e9903ed52ad1859dc23d3aa74e72 Mon Sep 17 00:00:00 2001
2From: Shengjiu Wang <shengjiu.wang@freescale.com>
3Date: Mon, 14 Jul 2014 16:55:48 +0800
4Subject: [PATCH] pcm: rate: fix hw_ptr exceed the boundary
5
6For long time test case, the hw_ptr will exceed the boundary, then cause
7the avail size wrong.
8
9Commit is 035f196bcdc1e9903ed52ad1859dc23d3aa74e72 in master branch
10
11Upstream Status: Backported
12
13Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
14Signed-off-by: Takashi Iwai <tiwai@suse.de>
15---
16 src/pcm/pcm_rate.c | 2 ++
17 1 file changed, 2 insertions(+)
18
19diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c
20index 7f667d4..2563d82 100644
21--- a/src/pcm/pcm_rate.c
22+++ b/src/pcm/pcm_rate.c
23@@ -574,6 +574,8 @@ static inline void snd_pcm_rate_sync_hwptr(snd_pcm_t *pcm)
24 rate->hw_ptr =
25 (slave_hw_ptr / rate->gen.slave->period_size) * pcm->period_size +
26 rate->ops.input_frames(rate->obj, slave_hw_ptr % rate->gen.slave->period_size);
27+
28+ rate->hw_ptr %= pcm->boundary;
29 }
30
31 static int snd_pcm_rate_hwsync(snd_pcm_t *pcm)
32--
331.7.9.5
34
diff --git a/meta/recipes-multimedia/alsa/alsa-lib/0001-pcm-route-Use-get32-for-multi-source-route-calculati.patch b/meta/recipes-multimedia/alsa/alsa-lib/0001-pcm-route-Use-get32-for-multi-source-route-calculati.patch
new file mode 100755
index 0000000000..89363d55d2
--- /dev/null
+++ b/meta/recipes-multimedia/alsa/alsa-lib/0001-pcm-route-Use-get32-for-multi-source-route-calculati.patch
@@ -0,0 +1,345 @@
1From 3f179d6cc7c222dfa42fe094b7ef1e21685a05bc Mon Sep 17 00:00:00 2001
2From: Takashi Iwai <tiwai@suse.de>
3Date: Tue, 22 Jul 2014 11:55:40 +0200
4Subject: [PATCH] pcm: route: Use get32 for multi-source route calculation
5
6The PCM route plugin can assign the destination value from average of
7multiple sources with attenuation. This requires the read of each
8channel value, sums and writes the resultant value in the requested
9format.
10
11Currently, get_labels is used for reading source values while
12put32_labels is used for writing the dest value. This is, however,
13a buggy implementation; get_labels gives the value as is only with
14endianness and signedness conversions, but put32_labels assumes that
15the value is normalized to 32bit int and it shifts down to the dest
16format. In addition, the current code lacks get_labels entries for
17the 24bit formats, as Shengjiu Wang spotted out.
18
19For fixing these bugs, this patch replaces the read with
20get32_labels and use always 64bit int for sum. This simplifies the
21code a lot and drops many lines.
22
23Commit fd84adc63e307572d05274be44c782a787087cda in master branch
24
25Upstream Status: Backported
26
27Signed-off-by: Takashi Iwai <tiwai@suse.de>
28---
29 src/pcm/pcm_route.c | 128 +++++++++-----------------------------------------
30 src/pcm/plugin_ops.h | 81 --------------------------------
31 2 files changed, 23 insertions(+), 186 deletions(-)
32
33diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c
34index 2beedf6..1ed9c5f 100644
35--- a/src/pcm/pcm_route.c
36+++ b/src/pcm/pcm_route.c
37@@ -60,7 +60,7 @@ typedef struct {
38 typedef struct snd_pcm_route_ttable_dst snd_pcm_route_ttable_dst_t;
39
40 typedef struct {
41- enum {UINT32=0, UINT64=1, FLOAT=2} sum_idx;
42+ enum {UINT64, FLOAT} sum_idx;
43 unsigned int get_idx;
44 unsigned int put_idx;
45 unsigned int conv_idx;
46@@ -232,55 +232,34 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
47 const snd_pcm_route_ttable_dst_t* ttable,
48 const snd_pcm_route_params_t *params)
49 {
50-#define GETS_LABELS
51+#define GET32_LABELS
52 #define PUT32_LABELS
53 #include "plugin_ops.h"
54-#undef GETS_LABELS
55+#undef GET32_LABELS
56 #undef PUT32_LABELS
57- static void *const zero_labels[3] = {
58- &&zero_int32, &&zero_int64,
59+ static void *const zero_labels[2] = {
60+ &&zero_int64,
61 #if SND_PCM_PLUGIN_ROUTE_FLOAT
62 &&zero_float
63 #endif
64 };
65 /* sum_type att */
66- static void *const add_labels[3 * 2] = {
67- &&add_int32_noatt, &&add_int32_att,
68+ static void *const add_labels[2 * 2] = {
69 &&add_int64_noatt, &&add_int64_att,
70 #if SND_PCM_PLUGIN_ROUTE_FLOAT
71 &&add_float_noatt, &&add_float_att
72 #endif
73 };
74- /* sum_type att shift */
75- static void *const norm_labels[3 * 2 * 4] = {
76- 0,
77- &&norm_int32_8_noatt,
78- &&norm_int32_16_noatt,
79- &&norm_int32_24_noatt,
80- 0,
81- &&norm_int32_8_att,
82- &&norm_int32_16_att,
83- &&norm_int32_24_att,
84- &&norm_int64_0_noatt,
85- &&norm_int64_8_noatt,
86- &&norm_int64_16_noatt,
87- &&norm_int64_24_noatt,
88- &&norm_int64_0_att,
89- &&norm_int64_8_att,
90- &&norm_int64_16_att,
91- &&norm_int64_24_att,
92+ /* sum_type att */
93+ static void *const norm_labels[2 * 2] = {
94+ &&norm_int64_noatt,
95+ &&norm_int64_att,
96 #if SND_PCM_PLUGIN_ROUTE_FLOAT
97- &&norm_float_0,
98- &&norm_float_8,
99- &&norm_float_16,
100- &&norm_float_24,
101- &&norm_float_0,
102- &&norm_float_8,
103- &&norm_float_16,
104- &&norm_float_24,
105+ &&norm_float,
106+ &&norm_float,
107 #endif
108 };
109- void *zero, *get, *add, *norm, *put32;
110+ void *zero, *get32, *add, *norm, *put32;
111 int nsrcs = ttable->nsrcs;
112 char *dst;
113 int dst_step;
114@@ -322,9 +301,9 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
115 }
116
117 zero = zero_labels[params->sum_idx];
118- get = gets_labels[params->get_idx];
119+ get32 = get32_labels[params->get_idx];
120 add = add_labels[params->sum_idx * 2 + ttable->att];
121- norm = norm_labels[params->sum_idx * 8 + ttable->att * 4 + 4 - params->src_size];
122+ norm = norm_labels[params->sum_idx * 2 + ttable->att];
123 put32 = put32_labels[params->put_idx];
124 dst = snd_pcm_channel_area_addr(dst_area, dst_offset);
125 dst_step = snd_pcm_channel_area_step(dst_area);
126@@ -335,9 +314,6 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
127
128 /* Zero sum */
129 goto *zero;
130- zero_int32:
131- sum.as_sint32 = 0;
132- goto zero_end;
133 zero_int64:
134 sum.as_sint64 = 0;
135 goto zero_end;
136@@ -351,21 +327,14 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
137 const char *src = srcs[srcidx];
138
139 /* Get sample */
140- goto *get;
141-#define GETS_END after_get
142+ goto *get32;
143+#define GET32_END after_get
144 #include "plugin_ops.h"
145-#undef GETS_END
146+#undef GET32_END
147 after_get:
148
149 /* Sum */
150 goto *add;
151- add_int32_att:
152- sum.as_sint32 += sample * ttp->as_int;
153- goto after_sum;
154- add_int32_noatt:
155- if (ttp->as_int)
156- sum.as_sint32 += sample;
157- goto after_sum;
158 add_int64_att:
159 sum.as_sint64 += (int64_t) sample * ttp->as_int;
160 goto after_sum;
161@@ -389,48 +358,10 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
162
163 /* Normalization */
164 goto *norm;
165- norm_int32_8_att:
166- sum.as_sint64 = sum.as_sint32;
167- norm_int64_8_att:
168- sum.as_sint64 <<= 8;
169- norm_int64_0_att:
170- div(sum.as_sint64);
171- goto norm_int;
172-
173- norm_int32_16_att:
174- sum.as_sint64 = sum.as_sint32;
175- norm_int64_16_att:
176- sum.as_sint64 <<= 16;
177+ norm_int64_att:
178 div(sum.as_sint64);
179- goto norm_int;
180-
181- norm_int32_24_att:
182- sum.as_sint64 = sum.as_sint32;
183- norm_int64_24_att:
184- sum.as_sint64 <<= 24;
185- div(sum.as_sint64);
186- goto norm_int;
187-
188- norm_int32_8_noatt:
189- sum.as_sint64 = sum.as_sint32;
190- norm_int64_8_noatt:
191- sum.as_sint64 <<= 8;
192- goto norm_int;
193-
194- norm_int32_16_noatt:
195- sum.as_sint64 = sum.as_sint32;
196- norm_int64_16_noatt:
197- sum.as_sint64 <<= 16;
198- goto norm_int;
199-
200- norm_int32_24_noatt:
201- sum.as_sint64 = sum.as_sint32;
202- norm_int64_24_noatt:
203- sum.as_sint64 <<= 24;
204- goto norm_int;
205-
206- norm_int64_0_noatt:
207- norm_int:
208+ /* fallthru */
209+ norm_int64_noatt:
210 if (sum.as_sint64 > (int64_t)0x7fffffff)
211 sample = 0x7fffffff; /* maximum positive value */
212 else if (sum.as_sint64 < -(int64_t)0x80000000)
213@@ -440,16 +371,6 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
214 goto after_norm;
215
216 #if SND_PCM_PLUGIN_ROUTE_FLOAT
217- norm_float_8:
218- sum.as_float *= 1 << 8;
219- goto norm_float;
220- norm_float_16:
221- sum.as_float *= 1 << 16;
222- goto norm_float;
223- norm_float_24:
224- sum.as_float *= 1 << 24;
225- goto norm_float;
226- norm_float_0:
227 norm_float:
228 sum.as_float = rint(sum.as_float);
229 if (sum.as_float > (int64_t)0x7fffffff)
230@@ -644,7 +565,7 @@ static int snd_pcm_route_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
231 return err;
232 route->params.use_getput = snd_pcm_format_physical_width(src_format) == 24 ||
233 snd_pcm_format_physical_width(dst_format) == 24;
234- route->params.get_idx = snd_pcm_linear_get_index(src_format, SND_PCM_FORMAT_S16);
235+ route->params.get_idx = snd_pcm_linear_get32_index(src_format, SND_PCM_FORMAT_S32);
236 route->params.put_idx = snd_pcm_linear_put32_index(SND_PCM_FORMAT_S32, dst_format);
237 route->params.conv_idx = snd_pcm_linear_convert_index(src_format, dst_format);
238 route->params.src_size = snd_pcm_format_width(src_format) / 8;
239@@ -652,10 +573,7 @@ static int snd_pcm_route_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
240 #if SND_PCM_PLUGIN_ROUTE_FLOAT
241 route->params.sum_idx = FLOAT;
242 #else
243- if (snd_pcm_format_width(src_format) == 32)
244- route->params.sum_idx = UINT64;
245- else
246- route->params.sum_idx = UINT32;
247+ route->params.sum_idx = UINT64;
248 #endif
249 return 0;
250 }
251diff --git a/src/pcm/plugin_ops.h b/src/pcm/plugin_ops.h
252index 21535c9..eb8c2c4 100644
253--- a/src/pcm/plugin_ops.h
254+++ b/src/pcm/plugin_ops.h
255@@ -668,87 +668,6 @@ getu_1234_C321: sample = bswap_32(as_u32c(src) ^ 0x80); goto GETU_END;
256 }
257 #endif
258
259-#ifdef GETS_LABELS
260-/* width endswap sign_toggle */
261-static void *const gets_labels[4 * 2 * 2] = {
262- &&gets_1_1, /* 8h -> 8h */
263- &&gets_1_9, /* 8h ^> 8h */
264- &&gets_1_1, /* 8s -> 8h */
265- &&gets_1_9, /* 8s ^> 8h */
266- &&gets_12_12, /* 16h -> 16h */
267- &&gets_12_92, /* 16h ^> 16h */
268- &&gets_12_21, /* 16s -> 16h */
269- &&gets_12_A1, /* 16s ^> 16h */
270- &&gets_0123_0123, /* 24h -> 24h */
271- &&gets_0123_0923, /* 24h ^> 24h */
272- &&gets_1230_0321, /* 24s -> 24h */
273- &&gets_1230_0B21, /* 24s ^> 24h */
274- &&gets_1234_1234, /* 32h -> 32h */
275- &&gets_1234_9234, /* 32h ^> 32h */
276- &&gets_1234_4321, /* 32s -> 32h */
277- &&gets_1234_C321, /* 32s ^> 32h */
278-};
279-#endif
280-
281-#ifdef GETS_END
282-while (0) {
283-gets_1_1: sample = as_s8c(src); goto GETS_END;
284-gets_1_9: sample = (int8_t)(as_s8c(src) ^ 0x80); goto GETS_END;
285-gets_12_12: sample = as_s16c(src); goto GETS_END;
286-gets_12_92: sample = (int16_t)(as_s16c(src) ^ 0x8000); goto GETS_END;
287-gets_12_21: sample = (int16_t)bswap_16(as_s16c(src)); goto GETS_END;
288-gets_12_A1: sample = (int16_t)bswap_16(as_s16c(src) ^ 0x80); goto GETS_END;
289-gets_0123_0123: sample = sx24((int32_t)(as_s32c(src) << 8) >> 8); goto GETS_END;
290-gets_0123_0923: sample = sx24((int32_t)((as_s32c(src) ^ 0x800000) << 8) >> 8); goto GETS_END;
291-gets_1230_0321: sample = sx24((int32_t)(bswap_32(as_s32c(src)) << 8) >> 8); goto GETS_END;
292-gets_1230_0B21: sample = sx24((int32_t)(bswap_32(as_s32c(src) ^ 0x8000) << 8) >> 8); goto GETS_END;
293-gets_1234_1234: sample = as_s32c(src); goto GETS_END;
294-gets_1234_9234: sample = (int32_t)(as_s32c(src) ^ 0x80000000); goto GETS_END;
295-gets_1234_4321: sample = (int32_t)bswap_32(as_s32c(src)); goto GETS_END;
296-gets_1234_C321: sample = (int32_t)bswap_32(as_s32c(src) ^ 0x80); goto GETS_END;
297-}
298-#endif
299-
300-#ifdef PUT_LABELS
301-/* width endswap sign_toggle */
302-static void *const put_labels[4 * 2 * 2] = {
303- &&put_1_1, /* 8h -> 8h */
304- &&put_1_9, /* 8h ^> 8h */
305- &&put_1_1, /* 8h -> 8s */
306- &&put_1_9, /* 8h ^> 8s */
307- &&put_12_12, /* 16h -> 16h */
308- &&put_12_92, /* 16h ^> 16h */
309- &&put_12_21, /* 16h -> 16s */
310- &&put_12_29, /* 16h ^> 16s */
311- &&put_0123_0123, /* 24h -> 24h */
312- &&put_0123_0923, /* 24h ^> 24h */
313- &&put_0123_3210, /* 24h -> 24s */
314- &&put_0123_3290, /* 24h ^> 24s */
315- &&put_1234_1234, /* 32h -> 32h */
316- &&put_1234_9234, /* 32h ^> 32h */
317- &&put_1234_4321, /* 32h -> 32s */
318- &&put_1234_4329, /* 32h ^> 32s */
319-};
320-#endif
321-
322-#ifdef PUT_END
323-put_1_1: as_s8(dst) = sample; goto PUT_END;
324-put_1_9: as_u8(dst) = sample ^ 0x80; goto PUT_END;
325-put_12_12: as_s16(dst) = sample; goto PUT_END;
326-put_12_92: as_u16(dst) = sample ^ 0x8000; goto PUT_END;
327-put_12_21: as_s16(dst) = bswap_16(sample); goto PUT_END;
328-put_12_29: as_u16(dst) = bswap_16(sample) ^ 0x80; goto PUT_END;
329-/* this always writes the unused byte in 24-bit formats as 0x00 */
330-put_0123_0123: as_s32(dst) = sx24(sample & 0x00ffffff); goto PUT_END;
331-put_0123_0923: as_u32(dst) = sx24((sample & 0x00ffffff) ^ 0x800000); goto PUT_END;
332-put_0123_3210: as_s32(dst) = sx24s(bswap_32(sample) & 0xffffff00); goto PUT_END;
333-put_0123_3290: as_u32(dst) = sx24s((bswap_32(sample) & 0xffffff00) ^ 0x8000); goto PUT_END;
334-put_1234_1234: as_s32(dst) = sample; goto PUT_END;
335-put_1234_9234: as_u32(dst) = sample ^ 0x80000000; goto PUT_END;
336-put_1234_4321: as_s32(dst) = bswap_32(sample); goto PUT_END;
337-put_1234_4329: as_u32(dst) = bswap_32(sample) ^ 0x80; goto PUT_END;
338-#endif
339-
340 #ifdef PUT32F_LABELS
341 /* type (0 = float, 1 = float64), endswap */
342 static void *const put32float_labels[2 * 2] = {
343--
3441.7.9.5
345
diff --git a/meta/recipes-multimedia/alsa/alsa-lib/Check-if-wordexp-function-is-supported.patch b/meta/recipes-multimedia/alsa/alsa-lib/Check-if-wordexp-function-is-supported.patch
new file mode 100644
index 0000000000..75a6eb8a3c
--- /dev/null
+++ b/meta/recipes-multimedia/alsa/alsa-lib/Check-if-wordexp-function-is-supported.patch
@@ -0,0 +1,51 @@
1From e33357b59a10d44e9bec5d24100ce23ca300cc79 Mon Sep 17 00:00:00 2001
2From: "Hong H. Pham" <hong.pham@windriver.com>
3Date: Fri, 29 Aug 2014 17:13:55 +0300
4Subject: [PATCH] Check if wordexp function is supported
5
6eglibc could be configured to build without wordexp, so it is not enough
7to check if wordexp.h exists (the header file could be installed, but it's
8possible that the wordexp() function is not supported). An additional
9check if wordexp() is supported by the system C library is needed.
10
11Upstream-Status: Inappropriate [configuration]
12
13Signed-off-by: Hong H. Pham <hong.pham@windriver.com>
14Signed-off-by: Cristian Iorga <cristian.iorga@intel.com>
15---
16 configure.ac | 5 ++++-
17 src/userfile.c | 2 +-
18 2 files changed, 5 insertions(+), 2 deletions(-)
19
20diff --git a/configure.ac b/configure.ac
21index b8353a0..773b72f 100644
22--- a/configure.ac
23+++ b/configure.ac
24@@ -311,7 +311,10 @@ fi
25 AC_SUBST(ALSA_DEPLIBS)
26
27 dnl Check for headers
28-AC_CHECK_HEADERS([wordexp.h endian.h sys/endian.h])
29+AC_CHECK_HEADERS([wordexp.h endian.h sys/endian.h],
30+ dnl Make sure wordexp is supported by the C library
31+ AC_CHECK_FUNCS([wordexp])
32+)
33
34 dnl Check for resmgr support...
35 AC_MSG_CHECKING(for resmgr support)
36diff --git a/src/userfile.c b/src/userfile.c
37index 3a73836..b8ce809 100644
38--- a/src/userfile.c
39+++ b/src/userfile.c
40@@ -32,7 +32,7 @@
41 * stores the first matchine one. The returned string is strdup'ed.
42 */
43
44-#ifdef HAVE_WORDEXP_H
45+#if (defined(HAVE_WORDEXP_H) && defined(HAVE_WORDEXP))
46 #include <wordexp.h>
47 #include <assert.h>
48 int snd_user_file(const char *file, char **result)
49--
501.9.1
51
diff --git a/meta/recipes-multimedia/alsa/alsa-lib/fix-tstamp-declaration.patch b/meta/recipes-multimedia/alsa/alsa-lib/fix-tstamp-declaration.patch
new file mode 100644
index 0000000000..32b84b7d7e
--- /dev/null
+++ b/meta/recipes-multimedia/alsa/alsa-lib/fix-tstamp-declaration.patch
@@ -0,0 +1,21 @@
1# Author: Michael Lauer <mickey@vanille-media.de>
2# Date: Thu Jan 18 00:27:21 2007 +0000
3# alsa-lib: fix "error: field 'tstamp' has incomplete type" when including alsa headers with strict compilation options
4#
5# Acquired from OpenEmbedded
6
7Upstream-Status: Pending
8
9Index: alsa-lib-1.0.13/include/global.h
10===================================================================
11--- alsa-lib-1.0.13.orig/include/global.h
12+++ alsa-lib-1.0.13/include/global.h
13@@ -29,6 +29,8 @@
14 #define __ALSA_GLOBAL_H_
15
16 /* for timeval and timespec */
17+#define __need_timeval
18+#define __need_timespec
19 #include <time.h>
20
21 #ifdef __cplusplus
diff --git a/meta/recipes-multimedia/alsa/alsa-lib_1.0.28.bb b/meta/recipes-multimedia/alsa/alsa-lib_1.0.28.bb
new file mode 100644
index 0000000000..9a4aab44d4
--- /dev/null
+++ b/meta/recipes-multimedia/alsa/alsa-lib_1.0.28.bb
@@ -0,0 +1,54 @@
1SUMMARY = "ALSA sound library"
2HOMEPAGE = "http://www.alsa-project.org"
3BUGTRACKER = "https://bugtrack.alsa-project.org/alsa-bug/login_page.php"
4SECTION = "libs/multimedia"
5LICENSE = "LGPLv2.1 & GPLv2+"
6LIC_FILES_CHKSUM = "file://COPYING;md5=7fbc338309ac38fefcd64b04bb903e34 \
7 file://src/socket.c;beginline=1;endline=26;md5=11ff89a8a7a4a690a5c78effe8159545"
8
9BBCLASSEXTEND = "native nativesdk"
10
11# configure.in sets -D__arm__ on the command line for any arm system
12# (not just those with the ARM instruction set), this should be removed,
13# (or replaced by a permitted #define).
14#FIXME: remove the following
15ARM_INSTRUCTION_SET = "arm"
16
17SRC_URI = "ftp://ftp.alsa-project.org/pub/lib/${BP}.tar.bz2 \
18 file://Check-if-wordexp-function-is-supported.patch \
19 file://fix-tstamp-declaration.patch \
20 file://0001-pcm-route-Use-get32-for-multi-source-route-calculati.patch \
21 file://0001-pcm-rate-fix-hw_ptr-exceed-the-boundary.patch \
22 file://0001-pcm-pcm_local.h-include-time.h-to-enable-CLOCK_MONOT.patch \
23"
24SRC_URI[md5sum] = "c9e21b88a2b3e6e12ea7ba0f3b271fc3"
25SRC_URI[sha256sum] = "3c074b85dde1b30e78ef4995579765833e5b693fbbd8f834c335e080cb734a6d"
26
27inherit autotools pkgconfig
28
29require alsa-fpu.inc
30EXTRA_OECONF += "${@get_alsa_fpu_setting(bb, d)} "
31
32EXTRA_OECONF = "--disable-python"
33
34EXTRA_OECONF_append_libc-uclibc = " --with-versioned=no "
35
36PACKAGES =+ "alsa-server libasound alsa-conf-base alsa-conf alsa-doc"
37FILES_${PN} += "${libdir}/${BPN}/smixer/*.so"
38FILES_${PN}-dbg += "${libdir}/${BPN}/smixer/.debug"
39FILES_${PN}-dev += "${libdir}/${BPN}/smixer/*.la"
40FILES_libasound = "${libdir}/libasound.so.*"
41FILES_alsa-server = "${bindir}/*"
42FILES_alsa-conf = "${datadir}/alsa/"
43FILES_alsa-conf-base = "\
44${datadir}/alsa/alsa.conf \
45${datadir}/alsa/cards/aliases.conf \
46${datadir}/alsa/pcm/default.conf \
47${datadir}/alsa/pcm/dmix.conf \
48${datadir}/alsa/pcm/dsnoop.conf"
49
50RDEPENDS_libasound = "alsa-conf-base alsa-conf"
51# upgrade path
52RPROVIDES_${PN}-dev = "alsa-dev"
53RREPLACES_${PN}-dev = "alsa-dev"
54RCONFLICTS_${PN}-dev = "alsa-dev"
diff --git a/meta/recipes-multimedia/alsa/alsa-tools/autotools.patch b/meta/recipes-multimedia/alsa/alsa-tools/autotools.patch
new file mode 100644
index 0000000000..5aec84c60d
--- /dev/null
+++ b/meta/recipes-multimedia/alsa/alsa-tools/autotools.patch
@@ -0,0 +1,32 @@
1Add parameters to autoreconf to support cross compile.
2Remove some sub-components which needs further recipe support.
3
4Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
5
6Upstream-Status: Inappropriate [configuration]
7
8diff -ruN alsa-tools-1.0.24.1-orig//ld10k1/gitcompile alsa-tools-1.0.24.1/ld10k1/gitcompile
9--- alsa-tools-1.0.24.1-orig//ld10k1/gitcompile 2011-07-06 11:27:40.227665002 +0800
10+++ alsa-tools-1.0.24.1/ld10k1/gitcompile 2011-07-14 13:26:18.017665004 +0800
11@@ -1,6 +1,6 @@
12 #!/bin/bash
13
14-autoreconf -fi || exit 1
15+autoreconf $ACLOCAL_FLAGS -fi || exit 1
16 export CFLAGS='-O2 -Wall -pipe -g'
17 echo "CFLAGS=$CFLAGS"
18 echo "./configure $@"
19diff -ruN alsa-tools-1.0.24.1-orig//Makefile alsa-tools-1.0.24.1/Makefile
20--- alsa-tools-1.0.24.1-orig//Makefile 2011-07-06 11:27:40.207665000 +0800
21+++ alsa-tools-1.0.24.1/Makefile 2011-07-14 15:08:08.877665009 +0800
22@@ -1,8 +1,8 @@
23 VERSION = 1.0.27
24 TOP = .
25-SUBDIRS = as10k1 envy24control hdsploader hdspconf hdspmixer \
26+SUBDIRS = as10k1 envy24control \
27 mixartloader pcxhrloader rmedigicontrol sb16_csp seq sscape_ctl \
28- us428control usx2yloader vxloader echomixer ld10k1 qlo10k1 \
29+ us428control usx2yloader vxloader echomixer \
30 hwmixvolume hdajackretask hda-verb
31
32 all:
diff --git a/meta/recipes-multimedia/alsa/alsa-tools/makefile_no_gtk.patch b/meta/recipes-multimedia/alsa/alsa-tools/makefile_no_gtk.patch
new file mode 100644
index 0000000000..26657266a8
--- /dev/null
+++ b/meta/recipes-multimedia/alsa/alsa-tools/makefile_no_gtk.patch
@@ -0,0 +1,25 @@
1Remove some sub-components which need gtk+.
2
3Upstream-Status: Inappropriate [configuration]
4
5Signed-off-by: Rogerio Nunes <ronunes@gmail.com>
6Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
7
8diff --git a/Makefile b/Makefile
9index 2457a1c..72346d9 100644
10--- a/Makefile
11+++ b/Makefile
12@@ -1,9 +1,9 @@
13 VERSION = 1.0.27
14 TOP = .
15-SUBDIRS = as10k1 envy24control \
16- mixartloader pcxhrloader rmedigicontrol sb16_csp seq sscape_ctl \
17- us428control usx2yloader vxloader echomixer \
18- hwmixvolume hdajackretask hda-verb
19+SUBDIRS = as10k1 \
20+ mixartloader pcxhrloader sb16_csp seq sscape_ctl \
21+ us428control usx2yloader vxloader \
22+ hwmixvolume hda-verb
23
24 all:
25 @for i in $(SUBDIRS); do \
diff --git a/meta/recipes-multimedia/alsa/alsa-tools_1.0.28.bb b/meta/recipes-multimedia/alsa/alsa-tools_1.0.28.bb
new file mode 100644
index 0000000000..4b9509e863
--- /dev/null
+++ b/meta/recipes-multimedia/alsa/alsa-tools_1.0.28.bb
@@ -0,0 +1,35 @@
1SUMMARY = "Advanced tools for certain ALSA sound card drivers"
2HOMEPAGE = "http://www.alsa-project.org"
3BUGTRACKER = "https://bugtrack.alsa-project.org/alsa-bug/login_page.php"
4SECTION = "console/utils"
5LICENSE = "GPLv2 & LGPLv2+"
6DEPENDS = "alsa-lib ncurses"
7
8LIC_FILES_CHKSUM = "file://hdsploader/COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
9 file://ld10k1/COPYING.LIB;md5=7fbc338309ac38fefcd64b04bb903e34"
10
11SRC_URI = "ftp://ftp.alsa-project.org/pub/tools/${BP}.tar.bz2 \
12 file://autotools.patch \
13 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', '', \
14 'file://makefile_no_gtk.patch', d)}"
15
16SRC_URI[md5sum] = "e6c929175d8ee729c06d49b51439bad6"
17SRC_URI[sha256sum] = "76e59711c6d0f39cbddce83ce1ed8da00bad112fee021f94fa990d8685cc3761"
18
19inherit autotools-brokensep pkgconfig
20
21EXTRA_OEMAKE += "GITCOMPILE_ARGS='--host=${HOST_SYS} --build=${BUILD_SYS} --target=${TARGET_SYS} --with-libtool-sysroot=${STAGING_DIR_HOST} --prefix=${prefix}'"
22
23PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'gtk+', '', d)}"
24PACKAGECONFIG[gtk+] = ",,gtk+ gtk+3,"
25
26# configure.ac/.in doesn't exist so force copy
27AUTOTOOLS_COPYACLOCAL = "1"
28
29do_compile_prepend () {
30 #Automake dir is not correctly detected in cross compilation case
31 export AUTOMAKE_DIR="$(automake --print-libdir)"
32 export ACLOCAL_FLAGS="--system-acdir=${ACLOCALDIR}/"
33}
34
35FILES_${PN} += "${datadir}/ld10k1"
diff --git a/meta/recipes-multimedia/alsa/alsa-utils-alsaconf_1.0.28.bb b/meta/recipes-multimedia/alsa/alsa-utils-alsaconf_1.0.28.bb
new file mode 100644
index 0000000000..968c81ee2b
--- /dev/null
+++ b/meta/recipes-multimedia/alsa/alsa-utils-alsaconf_1.0.28.bb
@@ -0,0 +1,17 @@
1require alsa-utils_${PV}.bb
2
3SUMMARY = "Shell script that creates ALSA configuration files"
4
5FILESEXTRAPATHS_prepend := "${THISDIR}/alsa-utils:"
6
7PACKAGES = "${PN}"
8RDEPENDS_${PN} += "bash"
9
10FILES_${PN} = "${sbindir}/alsaconf"
11
12S = "${WORKDIR}/alsa-utils-${PV}"
13
14do_install() {
15 install -d ${D}${sbindir}
16 install -m 0755 ${S}/alsaconf/alsaconf ${D}${sbindir}/
17}
diff --git a/meta/recipes-multimedia/alsa/alsa-utils/0001-alsactl-don-t-let-systemd-unit-restore-the-volume-wh.patch b/meta/recipes-multimedia/alsa/alsa-utils/0001-alsactl-don-t-let-systemd-unit-restore-the-volume-wh.patch
new file mode 100644
index 0000000000..e99dd515f0
--- /dev/null
+++ b/meta/recipes-multimedia/alsa/alsa-utils/0001-alsactl-don-t-let-systemd-unit-restore-the-volume-wh.patch
@@ -0,0 +1,52 @@
1From 43a56fa36a12f09ccd78b3cf5e6ae197fcab501f Mon Sep 17 00:00:00 2001
2From: Koen Kooi <koen@dominion.thruhere.net>
3Date: Fri, 29 Aug 2014 18:58:56 +0300
4Subject: [PATCH] alsactl: don't let systemd unit restore the volume when
5 asound.state is missing
6
7This avoids an error on bootup
8
9Filed as https://bugtrack.alsa-project.org/alsa-bug/view.php?id=5459
10
11Upstream-Status: Pending
12
13Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
14Signed-off-by: Cristian Iorga <cristian.iorga@intel.com>
15---
16 alsactl/Makefile.am | 7 ++++---
17 alsactl/alsa-restore.service.in | 1 +
18 2 files changed, 5 insertions(+), 3 deletions(-)
19
20diff --git a/alsactl/Makefile.am b/alsactl/Makefile.am
21index 47f06e9..b728c06 100644
22--- a/alsactl/Makefile.am
23+++ b/alsactl/Makefile.am
24@@ -43,9 +43,10 @@ install-data-hook:
25 endif
26
27 edit = \
28- $(SED) -r -e 's,@sbindir\@,$(sbindir),g' \
29- -e 's,@mydatadir\@,$(mydatadir),g' \
30- -e 's,@daemonswitch\@,$(ALSACTL_DAEMONSWITCH),g' \
31+ $(SED) -e 's,@localstatedir\@,$(localstatedir),g' \
32+ -e 's,@sbindir\@,$(sbindir),g' \
33+ -e 's,@mydatadir\@,$(mydatadir),g' \
34+ -e 's,@daemonswitch\@,$(ALSACTL_DAEMONSWITCH),g' \
35 < $< > $@ || rm $@
36
37 alsa-state.service: alsa-state.service.in
38diff --git a/alsactl/alsa-restore.service.in b/alsactl/alsa-restore.service.in
39index 245a439..b017854 100644
40--- a/alsactl/alsa-restore.service.in
41+++ b/alsactl/alsa-restore.service.in
42@@ -10,6 +10,7 @@ DefaultDependencies=no
43 After=alsa-state.service
44 Before=shutdown.target
45 Conflicts=shutdown.target
46+ConditionPathExists=@localstatedir@/lib/alsa/asound.state
47
48 [Service]
49 Type=oneshot
50--
511.9.1
52
diff --git a/meta/recipes-multimedia/alsa/alsa-utils/alsa-utils-aplay-interrupt-signal-handling.patch b/meta/recipes-multimedia/alsa/alsa-utils/alsa-utils-aplay-interrupt-signal-handling.patch
new file mode 100644
index 0000000000..5df004aeae
--- /dev/null
+++ b/meta/recipes-multimedia/alsa/alsa-utils/alsa-utils-aplay-interrupt-signal-handling.patch
@@ -0,0 +1,48 @@
1Upstream-Status: Pending
2
3aplay/arecord (alsa-utils v1.0.28) cannot interrupt streaming
4via CTRL-C. Fixed the issue by reverting buggy patches and
5properly handling 'in_aborting' flag in appropriate functions.
6
7Signed-off-by: Anant Agrawal <Anant_Agrawal@mentor.com>
8Signed-off-by: Mikhail Durnev <mikhail_durnev@mentor.com>
9
10--- a/aplay/aplay.c 2014-05-19 16:25:14.000000000 +0530
11+++ b/aplay/aplay.c 2014-05-20 15:17:14.364823007 +0530
12@@ -392,14 +392,22 @@
13 putchar('\n');
14 if (!quiet_mode)
15 fprintf(stderr, _("Aborted by signal %s...\n"), strsignal(sig));
16- if (handle)
17+ if (stream == SND_PCM_STREAM_CAPTURE) {
18+ if (fmt_rec_table[file_type].end) {
19+ fmt_rec_table[file_type].end(fd);
20+ fd = -1;
21+ }
22+ stream = -1;
23+ }
24+ if (fd > 1) {
25+ close(fd);
26+ fd = -1;
27+ }
28+ if (handle && sig != SIGABRT) {
29 snd_pcm_abort(handle);
30- if (sig == SIGABRT) {
31- /* do not call snd_pcm_close() and abort immediately */
32 handle = NULL;
33- prg_exit(EXIT_FAILURE);
34 }
35- signal(sig, signal_handler);
36+ prg_exit(EXIT_FAILURE);
37 }
38
39 /* call on SIGUSR1 signal. */
40@@ -2096,7 +2104,7 @@
41 ssize_t result = count, r;
42 size_t size;
43
44- while (count > 0) {
45+ while (count > 0 && !in_aborting) {
46 size = count;
47 if (size > chunk_bytes - buffer_pos)
48 size = chunk_bytes - buffer_pos;
diff --git a/meta/recipes-multimedia/alsa/alsa-utils_1.0.28.bb b/meta/recipes-multimedia/alsa/alsa-utils_1.0.28.bb
new file mode 100644
index 0000000000..5f35d76a6e
--- /dev/null
+++ b/meta/recipes-multimedia/alsa/alsa-utils_1.0.28.bb
@@ -0,0 +1,95 @@
1SUMMARY = "ALSA sound utilities"
2HOMEPAGE = "http://www.alsa-project.org"
3BUGTRACKER = "https://bugtrack.alsa-project.org/alsa-bug/login_page.php"
4SECTION = "console/utils"
5LICENSE = "GPLv2+"
6LIC_FILES_CHKSUM = "file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552 \
7 file://alsactl/utils.c;beginline=1;endline=20;md5=fe9526b055e246b5558809a5ae25c0b9"
8DEPENDS = "alsa-lib ncurses libsamplerate0 udev"
9
10PACKAGECONFIG ??= "udev"
11PACKAGECONFIG[udev] = "--with-udev-rules-dir=`pkg-config --variable=udevdir udev`/rules.d,,udev"
12PACKAGECONFIG[xmlto] = "--enable-xmlto, --disable-xmlto, xmlto-native docbook-xml-dtd4-native docbook-xsl-stylesheets-native"
13
14SRC_URI = "ftp://ftp.alsa-project.org/pub/utils/alsa-utils-${PV}.tar.bz2 \
15 file://0001-alsactl-don-t-let-systemd-unit-restore-the-volume-wh.patch \
16 file://alsa-utils-aplay-interrupt-signal-handling.patch \
17 "
18
19SRC_URI[md5sum] = "361552d5b1cacd0a1e7ba09e69990211"
20SRC_URI[sha256sum] = "f3ff4c89b0125a7797b1b13cd094cc92276e655458274967386e812d03642acc"
21
22# lazy hack. needs proper fixing in gettext.m4, see
23# http://bugs.openembedded.org/show_bug.cgi?id=2348
24# please close bug and remove this comment when properly fixed
25#
26EXTRA_OECONF_append_libc-uclibc = " --disable-nls"
27
28inherit autotools-brokensep gettext pkgconfig
29
30# This are all packages that we need to make. Also, the now empty alsa-utils
31# ipk depends on them.
32
33ALSA_UTILS_PKGS = "\
34 alsa-utils-alsamixer \
35 alsa-utils-midi \
36 alsa-utils-aplay \
37 alsa-utils-amixer \
38 alsa-utils-aconnect \
39 alsa-utils-iecset \
40 alsa-utils-speakertest \
41 alsa-utils-aseqnet \
42 alsa-utils-aseqdump \
43 alsa-utils-alsactl \
44 alsa-utils-alsaloop \
45 alsa-utils-alsaucm \
46 "
47
48PACKAGES += "${ALSA_UTILS_PKGS}"
49RDEPENDS_${PN} += "${ALSA_UTILS_PKGS}"
50
51FILES_${PN} = ""
52FILES_alsa-utils-aplay = "${bindir}/aplay ${bindir}/arecord"
53FILES_alsa-utils-amixer = "${bindir}/amixer"
54FILES_alsa-utils-alsamixer = "${bindir}/alsamixer"
55FILES_alsa-utils-speakertest = "${bindir}/speaker-test ${datadir}/sounds/alsa/ ${datadir}/alsa/speaker-test/"
56FILES_alsa-utils-midi = "${bindir}/aplaymidi ${bindir}/arecordmidi ${bindir}/amidi"
57FILES_alsa-utils-aconnect = "${bindir}/aconnect"
58FILES_alsa-utils-aseqnet = "${bindir}/aseqnet"
59FILES_alsa-utils-iecset = "${bindir}/iecset"
60FILES_alsa-utils-alsactl = "${sbindir}/alsactl */udev/rules.d ${systemd_unitdir} ${localstatedir}/lib/alsa ${datadir}/alsa/init/"
61FILES_alsa-utils-aseqdump = "${bindir}/aseqdump"
62FILES_alsa-utils-alsaloop = "${bindir}/alsaloop"
63FILES_alsa-utils-alsaucm = "${bindir}/alsaucm"
64
65
66SUMMARY_alsa-utils-aplay = "Play (and record) sound files using ALSA"
67SUMMARY_alsa-utils-amixer = "Command-line control for ALSA mixer and settings"
68SUMMARY_alsa-utils-alsamixer = "ncurses-based control for ALSA mixer and settings"
69SUMMARY_alsa-utils-speakertest = "ALSA surround speaker test utility"
70SUMMARY_alsa-utils-midi = "Miscellaneous MIDI utilities for ALSA"
71SUMMARY_alsa-utils-aconnect = "ALSA sequencer connection manager"
72SUMMARY_alsa-utils-aseqnet = "Network client/server for ALSA sequencer"
73SUMMARY_alsa-utils-iecset = "ALSA utility for setting/showing IEC958 (S/PDIF) status bits"
74SUMMARY_alsa-utils-alsactl = "Saves/restores ALSA-settings in /etc/asound.state"
75SUMMARY_alsa-utils-aseqdump = "Shows the events received at an ALSA sequencer port"
76SUMMARY_alsa-utils-alsaloop = "ALSA PCM loopback utility"
77SUMMARY_alsa-utils-alsaucm = "ALSA Use Case Manager"
78
79RRECOMMENDS_alsa-utils-alsactl = "alsa-states"
80
81ALLOW_EMPTY_alsa-utils = "1"
82
83do_install() {
84 autotools_do_install
85
86 # We don't ship this here because it requires a dependency on bash.
87 # See alsa-utils-alsaconf_${PV}.bb
88 rm ${D}${sbindir}/alsaconf
89
90 if ${@bb.utils.contains('PACKAGECONFIG', 'udev', 'false', 'true', d)}; then
91 # This is where alsa-utils will install its rules if we don't tell it anything else.
92 rm -rf ${D}/lib/udev
93 rmdir --ignore-fail-on-non-empty ${D}/lib
94 fi
95}
diff --git a/meta/recipes-multimedia/flac/flac-1.3.0/0001-Fix-Makefile.am-altivec-logic.patch b/meta/recipes-multimedia/flac/flac-1.3.0/0001-Fix-Makefile.am-altivec-logic.patch
new file mode 100644
index 0000000000..d086cc910f
--- /dev/null
+++ b/meta/recipes-multimedia/flac/flac-1.3.0/0001-Fix-Makefile.am-altivec-logic.patch
@@ -0,0 +1,35 @@
1From 1b3597cdc7b5e604ea37db29b2a65aab91e263e6 Mon Sep 17 00:00:00 2001
2From: Gustavo Zacarias <gustavo@zacarias.com.ar>
3Date: Wed, 4 Dec 2013 13:31:28 -0300
4Subject: [PATCH] Fix Makefile.am altivec logic
5
6Upstream-Status: Backport
7
8Besides SPE (FSL e500v? cores) there are other powerpc processors
9that don't support altivec instructions so only enable them when it's
10100% sure that the target has it.
11
12Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
13Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
14Signed-off-by: Cristian Iorga <cristian.iorga@intel.com>
15---
16 src/libFLAC/Makefile.am | 3 +--
17 1 file changed, 1 insertion(+), 2 deletions(-)
18
19diff --git a/src/libFLAC/Makefile.am b/src/libFLAC/Makefile.am
20index 247e33c..258de40 100644
21--- a/src/libFLAC/Makefile.am
22+++ b/src/libFLAC/Makefile.am
23@@ -47,8 +47,7 @@ CPUCFLAGS = -faltivec -force_cpusubtype_ALL -DFLAC__NO_ASM
24 else
25 # Linux-gcc for PPC does not have -force_cpusubtype_ALL, it is Darwin-specific
26 CPUCFLAGS =
27-if FLaC__CPU_PPC_SPE
28-else
29+if FLaC__USE_ALTIVEC
30 CPUCFLAGS += -maltivec -mabi=altivec
31 endif
32 #@@@ PPC optimizations temporarily disabled
33--
341.8.3.2
35
diff --git a/meta/recipes-multimedia/flac/flac_1.3.0.bb b/meta/recipes-multimedia/flac/flac_1.3.0.bb
new file mode 100644
index 0000000000..fdf38e9ea9
--- /dev/null
+++ b/meta/recipes-multimedia/flac/flac_1.3.0.bb
@@ -0,0 +1,44 @@
1SUMMARY = "Free Lossless Audio Codec"
2DESCRIPTION = "FLAC stands for Free Lossless Audio Codec, a lossless audio compression format."
3HOMEPAGE = "https://xiph.org/flac/"
4BUGTRACKER = "http://sourceforge.net/p/flac/bugs/"
5SECTION = "libs"
6LICENSE = "GFDL-1.2 & GPLv2+ & LGPLv2.1+ & BSD"
7LIC_FILES_CHKSUM = "file://COPYING.FDL;md5=ad1419ecc56e060eccf8184a87c4285f \
8 file://src/Makefile.am;beginline=1;endline=17;md5=59575c1aa8f5f70d9361b776c2e2bdb5 \
9 file://COPYING.GPL;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
10 file://src/flac/main.c;beginline=1;endline=18;md5=d36a16abc38d5ffd346ac4ba1be1932b \
11 file://COPYING.LGPL;md5=fbc093901857fcd118f065f900982c24 \
12 file://src/plugin_common/all.h;beginline=1;endline=18;md5=e33e281151e7f40db2d3d170d9b0c1bb \
13 file://COPYING.Xiph;md5=755582d124a03e3001afea59fc02b61b \
14 file://include/FLAC/all.h;beginline=65;endline=70;md5=64474f2b22e9e77b28d8b8b25c983a48"
15DEPENDS = "libogg"
16
17SRC_URI = "http://downloads.xiph.org/releases/flac/${BP}.tar.xz \
18 file://0001-Fix-Makefile.am-altivec-logic.patch \
19 "
20
21SRC_URI[md5sum] = "13b5c214cee8373464d3d65dee362cdd"
22SRC_URI[sha256sum] = "fa2d64aac1f77e31dfbb270aeb08f5b32e27036a52ad15e69a77e309528010dc"
23
24inherit autotools-brokensep gettext
25
26EXTRA_OECONF = "--disable-oggtest \
27 --with-ogg-libraries=${STAGING_LIBDIR} \
28 --with-ogg-includes=${STAGING_INCDIR} \
29 --disable-xmms-plugin \
30 --without-libiconv-prefix \
31 ac_cv_prog_NASM="" \
32 "
33
34EXTRA_OECONF += "${@bb.utils.contains("TUNE_FEATURES", "altivec", " --enable-altivec", " --disable-altivec", d)}"
35EXTRA_OECONF += "${@bb.utils.contains("TUNE_FEATURES", "core2", " --enable-sse", "", d)}"
36EXTRA_OECONF += "${@bb.utils.contains("TUNE_FEATURES", "corei7", " --enable-sse", "", d)}"
37
38PACKAGES += "libflac libflac++ liboggflac liboggflac++"
39FILES_${PN} = "${bindir}/*"
40FILES_libflac = "${libdir}/libFLAC.so.*"
41FILES_libflac++ = "${libdir}/libFLAC++.so.*"
42FILES_liboggflac = "${libdir}/libOggFLAC.so.*"
43FILES_liboggflac++ = "${libdir}/libOggFLAC++.so.*"
44
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
new file mode 100644
index 0000000000..7da0e14525
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-aacdec-check-channel-count.patch
@@ -0,0 +1,34 @@
1gst-ffmpeg: aacdec: check channel count
2
3Prevent out of array accesses
4
5Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
6Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
7(cherry picked from commit 96f452ac647dae33c53c242ef3266b65a9beafb6)
8
9Upstream-Status: Backport
10
11Signed-off-by: Yue Tao <yue.tao@windriver.com>
12---
13 libavcodec/aacdec.c | 5 +++++
14 1 files changed, 5 insertions(+), 0 deletions(-)
15
16diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
17index 239153a..6c17c33 100644
18--- a/gst-libs/ext/libav/libavcodec/aacdec.c
19+++ b/gst-libs/ext/libav/libavcodec/aacdec.c
20@@ -914,6 +914,11 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
21 }
22 }
23
24+ if (avctx->channels > MAX_CHANNELS) {
25+ av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
26+ return AVERROR_INVALIDDATA;
27+ }
28+
29 AAC_INIT_VLC_STATIC( 0, 304);
30 AAC_INIT_VLC_STATIC( 1, 270);
31 AAC_INIT_VLC_STATIC( 2, 550);
32--
331.7.5.4
34
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
new file mode 100644
index 0000000000..10ce0f332c
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alac-fix-nb_samples-order-case.patch
@@ -0,0 +1,30 @@
1From e0884eadf6a15e93142131b695f48776f9a0ac31 Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Sat, 10 Nov 2012 17:14:04 +0100
4Subject: [PATCH] alac: fix nb_samples < order case
5
6Upstream-Status: Backport
7
8Commit e0884eadf6a15e93142131b695f48776f9a0ac31 release/1.0
9
10Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
11Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12(cherry picked from commit fd4f4923cce6a2cbf4f48640b4ac706e614a1594)
13---
14 libavcodec/alac.c | 2 +-
15 1 file changed, 1 insertion(+), 1 deletion(-)
16
17diff --git a/libavcodec/alac.c b/libavcodec/alac.c
18index 9cd1737..e8e844a 100644
19--- a/gst-libs/ext/libav/libavcodec/alac.c
20+++ b/gst-libs/ext/libav/libavcodec/alac.c
21@@ -278,7 +278,7 @@ static void predictor_decompress_fir_ada
22
23 /* read warm-up samples */
24 if (predictor_coef_num > 0)
25- for (i = 0; i < predictor_coef_num; i++) {
26+ for (i = 0; i < predictor_coef_num && i < output_size; i++) {
27 int32_t val;
28
29 val = buffer_out[i] + error_buffer[i+1];
30--
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
new file mode 100644
index 0000000000..73980f4265
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-alsdec-check-block-length.patch
@@ -0,0 +1,61 @@
1From 6df0d3e2916c223dbe4262bf1b876dff1cb3f980 Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Wed, 12 Dec 2012 12:28:45 +0100
4Subject: [PATCH] alsdec: check block length
5
6Upstream-Status: Backport
7
8Commit 6df0d3e2916c223dbe4262bf1b876dff1cb3f980 release/1.0
9
10Fix writing over the end
11
12Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
13Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
14(cherry picked from commit 0ceca269b66ec12a23bf0907bd2c220513cdbf16)
15
16Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
17---
18 libavcodec/alsdec.c | 10 ++++++++--
19 1 file changed, 8 insertions(+), 2 deletions(-)
20
21diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
22index 46dd0b4..1095b01 100644
23--- a/gst-libs/ext/libav/libavcodec/alsdec.c
24+++ b/gst-libs/ext/libav/libavcodec/alsdec.c
25@@ -552,12 +552,15 @@ static void get_block_sizes(ALSDecContext *ctx, unsigned int *div_blocks,
26
27 /** Read the block data for a constant block
28 */
29-static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
30+static int read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
31 {
32 ALSSpecificConfig *sconf = &ctx->sconf;
33 AVCodecContext *avctx = ctx->avctx;
34 GetBitContext *gb = &ctx->gb;
35
36+ if (bd->block_length <= 0)
37+ return -1;
38+
39 *bd->raw_samples = 0;
40 *bd->const_block = get_bits1(gb); // 1 = constant value, 0 = zero block (silence)
41 bd->js_blocks = get_bits1(gb);
42@@ -572,6 +575,8 @@ static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
43
44 // ensure constant block decoding by reusing this field
45 *bd->const_block = 1;
46+
47+ return 0;
48 }
49
50
51@@ -971,7 +976,8 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
52 if (read_var_block_data(ctx, bd))
53 return -1;
54 } else {
55- read_const_block_data(ctx, bd);
56+ if (read_const_block_data(ctx, bd) < 0)
57+ return -1;
58 }
59
60 return 0;
61--
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
new file mode 100644
index 0000000000..42cb5f40b4
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-atrac3dec-Check-coding-mode-against-channels.patch
@@ -0,0 +1,37 @@
1From 2502914c5f8eb77659d7c0868396862557a63245 Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Fri, 9 Nov 2012 13:26:20 +0100
4Subject: [PATCH] atrac3dec: Check coding mode against channels.
5
6Upstream-Status: Backport
7
8Commit 2502914c5f8eb77659d7c0868396862557a63245 release/1.0
9
10Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
11Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12(cherry picked from commit 13451f5520ce6b0afde861b2285dda659f8d4fb4)
13
14Conflicts:
15
16 libavcodec/atrac3.c
17---
18 libavcodec/atrac3.c | 5 +++++
19 1 file changed, 5 insertions(+)
20
21diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
22index 7d076be..1da4c78 100644
23--- a/gst-libs/ext/libav/libavcodec/atrac3.c
24+++ b/gst-libs/ext/libav/libavcodec/atrac3.c
25@@ -955,6 +955,11 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
26 }
27 /* Check the extradata. */
28
29+ if (q->codingMode == JOINT_STEREO && avctx->channels < 2) {
30+ av_log(avctx, AV_LOG_ERROR, "Invalid coding mode\n");
31+ return AVERROR_INVALIDDATA;
32+ }
33+
34 if (q->atrac3version != 4) {
35 av_log(avctx,AV_LOG_ERROR,"Version %d != 4.\n",q->atrac3version);
36 return AVERROR_INVALIDDATA;
37--
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
new file mode 100644
index 0000000000..31fa51a3ea
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch
@@ -0,0 +1,40 @@
1From a99aff4e4bbef8e64b51f267cd1769214e1b4e80 Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Fri, 30 Aug 2013 23:40:47 +0200
4Subject: [PATCH] avcodec/dsputil: fix signedness in sizeof() comparissions
5
6Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
7(cherry picked from commit 454a11a1c9c686c78aa97954306fb63453299760)
8
9Upstream-Status: Backport
10
11Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12---
13 libavcodec/dsputil.c | 4 ++--
14 1 files changed, 2 insertions(+), 2 deletions(-)
15
16diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
17index 53dc2eb..6264832 100644
18--- a/gst-libs/ext/libav/libavcodec/dsputil.c
19+++ b/gst-libs/ext/libav/libavcodec/dsputil.c
20@@ -1912,7 +1912,7 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
21
22 static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
23 long i;
24- for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
25+ for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
26 long a = *(long*)(src+i);
27 long b = *(long*)(dst+i);
28 *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
29@@ -1937,7 +1937,7 @@ static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
30 }
31 }else
32 #endif
33- for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
34+ for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){
35 long a = *(long*)(src1+i);
36 long b = *(long*)(src2+i);
37 *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
38--
391.7.5.4
40
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
new file mode 100644
index 0000000000..b0a3fb10c7
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch
@@ -0,0 +1,50 @@
1From 573d5fdedae72bf59d8c0b0766fdee171063d36f Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Sun, 16 Feb 2014 23:08:52 +0100
4Subject: [PATCH] avcodec/msrle: use av_image_get_linesize() to calculate the
5 linesize
6
7Upstream-Status: Backport
8
9Commit 573d5fdedae72bf59d8c0b0766fdee171063d36f release/0.9
10
11Fixes out of array access
12Fixes: 14a74a0a2dc67ede543f0e35d834fbbe-asan_heap-oob_49572c_556_cov_215466444_44_001_engine_room.mov
13Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
14Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
15(cherry picked from commit c919e1ca2ecfc47d796382973ba0e48b8f6f92a2)
16
17Conflicts:
18
19 libavcodec/msrle.c
20(cherry picked from commit bc1c8ec5e65098fd2ccd8456f667151dfc9cda42)
21
22Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
23---
24 libavcodec/msrle.c | 3 ++-
25 1 files changed, 2 insertions(+), 1 deletions(-)
26
27diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c
28index 30159bb..c39ae7b 100644
29--- a/gst-libs/ext/libav/libavcodec/msrle.c
30+++ b/gst-libs/ext/libav/libavcodec/msrle.c
31@@ -35,6 +35,7 @@
32 #include "avcodec.h"
33 #include "dsputil.h"
34 #include "msrledec.h"
35+#include "libavutil/imgutils.h"
36
37 typedef struct MsrleContext {
38 AVCodecContext *avctx;
39@@ -107,7 +108,7 @@ static int msrle_decode_frame(AVCodecContext *avctx,
40
41 /* FIXME how to correctly detect RLE ??? */
42 if (avctx->height * istride == avpkt->size) { /* assume uncompressed */
43- int linesize = avctx->width * avctx->bits_per_coded_sample / 8;
44+ int linesize = av_image_get_linesize(avctx->pix_fmt, avctx->width, 0);
45 uint8_t *ptr = s->frame.data[0];
46 uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
47 int i, j;
48--
491.7.5.4
50
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
new file mode 100644
index 0000000000..5ff65834e4
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-parser-reset-indexes-on-realloc-failure.patch
@@ -0,0 +1,50 @@
1gst-ffmpeg: avcodec/parser: reset indexes on realloc failure
2
3Fixes Ticket2982
4
5Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
6(cherry picked from commit f31011e9abfb2ae75bb32bc44e2c34194c8dc40a)
7
8Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
9
10Upstream-Status: Backport
11
12Signed-off-by: Yue Tao <yue.tao@windriver.com>
13
14---
15 libavcodec/parser.c | 10 +++++++---
16 1 files changed, 7 insertions(+), 3 deletions(-)
17
18diff --git a/libavcodec/parser.c b/libavcodec/parser.c
19index 2c6de6e..66eca06 100644
20--- a/gst-libs/ext/libav/libavcodec/parser.c
21+++ b/gst-libs/ext/libav/libavcodec/parser.c
22@@ -241,8 +241,10 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
23 if(next == END_NOT_FOUND){
24 void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
25
26- if(!new_buffer)
27+ if(!new_buffer) {
28+ pc->index = 0;
29 return AVERROR(ENOMEM);
30+ }
31 pc->buffer = new_buffer;
32 memcpy(&pc->buffer[pc->index], *buf, *buf_size);
33 pc->index += *buf_size;
34@@ -255,9 +257,11 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
35 /* append to buffer */
36 if(pc->index){
37 void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
38-
39- if(!new_buffer)
40+ if(!new_buffer) {
41+ pc->overread_index =
42+ pc->index = 0;
43 return AVERROR(ENOMEM);
44+ }
45 pc->buffer = new_buffer;
46 if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
47 memcpy(&pc->buffer[pc->index], *buf,
48--
491.7.5.4
50
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
new file mode 100644
index 0000000000..7f6eb48889
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch
@@ -0,0 +1,81 @@
1gst-ffmpeg: avcodec/rpza: Perform pointer advance and checks before
2 using the pointers
3
4Fixes out of array accesses
5Fixes Ticket2850
6
7Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
8(cherry picked from commit 3819db745da2ac7fb3faacb116788c32f4753f34)
9
10Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11
12Upstream-Status: Backport
13
14Singed-off-by: Yue Tao <yue.tao@windriver.com>
15
16---
17 libavcodec/rpza.c | 8 ++++----
18 1 files changed, 4 insertions(+), 4 deletions(-)
19
20diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c
21index 635b406..f291a95 100644
22--- a/gst-libs/ext/libav/libavcodec/rpza.c
23+++ b/gst-libs/ext/libav/libavcodec/rpza.c
24@@ -83,7 +83,7 @@ static void rpza_decode_stream(RpzaContext *s)
25 unsigned short *pixels = (unsigned short *)s->frame.data[0];
26
27 int row_ptr = 0;
28- int pixel_ptr = 0;
29+ int pixel_ptr = -4;
30 int block_ptr;
31 int pixel_x, pixel_y;
32 int total_blocks;
33@@ -139,6 +139,7 @@ static void rpza_decode_stream(RpzaContext *s)
34 colorA = AV_RB16 (&s->buf[stream_ptr]);
35 stream_ptr += 2;
36 while (n_blocks--) {
37+ ADVANCE_BLOCK()
38 block_ptr = row_ptr + pixel_ptr;
39 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
40 for (pixel_x = 0; pixel_x < 4; pixel_x++){
41@@ -147,7 +148,6 @@ static void rpza_decode_stream(RpzaContext *s)
42 }
43 block_ptr += row_inc;
44 }
45- ADVANCE_BLOCK();
46 }
47 break;
48
49@@ -184,6 +184,7 @@ static void rpza_decode_stream(RpzaContext *s)
50 color4[2] |= ((21 * ta + 11 * tb) >> 5);
51
52 while (n_blocks--) {
53+ ADVANCE_BLOCK();
54 block_ptr = row_ptr + pixel_ptr;
55 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
56 index = s->buf[stream_ptr++];
57@@ -194,12 +195,12 @@ static void rpza_decode_stream(RpzaContext *s)
58 }
59 block_ptr += row_inc;
60 }
61- ADVANCE_BLOCK();
62 }
63 break;
64
65 /* Fill block with 16 colors */
66 case 0x00:
67+ ADVANCE_BLOCK();
68 block_ptr = row_ptr + pixel_ptr;
69 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
70 for (pixel_x = 0; pixel_x < 4; pixel_x++){
71@@ -213,7 +214,6 @@ static void rpza_decode_stream(RpzaContext *s)
72 }
73 block_ptr += row_inc;
74 }
75- ADVANCE_BLOCK();
76 break;
77
78 /* Unknown opcode */
79--
801.7.5.4
81
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
new file mode 100644
index 0000000000..3ca6fc4dc5
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avcodec-smc-fix-off-by-1-error.patch
@@ -0,0 +1,32 @@
1From c17a0ad1df15a94d0b1239adc2afb593bdf0a153 Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Fri, 3 Oct 2014 22:50:45 +0200
4Subject: [PATCH 1/2] avcodec/smc: fix off by 1 error
5
6Upstream-Status: Backport
7
8Fixes out of array access
9Fixes: asan_heap-oob_1685bf0_5_asan_heap-oob_1f35116_430_smc.mov
10
11Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
12Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
13---
14 libavcodec/smc.c | 2 +-
15 1 file changed, 1 insertion(+), 1 deletion(-)
16
17diff --git a/gst-libs/ext/libav/libavcodec/smc.c b/gst-libs/ext/libav/libavcodec/smc.c
18index 3cd5e53..dec9f71 100644
19--- a/gst-libs/ext/libav/libavcodec/smc.c
20+++ b/gst-libs/ext/libav/libavcodec/smc.c
21@@ -69,7 +69,7 @@ typedef struct SmcContext {
22 row_ptr += stride * 4; \
23 } \
24 total_blocks--; \
25- if (total_blocks < 0) \
26+ if (total_blocks < 0 + !!n_blocks) \
27 { \
28 av_log(s->avctx, AV_LOG_INFO, "warning: block counter just went negative (this should not happen)\n"); \
29 return; \
30--
312.1.0
32
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
new file mode 100644
index 0000000000..68bb66e4e2
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch
@@ -0,0 +1,69 @@
1From 12770701856a05b6b3cd706f708f8e9a4e8a1336 Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Thu, 13 Feb 2014 13:59:51 +0100
4Subject: [PATCH] avformat/mpegtsenc: Check data array size in
5 mpegts_write_pmt()
6
7Upstream-Status: Backport
8
9COmmit 12770701856a05b6b3cd706f708f8e9a4e8a1336 release/0.11
10
11Prevents out of array writes
12
13Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
14(cherry picked from commit 842b6c14bcfc1c5da1a2d288fd65386eb8c158ad)
15
16Conflicts:
17
18 libavformat/mpegtsenc.c
19(cherry picked from commit e87de3f50b765134588d0b048c32ed4b8acc16fb)
20
21Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
22---
23 libavformat/mpegtsenc.c | 9 +++++++--
24 1 files changed, 7 insertions(+), 2 deletions(-)
25
26diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
27index 793e205..a12d19f 100644
28--- a/gst-libs/ext/libav/libavformat/mpegtsenc.c
29+++ b/gst-libs/ext/libav/libavformat/mpegtsenc.c
30@@ -240,7 +240,7 @@ static void mpegts_write_pat(AVFormatContext *s)
31 data, q - data);
32 }
33
34-static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
35+static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
36 {
37 // MpegTSWrite *ts = s->priv_data;
38 uint8_t data[1012], *q, *desc_length_ptr, *program_info_length_ptr;
39@@ -293,6 +293,10 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
40 stream_type = STREAM_TYPE_PRIVATE_DATA;
41 break;
42 }
43+
44+ if (q - data > sizeof(data) - 32)
45+ return AVERROR(EINVAL);
46+
47 *q++ = stream_type;
48 put16(&q, 0xe000 | ts_st->pid);
49 desc_length_ptr = q;
50@@ -324,7 +328,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
51 len_ptr = q++;
52 *len_ptr = 0;
53
54- for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next + 1) {
55+ for (p = lang->value; next && *len_ptr < 255 / 4 * 4 && q - data < sizeof(data) - 4; p = next + 1) {
56 next = strchr(p, ',');
57 if (strlen(p) != 3 && (!next || next != p + 3))
58 continue; /* not a 3-letter code */
59@@ -386,6 +390,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
60 }
61 mpegts_write_section1(&service->pmt, PMT_TID, service->sid, 0, 0, 0,
62 data, q - data);
63+ return 0;
64 }
65
66 /* NOTE: str == NULL is accepted for an empty string */
67--
681.7.5.4
69
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
new file mode 100644
index 0000000000..f45e3fd59d
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-eamad-fix-out-of-array-accesses.patch
@@ -0,0 +1,29 @@
1From 63ac64864c6e0e84355aa3caa5b92208997a9a8d Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Sat, 17 Nov 2012 16:26:55 +0100
4Subject: [PATCH] eamad: fix out of array accesses
5
6Upstream-Status: Backport
7
8Commit 63ac64864c6e0e84355aa3caa5b92208997a9a8d release/1.1
9
10Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
11Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12---
13 libavcodec/eamad.c | 2 +-
14 1 file changed, 1 insertion(+), 1 deletion(-)
15
16diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c
17index 2805195..e38650e 100644
18--- a/gst-libs/ext/libav/libavcodec/eamad.c
19+++ b/gst-libs/ext/libav/libavcodec/eamad.c
20@@ -237,7 +237,7 @@ static int decode_frame(AVCodecContext *avctx,
21 int chunk_type;
22 int inter;
23
24- if (buf_size < 17) {
25+ if (buf_size < 26) {
26 av_log(avctx, AV_LOG_ERROR, "Input buffer too small\n");
27 *data_size = 0;
28 return -1;
29--
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
new file mode 100644
index 0000000000..e0e4239c2f
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error-concealment-initialize-block-index.patch
@@ -0,0 +1,29 @@
1gst-ffmpeg: error concealment: initialize block index.
2
3Fixes CVE-2011-3941 (out of bounds write)
4
5Upstream-Status: Backport
6
7Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
8Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
9---
10 libavcodec/error_resilience.c | 3 +++
11 1 files changed, 3 insertions(+), 0 deletions(-)
12
13diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
14index 8bb5d0c..d55c000 100644
15--- a/gst-libs/ext/libav/libavcodec/error_resilience.c
16+++ b/gst-libs/ext/libav/libavcodec/error_resilience.c
17@@ -45,6 +45,9 @@ static void decode_mb(MpegEncContext *s, int ref){
18 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);
19 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);
20
21+ ff_init_block_index(s);
22+ ff_update_block_index(s);
23+
24 if(CONFIG_H264_DECODER && s->codec_id == CODEC_ID_H264){
25 H264Context *h= (void*)s;
26 h->mb_xy= s->mb_x + s->mb_y*s->mb_stride;
27--
281.7.5.4
29
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch b/meta/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 0000000000..8eef6e99cc
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-error_concealment-Check-that-the-picture-is-not-in-a.patch
@@ -0,0 +1,37 @@
1gst-ffmpeg: error_concealment: Check that the picture is not in a half
2
3Fixes state becoming inconsistent
4Fixes a null pointer dereference
5
6Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
7Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
8(cherry picked from commit 23318a57358358e7a4dc551e830e4503f0638cfe)
9
10Upstream-Status: Backport
11
12Signed-off-by: Yue Tao <yue.tao@windriver.com>
13
14---
15 libavcodec/error_resilience.c | 6 ++++++
16 1 files changed, 6 insertions(+), 0 deletions(-)
17
18diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
19index 01f7424..2b6bc42 100644
20--- a/gst-libs/ext/libav/libavcodec/error_resilience.c
21+++ b/gst-libs/ext/libav/libavcodec/error_resilience.c
22@@ -793,6 +793,12 @@ void ff_er_frame_end(MpegEncContext *s){
23 s->picture_structure != PICT_FRAME || // we dont support ER of field pictures yet, though it should not crash if enabled
24 s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return;
25
26+ if ( s->picture_structure == PICT_FRAME
27+ && s->current_picture.linesize[0] != s->current_picture_ptr->linesize[0]) {
28+ av_log(s->avctx, AV_LOG_ERROR, "Error concealment not possible, frame not fully initialized\n");
29+ return;
30+ }
31+
32 if(s->current_picture.motion_val[0] == NULL){
33 av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
34
35--
361.7.5.4
37
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
new file mode 100644
index 0000000000..80325db4d6
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-ffserver-set-oformat.patch
@@ -0,0 +1,36 @@
1gst-ffmpeg: ffserver: set oformat
2
3Fix Ticket1986
4
5Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
6(cherry picked from commit cbe43e62c9ac7d4aefdc13476f6f691bd626525f)
7
8Upstream-Status: Backport
9
10---
11 ffserver.c | 4 +++-
12 1 files changed, 3 insertions(+), 1 deletions(-)
13
14diff --git a/ffserver.c b/ffserver.c
15index 4044d0f..8740140 100644
16--- a/gst-libs/ext/libav/ffserver.c
17+++ b/gst-libs/ext/libav/ffserver.c
18@@ -2937,12 +2937,14 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
19 {
20 AVFormatContext *avc;
21 AVStream *avs = NULL;
22+ AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
23 int i;
24
25 avc = avformat_alloc_context();
26- if (avc == NULL) {
27+ if (avc == NULL || !rtp_format) {
28 return -1;
29 }
30+ avc->oformat = rtp_format;
31 av_dict_set(&avc->metadata, "title",
32 stream->title[0] ? stream->title : "No Title", 0);
33 avc->nb_streams = stream->nb_streams;
34--
351.7.5.4
36
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch b/meta/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 0000000000..d4f55b2696
--- /dev/null
+++ b/meta/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 @@
1From d6c184880ee2e09fd68c0ae217173832cee5afc1 Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Sun, 18 Nov 2012 16:29:04 +0100
4Subject: [PATCH] h264: correct ref count check and limit, fix out of array
5 accesses.
6
7Upstream-Status: Backport
8
9Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
10Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11---
12 libavcodec/h264.c | 2 +-
13 1 file changed, 1 insertion(+), 1 deletion(-)
14
15diff --git a/libavcodec/h264.c b/libavcodec/h264.c
16index da43f1e..32cede5 100644
17--- a/gst-libs/ext/libav/libavcodec/h264.c
18+++ b/gst-libs/ext/libav/libavcodec/h264.c
19@@ -2870,6 +2870,9 @@ static int decode_slice_header(H264Conte
20 h->ref_count[0]= get_ue_golomb(&s->gb) + 1;
21 if(h->slice_type_nos==AV_PICTURE_TYPE_B)
22 h->ref_count[1]= get_ue_golomb(&s->gb) + 1;
23+ else
24+ // full range is spec-ok in this case, even for frames
25+ h->ref_count[1] = 1;
26
27 if(h->ref_count[0]-1 > 32-1 || h->ref_count[1]-1 > 32-1){
28 av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
29--
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
new file mode 100644
index 0000000000..05a9de3334
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-set-parameters-from-SPS-whenever-it-changes.patch
@@ -0,0 +1,145 @@
1gst-ffmpeg: h264: set parameters from SPS whenever it changes
2
3Fixes a crash in the fuzzed sample sample_varPAR.avi_s26638 with
4alternating bit depths.
5
6Upstream-Status: Backport
7
8Signed-off-by: Yue Tao <yue.tao@windriver.com>
9
10diff --git a/gst-libs/ext/libav/libavcodec/h264.c.old b/gst-libs/ext/libav/libavcodec/h264.c
11index 3621f41..718906a 100644
12--- a/gst-libs/ext/libav/libavcodec/h264.c.old
13+++ b/gst-libs/ext/libav/libavcodec/h264.c
14@@ -2491,6 +2491,34 @@ int ff_h264_get_profile(SPS *sps)
15 return profile;
16 }
17
18+static int h264_set_parameter_from_sps(H264Context *h)
19+{
20+ MpegEncContext *s = &h->s;
21+ AVCodecContext * avctx= s->avctx;
22+
23+ if (s->flags& CODEC_FLAG_LOW_DELAY ||
24+ (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames))
25+ s->low_delay=1;
26+
27+ if(avctx->has_b_frames < 2)
28+ avctx->has_b_frames= !s->low_delay;
29+
30+ if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
31+ if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
32+ avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
33+ h->pixel_shift = h->sps.bit_depth_luma > 8;
34+
35+ ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
36+ ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
37+ dsputil_init(&s->dsp, s->avctx);
38+ } else {
39+ av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
40+ return -1;
41+ }
42+ }
43+ return 0;
44+}
45+
46 /**
47 * decodes a slice header.
48 * This will also call MPV_common_init() and frame_start() as needed.
49@@ -2505,7 +2533,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
50 MpegEncContext * const s0 = &h0->s;
51 unsigned int first_mb_in_slice;
52 unsigned int pps_id;
53- int num_ref_idx_active_override_flag;
54+ int num_ref_idx_active_override_flag, ret;
55 unsigned int slice_type, tmp, i, j;
56 int default_ref_list_done = 0;
57 int last_pic_structure;
58@@ -2569,7 +2597,17 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
59 av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS %u referenced\n", h->pps.sps_id);
60 return -1;
61 }
62- h->sps = *h0->sps_buffers[h->pps.sps_id];
63+
64+ if (h->pps.sps_id != h->current_sps_id ||
65+ h0->sps_buffers[h->pps.sps_id]->new) {
66+ h0->sps_buffers[h->pps.sps_id]->new = 0;
67+
68+ h->current_sps_id = h->pps.sps_id;
69+ h->sps = *h0->sps_buffers[h->pps.sps_id];
70+
71+ if ((ret = h264_set_parameter_from_sps(h)) < 0)
72+ return ret;
73+ }
74
75 s->avctx->profile = ff_h264_get_profile(&h->sps);
76 s->avctx->level = h->sps.level_idc;
77@@ -3811,26 +3811,8 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
78 case NAL_SPS:
79 init_get_bits(&s->gb, ptr, bit_length);
80 ff_h264_decode_seq_parameter_set(h);
81-
82- if (s->flags& CODEC_FLAG_LOW_DELAY ||
83- (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames))
84- s->low_delay=1;
85-
86- if(avctx->has_b_frames < 2)
87- avctx->has_b_frames= !s->low_delay;
88-
89- if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
90- if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
91- avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
92- h->pixel_shift = h->sps.bit_depth_luma > 8;
93-
94- ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
95- ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
96- dsputil_init(&s->dsp, s->avctx);
97- } else {
98- av_log(avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
99- return -1;
100- }
101+ if (h264_set_parameter_from_sps(h) < 0) {
102+ return -1;
103 }
104 break;
105 case NAL_PPS:
106diff --git a/gst-libs/ext/libav/libavcodec/h264.h.old b/gst-libs/ext/libav/libavcodec/h264.h
107index e3cc815..b77ad98 100644
108--- a/gst-libs/ext/libav/libavcodec/h264.h.old
109+++ b/gst-libs/ext/libav/libavcodec/h264.h
110@@ -202,6 +202,7 @@ typedef struct SPS{
111 int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8
112 int residual_color_transform_flag; ///< residual_colour_transform_flag
113 int constraint_set_flags; ///< constraint_set[0-3]_flag
114+ int new; ///< flag to keep track if the decoder context needs re-init due to changed SPS
115 }SPS;
116
117 /**
118@@ -333,6 +334,7 @@ typedef struct H264Context{
119 int emu_edge_width;
120 int emu_edge_height;
121
122+ unsigned current_sps_id; ///< id of the current SPS
123 SPS sps; ///< current sps
124
125 /**
126diff --git a/gst-libs/ext/libav/libavcodec/h264_ps.c.old b/gst-libs/ext/libav/libavcodec/h264_ps.c
127index 7491807..0929098 100644
128--- a/gst-libs/ext/libav/libavcodec/h264_ps.c.old
129+++ b/gst-libs/ext/libav/libavcodec/h264_ps.c
130@@ -438,10 +438,13 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
131 sps->timing_info_present_flag ? sps->time_scale : 0
132 );
133 }
134+ sps->new = 1;
135
136 av_free(h->sps_buffers[sps_id]);
137- h->sps_buffers[sps_id]= sps;
138- h->sps = *sps;
139+ h->sps_buffers[sps_id] = sps;
140+ h->sps = *sps;
141+ h->current_sps_id = sps_id;
142+
143 return 0;
144 fail:
145 av_free(sps);
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
new file mode 100644
index 0000000000..5d45c1a96c
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch
@@ -0,0 +1,33 @@
1gst-ffmpeg: h264: skip error concealment when SPS and slices are
2 mismatching
3
4Fixes out of array accesses
5
6Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
7Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
8(cherry picked from commit 695af8eed642ff0104834495652d1ee784a4c14d)
9
10Upstream-Status: Backport
11
12Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
13Signed-off-by: Yue Tao <yue.tao@windriver.com>
14---
15 libavcodec/h264.c | 2 +-
16 1 files changed, 1 insertions(+), 1 deletions(-)
17
18diff --git a/libavcodec/h264.c b/libavcodec/h264.c
19index da144db..0aab4e7 100644
20--- a/gst-libs/ext/libav/libavcodec/h264.c
21+++ b/gst-libs/ext/libav/libavcodec/h264.c
22@@ -2351,7 +2351,7 @@ static int field_end(H264Context *h, int in_setup)
23 * past end by one (callers fault) and resync_mb_y != 0
24 * causes problems for the first MB line, too.
25 */
26- if (!FIELD_PICTURE)
27+ if (!FIELD_PICTURE && h->current_slice && !h->sps.new)
28 ff_er_frame_end(s);
29
30 ff_MPV_frame_end(s);
31--
321.7.5.4
33
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
new file mode 100644
index 0000000000..1e62b50360
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-h264_sei-Fix-infinite-loop.patch
@@ -0,0 +1,39 @@
1gst-ffmpeg: h264_sei: Fix infinite loop.
2
3Fixsot yet fixed parts of CVE-2011-3946.
4
5Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
6Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
7
8Upstream-Status: Backport
9
10Signed-off-by: Yue Tao <yue.tao@windriver.com>
11
12---
13 libavcodec/h264_sei.c | 4 ++++
14 1 files changed, 4 insertions(+), 0 deletions(-)
15
16
17diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
18index 374e53d..80d70e5 100644
19--- a/gst-libs/ext/libav/libavcodec/h264_sei.c
20+++ b/gst-libs/ext/libav/libavcodec/h264_sei.c
21@@ -169,11 +169,15 @@ int ff_h264_decode_sei(H264Context *h){
22
23 type=0;
24 do{
25+ if (get_bits_left(&s->gb) < 8)
26+ return -1;
27 type+= show_bits(&s->gb, 8);
28 }while(get_bits(&s->gb, 8) == 255);
29
30 size=0;
31 do{
32+ if (get_bits_left(&s->gb) < 8)
33+ return -1;
34 size+= show_bits(&s->gb, 8);
35 }while(get_bits(&s->gb, 8) == 255);
36
37--
381.7.5.4
39
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
new file mode 100644
index 0000000000..e859e443bb
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Check-init_vlc-return-codes.patch
@@ -0,0 +1,87 @@
1From b666debffec1fcbb19ef377635a53b9a58bca8a4 Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Tue, 29 Jan 2013 18:29:41 +0100
4Subject: [PATCH] huffyuvdec: Check init_vlc() return codes.
5
6Upstream-Status: Backport
7
8Commit b666debffec1fcbb19ef377635a53b9a58bca8a4 release/1.0
9
10Prevents out of array writes
11
12Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
13Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
14(cherry picked from commit f67a0d115254461649470452058fa3c28c0df294)
15
16Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
17---
18 libavcodec/huffyuv.c | 14 ++++++++++----
19 1 file changed, 10 insertions(+), 4 deletions(-)
20
21diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
22index 58da789..993e524 100644
23--- a/gst-libs/ext/libav/libavcodec/huffyuv.c
24+++ b/gst-libs/ext/libav/libavcodec/huffyuv.c
25@@ -33,6 +33,7 @@
26 #include "put_bits.h"
27 #include "dsputil.h"
28 #include "thread.h"
29+#include "libavutil/avassert.h"
30
31 #define VLC_BITS 11
32
33@@ -287,6 +287,7 @@ static void generate_joint_tables(HYuvCo
34 int len1 = s->len[p][u];
35 if (len1 > limit || !len1)
36 continue;
37+ av_assert0(i < (1 << VLC_BITS));
38 len[i] = len0 + len1;
39 bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
40 symbols[i] = (y<<8) + u;
41@@ -320,6 +321,7 @@ static void generate_joint_tables(HYuvCo
42 int len2 = s->len[2][r&255];
43 if (len2 > limit1 || !len2)
44 continue;
45+ av_assert0(i < (1 << VLC_BITS));
46 len[i] = len0 + len1 + len2;
47 bits[i] = (code << len2) + s->bits[2][r&255];
48 if(s->decorrelate){
49@@ -343,6 +345,7 @@ static void generate_joint_tables(HYuvCo
50 static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length){
51 GetBitContext gb;
52 int i;
53+ int ret;
54
55 init_get_bits(&gb, src, length*8);
56
57@@ -353,7 +356,9 @@ static int read_huffman_tables(HYuvConte
58 return -1;
59 }
60 free_vlc(&s->vlc[i]);
61- init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
62+ if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
63+ s->bits[i], 4, 4, 0)) < 0)
64+ return ret;
65 }
66
67 generate_joint_tables(s);
68@@ -365,6 +370,7 @@ static int read_old_huffman_tables(HYuvC
69 #if 1
70 GetBitContext gb;
71 int i;
72+ int ret;
73
74 init_get_bits(&gb, classic_shift_luma, sizeof(classic_shift_luma)*8);
75 if(read_len_table(s->len[0], &gb)<0)
76@@ -385,7 +391,9 @@ static int read_old_huffman_tables(HYuvC
77
78 for(i=0; i<3; i++){
79 free_vlc(&s->vlc[i]);
80- init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4, 0);
81+ if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1,
82+ s->bits[i], 4, 4, 0)) < 0)
83+ return ret;
84 }
85
86 generate_joint_tables(s);
87--
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
new file mode 100644
index 0000000000..94bf4b6fba
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-Skip-len-0-cases.patch
@@ -0,0 +1,61 @@
1From db0f7f7394e1f994ed38db043f78ed0f10bde0da Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Tue, 29 Jan 2013 19:22:33 +0100
4Subject: [PATCH] huffyuvdec: Skip len==0 cases
5
6Upstream-Status: Backport
7
8Commit db0f7f7394e1f994ed38db043f78ed0f10bde0da release/1.0
9
10Fixes vlc decoding for hypothetical files that would contain such cases.
11
12Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
13(cherry picked from commit 0dfc01c2bbf4b71bb56201bc4a393321e15d1b31)
14
15Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
16---
17 libavcodec/huffyuv.c | 10 +++++-----
18 1 file changed, 5 insertions(+), 5 deletions(-)
19
20diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
21index 993e524..72ed351 100644
22--- a/gst-libs/ext/libav/libavcodec/huffyuv.c
23+++ b/gst-libs/ext/libav/libavcodec/huffyuv.c
24@@ -281,11 +281,11 @@ static void generate_joint_tables(HYuvCo
25 for(i=y=0; y<256; y++){
26 int len0 = s->len[0][y];
27 int limit = VLC_BITS - len0;
28- if(limit <= 0)
29+ if(limit <= 0 || !len0)
30 continue;
31 for(u=0; u<256; u++){
32 int len1 = s->len[p][u];
33- if(len1 > limit)
34+ if (len1 > limit || !len1)
35 continue;
36 len[i] = len0 + len1;
37 bits[i] = (s->bits[0][y] << len1) + s->bits[p][u];
38@@ -308,17 +308,17 @@ static void generate_joint_tables(HYuvCo
39 for(i=0, g=-16; g<16; g++){
40 int len0 = s->len[p0][g&255];
41 int limit0 = VLC_BITS - len0;
42- if(limit0 < 2)
43+ if (limit0 < 2 || !len0)
44 continue;
45 for(b=-16; b<16; b++){
46 int len1 = s->len[p1][b&255];
47 int limit1 = limit0 - len1;
48- if(limit1 < 1)
49+ if (limit1 < 1 || !len1)
50 continue;
51 code = (s->bits[p0][g&255] << len1) + s->bits[p1][b&255];
52 for(r=-16; r<16; r++){
53 int len2 = s->len[2][r&255];
54- if(len2 > limit1)
55+ if (len2 > limit1 || !len2)
56 continue;
57 len[i] = len0 + len1 + len2;
58 bits[i] = (code << len2) + s->bits[2][r&255];
59--
601.8.5.2.233.g932f7e4
61
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-check-width-more-completely-avoid-out-of-.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-check-width-more-completely-avoid-out-of-.patch
new file mode 100644
index 0000000000..6b60d163fb
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-huffyuvdec-check-width-more-completely-avoid-out-of-.patch
@@ -0,0 +1,30 @@
1gst-ffmpeg: huffyuvdec: check width more completely, avoid out of array
2 accesses
3
4Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
5
6Upstream-Status: Backport
7
8Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
9---
10 libavcodec/huffyuv.c | 5 ++++-
11 1 files changed, 4 insertions(+), 1 deletions(-)
12
13diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
14index 6e88114..ca5bcd8 100644
15--- a/gst-libs/ext/libav/libavcodec/huffyuv.c
16+++ b/gst-libs/ext/libav/libavcodec/huffyuv.c
17@@ -526,6 +526,10 @@ s->bgr32=1;
18 assert(0);
19 }
20
21+ if (s->predictor == MEDIAN && avctx->pix_fmt == AV_PIX_FMT_YUV422P && avctx->width%4) {
22+ av_log(avctx, AV_LOG_ERROR, "width must be a multiple of 4 this colorspace and predictor\n");
23+ return AVERROR_INVALIDDATA;
24+ }
25 alloc_temp(s);
26
27 // av_log(NULL, AV_LOG_DEBUG, "pred:%d bpp:%d hbpp:%d il:%d\n", s->predictor, s->bitstream_bpp, avctx->bits_per_coded_sample, s->interlaced);
28--
291.7.5.4
30
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
new file mode 100644
index 0000000000..ea4aa222b3
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-lavf-compute-probe-buffer-size-more-reliably.patch
@@ -0,0 +1,45 @@
1gst-ffmpeg: lavf: compute probe buffer size more reliably.
2
3The previous code computes the offset by reversing the growth
4of the allocated buffer size: it is complex and did lead to
5inconsistencies when the size limit is reached.
6
7Fix trac ticket #1991.
8(cherry picked from commit 03847eb8259291b4ff1bd840bd779d0699d71f96)
9
10Conflicts:
11 libavformat/utils.c
12
13Upstream-Status: Backport
14
15Signed-off-by: Yue Tao <yue.tao@windriver.com>
16
17---
18 libavformat/utils.c | 4 ++--
19 1 files changed, 2 insertions(+), 2 deletions(-)
20
21diff --git a/libavformat/utils.c b/libavformat/utils.c
22index 7940037..be73c4a 100644
23--- a/gst-libs/ext/libav/libavformat/utils.c
24+++ b/gst-libs/ext/libav/libavformat/utils.c
25@@ -459,7 +459,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
26 {
27 AVProbeData pd = { filename ? filename : "", NULL, -offset };
28 unsigned char *buf = NULL;
29- int ret = 0, probe_size;
30+ int ret = 0, probe_size, buf_offset = 0;
31
32 if (!max_probe_size) {
33 max_probe_size = PROBE_BUF_MAX;
34@@ -499,7 +499,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
35 score = 0;
36 ret = 0; /* error was end of file, nothing read */
37 }
38- pd.buf_size += ret;
39+ pd.buf_size = buf_offset += ret;
40 pd.buf = &buf[offset];
41
42 memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
43--
441.7.5.4
45
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
new file mode 100644
index 0000000000..d90bafac91
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-mjpegdec-check-SE.patch
@@ -0,0 +1,32 @@
1From 1f41cffe1e3e79620f587545bdfcbd7e6e68ed29 Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Sun, 11 Nov 2012 00:01:24 +0100
4Subject: [PATCH] mjpegdec: check SE.
5
6Upstream-Status: Backport
7
8Commit 1f41cffe1e3e79620f587545bdfcbd7e6e68ed29 release/1.1
9
10Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
11Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12---
13 libavcodec/mjpegdec.c | 5 +++++
14 1 file changed, 5 insertions(+)
15
16diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
17index 6b5266d..0a71a6f 100644
18--- a/gst-libs/ext/libav/libavcodec/mjpegdec.c
19+++ b/gst-libs/ext/libav/libavcodec/mjpegdec.c
20@@ -905,6 +905,11 @@ static int mjpeg_decode_scan_progressive
21 int16_t *quant_matrix = s->quant_matrixes[ s->quant_index[c] ];
22 GetBitContext mb_bitmask_gb;
23
24+ if (se > 63) {
25+ av_log(s->avctx, AV_LOG_ERROR, "SE %d is too large\n", se);
26+ return AVERROR_INVALIDDATA;
27+ }
28+
29 if (mb_bitmask) {
30 init_get_bits(&mb_bitmask_gb, mb_bitmask, s->mb_width*s->mb_height);
31 }
32--
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
new file mode 100644
index 0000000000..1041347c87
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch
@@ -0,0 +1,34 @@
1From 28bf685bfc6d0c744369cdf367f61a78d80d0b01 Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Thu, 15 Nov 2012 16:41:28 +0100
4Subject: [PATCH] pgssubdec: check RLE size before copying. Fix out of array
5 accesses
6
7Upstream-Status: Backport
8
9Commit 28bf685bfc6d0c744369cdf367f61a78d80d0b01 release/1.1
10
11Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
12Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
13(cherry picked from commit c0d68be555f5858703383040e04fcd6529777061)
14---
15 libavcodec/pgssubdec.c | 5 +++++
16 1 file changed, 5 insertions(+)
17
18diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
19index 728f178..26a3c2a 100644
20--- a/gst-libs/ext/libav/libavcodec/pgssubdec.c
21+++ b/gst-libs/ext/libav/libavcodec/pgssubdec.c
22@@ -202,6 +202,11 @@ static int parse_picture_segment(AVCodec
23 return -1;
24 }
25
26+ if (buf_size > rle_bitmap_len) {
27+ av_log(avctx, AV_LOG_ERROR, "too much RLE data\n");
28+ return AVERROR_INVALIDDATA;
29+ }
30+
31 ctx->picture.w = width;
32 ctx->picture.h = height;
33
34--
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch b/meta/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 0000000000..1e5fb7deb1
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch
@@ -0,0 +1,44 @@
1gst-ffmpeg: pngdec/filter: dont access out of array elements at the end
2
3Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
4
5Upstream-Status: Backport
6
7Signed-off-by: Yue Tao <yue.tao@windriver.com>
8---
9 libavcodec/pngdec.c | 12 ++++--------
10 1 files changed, 4 insertions(+), 8 deletions(-)
11
12diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
13index 97c0ad1..193e35e 100644
14--- a/gst-libs/ext/libav/libavcodec/pngdec.c
15+++ b/gst-libs/ext/libav/libavcodec/pngdec.c
16@@ -190,7 +190,7 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w
17 if(bpp >= 2) g = dst[1];\
18 if(bpp >= 3) b = dst[2];\
19 if(bpp >= 4) a = dst[3];\
20- for(; i < size; i+=bpp) {\
21+ for(; i <= size - bpp; i+=bpp) {\
22 dst[i+0] = r = op(r, src[i+0], last[i+0]);\
23 if(bpp == 1) continue;\
24 dst[i+1] = g = op(g, src[i+1], last[i+1]);\
25@@ -206,13 +206,9 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w
26 else if(bpp == 2) UNROLL1(2, op)\
27 else if(bpp == 3) UNROLL1(3, op)\
28 else if(bpp == 4) UNROLL1(4, op)\
29- else {\
30- for (; i < size; i += bpp) {\
31- int j;\
32- for (j = 0; j < bpp; j++)\
33- dst[i+j] = op(dst[i+j-bpp], src[i+j], last[i+j]);\
34- }\
35- }
36+ for (; i < size; i++) {\
37+ dst[i] = op(dst[i-bpp], src[i], last[i]);\
38+ }\
39
40 /* NOTE: 'dst' can be equal to 'last' */
41 static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
42--
431.7.5.4
44
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch b/meta/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 0000000000..8c94232d6d
--- /dev/null
+++ b/meta/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 @@
1gst-ffmpeg: qdm2: check array index before use, fix out of array
2 accesses
3
4Upstream-Status: Backport
5
6Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
7Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
8---
9 libavcodec/qdm2.c | 5 +++++
10 1 files changed, 5 insertions(+), 0 deletions(-)
11
12diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
13index 4cf4b2f..1dfb8d5 100644
14--- a/gst-libs/ext/libav/libavcodec/qdm2.c
15+++ b/gst-libs/ext/libav/libavcodec/qdm2.c
16@@ -1257,6 +1257,11 @@ static void qdm2_decode_super_block (QDM2Context *q)
17 for (i = 0; packet_bytes > 0; i++) {
18 int j;
19
20+ if (i>=FF_ARRAY_ELEMS(q->sub_packet_list_A)) {
21+ SAMPLES_NEEDED_2("too many packet bytes");
22+ return;
23+ }
24+
25 q->sub_packet_list_A[i].next = NULL;
26
27 if (i > 0) {
28--
291.7.5.4
30
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
new file mode 100644
index 0000000000..43ffc03a69
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-qdm2dec-fix-buffer-overflow.patch
@@ -0,0 +1,58 @@
1gst-ffmpeg: qdm2dec: fix buffer overflow. Fixes NGS00144
2
3This also adds a few lines of code from master that are needed for this fix.
4
5Thanks to Phillip for suggestions to improve the patch.
6Found-by: Phillip Langlois
7
8Upstream-Status: Backport
9
10Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11---
12 libavcodec/qdm2.c | 9 +++++++--
13 1 files changed, 7 insertions(+), 2 deletions(-)
14
15diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
16index 3aa9e5b..e000df8 100644
17--- a/gst-libs/ext/libav/libavcodec/qdm2.c
18+++ b/gst-libs/ext/libav/libavcodec/qdm2.c
19@@ -76,6 +76,7 @@ do { \
20 #define SAMPLES_NEEDED_2(why) \
21 av_log (NULL,AV_LOG_INFO,"This file triggers some missing code. Please contact the developers.\nPosition: %s\n",why);
22
23+#define QDM2_MAX_FRAME_SIZE 512
24
25 typedef int8_t sb_int8_array[2][30][64];
26
27@@ -168,7 +169,7 @@ typedef struct {
28 /// I/O data
29 const uint8_t *compressed_data;
30 int compressed_size;
31- float output_buffer[1024];
32+ float output_buffer[QDM2_MAX_FRAME_SIZE * MPA_MAX_CHANNELS * 2];
33
34 /// Synthesis filter
35 MPADSPContext mpadsp;
36@@ -1819,6 +1820,9 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
37 s->group_order = av_log2(s->group_size) + 1;
38 s->frame_size = s->group_size / 16; // 16 iterations per super block
39
40+ if (s->frame_size > QDM2_MAX_FRAME_SIZE)
41+ return AVERROR_INVALIDDATA;
42+
43 s->sub_sampling = s->fft_order - 7;
44 s->frequency_range = 255 / (1 << (2 - s->sub_sampling));
45
46@@ -1887,6 +1891,9 @@ static int qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
47 int ch, i;
48 const int frame_size = (q->frame_size * q->channels);
49
50+ if((unsigned)frame_size > FF_ARRAY_ELEMS(q->output_buffer)/2)
51+ return -1;
52+
53 /* select input buffer */
54 q->compressed_data = in;
55 q->compressed_size = q->checksum_size;
56--
571.7.5.4
58
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
new file mode 100644
index 0000000000..7e58afcf6b
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-roqvideodec-check-dimensions-validity.patch
@@ -0,0 +1,36 @@
1From 391e0fc6c90ced6656b74f50f3a487b6dc76ea63 Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Thu, 29 Nov 2012 15:18:17 +0100
4Subject: [PATCH] roqvideodec: check dimensions validity
5
6Upstream-Status: Backport
7
8Commit 391e0fc6c90ced6656b74f50f3a487b6dc76ea63 release/0.7
9
10Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
11Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12(cherry picked from commit 3ae610451170cd5a28b33950006ff0bd23036845)
13
14Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
15---
16 libavcodec/roqvideodec.c | 6 ++++++
17 1 file changed, 6 insertions(+)
18
19diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c
20index f0977f6..4e34231 100644
21--- a/gst-libs/ext/libav/libavcodec/roqvideodec.c
22+++ b/gst-libs/ext/libav/libavcodec/roqvideodec.c
23@@ -157,6 +157,12 @@ static av_cold int roq_decode_init(AVCodecContext *avctx)
24 RoqContext *s = avctx->priv_data;
25
26 s->avctx = avctx;
27+
28+ if (avctx->width%16 || avctx->height%16) {
29+ av_log_ask_for_sample(avctx, "dimensions not being a multiple of 16 are unsupported\n");
30+ return AVERROR_PATCHWELCOME;
31+ }
32+
33 s->width = avctx->width;
34 s->height = avctx->height;
35 avcodec_get_frame_defaults(&s->frames[0]);
36--
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
new file mode 100644
index 0000000000..15b161469c
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch
@@ -0,0 +1,32 @@
1gst-ffmpeg: smackerdec: Check that the last indexes are within the
2 table.
3
4Fixes CVE-2011-3944
5
6Upstream-Status: Backport
7
8Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
9Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
10---
11 libavcodec/smacker.c | 5 +++++
12 1 files changed, 5 insertions(+), 0 deletions(-)
13
14diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
15index 30f99b4..2a8bae8 100644
16--- a/gst-libs/ext/libav/libavcodec/smacker.c
17+++ b/gst-libs/ext/libav/libavcodec/smacker.c
18@@ -259,6 +259,11 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int
19 if(ctx.last[0] == -1) ctx.last[0] = huff.current++;
20 if(ctx.last[1] == -1) ctx.last[1] = huff.current++;
21 if(ctx.last[2] == -1) ctx.last[2] = huff.current++;
22+ if(huff.current > huff.length){
23+ ctx.last[0] = ctx.last[1] = ctx.last[2] = 1;
24+ av_log(smk->avctx, AV_LOG_ERROR, "bigtree damaged\n");
25+ return -1;
26+ }
27
28 *recodes = huff.values;
29
30--
311.7.5.4
32
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
new file mode 100644
index 0000000000..a1989cfeab
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-Copy-all-3-frames-for-thread-updates.patch
@@ -0,0 +1,32 @@
1gst-ffmpeg: vp3: Copy all 3 frames for thread updates.
2
3This fixes a double release of the current frame on deinit.
4Fixes CVE-2011-3934
5
6Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
7Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
8
9Upstream-Status: Backport
10
11Signed-off-by: Yue.Tao <yue.tao@windriver.com>
12
13---
14 libavcodec/vp3.c | 2 +-
15 1 files changed, 1 insertions(+), 1 deletions(-)
16
17diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
18index 738ae9f..b5daafc 100644
19--- a/gst-libs/ext/libav/libavcodec/vp3.c
20+++ b/gst-libs/ext/libav/libavcodec/vp3.c
21@@ -1859,7 +1859,7 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
22 ||s->width != s1->width
23 ||s->height!= s1->height) {
24 if (s != s1)
25- copy_fields(s, s1, golden_frame, current_frame);
26+ copy_fields(s, s1, golden_frame, keyframe);
27 return -1;
28 }
29
30--
311.7.5.4
32
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch b/meta/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 0000000000..e83d8f402b
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch
@@ -0,0 +1,183 @@
1gst-ffmpeg: vp3: fix oob read for negative tokens and memleaks on error.
2
3Upstream-Status: Backport
4
5Signed-off-by: Yue.Tao <yue.tao@windriver.com>
6
7---
8 libavcodec/vp3.c | 59 +++++++++++++++++++++++++++++++++++++++++------------
9 1 files changed, 45 insertions(+), 14 deletions(-)
10
11diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
12index 36715bb..ce14e63 100644
13--- a/gst-libs/ext/libav/libavcodec/vp3.c
14+++ b/gst-libs/ext/libav/libavcodec/vp3.c
15@@ -45,6 +45,7 @@
16 #define FRAGMENT_PIXELS 8
17
18 static av_cold int vp3_decode_end(AVCodecContext *avctx);
19+static void vp3_decode_flush(AVCodecContext *avctx);
20
21 //FIXME split things out into their own arrays
22 typedef struct Vp3Fragment {
23@@ -890,7 +891,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
24 /* decode a VLC into a token */
25 token = get_vlc2(gb, vlc_table, 11, 3);
26 /* use the token to get a zero run, a coefficient, and an eob run */
27- if (token <= 6) {
28+ if ((unsigned) token <= 6U) {
29 eob_run = eob_run_base[token];
30 if (eob_run_get_bits[token])
31 eob_run += get_bits(gb, eob_run_get_bits[token]);
32@@ -908,7 +909,7 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
33 coeff_i += eob_run;
34 eob_run = 0;
35 }
36- } else {
37+ } else if (token >= 0) {
38 bits_to_get = coeff_get_bits[token];
39 if (bits_to_get)
40 bits_to_get = get_bits(gb, bits_to_get);
41@@ -942,6 +943,10 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *gb,
42 for (i = coeff_index+1; i <= coeff_index+zero_run; i++)
43 s->num_coded_frags[plane][i]--;
44 coeff_i++;
45+ } else {
46+ av_log(s->avctx, AV_LOG_ERROR,
47+ "Invalid token %d\n", token);
48+ return -1;
49 }
50 }
51
52@@ -991,6 +996,8 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
53 /* unpack the Y plane DC coefficients */
54 residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0,
55 0, residual_eob_run);
56+ if (residual_eob_run < 0)
57+ return residual_eob_run;
58
59 /* reverse prediction of the Y-plane DC coefficients */
60 reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]);
61@@ -998,8 +1005,12 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
62 /* unpack the C plane DC coefficients */
63 residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
64 1, residual_eob_run);
65+ if (residual_eob_run < 0)
66+ return residual_eob_run;
67 residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
68 2, residual_eob_run);
69+ if (residual_eob_run < 0)
70+ return residual_eob_run;
71
72 /* reverse prediction of the C-plane DC coefficients */
73 if (!(s->avctx->flags & CODEC_FLAG_GRAY))
74@@ -1036,11 +1047,17 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
75 for (i = 1; i <= 63; i++) {
76 residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i,
77 0, residual_eob_run);
78+ if (residual_eob_run < 0)
79+ return residual_eob_run;
80
81 residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
82 1, residual_eob_run);
83+ if (residual_eob_run < 0)
84+ return residual_eob_run;
85 residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i,
86 2, residual_eob_run);
87+ if (residual_eob_run < 0)
88+ return residual_eob_run;
89 }
90
91 return 0;
92@@ -1777,10 +1794,15 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
93 Vp3DecodeContext *s = dst->priv_data, *s1 = src->priv_data;
94 int qps_changed = 0, i, err;
95
96+#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
97+
98 if (!s1->current_frame.data[0]
99 ||s->width != s1->width
100- ||s->height!= s1->height)
101+ ||s->height!= s1->height) {
102+ if (s != s1)
103+ copy_fields(s, s1, golden_frame, current_frame);
104 return -1;
105+ }
106
107 if (s != s1) {
108 // init tables if the first frame hasn't been decoded
109@@ -1796,8 +1818,6 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *
110 memcpy(s->motion_val[1], s1->motion_val[1], c_fragment_count * sizeof(*s->motion_val[1]));
111 }
112
113-#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field)
114-
115 // copy previous frame data
116 copy_fields(s, s1, golden_frame, dsp);
117
118@@ -1987,9 +2007,6 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
119 Vp3DecodeContext *s = avctx->priv_data;
120 int i;
121
122- if (avctx->is_copy && !s->current_frame.data[0])
123- return 0;
124-
125 av_free(s->superblock_coding);
126 av_free(s->all_fragments);
127 av_free(s->coded_fragment_list[0]);
128@@ -2016,12 +2033,7 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
129 free_vlc(&s->motion_vector_vlc);
130
131 /* release all frames */
132- if (s->golden_frame.data[0])
133- ff_thread_release_buffer(avctx, &s->golden_frame);
134- if (s->last_frame.data[0] && s->last_frame.type != FF_BUFFER_TYPE_COPY)
135- ff_thread_release_buffer(avctx, &s->last_frame);
136- /* no need to release the current_frame since it will always be pointing
137- * to the same frame as either the golden or last frame */
138+ vp3_decode_flush(avctx);
139
140 return 0;
141 }
142@@ -2341,6 +2353,23 @@ static void vp3_decode_flush(AVCodecContext *avctx)
143 ff_thread_release_buffer(avctx, &s->current_frame);
144 }
145
146+static int vp3_init_thread_copy(AVCodecContext *avctx)
147+{
148+ Vp3DecodeContext *s = avctx->priv_data;
149+
150+ s->superblock_coding = NULL;
151+ s->all_fragments = NULL;
152+ s->coded_fragment_list[0] = NULL;
153+ s->dct_tokens_base = NULL;
154+ s->superblock_fragments = NULL;
155+ s->macroblock_coding = NULL;
156+ s->motion_val[0] = NULL;
157+ s->motion_val[1] = NULL;
158+ s->edge_emu_buffer = NULL;
159+
160+ return 0;
161+}
162+
163 AVCodec ff_theora_decoder = {
164 .name = "theora",
165 .type = AVMEDIA_TYPE_VIDEO,
166@@ -2352,6 +2381,7 @@ AVCodec ff_theora_decoder = {
167 .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
168 .flush = vp3_decode_flush,
169 .long_name = NULL_IF_CONFIG_SMALL("Theora"),
170+ .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
171 .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
172 };
173 #endif
174@@ -2367,5 +2397,6 @@ AVCodec ff_vp3_decoder = {
175 .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
176 .flush = vp3_decode_flush,
177 .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"),
178+ .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
179 .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
180 };
181--
1821.7.5.4
183
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
new file mode 100644
index 0000000000..7e4f682167
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch
@@ -0,0 +1,51 @@
1From 2cac35086c9e103fa98960c546d5017e7363803a Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Fri, 25 Jan 2013 06:11:59 +0100
4Subject: [PATCH] vqavideo: check chunk sizes before reading chunks
5
6Upstream-Status: Backport
7
8Commit 2cac35086c9e103fa98960c546d5017e7363803a release/0.7
9
10Fixes out of array writes
11
12Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
13Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
14(cherry picked from commit ab6c9332bfa1e20127a16392a0b85a4aa4840889)
15
16Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
17---
18 libavcodec/vqavideo.c | 10 ++++++++++
19 1 files changed, 10 insertions(+), 0 deletions(-)
20
21diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
22index d1eab5b..6e1ce6c 100644
23--- a/gst-libs/ext/libav/libavcodec/vqavideo.c
24+++ b/gst-libs/ext/libav/libavcodec/vqavideo.c
25@@ -527,6 +527,11 @@ static void vqa_decode_chunk(VqaContext *s)
26 chunk_size = AV_RB32(&s->buf[cbp0_chunk + 4]);
27 cbp0_chunk += CHUNK_PREAMBLE_SIZE;
28
29+ if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
30+ av_log(s->avctx, AV_LOG_ERROR, "cbp0 chunk too large (0x%X bytes)\n", chunk_size);
31+ return AVERROR_INVALIDDATA;
32+ }
33+
34 /* accumulate partial codebook */
35 memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
36 &s->buf[cbp0_chunk], chunk_size);
37@@ -550,6 +555,11 @@ static void vqa_decode_chunk(VqaContext *s)
38 chunk_size = AV_RB32(&s->buf[cbpz_chunk + 4]);
39 cbpz_chunk += CHUNK_PREAMBLE_SIZE;
40
41+ if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
42+ av_log(s->avctx, AV_LOG_ERROR, "cbpz chunk too large (0x%X bytes)\n", chunk_size);
43+ return AVERROR_INVALIDDATA;
44+ }
45+
46 /* accumulate partial codebook */
47 memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
48 &s->buf[cbpz_chunk], chunk_size);
49--
501.7.5.4
51
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
new file mode 100644
index 0000000000..c8bafd570e
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch
@@ -0,0 +1,68 @@
1From 6043c431c97d55173f339fafbd033d3c0642e2e9 Mon Sep 17 00:00:00 2001
2From: Michael Niedermayer <michaelni@gmx.at>
3Date: Fri, 3 Oct 2014 01:50:27 +0200
4Subject: [PATCH 2/2] avcodec/mjpegdec: check bits per pixel for changes
5 similar to dimensions
6
7Upstream-Status: Backport
8
9Fixes out of array accesses
10Fixes: asan_heap-oob_16668e9_2_asan_heap-oob_16668e9_346_miss_congeniality_pegasus_mjpg.avi
11
12Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
13Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
14
15Conflicts:
16 libavcodec/mjpegdec.c
17---
18 libavcodec/mjpegdec.c | 15 ++++++++-------
19 1 file changed, 8 insertions(+), 7 deletions(-)
20
21diff --git a/gst-libs/ext/libav/libavcodec/mjpegdec.c b/gst-libs/ext/libav/libavcodec/mjpegdec.c
22index 84343c0..c0137d8 100644
23--- a/gst-libs/ext/libav/libavcodec/mjpegdec.c
24+++ b/gst-libs/ext/libav/libavcodec/mjpegdec.c
25@@ -210,16 +210,16 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
26
27 int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
28 {
29- int len, nb_components, i, width, height, pix_fmt_id;
30+ int len, nb_components, i, bits, width, height, pix_fmt_id;
31
32 /* XXX: verify len field validity */
33 len = get_bits(&s->gb, 16);
34- s->bits= get_bits(&s->gb, 8);
35+ bits= get_bits(&s->gb, 8);
36
37- if(s->pegasus_rct) s->bits=9;
38- if(s->bits==9 && !s->pegasus_rct) s->rct=1; //FIXME ugly
39+ if(s->pegasus_rct) bits=9;
40+ if(bits==9 && !s->pegasus_rct) s->rct=1; //FIXME ugly
41
42- if (s->bits != 8 && !s->lossless){
43+ if (bits != 8 && !s->lossless){
44 av_log(s->avctx, AV_LOG_ERROR, "only 8 bits/component accepted\n");
45 return -1;
46 }
47@@ -239,7 +239,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
48 if (nb_components <= 0 ||
49 nb_components > MAX_COMPONENTS)
50 return -1;
51- if (s->ls && !(s->bits <= 8 || nb_components == 1)){
52+ if (s->ls && !(bits <= 8 || nb_components == 1)){
53 av_log(s->avctx, AV_LOG_ERROR, "only <= 8 bits/component or 16-bit gray accepted for JPEG-LS\n");
54 return -1;
55 }
56@@ -272,10 +272,11 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
57
58 /* if different size, realloc/alloc picture */
59 /* XXX: also check h_count and v_count */
60- if (width != s->width || height != s->height) {
61+ if (width != s->width || height != s->height || bits != s->bits) {
62 av_freep(&s->qscale_table);
63
64 s->width = width;
65+ s->bits= bits;
66 s->height = height;
67 s->interlaced = 0;
68
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch
new file mode 100644
index 0000000000..9ef6f7c4bf
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/configure-fix.patch
@@ -0,0 +1,22 @@
1Disable yasm for libav when --disable-yasm
2
3Upstream-Status: Inappropriate [configuration]
4
5Signed-off-by: Shane Wang <shane.wang@intel.com>
6
7diff -r f2f8f74c6e30 configure.ac
8--- a/configure.ac Thu Dec 22 23:56:09 2011 +0800
9+++ b/configure.ac Thu Dec 22 23:57:37 2011 +0800
10@@ -325,6 +325,12 @@
11 --enable-gpl"
12 fi
13
14+ AC_ARG_ENABLE(yasm,
15+ [AC_HELP_STRING([--disable-yasm], [disable use of yasm assembler])])
16+ if test "x$enable_yasm" = "xno"; then
17+ embffmpeg_configure_args="$embffmpeg_configure_args --disable-yasm"
18+ fi
19+
20 # if we are cross-compiling, tell ffmpeg so
21 target_os=`echo $host_os | sed 's/-gnu//'`
22 if test "x$cross_compiling" = xyes; then
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
new file mode 100644
index 0000000000..3c8d8e353e
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-0855.patch
@@ -0,0 +1,100 @@
1gst-ffmpeg: Security Advisory - ffmpeg - CVE-2013-0855
2
3Upstream-Status: Backport
4
5Signed-off-by: Yue Tao <yue.tao@windriver.com>
6
7diff --git a/gst-libs/ext/libav/libavcodec/alac.c.old b/gst-libs/ext/libav/libavcodec/alac.c
8index 2a0df8c..bcbd56d 100644
9--- a/gst-libs/ext/libav/libavcodec/alac.c.old
10+++ b/gst-libs/ext/libav/libavcodec/alac.c
11@@ -87,18 +87,44 @@ typedef struct {
12 int wasted_bits;
13 } ALACContext;
14
15-static void allocate_buffers(ALACContext *alac)
16+static av_cold int alac_decode_close(AVCodecContext *avctx)
17+{
18+ ALACContext *alac = avctx->priv_data;
19+
20+ int chan;
21+ for (chan = 0; chan < MAX_CHANNELS; chan++) {
22+ av_freep(&alac->predicterror_buffer[chan]);
23+ av_freep(&alac->outputsamples_buffer[chan]);
24+ av_freep(&alac->wasted_bits_buffer[chan]);
25+ }
26+
27+ return 0;
28+}
29+
30+static int allocate_buffers(ALACContext *alac)
31 {
32 int chan;
33+ int buf_size;
34+
35+ if (alac->setinfo_max_samples_per_frame > INT_MAX / sizeof(int32_t))
36+ goto buf_alloc_fail;
37+ buf_size = alac->setinfo_max_samples_per_frame * sizeof(int32_t);
38+
39 for (chan = 0; chan < MAX_CHANNELS; chan++) {
40- alac->predicterror_buffer[chan] =
41- av_malloc(alac->setinfo_max_samples_per_frame * 4);
42
43- alac->outputsamples_buffer[chan] =
44- av_malloc(alac->setinfo_max_samples_per_frame * 4);
45+ FF_ALLOC_OR_GOTO(alac->avctx, alac->predicterror_buffer[chan],
46+ buf_size, buf_alloc_fail);
47
48- alac->wasted_bits_buffer[chan] = av_malloc(alac->setinfo_max_samples_per_frame * 4);
49+ FF_ALLOC_OR_GOTO(alac->avctx, alac->outputsamples_buffer[chan],
50+ buf_size, buf_alloc_fail);
51+
52+ FF_ALLOC_OR_GOTO(alac->avctx, alac->wasted_bits_buffer[chan],
53+ buf_size, buf_alloc_fail);
54 }
55+ return 0;
56+buf_alloc_fail:
57+ alac_decode_close(alac->avctx);
58+ return AVERROR(ENOMEM);
59 }
60
61 static int alac_set_info(ALACContext *alac)
62@@ -131,8 +157,6 @@ static int alac_set_info(ALACContext *alac)
63 bytestream_get_be32(&ptr); /* bitrate ? */
64 bytestream_get_be32(&ptr); /* samplerate */
65
66- allocate_buffers(alac);
67-
68 return 0;
69 }
70
71@@ -659,6 +683,7 @@ static int alac_decode_frame(AVCodecContext *avctx,
72
73 static av_cold int alac_decode_init(AVCodecContext * avctx)
74 {
75+ int ret;
76 ALACContext *alac = avctx->priv_data;
77 alac->avctx = avctx;
78 alac->numchannels = alac->avctx->channels;
79@@ -674,18 +699,9 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
80 return -1;
81 }
82
83- return 0;
84-}
85-
86-static av_cold int alac_decode_close(AVCodecContext *avctx)
87-{
88- ALACContext *alac = avctx->priv_data;
89-
90- int chan;
91- for (chan = 0; chan < MAX_CHANNELS; chan++) {
92- av_freep(&alac->predicterror_buffer[chan]);
93- av_freep(&alac->outputsamples_buffer[chan]);
94- av_freep(&alac->wasted_bits_buffer[chan]);
95+ if ((ret = allocate_buffers(alac)) < 0) {
96+ av_log(avctx, AV_LOG_ERROR, "Error allocating buffers\n");
97+ return ret;
98 }
99
100 return 0;
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
new file mode 100644
index 0000000000..aa385f54c1
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/gst-ffmpeg-CVE-2013-3674.patch
@@ -0,0 +1,26 @@
1avcodec/cdgraphics: check buffer size before use
2
3Fixes out of array accesses
4
5Backported from:http://git.videolan.org/?p=ffmpeg.git;a=commit;h=ad002e1a13a8df934bd6cb2c84175a4780ab8942
6
7Upstream-Status: Backport
8
9Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
10Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11Signed-off-by: Ming Liu <ming.liu@windriver.com>
12
13diff -urpN a/gst-libs/ext/libav/libavcodec/cdgraphics.c b/gst-libs/ext/libav/libavcodec/cdgraphics.c
14--- a/gst-libs/ext/libav/libavcodec/cdgraphics.c 2013-07-18 13:17:08.399876575 +0800
15+++ b/gst-libs/ext/libav/libavcodec/cdgraphics.c 2013-07-18 13:18:05.880502267 +0800
16@@ -291,7 +291,9 @@ static int cdg_decode_frame(AVCodecConte
17 inst = bytestream_get_byte(&buf);
18 inst &= CDG_MASK;
19 buf += 2; /// skipping 2 unneeded bytes
20- bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
21+
22+ if (buf_size > CDG_HEADER_SIZE)
23+ bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
24
25 if ((command & CDG_MASK) == CDG_COMMAND) {
26 switch (inst) {
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
new file mode 100644
index 0000000000..ade24dc06a
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/h264_qpel_mmx.patch
@@ -0,0 +1,57 @@
1Backport http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=5f654897e325349dacf2546674e0510bb72ecb50;hp=250cebeb3b348c3da71f9972eb500d6005dc01f1
2
3Fixes these errors on x86
4
5libavcodec/x86/h264_qpel_mmx.c: Assembler messages:
6libavcodec/x86/h264_qpel_mmx.c:1294: Error: operand type mismatch for `cmp'
7libavcodec/x86/h264_qpel_mmx.c:1294: Error: operand type mismatch for `cmp'
8libavcodec/x86/h264_qpel_mmx.c:1298: Error: operand type mismatch for `cmp'
9libavcodec/x86/h264_qpel_mmx.c:1298: Error: operand type mismatch for `cmp'
10libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
11libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
12libavcodec/x86/h264_qpel_mmx.c:964: Error: operand type mismatch for `cmp'
13make[5]: *** [libavcodec/x86/dsputil_mmx.o] Error 1
14
15
16Signed-off-by: Khem Raj <raj.khem@gmail.com>
17Upstream-Status: Backport
18Index: gst-ffmpeg-0.10.13/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c
19===================================================================
20--- gst-ffmpeg-0.10.13.orig/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c 2012-03-30 11:39:41.324522051 -0700
21+++ gst-ffmpeg-0.10.13/gst-libs/ext/libav/libavcodec/x86/h264_qpel_mmx.c 2012-03-30 11:54:08.152564075 -0700
22@@ -398,7 +398,7 @@
23 "2: \n\t"\
24 \
25 : "+a"(src), "+c"(dst)\
26- : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\
27+ : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "rm"(h)\
28 : "memory"\
29 );\
30 src += 4-(h+5)*srcStride;\
31@@ -446,7 +446,7 @@
32 QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 15*48)\
33 "2: \n\t"\
34 : "+a"(src)\
35- : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)\
36+ : "c"(tmp), "S"((x86_reg)srcStride), "rm"(size)\
37 : "memory"\
38 );\
39 tmp += 4;\
40@@ -823,7 +823,7 @@
41 "2: \n\t"\
42 \
43 : "+a"(src), "+c"(dst)\
44- : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "g"(h)\
45+ : "S"((x86_reg)srcStride), "D"((x86_reg)dstStride), "rm"(h)\
46 : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
47 "%xmm4", "%xmm5", "%xmm6", "%xmm7",)\
48 "memory"\
49@@ -878,7 +878,7 @@
50 QPEL_H264HV_XMM(%%xmm3, %%xmm4, %%xmm5, %%xmm0, %%xmm1, %%xmm2, 15*48)
51 "2: \n\t"
52 : "+a"(src)
53- : "c"(tmp), "S"((x86_reg)srcStride), "g"(size)
54+ : "c"(tmp), "S"((x86_reg)srcStride), "rm"(size)
55 : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3",
56 "%xmm4", "%xmm5", "%xmm6", "%xmm7",)
57 "memory"
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch
new file mode 100644
index 0000000000..9055b341dc
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav-9.patch
@@ -0,0 +1,9304 @@
1Taken from gentoo patchset:
2http://dev.gentoo.org/~tetromino/distfiles/gst-plugins-ffmpeg/gst-ffmpeg-0.10.13_p2012.11-libav-9-patches.tar.xz
3
4Upstream-Status: Pending
5
6Contains following changes, rebased to apply on top of our changes
70002-Fix-includes-for-systemwide-build.patch
80003-libav-Switch-to-non-deprecated-symbols.patch
90005-av-Update-for-some-constant-changes.patch
100006-av-Remove-palette-support-for-now.patch
110007-av-Port-remaining-simple-bits.patch
120008-av-Use-av_codec_is_-en-de-coder-API-instead-of-priva.patch
130009-avprotocol-Port-from-the-URL-protocol-handler-to-san.patch
140010-avdec-don-t-wait-for-keyframe.patch
15
16Following changes were skipped:
170001-Partially-revert-commit-0300801b.patch
180004-av-update-to-use-AVOption-variants.patch
190011-av_get_bits_per_sample_format-was-removed-in-libav-9.patch
20
21Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
22
23diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.c
24--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.c 2011-10-31 11:14:03.000000000 +0100
25+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.c 2014-08-08 15:26:07.872857555 +0200
26@@ -151,9 +151,6 @@
27 #endif
28 gst_ffmpegaudioresample_register (plugin);
29
30- av_register_protocol2 (&gstreamer_protocol, sizeof (URLProtocol));
31- av_register_protocol2 (&gstpipe_protocol, sizeof (URLProtocol));
32-
33 /* Now we can return the pointer to the newly created Plugin object. */
34 return TRUE;
35 }
36diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.h gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.h
37--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpeg.h 2011-05-17 10:53:16.000000000 +0200
38+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpeg.h 2014-08-08 15:26:07.872857555 +0200
39@@ -58,10 +58,13 @@
40 int gst_ffmpeg_avcodec_close (AVCodecContext *avctx);
41 int gst_ffmpeg_av_find_stream_info(AVFormatContext *ic);
42
43-G_END_DECLS
44+int gst_ffmpegdata_open (GstPad * pad, int flags, AVIOContext ** context);
45+int gst_ffmpegdata_close (AVIOContext * h);
46+typedef struct _GstFFMpegPipe GstFFMpegPipe;
47+int gst_ffmpeg_pipe_open (GstFFMpegPipe *ffpipe, int flags, AVIOContext ** context);
48+int gst_ffmpeg_pipe_close (AVIOContext * h);
49
50-extern URLProtocol gstreamer_protocol;
51-extern URLProtocol gstpipe_protocol;
52+G_END_DECLS
53
54 /* use GST_FFMPEG URL_STREAMHEADER with URL_WRONLY if the first
55 * buffer should be used as streamheader property on the pad's caps. */
56diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcfg.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcfg.c
57--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcfg.c 2011-07-12 16:35:27.000000000 +0200
58+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcfg.c 2014-08-08 15:24:17.899853612 +0200
59@@ -147,7 +147,6 @@
60 {FF_DCT_FASTINT, "Fast Integer", "fastint"},
61 {FF_DCT_INT, "Accurate Integer", "int"},
62 {FF_DCT_MMX, "MMX", "mmx"},
63- {FF_DCT_MLIB, "MLIB", "mlib"},
64 {FF_DCT_ALTIVEC, "ALTIVEC", "altivec"},
65 {FF_DCT_FAAN, "FAAN", "faan"},
66 {0, NULL, NULL},
67@@ -173,8 +172,6 @@
68 {FF_IDCT_SIMPLE, "Simple", "simple"},
69 {FF_IDCT_SIMPLEMMX, "Simple MMX", "simplemmx"},
70 {FF_IDCT_LIBMPEG2MMX, "LIBMPEG2MMX", "libmpeg2mmx"},
71- {FF_IDCT_PS2, "PS2", "ps2"},
72- {FF_IDCT_MLIB, "MLIB", "mlib"},
73 {FF_IDCT_ARM, "ARM", "arm"},
74 {FF_IDCT_ALTIVEC, "ALTIVEC", "altivec"},
75 {FF_IDCT_SH4, "SH4", "sh4"},
76@@ -263,16 +260,11 @@
77
78 if (!ffmpeg_flags_type) {
79 static const GFlagsValue ffmpeg_flags[] = {
80- {CODEC_FLAG_OBMC, "Use overlapped block motion compensation (h263+)",
81- "obmc"},
82 {CODEC_FLAG_QSCALE, "Use fixed qscale", "qscale"},
83 {CODEC_FLAG_4MV, "Allow 4 MV per MB", "4mv"},
84- {CODEC_FLAG_H263P_AIV, "H.263 alternative inter VLC", "aiv"},
85 {CODEC_FLAG_QPEL, "Quartel Pel Motion Compensation", "qpel"},
86 {CODEC_FLAG_GMC, "GMC", "gmc"},
87 {CODEC_FLAG_MV0, "Always try a MB with MV (0,0)", "mv0"},
88- {CODEC_FLAG_PART,
89- "Store MV, DC and AC coefficients in seperate partitions", "part"},
90 {CODEC_FLAG_LOOP_FILTER, "Loop filter", "loop-filter"},
91 {CODEC_FLAG_GRAY, "Only decode/encode grayscale", "gray"},
92 {CODEC_FLAG_NORMALIZE_AQP,
93@@ -282,13 +274,9 @@
94 "global-headers"},
95 {CODEC_FLAG_AC_PRED, "H263 Advanced Intra Coding / MPEG4 AC prediction",
96 "aic"},
97- {CODEC_FLAG_H263P_UMV, "Unlimited Motion Vector", "umv"},
98 {CODEC_FLAG_CBP_RD, "Rate Distoration Optimization for CBP", "cbp-rd"},
99 {CODEC_FLAG_QP_RD, "Rate Distoration Optimization for QP selection",
100 "qp-rd"},
101- {CODEC_FLAG_H263P_SLICE_STRUCT, "H263 slice struct", "ss"},
102- {CODEC_FLAG_SVCD_SCAN_OFFSET,
103- "Reserve space for SVCD scan offset user data", "scanoffset"},
104 {CODEC_FLAG_CLOSED_GOP, "Closed GOP", "closedgop"},
105 {0, NULL, NULL},
106 };
107diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c
108--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c 2011-10-31 11:14:03.000000000 +0100
109+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c 2014-08-08 15:31:30.968869139 +0200
110@@ -25,8 +25,10 @@
111 #include <gst/gst.h>
112 #ifdef HAVE_FFMPEG_UNINSTALLED
113 #include <avcodec.h>
114+#include <channel_layout.h>>
115 #else
116 #include <libavcodec/avcodec.h>
117+#include <libavutil/channel_layout.h>
118 #endif
119 #include <string.h>
120
121@@ -35,43 +37,6 @@
122
123 #include <gst/pbutils/codec-utils.h>
124
125-/*
126- * Read a palette from a caps.
127- */
128-
129-static void
130-gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
131-{
132- GstStructure *str = gst_caps_get_structure (caps, 0);
133- const GValue *palette_v;
134- const GstBuffer *palette;
135-
136- /* do we have a palette? */
137- if ((palette_v = gst_structure_get_value (str, "palette_data")) && context) {
138- palette = gst_value_get_buffer (palette_v);
139- if (GST_BUFFER_SIZE (palette) >= AVPALETTE_SIZE) {
140- if (context->palctrl)
141- av_free (context->palctrl);
142- context->palctrl = av_malloc (sizeof (AVPaletteControl));
143- context->palctrl->palette_changed = 1;
144- memcpy (context->palctrl->palette, GST_BUFFER_DATA (palette),
145- AVPALETTE_SIZE);
146- }
147- }
148-}
149-
150-static void
151-gst_ffmpeg_set_palette (GstCaps * caps, AVCodecContext * context)
152-{
153- if (context->palctrl) {
154- GstBuffer *palette = gst_buffer_new_and_alloc (AVPALETTE_SIZE);
155-
156- memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
157- AVPALETTE_SIZE);
158- gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, palette, NULL);
159- }
160-}
161-
162 /* IMPORTANT: Keep this sorted by the ffmpeg channel masks */
163 static const struct
164 {
165@@ -79,26 +44,26 @@
166 GstAudioChannelPosition gst;
167 } _ff_to_gst_layout[] = {
168 {
169- CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
170- CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
171- CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
172- CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
173- CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
174- CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
175- CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
176- CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
177- CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
178- CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
179- CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
180- CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
181- CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
182- CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
183- CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
184- CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
185- CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
186- CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
187- CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
188- CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
189+ AV_CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
190+ AV_CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
191+ AV_CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
192+ AV_CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
193+ AV_CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
194+ AV_CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
195+ AV_CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
196+ AV_CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
197+ AV_CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
198+ AV_CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
199+ AV_CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
200+ AV_CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
201+ AV_CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
202+ AV_CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
203+ AV_CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
204+ AV_CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
205+ AV_CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
206+ AV_CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
207+ AV_CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
208+ AV_CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
209 };
210
211 static GstAudioChannelPosition *
212@@ -342,8 +307,8 @@
213
214 if (channel_layout == 0) {
215 const guint64 default_channel_set[] = {
216- 0, 0, CH_LAYOUT_SURROUND, CH_LAYOUT_QUAD, CH_LAYOUT_5POINT0,
217- CH_LAYOUT_5POINT1, 0, CH_LAYOUT_7POINT1
218+ 0, 0, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_5POINT0,
219+ AV_CH_LAYOUT_5POINT1, 0, AV_CH_LAYOUT_7POINT1
220 };
221
222 switch (codec_id) {
223@@ -1267,8 +1232,6 @@
224 case CODEC_ID_FLIC:
225 case CODEC_ID_VMDVIDEO:
226 case CODEC_ID_VMDAUDIO:
227- case CODEC_ID_SONIC:
228- case CODEC_ID_SONIC_LS:
229 case CODEC_ID_SNOW:
230 case CODEC_ID_VIXL:
231 case CODEC_ID_QPEG:
232@@ -1689,11 +1652,6 @@
233 gst_buffer_unref (data);
234 }
235
236- /* palette */
237- if (context) {
238- gst_ffmpeg_set_palette (caps, context);
239- }
240-
241 GST_LOG ("caps for codec_id=%d: %" GST_PTR_FORMAT, codec_id, caps);
242
243 } else {
244@@ -1830,9 +1788,6 @@
245 "bpp", G_TYPE_INT, bpp,
246 "depth", G_TYPE_INT, depth,
247 "endianness", G_TYPE_INT, endianness, NULL);
248- if (caps && context) {
249- gst_ffmpeg_set_palette (caps, context);
250- }
251 }
252 } else if (fmt) {
253 caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-yuv",
254@@ -1857,7 +1812,7 @@
255 */
256
257 static GstCaps *
258-gst_ffmpeg_smpfmt_to_caps (enum SampleFormat sample_fmt,
259+gst_ffmpeg_smpfmt_to_caps (enum AVSampleFormat sample_fmt,
260 AVCodecContext * context, enum CodecID codec_id)
261 {
262 GstCaps *caps = NULL;
263@@ -1867,22 +1822,22 @@
264 gboolean signedness = FALSE;
265
266 switch (sample_fmt) {
267- case SAMPLE_FMT_S16:
268+ case AV_SAMPLE_FMT_S16:
269 signedness = TRUE;
270 bpp = 16;
271 break;
272
273- case SAMPLE_FMT_S32:
274+ case AV_SAMPLE_FMT_S32:
275 signedness = TRUE;
276 bpp = 32;
277 break;
278
279- case SAMPLE_FMT_FLT:
280+ case AV_SAMPLE_FMT_FLT:
281 integer = FALSE;
282 bpp = 32;
283 break;
284
285- case SAMPLE_FMT_DBL:
286+ case AV_SAMPLE_FMT_DBL:
287 integer = FALSE;
288 bpp = 64;
289 break;
290@@ -1941,12 +1896,12 @@
291 }
292 } else {
293 GstCaps *temp;
294- enum SampleFormat i;
295+ enum AVSampleFormat i;
296 AVCodecContext ctx = { 0, };
297
298 ctx.channels = -1;
299 caps = gst_caps_new_empty ();
300- for (i = 0; i <= SAMPLE_FMT_DBL; i++) {
301+ for (i = 0; i <= AV_SAMPLE_FMT_DBL; i++) {
302 temp = gst_ffmpeg_smpfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
303 if (temp != NULL) {
304 gst_caps_append (caps, temp);
305@@ -2049,9 +2004,9 @@
306 gst_structure_get_int (structure, "endianness", &endianness)) {
307 if (endianness == G_BYTE_ORDER) {
308 if (width == 32)
309- context->sample_fmt = SAMPLE_FMT_FLT;
310+ context->sample_fmt = AV_SAMPLE_FMT_FLT;
311 else if (width == 64)
312- context->sample_fmt = SAMPLE_FMT_DBL;
313+ context->sample_fmt = AV_SAMPLE_FMT_DBL;
314 }
315 }
316 } else {
317@@ -2062,9 +2017,9 @@
318 gst_structure_get_int (structure, "endianness", &endianness)) {
319 if ((endianness == G_BYTE_ORDER) && (signedness == TRUE)) {
320 if ((width == 16) && (depth == 16))
321- context->sample_fmt = SAMPLE_FMT_S16;
322+ context->sample_fmt = AV_SAMPLE_FMT_S16;
323 else if ((width == 32) && (depth == 32))
324- context->sample_fmt = SAMPLE_FMT_S32;
325+ context->sample_fmt = AV_SAMPLE_FMT_S32;
326 }
327 }
328 }
329@@ -2190,7 +2145,6 @@
330 } else {
331 if (bpp == 8) {
332 context->pix_fmt = PIX_FMT_PAL8;
333- gst_ffmpeg_get_palette (caps, context);
334 }
335 }
336 }
337@@ -2576,7 +2530,6 @@
338 switch (codec_type) {
339 case AVMEDIA_TYPE_VIDEO:
340 gst_ffmpeg_caps_to_pixfmt (caps, context, codec_id == CODEC_ID_RAWVIDEO);
341- gst_ffmpeg_get_palette (caps, context);
342 break;
343 case AVMEDIA_TYPE_AUDIO:
344 gst_ffmpeg_caps_to_smpfmt (caps, context, FALSE);
345diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.orig
346--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.orig 1970-01-01 01:00:00.000000000 +0100
347+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.orig 2014-08-08 15:30:34.006867097 +0200
348@@ -0,0 +1,3447 @@
349+/* GStreamer
350+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
351+ * This file:
352+ * Copyright (c) 2002-2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
353+ *
354+ * This library is free software; you can redistribute it and/or
355+ * modify it under the terms of the GNU Library General Public
356+ * License as published by the Free Software Foundation; either
357+ * version 2 of the License, or (at your option) any later version.
358+ *
359+ * This library is distributed in the hope that it will be useful,
360+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
361+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
362+ * Library General Public License for more details.
363+ *
364+ * You should have received a copy of the GNU Library General Public
365+ * License along with this library; if not, write to the
366+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
367+ * Boston, MA 02111-1307, USA.
368+ */
369+
370+#ifdef HAVE_CONFIG_H
371+#include "config.h"
372+#endif
373+#include <gst/gst.h>
374+#ifdef HAVE_FFMPEG_UNINSTALLED
375+#include <avcodec.h>
376+#include <channel_layout.h>>
377+#else
378+#include <libavcodec/avcodec.h>
379+#include <libavutil/channel_layout.h>
380+#endif
381+#include <string.h>
382+
383+#include "gstffmpeg.h"
384+#include "gstffmpegcodecmap.h"
385+
386+#include <gst/pbutils/codec-utils.h>
387+
388+/*
389+ * Read a palette from a caps.
390+ */
391+
392+static void
393+gst_ffmpeg_get_palette (const GstCaps * caps, AVCodecContext * context)
394+{
395+ GstStructure *str = gst_caps_get_structure (caps, 0);
396+ const GValue *palette_v;
397+ const GstBuffer *palette;
398+
399+ /* do we have a palette? */
400+ if ((palette_v = gst_structure_get_value (str, "palette_data")) && context) {
401+ palette = gst_value_get_buffer (palette_v);
402+ if (GST_BUFFER_SIZE (palette) >= AVPALETTE_SIZE) {
403+ if (context->palctrl)
404+ av_free (context->palctrl);
405+ context->palctrl = av_malloc (sizeof (AVPaletteControl));
406+ context->palctrl->palette_changed = 1;
407+ memcpy (context->palctrl->palette, GST_BUFFER_DATA (palette),
408+ AVPALETTE_SIZE);
409+ }
410+ }
411+}
412+
413+static void
414+gst_ffmpeg_set_palette (GstCaps * caps, AVCodecContext * context)
415+{
416+ if (context->palctrl) {
417+ GstBuffer *palette = gst_buffer_new_and_alloc (AVPALETTE_SIZE);
418+
419+ memcpy (GST_BUFFER_DATA (palette), context->palctrl->palette,
420+ AVPALETTE_SIZE);
421+ gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, palette, NULL);
422+ }
423+}
424+
425+/* IMPORTANT: Keep this sorted by the ffmpeg channel masks */
426+static const struct
427+{
428+ guint64 ff;
429+ GstAudioChannelPosition gst;
430+} _ff_to_gst_layout[] = {
431+ {
432+ AV_CH_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
433+ AV_CH_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
434+ AV_CH_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
435+ AV_CH_LOW_FREQUENCY, GST_AUDIO_CHANNEL_POSITION_LFE}, {
436+ AV_CH_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, {
437+ AV_CH_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
438+ AV_CH_FRONT_LEFT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, {
439+ AV_CH_FRONT_RIGHT_OF_CENTER, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, {
440+ AV_CH_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
441+ AV_CH_SIDE_LEFT, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, {
442+ AV_CH_SIDE_RIGHT, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, {
443+ AV_CH_TOP_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
444+ AV_CH_TOP_FRONT_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
445+ AV_CH_TOP_FRONT_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
446+ AV_CH_TOP_FRONT_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
447+ AV_CH_TOP_BACK_LEFT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
448+ AV_CH_TOP_BACK_CENTER, GST_AUDIO_CHANNEL_POSITION_NONE}, {
449+ AV_CH_TOP_BACK_RIGHT, GST_AUDIO_CHANNEL_POSITION_NONE}, {
450+ AV_CH_STEREO_LEFT, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, {
451+ AV_CH_STEREO_RIGHT, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
452+};
453+
454+static GstAudioChannelPosition *
455+gst_ff_channel_layout_to_gst (guint64 channel_layout, guint channels)
456+{
457+ guint nchannels = 0, i, j;
458+ GstAudioChannelPosition *pos = NULL;
459+ gboolean none_layout = FALSE;
460+
461+ for (i = 0; i < 64; i++) {
462+ if ((channel_layout & (G_GUINT64_CONSTANT (1) << i)) != 0) {
463+ nchannels++;
464+ }
465+ }
466+
467+ if (channel_layout == 0) {
468+ nchannels = channels;
469+ none_layout = TRUE;
470+ }
471+
472+ if (nchannels != channels) {
473+ GST_ERROR ("Number of channels is different (%u != %u)", channels,
474+ nchannels);
475+ return NULL;
476+ }
477+
478+ pos = g_new (GstAudioChannelPosition, nchannels);
479+
480+ for (i = 0, j = 0; i < G_N_ELEMENTS (_ff_to_gst_layout); i++) {
481+ if ((channel_layout & _ff_to_gst_layout[i].ff) != 0) {
482+ pos[j++] = _ff_to_gst_layout[i].gst;
483+
484+ if (_ff_to_gst_layout[i].gst == GST_AUDIO_CHANNEL_POSITION_NONE)
485+ none_layout = TRUE;
486+ }
487+ }
488+
489+ if (j != nchannels) {
490+ GST_WARNING ("Unknown channels in channel layout - assuming NONE layout");
491+ none_layout = TRUE;
492+ }
493+
494+ if (!none_layout && !gst_audio_check_channel_positions (pos, nchannels)) {
495+ GST_ERROR ("Invalid channel layout %" G_GUINT64_FORMAT
496+ " - assuming NONE layout", channel_layout);
497+ none_layout = TRUE;
498+ }
499+
500+ if (none_layout) {
501+ if (nchannels == 1) {
502+ pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_MONO;
503+ } else if (nchannels == 2) {
504+ pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
505+ pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
506+ } else if (channel_layout == 0) {
507+ g_free (pos);
508+ pos = NULL;
509+ } else {
510+ for (i = 0; i < nchannels; i++)
511+ pos[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
512+ }
513+ }
514+
515+ if (nchannels == 1 && pos[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER) {
516+ GST_DEBUG ("mono common case; won't set channel positions");
517+ g_free (pos);
518+ pos = NULL;
519+ } else if (nchannels == 2 && pos[0] == GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT
520+ && pos[1] == GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT) {
521+ GST_DEBUG ("stereo common case; won't set channel positions");
522+ g_free (pos);
523+ pos = NULL;
524+ }
525+
526+ return pos;
527+}
528+
529+/* this macro makes a caps width fixed or unfixed width/height
530+ * properties depending on whether we've got a context.
531+ *
532+ * See below for why we use this.
533+ *
534+ * We should actually do this stuff at the end, like in riff-media.c,
535+ * but I'm too lazy today. Maybe later.
536+ */
537+static GstCaps *
538+gst_ff_vid_caps_new (AVCodecContext * context, enum CodecID codec_id,
539+ const char *mimetype, const char *fieldname, ...)
540+{
541+ GstStructure *structure = NULL;
542+ GstCaps *caps = NULL;
543+ va_list var_args;
544+ gint i;
545+
546+ GST_LOG ("context:%p, codec_id:%d, mimetype:%s", context, codec_id, mimetype);
547+
548+ /* fixed, non probing context */
549+ if (context != NULL && context->width != -1) {
550+ gint num, denom;
551+
552+ caps = gst_caps_new_simple (mimetype,
553+ "width", G_TYPE_INT, context->width,
554+ "height", G_TYPE_INT, context->height, NULL);
555+
556+ num = context->time_base.den / context->ticks_per_frame;
557+ denom = context->time_base.num;
558+
559+ if (!denom) {
560+ GST_LOG ("invalid framerate: %d/0, -> %d/1", num, num);
561+ denom = 1;
562+ }
563+ if (gst_util_fraction_compare (num, denom, 1000, 1) > 0) {
564+ GST_LOG ("excessive framerate: %d/%d, -> 0/1", num, denom);
565+ num = 0;
566+ denom = 1;
567+ }
568+ GST_LOG ("setting framerate: %d/%d", num, denom);
569+ gst_caps_set_simple (caps,
570+ "framerate", GST_TYPE_FRACTION, num, denom, NULL);
571+ } else {
572+ /* so we are after restricted caps in this case */
573+ switch (codec_id) {
574+ case CODEC_ID_H261:
575+ {
576+ caps = gst_caps_new_simple (mimetype,
577+ "width", G_TYPE_INT, 352,
578+ "height", G_TYPE_INT, 288,
579+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
580+ gst_caps_append (caps, gst_caps_new_simple (mimetype,
581+ "width", G_TYPE_INT, 176,
582+ "height", G_TYPE_INT, 144,
583+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL));
584+ break;
585+ }
586+ case CODEC_ID_H263:
587+ {
588+ /* 128x96, 176x144, 352x288, 704x576, and 1408x1152. slightly reordered
589+ * because we want automatic negotiation to go as close to 320x240 as
590+ * possible. */
591+ const static gint widths[] = { 352, 704, 176, 1408, 128 };
592+ const static gint heights[] = { 288, 576, 144, 1152, 96 };
593+ GstCaps *temp;
594+ gint n_sizes = G_N_ELEMENTS (widths);
595+
596+ caps = gst_caps_new_empty ();
597+ for (i = 0; i < n_sizes; i++) {
598+ temp = gst_caps_new_simple (mimetype,
599+ "width", G_TYPE_INT, widths[i],
600+ "height", G_TYPE_INT, heights[i],
601+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
602+
603+ gst_caps_append (caps, temp);
604+ }
605+ break;
606+ }
607+ case CODEC_ID_DVVIDEO:
608+ {
609+ static struct
610+ {
611+ guint32 csp;
612+ gint width, height;
613+ gint par_n, par_d;
614+ gint framerate_n, framerate_d;
615+ } profiles[] = {
616+ {
617+ GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 480, 10, 11, 30000, 1001}, {
618+ GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 480, 40, 33, 30000, 1001}, {
619+ GST_MAKE_FOURCC ('I', '4', '2', '0'), 720, 576, 59, 54, 25, 1}, {
620+ GST_MAKE_FOURCC ('I', '4', '2', '0'), 720, 576, 118, 81, 25, 1}, {
621+ GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 576, 59, 54, 25, 1}, {
622+ GST_MAKE_FOURCC ('Y', '4', '1', 'B'), 720, 576, 118, 81, 25, 1}
623+ };
624+ GstCaps *temp;
625+ gint n_sizes = G_N_ELEMENTS (profiles);
626+
627+ caps = gst_caps_new_empty ();
628+ for (i = 0; i < n_sizes; i++) {
629+ temp = gst_caps_new_simple (mimetype,
630+ "width", G_TYPE_INT, profiles[i].width,
631+ "height", G_TYPE_INT, profiles[i].height,
632+ "framerate", GST_TYPE_FRACTION, profiles[i].framerate_n,
633+ profiles[i].framerate_d, "pixel-aspect-ratio", GST_TYPE_FRACTION,
634+ profiles[i].par_n, profiles[i].par_d, NULL);
635+
636+ gst_caps_append (caps, temp);
637+ }
638+ break;
639+ }
640+ case CODEC_ID_DNXHD:
641+ {
642+ caps = gst_caps_new_simple (mimetype,
643+ "width", G_TYPE_INT, 1920,
644+ "height", G_TYPE_INT, 1080,
645+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
646+ gst_caps_append (caps, gst_caps_new_simple (mimetype,
647+ "width", G_TYPE_INT, 1280,
648+ "height", G_TYPE_INT, 720,
649+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL));
650+ break;
651+ }
652+ default:
653+ break;
654+ }
655+ }
656+
657+ /* no fixed caps or special restrictions applied;
658+ * default unfixed setting */
659+ if (!caps) {
660+ GST_DEBUG ("Creating default caps");
661+ caps = gst_caps_new_simple (mimetype,
662+ "width", GST_TYPE_INT_RANGE, 16, 4096,
663+ "height", GST_TYPE_INT_RANGE, 16, 4096,
664+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
665+ }
666+
667+ for (i = 0; i < gst_caps_get_size (caps); i++) {
668+ va_start (var_args, fieldname);
669+ structure = gst_caps_get_structure (caps, i);
670+ gst_structure_set_valist (structure, fieldname, var_args);
671+ va_end (var_args);
672+ }
673+
674+ return caps;
675+}
676+
677+/* same for audio - now with channels/sample rate
678+ */
679+static GstCaps *
680+gst_ff_aud_caps_new (AVCodecContext * context, enum CodecID codec_id,
681+ const char *mimetype, const char *fieldname, ...)
682+{
683+ GstCaps *caps = NULL;
684+ GstStructure *structure = NULL;
685+ gint i;
686+ va_list var_args;
687+
688+ /* fixed, non-probing context */
689+ if (context != NULL && context->channels != -1) {
690+ GstAudioChannelPosition *pos;
691+ guint64 channel_layout = context->channel_layout;
692+
693+ if (channel_layout == 0) {
694+ const guint64 default_channel_set[] = {
695+ 0, 0, AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_5POINT0,
696+ AV_CH_LAYOUT_5POINT1, 0, AV_CH_LAYOUT_7POINT1
697+ };
698+
699+ switch (codec_id) {
700+ case CODEC_ID_EAC3:
701+ case CODEC_ID_AC3:
702+ case CODEC_ID_DTS:
703+ if (context->channels > 0
704+ && context->channels < G_N_ELEMENTS (default_channel_set))
705+ channel_layout = default_channel_set[context->channels - 1];
706+ break;
707+ default:
708+ break;
709+ }
710+ }
711+
712+ caps = gst_caps_new_simple (mimetype,
713+ "rate", G_TYPE_INT, context->sample_rate,
714+ "channels", G_TYPE_INT, context->channels, NULL);
715+
716+ pos = gst_ff_channel_layout_to_gst (channel_layout, context->channels);
717+ if (pos != NULL) {
718+ gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
719+ g_free (pos);
720+ }
721+ } else {
722+ gint maxchannels = 2;
723+ const gint *rates = NULL;
724+ gint n_rates = 0;
725+
726+ /* so we must be after restricted caps in this case */
727+ switch (codec_id) {
728+ case CODEC_ID_AAC:
729+ case CODEC_ID_AAC_LATM:
730+ case CODEC_ID_DTS:
731+ maxchannels = 6;
732+ break;
733+ case CODEC_ID_MP2:
734+ {
735+ const static gint l_rates[] =
736+ { 48000, 44100, 32000, 24000, 22050, 16000 };
737+ n_rates = G_N_ELEMENTS (l_rates);
738+ rates = l_rates;
739+ break;
740+ }
741+ case CODEC_ID_EAC3:
742+ case CODEC_ID_AC3:
743+ {
744+ const static gint l_rates[] = { 48000, 44100, 32000 };
745+ maxchannels = 6;
746+ n_rates = G_N_ELEMENTS (l_rates);
747+ rates = l_rates;
748+ break;
749+ }
750+ case CODEC_ID_ADPCM_G722:
751+ {
752+ const static gint l_rates[] = { 16000 };
753+ n_rates = G_N_ELEMENTS (l_rates);
754+ rates = l_rates;
755+ maxchannels = 1;
756+ break;
757+ }
758+ case CODEC_ID_ADPCM_G726:
759+ {
760+ const static gint l_rates[] = { 8000 };
761+ n_rates = G_N_ELEMENTS (l_rates);
762+ rates = l_rates;
763+ maxchannels = 1;
764+ break;
765+ }
766+ case CODEC_ID_ADPCM_SWF:
767+ {
768+ const static gint l_rates[] = { 11025, 22050, 44100 };
769+ n_rates = G_N_ELEMENTS (l_rates);
770+ rates = l_rates;
771+ break;
772+ }
773+ case CODEC_ID_ROQ_DPCM:
774+ {
775+ const static gint l_rates[] = { 22050 };
776+ n_rates = G_N_ELEMENTS (l_rates);
777+ rates = l_rates;
778+ break;
779+ }
780+ case CODEC_ID_AMR_NB:
781+ {
782+ const static gint l_rates[] = { 8000 };
783+ maxchannels = 1;
784+ n_rates = G_N_ELEMENTS (l_rates);
785+ rates = l_rates;
786+ break;
787+ }
788+ case CODEC_ID_AMR_WB:
789+ {
790+ const static gint l_rates[] = { 16000 };
791+ maxchannels = 1;
792+ n_rates = G_N_ELEMENTS (l_rates);
793+ rates = l_rates;
794+ break;
795+ }
796+ default:
797+ break;
798+ }
799+
800+ /* TODO: handle context->channel_layouts here to set
801+ * the list of channel layouts supported by the encoder.
802+ * Unfortunately no encoder uses this yet....
803+ */
804+ /* regardless of encode/decode, open up channels if applicable */
805+ /* Until decoders/encoders expose the maximum number of channels
806+ * they support, we whitelist them here. */
807+ switch (codec_id) {
808+ case CODEC_ID_WMAPRO:
809+ case CODEC_ID_TRUEHD:
810+ maxchannels = 8;
811+ break;
812+ default:
813+ break;
814+ }
815+
816+ if (maxchannels == 1)
817+ caps = gst_caps_new_simple (mimetype,
818+ "channels", G_TYPE_INT, maxchannels, NULL);
819+ else
820+ caps = gst_caps_new_simple (mimetype,
821+ "channels", GST_TYPE_INT_RANGE, 1, maxchannels, NULL);
822+ if (n_rates) {
823+ GValue list = { 0, };
824+ GstStructure *structure;
825+
826+ g_value_init (&list, GST_TYPE_LIST);
827+ for (i = 0; i < n_rates; i++) {
828+ GValue v = { 0, };
829+
830+ g_value_init (&v, G_TYPE_INT);
831+ g_value_set_int (&v, rates[i]);
832+ gst_value_list_append_value (&list, &v);
833+ g_value_unset (&v);
834+ }
835+ structure = gst_caps_get_structure (caps, 0);
836+ gst_structure_set_value (structure, "rate", &list);
837+ g_value_unset (&list);
838+ } else
839+ gst_caps_set_simple (caps, "rate", GST_TYPE_INT_RANGE, 4000, 96000, NULL);
840+ }
841+
842+ for (i = 0; i < gst_caps_get_size (caps); i++) {
843+ va_start (var_args, fieldname);
844+ structure = gst_caps_get_structure (caps, i);
845+ gst_structure_set_valist (structure, fieldname, var_args);
846+ va_end (var_args);
847+ }
848+
849+ return caps;
850+}
851+
852+/* Convert a FFMPEG codec ID and optional AVCodecContext
853+ * to a GstCaps. If the context is ommitted, no fixed values
854+ * for video/audio size will be included in the GstCaps
855+ *
856+ * CodecID is primarily meant for compressed data GstCaps!
857+ *
858+ * encode is a special parameter. gstffmpegdec will say
859+ * FALSE, gstffmpegenc will say TRUE. The output caps
860+ * depends on this, in such a way that it will be very
861+ * specific, defined, fixed and correct caps for encoders,
862+ * yet very wide, "forgiving" caps for decoders. Example
863+ * for mp3: decode: audio/mpeg,mpegversion=1,layer=[1-3]
864+ * but encode: audio/mpeg,mpegversion=1,layer=3,bitrate=x,
865+ * rate=x,channels=x.
866+ */
867+
868+GstCaps *
869+gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
870+ AVCodecContext * context, gboolean encode)
871+{
872+ GstCaps *caps = NULL;
873+ gboolean buildcaps = FALSE;
874+
875+ GST_LOG ("codec_id:%d, context:%p, encode:%d", codec_id, context, encode);
876+
877+ switch (codec_id) {
878+ case CODEC_ID_MPEG1VIDEO:
879+ /* FIXME: bitrate */
880+ caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
881+ "mpegversion", G_TYPE_INT, 1,
882+ "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
883+ break;
884+
885+ case CODEC_ID_MPEG2VIDEO:
886+ if (encode) {
887+ /* FIXME: bitrate */
888+ caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
889+ "mpegversion", G_TYPE_INT, 2,
890+ "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
891+ } else {
892+ /* decode both MPEG-1 and MPEG-2; width/height/fps are all in
893+ * the MPEG video stream headers, so may be omitted from caps. */
894+ caps = gst_caps_new_simple ("video/mpeg",
895+ "mpegversion", GST_TYPE_INT_RANGE, 1, 2,
896+ "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
897+ }
898+ break;
899+
900+ case CODEC_ID_MPEG2VIDEO_XVMC:
901+ /* this is a special ID - don't need it in GStreamer, I think */
902+ break;
903+
904+ case CODEC_ID_H263:
905+ if (encode) {
906+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h263",
907+ "variant", G_TYPE_STRING, "itu",
908+ "h263version", G_TYPE_STRING, "h263", NULL);
909+ } else {
910+ /* don't pass codec_id, we can decode other variants with the H263
911+ * decoder that don't have specific size requirements
912+ */
913+ caps = gst_ff_vid_caps_new (context, CODEC_ID_NONE, "video/x-h263",
914+ "variant", G_TYPE_STRING, "itu", NULL);
915+ }
916+ break;
917+
918+ case CODEC_ID_H263P:
919+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h263",
920+ "variant", G_TYPE_STRING, "itu",
921+ "h263version", G_TYPE_STRING, "h263p", NULL);
922+ if (encode && context) {
923+
924+ gst_caps_set_simple (caps,
925+ "annex-f", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_4MV,
926+ "annex-j", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_LOOP_FILTER,
927+ "annex-i", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_AC_PRED,
928+ "annex-t", G_TYPE_BOOLEAN, context->flags & CODEC_FLAG_AC_PRED,
929+ NULL);
930+ }
931+ break;
932+
933+ case CODEC_ID_H263I:
934+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-intel-h263",
935+ "variant", G_TYPE_STRING, "intel", NULL);
936+ break;
937+
938+ case CODEC_ID_H261:
939+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h261", NULL);
940+ break;
941+
942+ case CODEC_ID_RV10:
943+ case CODEC_ID_RV20:
944+ case CODEC_ID_RV30:
945+ case CODEC_ID_RV40:
946+ {
947+ gint version;
948+
949+ switch (codec_id) {
950+ case CODEC_ID_RV40:
951+ version = 4;
952+ break;
953+ case CODEC_ID_RV30:
954+ version = 3;
955+ break;
956+ case CODEC_ID_RV20:
957+ version = 2;
958+ break;
959+ default:
960+ version = 1;
961+ break;
962+ }
963+
964+ /* FIXME: context->sub_id must be filled in during decoding */
965+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-pn-realvideo",
966+ "systemstream", G_TYPE_BOOLEAN, FALSE,
967+ "rmversion", G_TYPE_INT, version, NULL);
968+ if (context) {
969+ gst_caps_set_simple (caps, "format", G_TYPE_INT, context->sub_id, NULL);
970+ if (context->extradata_size >= 8) {
971+ gst_caps_set_simple (caps,
972+ "subformat", G_TYPE_INT, GST_READ_UINT32_BE (context->extradata),
973+ NULL);
974+ }
975+ }
976+ }
977+ break;
978+
979+ case CODEC_ID_MP1:
980+ /* FIXME: bitrate */
981+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
982+ "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 1, NULL);
983+ break;
984+
985+ case CODEC_ID_MP2:
986+ /* FIXME: bitrate */
987+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
988+ "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 2, NULL);
989+ break;
990+
991+ case CODEC_ID_MP3:
992+ if (encode) {
993+ /* FIXME: bitrate */
994+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
995+ "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
996+ } else {
997+ /* Decodes MPEG-1 layer 1/2/3. Samplerate, channels et al are
998+ * in the MPEG audio header, so may be omitted from caps. */
999+ caps = gst_caps_new_simple ("audio/mpeg",
1000+ "mpegversion", G_TYPE_INT, 1,
1001+ "layer", GST_TYPE_INT_RANGE, 1, 3, NULL);
1002+ }
1003+ break;
1004+
1005+ case CODEC_ID_MUSEPACK7:
1006+ caps =
1007+ gst_ff_aud_caps_new (context, codec_id,
1008+ "audio/x-ffmpeg-parsed-musepack", "streamversion", G_TYPE_INT, 7,
1009+ NULL);
1010+ break;
1011+
1012+ case CODEC_ID_MUSEPACK8:
1013+ caps =
1014+ gst_ff_aud_caps_new (context, codec_id,
1015+ "audio/x-ffmpeg-parsed-musepack", "streamversion", G_TYPE_INT, 8,
1016+ NULL);
1017+ break;
1018+
1019+ case CODEC_ID_AC3:
1020+ /* FIXME: bitrate */
1021+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-ac3", NULL);
1022+ break;
1023+
1024+ case CODEC_ID_EAC3:
1025+ /* FIXME: bitrate */
1026+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-eac3", NULL);
1027+ break;
1028+
1029+ case CODEC_ID_TRUEHD:
1030+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-true-hd", NULL);
1031+ break;
1032+
1033+ case CODEC_ID_ATRAC1:
1034+ caps =
1035+ gst_ff_aud_caps_new (context, codec_id, "audio/x-vnd.sony.atrac1",
1036+ NULL);
1037+ break;
1038+
1039+ case CODEC_ID_ATRAC3:
1040+ caps =
1041+ gst_ff_aud_caps_new (context, codec_id, "audio/x-vnd.sony.atrac3",
1042+ NULL);
1043+ break;
1044+
1045+ case CODEC_ID_DTS:
1046+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dts", NULL);
1047+ break;
1048+
1049+ case CODEC_ID_APE:
1050+ caps =
1051+ gst_ff_aud_caps_new (context, codec_id, "audio/x-ffmpeg-parsed-ape",
1052+ NULL);
1053+ if (context) {
1054+ gst_caps_set_simple (caps,
1055+ "depth", G_TYPE_INT, context->bits_per_coded_sample, NULL);
1056+ }
1057+ break;
1058+
1059+ case CODEC_ID_MLP:
1060+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mlp", NULL);
1061+ break;
1062+
1063+ case CODEC_ID_IMC:
1064+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-imc", NULL);
1065+ break;
1066+
1067+ /* MJPEG is normal JPEG, Motion-JPEG and Quicktime MJPEG-A. MJPEGB
1068+ * is Quicktime's MJPEG-B. LJPEG is lossless JPEG. I don't know what
1069+ * sp5x is, but it's apparently something JPEG... We don't separate
1070+ * between those in GStreamer. Should we (at least between MJPEG,
1071+ * MJPEG-B and sp5x decoding...)? */
1072+ case CODEC_ID_MJPEG:
1073+ case CODEC_ID_LJPEG:
1074+ caps = gst_ff_vid_caps_new (context, codec_id, "image/jpeg", NULL);
1075+ break;
1076+
1077+ case CODEC_ID_SP5X:
1078+ caps = gst_ff_vid_caps_new (context, codec_id, "video/sp5x", NULL);
1079+ break;
1080+
1081+ case CODEC_ID_MJPEGB:
1082+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mjpeg-b", NULL);
1083+ break;
1084+
1085+ case CODEC_ID_MPEG4:
1086+ if (encode && context != NULL) {
1087+ /* I'm not exactly sure what ffmpeg outputs... ffmpeg itself uses
1088+ * the AVI fourcc 'DIVX', but 'mp4v' for Quicktime... */
1089+ switch (context->codec_tag) {
1090+ case GST_MAKE_FOURCC ('D', 'I', 'V', 'X'):
1091+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-divx",
1092+ "divxversion", G_TYPE_INT, 5, NULL);
1093+ break;
1094+ case GST_MAKE_FOURCC ('m', 'p', '4', 'v'):
1095+ default:
1096+ /* FIXME: bitrate */
1097+ caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
1098+ "systemstream", G_TYPE_BOOLEAN, FALSE,
1099+ "mpegversion", G_TYPE_INT, 4, NULL);
1100+ break;
1101+ }
1102+ } else {
1103+ /* The trick here is to separate xvid, divx, mpeg4, 3ivx et al */
1104+ caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
1105+ "mpegversion", G_TYPE_INT, 4,
1106+ "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
1107+ if (encode) {
1108+ gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
1109+ "video/x-divx", "divxversion", G_TYPE_INT, 5, NULL));
1110+ } else {
1111+ gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
1112+ "video/x-divx", "divxversion", GST_TYPE_INT_RANGE, 4, 5,
1113+ NULL));
1114+ gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
1115+ "video/x-xvid", NULL));
1116+ gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
1117+ "video/x-3ivx", NULL));
1118+ }
1119+ }
1120+ break;
1121+
1122+ case CODEC_ID_RAWVIDEO:
1123+ caps =
1124+ gst_ffmpeg_codectype_to_caps (AVMEDIA_TYPE_VIDEO, context, codec_id,
1125+ encode);
1126+ break;
1127+
1128+ case CODEC_ID_MSMPEG4V1:
1129+ case CODEC_ID_MSMPEG4V2:
1130+ case CODEC_ID_MSMPEG4V3:
1131+ {
1132+ gint version = 41 + codec_id - CODEC_ID_MSMPEG4V1;
1133+
1134+ /* encode-FIXME: bitrate */
1135+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-msmpeg",
1136+ "msmpegversion", G_TYPE_INT, version, NULL);
1137+ if (!encode && codec_id == CODEC_ID_MSMPEG4V3) {
1138+ gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
1139+ "video/x-divx", "divxversion", G_TYPE_INT, 3, NULL));
1140+ }
1141+ }
1142+ break;
1143+
1144+ case CODEC_ID_WMV1:
1145+ case CODEC_ID_WMV2:
1146+ {
1147+ gint version = (codec_id == CODEC_ID_WMV1) ? 1 : 2;
1148+
1149+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
1150+ "wmvversion", G_TYPE_INT, version, NULL);
1151+ }
1152+ break;
1153+
1154+ case CODEC_ID_FLV1:
1155+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-flash-video",
1156+ "flvversion", G_TYPE_INT, 1, NULL);
1157+ break;
1158+
1159+ case CODEC_ID_SVQ1:
1160+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-svq",
1161+ "svqversion", G_TYPE_INT, 1, NULL);
1162+ break;
1163+
1164+ case CODEC_ID_SVQ3:
1165+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-svq",
1166+ "svqversion", G_TYPE_INT, 3, NULL);
1167+ break;
1168+
1169+ case CODEC_ID_DVAUDIO:
1170+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dv", NULL);
1171+ break;
1172+
1173+ case CODEC_ID_DVVIDEO:
1174+ {
1175+ if (encode && context) {
1176+ guint32 fourcc;
1177+
1178+ switch (context->pix_fmt) {
1179+ case PIX_FMT_YUYV422:
1180+ fourcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
1181+ break;
1182+ case PIX_FMT_YUV420P:
1183+ fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
1184+ break;
1185+ case PIX_FMT_YUVA420P:
1186+ fourcc = GST_MAKE_FOURCC ('A', '4', '2', '0');
1187+ break;
1188+ case PIX_FMT_YUV411P:
1189+ fourcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
1190+ break;
1191+ case PIX_FMT_YUV422P:
1192+ fourcc = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
1193+ break;
1194+ case PIX_FMT_YUV410P:
1195+ fourcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
1196+ break;
1197+ default:
1198+ GST_WARNING
1199+ ("Couldnt' find fourcc for pixfmt %d, defaulting to I420",
1200+ context->pix_fmt);
1201+ fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
1202+ break;
1203+ }
1204+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dv",
1205+ "systemstream", G_TYPE_BOOLEAN, FALSE,
1206+ "format", GST_TYPE_FOURCC, fourcc, NULL);
1207+ } else {
1208+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dv",
1209+ "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
1210+ }
1211+ }
1212+ break;
1213+
1214+ case CODEC_ID_WMAV1:
1215+ case CODEC_ID_WMAV2:
1216+ {
1217+ gint version = (codec_id == CODEC_ID_WMAV1) ? 1 : 2;
1218+
1219+ if (context) {
1220+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
1221+ "wmaversion", G_TYPE_INT, version,
1222+ "block_align", G_TYPE_INT, context->block_align,
1223+ "bitrate", G_TYPE_INT, context->bit_rate, NULL);
1224+ } else {
1225+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
1226+ "wmaversion", G_TYPE_INT, version,
1227+ "block_align", GST_TYPE_INT_RANGE, 0, G_MAXINT,
1228+ "bitrate", GST_TYPE_INT_RANGE, 0, G_MAXINT, NULL);
1229+ }
1230+ }
1231+ break;
1232+ case CODEC_ID_WMAPRO:
1233+ {
1234+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
1235+ "wmaversion", G_TYPE_INT, 3, NULL);
1236+ break;
1237+ }
1238+
1239+ case CODEC_ID_WMAVOICE:
1240+ {
1241+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wms", NULL);
1242+ break;
1243+ }
1244+
1245+ case CODEC_ID_MACE3:
1246+ case CODEC_ID_MACE6:
1247+ {
1248+ gint version = (codec_id == CODEC_ID_MACE3) ? 3 : 6;
1249+
1250+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mace",
1251+ "maceversion", G_TYPE_INT, version, NULL);
1252+ }
1253+ break;
1254+
1255+ case CODEC_ID_HUFFYUV:
1256+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-huffyuv", NULL);
1257+ if (context) {
1258+ gst_caps_set_simple (caps,
1259+ "bpp", G_TYPE_INT, context->bits_per_coded_sample, NULL);
1260+ }
1261+ break;
1262+
1263+ case CODEC_ID_CYUV:
1264+ caps =
1265+ gst_ff_vid_caps_new (context, codec_id, "video/x-compressed-yuv",
1266+ NULL);
1267+ break;
1268+
1269+ case CODEC_ID_H264:
1270+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h264", NULL);
1271+ break;
1272+
1273+ case CODEC_ID_INDEO5:
1274+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
1275+ "indeoversion", G_TYPE_INT, 5, NULL);
1276+ break;
1277+
1278+ case CODEC_ID_INDEO3:
1279+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
1280+ "indeoversion", G_TYPE_INT, 3, NULL);
1281+ break;
1282+
1283+ case CODEC_ID_INDEO2:
1284+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
1285+ "indeoversion", G_TYPE_INT, 2, NULL);
1286+ break;
1287+
1288+ case CODEC_ID_FLASHSV:
1289+ caps =
1290+ gst_ff_vid_caps_new (context, codec_id, "video/x-flash-screen", NULL);
1291+ break;
1292+
1293+ case CODEC_ID_VP3:
1294+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp3", NULL);
1295+ break;
1296+
1297+ case CODEC_ID_VP5:
1298+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp5", NULL);
1299+ break;
1300+
1301+ case CODEC_ID_VP6:
1302+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6", NULL);
1303+ break;
1304+
1305+ case CODEC_ID_VP6F:
1306+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6-flash", NULL);
1307+ break;
1308+
1309+ case CODEC_ID_VP6A:
1310+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6-alpha", NULL);
1311+ break;
1312+
1313+ case CODEC_ID_VP8:
1314+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp8", NULL);
1315+ break;
1316+
1317+ case CODEC_ID_THEORA:
1318+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-theora", NULL);
1319+ break;
1320+
1321+ case CODEC_ID_AAC:
1322+ {
1323+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg", NULL);
1324+
1325+ if (!encode) {
1326+ GValue arr = { 0, };
1327+ GValue item = { 0, };
1328+
1329+ g_value_init (&arr, GST_TYPE_LIST);
1330+ g_value_init (&item, G_TYPE_INT);
1331+ g_value_set_int (&item, 2);
1332+ gst_value_list_append_value (&arr, &item);
1333+ g_value_set_int (&item, 4);
1334+ gst_value_list_append_value (&arr, &item);
1335+ g_value_unset (&item);
1336+
1337+ gst_caps_set_value (caps, "mpegversion", &arr);
1338+ g_value_unset (&arr);
1339+
1340+ g_value_init (&arr, GST_TYPE_LIST);
1341+ g_value_init (&item, G_TYPE_STRING);
1342+ g_value_set_string (&item, "raw");
1343+ gst_value_list_append_value (&arr, &item);
1344+ g_value_set_string (&item, "adts");
1345+ gst_value_list_append_value (&arr, &item);
1346+ g_value_set_string (&item, "adif");
1347+ gst_value_list_append_value (&arr, &item);
1348+ g_value_unset (&item);
1349+
1350+ gst_caps_set_value (caps, "stream-format", &arr);
1351+ g_value_unset (&arr);
1352+ } else {
1353+ gst_caps_set_simple (caps, "mpegversion", G_TYPE_INT, 4,
1354+ "stream-format", G_TYPE_STRING, "raw",
1355+ "base-profile", G_TYPE_STRING, "lc", NULL);
1356+
1357+ if (context && context->extradata_size > 0)
1358+ gst_codec_utils_aac_caps_set_level_and_profile (caps,
1359+ context->extradata, context->extradata_size);
1360+ }
1361+
1362+ break;
1363+ }
1364+ case CODEC_ID_AAC_LATM: /* LATM/LOAS AAC syntax */
1365+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
1366+ "mpegversion", G_TYPE_INT, 4, "stream-format", G_TYPE_STRING, "loas",
1367+ NULL);
1368+ break;
1369+
1370+ case CODEC_ID_ASV1:
1371+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-asus",
1372+ "asusversion", G_TYPE_INT, 1, NULL);
1373+ break;
1374+ case CODEC_ID_ASV2:
1375+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-asus",
1376+ "asusversion", G_TYPE_INT, 2, NULL);
1377+ break;
1378+
1379+ case CODEC_ID_FFV1:
1380+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ffv",
1381+ "ffvversion", G_TYPE_INT, 1, NULL);
1382+ break;
1383+
1384+ case CODEC_ID_4XM:
1385+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-4xm", NULL);
1386+ break;
1387+
1388+ case CODEC_ID_XAN_WC3:
1389+ case CODEC_ID_XAN_WC4:
1390+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-xan",
1391+ "wcversion", G_TYPE_INT, 3 - CODEC_ID_XAN_WC3 + codec_id, NULL);
1392+ break;
1393+
1394+ case CODEC_ID_CLJR:
1395+ caps =
1396+ gst_ff_vid_caps_new (context, codec_id,
1397+ "video/x-cirrus-logic-accupak", NULL);
1398+ break;
1399+
1400+ case CODEC_ID_FRAPS:
1401+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-fraps", NULL);
1402+ break;
1403+
1404+ case CODEC_ID_MDEC:
1405+ case CODEC_ID_ROQ:
1406+ case CODEC_ID_INTERPLAY_VIDEO:
1407+ buildcaps = TRUE;
1408+ break;
1409+
1410+ case CODEC_ID_VCR1:
1411+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ati-vcr",
1412+ "vcrversion", G_TYPE_INT, 1, NULL);
1413+ break;
1414+
1415+ case CODEC_ID_RPZA:
1416+ caps =
1417+ gst_ff_vid_caps_new (context, codec_id, "video/x-apple-video", NULL);
1418+ break;
1419+
1420+ case CODEC_ID_CINEPAK:
1421+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-cinepak", NULL);
1422+ break;
1423+
1424+ /* WS_VQA belogns here (order) */
1425+
1426+ case CODEC_ID_MSRLE:
1427+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-rle",
1428+ "layout", G_TYPE_STRING, "microsoft", NULL);
1429+ if (context) {
1430+ gst_caps_set_simple (caps,
1431+ "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
1432+ } else {
1433+ gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 1, 64, NULL);
1434+ }
1435+ break;
1436+
1437+ case CODEC_ID_QTRLE:
1438+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-rle",
1439+ "layout", G_TYPE_STRING, "quicktime", NULL);
1440+ if (context) {
1441+ gst_caps_set_simple (caps,
1442+ "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
1443+ } else {
1444+ gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 1, 64, NULL);
1445+ }
1446+ break;
1447+
1448+ case CODEC_ID_MSVIDEO1:
1449+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-msvideocodec",
1450+ "msvideoversion", G_TYPE_INT, 1, NULL);
1451+ break;
1452+
1453+ case CODEC_ID_WMV3:
1454+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
1455+ "wmvversion", G_TYPE_INT, 3, NULL);
1456+ break;
1457+ case CODEC_ID_VC1:
1458+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
1459+ "wmvversion", G_TYPE_INT, 3, "format", GST_TYPE_FOURCC,
1460+ GST_MAKE_FOURCC ('W', 'V', 'C', '1'), NULL);
1461+ break;
1462+ case CODEC_ID_QDM2:
1463+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-qdm2", NULL);
1464+ break;
1465+
1466+ case CODEC_ID_MSZH:
1467+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mszh", NULL);
1468+ break;
1469+
1470+ case CODEC_ID_ZLIB:
1471+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-zlib", NULL);
1472+ break;
1473+
1474+ case CODEC_ID_TRUEMOTION1:
1475+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-truemotion",
1476+ "trueversion", G_TYPE_INT, 1, NULL);
1477+ break;
1478+ case CODEC_ID_TRUEMOTION2:
1479+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-truemotion",
1480+ "trueversion", G_TYPE_INT, 2, NULL);
1481+ break;
1482+
1483+ case CODEC_ID_ULTI:
1484+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ultimotion",
1485+ NULL);
1486+ break;
1487+
1488+ case CODEC_ID_TSCC:
1489+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-camtasia", NULL);
1490+ if (context) {
1491+ gst_caps_set_simple (caps,
1492+ "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
1493+ } else {
1494+ gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 8, 32, NULL);
1495+ }
1496+ break;
1497+
1498+ case CODEC_ID_KMVC:
1499+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-kmvc", NULL);
1500+ break;
1501+
1502+ case CODEC_ID_NUV:
1503+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-nuv", NULL);
1504+ break;
1505+
1506+ case CODEC_ID_GIF:
1507+ caps = gst_ff_vid_caps_new (context, codec_id, "image/gif", NULL);
1508+ break;
1509+
1510+ case CODEC_ID_PNG:
1511+ caps = gst_ff_vid_caps_new (context, codec_id, "image/png", NULL);
1512+ break;
1513+
1514+ case CODEC_ID_PPM:
1515+ caps = gst_ff_vid_caps_new (context, codec_id, "image/ppm", NULL);
1516+ break;
1517+
1518+ case CODEC_ID_PBM:
1519+ caps = gst_ff_vid_caps_new (context, codec_id, "image/pbm", NULL);
1520+ break;
1521+
1522+ case CODEC_ID_PAM:
1523+ caps =
1524+ gst_ff_vid_caps_new (context, codec_id, "image/x-portable-anymap",
1525+ NULL);
1526+ break;
1527+
1528+ case CODEC_ID_PGM:
1529+ caps =
1530+ gst_ff_vid_caps_new (context, codec_id, "image/x-portable-graymap",
1531+ NULL);
1532+ break;
1533+
1534+ case CODEC_ID_PCX:
1535+ caps = gst_ff_vid_caps_new (context, codec_id, "image/x-pcx", NULL);
1536+ break;
1537+
1538+ case CODEC_ID_SGI:
1539+ caps = gst_ff_vid_caps_new (context, codec_id, "image/x-sgi", NULL);
1540+ break;
1541+
1542+ case CODEC_ID_TARGA:
1543+ caps = gst_ff_vid_caps_new (context, codec_id, "image/x-tga", NULL);
1544+ break;
1545+
1546+ case CODEC_ID_TIFF:
1547+ caps = gst_ff_vid_caps_new (context, codec_id, "image/tiff", NULL);
1548+ break;
1549+
1550+ case CODEC_ID_SUNRAST:
1551+ caps =
1552+ gst_ff_vid_caps_new (context, codec_id, "image/x-sun-raster", NULL);
1553+ break;
1554+
1555+ case CODEC_ID_SMC:
1556+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-smc", NULL);
1557+ break;
1558+
1559+ case CODEC_ID_QDRAW:
1560+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-qdrw", NULL);
1561+ break;
1562+
1563+ case CODEC_ID_DNXHD:
1564+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dnxhd", NULL);
1565+ break;
1566+
1567+ case CODEC_ID_MIMIC:
1568+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mimic", NULL);
1569+ break;
1570+
1571+ case CODEC_ID_VMNC:
1572+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vmnc", NULL);
1573+ break;
1574+
1575+ case CODEC_ID_TRUESPEECH:
1576+ caps =
1577+ gst_ff_aud_caps_new (context, codec_id, "audio/x-truespeech", NULL);
1578+ break;
1579+
1580+ case CODEC_ID_QCELP:
1581+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/qcelp", NULL);
1582+ break;
1583+
1584+ case CODEC_ID_AMV:
1585+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-amv", NULL);
1586+ break;
1587+
1588+ case CODEC_ID_AASC:
1589+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-aasc", NULL);
1590+ break;
1591+
1592+ case CODEC_ID_LOCO:
1593+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-loco", NULL);
1594+ break;
1595+
1596+ case CODEC_ID_ZMBV:
1597+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-zmbv", NULL);
1598+ break;
1599+
1600+ case CODEC_ID_LAGARITH:
1601+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-lagarith", NULL);
1602+ break;
1603+
1604+ case CODEC_ID_CSCD:
1605+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-camstudio", NULL);
1606+ if (context) {
1607+ gst_caps_set_simple (caps,
1608+ "depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
1609+ } else {
1610+ gst_caps_set_simple (caps, "depth", GST_TYPE_INT_RANGE, 8, 32, NULL);
1611+ }
1612+ break;
1613+
1614+ case CODEC_ID_WS_VQA:
1615+ case CODEC_ID_IDCIN:
1616+ case CODEC_ID_8BPS:
1617+ case CODEC_ID_FLIC:
1618+ case CODEC_ID_VMDVIDEO:
1619+ case CODEC_ID_VMDAUDIO:
1620+ case CODEC_ID_SNOW:
1621+ case CODEC_ID_VIXL:
1622+ case CODEC_ID_QPEG:
1623+ case CODEC_ID_PGMYUV:
1624+ case CODEC_ID_FFVHUFF:
1625+ case CODEC_ID_WNV1:
1626+ case CODEC_ID_MP3ADU:
1627+ case CODEC_ID_MP3ON4:
1628+ case CODEC_ID_WESTWOOD_SND1:
1629+ case CODEC_ID_MMVIDEO:
1630+ case CODEC_ID_AVS:
1631+ case CODEC_ID_CAVS:
1632+ buildcaps = TRUE;
1633+ break;
1634+
1635+ /* weird quasi-codecs for the demuxers only */
1636+ case CODEC_ID_PCM_S16LE:
1637+ case CODEC_ID_PCM_S16BE:
1638+ case CODEC_ID_PCM_U16LE:
1639+ case CODEC_ID_PCM_U16BE:
1640+ case CODEC_ID_PCM_S8:
1641+ case CODEC_ID_PCM_U8:
1642+ {
1643+ gint width = 0, depth = 0, endianness = 0;
1644+ gboolean signedness = FALSE; /* blabla */
1645+
1646+ switch (codec_id) {
1647+ case CODEC_ID_PCM_S16LE:
1648+ width = 16;
1649+ depth = 16;
1650+ endianness = G_LITTLE_ENDIAN;
1651+ signedness = TRUE;
1652+ break;
1653+ case CODEC_ID_PCM_S16BE:
1654+ width = 16;
1655+ depth = 16;
1656+ endianness = G_BIG_ENDIAN;
1657+ signedness = TRUE;
1658+ break;
1659+ case CODEC_ID_PCM_U16LE:
1660+ width = 16;
1661+ depth = 16;
1662+ endianness = G_LITTLE_ENDIAN;
1663+ signedness = FALSE;
1664+ break;
1665+ case CODEC_ID_PCM_U16BE:
1666+ width = 16;
1667+ depth = 16;
1668+ endianness = G_BIG_ENDIAN;
1669+ signedness = FALSE;
1670+ break;
1671+ case CODEC_ID_PCM_S8:
1672+ width = 8;
1673+ depth = 8;
1674+ endianness = G_BYTE_ORDER;
1675+ signedness = TRUE;
1676+ break;
1677+ case CODEC_ID_PCM_U8:
1678+ width = 8;
1679+ depth = 8;
1680+ endianness = G_BYTE_ORDER;
1681+ signedness = FALSE;
1682+ break;
1683+ default:
1684+ g_assert (0); /* don't worry, we never get here */
1685+ break;
1686+ }
1687+
1688+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-int",
1689+ "width", G_TYPE_INT, width,
1690+ "depth", G_TYPE_INT, depth,
1691+ "endianness", G_TYPE_INT, endianness,
1692+ "signed", G_TYPE_BOOLEAN, signedness, NULL);
1693+ }
1694+ break;
1695+
1696+ case CODEC_ID_PCM_MULAW:
1697+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mulaw", NULL);
1698+ break;
1699+
1700+ case CODEC_ID_PCM_ALAW:
1701+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-alaw", NULL);
1702+ break;
1703+
1704+ case CODEC_ID_ADPCM_G722:
1705+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/G722", NULL);
1706+ if (context)
1707+ gst_caps_set_simple (caps,
1708+ "block_align", G_TYPE_INT, context->block_align,
1709+ "bitrate", G_TYPE_INT, context->bit_rate, NULL);
1710+ break;
1711+
1712+ case CODEC_ID_ADPCM_G726:
1713+ {
1714+ /* the G726 decoder can also handle G721 */
1715+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-adpcm",
1716+ "layout", G_TYPE_STRING, "g726", NULL);
1717+ if (context)
1718+ gst_caps_set_simple (caps,
1719+ "block_align", G_TYPE_INT, context->block_align,
1720+ "bitrate", G_TYPE_INT, context->bit_rate, NULL);
1721+
1722+ if (!encode) {
1723+ gst_caps_append (caps, gst_caps_new_simple ("audio/x-adpcm",
1724+ "layout", G_TYPE_STRING, "g721",
1725+ "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL));
1726+ }
1727+ break;
1728+ }
1729+ case CODEC_ID_ADPCM_IMA_QT:
1730+ case CODEC_ID_ADPCM_IMA_WAV:
1731+ case CODEC_ID_ADPCM_IMA_DK3:
1732+ case CODEC_ID_ADPCM_IMA_DK4:
1733+ case CODEC_ID_ADPCM_IMA_WS:
1734+ case CODEC_ID_ADPCM_IMA_SMJPEG:
1735+ case CODEC_ID_ADPCM_IMA_AMV:
1736+ case CODEC_ID_ADPCM_IMA_ISS:
1737+ case CODEC_ID_ADPCM_IMA_EA_EACS:
1738+ case CODEC_ID_ADPCM_IMA_EA_SEAD:
1739+ case CODEC_ID_ADPCM_MS:
1740+ case CODEC_ID_ADPCM_4XM:
1741+ case CODEC_ID_ADPCM_XA:
1742+ case CODEC_ID_ADPCM_ADX:
1743+ case CODEC_ID_ADPCM_EA:
1744+ case CODEC_ID_ADPCM_CT:
1745+ case CODEC_ID_ADPCM_SWF:
1746+ case CODEC_ID_ADPCM_YAMAHA:
1747+ case CODEC_ID_ADPCM_SBPRO_2:
1748+ case CODEC_ID_ADPCM_SBPRO_3:
1749+ case CODEC_ID_ADPCM_SBPRO_4:
1750+ case CODEC_ID_ADPCM_EA_R1:
1751+ case CODEC_ID_ADPCM_EA_R2:
1752+ case CODEC_ID_ADPCM_EA_R3:
1753+ case CODEC_ID_ADPCM_EA_MAXIS_XA:
1754+ case CODEC_ID_ADPCM_EA_XAS:
1755+ case CODEC_ID_ADPCM_THP:
1756+ {
1757+ const gchar *layout = NULL;
1758+
1759+ switch (codec_id) {
1760+ case CODEC_ID_ADPCM_IMA_QT:
1761+ layout = "quicktime";
1762+ break;
1763+ case CODEC_ID_ADPCM_IMA_WAV:
1764+ layout = "dvi";
1765+ break;
1766+ case CODEC_ID_ADPCM_IMA_DK3:
1767+ layout = "dk3";
1768+ break;
1769+ case CODEC_ID_ADPCM_IMA_DK4:
1770+ layout = "dk4";
1771+ break;
1772+ case CODEC_ID_ADPCM_IMA_WS:
1773+ layout = "westwood";
1774+ break;
1775+ case CODEC_ID_ADPCM_IMA_SMJPEG:
1776+ layout = "smjpeg";
1777+ break;
1778+ case CODEC_ID_ADPCM_IMA_AMV:
1779+ layout = "amv";
1780+ break;
1781+ case CODEC_ID_ADPCM_IMA_ISS:
1782+ layout = "iss";
1783+ break;
1784+ case CODEC_ID_ADPCM_IMA_EA_EACS:
1785+ layout = "ea-eacs";
1786+ break;
1787+ case CODEC_ID_ADPCM_IMA_EA_SEAD:
1788+ layout = "ea-sead";
1789+ break;
1790+ case CODEC_ID_ADPCM_MS:
1791+ layout = "microsoft";
1792+ break;
1793+ case CODEC_ID_ADPCM_4XM:
1794+ layout = "4xm";
1795+ break;
1796+ case CODEC_ID_ADPCM_XA:
1797+ layout = "xa";
1798+ break;
1799+ case CODEC_ID_ADPCM_ADX:
1800+ layout = "adx";
1801+ break;
1802+ case CODEC_ID_ADPCM_EA:
1803+ layout = "ea";
1804+ break;
1805+ case CODEC_ID_ADPCM_CT:
1806+ layout = "ct";
1807+ break;
1808+ case CODEC_ID_ADPCM_SWF:
1809+ layout = "swf";
1810+ break;
1811+ case CODEC_ID_ADPCM_YAMAHA:
1812+ layout = "yamaha";
1813+ break;
1814+ case CODEC_ID_ADPCM_SBPRO_2:
1815+ layout = "sbpro2";
1816+ break;
1817+ case CODEC_ID_ADPCM_SBPRO_3:
1818+ layout = "sbpro3";
1819+ break;
1820+ case CODEC_ID_ADPCM_SBPRO_4:
1821+ layout = "sbpro4";
1822+ break;
1823+ case CODEC_ID_ADPCM_EA_R1:
1824+ layout = "ea-r1";
1825+ break;
1826+ case CODEC_ID_ADPCM_EA_R2:
1827+ layout = "ea-r3";
1828+ break;
1829+ case CODEC_ID_ADPCM_EA_R3:
1830+ layout = "ea-r3";
1831+ break;
1832+ case CODEC_ID_ADPCM_EA_MAXIS_XA:
1833+ layout = "ea-maxis-xa";
1834+ break;
1835+ case CODEC_ID_ADPCM_EA_XAS:
1836+ layout = "ea-xas";
1837+ break;
1838+ case CODEC_ID_ADPCM_THP:
1839+ layout = "thp";
1840+ break;
1841+ default:
1842+ g_assert (0); /* don't worry, we never get here */
1843+ break;
1844+ }
1845+
1846+ /* FIXME: someone please check whether we need additional properties
1847+ * in this caps definition. */
1848+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-adpcm",
1849+ "layout", G_TYPE_STRING, layout, NULL);
1850+ if (context)
1851+ gst_caps_set_simple (caps,
1852+ "block_align", G_TYPE_INT, context->block_align,
1853+ "bitrate", G_TYPE_INT, context->bit_rate, NULL);
1854+ }
1855+ break;
1856+
1857+ case CODEC_ID_AMR_NB:
1858+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/AMR", NULL);
1859+ break;
1860+
1861+ case CODEC_ID_AMR_WB:
1862+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/AMR-WB", NULL);
1863+ break;
1864+
1865+ case CODEC_ID_GSM:
1866+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-gsm", NULL);
1867+ break;
1868+
1869+ case CODEC_ID_GSM_MS:
1870+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/ms-gsm", NULL);
1871+ break;
1872+
1873+ case CODEC_ID_NELLYMOSER:
1874+ caps =
1875+ gst_ff_aud_caps_new (context, codec_id, "audio/x-nellymoser", NULL);
1876+ break;
1877+
1878+ case CODEC_ID_SIPR:
1879+ {
1880+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-sipro", NULL);
1881+ if (context) {
1882+ gst_caps_set_simple (caps,
1883+ "leaf_size", G_TYPE_INT, context->block_align,
1884+ "bitrate", G_TYPE_INT, context->bit_rate, NULL);
1885+ }
1886+ }
1887+ break;
1888+
1889+ case CODEC_ID_RA_144:
1890+ case CODEC_ID_RA_288:
1891+ case CODEC_ID_COOK:
1892+ {
1893+ gint version = 0;
1894+
1895+ switch (codec_id) {
1896+ case CODEC_ID_RA_144:
1897+ version = 1;
1898+ break;
1899+ case CODEC_ID_RA_288:
1900+ version = 2;
1901+ break;
1902+ case CODEC_ID_COOK:
1903+ version = 8;
1904+ break;
1905+ default:
1906+ break;
1907+ }
1908+
1909+ /* FIXME: properties? */
1910+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-pn-realaudio",
1911+ "raversion", G_TYPE_INT, version, NULL);
1912+ if (context) {
1913+ gst_caps_set_simple (caps,
1914+ "leaf_size", G_TYPE_INT, context->block_align,
1915+ "bitrate", G_TYPE_INT, context->bit_rate, NULL);
1916+ }
1917+ }
1918+ break;
1919+
1920+ case CODEC_ID_ROQ_DPCM:
1921+ case CODEC_ID_INTERPLAY_DPCM:
1922+ case CODEC_ID_XAN_DPCM:
1923+ case CODEC_ID_SOL_DPCM:
1924+ {
1925+ const gchar *layout = NULL;
1926+
1927+ switch (codec_id) {
1928+ case CODEC_ID_ROQ_DPCM:
1929+ layout = "roq";
1930+ break;
1931+ case CODEC_ID_INTERPLAY_DPCM:
1932+ layout = "interplay";
1933+ break;
1934+ case CODEC_ID_XAN_DPCM:
1935+ layout = "xan";
1936+ break;
1937+ case CODEC_ID_SOL_DPCM:
1938+ layout = "sol";
1939+ break;
1940+ default:
1941+ g_assert (0); /* don't worry, we never get here */
1942+ break;
1943+ }
1944+
1945+ /* FIXME: someone please check whether we need additional properties
1946+ * in this caps definition. */
1947+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dpcm",
1948+ "layout", G_TYPE_STRING, layout, NULL);
1949+ if (context)
1950+ gst_caps_set_simple (caps,
1951+ "block_align", G_TYPE_INT, context->block_align,
1952+ "bitrate", G_TYPE_INT, context->bit_rate, NULL);
1953+ }
1954+ break;
1955+
1956+ case CODEC_ID_SHORTEN:
1957+ caps = gst_caps_new_simple ("audio/x-shorten", NULL);
1958+ break;
1959+
1960+ case CODEC_ID_ALAC:
1961+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-alac", NULL);
1962+ if (context) {
1963+ gst_caps_set_simple (caps,
1964+ "samplesize", G_TYPE_INT, context->bits_per_coded_sample, NULL);
1965+ }
1966+ break;
1967+
1968+ case CODEC_ID_FLAC:
1969+ /* Note that ffmpeg has no encoder yet, but just for safety. In the
1970+ * encoder case, we want to add things like samplerate, channels... */
1971+ if (!encode) {
1972+ caps = gst_caps_new_simple ("audio/x-flac", NULL);
1973+ }
1974+ break;
1975+
1976+ case CODEC_ID_DVD_SUBTITLE:
1977+ case CODEC_ID_DVB_SUBTITLE:
1978+ caps = NULL;
1979+ break;
1980+ case CODEC_ID_BMP:
1981+ caps = gst_caps_new_simple ("image/bmp", NULL);
1982+ break;
1983+ case CODEC_ID_TTA:
1984+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-tta", NULL);
1985+ if (context) {
1986+ gst_caps_set_simple (caps,
1987+ "samplesize", G_TYPE_INT, context->bits_per_coded_sample, NULL);
1988+ }
1989+ break;
1990+ case CODEC_ID_TWINVQ:
1991+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-twin-vq", NULL);
1992+ break;
1993+ default:
1994+ GST_DEBUG ("Unknown codec ID %d, please add mapping here", codec_id);
1995+ break;
1996+ }
1997+
1998+ if (buildcaps) {
1999+ AVCodec *codec;
2000+
2001+ if ((codec = avcodec_find_decoder (codec_id)) ||
2002+ (codec = avcodec_find_encoder (codec_id))) {
2003+ gchar *mime = NULL;
2004+
2005+ GST_LOG ("Could not create stream format caps for %s", codec->name);
2006+
2007+ switch (codec->type) {
2008+ case AVMEDIA_TYPE_VIDEO:
2009+ mime = g_strdup_printf ("video/x-gst_ff-%s", codec->name);
2010+ caps = gst_ff_vid_caps_new (context, codec_id, mime, NULL);
2011+ g_free (mime);
2012+ break;
2013+ case AVMEDIA_TYPE_AUDIO:
2014+ mime = g_strdup_printf ("audio/x-gst_ff-%s", codec->name);
2015+ caps = gst_ff_aud_caps_new (context, codec_id, mime, NULL);
2016+ if (context)
2017+ gst_caps_set_simple (caps,
2018+ "block_align", G_TYPE_INT, context->block_align,
2019+ "bitrate", G_TYPE_INT, context->bit_rate, NULL);
2020+ g_free (mime);
2021+ break;
2022+ default:
2023+ break;
2024+ }
2025+ }
2026+ }
2027+
2028+ if (caps != NULL) {
2029+
2030+ /* set private data */
2031+ if (context && context->extradata_size > 0) {
2032+ GstBuffer *data = gst_buffer_new_and_alloc (context->extradata_size);
2033+
2034+ memcpy (GST_BUFFER_DATA (data), context->extradata,
2035+ context->extradata_size);
2036+ gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, data, NULL);
2037+ gst_buffer_unref (data);
2038+ }
2039+
2040+ /* palette */
2041+ if (context) {
2042+ gst_ffmpeg_set_palette (caps, context);
2043+ }
2044+
2045+ GST_LOG ("caps for codec_id=%d: %" GST_PTR_FORMAT, codec_id, caps);
2046+
2047+ } else {
2048+ GST_LOG ("No caps found for codec_id=%d", codec_id);
2049+ }
2050+
2051+ return caps;
2052+}
2053+
2054+/* Convert a FFMPEG Pixel Format and optional AVCodecContext
2055+ * to a GstCaps. If the context is ommitted, no fixed values
2056+ * for video/audio size will be included in the GstCaps
2057+ *
2058+ * See below for usefullness
2059+ */
2060+
2061+GstCaps *
2062+gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context,
2063+ enum CodecID codec_id)
2064+{
2065+ GstCaps *caps = NULL;
2066+
2067+ int bpp = 0, depth = 0, endianness = 0;
2068+ gulong g_mask = 0, r_mask = 0, b_mask = 0, a_mask = 0;
2069+ guint32 fmt = 0;
2070+
2071+ switch (pix_fmt) {
2072+ case PIX_FMT_YUVJ420P:
2073+ case PIX_FMT_YUV420P:
2074+ fmt = GST_MAKE_FOURCC ('I', '4', '2', '0');
2075+ break;
2076+ case PIX_FMT_YUVA420P:
2077+ fmt = GST_MAKE_FOURCC ('A', '4', '2', '0');
2078+ break;
2079+ case PIX_FMT_YUYV422:
2080+ fmt = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
2081+ break;
2082+ case PIX_FMT_RGB24:
2083+ bpp = depth = 24;
2084+ endianness = G_BIG_ENDIAN;
2085+ r_mask = 0xff0000;
2086+ g_mask = 0x00ff00;
2087+ b_mask = 0x0000ff;
2088+ break;
2089+ case PIX_FMT_BGR24:
2090+ bpp = depth = 24;
2091+ endianness = G_BIG_ENDIAN;
2092+ r_mask = 0x0000ff;
2093+ g_mask = 0x00ff00;
2094+ b_mask = 0xff0000;
2095+ break;
2096+ case PIX_FMT_YUVJ422P:
2097+ case PIX_FMT_YUV422P:
2098+ fmt = GST_MAKE_FOURCC ('Y', '4', '2', 'B');
2099+ break;
2100+ case PIX_FMT_YUVJ444P:
2101+ case PIX_FMT_YUV444P:
2102+ fmt = GST_MAKE_FOURCC ('Y', '4', '4', '4');
2103+ break;
2104+ case PIX_FMT_RGB32:
2105+ bpp = 32;
2106+ depth = 32;
2107+ endianness = G_BIG_ENDIAN;
2108+#if (G_BYTE_ORDER == G_BIG_ENDIAN)
2109+ r_mask = 0x00ff0000;
2110+ g_mask = 0x0000ff00;
2111+ b_mask = 0x000000ff;
2112+ a_mask = 0xff000000;
2113+#else
2114+ r_mask = 0x0000ff00;
2115+ g_mask = 0x00ff0000;
2116+ b_mask = 0xff000000;
2117+ a_mask = 0x000000ff;
2118+#endif
2119+ break;
2120+ case PIX_FMT_YUV410P:
2121+ fmt = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
2122+ break;
2123+ case PIX_FMT_YUV411P:
2124+ fmt = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
2125+ break;
2126+ case PIX_FMT_RGB565:
2127+ bpp = depth = 16;
2128+ endianness = G_BYTE_ORDER;
2129+ r_mask = 0xf800;
2130+ g_mask = 0x07e0;
2131+ b_mask = 0x001f;
2132+ break;
2133+ case PIX_FMT_RGB555:
2134+ bpp = 16;
2135+ depth = 15;
2136+ endianness = G_BYTE_ORDER;
2137+ r_mask = 0x7c00;
2138+ g_mask = 0x03e0;
2139+ b_mask = 0x001f;
2140+ break;
2141+ case PIX_FMT_PAL8:
2142+ bpp = depth = 8;
2143+ endianness = G_BYTE_ORDER;
2144+ break;
2145+ case PIX_FMT_GRAY8:
2146+ bpp = depth = 8;
2147+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-gray",
2148+ "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, NULL);
2149+ break;
2150+ default:
2151+ /* give up ... */
2152+ break;
2153+ }
2154+
2155+ if (caps == NULL) {
2156+ if (bpp != 0) {
2157+ if (r_mask != 0) {
2158+ if (a_mask) {
2159+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
2160+ "bpp", G_TYPE_INT, bpp,
2161+ "depth", G_TYPE_INT, depth,
2162+ "red_mask", G_TYPE_INT, r_mask,
2163+ "green_mask", G_TYPE_INT, g_mask,
2164+ "blue_mask", G_TYPE_INT, b_mask,
2165+ "alpha_mask", G_TYPE_INT, a_mask,
2166+ "endianness", G_TYPE_INT, endianness, NULL);
2167+ } else {
2168+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
2169+ "bpp", G_TYPE_INT, bpp,
2170+ "depth", G_TYPE_INT, depth,
2171+ "red_mask", G_TYPE_INT, r_mask,
2172+ "green_mask", G_TYPE_INT, g_mask,
2173+ "blue_mask", G_TYPE_INT, b_mask,
2174+ "endianness", G_TYPE_INT, endianness, NULL);
2175+ }
2176+ } else {
2177+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-rgb",
2178+ "bpp", G_TYPE_INT, bpp,
2179+ "depth", G_TYPE_INT, depth,
2180+ "endianness", G_TYPE_INT, endianness, NULL);
2181+ if (caps && context) {
2182+ gst_ffmpeg_set_palette (caps, context);
2183+ }
2184+ }
2185+ } else if (fmt) {
2186+ caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw-yuv",
2187+ "format", GST_TYPE_FOURCC, fmt, NULL);
2188+ }
2189+ }
2190+
2191+ if (caps != NULL) {
2192+ GST_DEBUG ("caps for pix_fmt=%d: %" GST_PTR_FORMAT, pix_fmt, caps);
2193+ } else {
2194+ GST_LOG ("No caps found for pix_fmt=%d", pix_fmt);
2195+ }
2196+
2197+ return caps;
2198+}
2199+
2200+/* Convert a FFMPEG Sample Format and optional AVCodecContext
2201+ * to a GstCaps. If the context is ommitted, no fixed values
2202+ * for video/audio size will be included in the GstCaps
2203+ *
2204+ * See below for usefullness
2205+ */
2206+
2207+static GstCaps *
2208+gst_ffmpeg_smpfmt_to_caps (enum AVSampleFormat sample_fmt,
2209+ AVCodecContext * context, enum CodecID codec_id)
2210+{
2211+ GstCaps *caps = NULL;
2212+
2213+ int bpp = 0;
2214+ gboolean integer = TRUE;
2215+ gboolean signedness = FALSE;
2216+
2217+ switch (sample_fmt) {
2218+ case AV_SAMPLE_FMT_S16:
2219+ signedness = TRUE;
2220+ bpp = 16;
2221+ break;
2222+
2223+ case AV_SAMPLE_FMT_S32:
2224+ signedness = TRUE;
2225+ bpp = 32;
2226+ break;
2227+
2228+ case AV_SAMPLE_FMT_FLT:
2229+ integer = FALSE;
2230+ bpp = 32;
2231+ break;
2232+
2233+ case AV_SAMPLE_FMT_DBL:
2234+ integer = FALSE;
2235+ bpp = 64;
2236+ break;
2237+ default:
2238+ /* .. */
2239+ break;
2240+ }
2241+
2242+ if (bpp) {
2243+ if (integer) {
2244+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-int",
2245+ "signed", G_TYPE_BOOLEAN, signedness,
2246+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
2247+ "width", G_TYPE_INT, bpp, "depth", G_TYPE_INT, bpp, NULL);
2248+ } else {
2249+ caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw-float",
2250+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
2251+ "width", G_TYPE_INT, bpp, NULL);
2252+ }
2253+ }
2254+
2255+ if (caps != NULL) {
2256+ GST_LOG ("caps for sample_fmt=%d: %" GST_PTR_FORMAT, sample_fmt, caps);
2257+ } else {
2258+ GST_LOG ("No caps found for sample_fmt=%d", sample_fmt);
2259+ }
2260+
2261+ return caps;
2262+}
2263+
2264+GstCaps *
2265+gst_ffmpeg_codectype_to_audio_caps (AVCodecContext * context,
2266+ enum CodecID codec_id, gboolean encode, AVCodec * codec)
2267+{
2268+ GstCaps *caps = NULL;
2269+
2270+ GST_DEBUG ("context:%p, codec_id:%d, encode:%d, codec:%p",
2271+ context, codec_id, encode, codec);
2272+ if (codec)
2273+ GST_DEBUG ("sample_fmts:%p, samplerates:%p",
2274+ codec->sample_fmts, codec->supported_samplerates);
2275+
2276+ if (context) {
2277+ /* Specific codec context */
2278+ caps = gst_ffmpeg_smpfmt_to_caps (context->sample_fmt, context, codec_id);
2279+ } else if (codec && codec->sample_fmts) {
2280+ GstCaps *temp;
2281+ int i;
2282+
2283+ caps = gst_caps_new_empty ();
2284+ for (i = 0; codec->sample_fmts[i] != -1; i++) {
2285+ temp =
2286+ gst_ffmpeg_smpfmt_to_caps (codec->sample_fmts[i], context, codec_id);
2287+ if (temp != NULL)
2288+ gst_caps_append (caps, temp);
2289+ }
2290+ } else {
2291+ GstCaps *temp;
2292+ enum AVSampleFormat i;
2293+ AVCodecContext ctx = { 0, };
2294+
2295+ ctx.channels = -1;
2296+ caps = gst_caps_new_empty ();
2297+ for (i = 0; i <= AV_SAMPLE_FMT_DBL; i++) {
2298+ temp = gst_ffmpeg_smpfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
2299+ if (temp != NULL) {
2300+ gst_caps_append (caps, temp);
2301+ }
2302+ }
2303+ }
2304+ return caps;
2305+}
2306+
2307+GstCaps *
2308+gst_ffmpeg_codectype_to_video_caps (AVCodecContext * context,
2309+ enum CodecID codec_id, gboolean encode, AVCodec * codec)
2310+{
2311+ GstCaps *caps;
2312+
2313+ GST_LOG ("context:%p, codec_id:%d, encode:%d, codec:%p",
2314+ context, codec_id, encode, codec);
2315+
2316+ if (context) {
2317+ caps = gst_ffmpeg_pixfmt_to_caps (context->pix_fmt, context, codec_id);
2318+ } else {
2319+ GstCaps *temp;
2320+ enum PixelFormat i;
2321+ AVCodecContext ctx = { 0, };
2322+
2323+ caps = gst_caps_new_empty ();
2324+ for (i = 0; i < PIX_FMT_NB; i++) {
2325+ ctx.width = -1;
2326+ ctx.pix_fmt = i;
2327+ temp = gst_ffmpeg_pixfmt_to_caps (i, encode ? &ctx : NULL, codec_id);
2328+ if (temp != NULL) {
2329+ gst_caps_append (caps, temp);
2330+ }
2331+ }
2332+ }
2333+ return caps;
2334+}
2335+
2336+/* Convert a FFMPEG codec Type and optional AVCodecContext
2337+ * to a GstCaps. If the context is ommitted, no fixed values
2338+ * for video/audio size will be included in the GstCaps
2339+ *
2340+ * AVMediaType is primarily meant for uncompressed data GstCaps!
2341+ */
2342+
2343+GstCaps *
2344+gst_ffmpeg_codectype_to_caps (enum AVMediaType codec_type,
2345+ AVCodecContext * context, enum CodecID codec_id, gboolean encode)
2346+{
2347+ GstCaps *caps;
2348+
2349+ switch (codec_type) {
2350+ case AVMEDIA_TYPE_VIDEO:
2351+ caps =
2352+ gst_ffmpeg_codectype_to_video_caps (context, codec_id, encode, NULL);
2353+ break;
2354+ case AVMEDIA_TYPE_AUDIO:
2355+ caps =
2356+ gst_ffmpeg_codectype_to_audio_caps (context, codec_id, encode, NULL);
2357+ break;
2358+ default:
2359+ caps = NULL;
2360+ break;
2361+ }
2362+
2363+ return caps;
2364+}
2365+
2366+/* Convert a GstCaps (audio/raw) to a FFMPEG SampleFmt
2367+ * and other audio properties in a AVCodecContext.
2368+ *
2369+ * For usefullness, see below
2370+ */
2371+
2372+static void
2373+gst_ffmpeg_caps_to_smpfmt (const GstCaps * caps,
2374+ AVCodecContext * context, gboolean raw)
2375+{
2376+ GstStructure *structure;
2377+ gint depth = 0, width = 0, endianness = 0;
2378+ gboolean signedness = FALSE;
2379+ const gchar *name;
2380+
2381+ g_return_if_fail (gst_caps_get_size (caps) == 1);
2382+ structure = gst_caps_get_structure (caps, 0);
2383+
2384+ gst_structure_get_int (structure, "channels", &context->channels);
2385+ gst_structure_get_int (structure, "rate", &context->sample_rate);
2386+ gst_structure_get_int (structure, "block_align", &context->block_align);
2387+ gst_structure_get_int (structure, "bitrate", &context->bit_rate);
2388+
2389+ if (!raw)
2390+ return;
2391+
2392+ name = gst_structure_get_name (structure);
2393+
2394+ if (!strcmp (name, "audio/x-raw-float")) {
2395+ /* FLOAT */
2396+ if (gst_structure_get_int (structure, "width", &width) &&
2397+ gst_structure_get_int (structure, "endianness", &endianness)) {
2398+ if (endianness == G_BYTE_ORDER) {
2399+ if (width == 32)
2400+ context->sample_fmt = AV_SAMPLE_FMT_FLT;
2401+ else if (width == 64)
2402+ context->sample_fmt = AV_SAMPLE_FMT_DBL;
2403+ }
2404+ }
2405+ } else {
2406+ /* INT */
2407+ if (gst_structure_get_int (structure, "width", &width) &&
2408+ gst_structure_get_int (structure, "depth", &depth) &&
2409+ gst_structure_get_boolean (structure, "signed", &signedness) &&
2410+ gst_structure_get_int (structure, "endianness", &endianness)) {
2411+ if ((endianness == G_BYTE_ORDER) && (signedness == TRUE)) {
2412+ if ((width == 16) && (depth == 16))
2413+ context->sample_fmt = AV_SAMPLE_FMT_S16;
2414+ else if ((width == 32) && (depth == 32))
2415+ context->sample_fmt = AV_SAMPLE_FMT_S32;
2416+ }
2417+ }
2418+ }
2419+}
2420+
2421+
2422+/* Convert a GstCaps (video/raw) to a FFMPEG PixFmt
2423+ * and other video properties in a AVCodecContext.
2424+ *
2425+ * For usefullness, see below
2426+ */
2427+
2428+static void
2429+gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
2430+ AVCodecContext * context, gboolean raw)
2431+{
2432+ GstStructure *structure;
2433+ const GValue *fps;
2434+ const GValue *par = NULL;
2435+
2436+ GST_DEBUG ("converting caps %" GST_PTR_FORMAT, caps);
2437+ g_return_if_fail (gst_caps_get_size (caps) == 1);
2438+ structure = gst_caps_get_structure (caps, 0);
2439+
2440+ gst_structure_get_int (structure, "width", &context->width);
2441+ gst_structure_get_int (structure, "height", &context->height);
2442+ gst_structure_get_int (structure, "bpp", &context->bits_per_coded_sample);
2443+
2444+ fps = gst_structure_get_value (structure, "framerate");
2445+ if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
2446+
2447+ /* somehow these seem mixed up.. */
2448+ context->time_base.den = gst_value_get_fraction_numerator (fps);
2449+ context->time_base.num = gst_value_get_fraction_denominator (fps);
2450+ context->ticks_per_frame = 1;
2451+
2452+ GST_DEBUG ("setting framerate %d/%d = %lf",
2453+ context->time_base.den, context->time_base.num,
2454+ 1. * context->time_base.den / context->time_base.num);
2455+ }
2456+
2457+ par = gst_structure_get_value (structure, "pixel-aspect-ratio");
2458+ if (par && GST_VALUE_HOLDS_FRACTION (par)) {
2459+
2460+ context->sample_aspect_ratio.num = gst_value_get_fraction_numerator (par);
2461+ context->sample_aspect_ratio.den = gst_value_get_fraction_denominator (par);
2462+
2463+ GST_DEBUG ("setting pixel-aspect-ratio %d/%d = %lf",
2464+ context->sample_aspect_ratio.den, context->sample_aspect_ratio.num,
2465+ 1. * context->sample_aspect_ratio.den /
2466+ context->sample_aspect_ratio.num);
2467+ }
2468+
2469+ if (!raw)
2470+ return;
2471+
2472+ g_return_if_fail (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps));
2473+
2474+ if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
2475+ guint32 fourcc;
2476+
2477+ if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
2478+ switch (fourcc) {
2479+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
2480+ context->pix_fmt = PIX_FMT_YUYV422;
2481+ break;
2482+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
2483+ context->pix_fmt = PIX_FMT_YUV420P;
2484+ break;
2485+ case GST_MAKE_FOURCC ('A', '4', '2', '0'):
2486+ context->pix_fmt = PIX_FMT_YUVA420P;
2487+ break;
2488+ case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
2489+ context->pix_fmt = PIX_FMT_YUV411P;
2490+ break;
2491+ case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
2492+ context->pix_fmt = PIX_FMT_YUV422P;
2493+ break;
2494+ case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
2495+ context->pix_fmt = PIX_FMT_YUV410P;
2496+ break;
2497+#if 0
2498+ case FIXME:
2499+ context->pix_fmt = PIX_FMT_YUV444P;
2500+ break;
2501+#endif
2502+ }
2503+ }
2504+ } else if (strcmp (gst_structure_get_name (structure),
2505+ "video/x-raw-rgb") == 0) {
2506+ gint bpp = 0, rmask = 0, endianness = 0;
2507+
2508+ if (gst_structure_get_int (structure, "bpp", &bpp) &&
2509+ gst_structure_get_int (structure, "endianness", &endianness)) {
2510+ if (gst_structure_get_int (structure, "red_mask", &rmask)) {
2511+ switch (bpp) {
2512+ case 32:
2513+#if (G_BYTE_ORDER == G_BIG_ENDIAN)
2514+ if (rmask == 0x00ff0000)
2515+#else
2516+ if (rmask == 0x0000ff00)
2517+#endif
2518+ context->pix_fmt = PIX_FMT_RGB32;
2519+ break;
2520+ case 24:
2521+ if (rmask == 0x0000FF)
2522+ context->pix_fmt = PIX_FMT_BGR24;
2523+ else
2524+ context->pix_fmt = PIX_FMT_RGB24;
2525+ break;
2526+ case 16:
2527+ if (endianness == G_BYTE_ORDER)
2528+ context->pix_fmt = PIX_FMT_RGB565;
2529+ break;
2530+ case 15:
2531+ if (endianness == G_BYTE_ORDER)
2532+ context->pix_fmt = PIX_FMT_RGB555;
2533+ break;
2534+ default:
2535+ /* nothing */
2536+ break;
2537+ }
2538+ } else {
2539+ if (bpp == 8) {
2540+ context->pix_fmt = PIX_FMT_PAL8;
2541+ gst_ffmpeg_get_palette (caps, context);
2542+ }
2543+ }
2544+ }
2545+ } else if (strcmp (gst_structure_get_name (structure),
2546+ "video/x-raw-gray") == 0) {
2547+ gint bpp = 0;
2548+
2549+ if (gst_structure_get_int (structure, "bpp", &bpp)) {
2550+ switch (bpp) {
2551+ case 8:
2552+ context->pix_fmt = PIX_FMT_GRAY8;
2553+ break;
2554+ }
2555+ }
2556+ }
2557+}
2558+
2559+/* Convert a GstCaps and a FFMPEG codec Type to a
2560+ * AVCodecContext. If the context is ommitted, no fixed values
2561+ * for video/audio size will be included in the context
2562+ *
2563+ * AVMediaType is primarily meant for uncompressed data GstCaps!
2564+ */
2565+
2566+void
2567+gst_ffmpeg_caps_with_codectype (enum AVMediaType type,
2568+ const GstCaps * caps, AVCodecContext * context)
2569+{
2570+ if (context == NULL)
2571+ return;
2572+
2573+ switch (type) {
2574+ case AVMEDIA_TYPE_VIDEO:
2575+ gst_ffmpeg_caps_to_pixfmt (caps, context, TRUE);
2576+ break;
2577+
2578+ case AVMEDIA_TYPE_AUDIO:
2579+ gst_ffmpeg_caps_to_smpfmt (caps, context, TRUE);
2580+ break;
2581+
2582+ default:
2583+ /* unknown */
2584+ break;
2585+ }
2586+}
2587+
2588+#if 0
2589+static void
2590+nal_escape (guint8 * dst, guint8 * src, guint size, guint * destsize)
2591+{
2592+ guint8 *dstp = dst;
2593+ guint8 *srcp = src;
2594+ guint8 *end = src + size;
2595+ gint count = 0;
2596+
2597+ while (srcp < end) {
2598+ if (count == 2 && *srcp <= 0x03) {
2599+ GST_DEBUG ("added escape code");
2600+ *dstp++ = 0x03;
2601+ count = 0;
2602+ }
2603+ if (*srcp == 0)
2604+ count++;
2605+ else
2606+ count = 0;
2607+
2608+ GST_DEBUG ("copy %02x, count %d", *srcp, count);
2609+ *dstp++ = *srcp++;
2610+ }
2611+ *destsize = dstp - dst;
2612+}
2613+
2614+/* copy the config, escaping NAL units as we iterate them, if something fails we
2615+ * copy everything and hope for the best. */
2616+static void
2617+copy_config (guint8 * dst, guint8 * src, guint size, guint * destsize)
2618+{
2619+ guint8 *dstp = dst;
2620+ guint8 *srcp = src;
2621+ gint cnt, i;
2622+ guint nalsize, esize;
2623+
2624+ /* check size */
2625+ if (size < 7)
2626+ goto full_copy;
2627+
2628+ /* check version */
2629+ if (*srcp != 1)
2630+ goto full_copy;
2631+
2632+ cnt = *(srcp + 5) & 0x1f; /* Number of sps */
2633+
2634+ GST_DEBUG ("num SPS %d", cnt);
2635+
2636+ memcpy (dstp, srcp, 6);
2637+ srcp += 6;
2638+ dstp += 6;
2639+
2640+ for (i = 0; i < cnt; i++) {
2641+ GST_DEBUG ("copy SPS %d", i);
2642+ nalsize = (srcp[0] << 8) | srcp[1];
2643+ nal_escape (dstp + 2, srcp + 2, nalsize, &esize);
2644+ dstp[0] = esize >> 8;
2645+ dstp[1] = esize & 0xff;
2646+ dstp += esize + 2;
2647+ srcp += nalsize + 2;
2648+ }
2649+
2650+ cnt = *(dstp++) = *(srcp++); /* Number of pps */
2651+
2652+ GST_DEBUG ("num PPS %d", cnt);
2653+
2654+ for (i = 0; i < cnt; i++) {
2655+ GST_DEBUG ("copy PPS %d", i);
2656+ nalsize = (srcp[0] << 8) | srcp[1];
2657+ nal_escape (dstp + 2, srcp + 2, nalsize, &esize);
2658+ dstp[0] = esize >> 8;
2659+ dstp[1] = esize & 0xff;
2660+ dstp += esize + 2;
2661+ srcp += nalsize + 2;
2662+ }
2663+ *destsize = dstp - dst;
2664+
2665+ return;
2666+
2667+full_copy:
2668+ {
2669+ GST_DEBUG ("something unexpected, doing full copy");
2670+ memcpy (dst, src, size);
2671+ *destsize = size;
2672+ return;
2673+ }
2674+}
2675+#endif
2676+
2677+/*
2678+ * caps_with_codecid () transforms a GstCaps for a known codec
2679+ * ID into a filled-in context.
2680+ * codec_data from caps will override possible extradata already in the context
2681+ */
2682+
2683+void
2684+gst_ffmpeg_caps_with_codecid (enum CodecID codec_id,
2685+ enum AVMediaType codec_type, const GstCaps * caps, AVCodecContext * context)
2686+{
2687+ GstStructure *str;
2688+ const GValue *value;
2689+ const GstBuffer *buf;
2690+
2691+ GST_LOG ("codec_id:%d, codec_type:%d, caps:%" GST_PTR_FORMAT " context:%p",
2692+ codec_id, codec_type, caps, context);
2693+
2694+ if (!context || !gst_caps_get_size (caps))
2695+ return;
2696+
2697+ str = gst_caps_get_structure (caps, 0);
2698+
2699+ /* extradata parsing (esds [mpeg4], wma/wmv, msmpeg4v1/2/3, etc.) */
2700+ if ((value = gst_structure_get_value (str, "codec_data"))) {
2701+ guint size;
2702+ guint8 *data;
2703+
2704+ buf = GST_BUFFER_CAST (gst_value_get_mini_object (value));
2705+ size = GST_BUFFER_SIZE (buf);
2706+ data = GST_BUFFER_DATA (buf);
2707+
2708+ /* free the old one if it is there */
2709+ if (context->extradata)
2710+ av_free (context->extradata);
2711+
2712+#if 0
2713+ if (codec_id == CODEC_ID_H264) {
2714+ guint extrasize;
2715+
2716+ GST_DEBUG ("copy, escaping codec_data %d", size);
2717+ /* ffmpeg h264 expects the codec_data to be escaped, there is no real
2718+ * reason for this but let's just escape it for now. Start by allocating
2719+ * enough space, x2 is more than enough.
2720+ *
2721+ * FIXME, we disabled escaping because some file already contain escaped
2722+ * codec_data and then we escape twice and fail. It's better to leave it
2723+ * as is, as that is what most players do. */
2724+ context->extradata =
2725+ av_mallocz (GST_ROUND_UP_16 (size * 2 +
2726+ FF_INPUT_BUFFER_PADDING_SIZE));
2727+ copy_config (context->extradata, data, size, &extrasize);
2728+ GST_DEBUG ("escaped size: %d", extrasize);
2729+ context->extradata_size = extrasize;
2730+ } else
2731+#endif
2732+ {
2733+ /* allocate with enough padding */
2734+ GST_DEBUG ("copy codec_data");
2735+ context->extradata =
2736+ av_mallocz (GST_ROUND_UP_16 (size + FF_INPUT_BUFFER_PADDING_SIZE));
2737+ memcpy (context->extradata, data, size);
2738+ context->extradata_size = size;
2739+ }
2740+
2741+ /* Hack for VC1. Sometimes the first (length) byte is 0 for some files */
2742+ if (codec_id == CODEC_ID_VC1 && size > 0 && data[0] == 0) {
2743+ context->extradata[0] = (guint8) size;
2744+ }
2745+
2746+ GST_DEBUG ("have codec data of size %d", size);
2747+ } else if (context->extradata == NULL && codec_id != CODEC_ID_AAC_LATM &&
2748+ codec_id != CODEC_ID_FLAC) {
2749+ /* no extradata, alloc dummy with 0 sized, some codecs insist on reading
2750+ * extradata anyway which makes then segfault. */
2751+ context->extradata =
2752+ av_mallocz (GST_ROUND_UP_16 (FF_INPUT_BUFFER_PADDING_SIZE));
2753+ context->extradata_size = 0;
2754+ GST_DEBUG ("no codec data");
2755+ }
2756+
2757+ switch (codec_id) {
2758+ case CODEC_ID_MPEG4:
2759+ {
2760+ const gchar *mime = gst_structure_get_name (str);
2761+
2762+ if (!strcmp (mime, "video/x-divx"))
2763+ context->codec_tag = GST_MAKE_FOURCC ('D', 'I', 'V', 'X');
2764+ else if (!strcmp (mime, "video/x-xvid"))
2765+ context->codec_tag = GST_MAKE_FOURCC ('X', 'V', 'I', 'D');
2766+ else if (!strcmp (mime, "video/x-3ivx"))
2767+ context->codec_tag = GST_MAKE_FOURCC ('3', 'I', 'V', '1');
2768+ else if (!strcmp (mime, "video/mpeg"))
2769+ context->codec_tag = GST_MAKE_FOURCC ('m', 'p', '4', 'v');
2770+ }
2771+ break;
2772+
2773+ case CODEC_ID_SVQ3:
2774+ /* FIXME: this is a workaround for older gst-plugins releases
2775+ * (<= 0.8.9). This should be removed at some point, because
2776+ * it causes wrong decoded frame order. */
2777+ if (!context->extradata) {
2778+ gint halfpel_flag, thirdpel_flag, low_delay, unknown_svq3_flag;
2779+ guint16 flags;
2780+
2781+ if (gst_structure_get_int (str, "halfpel_flag", &halfpel_flag) ||
2782+ gst_structure_get_int (str, "thirdpel_flag", &thirdpel_flag) ||
2783+ gst_structure_get_int (str, "low_delay", &low_delay) ||
2784+ gst_structure_get_int (str, "unknown_svq3_flag",
2785+ &unknown_svq3_flag)) {
2786+ context->extradata = (guint8 *) av_mallocz (0x64);
2787+ g_stpcpy ((gchar *) context->extradata, "SVQ3");
2788+ flags = 1 << 3;
2789+ flags |= low_delay;
2790+ flags = flags << 2;
2791+ flags |= unknown_svq3_flag;
2792+ flags = flags << 6;
2793+ flags |= halfpel_flag;
2794+ flags = flags << 1;
2795+ flags |= thirdpel_flag;
2796+ flags = flags << 3;
2797+
2798+ flags = GUINT16_FROM_LE (flags);
2799+
2800+ memcpy ((gchar *) context->extradata + 0x62, &flags, 2);
2801+ context->extradata_size = 0x64;
2802+ }
2803+ }
2804+ break;
2805+
2806+ case CODEC_ID_MSRLE:
2807+ case CODEC_ID_QTRLE:
2808+ case CODEC_ID_TSCC:
2809+ case CODEC_ID_CSCD:
2810+ case CODEC_ID_APE:
2811+ {
2812+ gint depth;
2813+
2814+ if (gst_structure_get_int (str, "depth", &depth)) {
2815+ context->bits_per_coded_sample = depth;
2816+ } else {
2817+ GST_WARNING ("No depth field in caps %" GST_PTR_FORMAT, caps);
2818+ }
2819+
2820+ }
2821+ break;
2822+
2823+ case CODEC_ID_RV10:
2824+ case CODEC_ID_RV20:
2825+ case CODEC_ID_RV30:
2826+ case CODEC_ID_RV40:
2827+ {
2828+ gint format;
2829+
2830+ if (gst_structure_get_int (str, "format", &format))
2831+ context->sub_id = format;
2832+
2833+ break;
2834+ }
2835+ case CODEC_ID_COOK:
2836+ case CODEC_ID_RA_288:
2837+ case CODEC_ID_RA_144:
2838+ case CODEC_ID_SIPR:
2839+ {
2840+ gint leaf_size;
2841+ gint bitrate;
2842+
2843+ if (gst_structure_get_int (str, "leaf_size", &leaf_size))
2844+ context->block_align = leaf_size;
2845+ if (gst_structure_get_int (str, "bitrate", &bitrate))
2846+ context->bit_rate = bitrate;
2847+ }
2848+ case CODEC_ID_ALAC:
2849+ gst_structure_get_int (str, "samplesize",
2850+ &context->bits_per_coded_sample);
2851+ break;
2852+
2853+ case CODEC_ID_DVVIDEO:
2854+ {
2855+ guint32 fourcc;
2856+
2857+ if (gst_structure_get_fourcc (str, "format", &fourcc))
2858+ switch (fourcc) {
2859+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
2860+ context->pix_fmt = PIX_FMT_YUYV422;
2861+ break;
2862+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
2863+ context->pix_fmt = PIX_FMT_YUV420P;
2864+ break;
2865+ case GST_MAKE_FOURCC ('A', '4', '2', '0'):
2866+ context->pix_fmt = PIX_FMT_YUVA420P;
2867+ break;
2868+ case GST_MAKE_FOURCC ('Y', '4', '1', 'B'):
2869+ context->pix_fmt = PIX_FMT_YUV411P;
2870+ break;
2871+ case GST_MAKE_FOURCC ('Y', '4', '2', 'B'):
2872+ context->pix_fmt = PIX_FMT_YUV422P;
2873+ break;
2874+ case GST_MAKE_FOURCC ('Y', 'U', 'V', '9'):
2875+ context->pix_fmt = PIX_FMT_YUV410P;
2876+ break;
2877+ default:
2878+ GST_WARNING ("couldn't convert fourcc %" GST_FOURCC_FORMAT
2879+ " to a pixel format", GST_FOURCC_ARGS (fourcc));
2880+ break;
2881+ }
2882+ break;
2883+ }
2884+ case CODEC_ID_H263P:
2885+ {
2886+ gboolean val;
2887+
2888+ if (!gst_structure_get_boolean (str, "annex-f", &val) || val)
2889+ context->flags |= CODEC_FLAG_4MV;
2890+ else
2891+ context->flags &= ~CODEC_FLAG_4MV;
2892+ if ((!gst_structure_get_boolean (str, "annex-i", &val) || val) &&
2893+ (!gst_structure_get_boolean (str, "annex-t", &val) || val))
2894+ context->flags |= CODEC_FLAG_AC_PRED;
2895+ else
2896+ context->flags &= ~CODEC_FLAG_AC_PRED;
2897+ if (!gst_structure_get_boolean (str, "annex-j", &val) || val)
2898+ context->flags |= CODEC_FLAG_LOOP_FILTER;
2899+ else
2900+ context->flags &= ~CODEC_FLAG_LOOP_FILTER;
2901+ break;
2902+ }
2903+ case CODEC_ID_ADPCM_G726:
2904+ {
2905+ const gchar *layout;
2906+
2907+ if ((layout = gst_structure_get_string (str, "layout"))) {
2908+ if (!strcmp (layout, "g721")) {
2909+ context->sample_rate = 8000;
2910+ context->channels = 1;
2911+ context->bit_rate = 32000;
2912+ }
2913+ }
2914+ break;
2915+ }
2916+ default:
2917+ break;
2918+ }
2919+
2920+ if (!gst_caps_is_fixed (caps))
2921+ return;
2922+
2923+ /* common properties (width, height, fps) */
2924+ switch (codec_type) {
2925+ case AVMEDIA_TYPE_VIDEO:
2926+ gst_ffmpeg_caps_to_pixfmt (caps, context, codec_id == CODEC_ID_RAWVIDEO);
2927+ gst_ffmpeg_get_palette (caps, context);
2928+ break;
2929+ case AVMEDIA_TYPE_AUDIO:
2930+ gst_ffmpeg_caps_to_smpfmt (caps, context, FALSE);
2931+ break;
2932+ default:
2933+ break;
2934+ }
2935+
2936+ /* fixup of default settings */
2937+ switch (codec_id) {
2938+ case CODEC_ID_QCELP:
2939+ /* QCELP is always mono, no matter what the caps say */
2940+ context->channels = 1;
2941+ break;
2942+ default:
2943+ break;
2944+ }
2945+}
2946+
2947+/* _formatid_to_caps () is meant for muxers/demuxers, it
2948+ * transforms a name (ffmpeg way of ID'ing these, why don't
2949+ * they have unique numerical IDs?) to the corresponding
2950+ * caps belonging to that mux-format
2951+ *
2952+ * Note: we don't need any additional info because the caps
2953+ * isn't supposed to contain any useful info besides the
2954+ * media type anyway
2955+ */
2956+
2957+GstCaps *
2958+gst_ffmpeg_formatid_to_caps (const gchar * format_name)
2959+{
2960+ GstCaps *caps = NULL;
2961+
2962+ if (!strcmp (format_name, "mpeg")) {
2963+ caps = gst_caps_new_simple ("video/mpeg",
2964+ "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
2965+ } else if (!strcmp (format_name, "mpegts")) {
2966+ caps = gst_caps_new_simple ("video/mpegts",
2967+ "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
2968+ } else if (!strcmp (format_name, "rm")) {
2969+ caps = gst_caps_new_simple ("application/x-pn-realmedia",
2970+ "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
2971+ } else if (!strcmp (format_name, "asf")) {
2972+ caps = gst_caps_new_simple ("video/x-ms-asf", NULL);
2973+ } else if (!strcmp (format_name, "avi")) {
2974+ caps = gst_caps_new_simple ("video/x-msvideo", NULL);
2975+ } else if (!strcmp (format_name, "wav")) {
2976+ caps = gst_caps_new_simple ("audio/x-wav", NULL);
2977+ } else if (!strcmp (format_name, "ape")) {
2978+ caps = gst_caps_new_simple ("application/x-ape", NULL);
2979+ } else if (!strcmp (format_name, "swf")) {
2980+ caps = gst_caps_new_simple ("application/x-shockwave-flash", NULL);
2981+ } else if (!strcmp (format_name, "au")) {
2982+ caps = gst_caps_new_simple ("audio/x-au", NULL);
2983+ } else if (!strcmp (format_name, "dv")) {
2984+ caps = gst_caps_new_simple ("video/x-dv",
2985+ "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
2986+ } else if (!strcmp (format_name, "4xm")) {
2987+ caps = gst_caps_new_simple ("video/x-4xm", NULL);
2988+ } else if (!strcmp (format_name, "matroska")) {
2989+ caps = gst_caps_new_simple ("video/x-matroska", NULL);
2990+ } else if (!strcmp (format_name, "mp3")) {
2991+ caps = gst_caps_new_simple ("application/x-id3", NULL);
2992+ } else if (!strcmp (format_name, "flic")) {
2993+ caps = gst_caps_new_simple ("video/x-fli", NULL);
2994+ } else if (!strcmp (format_name, "flv")) {
2995+ caps = gst_caps_new_simple ("video/x-flv", NULL);
2996+ } else if (!strcmp (format_name, "tta")) {
2997+ caps = gst_caps_new_simple ("audio/x-ttafile", NULL);
2998+ } else if (!strcmp (format_name, "aiff")) {
2999+ caps = gst_caps_new_simple ("audio/x-aiff", NULL);
3000+ } else if (!strcmp (format_name, "mov_mp4_m4a_3gp_3g2")) {
3001+ caps =
3002+ gst_caps_from_string
3003+ ("application/x-3gp; video/quicktime; audio/x-m4a");
3004+ } else if (!strcmp (format_name, "mov")) {
3005+ caps = gst_caps_from_string ("video/quicktime,variant=(string)apple");
3006+ } else if (!strcmp (format_name, "mp4")) {
3007+ caps = gst_caps_from_string ("video/quicktime,variant=(string)iso");
3008+ } else if (!strcmp (format_name, "3gp")) {
3009+ caps = gst_caps_from_string ("video/quicktime,variant=(string)3gpp");
3010+ } else if (!strcmp (format_name, "3g2")) {
3011+ caps = gst_caps_from_string ("video/quicktime,variant=(string)3g2");
3012+ } else if (!strcmp (format_name, "psp")) {
3013+ caps = gst_caps_from_string ("video/quicktime,variant=(string)psp");
3014+ } else if (!strcmp (format_name, "ipod")) {
3015+ caps = gst_caps_from_string ("video/quicktime,variant=(string)ipod");
3016+ } else if (!strcmp (format_name, "aac")) {
3017+ caps = gst_caps_new_simple ("audio/mpeg",
3018+ "mpegversion", G_TYPE_INT, 4, NULL);
3019+ } else if (!strcmp (format_name, "gif")) {
3020+ caps = gst_caps_from_string ("image/gif");
3021+ } else if (!strcmp (format_name, "ogg")) {
3022+ caps = gst_caps_from_string ("application/ogg");
3023+ } else if (!strcmp (format_name, "mxf") || !strcmp (format_name, "mxf_d10")) {
3024+ caps = gst_caps_from_string ("application/mxf");
3025+ } else if (!strcmp (format_name, "gxf")) {
3026+ caps = gst_caps_from_string ("application/gxf");
3027+ } else if (!strcmp (format_name, "yuv4mpegpipe")) {
3028+ caps = gst_caps_new_simple ("application/x-yuv4mpeg",
3029+ "y4mversion", G_TYPE_INT, 2, NULL);
3030+ } else if (!strcmp (format_name, "mpc")) {
3031+ caps = gst_caps_from_string ("audio/x-musepack, streamversion = (int) 7");
3032+ } else if (!strcmp (format_name, "vqf")) {
3033+ caps = gst_caps_from_string ("audio/x-vqf");
3034+ } else if (!strcmp (format_name, "nsv")) {
3035+ caps = gst_caps_from_string ("video/x-nsv");
3036+ } else if (!strcmp (format_name, "amr")) {
3037+ caps = gst_caps_from_string ("audio/x-amr-nb-sh");
3038+ } else if (!strcmp (format_name, "webm")) {
3039+ caps = gst_caps_from_string ("video/webm");
3040+ } else {
3041+ gchar *name;
3042+
3043+ GST_LOG ("Could not create stream format caps for %s", format_name);
3044+ name = g_strdup_printf ("application/x-gst_ff-%s", format_name);
3045+ caps = gst_caps_new_simple (name, NULL);
3046+ g_free (name);
3047+ }
3048+
3049+ return caps;
3050+}
3051+
3052+gboolean
3053+gst_ffmpeg_formatid_get_codecids (const gchar * format_name,
3054+ enum CodecID ** video_codec_list, enum CodecID ** audio_codec_list,
3055+ AVOutputFormat * plugin)
3056+{
3057+ static enum CodecID tmp_vlist[] = {
3058+ CODEC_ID_NONE,
3059+ CODEC_ID_NONE
3060+ };
3061+ static enum CodecID tmp_alist[] = {
3062+ CODEC_ID_NONE,
3063+ CODEC_ID_NONE
3064+ };
3065+
3066+ GST_LOG ("format_name : %s", format_name);
3067+
3068+ if (!strcmp (format_name, "mp4")) {
3069+ static enum CodecID mp4_video_list[] = {
3070+ CODEC_ID_MPEG4, CODEC_ID_H264,
3071+ CODEC_ID_MJPEG,
3072+ CODEC_ID_NONE
3073+ };
3074+ static enum CodecID mp4_audio_list[] = {
3075+ CODEC_ID_AAC, CODEC_ID_MP3,
3076+ CODEC_ID_NONE
3077+ };
3078+
3079+ *video_codec_list = mp4_video_list;
3080+ *audio_codec_list = mp4_audio_list;
3081+ } else if (!strcmp (format_name, "mpeg")) {
3082+ static enum CodecID mpeg_video_list[] = { CODEC_ID_MPEG1VIDEO,
3083+ CODEC_ID_MPEG2VIDEO,
3084+ CODEC_ID_H264,
3085+ CODEC_ID_NONE
3086+ };
3087+ static enum CodecID mpeg_audio_list[] = { CODEC_ID_MP1,
3088+ CODEC_ID_MP2,
3089+ CODEC_ID_MP3,
3090+ CODEC_ID_NONE
3091+ };
3092+
3093+ *video_codec_list = mpeg_video_list;
3094+ *audio_codec_list = mpeg_audio_list;
3095+ } else if (!strcmp (format_name, "dvd")) {
3096+ static enum CodecID mpeg_video_list[] = { CODEC_ID_MPEG2VIDEO,
3097+ CODEC_ID_NONE
3098+ };
3099+ static enum CodecID mpeg_audio_list[] = { CODEC_ID_MP2,
3100+ CODEC_ID_AC3,
3101+ CODEC_ID_DTS,
3102+ CODEC_ID_PCM_S16BE,
3103+ CODEC_ID_NONE
3104+ };
3105+
3106+ *video_codec_list = mpeg_video_list;
3107+ *audio_codec_list = mpeg_audio_list;
3108+ } else if (!strcmp (format_name, "mpegts")) {
3109+ static enum CodecID mpegts_video_list[] = { CODEC_ID_MPEG1VIDEO,
3110+ CODEC_ID_MPEG2VIDEO,
3111+ CODEC_ID_H264,
3112+ CODEC_ID_NONE
3113+ };
3114+ static enum CodecID mpegts_audio_list[] = { CODEC_ID_MP2,
3115+ CODEC_ID_MP3,
3116+ CODEC_ID_AC3,
3117+ CODEC_ID_DTS,
3118+ CODEC_ID_AAC,
3119+ CODEC_ID_NONE
3120+ };
3121+
3122+ *video_codec_list = mpegts_video_list;
3123+ *audio_codec_list = mpegts_audio_list;
3124+ } else if (!strcmp (format_name, "vob")) {
3125+ static enum CodecID vob_video_list[] =
3126+ { CODEC_ID_MPEG2VIDEO, CODEC_ID_NONE };
3127+ static enum CodecID vob_audio_list[] = { CODEC_ID_MP2, CODEC_ID_AC3,
3128+ CODEC_ID_DTS, CODEC_ID_NONE
3129+ };
3130+
3131+ *video_codec_list = vob_video_list;
3132+ *audio_codec_list = vob_audio_list;
3133+ } else if (!strcmp (format_name, "flv")) {
3134+ static enum CodecID flv_video_list[] = { CODEC_ID_FLV1, CODEC_ID_NONE };
3135+ static enum CodecID flv_audio_list[] = { CODEC_ID_MP3, CODEC_ID_NONE };
3136+
3137+ *video_codec_list = flv_video_list;
3138+ *audio_codec_list = flv_audio_list;
3139+ } else if (!strcmp (format_name, "asf")) {
3140+ static enum CodecID asf_video_list[] =
3141+ { CODEC_ID_WMV1, CODEC_ID_WMV2, CODEC_ID_MSMPEG4V3, CODEC_ID_NONE };
3142+ static enum CodecID asf_audio_list[] =
3143+ { CODEC_ID_WMAV1, CODEC_ID_WMAV2, CODEC_ID_MP3, CODEC_ID_NONE };
3144+
3145+ *video_codec_list = asf_video_list;
3146+ *audio_codec_list = asf_audio_list;
3147+ } else if (!strcmp (format_name, "dv")) {
3148+ static enum CodecID dv_video_list[] = { CODEC_ID_DVVIDEO, CODEC_ID_NONE };
3149+ static enum CodecID dv_audio_list[] = { CODEC_ID_PCM_S16LE, CODEC_ID_NONE };
3150+
3151+ *video_codec_list = dv_video_list;
3152+ *audio_codec_list = dv_audio_list;
3153+ } else if (!strcmp (format_name, "mov")) {
3154+ static enum CodecID mov_video_list[] = {
3155+ CODEC_ID_SVQ1, CODEC_ID_SVQ3, CODEC_ID_MPEG4,
3156+ CODEC_ID_H263, CODEC_ID_H263P,
3157+ CODEC_ID_H264, CODEC_ID_DVVIDEO,
3158+ CODEC_ID_MJPEG,
3159+ CODEC_ID_NONE
3160+ };
3161+ static enum CodecID mov_audio_list[] = {
3162+ CODEC_ID_PCM_MULAW, CODEC_ID_PCM_ALAW, CODEC_ID_ADPCM_IMA_QT,
3163+ CODEC_ID_MACE3, CODEC_ID_MACE6, CODEC_ID_AAC,
3164+ CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
3165+ CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE,
3166+ CODEC_ID_MP3, CODEC_ID_NONE
3167+ };
3168+
3169+ *video_codec_list = mov_video_list;
3170+ *audio_codec_list = mov_audio_list;
3171+ } else if ((!strcmp (format_name, "3gp") || !strcmp (format_name, "3g2"))) {
3172+ static enum CodecID tgp_video_list[] = {
3173+ CODEC_ID_MPEG4, CODEC_ID_H263, CODEC_ID_H263P, CODEC_ID_H264,
3174+ CODEC_ID_NONE
3175+ };
3176+ static enum CodecID tgp_audio_list[] = {
3177+ CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
3178+ CODEC_ID_AAC,
3179+ CODEC_ID_NONE
3180+ };
3181+
3182+ *video_codec_list = tgp_video_list;
3183+ *audio_codec_list = tgp_audio_list;
3184+ } else if (!strcmp (format_name, "mmf")) {
3185+ static enum CodecID mmf_audio_list[] = {
3186+ CODEC_ID_ADPCM_YAMAHA, CODEC_ID_NONE
3187+ };
3188+ *video_codec_list = NULL;
3189+ *audio_codec_list = mmf_audio_list;
3190+ } else if (!strcmp (format_name, "amr")) {
3191+ static enum CodecID amr_audio_list[] = {
3192+ CODEC_ID_AMR_NB, CODEC_ID_AMR_WB,
3193+ CODEC_ID_NONE
3194+ };
3195+ *video_codec_list = NULL;
3196+ *audio_codec_list = amr_audio_list;
3197+ } else if (!strcmp (format_name, "gif")) {
3198+ static enum CodecID gif_image_list[] = {
3199+ CODEC_ID_RAWVIDEO, CODEC_ID_NONE
3200+ };
3201+ *video_codec_list = gif_image_list;
3202+ *audio_codec_list = NULL;
3203+ } else if ((plugin->audio_codec != CODEC_ID_NONE) ||
3204+ (plugin->video_codec != CODEC_ID_NONE)) {
3205+ tmp_vlist[0] = plugin->video_codec;
3206+ tmp_alist[0] = plugin->audio_codec;
3207+
3208+ *video_codec_list = tmp_vlist;
3209+ *audio_codec_list = tmp_alist;
3210+ } else {
3211+ GST_LOG ("Format %s not found", format_name);
3212+ return FALSE;
3213+ }
3214+
3215+ return TRUE;
3216+}
3217+
3218+/* Convert a GstCaps to a FFMPEG codec ID. Size et all
3219+ * are omitted, that can be queried by the user itself,
3220+ * we're not eating the GstCaps or anything
3221+ * A pointer to an allocated context is also needed for
3222+ * optional extra info
3223+ */
3224+
3225+enum CodecID
3226+gst_ffmpeg_caps_to_codecid (const GstCaps * caps, AVCodecContext * context)
3227+{
3228+ enum CodecID id = CODEC_ID_NONE;
3229+ const gchar *mimetype;
3230+ const GstStructure *structure;
3231+ gboolean video = FALSE, audio = FALSE; /* we want to be sure! */
3232+
3233+ g_return_val_if_fail (caps != NULL, CODEC_ID_NONE);
3234+ g_return_val_if_fail (gst_caps_get_size (caps) == 1, CODEC_ID_NONE);
3235+ structure = gst_caps_get_structure (caps, 0);
3236+
3237+ mimetype = gst_structure_get_name (structure);
3238+
3239+ if (!strcmp (mimetype, "video/x-raw-rgb") ||
3240+ !strcmp (mimetype, "video/x-raw-yuv")) {
3241+ id = CODEC_ID_RAWVIDEO;
3242+ video = TRUE;
3243+ } else if (!strcmp (mimetype, "audio/x-raw-int")) {
3244+ gint depth, width, endianness;
3245+ gboolean signedness;
3246+
3247+ if (gst_structure_get_int (structure, "endianness", &endianness) &&
3248+ gst_structure_get_boolean (structure, "signed", &signedness) &&
3249+ gst_structure_get_int (structure, "width", &width) &&
3250+ gst_structure_get_int (structure, "depth", &depth) && depth == width) {
3251+ switch (depth) {
3252+ case 8:
3253+ if (signedness) {
3254+ id = CODEC_ID_PCM_S8;
3255+ } else {
3256+ id = CODEC_ID_PCM_U8;
3257+ }
3258+ break;
3259+ case 16:
3260+ switch (endianness) {
3261+ case G_BIG_ENDIAN:
3262+ if (signedness) {
3263+ id = CODEC_ID_PCM_S16BE;
3264+ } else {
3265+ id = CODEC_ID_PCM_U16BE;
3266+ }
3267+ break;
3268+ case G_LITTLE_ENDIAN:
3269+ if (signedness) {
3270+ id = CODEC_ID_PCM_S16LE;
3271+ } else {
3272+ id = CODEC_ID_PCM_U16LE;
3273+ }
3274+ break;
3275+ }
3276+ break;
3277+ }
3278+ if (id != CODEC_ID_NONE)
3279+ audio = TRUE;
3280+ }
3281+ } else if (!strcmp (mimetype, "audio/x-mulaw")) {
3282+ id = CODEC_ID_PCM_MULAW;
3283+ audio = TRUE;
3284+ } else if (!strcmp (mimetype, "audio/x-alaw")) {
3285+ id = CODEC_ID_PCM_ALAW;
3286+ audio = TRUE;
3287+ } else if (!strcmp (mimetype, "video/x-dv")) {
3288+ gboolean sys_strm;
3289+
3290+ if (gst_structure_get_boolean (structure, "systemstream", &sys_strm) &&
3291+ !sys_strm) {
3292+ id = CODEC_ID_DVVIDEO;
3293+ video = TRUE;
3294+ }
3295+ } else if (!strcmp (mimetype, "audio/x-dv")) { /* ??? */
3296+ id = CODEC_ID_DVAUDIO;
3297+ audio = TRUE;
3298+ } else if (!strcmp (mimetype, "video/x-h263")) {
3299+ const gchar *h263version =
3300+ gst_structure_get_string (structure, "h263version");
3301+ if (h263version && !strcmp (h263version, "h263p"))
3302+ id = CODEC_ID_H263P;
3303+ else
3304+ id = CODEC_ID_H263;
3305+ video = TRUE;
3306+ } else if (!strcmp (mimetype, "video/x-intel-h263")) {
3307+ id = CODEC_ID_H263I;
3308+ video = TRUE;
3309+ } else if (!strcmp (mimetype, "video/x-h261")) {
3310+ id = CODEC_ID_H261;
3311+ video = TRUE;
3312+ } else if (!strcmp (mimetype, "video/mpeg")) {
3313+ gboolean sys_strm;
3314+ gint mpegversion;
3315+
3316+ if (gst_structure_get_boolean (structure, "systemstream", &sys_strm) &&
3317+ gst_structure_get_int (structure, "mpegversion", &mpegversion) &&
3318+ !sys_strm) {
3319+ switch (mpegversion) {
3320+ case 1:
3321+ id = CODEC_ID_MPEG1VIDEO;
3322+ break;
3323+ case 2:
3324+ id = CODEC_ID_MPEG2VIDEO;
3325+ break;
3326+ case 4:
3327+ id = CODEC_ID_MPEG4;
3328+ break;
3329+ }
3330+ }
3331+ if (id != CODEC_ID_NONE)
3332+ video = TRUE;
3333+ } else if (!strcmp (mimetype, "image/jpeg")) {
3334+ id = CODEC_ID_MJPEG; /* A... B... */
3335+ video = TRUE;
3336+ } else if (!strcmp (mimetype, "video/x-jpeg-b")) {
3337+ id = CODEC_ID_MJPEGB;
3338+ video = TRUE;
3339+ } else if (!strcmp (mimetype, "video/x-wmv")) {
3340+ gint wmvversion = 0;
3341+
3342+ if (gst_structure_get_int (structure, "wmvversion", &wmvversion)) {
3343+ switch (wmvversion) {
3344+ case 1:
3345+ id = CODEC_ID_WMV1;
3346+ break;
3347+ case 2:
3348+ id = CODEC_ID_WMV2;
3349+ break;
3350+ case 3:
3351+ {
3352+ guint32 fourcc;
3353+
3354+ /* WMV3 unless the fourcc exists and says otherwise */
3355+ id = CODEC_ID_WMV3;
3356+
3357+ if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
3358+ if ((fourcc == GST_MAKE_FOURCC ('W', 'V', 'C', '1')) ||
3359+ (fourcc == GST_MAKE_FOURCC ('W', 'M', 'V', 'A'))) {
3360+ id = CODEC_ID_VC1;
3361+ }
3362+ }
3363+ }
3364+ break;
3365+ }
3366+ }
3367+ if (id != CODEC_ID_NONE)
3368+ video = TRUE;
3369+ } else if (!strcmp (mimetype, "audio/x-vorbis")) {
3370+ id = CODEC_ID_VORBIS;
3371+ audio = TRUE;
3372+ } else if (!strcmp (mimetype, "audio/x-qdm2")) {
3373+ id = CODEC_ID_QDM2;
3374+ audio = TRUE;
3375+ } else if (!strcmp (mimetype, "audio/mpeg")) {
3376+ gint layer = 0;
3377+ gint mpegversion = 0;
3378+
3379+ if (gst_structure_get_int (structure, "mpegversion", &mpegversion)) {
3380+ switch (mpegversion) {
3381+ case 2: /* ffmpeg uses faad for both... */
3382+ case 4:
3383+ id = CODEC_ID_AAC;
3384+ break;
3385+ case 1:
3386+ if (gst_structure_get_int (structure, "layer", &layer)) {
3387+ switch (layer) {
3388+ case 1:
3389+ id = CODEC_ID_MP1;
3390+ break;
3391+ case 2:
3392+ id = CODEC_ID_MP2;
3393+ break;
3394+ case 3:
3395+ id = CODEC_ID_MP3;
3396+ break;
3397+ }
3398+ }
3399+ }
3400+ }
3401+ if (id != CODEC_ID_NONE)
3402+ audio = TRUE;
3403+ } else if (!strcmp (mimetype, "audio/x-musepack")) {
3404+ gint streamversion = -1;
3405+
3406+ if (gst_structure_get_int (structure, "streamversion", &streamversion)) {
3407+ if (streamversion == 7)
3408+ id = CODEC_ID_MUSEPACK7;
3409+ } else {
3410+ id = CODEC_ID_MUSEPACK7;
3411+ }
3412+ } else if (!strcmp (mimetype, "audio/x-wma")) {
3413+ gint wmaversion = 0;
3414+
3415+ if (gst_structure_get_int (structure, "wmaversion", &wmaversion)) {
3416+ switch (wmaversion) {
3417+ case 1:
3418+ id = CODEC_ID_WMAV1;
3419+ break;
3420+ case 2:
3421+ id = CODEC_ID_WMAV2;
3422+ break;
3423+ case 3:
3424+ id = CODEC_ID_WMAPRO;
3425+ break;
3426+ }
3427+ }
3428+ if (id != CODEC_ID_NONE)
3429+ audio = TRUE;
3430+ } else if (!strcmp (mimetype, "audio/x-wms")) {
3431+ id = CODEC_ID_WMAVOICE;
3432+ audio = TRUE;
3433+ } else if (!strcmp (mimetype, "audio/x-ac3")) {
3434+ id = CODEC_ID_AC3;
3435+ audio = TRUE;
3436+ } else if (!strcmp (mimetype, "audio/x-eac3")) {
3437+ id = CODEC_ID_EAC3;
3438+ audio = TRUE;
3439+ } else if (!strcmp (mimetype, "audio/x-vnd.sony.atrac3") ||
3440+ !strcmp (mimetype, "audio/atrac3")) {
3441+ id = CODEC_ID_ATRAC3;
3442+ audio = TRUE;
3443+ } else if (!strcmp (mimetype, "audio/x-dts")) {
3444+ id = CODEC_ID_DTS;
3445+ audio = TRUE;
3446+ } else if (!strcmp (mimetype, "application/x-ape")) {
3447+ id = CODEC_ID_APE;
3448+ audio = TRUE;
3449+ } else if (!strcmp (mimetype, "video/x-msmpeg")) {
3450+ gint msmpegversion = 0;
3451+
3452+ if (gst_structure_get_int (structure, "msmpegversion", &msmpegversion)) {
3453+ switch (msmpegversion) {
3454+ case 41:
3455+ id = CODEC_ID_MSMPEG4V1;
3456+ break;
3457+ case 42:
3458+ id = CODEC_ID_MSMPEG4V2;
3459+ break;
3460+ case 43:
3461+ id = CODEC_ID_MSMPEG4V3;
3462+ break;
3463+ }
3464+ }
3465+ if (id != CODEC_ID_NONE)
3466+ video = TRUE;
3467+ } else if (!strcmp (mimetype, "video/x-svq")) {
3468+ gint svqversion = 0;
3469+
3470+ if (gst_structure_get_int (structure, "svqversion", &svqversion)) {
3471+ switch (svqversion) {
3472+ case 1:
3473+ id = CODEC_ID_SVQ1;
3474+ break;
3475+ case 3:
3476+ id = CODEC_ID_SVQ3;
3477+ break;
3478+ }
3479+ }
3480+ if (id != CODEC_ID_NONE)
3481+ video = TRUE;
3482+ } else if (!strcmp (mimetype, "video/x-huffyuv")) {
3483+ id = CODEC_ID_HUFFYUV;
3484+ video = TRUE;
3485+ } else if (!strcmp (mimetype, "audio/x-mace")) {
3486+ gint maceversion = 0;
3487+
3488+ if (gst_structure_get_int (structure, "maceversion", &maceversion)) {
3489+ switch (maceversion) {
3490+ case 3:
3491+ id = CODEC_ID_MACE3;
3492+ break;
3493+ case 6:
3494+ id = CODEC_ID_MACE6;
3495+ break;
3496+ }
3497+ }
3498+ if (id != CODEC_ID_NONE)
3499+ audio = TRUE;
3500+ } else if (!strcmp (mimetype, "video/x-theora")) {
3501+ id = CODEC_ID_THEORA;
3502+ video = TRUE;
3503+ } else if (!strcmp (mimetype, "video/x-vp3")) {
3504+ id = CODEC_ID_VP3;
3505+ video = TRUE;
3506+ } else if (!strcmp (mimetype, "video/x-vp5")) {
3507+ id = CODEC_ID_VP5;
3508+ video = TRUE;
3509+ } else if (!strcmp (mimetype, "video/x-vp6")) {
3510+ id = CODEC_ID_VP6;
3511+ video = TRUE;
3512+ } else if (!strcmp (mimetype, "video/x-vp6-flash")) {
3513+ id = CODEC_ID_VP6F;
3514+ video = TRUE;
3515+ } else if (!strcmp (mimetype, "video/x-vp6-alpha")) {
3516+ id = CODEC_ID_VP6A;
3517+ video = TRUE;
3518+ } else if (!strcmp (mimetype, "video/x-vp8")) {
3519+ id = CODEC_ID_VP8;
3520+ video = TRUE;
3521+ } else if (!strcmp (mimetype, "video/x-flash-screen")) {
3522+ id = CODEC_ID_FLASHSV;
3523+ video = TRUE;
3524+ } else if (!strcmp (mimetype, "video/x-indeo")) {
3525+ gint indeoversion = 0;
3526+
3527+ if (gst_structure_get_int (structure, "indeoversion", &indeoversion)) {
3528+ switch (indeoversion) {
3529+ case 5:
3530+ id = CODEC_ID_INDEO5;
3531+ break;
3532+ case 3:
3533+ id = CODEC_ID_INDEO3;
3534+ break;
3535+ case 2:
3536+ id = CODEC_ID_INDEO2;
3537+ break;
3538+ }
3539+ if (id != CODEC_ID_NONE)
3540+ video = TRUE;
3541+ }
3542+ } else if (!strcmp (mimetype, "video/x-divx")) {
3543+ gint divxversion = 0;
3544+
3545+ if (gst_structure_get_int (structure, "divxversion", &divxversion)) {
3546+ switch (divxversion) {
3547+ case 3:
3548+ id = CODEC_ID_MSMPEG4V3;
3549+ break;
3550+ case 4:
3551+ case 5:
3552+ id = CODEC_ID_MPEG4;
3553+ break;
3554+ }
3555+ }
3556+ if (id != CODEC_ID_NONE)
3557+ video = TRUE;
3558+ } else if (!strcmp (mimetype, "video/x-3ivx")) {
3559+ id = CODEC_ID_MPEG4;
3560+ video = TRUE;
3561+ } else if (!strcmp (mimetype, "video/x-xvid")) {
3562+ id = CODEC_ID_MPEG4;
3563+ video = TRUE;
3564+ } else if (!strcmp (mimetype, "video/x-ffv")) {
3565+ gint ffvversion = 0;
3566+
3567+ if (gst_structure_get_int (structure, "ffvversion", &ffvversion) &&
3568+ ffvversion == 1) {
3569+ id = CODEC_ID_FFV1;
3570+ video = TRUE;
3571+ }
3572+ } else if (!strcmp (mimetype, "audio/x-adpcm")) {
3573+ const gchar *layout;
3574+
3575+ layout = gst_structure_get_string (structure, "layout");
3576+ if (layout == NULL) {
3577+ /* break */
3578+ } else if (!strcmp (layout, "quicktime")) {
3579+ id = CODEC_ID_ADPCM_IMA_QT;
3580+ } else if (!strcmp (layout, "microsoft")) {
3581+ id = CODEC_ID_ADPCM_MS;
3582+ } else if (!strcmp (layout, "dvi")) {
3583+ id = CODEC_ID_ADPCM_IMA_WAV;
3584+ } else if (!strcmp (layout, "4xm")) {
3585+ id = CODEC_ID_ADPCM_4XM;
3586+ } else if (!strcmp (layout, "smjpeg")) {
3587+ id = CODEC_ID_ADPCM_IMA_SMJPEG;
3588+ } else if (!strcmp (layout, "dk3")) {
3589+ id = CODEC_ID_ADPCM_IMA_DK3;
3590+ } else if (!strcmp (layout, "dk4")) {
3591+ id = CODEC_ID_ADPCM_IMA_DK4;
3592+ } else if (!strcmp (layout, "westwood")) {
3593+ id = CODEC_ID_ADPCM_IMA_WS;
3594+ } else if (!strcmp (layout, "iss")) {
3595+ id = CODEC_ID_ADPCM_IMA_ISS;
3596+ } else if (!strcmp (layout, "xa")) {
3597+ id = CODEC_ID_ADPCM_XA;
3598+ } else if (!strcmp (layout, "adx")) {
3599+ id = CODEC_ID_ADPCM_ADX;
3600+ } else if (!strcmp (layout, "ea")) {
3601+ id = CODEC_ID_ADPCM_EA;
3602+ } else if (!strcmp (layout, "g726")) {
3603+ id = CODEC_ID_ADPCM_G726;
3604+ } else if (!strcmp (layout, "g721")) {
3605+ id = CODEC_ID_ADPCM_G726;
3606+ } else if (!strcmp (layout, "ct")) {
3607+ id = CODEC_ID_ADPCM_CT;
3608+ } else if (!strcmp (layout, "swf")) {
3609+ id = CODEC_ID_ADPCM_SWF;
3610+ } else if (!strcmp (layout, "yamaha")) {
3611+ id = CODEC_ID_ADPCM_YAMAHA;
3612+ } else if (!strcmp (layout, "sbpro2")) {
3613+ id = CODEC_ID_ADPCM_SBPRO_2;
3614+ } else if (!strcmp (layout, "sbpro3")) {
3615+ id = CODEC_ID_ADPCM_SBPRO_3;
3616+ } else if (!strcmp (layout, "sbpro4")) {
3617+ id = CODEC_ID_ADPCM_SBPRO_4;
3618+ }
3619+ if (id != CODEC_ID_NONE)
3620+ audio = TRUE;
3621+ } else if (!strcmp (mimetype, "video/x-4xm")) {
3622+ id = CODEC_ID_4XM;
3623+ video = TRUE;
3624+ } else if (!strcmp (mimetype, "audio/x-dpcm")) {
3625+ const gchar *layout;
3626+
3627+ layout = gst_structure_get_string (structure, "layout");
3628+ if (!layout) {
3629+ /* .. */
3630+ } else if (!strcmp (layout, "roq")) {
3631+ id = CODEC_ID_ROQ_DPCM;
3632+ } else if (!strcmp (layout, "interplay")) {
3633+ id = CODEC_ID_INTERPLAY_DPCM;
3634+ } else if (!strcmp (layout, "xan")) {
3635+ id = CODEC_ID_XAN_DPCM;
3636+ } else if (!strcmp (layout, "sol")) {
3637+ id = CODEC_ID_SOL_DPCM;
3638+ }
3639+ if (id != CODEC_ID_NONE)
3640+ audio = TRUE;
3641+ } else if (!strcmp (mimetype, "audio/x-flac")) {
3642+ id = CODEC_ID_FLAC;
3643+ audio = TRUE;
3644+ } else if (!strcmp (mimetype, "audio/x-shorten")) {
3645+ id = CODEC_ID_SHORTEN;
3646+ audio = TRUE;
3647+ } else if (!strcmp (mimetype, "audio/x-alac")) {
3648+ id = CODEC_ID_ALAC;
3649+ audio = TRUE;
3650+ } else if (!strcmp (mimetype, "video/x-cinepak")) {
3651+ id = CODEC_ID_CINEPAK;
3652+ video = TRUE;
3653+ } else if (!strcmp (mimetype, "video/x-pn-realvideo")) {
3654+ gint rmversion;
3655+
3656+ if (gst_structure_get_int (structure, "rmversion", &rmversion)) {
3657+ switch (rmversion) {
3658+ case 1:
3659+ id = CODEC_ID_RV10;
3660+ break;
3661+ case 2:
3662+ id = CODEC_ID_RV20;
3663+ break;
3664+ case 3:
3665+ id = CODEC_ID_RV30;
3666+ break;
3667+ case 4:
3668+ id = CODEC_ID_RV40;
3669+ break;
3670+ }
3671+ }
3672+ if (id != CODEC_ID_NONE)
3673+ video = TRUE;
3674+ } else if (!strcmp (mimetype, "audio/x-sipro")) {
3675+ id = CODEC_ID_SIPR;
3676+ audio = TRUE;
3677+ } else if (!strcmp (mimetype, "audio/x-pn-realaudio")) {
3678+ gint raversion;
3679+
3680+ if (gst_structure_get_int (structure, "raversion", &raversion)) {
3681+ switch (raversion) {
3682+ case 1:
3683+ id = CODEC_ID_RA_144;
3684+ break;
3685+ case 2:
3686+ id = CODEC_ID_RA_288;
3687+ break;
3688+ case 8:
3689+ id = CODEC_ID_COOK;
3690+ break;
3691+ }
3692+ }
3693+ if (id != CODEC_ID_NONE)
3694+ audio = TRUE;
3695+ } else if (!strcmp (mimetype, "video/x-rle")) {
3696+ const gchar *layout;
3697+
3698+ if ((layout = gst_structure_get_string (structure, "layout"))) {
3699+ if (!strcmp (layout, "microsoft")) {
3700+ id = CODEC_ID_MSRLE;
3701+ video = TRUE;
3702+ }
3703+ }
3704+ } else if (!strcmp (mimetype, "video/x-xan")) {
3705+ gint wcversion = 0;
3706+
3707+ if ((gst_structure_get_int (structure, "wcversion", &wcversion))) {
3708+ switch (wcversion) {
3709+ case 3:
3710+ id = CODEC_ID_XAN_WC3;
3711+ video = TRUE;
3712+ break;
3713+ case 4:
3714+ id = CODEC_ID_XAN_WC4;
3715+ video = TRUE;
3716+ break;
3717+ default:
3718+ break;
3719+ }
3720+ }
3721+ } else if (!strcmp (mimetype, "audio/AMR")) {
3722+ audio = TRUE;
3723+ id = CODEC_ID_AMR_NB;
3724+ } else if (!strcmp (mimetype, "audio/AMR-WB")) {
3725+ id = CODEC_ID_AMR_WB;
3726+ audio = TRUE;
3727+ } else if (!strcmp (mimetype, "audio/qcelp")) {
3728+ id = CODEC_ID_QCELP;
3729+ audio = TRUE;
3730+ } else if (!strcmp (mimetype, "video/x-h264")) {
3731+ id = CODEC_ID_H264;
3732+ video = TRUE;
3733+ } else if (!strcmp (mimetype, "video/x-flash-video")) {
3734+ gint flvversion = 0;
3735+
3736+ if ((gst_structure_get_int (structure, "flvversion", &flvversion))) {
3737+ switch (flvversion) {
3738+ case 1:
3739+ id = CODEC_ID_FLV1;
3740+ video = TRUE;
3741+ break;
3742+ default:
3743+ break;
3744+ }
3745+ }
3746+
3747+ } else if (!strcmp (mimetype, "audio/x-nellymoser")) {
3748+ id = CODEC_ID_NELLYMOSER;
3749+ audio = TRUE;
3750+ } else if (!strncmp (mimetype, "audio/x-gst_ff-", 15)) {
3751+ gchar ext[16];
3752+ AVCodec *codec;
3753+
3754+ if (strlen (mimetype) <= 30 &&
3755+ sscanf (mimetype, "audio/x-gst_ff-%s", ext) == 1) {
3756+ if ((codec = avcodec_find_decoder_by_name (ext)) ||
3757+ (codec = avcodec_find_encoder_by_name (ext))) {
3758+ id = codec->id;
3759+ audio = TRUE;
3760+ }
3761+ }
3762+ } else if (!strncmp (mimetype, "video/x-gst_ff-", 15)) {
3763+ gchar ext[16];
3764+ AVCodec *codec;
3765+
3766+ if (strlen (mimetype) <= 30 &&
3767+ sscanf (mimetype, "video/x-gst_ff-%s", ext) == 1) {
3768+ if ((codec = avcodec_find_decoder_by_name (ext)) ||
3769+ (codec = avcodec_find_encoder_by_name (ext))) {
3770+ id = codec->id;
3771+ video = TRUE;
3772+ }
3773+ }
3774+ }
3775+
3776+ if (context != NULL) {
3777+ if (video == TRUE) {
3778+ context->codec_type = AVMEDIA_TYPE_VIDEO;
3779+ } else if (audio == TRUE) {
3780+ context->codec_type = AVMEDIA_TYPE_AUDIO;
3781+ } else {
3782+ context->codec_type = AVMEDIA_TYPE_UNKNOWN;
3783+ }
3784+ context->codec_id = id;
3785+ gst_ffmpeg_caps_with_codecid (id, context->codec_type, caps, context);
3786+ }
3787+
3788+ if (id != CODEC_ID_NONE) {
3789+ GST_DEBUG ("The id=%d belongs to the caps %" GST_PTR_FORMAT, id, caps);
3790+ } else {
3791+ GST_WARNING ("Couldn't figure out the id for caps %" GST_PTR_FORMAT, caps);
3792+ }
3793+
3794+ return id;
3795+}
3796diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.rej gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.rej
3797--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegcodecmap.c.rej 1970-01-01 01:00:00.000000000 +0100
3798+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegcodecmap.c.rej 2014-08-08 15:31:06.055868246 +0200
3799@@ -0,0 +1,12 @@
3800+--- ext/ffmpeg/gstffmpegcodecmap.c
3801++++ ext/ffmpeg/gstffmpegcodecmap.c
3802+@@ -1884,9 +1842,6 @@
3803+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-raw-rgb",
3804+ "bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, "endianness",
3805+ G_TYPE_INT, endianness, NULL);
3806+- if (caps && context) {
3807+- gst_ffmpeg_set_palette (caps, context);
3808+- }
3809+ }
3810+ } else if (fmt) {
3811+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-raw-yuv",
3812diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c
3813--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c 2014-08-08 14:46:31.462772351 +0200
3814+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c 2014-08-08 15:32:18.608870847 +0200
3815@@ -88,7 +88,6 @@
3816 gint depth;
3817 } audio;
3818 } format;
3819- gboolean waiting_for_key;
3820 gboolean discont;
3821 gboolean clear_ts;
3822
3823@@ -438,7 +437,6 @@
3824 ffmpegdec->pcache = NULL;
3825 ffmpegdec->par = NULL;
3826 ffmpegdec->opened = FALSE;
3827- ffmpegdec->waiting_for_key = TRUE;
3828 ffmpegdec->skip_frame = ffmpegdec->lowres = 0;
3829 ffmpegdec->direct_rendering = DEFAULT_DIRECT_RENDERING;
3830 ffmpegdec->do_padding = DEFAULT_DO_PADDING;
3831@@ -608,11 +606,6 @@
3832 gst_ffmpeg_avcodec_close (ffmpegdec->context);
3833 ffmpegdec->opened = FALSE;
3834
3835- if (ffmpegdec->context->palctrl) {
3836- av_free (ffmpegdec->context->palctrl);
3837- ffmpegdec->context->palctrl = NULL;
3838- }
3839-
3840 if (ffmpegdec->context->extradata) {
3841 av_free (ffmpegdec->context->extradata);
3842 ffmpegdec->context->extradata = NULL;
3843@@ -864,7 +857,7 @@
3844
3845 /* workaround encoder bugs */
3846 ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
3847- ffmpegdec->context->error_recognition = 1;
3848+ ffmpegdec->context->err_recognition = 1;
3849
3850 /* for slow cpus */
3851 ffmpegdec->context->lowres = ffmpegdec->lowres;
3852@@ -944,7 +937,7 @@
3853 fsize = gst_ffmpeg_avpicture_get_size (ffmpegdec->context->pix_fmt,
3854 width, height);
3855
3856- if (!ffmpegdec->context->palctrl && ffmpegdec->can_allocate_aligned) {
3857+ if (ffmpegdec->can_allocate_aligned) {
3858 GST_LOG_OBJECT (ffmpegdec, "calling pad_alloc");
3859 /* no pallete, we can use the buffer size to alloc */
3860 ret = gst_pad_alloc_buffer_and_set_caps (ffmpegdec->srcpad,
3861@@ -1083,7 +1076,6 @@
3862 /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to
3863 * the opaque data. */
3864 picture->type = FF_BUFFER_TYPE_USER;
3865- picture->age = 256 * 256 * 256 * 64;
3866 picture->opaque = buf;
3867
3868 #ifdef EXTRA_REF
3869@@ -1414,10 +1406,6 @@
3870 } else {
3871 if (diff >= 0) {
3872 /* we're too slow, try to speed up */
3873- if (ffmpegdec->waiting_for_key) {
3874- /* we were waiting for a keyframe, that's ok */
3875- goto skipping;
3876- }
3877 /* switch to skip_frame mode */
3878 goto skip_frame;
3879 }
3880@@ -1427,11 +1415,6 @@
3881 ffmpegdec->processed++;
3882 return TRUE;
3883
3884-skipping:
3885- {
3886- res = FALSE;
3887- goto drop_qos;
3888- }
3889 normal_mode:
3890 {
3891 if (ffmpegdec->context->skip_frame != AVDISCARD_DEFAULT) {
3892@@ -1528,43 +1511,6 @@
3893 }
3894
3895
3896-/* figure out if the current picture is a keyframe, return TRUE if that is
3897- * the case. */
3898-static gboolean
3899-check_keyframe (GstFFMpegDec * ffmpegdec)
3900-{
3901- GstFFMpegDecClass *oclass;
3902- gboolean is_itype = FALSE;
3903- gboolean is_reference = FALSE;
3904- gboolean iskeyframe;
3905-
3906- /* figure out if we are dealing with a keyframe */
3907- oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
3908-
3909- /* remember that we have B frames, we need this for the DTS -> PTS conversion
3910- * code */
3911- if (!ffmpegdec->has_b_frames && ffmpegdec->picture->pict_type == FF_B_TYPE) {
3912- GST_DEBUG_OBJECT (ffmpegdec, "we have B frames");
3913- ffmpegdec->has_b_frames = TRUE;
3914- }
3915-
3916- is_itype = (ffmpegdec->picture->pict_type == FF_I_TYPE);
3917- is_reference = (ffmpegdec->picture->reference == 1);
3918-
3919- iskeyframe = (is_itype || is_reference || ffmpegdec->picture->key_frame)
3920- || (oclass->in_plugin->id == CODEC_ID_INDEO3)
3921- || (oclass->in_plugin->id == CODEC_ID_MSZH)
3922- || (oclass->in_plugin->id == CODEC_ID_ZLIB)
3923- || (oclass->in_plugin->id == CODEC_ID_VP3)
3924- || (oclass->in_plugin->id == CODEC_ID_HUFFYUV);
3925-
3926- GST_LOG_OBJECT (ffmpegdec,
3927- "current picture: type: %d, is_keyframe:%d, is_itype:%d, is_reference:%d",
3928- ffmpegdec->picture->pict_type, iskeyframe, is_itype, is_reference);
3929-
3930- return iskeyframe;
3931-}
3932-
3933 /* get an outbuf buffer with the current picture */
3934 static GstFlowReturn
3935 get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
3936@@ -1694,7 +1640,6 @@
3937 {
3938 gint len = -1;
3939 gint have_data;
3940- gboolean iskeyframe;
3941 gboolean mode_switch;
3942 gboolean decode;
3943 gint skip_frame = AVDISCARD_DEFAULT;
3944@@ -1809,7 +1754,6 @@
3945 gst_ffmpegdec_negotiate (ffmpegdec, TRUE);
3946 }
3947
3948-
3949 /* Whether a frame is interlaced or not is unknown at the time of
3950 buffer allocation, so caps on the buffer in opaque will have
3951 the previous frame's interlaced flag set. So if interlacedness
3952@@ -1831,10 +1775,6 @@
3953 }
3954 }
3955
3956- /* check if we are dealing with a keyframe here, this will also check if we
3957- * are dealing with B frames. */
3958- iskeyframe = check_keyframe (ffmpegdec);
3959-
3960 /* check that the timestamps go upwards */
3961 if (ffmpegdec->last_out != -1 && ffmpegdec->last_out > out_pts) {
3962 /* timestamps go backwards, this means frames were reordered and we must
3963@@ -1865,7 +1805,7 @@
3964 * timestamps */
3965 if (!ffmpegdec->reordered_in && ffmpegdec->reordered_out) {
3966 /* PTS and DTS are the same for keyframes */
3967- if (!iskeyframe && ffmpegdec->next_out != -1) {
3968+ if (ffmpegdec->next_out != -1) {
3969 /* interpolate all timestamps except for keyframes, FIXME, this is
3970 * wrong when QoS is active. */
3971 GST_DEBUG_OBJECT (ffmpegdec, "interpolate timestamps");
3972@@ -1874,16 +1814,6 @@
3973 }
3974 }
3975
3976- /* when we're waiting for a keyframe, see if we have one or drop the current
3977- * non-keyframe */
3978- if (G_UNLIKELY (ffmpegdec->waiting_for_key)) {
3979- if (G_LIKELY (!iskeyframe))
3980- goto drop_non_keyframe;
3981-
3982- /* we have a keyframe, we can stop waiting for one */
3983- ffmpegdec->waiting_for_key = FALSE;
3984- }
3985-
3986 /* get a handle to the output buffer */
3987 *ret = get_output_buffer (ffmpegdec, outbuf);
3988 if (G_UNLIKELY (*ret != GST_FLOW_OK))
3989@@ -2000,20 +1930,11 @@
3990 else
3991 ffmpegdec->next_out = -1;
3992
3993- /* palette is not part of raw video frame in gst and the size
3994- * of the outgoing buffer needs to be adjusted accordingly */
3995- if (ffmpegdec->context->palctrl != NULL)
3996- GST_BUFFER_SIZE (*outbuf) -= AVPALETTE_SIZE;
3997-
3998 /* now see if we need to clip the buffer against the segment boundaries. */
3999 if (G_UNLIKELY (!clip_video_buffer (ffmpegdec, *outbuf, out_timestamp,
4000 out_duration)))
4001 goto clipped;
4002
4003- /* mark as keyframe or delta unit */
4004- if (!iskeyframe)
4005- GST_BUFFER_FLAG_SET (*outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
4006-
4007 if (ffmpegdec->picture->top_field_first)
4008 GST_BUFFER_FLAG_SET (*outbuf, GST_VIDEO_BUFFER_TFF);
4009
4010@@ -2024,11 +1945,6 @@
4011 return len;
4012
4013 /* special cases */
4014-drop_non_keyframe:
4015- {
4016- GST_WARNING_OBJECT (ffmpegdec, "Dropping non-keyframe (seek/init)");
4017- goto beach;
4018- }
4019 no_output:
4020 {
4021 GST_DEBUG_OBJECT (ffmpegdec, "no output buffer");
4022@@ -2422,7 +2338,6 @@
4023 gst_ffmpegdec_reset_ts (ffmpegdec);
4024 gst_ffmpegdec_reset_qos (ffmpegdec);
4025 gst_ffmpegdec_flush_pcache (ffmpegdec);
4026- ffmpegdec->waiting_for_key = TRUE;
4027 gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
4028 clear_queued (ffmpegdec);
4029 break;
4030@@ -2560,17 +2475,6 @@
4031
4032 oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
4033
4034- /* do early keyframe check pretty bad to rely on the keyframe flag in the
4035- * source for this as it might not even be parsed (UDP/file/..). */
4036- if (G_UNLIKELY (ffmpegdec->waiting_for_key)) {
4037- GST_DEBUG_OBJECT (ffmpegdec, "waiting for keyframe");
4038- if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_DELTA_UNIT) &&
4039- oclass->in_plugin->type != AVMEDIA_TYPE_AUDIO)
4040- goto skip_keyframe;
4041-
4042- GST_DEBUG_OBJECT (ffmpegdec, "got keyframe");
4043- ffmpegdec->waiting_for_key = FALSE;
4044- }
4045 /* parse cache joining. If there is cached data */
4046 if (ffmpegdec->pcache) {
4047 /* join with previous data */
4048@@ -2805,12 +2709,6 @@
4049 gst_buffer_unref (inbuf);
4050 return GST_FLOW_NOT_NEGOTIATED;
4051 }
4052-skip_keyframe:
4053- {
4054- GST_DEBUG_OBJECT (ffmpegdec, "skipping non keyframe");
4055- gst_buffer_unref (inbuf);
4056- return GST_FLOW_OK;
4057- }
4058 }
4059
4060 static GstStateChangeReturn
4061@@ -2936,7 +2834,7 @@
4062 gchar *plugin_name;
4063
4064 /* only decoders */
4065- if (!in_plugin->decode) {
4066+ if (!av_codec_is_decoder (in_plugin)) {
4067 goto next;
4068 }
4069
4070diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.orig
4071--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.orig 1970-01-01 01:00:00.000000000 +0100
4072+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.orig 2014-08-08 15:31:06.057868246 +0200
4073@@ -0,0 +1,2973 @@
4074+/* GStreamer
4075+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
4076+ *
4077+ * This library is free software; you can redistribute it and/or
4078+ * modify it under the terms of the GNU Library General Public
4079+ * License as published by the Free Software Foundation; either
4080+ * version 2 of the License, or (at your option) any later version.
4081+ *
4082+ * This library is distributed in the hope that it will be useful,
4083+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4084+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4085+ * Library General Public License for more details.
4086+ *
4087+ * You should have received a copy of the GNU Library General Public
4088+ * License along with this library; if not, write to the
4089+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
4090+ * Boston, MA 02111-1307, USA.
4091+ */
4092+
4093+#ifdef HAVE_CONFIG_H
4094+#include "config.h"
4095+#endif
4096+
4097+#include <assert.h>
4098+#include <string.h>
4099+
4100+#ifdef HAVE_FFMPEG_UNINSTALLED
4101+#include <avcodec.h>
4102+#else
4103+#include <libavcodec/avcodec.h>
4104+#endif
4105+
4106+#include <gst/gst.h>
4107+#include <gst/video/video.h>
4108+
4109+#include "gstffmpeg.h"
4110+#include "gstffmpegcodecmap.h"
4111+#include "gstffmpegutils.h"
4112+
4113+/* define to enable alternative buffer refcounting algorithm */
4114+#undef EXTRA_REF
4115+
4116+typedef struct _GstFFMpegDec GstFFMpegDec;
4117+
4118+#define MAX_TS_MASK 0xff
4119+
4120+/* for each incomming buffer we keep all timing info in a structure like this.
4121+ * We keep a circular array of these structures around to store the timing info.
4122+ * The index in the array is what we pass as opaque data (to pictures) and
4123+ * pts (to parsers) so that ffmpeg can remember them for us. */
4124+typedef struct
4125+{
4126+ gint idx;
4127+ GstClockTime timestamp;
4128+ GstClockTime duration;
4129+ gint64 offset;
4130+} GstTSInfo;
4131+
4132+struct _GstFFMpegDec
4133+{
4134+ GstElement element;
4135+
4136+ /* We need to keep track of our pads, so we do so here. */
4137+ GstPad *srcpad;
4138+ GstPad *sinkpad;
4139+
4140+ /* decoding */
4141+ AVCodecContext *context;
4142+ AVFrame *picture;
4143+ gboolean opened;
4144+ union
4145+ {
4146+ struct
4147+ {
4148+ gint width, height;
4149+ gint clip_width, clip_height;
4150+ gint par_n, par_d;
4151+ gint fps_n, fps_d;
4152+ gint old_fps_n, old_fps_d;
4153+ gboolean interlaced;
4154+
4155+ enum PixelFormat pix_fmt;
4156+ } video;
4157+ struct
4158+ {
4159+ gint channels;
4160+ gint samplerate;
4161+ gint depth;
4162+ } audio;
4163+ } format;
4164+ gboolean discont;
4165+ gboolean clear_ts;
4166+
4167+ /* for tracking DTS/PTS */
4168+ gboolean has_b_frames;
4169+ gboolean reordered_in;
4170+ GstClockTime last_in;
4171+ GstClockTime last_diff;
4172+ guint last_frames;
4173+ gboolean reordered_out;
4174+ GstClockTime last_out;
4175+ GstClockTime next_out;
4176+
4177+ /* parsing */
4178+ gboolean turnoff_parser; /* used for turning off aac raw parsing
4179+ * See bug #566250 */
4180+ AVCodecParserContext *pctx;
4181+ GstBuffer *pcache;
4182+ guint8 *padded;
4183+ guint padded_size;
4184+
4185+ GValue *par; /* pixel aspect ratio of incoming data */
4186+ gboolean current_dr; /* if direct rendering is enabled */
4187+ gboolean extra_ref; /* keep extra ref around in get/release */
4188+
4189+ /* some properties */
4190+ enum AVDiscard skip_frame;
4191+ gint lowres;
4192+ gboolean direct_rendering;
4193+ gboolean do_padding;
4194+ gboolean debug_mv;
4195+ gboolean crop;
4196+ int max_threads;
4197+
4198+ /* QoS stuff *//* with LOCK */
4199+ gdouble proportion;
4200+ GstClockTime earliest_time;
4201+ gint64 processed;
4202+ gint64 dropped;
4203+
4204+ /* clipping segment */
4205+ GstSegment segment;
4206+
4207+ gboolean is_realvideo;
4208+
4209+ GstTSInfo ts_info[MAX_TS_MASK + 1];
4210+ gint ts_idx;
4211+
4212+ /* reverse playback queue */
4213+ GList *queued;
4214+
4215+ /* Can downstream allocate 16bytes aligned data. */
4216+ gboolean can_allocate_aligned;
4217+};
4218+
4219+typedef struct _GstFFMpegDecClass GstFFMpegDecClass;
4220+
4221+struct _GstFFMpegDecClass
4222+{
4223+ GstElementClass parent_class;
4224+
4225+ AVCodec *in_plugin;
4226+ GstPadTemplate *srctempl, *sinktempl;
4227+};
4228+
4229+#define GST_TS_INFO_NONE &ts_info_none
4230+static const GstTSInfo ts_info_none = { -1, -1, -1, -1 };
4231+
4232+static const GstTSInfo *
4233+gst_ts_info_store (GstFFMpegDec * dec, GstClockTime timestamp,
4234+ GstClockTime duration, gint64 offset)
4235+{
4236+ gint idx = dec->ts_idx;
4237+ dec->ts_info[idx].idx = idx;
4238+ dec->ts_info[idx].timestamp = timestamp;
4239+ dec->ts_info[idx].duration = duration;
4240+ dec->ts_info[idx].offset = offset;
4241+ dec->ts_idx = (idx + 1) & MAX_TS_MASK;
4242+
4243+ return &dec->ts_info[idx];
4244+}
4245+
4246+static const GstTSInfo *
4247+gst_ts_info_get (GstFFMpegDec * dec, gint idx)
4248+{
4249+ if (G_UNLIKELY (idx < 0 || idx > MAX_TS_MASK))
4250+ return GST_TS_INFO_NONE;
4251+
4252+ return &dec->ts_info[idx];
4253+}
4254+
4255+#define GST_TYPE_FFMPEGDEC \
4256+ (gst_ffmpegdec_get_type())
4257+#define GST_FFMPEGDEC(obj) \
4258+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGDEC,GstFFMpegDec))
4259+#define GST_FFMPEGDEC_CLASS(klass) \
4260+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGDEC,GstFFMpegDecClass))
4261+#define GST_IS_FFMPEGDEC(obj) \
4262+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGDEC))
4263+#define GST_IS_FFMPEGDEC_CLASS(klass) \
4264+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGDEC))
4265+
4266+#define DEFAULT_LOWRES 0
4267+#define DEFAULT_SKIPFRAME 0
4268+#define DEFAULT_DIRECT_RENDERING TRUE
4269+#define DEFAULT_DO_PADDING TRUE
4270+#define DEFAULT_DEBUG_MV FALSE
4271+#define DEFAULT_CROP TRUE
4272+#define DEFAULT_MAX_THREADS 1
4273+
4274+enum
4275+{
4276+ PROP_0,
4277+ PROP_LOWRES,
4278+ PROP_SKIPFRAME,
4279+ PROP_DIRECT_RENDERING,
4280+ PROP_DO_PADDING,
4281+ PROP_DEBUG_MV,
4282+ PROP_CROP,
4283+ PROP_MAX_THREADS,
4284+ PROP_LAST
4285+};
4286+
4287+/* A number of function prototypes are given so we can refer to them later. */
4288+static void gst_ffmpegdec_base_init (GstFFMpegDecClass * klass);
4289+static void gst_ffmpegdec_class_init (GstFFMpegDecClass * klass);
4290+static void gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec);
4291+static void gst_ffmpegdec_finalize (GObject * object);
4292+
4293+static gboolean gst_ffmpegdec_query (GstPad * pad, GstQuery * query);
4294+static gboolean gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event);
4295+
4296+static gboolean gst_ffmpegdec_setcaps (GstPad * pad, GstCaps * caps);
4297+static gboolean gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event);
4298+static GstFlowReturn gst_ffmpegdec_chain (GstPad * pad, GstBuffer * buf);
4299+
4300+static GstStateChangeReturn gst_ffmpegdec_change_state (GstElement * element,
4301+ GstStateChange transition);
4302+
4303+static void gst_ffmpegdec_set_property (GObject * object,
4304+ guint prop_id, const GValue * value, GParamSpec * pspec);
4305+static void gst_ffmpegdec_get_property (GObject * object,
4306+ guint prop_id, GValue * value, GParamSpec * pspec);
4307+
4308+static gboolean gst_ffmpegdec_negotiate (GstFFMpegDec * ffmpegdec,
4309+ gboolean force);
4310+
4311+/* some sort of bufferpool handling, but different */
4312+static int gst_ffmpegdec_get_buffer (AVCodecContext * context,
4313+ AVFrame * picture);
4314+static void gst_ffmpegdec_release_buffer (AVCodecContext * context,
4315+ AVFrame * picture);
4316+
4317+static void gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec);
4318+
4319+#define GST_FFDEC_PARAMS_QDATA g_quark_from_static_string("ffdec-params")
4320+
4321+static GstElementClass *parent_class = NULL;
4322+
4323+#define GST_FFMPEGDEC_TYPE_LOWRES (gst_ffmpegdec_lowres_get_type())
4324+static GType
4325+gst_ffmpegdec_lowres_get_type (void)
4326+{
4327+ static GType ffmpegdec_lowres_type = 0;
4328+
4329+ if (!ffmpegdec_lowres_type) {
4330+ static const GEnumValue ffmpegdec_lowres[] = {
4331+ {0, "0", "full"},
4332+ {1, "1", "1/2-size"},
4333+ {2, "2", "1/4-size"},
4334+ {0, NULL, NULL},
4335+ };
4336+
4337+ ffmpegdec_lowres_type =
4338+ g_enum_register_static ("GstFFMpegDecLowres", ffmpegdec_lowres);
4339+ }
4340+
4341+ return ffmpegdec_lowres_type;
4342+}
4343+
4344+#define GST_FFMPEGDEC_TYPE_SKIPFRAME (gst_ffmpegdec_skipframe_get_type())
4345+static GType
4346+gst_ffmpegdec_skipframe_get_type (void)
4347+{
4348+ static GType ffmpegdec_skipframe_type = 0;
4349+
4350+ if (!ffmpegdec_skipframe_type) {
4351+ static const GEnumValue ffmpegdec_skipframe[] = {
4352+ {0, "0", "Skip nothing"},
4353+ {1, "1", "Skip B-frames"},
4354+ {2, "2", "Skip IDCT/Dequantization"},
4355+ {5, "5", "Skip everything"},
4356+ {0, NULL, NULL},
4357+ };
4358+
4359+ ffmpegdec_skipframe_type =
4360+ g_enum_register_static ("GstFFMpegDecSkipFrame", ffmpegdec_skipframe);
4361+ }
4362+
4363+ return ffmpegdec_skipframe_type;
4364+}
4365+
4366+static void
4367+gst_ffmpegdec_base_init (GstFFMpegDecClass * klass)
4368+{
4369+ GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
4370+ GstPadTemplate *sinktempl, *srctempl;
4371+ GstCaps *sinkcaps, *srccaps;
4372+ AVCodec *in_plugin;
4373+ gchar *longname, *classification, *description;
4374+
4375+ in_plugin =
4376+ (AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
4377+ GST_FFDEC_PARAMS_QDATA);
4378+ g_assert (in_plugin != NULL);
4379+
4380+ /* construct the element details struct */
4381+ longname = g_strdup_printf ("FFmpeg %s decoder", in_plugin->long_name);
4382+ classification = g_strdup_printf ("Codec/Decoder/%s",
4383+ (in_plugin->type == AVMEDIA_TYPE_VIDEO) ? "Video" : "Audio");
4384+ description = g_strdup_printf ("FFmpeg %s decoder", in_plugin->name);
4385+ gst_element_class_set_details_simple (element_class, longname, classification,
4386+ description,
4387+ "Wim Taymans <wim.taymans@gmail.com>, "
4388+ "Ronald Bultje <rbultje@ronald.bitfreak.net>, "
4389+ "Edward Hervey <bilboed@bilboed.com>");
4390+ g_free (longname);
4391+ g_free (classification);
4392+ g_free (description);
4393+
4394+ /* get the caps */
4395+ sinkcaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, FALSE);
4396+ if (!sinkcaps) {
4397+ GST_DEBUG ("Couldn't get sink caps for decoder '%s'", in_plugin->name);
4398+ sinkcaps = gst_caps_from_string ("unknown/unknown");
4399+ }
4400+ if (in_plugin->type == AVMEDIA_TYPE_VIDEO) {
4401+ srccaps = gst_caps_from_string ("video/x-raw-rgb; video/x-raw-yuv");
4402+ } else {
4403+ srccaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
4404+ in_plugin->id, FALSE, in_plugin);
4405+ }
4406+ if (!srccaps) {
4407+ GST_DEBUG ("Couldn't get source caps for decoder '%s'", in_plugin->name);
4408+ srccaps = gst_caps_from_string ("unknown/unknown");
4409+ }
4410+
4411+ /* pad templates */
4412+ sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
4413+ GST_PAD_ALWAYS, sinkcaps);
4414+ srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
4415+
4416+ gst_element_class_add_pad_template (element_class, srctempl);
4417+ gst_element_class_add_pad_template (element_class, sinktempl);
4418+
4419+ klass->in_plugin = in_plugin;
4420+ klass->srctempl = srctempl;
4421+ klass->sinktempl = sinktempl;
4422+}
4423+
4424+static void
4425+gst_ffmpegdec_class_init (GstFFMpegDecClass * klass)
4426+{
4427+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
4428+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
4429+
4430+ parent_class = g_type_class_peek_parent (klass);
4431+
4432+ gobject_class->finalize = gst_ffmpegdec_finalize;
4433+
4434+ gobject_class->set_property = gst_ffmpegdec_set_property;
4435+ gobject_class->get_property = gst_ffmpegdec_get_property;
4436+
4437+ if (klass->in_plugin->type == AVMEDIA_TYPE_VIDEO) {
4438+ int caps;
4439+
4440+ g_object_class_install_property (gobject_class, PROP_SKIPFRAME,
4441+ g_param_spec_enum ("skip-frame", "Skip frames",
4442+ "Which types of frames to skip during decoding",
4443+ GST_FFMPEGDEC_TYPE_SKIPFRAME, 0,
4444+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
4445+ g_object_class_install_property (gobject_class, PROP_LOWRES,
4446+ g_param_spec_enum ("lowres", "Low resolution",
4447+ "At which resolution to decode images", GST_FFMPEGDEC_TYPE_LOWRES,
4448+ 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
4449+ g_object_class_install_property (gobject_class, PROP_DIRECT_RENDERING,
4450+ g_param_spec_boolean ("direct-rendering", "Direct Rendering",
4451+ "Enable direct rendering", DEFAULT_DIRECT_RENDERING,
4452+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
4453+ g_object_class_install_property (gobject_class, PROP_DO_PADDING,
4454+ g_param_spec_boolean ("do-padding", "Do Padding",
4455+ "Add 0 padding before decoding data", DEFAULT_DO_PADDING,
4456+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
4457+ g_object_class_install_property (gobject_class, PROP_DEBUG_MV,
4458+ g_param_spec_boolean ("debug-mv", "Debug motion vectors",
4459+ "Whether ffmpeg should print motion vectors on top of the image",
4460+ DEFAULT_DEBUG_MV, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
4461+#if 0
4462+ g_object_class_install_property (gobject_class, PROP_CROP,
4463+ g_param_spec_boolean ("crop", "Crop",
4464+ "Crop images to the display region",
4465+ DEFAULT_CROP, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
4466+#endif
4467+
4468+ caps = klass->in_plugin->capabilities;
4469+ if (caps & (CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS)) {
4470+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_THREADS,
4471+ g_param_spec_int ("max-threads", "Maximum decode threads",
4472+ "Maximum number of worker threads to spawn. (0 = auto)",
4473+ 0, G_MAXINT, DEFAULT_MAX_THREADS,
4474+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
4475+ }
4476+ }
4477+
4478+ gstelement_class->change_state = gst_ffmpegdec_change_state;
4479+}
4480+
4481+static void
4482+gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec)
4483+{
4484+ GstFFMpegDecClass *oclass;
4485+
4486+ oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
4487+
4488+ /* setup pads */
4489+ ffmpegdec->sinkpad = gst_pad_new_from_template (oclass->sinktempl, "sink");
4490+ gst_pad_set_setcaps_function (ffmpegdec->sinkpad,
4491+ GST_DEBUG_FUNCPTR (gst_ffmpegdec_setcaps));
4492+ gst_pad_set_event_function (ffmpegdec->sinkpad,
4493+ GST_DEBUG_FUNCPTR (gst_ffmpegdec_sink_event));
4494+ gst_pad_set_chain_function (ffmpegdec->sinkpad,
4495+ GST_DEBUG_FUNCPTR (gst_ffmpegdec_chain));
4496+ gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->sinkpad);
4497+
4498+ ffmpegdec->srcpad = gst_pad_new_from_template (oclass->srctempl, "src");
4499+ gst_pad_use_fixed_caps (ffmpegdec->srcpad);
4500+ gst_pad_set_event_function (ffmpegdec->srcpad,
4501+ GST_DEBUG_FUNCPTR (gst_ffmpegdec_src_event));
4502+ gst_pad_set_query_function (ffmpegdec->srcpad,
4503+ GST_DEBUG_FUNCPTR (gst_ffmpegdec_query));
4504+ gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->srcpad);
4505+
4506+ /* some ffmpeg data */
4507+ ffmpegdec->context = avcodec_alloc_context ();
4508+ ffmpegdec->picture = avcodec_alloc_frame ();
4509+ ffmpegdec->pctx = NULL;
4510+ ffmpegdec->pcache = NULL;
4511+ ffmpegdec->par = NULL;
4512+ ffmpegdec->opened = FALSE;
4513+ ffmpegdec->skip_frame = ffmpegdec->lowres = 0;
4514+ ffmpegdec->direct_rendering = DEFAULT_DIRECT_RENDERING;
4515+ ffmpegdec->do_padding = DEFAULT_DO_PADDING;
4516+ ffmpegdec->debug_mv = DEFAULT_DEBUG_MV;
4517+ ffmpegdec->crop = DEFAULT_CROP;
4518+ ffmpegdec->max_threads = DEFAULT_MAX_THREADS;
4519+
4520+ ffmpegdec->format.video.par_n = -1;
4521+ ffmpegdec->format.video.fps_n = -1;
4522+ ffmpegdec->format.video.old_fps_n = -1;
4523+ gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
4524+
4525+ /* We initially assume downstream can allocate 16 bytes aligned buffers */
4526+ ffmpegdec->can_allocate_aligned = TRUE;
4527+}
4528+
4529+static void
4530+gst_ffmpegdec_finalize (GObject * object)
4531+{
4532+ GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
4533+
4534+ if (ffmpegdec->context != NULL) {
4535+ av_free (ffmpegdec->context);
4536+ ffmpegdec->context = NULL;
4537+ }
4538+
4539+ if (ffmpegdec->picture != NULL) {
4540+ av_free (ffmpegdec->picture);
4541+ ffmpegdec->picture = NULL;
4542+ }
4543+
4544+ G_OBJECT_CLASS (parent_class)->finalize (object);
4545+}
4546+
4547+static gboolean
4548+gst_ffmpegdec_query (GstPad * pad, GstQuery * query)
4549+{
4550+ GstFFMpegDec *ffmpegdec;
4551+ GstPad *peer;
4552+ gboolean res;
4553+
4554+ ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
4555+
4556+ res = FALSE;
4557+
4558+ if ((peer = gst_pad_get_peer (ffmpegdec->sinkpad))) {
4559+ /* just forward to peer */
4560+ res = gst_pad_query (peer, query);
4561+ gst_object_unref (peer);
4562+ }
4563+#if 0
4564+ {
4565+ GstFormat bfmt;
4566+
4567+ bfmt = GST_FORMAT_BYTES;
4568+
4569+ /* ok, do bitrate calc... */
4570+ if ((type != GST_QUERY_POSITION && type != GST_QUERY_TOTAL) ||
4571+ *fmt != GST_FORMAT_TIME || ffmpegdec->context->bit_rate == 0 ||
4572+ !gst_pad_query (peer, type, &bfmt, value))
4573+ return FALSE;
4574+
4575+ if (ffmpegdec->pcache && type == GST_QUERY_POSITION)
4576+ *value -= GST_BUFFER_SIZE (ffmpegdec->pcache);
4577+ *value *= GST_SECOND / ffmpegdec->context->bit_rate;
4578+ }
4579+#endif
4580+
4581+ gst_object_unref (ffmpegdec);
4582+
4583+ return res;
4584+}
4585+
4586+static void
4587+gst_ffmpegdec_reset_ts (GstFFMpegDec * ffmpegdec)
4588+{
4589+ ffmpegdec->last_in = GST_CLOCK_TIME_NONE;
4590+ ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
4591+ ffmpegdec->last_frames = 0;
4592+ ffmpegdec->last_out = GST_CLOCK_TIME_NONE;
4593+ ffmpegdec->next_out = GST_CLOCK_TIME_NONE;
4594+ ffmpegdec->reordered_in = FALSE;
4595+ ffmpegdec->reordered_out = FALSE;
4596+}
4597+
4598+static void
4599+gst_ffmpegdec_update_qos (GstFFMpegDec * ffmpegdec, gdouble proportion,
4600+ GstClockTime timestamp)
4601+{
4602+ GST_LOG_OBJECT (ffmpegdec, "update QOS: %f, %" GST_TIME_FORMAT,
4603+ proportion, GST_TIME_ARGS (timestamp));
4604+
4605+ GST_OBJECT_LOCK (ffmpegdec);
4606+ ffmpegdec->proportion = proportion;
4607+ ffmpegdec->earliest_time = timestamp;
4608+ GST_OBJECT_UNLOCK (ffmpegdec);
4609+}
4610+
4611+static void
4612+gst_ffmpegdec_reset_qos (GstFFMpegDec * ffmpegdec)
4613+{
4614+ gst_ffmpegdec_update_qos (ffmpegdec, 0.5, GST_CLOCK_TIME_NONE);
4615+ ffmpegdec->processed = 0;
4616+ ffmpegdec->dropped = 0;
4617+}
4618+
4619+static void
4620+gst_ffmpegdec_read_qos (GstFFMpegDec * ffmpegdec, gdouble * proportion,
4621+ GstClockTime * timestamp)
4622+{
4623+ GST_OBJECT_LOCK (ffmpegdec);
4624+ *proportion = ffmpegdec->proportion;
4625+ *timestamp = ffmpegdec->earliest_time;
4626+ GST_OBJECT_UNLOCK (ffmpegdec);
4627+}
4628+
4629+static gboolean
4630+gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event)
4631+{
4632+ GstFFMpegDec *ffmpegdec;
4633+ gboolean res;
4634+
4635+ ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
4636+
4637+ switch (GST_EVENT_TYPE (event)) {
4638+ case GST_EVENT_QOS:
4639+ {
4640+ gdouble proportion;
4641+ GstClockTimeDiff diff;
4642+ GstClockTime timestamp;
4643+
4644+ gst_event_parse_qos (event, &proportion, &diff, &timestamp);
4645+
4646+ /* update our QoS values */
4647+ gst_ffmpegdec_update_qos (ffmpegdec, proportion, timestamp + diff);
4648+
4649+ /* forward upstream */
4650+ res = gst_pad_push_event (ffmpegdec->sinkpad, event);
4651+ break;
4652+ }
4653+ default:
4654+ /* forward upstream */
4655+ res = gst_pad_push_event (ffmpegdec->sinkpad, event);
4656+ break;
4657+ }
4658+
4659+ gst_object_unref (ffmpegdec);
4660+
4661+ return res;
4662+}
4663+
4664+/* with LOCK */
4665+static void
4666+gst_ffmpegdec_close (GstFFMpegDec * ffmpegdec)
4667+{
4668+ if (!ffmpegdec->opened)
4669+ return;
4670+
4671+ GST_LOG_OBJECT (ffmpegdec, "closing ffmpeg codec");
4672+
4673+ if (ffmpegdec->par) {
4674+ g_free (ffmpegdec->par);
4675+ ffmpegdec->par = NULL;
4676+ }
4677+
4678+ if (ffmpegdec->context->priv_data)
4679+ gst_ffmpeg_avcodec_close (ffmpegdec->context);
4680+ ffmpegdec->opened = FALSE;
4681+
4682+ if (ffmpegdec->context->extradata) {
4683+ av_free (ffmpegdec->context->extradata);
4684+ ffmpegdec->context->extradata = NULL;
4685+ }
4686+
4687+ if (ffmpegdec->pctx) {
4688+ if (ffmpegdec->pcache) {
4689+ gst_buffer_unref (ffmpegdec->pcache);
4690+ ffmpegdec->pcache = NULL;
4691+ }
4692+ av_parser_close (ffmpegdec->pctx);
4693+ ffmpegdec->pctx = NULL;
4694+ }
4695+
4696+ ffmpegdec->format.video.par_n = -1;
4697+ ffmpegdec->format.video.fps_n = -1;
4698+ ffmpegdec->format.video.old_fps_n = -1;
4699+ ffmpegdec->format.video.interlaced = FALSE;
4700+}
4701+
4702+/* with LOCK */
4703+static gboolean
4704+gst_ffmpegdec_open (GstFFMpegDec * ffmpegdec)
4705+{
4706+ GstFFMpegDecClass *oclass;
4707+
4708+ oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
4709+
4710+ if (gst_ffmpeg_avcodec_open (ffmpegdec->context, oclass->in_plugin) < 0)
4711+ goto could_not_open;
4712+
4713+ ffmpegdec->opened = TRUE;
4714+ ffmpegdec->is_realvideo = FALSE;
4715+
4716+ GST_LOG_OBJECT (ffmpegdec, "Opened ffmpeg codec %s, id %d",
4717+ oclass->in_plugin->name, oclass->in_plugin->id);
4718+
4719+ /* open a parser if we can */
4720+ switch (oclass->in_plugin->id) {
4721+ case CODEC_ID_MPEG4:
4722+ case CODEC_ID_MJPEG:
4723+ case CODEC_ID_VC1:
4724+ GST_LOG_OBJECT (ffmpegdec, "not using parser, blacklisted codec");
4725+ ffmpegdec->pctx = NULL;
4726+ break;
4727+ case CODEC_ID_H264:
4728+ /* For H264, only use a parser if there is no context data, if there is,
4729+ * we're talking AVC */
4730+ if (ffmpegdec->context->extradata_size == 0) {
4731+ GST_LOG_OBJECT (ffmpegdec, "H264 with no extradata, creating parser");
4732+ ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
4733+ } else {
4734+ GST_LOG_OBJECT (ffmpegdec,
4735+ "H264 with extradata implies framed data - not using parser");
4736+ ffmpegdec->pctx = NULL;
4737+ }
4738+ break;
4739+ case CODEC_ID_RV10:
4740+ case CODEC_ID_RV30:
4741+ case CODEC_ID_RV20:
4742+ case CODEC_ID_RV40:
4743+ ffmpegdec->is_realvideo = TRUE;
4744+ break;
4745+ default:
4746+ if (!ffmpegdec->turnoff_parser) {
4747+ ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
4748+ if (ffmpegdec->pctx)
4749+ GST_LOG_OBJECT (ffmpegdec, "Using parser %p", ffmpegdec->pctx);
4750+ else
4751+ GST_LOG_OBJECT (ffmpegdec, "No parser for codec");
4752+ } else {
4753+ GST_LOG_OBJECT (ffmpegdec, "Parser deactivated for format");
4754+ }
4755+ break;
4756+ }
4757+
4758+ switch (oclass->in_plugin->type) {
4759+ case AVMEDIA_TYPE_VIDEO:
4760+ ffmpegdec->format.video.width = 0;
4761+ ffmpegdec->format.video.height = 0;
4762+ ffmpegdec->format.video.clip_width = -1;
4763+ ffmpegdec->format.video.clip_height = -1;
4764+ ffmpegdec->format.video.pix_fmt = PIX_FMT_NB;
4765+ ffmpegdec->format.video.interlaced = FALSE;
4766+ break;
4767+ case AVMEDIA_TYPE_AUDIO:
4768+ ffmpegdec->format.audio.samplerate = 0;
4769+ ffmpegdec->format.audio.channels = 0;
4770+ ffmpegdec->format.audio.depth = 0;
4771+ break;
4772+ default:
4773+ break;
4774+ }
4775+
4776+ gst_ffmpegdec_reset_ts (ffmpegdec);
4777+ /* FIXME, reset_qos holds the LOCK */
4778+ ffmpegdec->proportion = 0.0;
4779+ ffmpegdec->earliest_time = -1;
4780+
4781+ return TRUE;
4782+
4783+ /* ERRORS */
4784+could_not_open:
4785+ {
4786+ gst_ffmpegdec_close (ffmpegdec);
4787+ GST_DEBUG_OBJECT (ffmpegdec, "ffdec_%s: Failed to open FFMPEG codec",
4788+ oclass->in_plugin->name);
4789+ return FALSE;
4790+ }
4791+}
4792+
4793+static gboolean
4794+gst_ffmpegdec_setcaps (GstPad * pad, GstCaps * caps)
4795+{
4796+ GstFFMpegDec *ffmpegdec;
4797+ GstFFMpegDecClass *oclass;
4798+ GstStructure *structure;
4799+ const GValue *par;
4800+ const GValue *fps;
4801+ gboolean ret = TRUE;
4802+
4803+ ffmpegdec = (GstFFMpegDec *) (gst_pad_get_parent (pad));
4804+ oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
4805+
4806+ GST_DEBUG_OBJECT (pad, "setcaps called");
4807+
4808+ GST_OBJECT_LOCK (ffmpegdec);
4809+
4810+ /* stupid check for VC1 */
4811+ if ((oclass->in_plugin->id == CODEC_ID_WMV3) ||
4812+ (oclass->in_plugin->id == CODEC_ID_VC1))
4813+ oclass->in_plugin->id = gst_ffmpeg_caps_to_codecid (caps, NULL);
4814+
4815+ /* close old session */
4816+ if (ffmpegdec->opened) {
4817+ GST_OBJECT_UNLOCK (ffmpegdec);
4818+ gst_ffmpegdec_drain (ffmpegdec);
4819+ GST_OBJECT_LOCK (ffmpegdec);
4820+ gst_ffmpegdec_close (ffmpegdec);
4821+
4822+ /* and reset the defaults that were set when a context is created */
4823+ avcodec_get_context_defaults (ffmpegdec->context);
4824+ }
4825+
4826+ /* set buffer functions */
4827+ ffmpegdec->context->get_buffer = gst_ffmpegdec_get_buffer;
4828+ ffmpegdec->context->release_buffer = gst_ffmpegdec_release_buffer;
4829+ ffmpegdec->context->draw_horiz_band = NULL;
4830+
4831+ /* default is to let format decide if it needs a parser */
4832+ ffmpegdec->turnoff_parser = FALSE;
4833+
4834+ ffmpegdec->has_b_frames = FALSE;
4835+
4836+ GST_LOG_OBJECT (ffmpegdec, "size %dx%d", ffmpegdec->context->width,
4837+ ffmpegdec->context->height);
4838+
4839+ /* get size and so */
4840+ gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
4841+ oclass->in_plugin->type, caps, ffmpegdec->context);
4842+
4843+ GST_LOG_OBJECT (ffmpegdec, "size after %dx%d", ffmpegdec->context->width,
4844+ ffmpegdec->context->height);
4845+
4846+ if (!ffmpegdec->context->time_base.den || !ffmpegdec->context->time_base.num) {
4847+ GST_DEBUG_OBJECT (ffmpegdec, "forcing 25/1 framerate");
4848+ ffmpegdec->context->time_base.num = 1;
4849+ ffmpegdec->context->time_base.den = 25;
4850+ }
4851+
4852+ /* get pixel aspect ratio if it's set */
4853+ structure = gst_caps_get_structure (caps, 0);
4854+
4855+ par = gst_structure_get_value (structure, "pixel-aspect-ratio");
4856+ if (par) {
4857+ GST_DEBUG_OBJECT (ffmpegdec, "sink caps have pixel-aspect-ratio of %d:%d",
4858+ gst_value_get_fraction_numerator (par),
4859+ gst_value_get_fraction_denominator (par));
4860+ /* should be NULL */
4861+ if (ffmpegdec->par)
4862+ g_free (ffmpegdec->par);
4863+ ffmpegdec->par = g_new0 (GValue, 1);
4864+ gst_value_init_and_copy (ffmpegdec->par, par);
4865+ }
4866+
4867+ /* get the framerate from incoming caps. fps_n is set to -1 when
4868+ * there is no valid framerate */
4869+ fps = gst_structure_get_value (structure, "framerate");
4870+ if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
4871+ ffmpegdec->format.video.fps_n = gst_value_get_fraction_numerator (fps);
4872+ ffmpegdec->format.video.fps_d = gst_value_get_fraction_denominator (fps);
4873+ GST_DEBUG_OBJECT (ffmpegdec, "Using framerate %d/%d from incoming caps",
4874+ ffmpegdec->format.video.fps_n, ffmpegdec->format.video.fps_d);
4875+ } else {
4876+ ffmpegdec->format.video.fps_n = -1;
4877+ GST_DEBUG_OBJECT (ffmpegdec, "Using framerate from codec");
4878+ }
4879+
4880+ /* figure out if we can use direct rendering */
4881+ ffmpegdec->current_dr = FALSE;
4882+ ffmpegdec->extra_ref = FALSE;
4883+ if (ffmpegdec->direct_rendering) {
4884+ GST_DEBUG_OBJECT (ffmpegdec, "trying to enable direct rendering");
4885+ if (oclass->in_plugin->capabilities & CODEC_CAP_DR1) {
4886+ if (oclass->in_plugin->id == CODEC_ID_H264) {
4887+ GST_DEBUG_OBJECT (ffmpegdec, "disable direct rendering setup for H264");
4888+ /* does not work, many stuff reads outside of the planes */
4889+ ffmpegdec->current_dr = FALSE;
4890+ ffmpegdec->extra_ref = TRUE;
4891+ } else if ((oclass->in_plugin->id == CODEC_ID_SVQ1) ||
4892+ (oclass->in_plugin->id == CODEC_ID_VP5) ||
4893+ (oclass->in_plugin->id == CODEC_ID_VP6) ||
4894+ (oclass->in_plugin->id == CODEC_ID_VP6F) ||
4895+ (oclass->in_plugin->id == CODEC_ID_VP6A)) {
4896+ GST_DEBUG_OBJECT (ffmpegdec,
4897+ "disable direct rendering setup for broken stride support");
4898+ /* does not work, uses a incompatible stride. See #610613 */
4899+ ffmpegdec->current_dr = FALSE;
4900+ ffmpegdec->extra_ref = TRUE;
4901+ } else {
4902+ GST_DEBUG_OBJECT (ffmpegdec, "enabled direct rendering");
4903+ ffmpegdec->current_dr = TRUE;
4904+ }
4905+ } else {
4906+ GST_DEBUG_OBJECT (ffmpegdec, "direct rendering not supported");
4907+ }
4908+ }
4909+ if (ffmpegdec->current_dr) {
4910+ /* do *not* draw edges when in direct rendering, for some reason it draws
4911+ * outside of the memory. */
4912+ ffmpegdec->context->flags |= CODEC_FLAG_EMU_EDGE;
4913+ }
4914+
4915+ /* for AAC we only use av_parse if not on stream-format==raw or ==loas */
4916+ if (oclass->in_plugin->id == CODEC_ID_AAC
4917+ || oclass->in_plugin->id == CODEC_ID_AAC_LATM) {
4918+ const gchar *format = gst_structure_get_string (structure, "stream-format");
4919+
4920+ if (format == NULL || strcmp (format, "raw") == 0) {
4921+ ffmpegdec->turnoff_parser = TRUE;
4922+ }
4923+ }
4924+
4925+ /* for FLAC, don't parse if it's already parsed */
4926+ if (oclass->in_plugin->id == CODEC_ID_FLAC) {
4927+ if (gst_structure_has_field (structure, "streamheader"))
4928+ ffmpegdec->turnoff_parser = TRUE;
4929+ }
4930+
4931+ /* workaround encoder bugs */
4932+ ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
4933+ ffmpegdec->context->err_recognition = 1;
4934+
4935+ /* for slow cpus */
4936+ ffmpegdec->context->lowres = ffmpegdec->lowres;
4937+ ffmpegdec->context->skip_frame = ffmpegdec->skip_frame;
4938+
4939+ /* ffmpeg can draw motion vectors on top of the image (not every decoder
4940+ * supports it) */
4941+ ffmpegdec->context->debug_mv = ffmpegdec->debug_mv;
4942+
4943+ if (ffmpegdec->max_threads == 0)
4944+ ffmpegdec->context->thread_count = gst_ffmpeg_auto_max_threads ();
4945+ else
4946+ ffmpegdec->context->thread_count = ffmpegdec->max_threads;
4947+
4948+ /* open codec - we don't select an output pix_fmt yet,
4949+ * simply because we don't know! We only get it
4950+ * during playback... */
4951+ if (!gst_ffmpegdec_open (ffmpegdec))
4952+ goto open_failed;
4953+
4954+ /* clipping region */
4955+ gst_structure_get_int (structure, "width",
4956+ &ffmpegdec->format.video.clip_width);
4957+ gst_structure_get_int (structure, "height",
4958+ &ffmpegdec->format.video.clip_height);
4959+
4960+ GST_DEBUG_OBJECT (pad, "clipping to %dx%d",
4961+ ffmpegdec->format.video.clip_width, ffmpegdec->format.video.clip_height);
4962+
4963+ /* take into account the lowres property */
4964+ if (ffmpegdec->format.video.clip_width != -1)
4965+ ffmpegdec->format.video.clip_width >>= ffmpegdec->lowres;
4966+ if (ffmpegdec->format.video.clip_height != -1)
4967+ ffmpegdec->format.video.clip_height >>= ffmpegdec->lowres;
4968+
4969+ GST_DEBUG_OBJECT (pad, "final clipping to %dx%d",
4970+ ffmpegdec->format.video.clip_width, ffmpegdec->format.video.clip_height);
4971+
4972+done:
4973+ GST_OBJECT_UNLOCK (ffmpegdec);
4974+
4975+ gst_object_unref (ffmpegdec);
4976+
4977+ return ret;
4978+
4979+ /* ERRORS */
4980+open_failed:
4981+ {
4982+ GST_DEBUG_OBJECT (ffmpegdec, "Failed to open");
4983+ if (ffmpegdec->par) {
4984+ g_free (ffmpegdec->par);
4985+ ffmpegdec->par = NULL;
4986+ }
4987+ ret = FALSE;
4988+ goto done;
4989+ }
4990+}
4991+
4992+static GstFlowReturn
4993+alloc_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf,
4994+ gint width, gint height)
4995+{
4996+ GstFlowReturn ret;
4997+ gint fsize;
4998+
4999+ ret = GST_FLOW_ERROR;
5000+ *outbuf = NULL;
5001+
5002+ GST_LOG_OBJECT (ffmpegdec, "alloc output buffer");
5003+
5004+ /* see if we need renegotiation */
5005+ if (G_UNLIKELY (!gst_ffmpegdec_negotiate (ffmpegdec, FALSE)))
5006+ goto negotiate_failed;
5007+
5008+ /* get the size of the gstreamer output buffer given a
5009+ * width/height/format */
5010+ fsize = gst_ffmpeg_avpicture_get_size (ffmpegdec->context->pix_fmt,
5011+ width, height);
5012+
5013+ if (ffmpegdec->can_allocate_aligned) {
5014+ GST_LOG_OBJECT (ffmpegdec, "calling pad_alloc");
5015+ /* no pallete, we can use the buffer size to alloc */
5016+ ret = gst_pad_alloc_buffer_and_set_caps (ffmpegdec->srcpad,
5017+ GST_BUFFER_OFFSET_NONE, fsize,
5018+ GST_PAD_CAPS (ffmpegdec->srcpad), outbuf);
5019+ if (G_UNLIKELY (ret != GST_FLOW_OK))
5020+ goto alloc_failed;
5021+
5022+ /* If buffer isn't 128-bit aligned, create a memaligned one ourselves */
5023+ if (((uintptr_t) GST_BUFFER_DATA (*outbuf)) % 16) {
5024+ GST_DEBUG_OBJECT (ffmpegdec,
5025+ "Downstream can't allocate aligned buffers.");
5026+ ffmpegdec->can_allocate_aligned = FALSE;
5027+ gst_buffer_unref (*outbuf);
5028+ *outbuf = new_aligned_buffer (fsize, GST_PAD_CAPS (ffmpegdec->srcpad));
5029+ }
5030+ } else {
5031+ GST_LOG_OBJECT (ffmpegdec,
5032+ "not calling pad_alloc, we have a pallete or downstream can't give 16 byte aligned buffers.");
5033+ /* for paletted data we can't use pad_alloc_buffer(), because
5034+ * fsize contains the size of the palette, so the overall size
5035+ * is bigger than ffmpegcolorspace's unit size, which will
5036+ * prompt GstBaseTransform to complain endlessly ... */
5037+ *outbuf = new_aligned_buffer (fsize, GST_PAD_CAPS (ffmpegdec->srcpad));
5038+ ret = GST_FLOW_OK;
5039+ }
5040+ /* set caps, we do this here because the buffer is still writable here and we
5041+ * are sure to be negotiated */
5042+ gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (ffmpegdec->srcpad));
5043+
5044+ return ret;
5045+
5046+ /* special cases */
5047+negotiate_failed:
5048+ {
5049+ GST_DEBUG_OBJECT (ffmpegdec, "negotiate failed");
5050+ return GST_FLOW_NOT_NEGOTIATED;
5051+ }
5052+alloc_failed:
5053+ {
5054+ GST_DEBUG_OBJECT (ffmpegdec, "pad_alloc failed %d (%s)", ret,
5055+ gst_flow_get_name (ret));
5056+ return ret;
5057+ }
5058+}
5059+
5060+static int
5061+gst_ffmpegdec_get_buffer (AVCodecContext * context, AVFrame * picture)
5062+{
5063+ GstBuffer *buf = NULL;
5064+ GstFFMpegDec *ffmpegdec;
5065+ gint width, height;
5066+ gint coded_width, coded_height;
5067+ gint res;
5068+
5069+ ffmpegdec = (GstFFMpegDec *) context->opaque;
5070+
5071+ GST_DEBUG_OBJECT (ffmpegdec, "getting buffer");
5072+
5073+ /* apply the last info we have seen to this picture, when we get the
5074+ * picture back from ffmpeg we can use this to correctly timestamp the output
5075+ * buffer */
5076+ picture->reordered_opaque = context->reordered_opaque;
5077+ /* make sure we don't free the buffer when it's not ours */
5078+ picture->opaque = NULL;
5079+
5080+ /* take width and height before clipping */
5081+ width = context->width;
5082+ height = context->height;
5083+ coded_width = context->coded_width;
5084+ coded_height = context->coded_height;
5085+
5086+ GST_LOG_OBJECT (ffmpegdec, "dimension %dx%d, coded %dx%d", width, height,
5087+ coded_width, coded_height);
5088+ if (!ffmpegdec->current_dr) {
5089+ GST_LOG_OBJECT (ffmpegdec, "direct rendering disabled, fallback alloc");
5090+ res = avcodec_default_get_buffer (context, picture);
5091+
5092+ GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", picture->linesize[0],
5093+ picture->linesize[1], picture->linesize[2]);
5094+ GST_LOG_OBJECT (ffmpegdec, "data %u %u %u", 0,
5095+ (guint) (picture->data[1] - picture->data[0]),
5096+ (guint) (picture->data[2] - picture->data[0]));
5097+ return res;
5098+ }
5099+
5100+ switch (context->codec_type) {
5101+ case AVMEDIA_TYPE_VIDEO:
5102+ /* some ffmpeg video plugins don't see the point in setting codec_type ... */
5103+ case AVMEDIA_TYPE_UNKNOWN:
5104+ {
5105+ GstFlowReturn ret;
5106+ gint clip_width, clip_height;
5107+
5108+ /* take final clipped output size */
5109+ if ((clip_width = ffmpegdec->format.video.clip_width) == -1)
5110+ clip_width = width;
5111+ if ((clip_height = ffmpegdec->format.video.clip_height) == -1)
5112+ clip_height = height;
5113+
5114+ GST_LOG_OBJECT (ffmpegdec, "raw outsize %d/%d", width, height);
5115+
5116+ /* this is the size ffmpeg needs for the buffer */
5117+ avcodec_align_dimensions (context, &width, &height);
5118+
5119+ GST_LOG_OBJECT (ffmpegdec, "aligned outsize %d/%d, clip %d/%d",
5120+ width, height, clip_width, clip_height);
5121+
5122+ if (width != clip_width || height != clip_height) {
5123+ /* We can't alloc if we need to clip the output buffer later */
5124+ GST_LOG_OBJECT (ffmpegdec, "we need clipping, fallback alloc");
5125+ return avcodec_default_get_buffer (context, picture);
5126+ }
5127+
5128+ /* alloc with aligned dimensions for ffmpeg */
5129+ ret = alloc_output_buffer (ffmpegdec, &buf, width, height);
5130+ if (G_UNLIKELY (ret != GST_FLOW_OK)) {
5131+ /* alloc default buffer when we can't get one from downstream */
5132+ GST_LOG_OBJECT (ffmpegdec, "alloc failed, fallback alloc");
5133+ return avcodec_default_get_buffer (context, picture);
5134+ }
5135+
5136+ /* copy the right pointers and strides in the picture object */
5137+ gst_ffmpeg_avpicture_fill ((AVPicture *) picture,
5138+ GST_BUFFER_DATA (buf), context->pix_fmt, width, height);
5139+ break;
5140+ }
5141+ case AVMEDIA_TYPE_AUDIO:
5142+ default:
5143+ GST_ERROR_OBJECT (ffmpegdec,
5144+ "_get_buffer() should never get called for non-video buffers !");
5145+ g_assert_not_reached ();
5146+ break;
5147+ }
5148+
5149+ /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to
5150+ * the opaque data. */
5151+ picture->type = FF_BUFFER_TYPE_USER;
5152+ picture->opaque = buf;
5153+
5154+#ifdef EXTRA_REF
5155+ if (picture->reference != 0 || ffmpegdec->extra_ref) {
5156+ GST_DEBUG_OBJECT (ffmpegdec, "adding extra ref");
5157+ gst_buffer_ref (buf);
5158+ }
5159+#endif
5160+
5161+ GST_LOG_OBJECT (ffmpegdec, "returned buffer %p", buf);
5162+
5163+ return 0;
5164+}
5165+
5166+static void
5167+gst_ffmpegdec_release_buffer (AVCodecContext * context, AVFrame * picture)
5168+{
5169+ gint i;
5170+ GstBuffer *buf;
5171+ GstFFMpegDec *ffmpegdec;
5172+
5173+ ffmpegdec = (GstFFMpegDec *) context->opaque;
5174+
5175+ /* check if it was our buffer */
5176+ if (picture->opaque == NULL) {
5177+ GST_DEBUG_OBJECT (ffmpegdec, "default release buffer");
5178+ avcodec_default_release_buffer (context, picture);
5179+ return;
5180+ }
5181+
5182+ /* we remove the opaque data now */
5183+ buf = GST_BUFFER_CAST (picture->opaque);
5184+ GST_DEBUG_OBJECT (ffmpegdec, "release buffer %p", buf);
5185+ picture->opaque = NULL;
5186+
5187+#ifdef EXTRA_REF
5188+ if (picture->reference != 0 || ffmpegdec->extra_ref) {
5189+ GST_DEBUG_OBJECT (ffmpegdec, "remove extra ref");
5190+ gst_buffer_unref (buf);
5191+ }
5192+#else
5193+ gst_buffer_unref (buf);
5194+#endif
5195+
5196+ /* zero out the reference in ffmpeg */
5197+ for (i = 0; i < 4; i++) {
5198+ picture->data[i] = NULL;
5199+ picture->linesize[i] = 0;
5200+ }
5201+}
5202+
5203+static void
5204+gst_ffmpegdec_add_pixel_aspect_ratio (GstFFMpegDec * ffmpegdec,
5205+ GstStructure * s)
5206+{
5207+ gboolean demuxer_par_set = FALSE;
5208+ gboolean decoder_par_set = FALSE;
5209+ gint demuxer_num = 1, demuxer_denom = 1;
5210+ gint decoder_num = 1, decoder_denom = 1;
5211+
5212+ GST_OBJECT_LOCK (ffmpegdec);
5213+
5214+ if (ffmpegdec->par) {
5215+ demuxer_num = gst_value_get_fraction_numerator (ffmpegdec->par);
5216+ demuxer_denom = gst_value_get_fraction_denominator (ffmpegdec->par);
5217+ demuxer_par_set = TRUE;
5218+ GST_DEBUG_OBJECT (ffmpegdec, "Demuxer PAR: %d:%d", demuxer_num,
5219+ demuxer_denom);
5220+ }
5221+
5222+ if (ffmpegdec->context->sample_aspect_ratio.num &&
5223+ ffmpegdec->context->sample_aspect_ratio.den) {
5224+ decoder_num = ffmpegdec->context->sample_aspect_ratio.num;
5225+ decoder_denom = ffmpegdec->context->sample_aspect_ratio.den;
5226+ decoder_par_set = TRUE;
5227+ GST_DEBUG_OBJECT (ffmpegdec, "Decoder PAR: %d:%d", decoder_num,
5228+ decoder_denom);
5229+ }
5230+
5231+ GST_OBJECT_UNLOCK (ffmpegdec);
5232+
5233+ if (!demuxer_par_set && !decoder_par_set)
5234+ goto no_par;
5235+
5236+ if (demuxer_par_set && !decoder_par_set)
5237+ goto use_demuxer_par;
5238+
5239+ if (decoder_par_set && !demuxer_par_set)
5240+ goto use_decoder_par;
5241+
5242+ /* Both the demuxer and the decoder provide a PAR. If one of
5243+ * the two PARs is 1:1 and the other one is not, use the one
5244+ * that is not 1:1. */
5245+ if (demuxer_num == demuxer_denom && decoder_num != decoder_denom)
5246+ goto use_decoder_par;
5247+
5248+ if (decoder_num == decoder_denom && demuxer_num != demuxer_denom)
5249+ goto use_demuxer_par;
5250+
5251+ /* Both PARs are non-1:1, so use the PAR provided by the demuxer */
5252+ goto use_demuxer_par;
5253+
5254+use_decoder_par:
5255+ {
5256+ GST_DEBUG_OBJECT (ffmpegdec,
5257+ "Setting decoder provided pixel-aspect-ratio of %u:%u", decoder_num,
5258+ decoder_denom);
5259+ gst_structure_set (s, "pixel-aspect-ratio", GST_TYPE_FRACTION, decoder_num,
5260+ decoder_denom, NULL);
5261+ return;
5262+ }
5263+
5264+use_demuxer_par:
5265+ {
5266+ GST_DEBUG_OBJECT (ffmpegdec,
5267+ "Setting demuxer provided pixel-aspect-ratio of %u:%u", demuxer_num,
5268+ demuxer_denom);
5269+ gst_structure_set (s, "pixel-aspect-ratio", GST_TYPE_FRACTION, demuxer_num,
5270+ demuxer_denom, NULL);
5271+ return;
5272+ }
5273+no_par:
5274+ {
5275+ GST_DEBUG_OBJECT (ffmpegdec,
5276+ "Neither demuxer nor codec provide a pixel-aspect-ratio");
5277+ return;
5278+ }
5279+}
5280+
5281+static gboolean
5282+gst_ffmpegdec_negotiate (GstFFMpegDec * ffmpegdec, gboolean force)
5283+{
5284+ GstFFMpegDecClass *oclass;
5285+ GstCaps *caps;
5286+
5287+ oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
5288+
5289+ switch (oclass->in_plugin->type) {
5290+ case AVMEDIA_TYPE_VIDEO:
5291+ if (!force && ffmpegdec->format.video.width == ffmpegdec->context->width
5292+ && ffmpegdec->format.video.height == ffmpegdec->context->height
5293+ && ffmpegdec->format.video.fps_n == ffmpegdec->format.video.old_fps_n
5294+ && ffmpegdec->format.video.fps_d == ffmpegdec->format.video.old_fps_d
5295+ && ffmpegdec->format.video.pix_fmt == ffmpegdec->context->pix_fmt
5296+ && ffmpegdec->format.video.par_n ==
5297+ ffmpegdec->context->sample_aspect_ratio.num
5298+ && ffmpegdec->format.video.par_d ==
5299+ ffmpegdec->context->sample_aspect_ratio.den)
5300+ return TRUE;
5301+ GST_DEBUG_OBJECT (ffmpegdec,
5302+ "Renegotiating video from %dx%d@ %d:%d PAR %d/%d fps to %dx%d@ %d:%d PAR %d/%d fps",
5303+ ffmpegdec->format.video.width, ffmpegdec->format.video.height,
5304+ ffmpegdec->format.video.par_n, ffmpegdec->format.video.par_d,
5305+ ffmpegdec->format.video.old_fps_n, ffmpegdec->format.video.old_fps_n,
5306+ ffmpegdec->context->width, ffmpegdec->context->height,
5307+ ffmpegdec->context->sample_aspect_ratio.num,
5308+ ffmpegdec->context->sample_aspect_ratio.den,
5309+ ffmpegdec->format.video.fps_n, ffmpegdec->format.video.fps_d);
5310+ ffmpegdec->format.video.width = ffmpegdec->context->width;
5311+ ffmpegdec->format.video.height = ffmpegdec->context->height;
5312+ ffmpegdec->format.video.old_fps_n = ffmpegdec->format.video.fps_n;
5313+ ffmpegdec->format.video.old_fps_d = ffmpegdec->format.video.fps_d;
5314+ ffmpegdec->format.video.pix_fmt = ffmpegdec->context->pix_fmt;
5315+ ffmpegdec->format.video.par_n =
5316+ ffmpegdec->context->sample_aspect_ratio.num;
5317+ ffmpegdec->format.video.par_d =
5318+ ffmpegdec->context->sample_aspect_ratio.den;
5319+ break;
5320+ case AVMEDIA_TYPE_AUDIO:
5321+ {
5322+ gint depth = av_smp_format_depth (ffmpegdec->context->sample_fmt);
5323+ if (!force && ffmpegdec->format.audio.samplerate ==
5324+ ffmpegdec->context->sample_rate &&
5325+ ffmpegdec->format.audio.channels == ffmpegdec->context->channels &&
5326+ ffmpegdec->format.audio.depth == depth)
5327+ return TRUE;
5328+ GST_DEBUG_OBJECT (ffmpegdec,
5329+ "Renegotiating audio from %dHz@%dchannels (%d) to %dHz@%dchannels (%d)",
5330+ ffmpegdec->format.audio.samplerate, ffmpegdec->format.audio.channels,
5331+ ffmpegdec->format.audio.depth,
5332+ ffmpegdec->context->sample_rate, ffmpegdec->context->channels, depth);
5333+ ffmpegdec->format.audio.samplerate = ffmpegdec->context->sample_rate;
5334+ ffmpegdec->format.audio.channels = ffmpegdec->context->channels;
5335+ ffmpegdec->format.audio.depth = depth;
5336+ }
5337+ break;
5338+ default:
5339+ break;
5340+ }
5341+
5342+ caps = gst_ffmpeg_codectype_to_caps (oclass->in_plugin->type,
5343+ ffmpegdec->context, oclass->in_plugin->id, FALSE);
5344+
5345+ if (caps == NULL)
5346+ goto no_caps;
5347+
5348+ switch (oclass->in_plugin->type) {
5349+ case AVMEDIA_TYPE_VIDEO:
5350+ {
5351+ gint width, height;
5352+ gboolean interlaced;
5353+
5354+ width = ffmpegdec->format.video.clip_width;
5355+ height = ffmpegdec->format.video.clip_height;
5356+ interlaced = ffmpegdec->format.video.interlaced;
5357+
5358+ if (width != -1 && height != -1) {
5359+ /* overwrite the output size with the dimension of the
5360+ * clipping region but only if they are smaller. */
5361+ if (width < ffmpegdec->context->width)
5362+ gst_caps_set_simple (caps, "width", G_TYPE_INT, width, NULL);
5363+ if (height < ffmpegdec->context->height)
5364+ gst_caps_set_simple (caps, "height", G_TYPE_INT, height, NULL);
5365+ }
5366+ gst_caps_set_simple (caps, "interlaced", G_TYPE_BOOLEAN, interlaced,
5367+ NULL);
5368+
5369+ /* If a demuxer provided a framerate then use it (#313970) */
5370+ if (ffmpegdec->format.video.fps_n != -1) {
5371+ gst_caps_set_simple (caps, "framerate",
5372+ GST_TYPE_FRACTION, ffmpegdec->format.video.fps_n,
5373+ ffmpegdec->format.video.fps_d, NULL);
5374+ }
5375+ gst_ffmpegdec_add_pixel_aspect_ratio (ffmpegdec,
5376+ gst_caps_get_structure (caps, 0));
5377+ break;
5378+ }
5379+ case AVMEDIA_TYPE_AUDIO:
5380+ {
5381+ break;
5382+ }
5383+ default:
5384+ break;
5385+ }
5386+
5387+ if (!gst_pad_set_caps (ffmpegdec->srcpad, caps))
5388+ goto caps_failed;
5389+
5390+ gst_caps_unref (caps);
5391+
5392+ return TRUE;
5393+
5394+ /* ERRORS */
5395+no_caps:
5396+ {
5397+#ifdef HAVE_FFMPEG_UNINSTALLED
5398+ /* using internal ffmpeg snapshot */
5399+ GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
5400+ ("Could not find GStreamer caps mapping for FFmpeg codec '%s'.",
5401+ oclass->in_plugin->name), (NULL));
5402+#else
5403+ /* using external ffmpeg */
5404+ GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
5405+ ("Could not find GStreamer caps mapping for FFmpeg codec '%s', and "
5406+ "you are using an external libavcodec. This is most likely due to "
5407+ "a packaging problem and/or libavcodec having been upgraded to a "
5408+ "version that is not compatible with this version of "
5409+ "gstreamer-ffmpeg. Make sure your gstreamer-ffmpeg and libavcodec "
5410+ "packages come from the same source/repository.",
5411+ oclass->in_plugin->name), (NULL));
5412+#endif
5413+ return FALSE;
5414+ }
5415+caps_failed:
5416+ {
5417+ GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
5418+ ("Could not set caps for ffmpeg decoder (%s), not fixed?",
5419+ oclass->in_plugin->name));
5420+ gst_caps_unref (caps);
5421+
5422+ return FALSE;
5423+ }
5424+}
5425+
5426+/* perform qos calculations before decoding the next frame.
5427+ *
5428+ * Sets the skip_frame flag and if things are really bad, skips to the next
5429+ * keyframe.
5430+ *
5431+ * Returns TRUE if the frame should be decoded, FALSE if the frame can be dropped
5432+ * entirely.
5433+ */
5434+static gboolean
5435+gst_ffmpegdec_do_qos (GstFFMpegDec * ffmpegdec, GstClockTime timestamp,
5436+ gboolean * mode_switch)
5437+{
5438+ GstClockTimeDiff diff;
5439+ gdouble proportion;
5440+ GstClockTime qostime, earliest_time;
5441+ gboolean res = TRUE;
5442+
5443+ *mode_switch = FALSE;
5444+
5445+ /* no timestamp, can't do QoS */
5446+ if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (timestamp)))
5447+ goto no_qos;
5448+
5449+ /* get latest QoS observation values */
5450+ gst_ffmpegdec_read_qos (ffmpegdec, &proportion, &earliest_time);
5451+
5452+ /* skip qos if we have no observation (yet) */
5453+ if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (earliest_time))) {
5454+ /* no skip_frame initialy */
5455+ ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
5456+ goto no_qos;
5457+ }
5458+
5459+ /* qos is done on running time of the timestamp */
5460+ qostime = gst_segment_to_running_time (&ffmpegdec->segment, GST_FORMAT_TIME,
5461+ timestamp);
5462+
5463+ /* timestamp can be out of segment, then we don't do QoS */
5464+ if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (qostime)))
5465+ goto no_qos;
5466+
5467+ /* see how our next timestamp relates to the latest qos timestamp. negative
5468+ * values mean we are early, positive values mean we are too late. */
5469+ diff = GST_CLOCK_DIFF (qostime, earliest_time);
5470+
5471+ GST_DEBUG_OBJECT (ffmpegdec, "QOS: qostime %" GST_TIME_FORMAT
5472+ ", earliest %" GST_TIME_FORMAT, GST_TIME_ARGS (qostime),
5473+ GST_TIME_ARGS (earliest_time));
5474+
5475+ /* if we using less than 40% of the available time, we can try to
5476+ * speed up again when we were slow. */
5477+ if (proportion < 0.4 && diff < 0) {
5478+ goto normal_mode;
5479+ } else {
5480+ if (diff >= 0) {
5481+ /* we're too slow, try to speed up */
5482+ /* switch to skip_frame mode */
5483+ goto skip_frame;
5484+ }
5485+ }
5486+
5487+no_qos:
5488+ ffmpegdec->processed++;
5489+ return TRUE;
5490+
5491+normal_mode:
5492+ {
5493+ if (ffmpegdec->context->skip_frame != AVDISCARD_DEFAULT) {
5494+ ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
5495+ *mode_switch = TRUE;
5496+ GST_DEBUG_OBJECT (ffmpegdec, "QOS: normal mode %g < 0.4", proportion);
5497+ }
5498+ ffmpegdec->processed++;
5499+ return TRUE;
5500+ }
5501+skip_frame:
5502+ {
5503+ if (ffmpegdec->context->skip_frame != AVDISCARD_NONREF) {
5504+ ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
5505+ *mode_switch = TRUE;
5506+ GST_DEBUG_OBJECT (ffmpegdec,
5507+ "QOS: hurry up, diff %" G_GINT64_FORMAT " >= 0", diff);
5508+ }
5509+ goto drop_qos;
5510+ }
5511+drop_qos:
5512+ {
5513+ GstClockTime stream_time, jitter;
5514+ GstMessage *qos_msg;
5515+
5516+ ffmpegdec->dropped++;
5517+ stream_time =
5518+ gst_segment_to_stream_time (&ffmpegdec->segment, GST_FORMAT_TIME,
5519+ timestamp);
5520+ jitter = GST_CLOCK_DIFF (qostime, earliest_time);
5521+ qos_msg =
5522+ gst_message_new_qos (GST_OBJECT_CAST (ffmpegdec), FALSE, qostime,
5523+ stream_time, timestamp, GST_CLOCK_TIME_NONE);
5524+ gst_message_set_qos_values (qos_msg, jitter, proportion, 1000000);
5525+ gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
5526+ ffmpegdec->processed, ffmpegdec->dropped);
5527+ gst_element_post_message (GST_ELEMENT_CAST (ffmpegdec), qos_msg);
5528+
5529+ return res;
5530+ }
5531+}
5532+
5533+/* returns TRUE if buffer is within segment, else FALSE.
5534+ * if Buffer is on segment border, it's timestamp and duration will be clipped */
5535+static gboolean
5536+clip_video_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
5537+ GstClockTime in_dur)
5538+{
5539+ gboolean res = TRUE;
5540+ gint64 cstart, cstop;
5541+ GstClockTime stop;
5542+
5543+ GST_LOG_OBJECT (dec,
5544+ "timestamp:%" GST_TIME_FORMAT " , duration:%" GST_TIME_FORMAT,
5545+ GST_TIME_ARGS (in_ts), GST_TIME_ARGS (in_dur));
5546+
5547+ /* can't clip without TIME segment */
5548+ if (G_UNLIKELY (dec->segment.format != GST_FORMAT_TIME))
5549+ goto beach;
5550+
5551+ /* we need a start time */
5552+ if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (in_ts)))
5553+ goto beach;
5554+
5555+ /* generate valid stop, if duration unknown, we have unknown stop */
5556+ stop =
5557+ GST_CLOCK_TIME_IS_VALID (in_dur) ? (in_ts + in_dur) : GST_CLOCK_TIME_NONE;
5558+
5559+ /* now clip */
5560+ res =
5561+ gst_segment_clip (&dec->segment, GST_FORMAT_TIME, in_ts, stop, &cstart,
5562+ &cstop);
5563+ if (G_UNLIKELY (!res))
5564+ goto beach;
5565+
5566+ /* we're pretty sure the duration of this buffer is not till the end of this
5567+ * segment (which _clip will assume when the stop is -1) */
5568+ if (stop == GST_CLOCK_TIME_NONE)
5569+ cstop = GST_CLOCK_TIME_NONE;
5570+
5571+ /* update timestamp and possibly duration if the clipped stop time is
5572+ * valid */
5573+ GST_BUFFER_TIMESTAMP (buf) = cstart;
5574+ if (GST_CLOCK_TIME_IS_VALID (cstop))
5575+ GST_BUFFER_DURATION (buf) = cstop - cstart;
5576+
5577+ GST_LOG_OBJECT (dec,
5578+ "clipped timestamp:%" GST_TIME_FORMAT " , duration:%" GST_TIME_FORMAT,
5579+ GST_TIME_ARGS (cstart), GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
5580+
5581+beach:
5582+ GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
5583+ return res;
5584+}
5585+
5586+
5587+/* get an outbuf buffer with the current picture */
5588+static GstFlowReturn
5589+get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
5590+{
5591+ GstFlowReturn ret;
5592+
5593+ ret = GST_FLOW_OK;
5594+ *outbuf = NULL;
5595+
5596+ if (ffmpegdec->picture->opaque != NULL) {
5597+ /* we allocated a picture already for ffmpeg to decode into, let's pick it
5598+ * up and use it now. */
5599+ *outbuf = (GstBuffer *) ffmpegdec->picture->opaque;
5600+ GST_LOG_OBJECT (ffmpegdec, "using opaque buffer %p", *outbuf);
5601+#ifndef EXTRA_REF
5602+ gst_buffer_ref (*outbuf);
5603+#endif
5604+ } else {
5605+ AVPicture pic, *outpic;
5606+ gint width, height;
5607+
5608+ GST_LOG_OBJECT (ffmpegdec, "get output buffer");
5609+
5610+ /* figure out size of output buffer, this is the clipped output size because
5611+ * we will copy the picture into it but only when the clipping region is
5612+ * smaller than the actual picture size. */
5613+ if ((width = ffmpegdec->format.video.clip_width) == -1)
5614+ width = ffmpegdec->context->width;
5615+ else if (width > ffmpegdec->context->width)
5616+ width = ffmpegdec->context->width;
5617+
5618+ if ((height = ffmpegdec->format.video.clip_height) == -1)
5619+ height = ffmpegdec->context->height;
5620+ else if (height > ffmpegdec->context->height)
5621+ height = ffmpegdec->context->height;
5622+
5623+ GST_LOG_OBJECT (ffmpegdec, "clip width %d/height %d", width, height);
5624+
5625+ ret = alloc_output_buffer (ffmpegdec, outbuf, width, height);
5626+ if (G_UNLIKELY (ret != GST_FLOW_OK))
5627+ goto alloc_failed;
5628+
5629+ /* original ffmpeg code does not handle odd sizes correctly.
5630+ * This patched up version does */
5631+ gst_ffmpeg_avpicture_fill (&pic, GST_BUFFER_DATA (*outbuf),
5632+ ffmpegdec->context->pix_fmt, width, height);
5633+
5634+ outpic = (AVPicture *) ffmpegdec->picture;
5635+
5636+ GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", outpic->linesize[0],
5637+ outpic->linesize[1], outpic->linesize[2]);
5638+ GST_LOG_OBJECT (ffmpegdec, "data %u %u %u", 0,
5639+ (guint) (outpic->data[1] - outpic->data[0]),
5640+ (guint) (outpic->data[2] - outpic->data[0]));
5641+
5642+ av_picture_copy (&pic, outpic, ffmpegdec->context->pix_fmt, width, height);
5643+ }
5644+ ffmpegdec->picture->reordered_opaque = -1;
5645+
5646+ return ret;
5647+
5648+ /* special cases */
5649+alloc_failed:
5650+ {
5651+ GST_DEBUG_OBJECT (ffmpegdec, "pad_alloc failed");
5652+ return ret;
5653+ }
5654+}
5655+
5656+static void
5657+clear_queued (GstFFMpegDec * ffmpegdec)
5658+{
5659+ g_list_foreach (ffmpegdec->queued, (GFunc) gst_mini_object_unref, NULL);
5660+ g_list_free (ffmpegdec->queued);
5661+ ffmpegdec->queued = NULL;
5662+}
5663+
5664+static GstFlowReturn
5665+flush_queued (GstFFMpegDec * ffmpegdec)
5666+{
5667+ GstFlowReturn res = GST_FLOW_OK;
5668+
5669+ while (ffmpegdec->queued) {
5670+ GstBuffer *buf = GST_BUFFER_CAST (ffmpegdec->queued->data);
5671+
5672+ GST_LOG_OBJECT (ffmpegdec, "pushing buffer %p, offset %"
5673+ G_GUINT64_FORMAT ", timestamp %"
5674+ GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT, buf,
5675+ GST_BUFFER_OFFSET (buf),
5676+ GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
5677+ GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
5678+
5679+ /* iterate ouput queue an push downstream */
5680+ res = gst_pad_push (ffmpegdec->srcpad, buf);
5681+
5682+ ffmpegdec->queued =
5683+ g_list_delete_link (ffmpegdec->queued, ffmpegdec->queued);
5684+ }
5685+ return res;
5686+}
5687+
5688+static void
5689+gst_avpacket_init (AVPacket * packet, guint8 * data, guint size)
5690+{
5691+ memset (packet, 0, sizeof (AVPacket));
5692+ packet->data = data;
5693+ packet->size = size;
5694+}
5695+
5696+/* gst_ffmpegdec_[video|audio]_frame:
5697+ * ffmpegdec:
5698+ * data: pointer to the data to decode
5699+ * size: size of data in bytes
5700+ * in_timestamp: incoming timestamp.
5701+ * in_duration: incoming duration.
5702+ * in_offset: incoming offset (frame number).
5703+ * outbuf: outgoing buffer. Different from NULL ONLY if it contains decoded data.
5704+ * ret: Return flow.
5705+ *
5706+ * Returns: number of bytes used in decoding. The check for successful decode is
5707+ * outbuf being non-NULL.
5708+ */
5709+static gint
5710+gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
5711+ guint8 * data, guint size,
5712+ const GstTSInfo * dec_info, GstBuffer ** outbuf, GstFlowReturn * ret)
5713+{
5714+ gint len = -1;
5715+ gint have_data;
5716+ gboolean mode_switch;
5717+ gboolean decode;
5718+ gint skip_frame = AVDISCARD_DEFAULT;
5719+ GstClockTime out_timestamp, out_duration, out_pts;
5720+ gint64 out_offset;
5721+ const GstTSInfo *out_info;
5722+ AVPacket packet;
5723+
5724+ *ret = GST_FLOW_OK;
5725+ *outbuf = NULL;
5726+
5727+ ffmpegdec->context->opaque = ffmpegdec;
5728+
5729+ /* in case we skip frames */
5730+ ffmpegdec->picture->pict_type = -1;
5731+
5732+ /* run QoS code, we don't stop decoding the frame when we are late because
5733+ * else we might skip a reference frame */
5734+ decode = gst_ffmpegdec_do_qos (ffmpegdec, dec_info->timestamp, &mode_switch);
5735+
5736+ if (ffmpegdec->is_realvideo && data != NULL) {
5737+ gint slice_count;
5738+ gint i;
5739+
5740+ /* setup the slice table for realvideo */
5741+ if (ffmpegdec->context->slice_offset == NULL)
5742+ ffmpegdec->context->slice_offset = g_malloc (sizeof (guint32) * 1000);
5743+
5744+ slice_count = (*data++) + 1;
5745+ ffmpegdec->context->slice_count = slice_count;
5746+
5747+ for (i = 0; i < slice_count; i++) {
5748+ data += 4;
5749+ ffmpegdec->context->slice_offset[i] = GST_READ_UINT32_LE (data);
5750+ data += 4;
5751+ }
5752+ }
5753+
5754+ if (!decode) {
5755+ /* no decoding needed, save previous skip_frame value and brutely skip
5756+ * decoding everything */
5757+ skip_frame = ffmpegdec->context->skip_frame;
5758+ ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
5759+ }
5760+
5761+ /* save reference to the timing info */
5762+ ffmpegdec->context->reordered_opaque = (gint64) dec_info->idx;
5763+ ffmpegdec->picture->reordered_opaque = (gint64) dec_info->idx;
5764+
5765+ GST_DEBUG_OBJECT (ffmpegdec, "stored opaque values idx %d", dec_info->idx);
5766+
5767+ /* now decode the frame */
5768+ gst_avpacket_init (&packet, data, size);
5769+ len = avcodec_decode_video2 (ffmpegdec->context,
5770+ ffmpegdec->picture, &have_data, &packet);
5771+
5772+ /* restore previous state */
5773+ if (!decode)
5774+ ffmpegdec->context->skip_frame = skip_frame;
5775+
5776+ GST_DEBUG_OBJECT (ffmpegdec, "after decode: len %d, have_data %d",
5777+ len, have_data);
5778+
5779+ /* when we are in skip_frame mode, don't complain when ffmpeg returned
5780+ * no data because we told it to skip stuff. */
5781+ if (len < 0 && (mode_switch || ffmpegdec->context->skip_frame))
5782+ len = 0;
5783+
5784+ if (len > 0 && have_data <= 0 && (mode_switch
5785+ || ffmpegdec->context->skip_frame)) {
5786+ /* we consumed some bytes but nothing decoded and we are skipping frames,
5787+ * disable the interpollation of DTS timestamps */
5788+ ffmpegdec->last_out = -1;
5789+ }
5790+
5791+ /* no data, we're done */
5792+ if (len < 0 || have_data <= 0)
5793+ goto beach;
5794+
5795+ /* get the output picture timing info again */
5796+ out_info = gst_ts_info_get (ffmpegdec, ffmpegdec->picture->reordered_opaque);
5797+ out_pts = out_info->timestamp;
5798+ out_duration = out_info->duration;
5799+ out_offset = out_info->offset;
5800+
5801+ GST_DEBUG_OBJECT (ffmpegdec,
5802+ "pts %" G_GUINT64_FORMAT " duration %" G_GUINT64_FORMAT " offset %"
5803+ G_GINT64_FORMAT, out_pts, out_duration, out_offset);
5804+ GST_DEBUG_OBJECT (ffmpegdec, "picture: pts %" G_GUINT64_FORMAT,
5805+ (guint64) ffmpegdec->picture->pts);
5806+ GST_DEBUG_OBJECT (ffmpegdec, "picture: num %d",
5807+ ffmpegdec->picture->coded_picture_number);
5808+ GST_DEBUG_OBJECT (ffmpegdec, "picture: ref %d",
5809+ ffmpegdec->picture->reference);
5810+ GST_DEBUG_OBJECT (ffmpegdec, "picture: display %d",
5811+ ffmpegdec->picture->display_picture_number);
5812+ GST_DEBUG_OBJECT (ffmpegdec, "picture: opaque %p",
5813+ ffmpegdec->picture->opaque);
5814+ GST_DEBUG_OBJECT (ffmpegdec, "picture: reordered opaque %" G_GUINT64_FORMAT,
5815+ (guint64) ffmpegdec->picture->reordered_opaque);
5816+ GST_DEBUG_OBJECT (ffmpegdec, "repeat_pict:%d",
5817+ ffmpegdec->picture->repeat_pict);
5818+ GST_DEBUG_OBJECT (ffmpegdec, "interlaced_frame:%d",
5819+ ffmpegdec->picture->interlaced_frame);
5820+
5821+ if (G_UNLIKELY (ffmpegdec->picture->interlaced_frame !=
5822+ ffmpegdec->format.video.interlaced)) {
5823+ GST_WARNING ("Change in interlacing ! picture:%d, recorded:%d",
5824+ ffmpegdec->picture->interlaced_frame,
5825+ ffmpegdec->format.video.interlaced);
5826+ ffmpegdec->format.video.interlaced = ffmpegdec->picture->interlaced_frame;
5827+ gst_ffmpegdec_negotiate (ffmpegdec, TRUE);
5828+ }
5829+
5830+ /* Whether a frame is interlaced or not is unknown at the time of
5831+ buffer allocation, so caps on the buffer in opaque will have
5832+ the previous frame's interlaced flag set. So if interlacedness
5833+ has changed since allocation, we update the buffer (if any)
5834+ caps now with the correct interlaced flag. */
5835+ if (ffmpegdec->picture->opaque != NULL) {
5836+ GstBuffer *buffer = ffmpegdec->picture->opaque;
5837+ if (GST_BUFFER_CAPS (buffer) && GST_PAD_CAPS (ffmpegdec->srcpad)) {
5838+ GstStructure *s = gst_caps_get_structure (GST_BUFFER_CAPS (buffer), 0);
5839+ gboolean interlaced;
5840+ gboolean found = gst_structure_get_boolean (s, "interlaced", &interlaced);
5841+ if (!found || (!!interlaced != !!ffmpegdec->format.video.interlaced)) {
5842+ GST_DEBUG_OBJECT (ffmpegdec,
5843+ "Buffer interlacing does not match pad, updating");
5844+ buffer = gst_buffer_make_metadata_writable (buffer);
5845+ gst_buffer_set_caps (buffer, GST_PAD_CAPS (ffmpegdec->srcpad));
5846+ ffmpegdec->picture->opaque = buffer;
5847+ }
5848+ }
5849+ }
5850+
5851+ /* check that the timestamps go upwards */
5852+ if (ffmpegdec->last_out != -1 && ffmpegdec->last_out > out_pts) {
5853+ /* timestamps go backwards, this means frames were reordered and we must
5854+ * be dealing with DTS as the buffer timestamps */
5855+ if (!ffmpegdec->reordered_out) {
5856+ GST_DEBUG_OBJECT (ffmpegdec, "detected reordered out timestamps");
5857+ ffmpegdec->reordered_out = TRUE;
5858+ }
5859+ if (ffmpegdec->reordered_in) {
5860+ /* we reset the input reordering here because we want to recover from an
5861+ * occasionally wrong reordered input timestamp */
5862+ GST_DEBUG_OBJECT (ffmpegdec, "assuming DTS input timestamps");
5863+ ffmpegdec->reordered_in = FALSE;
5864+ }
5865+ }
5866+
5867+ if (out_pts == 0 && out_pts == ffmpegdec->last_out) {
5868+ GST_LOG_OBJECT (ffmpegdec, "ffmpeg returns 0 timestamps, ignoring");
5869+ /* some codecs only output 0 timestamps, when that happens, make us select an
5870+ * output timestamp based on the input timestamp. We do this by making the
5871+ * ffmpeg timestamp and the interpollated next timestamp invalid. */
5872+ out_pts = -1;
5873+ ffmpegdec->next_out = -1;
5874+ } else
5875+ ffmpegdec->last_out = out_pts;
5876+
5877+ /* we assume DTS as input timestamps unless we see reordered input
5878+ * timestamps */
5879+ if (!ffmpegdec->reordered_in && ffmpegdec->reordered_out) {
5880+ /* PTS and DTS are the same for keyframes */
5881+ if (ffmpegdec->next_out != -1) {
5882+ /* interpolate all timestamps except for keyframes, FIXME, this is
5883+ * wrong when QoS is active. */
5884+ GST_DEBUG_OBJECT (ffmpegdec, "interpolate timestamps");
5885+ out_pts = -1;
5886+ out_offset = -1;
5887+ }
5888+ }
5889+
5890+ /* get a handle to the output buffer */
5891+ *ret = get_output_buffer (ffmpegdec, outbuf);
5892+ if (G_UNLIKELY (*ret != GST_FLOW_OK))
5893+ goto no_output;
5894+
5895+ /*
5896+ * Timestamps:
5897+ *
5898+ * 1) Copy picture timestamp if valid
5899+ * 2) else interpolate from previous output timestamp
5900+ * 3) else copy input timestamp
5901+ */
5902+ out_timestamp = -1;
5903+ if (out_pts != -1) {
5904+ /* Get (interpolated) timestamp from FFMPEG */
5905+ out_timestamp = (GstClockTime) out_pts;
5906+ GST_LOG_OBJECT (ffmpegdec, "using timestamp %" GST_TIME_FORMAT
5907+ " returned by ffmpeg", GST_TIME_ARGS (out_timestamp));
5908+ }
5909+ if (!GST_CLOCK_TIME_IS_VALID (out_timestamp) && ffmpegdec->next_out != -1) {
5910+ out_timestamp = ffmpegdec->next_out;
5911+ GST_LOG_OBJECT (ffmpegdec, "using next timestamp %" GST_TIME_FORMAT,
5912+ GST_TIME_ARGS (out_timestamp));
5913+ }
5914+ if (!GST_CLOCK_TIME_IS_VALID (out_timestamp)) {
5915+ out_timestamp = dec_info->timestamp;
5916+ GST_LOG_OBJECT (ffmpegdec, "using in timestamp %" GST_TIME_FORMAT,
5917+ GST_TIME_ARGS (out_timestamp));
5918+ }
5919+ GST_BUFFER_TIMESTAMP (*outbuf) = out_timestamp;
5920+
5921+ /*
5922+ * Offset:
5923+ * 0) Use stored input offset (from opaque)
5924+ * 1) Use value converted from timestamp if valid
5925+ * 2) Use input offset if valid
5926+ */
5927+ if (out_offset != GST_BUFFER_OFFSET_NONE) {
5928+ /* out_offset already contains the offset from ts_info */
5929+ GST_LOG_OBJECT (ffmpegdec, "Using offset returned by ffmpeg");
5930+ } else if (out_timestamp != GST_CLOCK_TIME_NONE) {
5931+ GstFormat out_fmt = GST_FORMAT_DEFAULT;
5932+ GST_LOG_OBJECT (ffmpegdec, "Using offset converted from timestamp");
5933+ /* FIXME, we should really remove this as it's not nice at all to do
5934+ * upstream queries for each frame to get the frame offset. We also can't
5935+ * really remove this because it is the only way of setting frame offsets
5936+ * on outgoing buffers. We should have metadata so that the upstream peer
5937+ * can set a frame number on the encoded data. */
5938+ gst_pad_query_peer_convert (ffmpegdec->sinkpad,
5939+ GST_FORMAT_TIME, out_timestamp, &out_fmt, &out_offset);
5940+ } else if (dec_info->offset != GST_BUFFER_OFFSET_NONE) {
5941+ /* FIXME, the input offset is input media specific and might not
5942+ * be the same for the output media. (byte offset as input, frame number
5943+ * as output, for example) */
5944+ GST_LOG_OBJECT (ffmpegdec, "using in_offset %" G_GINT64_FORMAT,
5945+ dec_info->offset);
5946+ out_offset = dec_info->offset;
5947+ } else {
5948+ GST_LOG_OBJECT (ffmpegdec, "no valid offset found");
5949+ out_offset = GST_BUFFER_OFFSET_NONE;
5950+ }
5951+ GST_BUFFER_OFFSET (*outbuf) = out_offset;
5952+
5953+ /*
5954+ * Duration:
5955+ *
5956+ * 1) Use reordered input duration if valid
5957+ * 2) Else use input duration
5958+ * 3) else use input framerate
5959+ * 4) else use ffmpeg framerate
5960+ */
5961+ if (GST_CLOCK_TIME_IS_VALID (out_duration)) {
5962+ /* We have a valid (reordered) duration */
5963+ GST_LOG_OBJECT (ffmpegdec, "Using duration returned by ffmpeg");
5964+ } else if (GST_CLOCK_TIME_IS_VALID (dec_info->duration)) {
5965+ GST_LOG_OBJECT (ffmpegdec, "using in_duration");
5966+ out_duration = dec_info->duration;
5967+ } else if (GST_CLOCK_TIME_IS_VALID (ffmpegdec->last_diff)) {
5968+ GST_LOG_OBJECT (ffmpegdec, "using last-diff");
5969+ out_duration = ffmpegdec->last_diff;
5970+ } else {
5971+ /* if we have an input framerate, use that */
5972+ if (ffmpegdec->format.video.fps_n != -1 &&
5973+ (ffmpegdec->format.video.fps_n != 1000 &&
5974+ ffmpegdec->format.video.fps_d != 1)) {
5975+ GST_LOG_OBJECT (ffmpegdec, "using input framerate for duration");
5976+ out_duration = gst_util_uint64_scale_int (GST_SECOND,
5977+ ffmpegdec->format.video.fps_d, ffmpegdec->format.video.fps_n);
5978+ } else {
5979+ /* don't try to use the decoder's framerate when it seems a bit abnormal,
5980+ * which we assume when den >= 1000... */
5981+ if (ffmpegdec->context->time_base.num != 0 &&
5982+ (ffmpegdec->context->time_base.den > 0 &&
5983+ ffmpegdec->context->time_base.den < 1000)) {
5984+ GST_LOG_OBJECT (ffmpegdec, "using decoder's framerate for duration");
5985+ out_duration = gst_util_uint64_scale_int (GST_SECOND,
5986+ ffmpegdec->context->time_base.num *
5987+ ffmpegdec->context->ticks_per_frame,
5988+ ffmpegdec->context->time_base.den);
5989+ } else {
5990+ GST_LOG_OBJECT (ffmpegdec, "no valid duration found");
5991+ }
5992+ }
5993+ }
5994+
5995+ /* Take repeat_pict into account */
5996+ if (GST_CLOCK_TIME_IS_VALID (out_duration)) {
5997+ out_duration += out_duration * ffmpegdec->picture->repeat_pict / 2;
5998+ }
5999+ GST_BUFFER_DURATION (*outbuf) = out_duration;
6000+
6001+ if (out_timestamp != -1 && out_duration != -1 && out_duration != 0)
6002+ ffmpegdec->next_out = out_timestamp + out_duration;
6003+ else
6004+ ffmpegdec->next_out = -1;
6005+
6006+ /* now see if we need to clip the buffer against the segment boundaries. */
6007+ if (G_UNLIKELY (!clip_video_buffer (ffmpegdec, *outbuf, out_timestamp,
6008+ out_duration)))
6009+ goto clipped;
6010+
6011+ if (ffmpegdec->picture->top_field_first)
6012+ GST_BUFFER_FLAG_SET (*outbuf, GST_VIDEO_BUFFER_TFF);
6013+
6014+
6015+beach:
6016+ GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
6017+ *ret, *outbuf, len);
6018+ return len;
6019+
6020+ /* special cases */
6021+no_output:
6022+ {
6023+ GST_DEBUG_OBJECT (ffmpegdec, "no output buffer");
6024+ len = -1;
6025+ goto beach;
6026+ }
6027+clipped:
6028+ {
6029+ GST_DEBUG_OBJECT (ffmpegdec, "buffer clipped");
6030+ gst_buffer_unref (*outbuf);
6031+ *outbuf = NULL;
6032+ goto beach;
6033+ }
6034+}
6035+
6036+/* returns TRUE if buffer is within segment, else FALSE.
6037+ * if Buffer is on segment border, it's timestamp and duration will be clipped */
6038+static gboolean
6039+clip_audio_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
6040+ GstClockTime in_dur)
6041+{
6042+ GstClockTime stop;
6043+ gint64 diff, ctime, cstop;
6044+ gboolean res = TRUE;
6045+
6046+ GST_LOG_OBJECT (dec,
6047+ "timestamp:%" GST_TIME_FORMAT ", duration:%" GST_TIME_FORMAT
6048+ ", size %u", GST_TIME_ARGS (in_ts), GST_TIME_ARGS (in_dur),
6049+ GST_BUFFER_SIZE (buf));
6050+
6051+ /* can't clip without TIME segment */
6052+ if (G_UNLIKELY (dec->segment.format != GST_FORMAT_TIME))
6053+ goto beach;
6054+
6055+ /* we need a start time */
6056+ if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (in_ts)))
6057+ goto beach;
6058+
6059+ /* trust duration */
6060+ stop = in_ts + in_dur;
6061+
6062+ res = gst_segment_clip (&dec->segment, GST_FORMAT_TIME, in_ts, stop, &ctime,
6063+ &cstop);
6064+ if (G_UNLIKELY (!res))
6065+ goto out_of_segment;
6066+
6067+ /* see if some clipping happened */
6068+ if (G_UNLIKELY ((diff = ctime - in_ts) > 0)) {
6069+ /* bring clipped time to bytes */
6070+ diff =
6071+ gst_util_uint64_scale_int (diff, dec->format.audio.samplerate,
6072+ GST_SECOND) * (dec->format.audio.depth * dec->format.audio.channels);
6073+
6074+ GST_DEBUG_OBJECT (dec, "clipping start to %" GST_TIME_FORMAT " %"
6075+ G_GINT64_FORMAT " bytes", GST_TIME_ARGS (ctime), diff);
6076+
6077+ GST_BUFFER_SIZE (buf) -= diff;
6078+ GST_BUFFER_DATA (buf) += diff;
6079+ }
6080+ if (G_UNLIKELY ((diff = stop - cstop) > 0)) {
6081+ /* bring clipped time to bytes */
6082+ diff =
6083+ gst_util_uint64_scale_int (diff, dec->format.audio.samplerate,
6084+ GST_SECOND) * (dec->format.audio.depth * dec->format.audio.channels);
6085+
6086+ GST_DEBUG_OBJECT (dec, "clipping stop to %" GST_TIME_FORMAT " %"
6087+ G_GINT64_FORMAT " bytes", GST_TIME_ARGS (cstop), diff);
6088+
6089+ GST_BUFFER_SIZE (buf) -= diff;
6090+ }
6091+ GST_BUFFER_TIMESTAMP (buf) = ctime;
6092+ GST_BUFFER_DURATION (buf) = cstop - ctime;
6093+
6094+beach:
6095+ GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
6096+ return res;
6097+
6098+ /* ERRORS */
6099+out_of_segment:
6100+ {
6101+ GST_LOG_OBJECT (dec, "out of segment");
6102+ goto beach;
6103+ }
6104+}
6105+
6106+static gint
6107+gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec,
6108+ AVCodec * in_plugin, guint8 * data, guint size,
6109+ const GstTSInfo * dec_info, GstBuffer ** outbuf, GstFlowReturn * ret)
6110+{
6111+ gint len = -1;
6112+ gint have_data = AVCODEC_MAX_AUDIO_FRAME_SIZE;
6113+ GstClockTime out_timestamp, out_duration;
6114+ gint64 out_offset;
6115+ AVPacket packet;
6116+
6117+ GST_DEBUG_OBJECT (ffmpegdec,
6118+ "size:%d, offset:%" G_GINT64_FORMAT ", ts:%" GST_TIME_FORMAT ", dur:%"
6119+ GST_TIME_FORMAT ", ffmpegdec->next_out:%" GST_TIME_FORMAT, size,
6120+ dec_info->offset, GST_TIME_ARGS (dec_info->timestamp),
6121+ GST_TIME_ARGS (dec_info->duration), GST_TIME_ARGS (ffmpegdec->next_out));
6122+
6123+ *outbuf =
6124+ new_aligned_buffer (AVCODEC_MAX_AUDIO_FRAME_SIZE,
6125+ GST_PAD_CAPS (ffmpegdec->srcpad));
6126+
6127+ gst_avpacket_init (&packet, data, size);
6128+ len = avcodec_decode_audio3 (ffmpegdec->context,
6129+ (int16_t *) GST_BUFFER_DATA (*outbuf), &have_data, &packet);
6130+ GST_DEBUG_OBJECT (ffmpegdec,
6131+ "Decode audio: len=%d, have_data=%d", len, have_data);
6132+
6133+ if (len >= 0 && have_data > 0) {
6134+ GST_DEBUG_OBJECT (ffmpegdec, "Creating output buffer");
6135+ if (!gst_ffmpegdec_negotiate (ffmpegdec, FALSE)) {
6136+ gst_buffer_unref (*outbuf);
6137+ *outbuf = NULL;
6138+ len = -1;
6139+ goto beach;
6140+ }
6141+
6142+ /* Buffer size */
6143+ GST_BUFFER_SIZE (*outbuf) = have_data;
6144+
6145+ /*
6146+ * Timestamps:
6147+ *
6148+ * 1) Copy input timestamp if valid
6149+ * 2) else interpolate from previous input timestamp
6150+ */
6151+ /* always take timestamps from the input buffer if any */
6152+ if (GST_CLOCK_TIME_IS_VALID (dec_info->timestamp)) {
6153+ out_timestamp = dec_info->timestamp;
6154+ } else {
6155+ out_timestamp = ffmpegdec->next_out;
6156+ }
6157+
6158+ /*
6159+ * Duration:
6160+ *
6161+ * 1) calculate based on number of samples
6162+ */
6163+ out_duration = gst_util_uint64_scale (have_data, GST_SECOND,
6164+ ffmpegdec->format.audio.depth * ffmpegdec->format.audio.channels *
6165+ ffmpegdec->format.audio.samplerate);
6166+
6167+ /* offset:
6168+ *
6169+ * Just copy
6170+ */
6171+ out_offset = dec_info->offset;
6172+
6173+ GST_DEBUG_OBJECT (ffmpegdec,
6174+ "Buffer created. Size:%d , timestamp:%" GST_TIME_FORMAT " , duration:%"
6175+ GST_TIME_FORMAT, have_data,
6176+ GST_TIME_ARGS (out_timestamp), GST_TIME_ARGS (out_duration));
6177+
6178+ GST_BUFFER_TIMESTAMP (*outbuf) = out_timestamp;
6179+ GST_BUFFER_DURATION (*outbuf) = out_duration;
6180+ GST_BUFFER_OFFSET (*outbuf) = out_offset;
6181+ gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (ffmpegdec->srcpad));
6182+
6183+ /* the next timestamp we'll use when interpolating */
6184+ if (GST_CLOCK_TIME_IS_VALID (out_timestamp))
6185+ ffmpegdec->next_out = out_timestamp + out_duration;
6186+
6187+ /* now see if we need to clip the buffer against the segment boundaries. */
6188+ if (G_UNLIKELY (!clip_audio_buffer (ffmpegdec, *outbuf, out_timestamp,
6189+ out_duration)))
6190+ goto clipped;
6191+
6192+ } else {
6193+ gst_buffer_unref (*outbuf);
6194+ *outbuf = NULL;
6195+ }
6196+
6197+ /* If we don't error out after the first failed read with the AAC decoder,
6198+ * we must *not* carry on pushing data, else we'll cause segfaults... */
6199+ if (len == -1 && (in_plugin->id == CODEC_ID_AAC
6200+ || in_plugin->id == CODEC_ID_AAC_LATM)) {
6201+ GST_ELEMENT_ERROR (ffmpegdec, STREAM, DECODE, (NULL),
6202+ ("Decoding of AAC stream by FFMPEG failed."));
6203+ *ret = GST_FLOW_ERROR;
6204+ }
6205+
6206+beach:
6207+ GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
6208+ *ret, *outbuf, len);
6209+ return len;
6210+
6211+ /* ERRORS */
6212+clipped:
6213+ {
6214+ GST_DEBUG_OBJECT (ffmpegdec, "buffer clipped");
6215+ gst_buffer_unref (*outbuf);
6216+ *outbuf = NULL;
6217+ goto beach;
6218+ }
6219+}
6220+
6221+/* gst_ffmpegdec_frame:
6222+ * ffmpegdec:
6223+ * data: pointer to the data to decode
6224+ * size: size of data in bytes
6225+ * got_data: 0 if no data was decoded, != 0 otherwise.
6226+ * in_time: timestamp of data
6227+ * in_duration: duration of data
6228+ * ret: GstFlowReturn to return in the chain function
6229+ *
6230+ * Decode the given frame and pushes it downstream.
6231+ *
6232+ * Returns: Number of bytes used in decoding, -1 on error/failure.
6233+ */
6234+
6235+static gint
6236+gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec,
6237+ guint8 * data, guint size, gint * got_data, const GstTSInfo * dec_info,
6238+ GstFlowReturn * ret)
6239+{
6240+ GstFFMpegDecClass *oclass;
6241+ GstBuffer *outbuf = NULL;
6242+ gint have_data = 0, len = 0;
6243+
6244+ if (G_UNLIKELY (ffmpegdec->context->codec == NULL))
6245+ goto no_codec;
6246+
6247+ GST_LOG_OBJECT (ffmpegdec, "data:%p, size:%d, id:%d", data, size,
6248+ dec_info->idx);
6249+
6250+ *ret = GST_FLOW_OK;
6251+ ffmpegdec->context->frame_number++;
6252+
6253+ oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
6254+
6255+ switch (oclass->in_plugin->type) {
6256+ case AVMEDIA_TYPE_VIDEO:
6257+ len =
6258+ gst_ffmpegdec_video_frame (ffmpegdec, data, size, dec_info, &outbuf,
6259+ ret);
6260+ break;
6261+ case AVMEDIA_TYPE_AUDIO:
6262+ len =
6263+ gst_ffmpegdec_audio_frame (ffmpegdec, oclass->in_plugin, data, size,
6264+ dec_info, &outbuf, ret);
6265+
6266+ /* if we did not get an output buffer and we have a pending discont, don't
6267+ * clear the input timestamps, we will put them on the next buffer because
6268+ * else we might create the first buffer with a very big timestamp gap. */
6269+ if (outbuf == NULL && ffmpegdec->discont) {
6270+ GST_DEBUG_OBJECT (ffmpegdec, "no buffer but keeping timestamp");
6271+ ffmpegdec->clear_ts = FALSE;
6272+ }
6273+ break;
6274+ default:
6275+ GST_ERROR_OBJECT (ffmpegdec, "Asked to decode non-audio/video frame !");
6276+ g_assert_not_reached ();
6277+ break;
6278+ }
6279+
6280+ if (outbuf)
6281+ have_data = 1;
6282+
6283+ if (len < 0 || have_data < 0) {
6284+ GST_WARNING_OBJECT (ffmpegdec,
6285+ "ffdec_%s: decoding error (len: %d, have_data: %d)",
6286+ oclass->in_plugin->name, len, have_data);
6287+ *got_data = 0;
6288+ goto beach;
6289+ } else if (len == 0 && have_data == 0) {
6290+ *got_data = 0;
6291+ goto beach;
6292+ } else {
6293+ /* this is where I lost my last clue on ffmpeg... */
6294+ *got_data = 1;
6295+ }
6296+
6297+ if (outbuf) {
6298+ GST_LOG_OBJECT (ffmpegdec,
6299+ "Decoded data, now pushing buffer %p with offset %" G_GINT64_FORMAT
6300+ ", timestamp %" GST_TIME_FORMAT " and duration %" GST_TIME_FORMAT,
6301+ outbuf, GST_BUFFER_OFFSET (outbuf),
6302+ GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
6303+ GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)));
6304+
6305+ /* mark pending discont */
6306+ if (ffmpegdec->discont) {
6307+ GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
6308+ ffmpegdec->discont = FALSE;
6309+ }
6310+
6311+ if (ffmpegdec->segment.rate > 0.0) {
6312+ /* and off we go */
6313+ *ret = gst_pad_push (ffmpegdec->srcpad, outbuf);
6314+ } else {
6315+ /* reverse playback, queue frame till later when we get a discont. */
6316+ GST_DEBUG_OBJECT (ffmpegdec, "queued frame");
6317+ ffmpegdec->queued = g_list_prepend (ffmpegdec->queued, outbuf);
6318+ *ret = GST_FLOW_OK;
6319+ }
6320+ } else {
6321+ GST_DEBUG_OBJECT (ffmpegdec, "We didn't get a decoded buffer");
6322+ }
6323+
6324+beach:
6325+ return len;
6326+
6327+ /* ERRORS */
6328+no_codec:
6329+ {
6330+ GST_ERROR_OBJECT (ffmpegdec, "no codec context");
6331+ return -1;
6332+ }
6333+}
6334+
6335+static void
6336+gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec)
6337+{
6338+ GstFFMpegDecClass *oclass;
6339+
6340+ oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
6341+
6342+ if (oclass->in_plugin->capabilities & CODEC_CAP_DELAY) {
6343+ gint have_data, len, try = 0;
6344+
6345+ GST_LOG_OBJECT (ffmpegdec,
6346+ "codec has delay capabilities, calling until ffmpeg has drained everything");
6347+
6348+ do {
6349+ GstFlowReturn ret;
6350+
6351+ len =
6352+ gst_ffmpegdec_frame (ffmpegdec, NULL, 0, &have_data, &ts_info_none,
6353+ &ret);
6354+ if (len < 0 || have_data == 0)
6355+ break;
6356+ } while (try++ < 10);
6357+ }
6358+ if (ffmpegdec->segment.rate < 0.0) {
6359+ /* if we have some queued frames for reverse playback, flush them now */
6360+ flush_queued (ffmpegdec);
6361+ }
6362+}
6363+
6364+static void
6365+gst_ffmpegdec_flush_pcache (GstFFMpegDec * ffmpegdec)
6366+{
6367+ if (ffmpegdec->pctx) {
6368+ gint size, bsize;
6369+ guint8 *data;
6370+ guint8 bdata[FF_INPUT_BUFFER_PADDING_SIZE];
6371+
6372+ bsize = FF_INPUT_BUFFER_PADDING_SIZE;
6373+ memset (bdata, 0, bsize);
6374+
6375+ /* parse some dummy data to work around some ffmpeg weirdness where it keeps
6376+ * the previous pts around */
6377+ av_parser_parse2 (ffmpegdec->pctx, ffmpegdec->context,
6378+ &data, &size, bdata, bsize, -1, -1, -1);
6379+ ffmpegdec->pctx->pts = -1;
6380+ ffmpegdec->pctx->dts = -1;
6381+ }
6382+
6383+ if (ffmpegdec->pcache) {
6384+ gst_buffer_unref (ffmpegdec->pcache);
6385+ ffmpegdec->pcache = NULL;
6386+ }
6387+}
6388+
6389+static gboolean
6390+gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event)
6391+{
6392+ GstFFMpegDec *ffmpegdec;
6393+ gboolean ret = FALSE;
6394+
6395+ ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
6396+
6397+ GST_DEBUG_OBJECT (ffmpegdec, "Handling %s event",
6398+ GST_EVENT_TYPE_NAME (event));
6399+
6400+ switch (GST_EVENT_TYPE (event)) {
6401+ case GST_EVENT_EOS:
6402+ {
6403+ gst_ffmpegdec_drain (ffmpegdec);
6404+ break;
6405+ }
6406+ case GST_EVENT_FLUSH_STOP:
6407+ {
6408+ if (ffmpegdec->opened) {
6409+ avcodec_flush_buffers (ffmpegdec->context);
6410+ }
6411+ gst_ffmpegdec_reset_ts (ffmpegdec);
6412+ gst_ffmpegdec_reset_qos (ffmpegdec);
6413+ gst_ffmpegdec_flush_pcache (ffmpegdec);
6414+ gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
6415+ clear_queued (ffmpegdec);
6416+ break;
6417+ }
6418+ case GST_EVENT_NEWSEGMENT:
6419+ {
6420+ gboolean update;
6421+ GstFormat fmt;
6422+ gint64 start, stop, time;
6423+ gdouble rate, arate;
6424+
6425+ gst_event_parse_new_segment_full (event, &update, &rate, &arate, &fmt,
6426+ &start, &stop, &time);
6427+
6428+ switch (fmt) {
6429+ case GST_FORMAT_TIME:
6430+ /* fine, our native segment format */
6431+ break;
6432+ case GST_FORMAT_BYTES:
6433+ {
6434+ gint bit_rate;
6435+
6436+ bit_rate = ffmpegdec->context->bit_rate;
6437+
6438+ /* convert to time or fail */
6439+ if (!bit_rate)
6440+ goto no_bitrate;
6441+
6442+ GST_DEBUG_OBJECT (ffmpegdec, "bitrate: %d", bit_rate);
6443+
6444+ /* convert values to TIME */
6445+ if (start != -1)
6446+ start = gst_util_uint64_scale_int (start, GST_SECOND, bit_rate);
6447+ if (stop != -1)
6448+ stop = gst_util_uint64_scale_int (stop, GST_SECOND, bit_rate);
6449+ if (time != -1)
6450+ time = gst_util_uint64_scale_int (time, GST_SECOND, bit_rate);
6451+
6452+ /* unref old event */
6453+ gst_event_unref (event);
6454+
6455+ /* create new converted time segment */
6456+ fmt = GST_FORMAT_TIME;
6457+ /* FIXME, bitrate is not good enough too find a good stop, let's
6458+ * hope start and time were 0... meh. */
6459+ stop = -1;
6460+ event = gst_event_new_new_segment (update, rate, fmt,
6461+ start, stop, time);
6462+ break;
6463+ }
6464+ default:
6465+ /* invalid format */
6466+ goto invalid_format;
6467+ }
6468+
6469+ /* drain pending frames before trying to use the new segment, queued
6470+ * buffers belonged to the previous segment. */
6471+ if (ffmpegdec->context->codec)
6472+ gst_ffmpegdec_drain (ffmpegdec);
6473+
6474+ GST_DEBUG_OBJECT (ffmpegdec,
6475+ "NEWSEGMENT in time start %" GST_TIME_FORMAT " -- stop %"
6476+ GST_TIME_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
6477+
6478+ /* and store the values */
6479+ gst_segment_set_newsegment_full (&ffmpegdec->segment, update,
6480+ rate, arate, fmt, start, stop, time);
6481+ break;
6482+ }
6483+ default:
6484+ break;
6485+ }
6486+
6487+ /* and push segment downstream */
6488+ ret = gst_pad_push_event (ffmpegdec->srcpad, event);
6489+
6490+done:
6491+ gst_object_unref (ffmpegdec);
6492+
6493+ return ret;
6494+
6495+ /* ERRORS */
6496+no_bitrate:
6497+ {
6498+ GST_WARNING_OBJECT (ffmpegdec, "no bitrate to convert BYTES to TIME");
6499+ gst_event_unref (event);
6500+ goto done;
6501+ }
6502+invalid_format:
6503+ {
6504+ GST_WARNING_OBJECT (ffmpegdec, "unknown format received in NEWSEGMENT");
6505+ gst_event_unref (event);
6506+ goto done;
6507+ }
6508+}
6509+
6510+static GstFlowReturn
6511+gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
6512+{
6513+ GstFFMpegDec *ffmpegdec;
6514+ GstFFMpegDecClass *oclass;
6515+ guint8 *data, *bdata;
6516+ gint size, bsize, len, have_data;
6517+ GstFlowReturn ret = GST_FLOW_OK;
6518+ GstClockTime in_timestamp;
6519+ GstClockTime in_duration;
6520+ gboolean discont;
6521+ gint64 in_offset;
6522+ const GstTSInfo *in_info;
6523+ const GstTSInfo *dec_info;
6524+
6525+ ffmpegdec = (GstFFMpegDec *) (GST_PAD_PARENT (pad));
6526+
6527+ if (G_UNLIKELY (!ffmpegdec->opened))
6528+ goto not_negotiated;
6529+
6530+ discont = GST_BUFFER_IS_DISCONT (inbuf);
6531+
6532+ /* The discont flags marks a buffer that is not continuous with the previous
6533+ * buffer. This means we need to clear whatever data we currently have. We
6534+ * currently also wait for a new keyframe, which might be suboptimal in the
6535+ * case of a network error, better show the errors than to drop all data.. */
6536+ if (G_UNLIKELY (discont)) {
6537+ GST_DEBUG_OBJECT (ffmpegdec, "received DISCONT");
6538+ /* drain what we have queued */
6539+ gst_ffmpegdec_drain (ffmpegdec);
6540+ gst_ffmpegdec_flush_pcache (ffmpegdec);
6541+ avcodec_flush_buffers (ffmpegdec->context);
6542+ ffmpegdec->discont = TRUE;
6543+ gst_ffmpegdec_reset_ts (ffmpegdec);
6544+ }
6545+ /* by default we clear the input timestamp after decoding each frame so that
6546+ * interpollation can work. */
6547+ ffmpegdec->clear_ts = TRUE;
6548+
6549+ oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
6550+
6551+ /* parse cache joining. If there is cached data */
6552+ if (ffmpegdec->pcache) {
6553+ /* join with previous data */
6554+ GST_LOG_OBJECT (ffmpegdec, "join parse cache");
6555+ inbuf = gst_buffer_join (ffmpegdec->pcache, inbuf);
6556+ /* no more cached data, we assume we can consume the complete cache */
6557+ ffmpegdec->pcache = NULL;
6558+ }
6559+
6560+ in_timestamp = GST_BUFFER_TIMESTAMP (inbuf);
6561+ in_duration = GST_BUFFER_DURATION (inbuf);
6562+ in_offset = GST_BUFFER_OFFSET (inbuf);
6563+
6564+ /* get handle to timestamp info, we can pass this around to ffmpeg */
6565+ in_info = gst_ts_info_store (ffmpegdec, in_timestamp, in_duration, in_offset);
6566+
6567+ if (in_timestamp != -1) {
6568+ /* check for increasing timestamps if they are jumping backwards, we
6569+ * probably are dealing with PTS as timestamps */
6570+ if (!ffmpegdec->reordered_in && ffmpegdec->last_in != -1) {
6571+ if (in_timestamp < ffmpegdec->last_in) {
6572+ GST_LOG_OBJECT (ffmpegdec, "detected reordered input timestamps");
6573+ ffmpegdec->reordered_in = TRUE;
6574+ ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
6575+ } else if (in_timestamp > ffmpegdec->last_in) {
6576+ GstClockTime diff;
6577+ /* keep track of timestamp diff to estimate duration */
6578+ diff = in_timestamp - ffmpegdec->last_in;
6579+ /* need to scale with amount of frames in the interval */
6580+ if (ffmpegdec->last_frames)
6581+ diff /= ffmpegdec->last_frames;
6582+
6583+ GST_LOG_OBJECT (ffmpegdec, "estimated duration %" GST_TIME_FORMAT " %u",
6584+ GST_TIME_ARGS (diff), ffmpegdec->last_frames);
6585+
6586+ ffmpegdec->last_diff = diff;
6587+ }
6588+ }
6589+ ffmpegdec->last_in = in_timestamp;
6590+ ffmpegdec->last_frames = 0;
6591+ }
6592+
6593+ GST_LOG_OBJECT (ffmpegdec,
6594+ "Received new data of size %u, offset:%" G_GUINT64_FORMAT ", ts:%"
6595+ GST_TIME_FORMAT ", dur:%" GST_TIME_FORMAT ", info %d",
6596+ GST_BUFFER_SIZE (inbuf), GST_BUFFER_OFFSET (inbuf),
6597+ GST_TIME_ARGS (in_timestamp), GST_TIME_ARGS (in_duration), in_info->idx);
6598+
6599+ /* workarounds, functions write to buffers:
6600+ * libavcodec/svq1.c:svq1_decode_frame writes to the given buffer.
6601+ * libavcodec/svq3.c:svq3_decode_slice_header too.
6602+ * ffmpeg devs know about it and will fix it (they said). */
6603+ if (oclass->in_plugin->id == CODEC_ID_SVQ1 ||
6604+ oclass->in_plugin->id == CODEC_ID_SVQ3) {
6605+ inbuf = gst_buffer_make_writable (inbuf);
6606+ }
6607+
6608+ bdata = GST_BUFFER_DATA (inbuf);
6609+ bsize = GST_BUFFER_SIZE (inbuf);
6610+
6611+ if (ffmpegdec->do_padding) {
6612+ /* add padding */
6613+ if (ffmpegdec->padded_size < bsize + FF_INPUT_BUFFER_PADDING_SIZE) {
6614+ ffmpegdec->padded_size = bsize + FF_INPUT_BUFFER_PADDING_SIZE;
6615+ ffmpegdec->padded = g_realloc (ffmpegdec->padded, ffmpegdec->padded_size);
6616+ GST_LOG_OBJECT (ffmpegdec, "resized padding buffer to %d",
6617+ ffmpegdec->padded_size);
6618+ }
6619+ memcpy (ffmpegdec->padded, bdata, bsize);
6620+ memset (ffmpegdec->padded + bsize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
6621+
6622+ bdata = ffmpegdec->padded;
6623+ }
6624+
6625+ do {
6626+ guint8 tmp_padding[FF_INPUT_BUFFER_PADDING_SIZE];
6627+
6628+ /* parse, if at all possible */
6629+ if (ffmpegdec->pctx) {
6630+ gint res;
6631+
6632+ GST_LOG_OBJECT (ffmpegdec,
6633+ "Calling av_parser_parse2 with offset %" G_GINT64_FORMAT ", ts:%"
6634+ GST_TIME_FORMAT " size %d", in_offset, GST_TIME_ARGS (in_timestamp),
6635+ bsize);
6636+
6637+ /* feed the parser. We pass the timestamp info so that we can recover all
6638+ * info again later */
6639+ res = av_parser_parse2 (ffmpegdec->pctx, ffmpegdec->context,
6640+ &data, &size, bdata, bsize, in_info->idx, in_info->idx, in_offset);
6641+
6642+ GST_LOG_OBJECT (ffmpegdec,
6643+ "parser returned res %d and size %d, id %" G_GINT64_FORMAT, res, size,
6644+ ffmpegdec->pctx->pts);
6645+
6646+ /* store pts for decoding */
6647+ if (ffmpegdec->pctx->pts != AV_NOPTS_VALUE && ffmpegdec->pctx->pts != -1)
6648+ dec_info = gst_ts_info_get (ffmpegdec, ffmpegdec->pctx->pts);
6649+ else {
6650+ /* ffmpeg sometimes loses track after a flush, help it by feeding a
6651+ * valid start time */
6652+ ffmpegdec->pctx->pts = in_info->idx;
6653+ ffmpegdec->pctx->dts = in_info->idx;
6654+ dec_info = in_info;
6655+ }
6656+
6657+ GST_LOG_OBJECT (ffmpegdec, "consuming %d bytes. id %d", size,
6658+ dec_info->idx);
6659+
6660+ if (res) {
6661+ /* there is output, set pointers for next round. */
6662+ bsize -= res;
6663+ bdata += res;
6664+ } else {
6665+ /* Parser did not consume any data, make sure we don't clear the
6666+ * timestamp for the next round */
6667+ ffmpegdec->clear_ts = FALSE;
6668+ }
6669+
6670+ /* if there is no output, we must break and wait for more data. also the
6671+ * timestamp in the context is not updated. */
6672+ if (size == 0) {
6673+ if (bsize > 0)
6674+ continue;
6675+ else
6676+ break;
6677+ }
6678+ } else {
6679+ data = bdata;
6680+ size = bsize;
6681+
6682+ dec_info = in_info;
6683+ }
6684+
6685+ if (ffmpegdec->do_padding) {
6686+ /* add temporary padding */
6687+ memcpy (tmp_padding, data + size, FF_INPUT_BUFFER_PADDING_SIZE);
6688+ memset (data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
6689+ }
6690+
6691+ /* decode a frame of audio/video now */
6692+ len =
6693+ gst_ffmpegdec_frame (ffmpegdec, data, size, &have_data, dec_info, &ret);
6694+
6695+ if (ffmpegdec->do_padding) {
6696+ memcpy (data + size, tmp_padding, FF_INPUT_BUFFER_PADDING_SIZE);
6697+ }
6698+
6699+ if (ret != GST_FLOW_OK) {
6700+ GST_LOG_OBJECT (ffmpegdec, "breaking because of flow ret %s",
6701+ gst_flow_get_name (ret));
6702+ /* bad flow retun, make sure we discard all data and exit */
6703+ bsize = 0;
6704+ break;
6705+ }
6706+ if (!ffmpegdec->pctx) {
6707+ if (len == 0 && !have_data) {
6708+ /* nothing was decoded, this could be because no data was available or
6709+ * because we were skipping frames.
6710+ * If we have no context we must exit and wait for more data, we keep the
6711+ * data we tried. */
6712+ GST_LOG_OBJECT (ffmpegdec, "Decoding didn't return any data, breaking");
6713+ break;
6714+ } else if (len < 0) {
6715+ /* a decoding error happened, we must break and try again with next data. */
6716+ GST_LOG_OBJECT (ffmpegdec, "Decoding error, breaking");
6717+ bsize = 0;
6718+ break;
6719+ }
6720+ /* prepare for the next round, for codecs with a context we did this
6721+ * already when using the parser. */
6722+ bsize -= len;
6723+ bdata += len;
6724+ } else {
6725+ if (len == 0) {
6726+ /* nothing was decoded, this could be because no data was available or
6727+ * because we were skipping frames. Since we have a parser we can
6728+ * continue with the next frame */
6729+ GST_LOG_OBJECT (ffmpegdec,
6730+ "Decoding didn't return any data, trying next");
6731+ } else if (len < 0) {
6732+ /* we have a context that will bring us to the next frame */
6733+ GST_LOG_OBJECT (ffmpegdec, "Decoding error, trying next");
6734+ }
6735+ }
6736+
6737+ /* make sure we don't use the same old timestamp for the next frame and let
6738+ * the interpollation take care of it. */
6739+ if (ffmpegdec->clear_ts) {
6740+ in_timestamp = GST_CLOCK_TIME_NONE;
6741+ in_duration = GST_CLOCK_TIME_NONE;
6742+ in_offset = GST_BUFFER_OFFSET_NONE;
6743+ in_info = GST_TS_INFO_NONE;
6744+ } else {
6745+ ffmpegdec->clear_ts = TRUE;
6746+ }
6747+ ffmpegdec->last_frames++;
6748+
6749+ GST_LOG_OBJECT (ffmpegdec, "Before (while bsize>0). bsize:%d , bdata:%p",
6750+ bsize, bdata);
6751+ } while (bsize > 0);
6752+
6753+ /* keep left-over */
6754+ if (ffmpegdec->pctx && bsize > 0) {
6755+ in_timestamp = GST_BUFFER_TIMESTAMP (inbuf);
6756+ in_offset = GST_BUFFER_OFFSET (inbuf);
6757+
6758+ GST_LOG_OBJECT (ffmpegdec,
6759+ "Keeping %d bytes of data with offset %" G_GINT64_FORMAT ", timestamp %"
6760+ GST_TIME_FORMAT, bsize, in_offset, GST_TIME_ARGS (in_timestamp));
6761+
6762+ ffmpegdec->pcache = gst_buffer_create_sub (inbuf,
6763+ GST_BUFFER_SIZE (inbuf) - bsize, bsize);
6764+ /* we keep timestamp, even though all we really know is that the correct
6765+ * timestamp is not below the one from inbuf */
6766+ GST_BUFFER_TIMESTAMP (ffmpegdec->pcache) = in_timestamp;
6767+ GST_BUFFER_OFFSET (ffmpegdec->pcache) = in_offset;
6768+ } else if (bsize > 0) {
6769+ GST_DEBUG_OBJECT (ffmpegdec, "Dropping %d bytes of data", bsize);
6770+ }
6771+ gst_buffer_unref (inbuf);
6772+
6773+ return ret;
6774+
6775+ /* ERRORS */
6776+not_negotiated:
6777+ {
6778+ oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
6779+ GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
6780+ ("ffdec_%s: input format was not set before data start",
6781+ oclass->in_plugin->name));
6782+ gst_buffer_unref (inbuf);
6783+ return GST_FLOW_NOT_NEGOTIATED;
6784+ }
6785+}
6786+
6787+static GstStateChangeReturn
6788+gst_ffmpegdec_change_state (GstElement * element, GstStateChange transition)
6789+{
6790+ GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) element;
6791+ GstStateChangeReturn ret;
6792+
6793+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
6794+
6795+ switch (transition) {
6796+ case GST_STATE_CHANGE_PAUSED_TO_READY:
6797+ GST_OBJECT_LOCK (ffmpegdec);
6798+ gst_ffmpegdec_close (ffmpegdec);
6799+ GST_OBJECT_UNLOCK (ffmpegdec);
6800+ clear_queued (ffmpegdec);
6801+ g_free (ffmpegdec->padded);
6802+ ffmpegdec->padded = NULL;
6803+ ffmpegdec->padded_size = 0;
6804+ ffmpegdec->can_allocate_aligned = TRUE;
6805+ break;
6806+ default:
6807+ break;
6808+ }
6809+
6810+ return ret;
6811+}
6812+
6813+static void
6814+gst_ffmpegdec_set_property (GObject * object,
6815+ guint prop_id, const GValue * value, GParamSpec * pspec)
6816+{
6817+ GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
6818+
6819+ switch (prop_id) {
6820+ case PROP_LOWRES:
6821+ ffmpegdec->lowres = ffmpegdec->context->lowres = g_value_get_enum (value);
6822+ break;
6823+ case PROP_SKIPFRAME:
6824+ ffmpegdec->skip_frame = ffmpegdec->context->skip_frame =
6825+ g_value_get_enum (value);
6826+ break;
6827+ case PROP_DIRECT_RENDERING:
6828+ ffmpegdec->direct_rendering = g_value_get_boolean (value);
6829+ break;
6830+ case PROP_DO_PADDING:
6831+ ffmpegdec->do_padding = g_value_get_boolean (value);
6832+ break;
6833+ case PROP_DEBUG_MV:
6834+ ffmpegdec->debug_mv = ffmpegdec->context->debug_mv =
6835+ g_value_get_boolean (value);
6836+ break;
6837+ case PROP_CROP:
6838+ ffmpegdec->crop = g_value_get_boolean (value);
6839+ break;
6840+ case PROP_MAX_THREADS:
6841+ ffmpegdec->max_threads = g_value_get_int (value);
6842+ break;
6843+ default:
6844+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
6845+ break;
6846+ }
6847+}
6848+
6849+static void
6850+gst_ffmpegdec_get_property (GObject * object,
6851+ guint prop_id, GValue * value, GParamSpec * pspec)
6852+{
6853+ GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
6854+
6855+ switch (prop_id) {
6856+ case PROP_LOWRES:
6857+ g_value_set_enum (value, ffmpegdec->context->lowres);
6858+ break;
6859+ case PROP_SKIPFRAME:
6860+ g_value_set_enum (value, ffmpegdec->context->skip_frame);
6861+ break;
6862+ case PROP_DIRECT_RENDERING:
6863+ g_value_set_boolean (value, ffmpegdec->direct_rendering);
6864+ break;
6865+ case PROP_DO_PADDING:
6866+ g_value_set_boolean (value, ffmpegdec->do_padding);
6867+ break;
6868+ case PROP_DEBUG_MV:
6869+ g_value_set_boolean (value, ffmpegdec->context->debug_mv);
6870+ break;
6871+ case PROP_CROP:
6872+ g_value_set_boolean (value, ffmpegdec->crop);
6873+ break;
6874+ case PROP_MAX_THREADS:
6875+ g_value_set_int (value, ffmpegdec->max_threads);
6876+ break;
6877+ default:
6878+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
6879+ break;
6880+ }
6881+}
6882+
6883+gboolean
6884+gst_ffmpegdec_register (GstPlugin * plugin)
6885+{
6886+ GTypeInfo typeinfo = {
6887+ sizeof (GstFFMpegDecClass),
6888+ (GBaseInitFunc) gst_ffmpegdec_base_init,
6889+ NULL,
6890+ (GClassInitFunc) gst_ffmpegdec_class_init,
6891+ NULL,
6892+ NULL,
6893+ sizeof (GstFFMpegDec),
6894+ 0,
6895+ (GInstanceInitFunc) gst_ffmpegdec_init,
6896+ };
6897+ GType type;
6898+ AVCodec *in_plugin;
6899+ gint rank;
6900+
6901+ in_plugin = av_codec_next (NULL);
6902+
6903+ GST_LOG ("Registering decoders");
6904+
6905+ while (in_plugin) {
6906+ gchar *type_name;
6907+ gchar *plugin_name;
6908+
6909+ /* only decoders */
6910+ if (!in_plugin->decode) {
6911+ goto next;
6912+ }
6913+
6914+ /* no quasi-codecs, please */
6915+ if (in_plugin->id == CODEC_ID_RAWVIDEO ||
6916+ in_plugin->id == CODEC_ID_V210 ||
6917+ in_plugin->id == CODEC_ID_V210X ||
6918+ in_plugin->id == CODEC_ID_R210 ||
6919+ (in_plugin->id >= CODEC_ID_PCM_S16LE &&
6920+ in_plugin->id <= CODEC_ID_PCM_BLURAY)) {
6921+ goto next;
6922+ }
6923+
6924+ /* No decoders depending on external libraries (we don't build them, but
6925+ * people who build against an external ffmpeg might have them.
6926+ * We have native gstreamer plugins for all of those libraries anyway. */
6927+ if (!strncmp (in_plugin->name, "lib", 3)) {
6928+ GST_DEBUG
6929+ ("Not using external library decoder %s. Use the gstreamer-native ones instead.",
6930+ in_plugin->name);
6931+ goto next;
6932+ }
6933+
6934+ /* No vdpau plugins until we can figure out how to properly use them
6935+ * outside of ffmpeg. */
6936+ if (g_str_has_suffix (in_plugin->name, "_vdpau")) {
6937+ GST_DEBUG
6938+ ("Ignoring VDPAU decoder %s. We can't handle this outside of ffmpeg",
6939+ in_plugin->name);
6940+ goto next;
6941+ }
6942+
6943+ if (g_str_has_suffix (in_plugin->name, "_xvmc")) {
6944+ GST_DEBUG
6945+ ("Ignoring XVMC decoder %s. We can't handle this outside of ffmpeg",
6946+ in_plugin->name);
6947+ goto next;
6948+ }
6949+
6950+ GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name);
6951+
6952+ /* no codecs for which we're GUARANTEED to have better alternatives */
6953+ /* MPEG1VIDEO : the mpeg2video decoder is preferred */
6954+ /* MP1 : Use MP3 for decoding */
6955+ /* MP2 : Use MP3 for decoding */
6956+ /* Theora: Use libtheora based theoradec */
6957+ if (!strcmp (in_plugin->name, "gif") ||
6958+ !strcmp (in_plugin->name, "vorbis") ||
6959+ !strcmp (in_plugin->name, "theora") ||
6960+ !strcmp (in_plugin->name, "mpeg1video") ||
6961+ !strcmp (in_plugin->name, "wavpack") ||
6962+ !strcmp (in_plugin->name, "mp1") ||
6963+ !strcmp (in_plugin->name, "mp2") ||
6964+ !strcmp (in_plugin->name, "libfaad") ||
6965+ !strcmp (in_plugin->name, "mpeg4aac") ||
6966+ !strcmp (in_plugin->name, "ass") ||
6967+ !strcmp (in_plugin->name, "srt") ||
6968+ !strcmp (in_plugin->name, "pgssub") ||
6969+ !strcmp (in_plugin->name, "dvdsub") ||
6970+ !strcmp (in_plugin->name, "dvbsub")) {
6971+ GST_LOG ("Ignoring decoder %s", in_plugin->name);
6972+ goto next;
6973+ }
6974+
6975+ /* construct the type */
6976+ plugin_name = g_strdup ((gchar *) in_plugin->name);
6977+ g_strdelimit (plugin_name, NULL, '_');
6978+ type_name = g_strdup_printf ("ffdec_%s", plugin_name);
6979+ g_free (plugin_name);
6980+
6981+ type = g_type_from_name (type_name);
6982+
6983+ if (!type) {
6984+ /* create the gtype now */
6985+ type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
6986+ g_type_set_qdata (type, GST_FFDEC_PARAMS_QDATA, (gpointer) in_plugin);
6987+ }
6988+
6989+ /* (Ronald) MPEG-4 gets a higher priority because it has been well-
6990+ * tested and by far outperforms divxdec/xviddec - so we prefer it.
6991+ * msmpeg4v3 same, as it outperforms divxdec for divx3 playback.
6992+ * VC1/WMV3 are not working and thus unpreferred for now. */
6993+ switch (in_plugin->id) {
6994+ case CODEC_ID_MPEG4:
6995+ case CODEC_ID_MSMPEG4V3:
6996+ case CODEC_ID_H264:
6997+ case CODEC_ID_RA_144:
6998+ case CODEC_ID_RA_288:
6999+ case CODEC_ID_RV10:
7000+ case CODEC_ID_RV20:
7001+ case CODEC_ID_RV30:
7002+ case CODEC_ID_RV40:
7003+ case CODEC_ID_COOK:
7004+ rank = GST_RANK_SECONDARY;
7005+ break;
7006+ /* DVVIDEO: we have a good dv decoder, fast on both ppc as well as x86.
7007+ * They say libdv's quality is better though. leave as secondary.
7008+ * note: if you change this, see the code in gstdv.c in good/ext/dv.
7009+ *
7010+ * SIPR: decoder should have a higher rank than realaudiodec.
7011+ */
7012+ case CODEC_ID_DVVIDEO:
7013+ case CODEC_ID_SIPR:
7014+ rank = GST_RANK_SECONDARY;
7015+ break;
7016+ case CODEC_ID_MP3:
7017+ rank = GST_RANK_NONE;
7018+ break;
7019+ /* TEMPORARILY DISABLING AC3/EAC3/DTS for 0.10.12 release
7020+ * due to downmixing failure.
7021+ * See Bug #608892 for more details */
7022+ case CODEC_ID_EAC3:
7023+ case CODEC_ID_AC3:
7024+ case CODEC_ID_DTS:
7025+ rank = GST_RANK_NONE;
7026+ break;
7027+ default:
7028+ rank = GST_RANK_MARGINAL;
7029+ break;
7030+ }
7031+ if (!gst_element_register (plugin, type_name, rank, type)) {
7032+ g_warning ("Failed to register %s", type_name);
7033+ g_free (type_name);
7034+ return FALSE;
7035+ }
7036+
7037+ g_free (type_name);
7038+
7039+ next:
7040+ in_plugin = av_codec_next (in_plugin);
7041+ }
7042+
7043+ GST_LOG ("Finished Registering decoders");
7044+
7045+ return TRUE;
7046+}
7047diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.rej gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.rej
7048--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdec.c.rej 1970-01-01 01:00:00.000000000 +0100
7049+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdec.c.rej 2014-08-08 15:26:38.471858652 +0200
7050@@ -0,0 +1,11 @@
7051+--- ext/ffmpeg/gstffmpegdec.c
7052++++ ext/ffmpeg/gstffmpegdec.c
7053+@@ -1565,7 +1564,7 @@
7054+ gst_message_new_latency (GST_OBJECT_CAST (ffmpegdec)));
7055+ }
7056+
7057+- is_itype = (ffmpegdec->picture->pict_type == FF_I_TYPE);
7058++ is_itype = (ffmpegdec->picture->pict_type == AV_PICTURE_TYPE_I);
7059+ is_reference = (ffmpegdec->picture->reference == 1);
7060+
7061+ iskeyframe = (is_itype || is_reference || ffmpegdec->picture->key_frame)
7062diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdemux.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdemux.c
7063--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegdemux.c 2011-07-13 11:07:28.000000000 +0200
7064+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegdemux.c 2014-08-08 15:26:07.874857555 +0200
7065@@ -343,8 +343,11 @@
7066 demux->audiopads = 0;
7067
7068 /* close demuxer context from ffmpeg */
7069- av_close_input_file (demux->context);
7070- demux->context = NULL;
7071+ if (demux->seekable)
7072+ gst_ffmpegdata_close (demux->context->pb);
7073+ else
7074+ gst_ffmpeg_pipe_close (demux->context->pb);
7075+ avformat_close_input (&demux->context);
7076
7077 GST_OBJECT_LOCK (demux);
7078 demux->opened = FALSE;
7079@@ -1146,9 +1149,9 @@
7080 static gboolean
7081 gst_ffmpegdemux_open (GstFFMpegDemux * demux)
7082 {
7083+ AVIOContext *iocontext = NULL;
7084 GstFFMpegDemuxClass *oclass =
7085 (GstFFMpegDemuxClass *) G_OBJECT_GET_CLASS (demux);
7086- gchar *location;
7087 gint res, n_streams, i;
7088 #if 0
7089 /* Re-enable once converted to new AVMetaData API
7090@@ -1164,15 +1167,14 @@
7091
7092 /* open via our input protocol hack */
7093 if (demux->seekable)
7094- location = g_strdup_printf ("gstreamer://%p", demux->sinkpad);
7095+ res = gst_ffmpegdata_open (demux->sinkpad, AVIO_FLAG_READ, &iocontext);
7096 else
7097- location = g_strdup_printf ("gstpipe://%p", &demux->ffpipe);
7098- GST_DEBUG_OBJECT (demux, "about to call av_open_input_file %s", location);
7099+ res = gst_ffmpeg_pipe_open (&demux->ffpipe, AVIO_FLAG_READ, &iocontext);
7100
7101- res = av_open_input_file (&demux->context, location,
7102- oclass->in_plugin, 0, NULL);
7103+ demux->context = avformat_alloc_context ();
7104+ demux->context->pb = iocontext;
7105+ res = avformat_open_input (&demux->context, NULL, oclass->in_plugin, NULL);
7106
7107- g_free (location);
7108 GST_DEBUG_OBJECT (demux, "av_open_input returned %d", res);
7109 if (res < 0)
7110 goto open_failed;
7111diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegenc.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegenc.c
7112--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegenc.c 2011-10-31 11:14:03.000000000 +0100
7113+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegenc.c 2014-08-08 15:32:18.608870847 +0200
7114@@ -770,7 +770,7 @@
7115 GST_OBJECT_UNLOCK (ffmpegenc);
7116
7117 if (force_keyframe)
7118- ffmpegenc->picture->pict_type = FF_I_TYPE;
7119+ ffmpegenc->picture->pict_type = AV_PICTURE_TYPE_I;
7120
7121 frame_size = gst_ffmpeg_avpicture_fill ((AVPicture *) ffmpegenc->picture,
7122 GST_BUFFER_DATA (inbuf),
7123@@ -1136,7 +1136,7 @@
7124 const GstStructure *s;
7125 s = gst_event_get_structure (event);
7126 if (gst_structure_has_name (s, "GstForceKeyUnit")) {
7127- ffmpegenc->picture->pict_type = FF_I_TYPE;
7128+ ffmpegenc->picture->pict_type = AV_PICTURE_TYPE_I;
7129 }
7130 break;
7131 }
7132@@ -1339,7 +1339,7 @@
7133 }
7134
7135 /* only encoders */
7136- if (!in_plugin->encode) {
7137+ if (!av_codec_is_encoder (in_plugin)) {
7138 goto next;
7139 }
7140
7141diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c
7142--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c 2011-07-13 11:07:28.000000000 +0200
7143+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c 2014-08-08 15:26:07.874857555 +0200
7144@@ -24,8 +24,10 @@
7145 #include <string.h>
7146 #ifdef HAVE_FFMPEG_UNINSTALLED
7147 #include <avformat.h>
7148+#include <opt.h>
7149 #else
7150 #include <libavformat/avformat.h>
7151+#include <libavutil/opt.h>
7152 #endif
7153
7154 #include <gst/gst.h>
7155@@ -336,9 +338,6 @@
7156 ffmpegmux->context = g_new0 (AVFormatContext, 1);
7157 ffmpegmux->context->oformat = oclass->in_plugin;
7158 ffmpegmux->context->nb_streams = 0;
7159- g_snprintf (ffmpegmux->context->filename,
7160- sizeof (ffmpegmux->context->filename),
7161- "gstreamer://%p", ffmpegmux->srcpad);
7162 ffmpegmux->opened = FALSE;
7163
7164 ffmpegmux->videopads = 0;
7165@@ -450,10 +449,10 @@
7166 gst_element_add_pad (element, pad);
7167
7168 /* AVStream needs to be created */
7169- st = av_new_stream (ffmpegmux->context, collect_pad->padnum);
7170+ st = avformat_new_stream (ffmpegmux->context, NULL);
7171+ st->id = collect_pad->padnum;
7172 st->codec->codec_type = type;
7173 st->codec->codec_id = CODEC_ID_NONE; /* this is a check afterwards */
7174- st->stream_copy = 1; /* we're not the actual encoder */
7175 st->codec->bit_rate = bitrate;
7176 st->codec->frame_size = framesize;
7177 /* we fill in codec during capsnego */
7178@@ -485,7 +484,7 @@
7179 collect_pad = (GstFFMpegMuxPad *) gst_pad_get_element_private (pad);
7180
7181 st = ffmpegmux->context->streams[collect_pad->padnum];
7182- ffmpegmux->context->preload = ffmpegmux->preload;
7183+ av_opt_set_int (&ffmpegmux->context, "preload", ffmpegmux->preload, 0);
7184 ffmpegmux->context->max_delay = ffmpegmux->max_delay;
7185
7186 /* for the format-specific guesses, we'll go to
7187@@ -552,7 +551,7 @@
7188
7189 /* open "file" (gstreamer protocol to next element) */
7190 if (!ffmpegmux->opened) {
7191- int open_flags = URL_WRONLY;
7192+ int open_flags = AVIO_FLAG_WRITE;
7193
7194 /* we do need all streams to have started capsnego,
7195 * or things will go horribly wrong */
7196@@ -646,19 +645,13 @@
7197 open_flags |= GST_FFMPEG_URL_STREAMHEADER;
7198 }
7199
7200- if (url_fopen (&ffmpegmux->context->pb,
7201- ffmpegmux->context->filename, open_flags) < 0) {
7202+ if (gst_ffmpegdata_open (ffmpegmux->srcpad, open_flags,
7203+ &ffmpegmux->context->pb) < 0) {
7204 GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, TOO_LAZY, (NULL),
7205 ("Failed to open stream context in ffmux"));
7206 return GST_FLOW_ERROR;
7207 }
7208
7209- if (av_set_parameters (ffmpegmux->context, NULL) < 0) {
7210- GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, INIT, (NULL),
7211- ("Failed to initialize muxer"));
7212- return GST_FLOW_ERROR;
7213- }
7214-
7215 /* now open the mux format */
7216 if (av_write_header (ffmpegmux->context) < 0) {
7217 GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, SETTINGS, (NULL),
7218@@ -670,7 +663,7 @@
7219 ffmpegmux->opened = TRUE;
7220
7221 /* flush the header so it will be used as streamheader */
7222- put_flush_packet (ffmpegmux->context->pb);
7223+ avio_flush (ffmpegmux->context->pb);
7224 }
7225
7226 /* take the one with earliest timestamp,
7227@@ -770,8 +763,8 @@
7228 /* close down */
7229 av_write_trailer (ffmpegmux->context);
7230 ffmpegmux->opened = FALSE;
7231- put_flush_packet (ffmpegmux->context->pb);
7232- url_fclose (ffmpegmux->context->pb);
7233+ avio_flush (ffmpegmux->context->pb);
7234+ gst_ffmpegdata_close (ffmpegmux->context->pb);
7235 gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_eos ());
7236 return GST_FLOW_UNEXPECTED;
7237 }
7238@@ -795,6 +788,10 @@
7239 break;
7240 case GST_STATE_CHANGE_PAUSED_TO_READY:
7241 gst_collect_pads_stop (ffmpegmux->collect);
7242+ if (ffmpegmux->opened) {
7243+ ffmpegmux->opened = FALSE;
7244+ gst_ffmpegdata_close (ffmpegmux->context->pb);
7245+ }
7246 break;
7247 default:
7248 break;
7249@@ -809,7 +806,7 @@
7250 gst_tag_setter_reset_tags (GST_TAG_SETTER (ffmpegmux));
7251 if (ffmpegmux->opened) {
7252 ffmpegmux->opened = FALSE;
7253- url_fclose (ffmpegmux->context->pb);
7254+ avio_close (ffmpegmux->context->pb);
7255 }
7256 break;
7257 case GST_STATE_CHANGE_READY_TO_NULL:
7258diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c.orig
7259--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegmux.c.orig 1970-01-01 01:00:00.000000000 +0100
7260+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegmux.c.orig 2011-07-13 11:07:28.000000000 +0200
7261@@ -0,0 +1,970 @@
7262+/* GStreamer
7263+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
7264+ *
7265+ * This library is free software; you can redistribute it and/or
7266+ * modify it under the terms of the GNU Library General Public
7267+ * License as published by the Free Software Foundation; either
7268+ * version 2 of the License, or (at your option) any later version.
7269+ *
7270+ * This library is distributed in the hope that it will be useful,
7271+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7272+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7273+ * Library General Public License for more details.
7274+ *
7275+ * You should have received a copy of the GNU Library General Public
7276+ * License along with this library; if not, write to the
7277+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
7278+ * Boston, MA 02111-1307, USA.
7279+ */
7280+
7281+#ifdef HAVE_CONFIG_H
7282+#include "config.h"
7283+#endif
7284+
7285+#include <string.h>
7286+#ifdef HAVE_FFMPEG_UNINSTALLED
7287+#include <avformat.h>
7288+#else
7289+#include <libavformat/avformat.h>
7290+#endif
7291+
7292+#include <gst/gst.h>
7293+#include <gst/base/gstcollectpads.h>
7294+
7295+#include "gstffmpeg.h"
7296+#include "gstffmpegcodecmap.h"
7297+#include "gstffmpegutils.h"
7298+
7299+typedef struct _GstFFMpegMux GstFFMpegMux;
7300+typedef struct _GstFFMpegMuxPad GstFFMpegMuxPad;
7301+
7302+struct _GstFFMpegMuxPad
7303+{
7304+ GstCollectData collect; /* we extend the CollectData */
7305+
7306+ gint padnum;
7307+};
7308+
7309+struct _GstFFMpegMux
7310+{
7311+ GstElement element;
7312+
7313+ GstCollectPads *collect;
7314+ /* We need to keep track of our pads, so we do so here. */
7315+ GstPad *srcpad;
7316+
7317+ AVFormatContext *context;
7318+ gboolean opened;
7319+
7320+ gint videopads, audiopads;
7321+
7322+ /*< private > */
7323+ /* event_function is the collectpads default eventfunction */
7324+ GstPadEventFunction event_function;
7325+ int preload;
7326+ int max_delay;
7327+};
7328+
7329+typedef struct _GstFFMpegMuxClass GstFFMpegMuxClass;
7330+
7331+struct _GstFFMpegMuxClass
7332+{
7333+ GstElementClass parent_class;
7334+
7335+ AVOutputFormat *in_plugin;
7336+};
7337+
7338+#define GST_TYPE_FFMPEGMUX \
7339+ (gst_ffmpegdec_get_type())
7340+#define GST_FFMPEGMUX(obj) \
7341+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGMUX,GstFFMpegMux))
7342+#define GST_FFMPEGMUX_CLASS(klass) \
7343+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGMUX,GstFFMpegMuxClass))
7344+#define GST_IS_FFMPEGMUX(obj) \
7345+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGMUX))
7346+#define GST_IS_FFMPEGMUX_CLASS(klass) \
7347+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGMUX))
7348+
7349+enum
7350+{
7351+ /* FILL ME */
7352+ LAST_SIGNAL
7353+};
7354+
7355+enum
7356+{
7357+ ARG_0,
7358+ /* FILL ME */
7359+};
7360+
7361+enum
7362+{
7363+ PROP_0,
7364+ PROP_PRELOAD,
7365+ PROP_MAXDELAY
7366+};
7367+
7368+/* A number of function prototypes are given so we can refer to them later. */
7369+static void gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass);
7370+static void gst_ffmpegmux_base_init (gpointer g_class);
7371+static void gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux,
7372+ GstFFMpegMuxClass * g_class);
7373+static void gst_ffmpegmux_finalize (GObject * object);
7374+
7375+static gboolean gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps);
7376+static GstPad *gst_ffmpegmux_request_new_pad (GstElement * element,
7377+ GstPadTemplate * templ, const gchar * name);
7378+static GstFlowReturn gst_ffmpegmux_collected (GstCollectPads * pads,
7379+ gpointer user_data);
7380+
7381+static gboolean gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event);
7382+
7383+static GstStateChangeReturn gst_ffmpegmux_change_state (GstElement * element,
7384+ GstStateChange transition);
7385+
7386+static void gst_ffmpegmux_set_property (GObject * object, guint prop_id,
7387+ const GValue * value, GParamSpec * pspec);
7388+static void gst_ffmpegmux_get_property (GObject * object, guint prop_id,
7389+ GValue * value, GParamSpec * pspec);
7390+
7391+static GstCaps *gst_ffmpegmux_get_id_caps (enum CodecID *id_list);
7392+static void gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * caps,
7393+ const gchar * field, guint num, const gint * values);
7394+
7395+#define GST_FFMUX_PARAMS_QDATA g_quark_from_static_string("ffmux-params")
7396+
7397+static GstElementClass *parent_class = NULL;
7398+
7399+/*static guint gst_ffmpegmux_signals[LAST_SIGNAL] = { 0 }; */
7400+
7401+typedef struct
7402+{
7403+ const char *name;
7404+ const char *replacement;
7405+} GstFFMpegMuxReplacement;
7406+
7407+static const char *
7408+gst_ffmpegmux_get_replacement (const char *name)
7409+{
7410+ static const GstFFMpegMuxReplacement blacklist[] = {
7411+ {"avi", "avimux"},
7412+ {"matroska", "matroskamux"},
7413+ {"mov", "qtmux"},
7414+ {"mpegts", "mpegtsmux"},
7415+ {"mp4", "mp4mux"},
7416+ {"mpjpeg", "multipartmux"},
7417+ {"ogg", "oggmux"},
7418+ {"wav", "wavenc"},
7419+ {"webm", "webmmux"},
7420+ {"mxf", "mxfmux"},
7421+ {"3gp", "gppmux"},
7422+ {"yuv4mpegpipe", "y4menc"},
7423+ {"aiff", "aiffmux"},
7424+ {"adts", "aacparse"},
7425+ {"asf", "asfmux"},
7426+ {"asf_stream", "asfmux"},
7427+ {"flv", "flvmux"},
7428+ {"mp3", "id3v2mux"},
7429+ {"mp2", "id3v2mux"}
7430+ };
7431+ int i;
7432+
7433+ for (i = 0; i < sizeof (blacklist) / sizeof (blacklist[0]); i++) {
7434+ if (strcmp (blacklist[i].name, name) == 0) {
7435+ return blacklist[i].replacement;
7436+ }
7437+ }
7438+
7439+ return NULL;
7440+}
7441+
7442+static gboolean
7443+gst_ffmpegmux_is_formatter (const char *name)
7444+{
7445+ static const char *replace[] = {
7446+ "mp2", "mp3", NULL
7447+ };
7448+ int i;
7449+
7450+ for (i = 0; replace[i]; i++)
7451+ if (strcmp (replace[i], name) == 0)
7452+ return TRUE;
7453+ return FALSE;
7454+}
7455+
7456+static void
7457+gst_ffmpegmux_base_init (gpointer g_class)
7458+{
7459+ GstFFMpegMuxClass *klass = (GstFFMpegMuxClass *) g_class;
7460+ GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
7461+ GstPadTemplate *videosinktempl, *audiosinktempl, *srctempl;
7462+ AVOutputFormat *in_plugin;
7463+ GstCaps *srccaps, *audiosinkcaps, *videosinkcaps;
7464+ enum CodecID *video_ids = NULL, *audio_ids = NULL;
7465+ gchar *longname, *description;
7466+ const char *replacement;
7467+ gboolean is_formatter;
7468+
7469+ in_plugin =
7470+ (AVOutputFormat *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
7471+ GST_FFMUX_PARAMS_QDATA);
7472+ g_assert (in_plugin != NULL);
7473+
7474+ /* construct the element details struct */
7475+ replacement = gst_ffmpegmux_get_replacement (in_plugin->name);
7476+ is_formatter = gst_ffmpegmux_is_formatter (in_plugin->name);
7477+ if (replacement != NULL) {
7478+ longname =
7479+ g_strdup_printf ("FFmpeg %s %s (not recommended, use %s instead)",
7480+ in_plugin->long_name, is_formatter ? "formatter" : "muxer",
7481+ replacement);
7482+ description =
7483+ g_strdup_printf ("FFmpeg %s %s (not recommended, use %s instead)",
7484+ in_plugin->long_name, is_formatter ? "formatter" : "muxer",
7485+ replacement);
7486+ } else {
7487+ longname = g_strdup_printf ("FFmpeg %s %s", in_plugin->long_name,
7488+ is_formatter ? "formatter" : "muxer");
7489+ description = g_strdup_printf ("FFmpeg %s %s", in_plugin->long_name,
7490+ is_formatter ? "formatter" : "muxer");
7491+ }
7492+ gst_element_class_set_details_simple (element_class, longname,
7493+ is_formatter ? "Formatter/Metadata" : "Codec/Muxer", description,
7494+ "Wim Taymans <wim.taymans@chello.be>, "
7495+ "Ronald Bultje <rbultje@ronald.bitfreak.net>");
7496+ g_free (longname);
7497+ g_free (description);
7498+
7499+ /* Try to find the caps that belongs here */
7500+ srccaps = gst_ffmpeg_formatid_to_caps (in_plugin->name);
7501+ if (!srccaps) {
7502+ GST_DEBUG ("Couldn't get source caps for muxer '%s', skipping format",
7503+ in_plugin->name);
7504+ goto beach;
7505+ }
7506+
7507+ if (!gst_ffmpeg_formatid_get_codecids (in_plugin->name,
7508+ &video_ids, &audio_ids, in_plugin)) {
7509+ gst_caps_unref (srccaps);
7510+ GST_DEBUG
7511+ ("Couldn't get sink caps for muxer '%s'. Most likely because no input format mapping exists.",
7512+ in_plugin->name);
7513+ goto beach;
7514+ }
7515+
7516+ videosinkcaps = video_ids ? gst_ffmpegmux_get_id_caps (video_ids) : NULL;
7517+ audiosinkcaps = audio_ids ? gst_ffmpegmux_get_id_caps (audio_ids) : NULL;
7518+
7519+ /* fix up allowed caps for some muxers */
7520+ /* FIXME : This should be in gstffmpegcodecmap.c ! */
7521+ if (strcmp (in_plugin->name, "flv") == 0) {
7522+ const gint rates[] = { 44100, 22050, 11025 };
7523+
7524+ gst_ffmpeg_mux_simple_caps_set_int_list (audiosinkcaps, "rate", 3, rates);
7525+ } else if (strcmp (in_plugin->name, "gif") == 0) {
7526+ if (videosinkcaps)
7527+ gst_caps_unref (videosinkcaps);
7528+
7529+ videosinkcaps =
7530+ gst_caps_from_string ("video/x-raw-rgb, bpp=(int)24, depth=(int)24");
7531+ }
7532+
7533+ /* pad templates */
7534+ srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
7535+ gst_element_class_add_pad_template (element_class, srctempl);
7536+
7537+ if (audiosinkcaps) {
7538+ audiosinktempl = gst_pad_template_new ("audio_%d",
7539+ GST_PAD_SINK, GST_PAD_REQUEST, audiosinkcaps);
7540+ gst_element_class_add_pad_template (element_class, audiosinktempl);
7541+ }
7542+
7543+ if (videosinkcaps) {
7544+ videosinktempl = gst_pad_template_new ("video_%d",
7545+ GST_PAD_SINK, GST_PAD_REQUEST, videosinkcaps);
7546+ gst_element_class_add_pad_template (element_class, videosinktempl);
7547+ }
7548+
7549+beach:
7550+ klass->in_plugin = in_plugin;
7551+}
7552+
7553+static void
7554+gst_ffmpegmux_class_init (GstFFMpegMuxClass * klass)
7555+{
7556+ GObjectClass *gobject_class;
7557+ GstElementClass *gstelement_class;
7558+
7559+ gobject_class = (GObjectClass *) klass;
7560+ gstelement_class = (GstElementClass *) klass;
7561+
7562+ parent_class = g_type_class_peek_parent (klass);
7563+
7564+ gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_ffmpegmux_set_property);
7565+ gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_ffmpegmux_get_property);
7566+
7567+ g_object_class_install_property (gobject_class, PROP_PRELOAD,
7568+ g_param_spec_int ("preload", "preload",
7569+ "Set the initial demux-decode delay (in microseconds)", 0, G_MAXINT,
7570+ 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
7571+
7572+ g_object_class_install_property (gobject_class, PROP_MAXDELAY,
7573+ g_param_spec_int ("maxdelay", "maxdelay",
7574+ "Set the maximum demux-decode delay (in microseconds)", 0, G_MAXINT,
7575+ 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
7576+
7577+ gstelement_class->request_new_pad = gst_ffmpegmux_request_new_pad;
7578+ gstelement_class->change_state = gst_ffmpegmux_change_state;
7579+ gobject_class->finalize = gst_ffmpegmux_finalize;
7580+}
7581+
7582+static void
7583+gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux, GstFFMpegMuxClass * g_class)
7584+{
7585+ GstElementClass *klass = GST_ELEMENT_CLASS (g_class);
7586+ GstFFMpegMuxClass *oclass = (GstFFMpegMuxClass *) klass;
7587+ GstPadTemplate *templ = gst_element_class_get_pad_template (klass, "src");
7588+
7589+ ffmpegmux->srcpad = gst_pad_new_from_template (templ, "src");
7590+ gst_pad_set_caps (ffmpegmux->srcpad, gst_pad_template_get_caps (templ));
7591+ gst_element_add_pad (GST_ELEMENT (ffmpegmux), ffmpegmux->srcpad);
7592+
7593+ ffmpegmux->collect = gst_collect_pads_new ();
7594+ gst_collect_pads_set_function (ffmpegmux->collect,
7595+ (GstCollectPadsFunction) gst_ffmpegmux_collected, ffmpegmux);
7596+
7597+ ffmpegmux->context = g_new0 (AVFormatContext, 1);
7598+ ffmpegmux->context->oformat = oclass->in_plugin;
7599+ ffmpegmux->context->nb_streams = 0;
7600+ g_snprintf (ffmpegmux->context->filename,
7601+ sizeof (ffmpegmux->context->filename),
7602+ "gstreamer://%p", ffmpegmux->srcpad);
7603+ ffmpegmux->opened = FALSE;
7604+
7605+ ffmpegmux->videopads = 0;
7606+ ffmpegmux->audiopads = 0;
7607+ ffmpegmux->preload = 0;
7608+ ffmpegmux->max_delay = 0;
7609+}
7610+
7611+static void
7612+gst_ffmpegmux_set_property (GObject * object, guint prop_id,
7613+ const GValue * value, GParamSpec * pspec)
7614+{
7615+ GstFFMpegMux *src;
7616+
7617+ src = (GstFFMpegMux *) object;
7618+
7619+ switch (prop_id) {
7620+ case PROP_PRELOAD:
7621+ src->preload = g_value_get_int (value);
7622+ break;
7623+ case PROP_MAXDELAY:
7624+ src->max_delay = g_value_get_int (value);
7625+ break;
7626+ default:
7627+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
7628+ break;
7629+ }
7630+}
7631+
7632+static void
7633+gst_ffmpegmux_get_property (GObject * object, guint prop_id, GValue * value,
7634+ GParamSpec * pspec)
7635+{
7636+ GstFFMpegMux *src;
7637+
7638+ src = (GstFFMpegMux *) object;
7639+
7640+ switch (prop_id) {
7641+ case PROP_PRELOAD:
7642+ g_value_set_int (value, src->preload);
7643+ break;
7644+ case PROP_MAXDELAY:
7645+ g_value_set_int (value, src->max_delay);
7646+ break;
7647+ default:
7648+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
7649+ break;
7650+ }
7651+}
7652+
7653+
7654+static void
7655+gst_ffmpegmux_finalize (GObject * object)
7656+{
7657+ GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) object;
7658+
7659+ g_free (ffmpegmux->context);
7660+ gst_object_unref (ffmpegmux->collect);
7661+
7662+ if (G_OBJECT_CLASS (parent_class)->finalize)
7663+ G_OBJECT_CLASS (parent_class)->finalize (object);
7664+}
7665+
7666+static GstPad *
7667+gst_ffmpegmux_request_new_pad (GstElement * element,
7668+ GstPadTemplate * templ, const gchar * name)
7669+{
7670+ GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) element;
7671+ GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
7672+ GstFFMpegMuxPad *collect_pad;
7673+ gchar *padname;
7674+ GstPad *pad;
7675+ AVStream *st;
7676+ enum AVMediaType type;
7677+ gint bitrate = 0, framesize = 0;
7678+
7679+ g_return_val_if_fail (templ != NULL, NULL);
7680+ g_return_val_if_fail (templ->direction == GST_PAD_SINK, NULL);
7681+ g_return_val_if_fail (ffmpegmux->opened == FALSE, NULL);
7682+
7683+ /* figure out a name that *we* like */
7684+ if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
7685+ padname = g_strdup_printf ("video_%d", ffmpegmux->videopads++);
7686+ type = AVMEDIA_TYPE_VIDEO;
7687+ bitrate = 64 * 1024;
7688+ framesize = 1152;
7689+ } else if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
7690+ padname = g_strdup_printf ("audio_%d", ffmpegmux->audiopads++);
7691+ type = AVMEDIA_TYPE_AUDIO;
7692+ bitrate = 285 * 1024;
7693+ } else {
7694+ g_warning ("ffmux: unknown pad template!");
7695+ return NULL;
7696+ }
7697+
7698+ /* create pad */
7699+ pad = gst_pad_new_from_template (templ, padname);
7700+ collect_pad = (GstFFMpegMuxPad *)
7701+ gst_collect_pads_add_pad (ffmpegmux->collect, pad,
7702+ sizeof (GstFFMpegMuxPad));
7703+ collect_pad->padnum = ffmpegmux->context->nb_streams;
7704+
7705+ /* small hack to put our own event pad function and chain up to collect pad */
7706+ ffmpegmux->event_function = GST_PAD_EVENTFUNC (pad);
7707+ gst_pad_set_event_function (pad,
7708+ GST_DEBUG_FUNCPTR (gst_ffmpegmux_sink_event));
7709+
7710+ gst_pad_set_setcaps_function (pad, GST_DEBUG_FUNCPTR (gst_ffmpegmux_setcaps));
7711+ gst_element_add_pad (element, pad);
7712+
7713+ /* AVStream needs to be created */
7714+ st = av_new_stream (ffmpegmux->context, collect_pad->padnum);
7715+ st->codec->codec_type = type;
7716+ st->codec->codec_id = CODEC_ID_NONE; /* this is a check afterwards */
7717+ st->stream_copy = 1; /* we're not the actual encoder */
7718+ st->codec->bit_rate = bitrate;
7719+ st->codec->frame_size = framesize;
7720+ /* we fill in codec during capsnego */
7721+
7722+ /* we love debug output (c) (tm) (r) */
7723+ GST_DEBUG ("Created %s pad for ffmux_%s element",
7724+ padname, ((GstFFMpegMuxClass *) klass)->in_plugin->name);
7725+ g_free (padname);
7726+
7727+ return pad;
7728+}
7729+
7730+/**
7731+ * gst_ffmpegmux_setcaps
7732+ * @pad: #GstPad
7733+ * @caps: New caps.
7734+ *
7735+ * Set caps to pad.
7736+ *
7737+ * Returns: #TRUE on success.
7738+ */
7739+static gboolean
7740+gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps)
7741+{
7742+ GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (gst_pad_get_parent (pad));
7743+ GstFFMpegMuxPad *collect_pad;
7744+ AVStream *st;
7745+
7746+ collect_pad = (GstFFMpegMuxPad *) gst_pad_get_element_private (pad);
7747+
7748+ st = ffmpegmux->context->streams[collect_pad->padnum];
7749+ ffmpegmux->context->preload = ffmpegmux->preload;
7750+ ffmpegmux->context->max_delay = ffmpegmux->max_delay;
7751+
7752+ /* for the format-specific guesses, we'll go to
7753+ * our famous codec mapper */
7754+ if (gst_ffmpeg_caps_to_codecid (caps, st->codec) == CODEC_ID_NONE)
7755+ goto not_accepted;
7756+
7757+ /* copy over the aspect ratios, ffmpeg expects the stream aspect to match the
7758+ * codec aspect. */
7759+ st->sample_aspect_ratio = st->codec->sample_aspect_ratio;
7760+
7761+ GST_LOG_OBJECT (pad, "accepted caps %" GST_PTR_FORMAT, caps);
7762+ return TRUE;
7763+
7764+ /* ERRORS */
7765+not_accepted:
7766+ {
7767+ GST_LOG_OBJECT (pad, "rejecting caps %" GST_PTR_FORMAT, caps);
7768+ return FALSE;
7769+ }
7770+}
7771+
7772+
7773+static gboolean
7774+gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event)
7775+{
7776+ GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) gst_pad_get_parent (pad);
7777+ gboolean res = TRUE;
7778+
7779+ switch (GST_EVENT_TYPE (event)) {
7780+ case GST_EVENT_TAG:{
7781+ GstTagList *taglist;
7782+ GstTagSetter *setter = GST_TAG_SETTER (ffmpegmux);
7783+ const GstTagMergeMode mode = gst_tag_setter_get_tag_merge_mode (setter);
7784+
7785+ gst_event_parse_tag (event, &taglist);
7786+ gst_tag_setter_merge_tags (setter, taglist, mode);
7787+ break;
7788+ }
7789+ default:
7790+ break;
7791+ }
7792+
7793+ /* chaining up to collectpads default event function */
7794+ res = ffmpegmux->event_function (pad, event);
7795+
7796+ gst_object_unref (ffmpegmux);
7797+ return res;
7798+}
7799+
7800+static GstFlowReturn
7801+gst_ffmpegmux_collected (GstCollectPads * pads, gpointer user_data)
7802+{
7803+ GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) user_data;
7804+ GSList *collected;
7805+ GstFFMpegMuxPad *best_pad;
7806+ GstClockTime best_time;
7807+#if 0
7808+ /* Re-enable once converted to new AVMetaData API
7809+ * See #566605
7810+ */
7811+ const GstTagList *tags;
7812+#endif
7813+
7814+ /* open "file" (gstreamer protocol to next element) */
7815+ if (!ffmpegmux->opened) {
7816+ int open_flags = URL_WRONLY;
7817+
7818+ /* we do need all streams to have started capsnego,
7819+ * or things will go horribly wrong */
7820+ for (collected = ffmpegmux->collect->data; collected;
7821+ collected = g_slist_next (collected)) {
7822+ GstFFMpegMuxPad *collect_pad = (GstFFMpegMuxPad *) collected->data;
7823+ AVStream *st = ffmpegmux->context->streams[collect_pad->padnum];
7824+
7825+ /* check whether the pad has successfully completed capsnego */
7826+ if (st->codec->codec_id == CODEC_ID_NONE) {
7827+ GST_ELEMENT_ERROR (ffmpegmux, CORE, NEGOTIATION, (NULL),
7828+ ("no caps set on stream %d (%s)", collect_pad->padnum,
7829+ (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ?
7830+ "video" : "audio"));
7831+ return GST_FLOW_ERROR;
7832+ }
7833+ /* set framerate for audio */
7834+ if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
7835+ switch (st->codec->codec_id) {
7836+ case CODEC_ID_PCM_S16LE:
7837+ case CODEC_ID_PCM_S16BE:
7838+ case CODEC_ID_PCM_U16LE:
7839+ case CODEC_ID_PCM_U16BE:
7840+ case CODEC_ID_PCM_S8:
7841+ case CODEC_ID_PCM_U8:
7842+ st->codec->frame_size = 1;
7843+ break;
7844+ default:
7845+ {
7846+ GstBuffer *buffer;
7847+
7848+ /* FIXME : This doesn't work for RAW AUDIO...
7849+ * in fact I'm wondering if it even works for any kind of audio... */
7850+ buffer = gst_collect_pads_peek (ffmpegmux->collect,
7851+ (GstCollectData *) collect_pad);
7852+ if (buffer) {
7853+ st->codec->frame_size =
7854+ st->codec->sample_rate *
7855+ GST_BUFFER_DURATION (buffer) / GST_SECOND;
7856+ gst_buffer_unref (buffer);
7857+ }
7858+ }
7859+ }
7860+ }
7861+ }
7862+
7863+#if 0
7864+ /* Re-enable once converted to new AVMetaData API
7865+ * See #566605
7866+ */
7867+
7868+ /* tags */
7869+ tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (ffmpegmux));
7870+ if (tags) {
7871+ gint i;
7872+ gchar *s;
7873+
7874+ /* get the interesting ones */
7875+ if (gst_tag_list_get_string (tags, GST_TAG_TITLE, &s)) {
7876+ strncpy (ffmpegmux->context->title, s,
7877+ sizeof (ffmpegmux->context->title));
7878+ }
7879+ if (gst_tag_list_get_string (tags, GST_TAG_ARTIST, &s)) {
7880+ strncpy (ffmpegmux->context->author, s,
7881+ sizeof (ffmpegmux->context->author));
7882+ }
7883+ if (gst_tag_list_get_string (tags, GST_TAG_COPYRIGHT, &s)) {
7884+ strncpy (ffmpegmux->context->copyright, s,
7885+ sizeof (ffmpegmux->context->copyright));
7886+ }
7887+ if (gst_tag_list_get_string (tags, GST_TAG_COMMENT, &s)) {
7888+ strncpy (ffmpegmux->context->comment, s,
7889+ sizeof (ffmpegmux->context->comment));
7890+ }
7891+ if (gst_tag_list_get_string (tags, GST_TAG_ALBUM, &s)) {
7892+ strncpy (ffmpegmux->context->album, s,
7893+ sizeof (ffmpegmux->context->album));
7894+ }
7895+ if (gst_tag_list_get_string (tags, GST_TAG_GENRE, &s)) {
7896+ strncpy (ffmpegmux->context->genre, s,
7897+ sizeof (ffmpegmux->context->genre));
7898+ }
7899+ if (gst_tag_list_get_int (tags, GST_TAG_TRACK_NUMBER, &i)) {
7900+ ffmpegmux->context->track = i;
7901+ }
7902+ }
7903+#endif
7904+
7905+ /* set the streamheader flag for gstffmpegprotocol if codec supports it */
7906+ if (!strcmp (ffmpegmux->context->oformat->name, "flv")) {
7907+ open_flags |= GST_FFMPEG_URL_STREAMHEADER;
7908+ }
7909+
7910+ if (url_fopen (&ffmpegmux->context->pb,
7911+ ffmpegmux->context->filename, open_flags) < 0) {
7912+ GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, TOO_LAZY, (NULL),
7913+ ("Failed to open stream context in ffmux"));
7914+ return GST_FLOW_ERROR;
7915+ }
7916+
7917+ if (av_set_parameters (ffmpegmux->context, NULL) < 0) {
7918+ GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, INIT, (NULL),
7919+ ("Failed to initialize muxer"));
7920+ return GST_FLOW_ERROR;
7921+ }
7922+
7923+ /* now open the mux format */
7924+ if (av_write_header (ffmpegmux->context) < 0) {
7925+ GST_ELEMENT_ERROR (ffmpegmux, LIBRARY, SETTINGS, (NULL),
7926+ ("Failed to write file header - check codec settings"));
7927+ return GST_FLOW_ERROR;
7928+ }
7929+
7930+ /* we're now opened */
7931+ ffmpegmux->opened = TRUE;
7932+
7933+ /* flush the header so it will be used as streamheader */
7934+ put_flush_packet (ffmpegmux->context->pb);
7935+ }
7936+
7937+ /* take the one with earliest timestamp,
7938+ * and push it forward */
7939+ best_pad = NULL;
7940+ best_time = GST_CLOCK_TIME_NONE;
7941+ for (collected = ffmpegmux->collect->data; collected;
7942+ collected = g_slist_next (collected)) {
7943+ GstFFMpegMuxPad *collect_pad = (GstFFMpegMuxPad *) collected->data;
7944+ GstBuffer *buffer = gst_collect_pads_peek (ffmpegmux->collect,
7945+ (GstCollectData *) collect_pad);
7946+
7947+ /* if there's no buffer, just continue */
7948+ if (buffer == NULL) {
7949+ continue;
7950+ }
7951+
7952+ /* if we have no buffer yet, just use the first one */
7953+ if (best_pad == NULL) {
7954+ best_pad = collect_pad;
7955+ best_time = GST_BUFFER_TIMESTAMP (buffer);
7956+ goto next_pad;
7957+ }
7958+
7959+ /* if we do have one, only use this one if it's older */
7960+ if (GST_BUFFER_TIMESTAMP (buffer) < best_time) {
7961+ best_time = GST_BUFFER_TIMESTAMP (buffer);
7962+ best_pad = collect_pad;
7963+ }
7964+
7965+ next_pad:
7966+ gst_buffer_unref (buffer);
7967+
7968+ /* Mux buffers with invalid timestamp first */
7969+ if (!GST_CLOCK_TIME_IS_VALID (best_time))
7970+ break;
7971+ }
7972+
7973+ /* now handle the buffer, or signal EOS if we have
7974+ * no buffers left */
7975+ if (best_pad != NULL) {
7976+ GstBuffer *buf;
7977+ AVPacket pkt;
7978+ gboolean need_free = FALSE;
7979+
7980+ /* push out current buffer */
7981+ buf = gst_collect_pads_pop (ffmpegmux->collect,
7982+ (GstCollectData *) best_pad);
7983+
7984+ ffmpegmux->context->streams[best_pad->padnum]->codec->frame_number++;
7985+
7986+ /* set time */
7987+ pkt.pts = gst_ffmpeg_time_gst_to_ff (GST_BUFFER_TIMESTAMP (buf),
7988+ ffmpegmux->context->streams[best_pad->padnum]->time_base);
7989+ pkt.dts = pkt.pts;
7990+
7991+ if (strcmp (ffmpegmux->context->oformat->name, "gif") == 0) {
7992+ AVStream *st = ffmpegmux->context->streams[best_pad->padnum];
7993+ AVPicture src, dst;
7994+
7995+ need_free = TRUE;
7996+ pkt.size = st->codec->width * st->codec->height * 3;
7997+ pkt.data = g_malloc (pkt.size);
7998+
7999+ dst.data[0] = pkt.data;
8000+ dst.data[1] = NULL;
8001+ dst.data[2] = NULL;
8002+ dst.linesize[0] = st->codec->width * 3;
8003+
8004+ gst_ffmpeg_avpicture_fill (&src, GST_BUFFER_DATA (buf),
8005+ PIX_FMT_RGB24, st->codec->width, st->codec->height);
8006+
8007+ av_picture_copy (&dst, &src, PIX_FMT_RGB24,
8008+ st->codec->width, st->codec->height);
8009+ } else {
8010+ pkt.data = GST_BUFFER_DATA (buf);
8011+ pkt.size = GST_BUFFER_SIZE (buf);
8012+ }
8013+
8014+ pkt.stream_index = best_pad->padnum;
8015+ pkt.flags = 0;
8016+
8017+ if (!GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT))
8018+ pkt.flags |= AV_PKT_FLAG_KEY;
8019+
8020+ if (GST_BUFFER_DURATION_IS_VALID (buf))
8021+ pkt.duration =
8022+ gst_ffmpeg_time_gst_to_ff (GST_BUFFER_DURATION (buf),
8023+ ffmpegmux->context->streams[best_pad->padnum]->time_base);
8024+ else
8025+ pkt.duration = 0;
8026+ av_write_frame (ffmpegmux->context, &pkt);
8027+ gst_buffer_unref (buf);
8028+ if (need_free)
8029+ g_free (pkt.data);
8030+ } else {
8031+ /* close down */
8032+ av_write_trailer (ffmpegmux->context);
8033+ ffmpegmux->opened = FALSE;
8034+ put_flush_packet (ffmpegmux->context->pb);
8035+ url_fclose (ffmpegmux->context->pb);
8036+ gst_pad_push_event (ffmpegmux->srcpad, gst_event_new_eos ());
8037+ return GST_FLOW_UNEXPECTED;
8038+ }
8039+
8040+ return GST_FLOW_OK;
8041+}
8042+
8043+static GstStateChangeReturn
8044+gst_ffmpegmux_change_state (GstElement * element, GstStateChange transition)
8045+{
8046+ GstFlowReturn ret;
8047+ GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (element);
8048+
8049+ switch (transition) {
8050+ case GST_STATE_CHANGE_NULL_TO_READY:
8051+ break;
8052+ case GST_STATE_CHANGE_READY_TO_PAUSED:
8053+ gst_collect_pads_start (ffmpegmux->collect);
8054+ break;
8055+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
8056+ break;
8057+ case GST_STATE_CHANGE_PAUSED_TO_READY:
8058+ gst_collect_pads_stop (ffmpegmux->collect);
8059+ break;
8060+ default:
8061+ break;
8062+ }
8063+
8064+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
8065+
8066+ switch (transition) {
8067+ case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
8068+ break;
8069+ case GST_STATE_CHANGE_PAUSED_TO_READY:
8070+ gst_tag_setter_reset_tags (GST_TAG_SETTER (ffmpegmux));
8071+ if (ffmpegmux->opened) {
8072+ ffmpegmux->opened = FALSE;
8073+ url_fclose (ffmpegmux->context->pb);
8074+ }
8075+ break;
8076+ case GST_STATE_CHANGE_READY_TO_NULL:
8077+ break;
8078+ default:
8079+ break;
8080+ }
8081+
8082+ return ret;
8083+}
8084+
8085+static GstCaps *
8086+gst_ffmpegmux_get_id_caps (enum CodecID *id_list)
8087+{
8088+ GstCaps *caps, *t;
8089+ gint i;
8090+
8091+ caps = gst_caps_new_empty ();
8092+ for (i = 0; id_list[i] != CODEC_ID_NONE; i++) {
8093+ if ((t = gst_ffmpeg_codecid_to_caps (id_list[i], NULL, TRUE)))
8094+ gst_caps_append (caps, t);
8095+ }
8096+ if (gst_caps_is_empty (caps)) {
8097+ gst_caps_unref (caps);
8098+ return NULL;
8099+ }
8100+
8101+ return caps;
8102+}
8103+
8104+/* set a list of integer values on the caps, e.g. for sample rates */
8105+static void
8106+gst_ffmpeg_mux_simple_caps_set_int_list (GstCaps * caps, const gchar * field,
8107+ guint num, const gint * values)
8108+{
8109+ GValue list = { 0, };
8110+ GValue val = { 0, };
8111+ gint i;
8112+
8113+ g_return_if_fail (GST_CAPS_IS_SIMPLE (caps));
8114+
8115+ g_value_init (&list, GST_TYPE_LIST);
8116+ g_value_init (&val, G_TYPE_INT);
8117+
8118+ for (i = 0; i < num; ++i) {
8119+ g_value_set_int (&val, values[i]);
8120+ gst_value_list_append_value (&list, &val);
8121+ }
8122+
8123+ gst_structure_set_value (gst_caps_get_structure (caps, 0), field, &list);
8124+
8125+ g_value_unset (&val);
8126+ g_value_unset (&list);
8127+}
8128+
8129+gboolean
8130+gst_ffmpegmux_register (GstPlugin * plugin)
8131+{
8132+ GTypeInfo typeinfo = {
8133+ sizeof (GstFFMpegMuxClass),
8134+ (GBaseInitFunc) gst_ffmpegmux_base_init,
8135+ NULL,
8136+ (GClassInitFunc) gst_ffmpegmux_class_init,
8137+ NULL,
8138+ NULL,
8139+ sizeof (GstFFMpegMux),
8140+ 0,
8141+ (GInstanceInitFunc) gst_ffmpegmux_init,
8142+ };
8143+ static const GInterfaceInfo tag_setter_info = {
8144+ NULL, NULL, NULL
8145+ };
8146+ GType type;
8147+ AVOutputFormat *in_plugin;
8148+
8149+ in_plugin = av_oformat_next (NULL);
8150+
8151+ GST_LOG ("Registering muxers");
8152+
8153+ while (in_plugin) {
8154+ gchar *type_name;
8155+ gchar *p;
8156+ GstRank rank = GST_RANK_MARGINAL;
8157+
8158+ if ((!strncmp (in_plugin->name, "u16", 3)) ||
8159+ (!strncmp (in_plugin->name, "s16", 3)) ||
8160+ (!strncmp (in_plugin->name, "u24", 3)) ||
8161+ (!strncmp (in_plugin->name, "s24", 3)) ||
8162+ (!strncmp (in_plugin->name, "u8", 2)) ||
8163+ (!strncmp (in_plugin->name, "s8", 2)) ||
8164+ (!strncmp (in_plugin->name, "u32", 3)) ||
8165+ (!strncmp (in_plugin->name, "s32", 3)) ||
8166+ (!strncmp (in_plugin->name, "f32", 3)) ||
8167+ (!strncmp (in_plugin->name, "f64", 3)) ||
8168+ (!strncmp (in_plugin->name, "raw", 3)) ||
8169+ (!strncmp (in_plugin->name, "crc", 3)) ||
8170+ (!strncmp (in_plugin->name, "null", 4)) ||
8171+ (!strncmp (in_plugin->name, "gif", 3)) ||
8172+ (!strncmp (in_plugin->name, "frame", 5)) ||
8173+ (!strncmp (in_plugin->name, "image", 5)) ||
8174+ (!strncmp (in_plugin->name, "mulaw", 5)) ||
8175+ (!strncmp (in_plugin->name, "alaw", 4)) ||
8176+ (!strncmp (in_plugin->name, "h26", 3)) ||
8177+ (!strncmp (in_plugin->name, "rtp", 3)) ||
8178+ (!strncmp (in_plugin->name, "ass", 3)) ||
8179+ (!strncmp (in_plugin->name, "ffmetadata", 10)) ||
8180+ (!strncmp (in_plugin->name, "srt", 3))
8181+ ) {
8182+ GST_LOG ("Ignoring muxer %s", in_plugin->name);
8183+ goto next;
8184+ }
8185+
8186+ if ((!strncmp (in_plugin->long_name, "raw ", 4))) {
8187+ GST_LOG ("Ignoring raw muxer %s", in_plugin->name);
8188+ goto next;
8189+ }
8190+
8191+ if (gst_ffmpegmux_get_replacement (in_plugin->name))
8192+ rank = GST_RANK_NONE;
8193+
8194+ /* FIXME : We need a fast way to know whether we have mappings for this
8195+ * muxer type. */
8196+
8197+ /* construct the type */
8198+ type_name = g_strdup_printf ("ffmux_%s", in_plugin->name);
8199+
8200+ p = type_name;
8201+
8202+ while (*p) {
8203+ if (*p == '.')
8204+ *p = '_';
8205+ p++;
8206+ }
8207+
8208+ type = g_type_from_name (type_name);
8209+
8210+ if (!type) {
8211+ /* create the type now */
8212+ type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
8213+ g_type_set_qdata (type, GST_FFMUX_PARAMS_QDATA, (gpointer) in_plugin);
8214+ g_type_add_interface_static (type, GST_TYPE_TAG_SETTER, &tag_setter_info);
8215+ }
8216+
8217+ if (!gst_element_register (plugin, type_name, rank, type)) {
8218+ g_free (type_name);
8219+ return FALSE;
8220+ }
8221+
8222+ g_free (type_name);
8223+
8224+ next:
8225+ in_plugin = av_oformat_next (in_plugin);
8226+ }
8227+
8228+ GST_LOG ("Finished registering muxers");
8229+
8230+ return TRUE;
8231+}
8232diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegprotocol.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegprotocol.c
8233--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegprotocol.c 2011-07-12 16:35:28.000000000 +0200
8234+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegprotocol.c 2014-08-08 15:26:07.875857555 +0200
8235@@ -46,63 +46,14 @@
8236 };
8237
8238 static int
8239-gst_ffmpegdata_open (URLContext * h, const char *filename, int flags)
8240-{
8241- GstProtocolInfo *info;
8242- GstPad *pad;
8243-
8244- GST_LOG ("Opening %s", filename);
8245-
8246- info = g_new0 (GstProtocolInfo, 1);
8247-
8248- info->set_streamheader = flags & GST_FFMPEG_URL_STREAMHEADER;
8249- flags &= ~GST_FFMPEG_URL_STREAMHEADER;
8250- h->flags &= ~GST_FFMPEG_URL_STREAMHEADER;
8251-
8252- /* we don't support R/W together */
8253- if (flags != URL_RDONLY && flags != URL_WRONLY) {
8254- GST_WARNING ("Only read-only or write-only are supported");
8255- return -EINVAL;
8256- }
8257-
8258- if (sscanf (&filename[12], "%p", &pad) != 1) {
8259- GST_WARNING ("could not decode pad from %s", filename);
8260- return -EIO;
8261- }
8262-
8263- /* make sure we're a pad and that we're of the right type */
8264- g_return_val_if_fail (GST_IS_PAD (pad), -EINVAL);
8265-
8266- switch (flags) {
8267- case URL_RDONLY:
8268- g_return_val_if_fail (GST_PAD_IS_SINK (pad), -EINVAL);
8269- break;
8270- case URL_WRONLY:
8271- g_return_val_if_fail (GST_PAD_IS_SRC (pad), -EINVAL);
8272- break;
8273- }
8274-
8275- info->eos = FALSE;
8276- info->pad = pad;
8277- info->offset = 0;
8278-
8279- h->priv_data = (void *) info;
8280- h->is_streamed = FALSE;
8281- h->max_packet_size = 0;
8282-
8283- return 0;
8284-}
8285-
8286-static int
8287-gst_ffmpegdata_peek (URLContext * h, unsigned char *buf, int size)
8288+gst_ffmpegdata_peek (void *priv_data, unsigned char *buf, int size)
8289 {
8290 GstProtocolInfo *info;
8291 GstBuffer *inbuf = NULL;
8292 GstFlowReturn ret;
8293 int total = 0;
8294
8295- g_return_val_if_fail (h->flags == URL_RDONLY, AVERROR (EIO));
8296- info = (GstProtocolInfo *) h->priv_data;
8297+ info = (GstProtocolInfo *) priv_data;
8298
8299 GST_DEBUG ("Pulling %d bytes at position %" G_GUINT64_FORMAT, size,
8300 info->offset);
8301@@ -134,17 +85,17 @@
8302 }
8303
8304 static int
8305-gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size)
8306+gst_ffmpegdata_read (void *priv_data, unsigned char *buf, int size)
8307 {
8308 gint res;
8309 GstProtocolInfo *info;
8310
8311- info = (GstProtocolInfo *) h->priv_data;
8312+ info = (GstProtocolInfo *) priv_data;
8313
8314 GST_DEBUG ("Reading %d bytes of data at position %" G_GUINT64_FORMAT, size,
8315 info->offset);
8316
8317- res = gst_ffmpegdata_peek (h, buf, size);
8318+ res = gst_ffmpegdata_peek (priv_data, buf, size);
8319 if (res >= 0)
8320 info->offset += res;
8321
8322@@ -154,15 +105,13 @@
8323 }
8324
8325 static int
8326-gst_ffmpegdata_write (URLContext * h, const unsigned char *buf, int size)
8327+gst_ffmpegdata_write (void *priv_data, const unsigned char *buf, int size)
8328 {
8329 GstProtocolInfo *info;
8330 GstBuffer *outbuf;
8331
8332 GST_DEBUG ("Writing %d bytes", size);
8333- info = (GstProtocolInfo *) h->priv_data;
8334-
8335- g_return_val_if_fail (h->flags != URL_RDONLY, -EIO);
8336+ info = (GstProtocolInfo *) priv_data;
8337
8338 /* create buffer and push data further */
8339 if (gst_pad_alloc_buffer_and_set_caps (info->pad,
8340@@ -179,7 +128,7 @@
8341 }
8342
8343 static int64_t
8344-gst_ffmpegdata_seek (URLContext * h, int64_t pos, int whence)
8345+gst_ffmpegdata_seek (void *priv_data, int64_t pos, int whence)
8346 {
8347 GstProtocolInfo *info;
8348 guint64 newpos = 0;
8349@@ -187,70 +136,62 @@
8350 GST_DEBUG ("Seeking to %" G_GINT64_FORMAT ", whence=%d",
8351 (gint64) pos, whence);
8352
8353- info = (GstProtocolInfo *) h->priv_data;
8354+ info = (GstProtocolInfo *) priv_data;
8355
8356 /* TODO : if we are push-based, we need to return sensible info */
8357
8358- switch (h->flags) {
8359- case URL_RDONLY:
8360- {
8361- /* sinkpad */
8362- switch (whence) {
8363- case SEEK_SET:
8364- newpos = (guint64) pos;
8365- break;
8366- case SEEK_CUR:
8367- newpos = info->offset + pos;
8368- break;
8369- case SEEK_END:
8370- case AVSEEK_SIZE:
8371- /* ffmpeg wants to know the current end position in bytes ! */
8372- {
8373- GstFormat format = GST_FORMAT_BYTES;
8374- gint64 duration;
8375-
8376- GST_DEBUG ("Seek end");
8377-
8378- if (gst_pad_is_linked (info->pad))
8379- if (gst_pad_query_duration (GST_PAD_PEER (info->pad), &format,
8380- &duration))
8381- newpos = ((guint64) duration) + pos;
8382- }
8383- break;
8384- default:
8385- g_assert (0);
8386- break;
8387+ if (GST_PAD_IS_SINK (info->pad)) {
8388+ /* sinkpad */
8389+ switch (whence) {
8390+ case SEEK_SET:
8391+ newpos = (guint64) pos;
8392+ break;
8393+ case SEEK_CUR:
8394+ newpos = info->offset + pos;
8395+ break;
8396+ case SEEK_END:
8397+ case AVSEEK_SIZE:
8398+ /* ffmpeg wants to know the current end position in bytes ! */
8399+ {
8400+ GstFormat format = GST_FORMAT_BYTES;
8401+ gint64 duration;
8402+
8403+ GST_DEBUG ("Seek end");
8404+
8405+ if (gst_pad_is_linked (info->pad))
8406+ if (gst_pad_query_duration (GST_PAD_PEER (info->pad), &format,
8407+ &duration))
8408+ newpos = ((guint64) duration) + pos;
8409 }
8410- /* FIXME : implement case for push-based behaviour */
8411- if (whence != AVSEEK_SIZE)
8412- info->offset = newpos;
8413+ break;
8414+ default:
8415+ g_assert (0);
8416+ break;
8417 }
8418- break;
8419- case URL_WRONLY:
8420- {
8421- /* srcpad */
8422- switch (whence) {
8423- case SEEK_SET:
8424- info->offset = (guint64) pos;
8425- gst_pad_push_event (info->pad, gst_event_new_new_segment
8426- (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
8427- GST_CLOCK_TIME_NONE, info->offset));
8428- break;
8429- case SEEK_CUR:
8430- info->offset += pos;
8431- gst_pad_push_event (info->pad, gst_event_new_new_segment
8432- (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
8433- GST_CLOCK_TIME_NONE, info->offset));
8434- break;
8435- default:
8436- break;
8437- }
8438- newpos = info->offset;
8439+ /* FIXME : implement case for push-based behaviour */
8440+ if (whence != AVSEEK_SIZE)
8441+ info->offset = newpos;
8442+ } else if (GST_PAD_IS_SRC (info->pad)) {
8443+ /* srcpad */
8444+ switch (whence) {
8445+ case SEEK_SET:
8446+ info->offset = (guint64) pos;
8447+ gst_pad_push_event (info->pad, gst_event_new_new_segment
8448+ (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
8449+ GST_CLOCK_TIME_NONE, info->offset));
8450+ break;
8451+ case SEEK_CUR:
8452+ info->offset += pos;
8453+ gst_pad_push_event (info->pad, gst_event_new_new_segment
8454+ (TRUE, 1.0, GST_FORMAT_BYTES, info->offset,
8455+ GST_CLOCK_TIME_NONE, info->offset));
8456+ break;
8457+ default:
8458+ break;
8459 }
8460- break;
8461- default:
8462- g_assert (0);
8463- break;
8464+ newpos = info->offset;
8465+ } else {
8466+ g_assert_not_reached ();
8467 }
8468
8469 GST_DEBUG ("Now at offset %" G_GUINT64_FORMAT " (returning %" G_GUINT64_FORMAT
8470@@ -258,85 +199,91 @@
8471 return newpos;
8472 }
8473
8474-static int
8475-gst_ffmpegdata_close (URLContext * h)
8476+int
8477+gst_ffmpegdata_close (AVIOContext * h)
8478 {
8479 GstProtocolInfo *info;
8480
8481- info = (GstProtocolInfo *) h->priv_data;
8482+ info = (GstProtocolInfo *) h->opaque;
8483 if (info == NULL)
8484 return 0;
8485
8486 GST_LOG ("Closing file");
8487
8488- switch (h->flags) {
8489- case URL_WRONLY:
8490- {
8491- /* send EOS - that closes down the stream */
8492- gst_pad_push_event (info->pad, gst_event_new_eos ());
8493- break;
8494- }
8495- default:
8496- break;
8497+ if (GST_PAD_IS_SRC (info->pad)) {
8498+ /* send EOS - that closes down the stream */
8499+ gst_pad_push_event (info->pad, gst_event_new_eos ());
8500 }
8501
8502 /* clean up data */
8503 g_free (info);
8504- h->priv_data = NULL;
8505+ h->opaque = NULL;
8506+
8507+ av_freep (&h->buffer);
8508+ av_free (h);
8509
8510 return 0;
8511 }
8512
8513+int
8514+gst_ffmpegdata_open (GstPad * pad, int flags, AVIOContext ** context)
8515+{
8516+ GstProtocolInfo *info;
8517+ static const int buffer_size = 4096;
8518+ unsigned char *buffer = NULL;
8519
8520-URLProtocol gstreamer_protocol = {
8521- /*.name = */ "gstreamer",
8522- /*.url_open = */ gst_ffmpegdata_open,
8523- /*.url_read = */ gst_ffmpegdata_read,
8524- /*.url_write = */ gst_ffmpegdata_write,
8525- /*.url_seek = */ gst_ffmpegdata_seek,
8526- /*.url_close = */ gst_ffmpegdata_close,
8527-};
8528+ info = g_new0 (GstProtocolInfo, 1);
8529
8530+ info->set_streamheader = flags & GST_FFMPEG_URL_STREAMHEADER;
8531+ flags &= ~GST_FFMPEG_URL_STREAMHEADER;
8532
8533-/* specialized protocol for cross-thread pushing,
8534- * based on ffmpeg's pipe protocol */
8535+ /* we don't support R/W together */
8536+ if ((flags & AVIO_FLAG_WRITE) && (flags & AVIO_FLAG_READ)) {
8537+ GST_WARNING ("Only read-only or write-only are supported");
8538+ return -EINVAL;
8539+ }
8540
8541-static int
8542-gst_ffmpeg_pipe_open (URLContext * h, const char *filename, int flags)
8543-{
8544- GstFFMpegPipe *ffpipe;
8545+ /* make sure we're a pad and that we're of the right type */
8546+ g_return_val_if_fail (GST_IS_PAD (pad), -EINVAL);
8547
8548- GST_LOG ("Opening %s", filename);
8549+ if ((flags & AVIO_FLAG_READ))
8550+ g_return_val_if_fail (GST_PAD_IS_SINK (pad), -EINVAL);
8551+ if ((flags & AVIO_FLAG_WRITE))
8552+ g_return_val_if_fail (GST_PAD_IS_SRC (pad), -EINVAL);
8553
8554- /* we don't support W together */
8555- if (flags != URL_RDONLY) {
8556- GST_WARNING ("Only read-only is supported");
8557- return -EINVAL;
8558- }
8559+ info->eos = FALSE;
8560+ info->pad = pad;
8561+ info->offset = 0;
8562
8563- if (sscanf (&filename[10], "%p", &ffpipe) != 1) {
8564- GST_WARNING ("could not decode pipe info from %s", filename);
8565- return -EIO;
8566+ buffer = av_malloc (buffer_size);
8567+ if (buffer == NULL) {
8568+ GST_WARNING ("Failed to allocate buffer");
8569+ return -ENOMEM;
8570 }
8571
8572- /* sanity check */
8573- g_return_val_if_fail (GST_IS_ADAPTER (ffpipe->adapter), -EINVAL);
8574-
8575- h->priv_data = (void *) ffpipe;
8576- h->is_streamed = TRUE;
8577- h->max_packet_size = 0;
8578+ *context =
8579+ avio_alloc_context (buffer, buffer_size, flags, (void *) info,
8580+ gst_ffmpegdata_read, gst_ffmpegdata_write, gst_ffmpegdata_seek);
8581+ (*context)->seekable = AVIO_SEEKABLE_NORMAL;
8582+ if (!(flags & AVIO_FLAG_WRITE)) {
8583+ (*context)->buf_ptr = (*context)->buf_end;
8584+ (*context)->write_flag = 0;
8585+ }
8586
8587 return 0;
8588 }
8589
8590+/* specialized protocol for cross-thread pushing,
8591+ * based on ffmpeg's pipe protocol */
8592+
8593 static int
8594-gst_ffmpeg_pipe_read (URLContext * h, unsigned char *buf, int size)
8595+gst_ffmpeg_pipe_read (void *priv_data, unsigned char *buf, int size)
8596 {
8597 GstFFMpegPipe *ffpipe;
8598 const guint8 *data;
8599 guint available;
8600
8601- ffpipe = (GstFFMpegPipe *) h->priv_data;
8602+ ffpipe = (GstFFMpegPipe *) priv_data;
8603
8604 GST_LOG ("requested size %d", size);
8605
8606@@ -367,21 +314,38 @@
8607 return size;
8608 }
8609
8610-static int
8611-gst_ffmpeg_pipe_close (URLContext * h)
8612+int
8613+gst_ffmpeg_pipe_close (AVIOContext * h)
8614 {
8615 GST_LOG ("Closing pipe");
8616
8617- h->priv_data = NULL;
8618+ h->opaque = NULL;
8619+ av_freep (&h->buffer);
8620+ av_free (h);
8621
8622 return 0;
8623 }
8624
8625-URLProtocol gstpipe_protocol = {
8626- "gstpipe",
8627- gst_ffmpeg_pipe_open,
8628- gst_ffmpeg_pipe_read,
8629- NULL,
8630- NULL,
8631- gst_ffmpeg_pipe_close,
8632-};
8633+int
8634+gst_ffmpeg_pipe_open (GstFFMpegPipe * ffpipe, int flags, AVIOContext ** context)
8635+{
8636+ static const int buffer_size = 4096;
8637+ unsigned char *buffer = NULL;
8638+
8639+ /* sanity check */
8640+ g_return_val_if_fail (GST_IS_ADAPTER (ffpipe->adapter), -EINVAL);
8641+
8642+ buffer = av_malloc (buffer_size);
8643+ if (buffer == NULL) {
8644+ GST_WARNING ("Failed to allocate buffer");
8645+ return -ENOMEM;
8646+ }
8647+
8648+ *context =
8649+ avio_alloc_context (buffer, buffer_size, 0, (void *) ffpipe,
8650+ gst_ffmpeg_pipe_read, NULL, NULL);
8651+ (*context)->seekable = 0;
8652+ (*context)->buf_ptr = (*context)->buf_end;
8653+
8654+ return 0;
8655+}
8656diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c
8657--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c 2011-07-13 11:07:28.000000000 +0200
8658+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c 2014-08-08 15:34:04.007874626 +0200
8659@@ -25,6 +25,11 @@
8660 #ifdef __APPLE__
8661 #include <sys/sysctl.h>
8662 #endif
8663+#ifdef HAVE_FFMPEG_UNINSTALLED
8664+#include <avformat.h>
8665+#else
8666+#include <libavformat/avformat.h>
8667+#endif
8668
8669 G_CONST_RETURN gchar *
8670 gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
8671@@ -39,21 +44,21 @@
8672 }
8673
8674 gint
8675-av_smp_format_depth (enum SampleFormat smp_fmt)
8676+av_smp_format_depth (enum AVSampleFormat smp_fmt)
8677 {
8678 gint depth = -1;
8679 switch (smp_fmt) {
8680- case SAMPLE_FMT_U8:
8681+ case AV_SAMPLE_FMT_U8:
8682 depth = 1;
8683 break;
8684- case SAMPLE_FMT_S16:
8685+ case AV_SAMPLE_FMT_S16:
8686 depth = 2;
8687 break;
8688- case SAMPLE_FMT_S32:
8689- case SAMPLE_FMT_FLT:
8690+ case AV_SAMPLE_FMT_S32:
8691+ case AV_SAMPLE_FMT_FLT:
8692 depth = 4;
8693 break;
8694- case SAMPLE_FMT_DBL:
8695+ case AV_SAMPLE_FMT_DBL:
8696 depth = 8;
8697 break;
8698 default:
8699diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c.orig
8700--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.c.orig 1970-01-01 01:00:00.000000000 +0100
8701+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.c.orig 2011-07-13 11:07:28.000000000 +0200
8702@@ -0,0 +1,483 @@
8703+/* GStreamer
8704+ * Copyright (c) 2009 Edward Hervey <bilboed@bilboed.com>
8705+ *
8706+ * This library is free software; you can redistribute it and/or
8707+ * modify it under the terms of the GNU Library General Public
8708+ * License as published by the Free Software Foundation; either
8709+ * version 2 of the License, or (at your option) any later version.
8710+ *
8711+ * This library is distributed in the hope that it will be useful,
8712+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
8713+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8714+ * Library General Public License for more details.
8715+ *
8716+ * You should have received a copy of the GNU Library General Public
8717+ * License along with this library; if not, write to the
8718+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
8719+ * Boston, MA 02111-1307, USA.
8720+ */
8721+
8722+#ifdef HAVE_CONFIG_H
8723+#include "config.h"
8724+#endif
8725+#include "gstffmpegutils.h"
8726+#include <unistd.h>
8727+#ifdef __APPLE__
8728+#include <sys/sysctl.h>
8729+#endif
8730+
8731+G_CONST_RETURN gchar *
8732+gst_ffmpeg_get_codecid_longname (enum CodecID codec_id)
8733+{
8734+ AVCodec *codec;
8735+ /* Let's use what ffmpeg can provide us */
8736+
8737+ if ((codec = avcodec_find_decoder (codec_id)) ||
8738+ (codec = avcodec_find_encoder (codec_id)))
8739+ return codec->long_name;
8740+ return NULL;
8741+}
8742+
8743+gint
8744+av_smp_format_depth (enum SampleFormat smp_fmt)
8745+{
8746+ gint depth = -1;
8747+ switch (smp_fmt) {
8748+ case SAMPLE_FMT_U8:
8749+ depth = 1;
8750+ break;
8751+ case SAMPLE_FMT_S16:
8752+ depth = 2;
8753+ break;
8754+ case SAMPLE_FMT_S32:
8755+ case SAMPLE_FMT_FLT:
8756+ depth = 4;
8757+ break;
8758+ case SAMPLE_FMT_DBL:
8759+ depth = 8;
8760+ break;
8761+ default:
8762+ GST_ERROR ("UNHANDLED SAMPLE FORMAT !");
8763+ break;
8764+ }
8765+ return depth;
8766+}
8767+
8768+
8769+/*
8770+ * Fill in pointers to memory in a AVPicture, where
8771+ * everything is aligned by 4 (as required by X).
8772+ * This is mostly a copy from imgconvert.c with some
8773+ * small changes.
8774+ */
8775+
8776+#define FF_COLOR_RGB 0 /* RGB color space */
8777+#define FF_COLOR_GRAY 1 /* gray color space */
8778+#define FF_COLOR_YUV 2 /* YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */
8779+#define FF_COLOR_YUV_JPEG 3 /* YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */
8780+
8781+#define FF_PIXEL_PLANAR 0 /* each channel has one component in AVPicture */
8782+#define FF_PIXEL_PACKED 1 /* only one components containing all the channels */
8783+#define FF_PIXEL_PALETTE 2 /* one components containing indexes for a palette */
8784+
8785+typedef struct PixFmtInfo
8786+{
8787+ const char *name;
8788+ uint8_t nb_channels; /* number of channels (including alpha) */
8789+ uint8_t color_type; /* color type (see FF_COLOR_xxx constants) */
8790+ uint8_t pixel_type; /* pixel storage type (see FF_PIXEL_xxx constants) */
8791+ uint8_t is_alpha:1; /* true if alpha can be specified */
8792+ uint8_t x_chroma_shift; /* X chroma subsampling factor is 2 ^ shift */
8793+ uint8_t y_chroma_shift; /* Y chroma subsampling factor is 2 ^ shift */
8794+ uint8_t depth; /* bit depth of the color components */
8795+} PixFmtInfo;
8796+
8797+
8798+/* this table gives more information about formats */
8799+static PixFmtInfo pix_fmt_info[PIX_FMT_NB];
8800+void
8801+gst_ffmpeg_init_pix_fmt_info (void)
8802+{
8803+ /* YUV formats */
8804+ pix_fmt_info[PIX_FMT_YUV420P].name = g_strdup ("yuv420p");
8805+ pix_fmt_info[PIX_FMT_YUV420P].nb_channels = 3;
8806+ pix_fmt_info[PIX_FMT_YUV420P].color_type = FF_COLOR_YUV;
8807+ pix_fmt_info[PIX_FMT_YUV420P].pixel_type = FF_PIXEL_PLANAR;
8808+ pix_fmt_info[PIX_FMT_YUV420P].depth = 8,
8809+ pix_fmt_info[PIX_FMT_YUV420P].x_chroma_shift = 1,
8810+ pix_fmt_info[PIX_FMT_YUV420P].y_chroma_shift = 1;
8811+
8812+ pix_fmt_info[PIX_FMT_YUV422P].name = g_strdup ("yuv422p");
8813+ pix_fmt_info[PIX_FMT_YUV422P].nb_channels = 3;
8814+ pix_fmt_info[PIX_FMT_YUV422P].color_type = FF_COLOR_YUV;
8815+ pix_fmt_info[PIX_FMT_YUV422P].pixel_type = FF_PIXEL_PLANAR;
8816+ pix_fmt_info[PIX_FMT_YUV422P].depth = 8;
8817+ pix_fmt_info[PIX_FMT_YUV422P].x_chroma_shift = 1;
8818+ pix_fmt_info[PIX_FMT_YUV422P].y_chroma_shift = 0;
8819+
8820+ pix_fmt_info[PIX_FMT_YUV444P].name = g_strdup ("yuv444p");
8821+ pix_fmt_info[PIX_FMT_YUV444P].nb_channels = 3;
8822+ pix_fmt_info[PIX_FMT_YUV444P].color_type = FF_COLOR_YUV;
8823+ pix_fmt_info[PIX_FMT_YUV444P].pixel_type = FF_PIXEL_PLANAR;
8824+ pix_fmt_info[PIX_FMT_YUV444P].depth = 8;
8825+ pix_fmt_info[PIX_FMT_YUV444P].x_chroma_shift = 0;
8826+ pix_fmt_info[PIX_FMT_YUV444P].y_chroma_shift = 0;
8827+
8828+ pix_fmt_info[PIX_FMT_YUYV422].name = g_strdup ("yuv422");
8829+ pix_fmt_info[PIX_FMT_YUYV422].nb_channels = 1;
8830+ pix_fmt_info[PIX_FMT_YUYV422].color_type = FF_COLOR_YUV;
8831+ pix_fmt_info[PIX_FMT_YUYV422].pixel_type = FF_PIXEL_PACKED;
8832+ pix_fmt_info[PIX_FMT_YUYV422].depth = 8;
8833+ pix_fmt_info[PIX_FMT_YUYV422].x_chroma_shift = 1;
8834+ pix_fmt_info[PIX_FMT_YUYV422].y_chroma_shift = 0;
8835+
8836+ pix_fmt_info[PIX_FMT_YUV410P].name = g_strdup ("yuv410p");
8837+ pix_fmt_info[PIX_FMT_YUV410P].nb_channels = 3;
8838+ pix_fmt_info[PIX_FMT_YUV410P].color_type = FF_COLOR_YUV;
8839+ pix_fmt_info[PIX_FMT_YUV410P].pixel_type = FF_PIXEL_PLANAR;
8840+ pix_fmt_info[PIX_FMT_YUV410P].depth = 8;
8841+ pix_fmt_info[PIX_FMT_YUV410P].x_chroma_shift = 2;
8842+ pix_fmt_info[PIX_FMT_YUV410P].y_chroma_shift = 2;
8843+
8844+ pix_fmt_info[PIX_FMT_YUV411P].name = g_strdup ("yuv411p");
8845+ pix_fmt_info[PIX_FMT_YUV411P].nb_channels = 3;
8846+ pix_fmt_info[PIX_FMT_YUV411P].color_type = FF_COLOR_YUV;
8847+ pix_fmt_info[PIX_FMT_YUV411P].pixel_type = FF_PIXEL_PLANAR;
8848+ pix_fmt_info[PIX_FMT_YUV411P].depth = 8;
8849+ pix_fmt_info[PIX_FMT_YUV411P].x_chroma_shift = 2;
8850+ pix_fmt_info[PIX_FMT_YUV411P].y_chroma_shift = 0;
8851+
8852+ /* JPEG YUV */
8853+ pix_fmt_info[PIX_FMT_YUVJ420P].name = g_strdup ("yuvj420p");
8854+ pix_fmt_info[PIX_FMT_YUVJ420P].nb_channels = 3;
8855+ pix_fmt_info[PIX_FMT_YUVJ420P].color_type = FF_COLOR_YUV_JPEG;
8856+ pix_fmt_info[PIX_FMT_YUVJ420P].pixel_type = FF_PIXEL_PLANAR;
8857+ pix_fmt_info[PIX_FMT_YUVJ420P].depth = 8;
8858+ pix_fmt_info[PIX_FMT_YUVJ420P].x_chroma_shift = 1;
8859+ pix_fmt_info[PIX_FMT_YUVJ420P].y_chroma_shift = 1;
8860+
8861+ pix_fmt_info[PIX_FMT_YUVJ422P].name = g_strdup ("yuvj422p");
8862+ pix_fmt_info[PIX_FMT_YUVJ422P].nb_channels = 3;
8863+ pix_fmt_info[PIX_FMT_YUVJ422P].color_type = FF_COLOR_YUV_JPEG;
8864+ pix_fmt_info[PIX_FMT_YUVJ422P].pixel_type = FF_PIXEL_PLANAR;
8865+ pix_fmt_info[PIX_FMT_YUVJ422P].depth = 8;
8866+ pix_fmt_info[PIX_FMT_YUVJ422P].x_chroma_shift = 1;
8867+ pix_fmt_info[PIX_FMT_YUVJ422P].y_chroma_shift = 0;
8868+
8869+ pix_fmt_info[PIX_FMT_YUVJ444P].name = g_strdup ("yuvj444p");
8870+ pix_fmt_info[PIX_FMT_YUVJ444P].nb_channels = 3;
8871+ pix_fmt_info[PIX_FMT_YUVJ444P].color_type = FF_COLOR_YUV_JPEG;
8872+ pix_fmt_info[PIX_FMT_YUVJ444P].pixel_type = FF_PIXEL_PLANAR;
8873+ pix_fmt_info[PIX_FMT_YUVJ444P].depth = 8;
8874+ pix_fmt_info[PIX_FMT_YUVJ444P].x_chroma_shift = 0;
8875+ pix_fmt_info[PIX_FMT_YUVJ444P].y_chroma_shift = 0;
8876+
8877+ /* RGB formats */
8878+ pix_fmt_info[PIX_FMT_RGB24].name = g_strdup ("rgb24");
8879+ pix_fmt_info[PIX_FMT_RGB24].nb_channels = 3;
8880+ pix_fmt_info[PIX_FMT_RGB24].color_type = FF_COLOR_RGB;
8881+ pix_fmt_info[PIX_FMT_RGB24].pixel_type = FF_PIXEL_PACKED;
8882+ pix_fmt_info[PIX_FMT_RGB24].depth = 8;
8883+ pix_fmt_info[PIX_FMT_RGB24].x_chroma_shift = 0;
8884+ pix_fmt_info[PIX_FMT_RGB24].y_chroma_shift = 0;
8885+
8886+ pix_fmt_info[PIX_FMT_BGR24].name = g_strdup ("bgr24");
8887+ pix_fmt_info[PIX_FMT_BGR24].nb_channels = 3;
8888+ pix_fmt_info[PIX_FMT_BGR24].color_type = FF_COLOR_RGB;
8889+ pix_fmt_info[PIX_FMT_BGR24].pixel_type = FF_PIXEL_PACKED;
8890+ pix_fmt_info[PIX_FMT_BGR24].depth = 8;
8891+ pix_fmt_info[PIX_FMT_BGR24].x_chroma_shift = 0;
8892+ pix_fmt_info[PIX_FMT_BGR24].y_chroma_shift = 0;
8893+
8894+ pix_fmt_info[PIX_FMT_RGB32].name = g_strdup ("rgba32");
8895+ pix_fmt_info[PIX_FMT_RGB32].nb_channels = 4;
8896+ pix_fmt_info[PIX_FMT_RGB32].is_alpha = 1;
8897+ pix_fmt_info[PIX_FMT_RGB32].color_type = FF_COLOR_RGB;
8898+ pix_fmt_info[PIX_FMT_RGB32].pixel_type = FF_PIXEL_PACKED;
8899+ pix_fmt_info[PIX_FMT_RGB32].depth = 8;
8900+ pix_fmt_info[PIX_FMT_RGB32].x_chroma_shift = 0;
8901+ pix_fmt_info[PIX_FMT_RGB32].y_chroma_shift = 0;
8902+
8903+ pix_fmt_info[PIX_FMT_RGB565].name = g_strdup ("rgb565");
8904+ pix_fmt_info[PIX_FMT_RGB565].nb_channels = 3;
8905+ pix_fmt_info[PIX_FMT_RGB565].color_type = FF_COLOR_RGB;
8906+ pix_fmt_info[PIX_FMT_RGB565].pixel_type = FF_PIXEL_PACKED;
8907+ pix_fmt_info[PIX_FMT_RGB565].depth = 5;
8908+ pix_fmt_info[PIX_FMT_RGB565].x_chroma_shift = 0;
8909+ pix_fmt_info[PIX_FMT_RGB565].y_chroma_shift = 0;
8910+
8911+ pix_fmt_info[PIX_FMT_RGB555].name = g_strdup ("rgb555");
8912+ pix_fmt_info[PIX_FMT_RGB555].nb_channels = 4;
8913+ pix_fmt_info[PIX_FMT_RGB555].is_alpha = 1;
8914+ pix_fmt_info[PIX_FMT_RGB555].color_type = FF_COLOR_RGB;
8915+ pix_fmt_info[PIX_FMT_RGB555].pixel_type = FF_PIXEL_PACKED;
8916+ pix_fmt_info[PIX_FMT_RGB555].depth = 5;
8917+ pix_fmt_info[PIX_FMT_RGB555].x_chroma_shift = 0;
8918+ pix_fmt_info[PIX_FMT_RGB555].y_chroma_shift = 0;
8919+
8920+ /* gray / mono formats */
8921+ pix_fmt_info[PIX_FMT_GRAY8].name = g_strdup ("gray");
8922+ pix_fmt_info[PIX_FMT_GRAY8].nb_channels = 1;
8923+ pix_fmt_info[PIX_FMT_GRAY8].color_type = FF_COLOR_GRAY;
8924+ pix_fmt_info[PIX_FMT_GRAY8].pixel_type = FF_PIXEL_PLANAR;
8925+ pix_fmt_info[PIX_FMT_GRAY8].depth = 8;
8926+
8927+ pix_fmt_info[PIX_FMT_MONOWHITE].name = g_strdup ("monow");
8928+ pix_fmt_info[PIX_FMT_MONOWHITE].nb_channels = 1;
8929+ pix_fmt_info[PIX_FMT_MONOWHITE].color_type = FF_COLOR_GRAY;
8930+ pix_fmt_info[PIX_FMT_MONOWHITE].pixel_type = FF_PIXEL_PLANAR;
8931+ pix_fmt_info[PIX_FMT_MONOWHITE].depth = 1;
8932+
8933+ pix_fmt_info[PIX_FMT_MONOBLACK].name = g_strdup ("monob");
8934+ pix_fmt_info[PIX_FMT_MONOBLACK].nb_channels = 1;
8935+ pix_fmt_info[PIX_FMT_MONOBLACK].color_type = FF_COLOR_GRAY;
8936+ pix_fmt_info[PIX_FMT_MONOBLACK].pixel_type = FF_PIXEL_PLANAR;
8937+ pix_fmt_info[PIX_FMT_MONOBLACK].depth = 1;
8938+
8939+ /* paletted formats */
8940+ pix_fmt_info[PIX_FMT_PAL8].name = g_strdup ("pal8");
8941+ pix_fmt_info[PIX_FMT_PAL8].nb_channels = 4;
8942+ pix_fmt_info[PIX_FMT_PAL8].is_alpha = 1;
8943+ pix_fmt_info[PIX_FMT_PAL8].color_type = FF_COLOR_RGB;
8944+ pix_fmt_info[PIX_FMT_PAL8].pixel_type = FF_PIXEL_PALETTE;
8945+ pix_fmt_info[PIX_FMT_PAL8].depth = 8;
8946+
8947+ pix_fmt_info[PIX_FMT_YUVA420P].name = g_strdup ("yuva420p");
8948+ pix_fmt_info[PIX_FMT_YUVA420P].nb_channels = 4;
8949+ pix_fmt_info[PIX_FMT_YUVA420P].is_alpha = 1;
8950+ pix_fmt_info[PIX_FMT_YUVA420P].color_type = FF_COLOR_YUV;
8951+ pix_fmt_info[PIX_FMT_YUVA420P].pixel_type = FF_PIXEL_PLANAR;
8952+ pix_fmt_info[PIX_FMT_YUVA420P].depth = 8,
8953+ pix_fmt_info[PIX_FMT_YUVA420P].x_chroma_shift = 1,
8954+ pix_fmt_info[PIX_FMT_YUVA420P].y_chroma_shift = 1;
8955+};
8956+
8957+int
8958+gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height)
8959+{
8960+ AVPicture dummy_pict;
8961+
8962+ return gst_ffmpeg_avpicture_fill (&dummy_pict, NULL, pix_fmt, width, height);
8963+}
8964+
8965+#define GEN_MASK(x) ((1<<(x))-1)
8966+#define ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) & ~GEN_MASK(x))
8967+#define ROUND_UP_2(x) ROUND_UP_X (x, 1)
8968+#define ROUND_UP_4(x) ROUND_UP_X (x, 2)
8969+#define ROUND_UP_8(x) ROUND_UP_X (x, 3)
8970+#define DIV_ROUND_UP_X(v,x) (((v) + GEN_MASK(x)) >> (x))
8971+
8972+int
8973+gst_ffmpeg_avpicture_fill (AVPicture * picture,
8974+ uint8_t * ptr, enum PixelFormat pix_fmt, int width, int height)
8975+{
8976+ int size, w2, h2, size2;
8977+ int stride, stride2;
8978+ PixFmtInfo *pinfo;
8979+
8980+ pinfo = &pix_fmt_info[pix_fmt];
8981+
8982+ switch (pix_fmt) {
8983+ case PIX_FMT_YUV420P:
8984+ case PIX_FMT_YUV422P:
8985+ case PIX_FMT_YUV444P:
8986+ case PIX_FMT_YUV410P:
8987+ case PIX_FMT_YUV411P:
8988+ case PIX_FMT_YUVJ420P:
8989+ case PIX_FMT_YUVJ422P:
8990+ case PIX_FMT_YUVJ444P:
8991+ stride = ROUND_UP_4 (width);
8992+ h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
8993+ size = stride * h2;
8994+ w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
8995+ stride2 = ROUND_UP_4 (w2);
8996+ h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift);
8997+ size2 = stride2 * h2;
8998+ picture->data[0] = ptr;
8999+ picture->data[1] = picture->data[0] + size;
9000+ picture->data[2] = picture->data[1] + size2;
9001+ picture->data[3] = NULL;
9002+ picture->linesize[0] = stride;
9003+ picture->linesize[1] = stride2;
9004+ picture->linesize[2] = stride2;
9005+ picture->linesize[3] = 0;
9006+ GST_DEBUG ("planes %d %d %d", 0, size, size + size2);
9007+ GST_DEBUG ("strides %d %d %d", stride, stride2, stride2);
9008+ return size + 2 * size2;
9009+ case PIX_FMT_YUVA420P:
9010+ stride = ROUND_UP_4 (width);
9011+ h2 = ROUND_UP_X (height, pinfo->y_chroma_shift);
9012+ size = stride * h2;
9013+ w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift);
9014+ stride2 = ROUND_UP_4 (w2);
9015+ h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift);
9016+ size2 = stride2 * h2;
9017+ picture->data[0] = ptr;
9018+ picture->data[1] = picture->data[0] + size;
9019+ picture->data[2] = picture->data[1] + size2;
9020+ picture->data[3] = picture->data[2] + size2;
9021+ picture->linesize[0] = stride;
9022+ picture->linesize[1] = stride2;
9023+ picture->linesize[2] = stride2;
9024+ picture->linesize[3] = stride;
9025+ GST_DEBUG ("planes %d %d %d %d", 0, size, size + size2, size + 2 * size2);
9026+ GST_DEBUG ("strides %d %d %d %d", stride, stride2, stride2, stride);
9027+ return 2 * size + 2 * size2;
9028+ case PIX_FMT_RGB24:
9029+ case PIX_FMT_BGR24:
9030+ stride = ROUND_UP_4 (width * 3);
9031+ size = stride * height;
9032+ picture->data[0] = ptr;
9033+ picture->data[1] = NULL;
9034+ picture->data[2] = NULL;
9035+ picture->data[3] = NULL;
9036+ picture->linesize[0] = stride;
9037+ picture->linesize[1] = 0;
9038+ picture->linesize[2] = 0;
9039+ picture->linesize[3] = 0;
9040+ return size;
9041+ /*case PIX_FMT_AYUV4444:
9042+ case PIX_FMT_BGR32:
9043+ case PIX_FMT_BGRA32:
9044+ case PIX_FMT_RGB32: */
9045+ case PIX_FMT_RGB32:
9046+ stride = width * 4;
9047+ size = stride * height;
9048+ picture->data[0] = ptr;
9049+ picture->data[1] = NULL;
9050+ picture->data[2] = NULL;
9051+ picture->data[3] = NULL;
9052+ picture->linesize[0] = stride;
9053+ picture->linesize[1] = 0;
9054+ picture->linesize[2] = 0;
9055+ picture->linesize[3] = 0;
9056+ return size;
9057+ case PIX_FMT_RGB555:
9058+ case PIX_FMT_RGB565:
9059+ case PIX_FMT_YUYV422:
9060+ case PIX_FMT_UYVY422:
9061+ stride = ROUND_UP_4 (width * 2);
9062+ size = stride * height;
9063+ picture->data[0] = ptr;
9064+ picture->data[1] = NULL;
9065+ picture->data[2] = NULL;
9066+ picture->data[3] = NULL;
9067+ picture->linesize[0] = stride;
9068+ picture->linesize[1] = 0;
9069+ picture->linesize[2] = 0;
9070+ picture->linesize[3] = 0;
9071+ return size;
9072+ case PIX_FMT_UYYVYY411:
9073+ /* FIXME, probably not the right stride */
9074+ stride = ROUND_UP_4 (width);
9075+ size = stride * height;
9076+ picture->data[0] = ptr;
9077+ picture->data[1] = NULL;
9078+ picture->data[2] = NULL;
9079+ picture->data[3] = NULL;
9080+ picture->linesize[0] = width + width / 2;
9081+ picture->linesize[1] = 0;
9082+ picture->linesize[2] = 0;
9083+ picture->linesize[3] = 0;
9084+ return size + size / 2;
9085+ case PIX_FMT_GRAY8:
9086+ stride = ROUND_UP_4 (width);
9087+ size = stride * height;
9088+ picture->data[0] = ptr;
9089+ picture->data[1] = NULL;
9090+ picture->data[2] = NULL;
9091+ picture->data[3] = NULL;
9092+ picture->linesize[0] = stride;
9093+ picture->linesize[1] = 0;
9094+ picture->linesize[2] = 0;
9095+ picture->linesize[3] = 0;
9096+ return size;
9097+ case PIX_FMT_MONOWHITE:
9098+ case PIX_FMT_MONOBLACK:
9099+ stride = ROUND_UP_4 ((width + 7) >> 3);
9100+ size = stride * height;
9101+ picture->data[0] = ptr;
9102+ picture->data[1] = NULL;
9103+ picture->data[2] = NULL;
9104+ picture->data[3] = NULL;
9105+ picture->linesize[0] = stride;
9106+ picture->linesize[1] = 0;
9107+ picture->linesize[2] = 0;
9108+ picture->linesize[3] = 0;
9109+ return size;
9110+ case PIX_FMT_PAL8:
9111+ /* already forced to be with stride, so same result as other function */
9112+ stride = ROUND_UP_4 (width);
9113+ size = stride * height;
9114+ picture->data[0] = ptr;
9115+ picture->data[1] = ptr + size; /* palette is stored here as 256 32 bit words */
9116+ picture->data[2] = NULL;
9117+ picture->data[3] = NULL;
9118+ picture->linesize[0] = stride;
9119+ picture->linesize[1] = 4;
9120+ picture->linesize[2] = 0;
9121+ picture->linesize[3] = 0;
9122+ return size + 256 * 4;
9123+ default:
9124+ picture->data[0] = NULL;
9125+ picture->data[1] = NULL;
9126+ picture->data[2] = NULL;
9127+ picture->data[3] = NULL;
9128+ return -1;
9129+ }
9130+
9131+ return 0;
9132+}
9133+
9134+/* Create a GstBuffer of the requested size and caps.
9135+ * The memory will be allocated by ffmpeg, making sure it's properly aligned
9136+ * for any processing. */
9137+
9138+GstBuffer *
9139+new_aligned_buffer (gint size, GstCaps * caps)
9140+{
9141+ GstBuffer *buf;
9142+
9143+ buf = gst_buffer_new ();
9144+ GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = av_malloc (size);
9145+ GST_BUFFER_SIZE (buf) = size;
9146+ GST_BUFFER_FREE_FUNC (buf) = av_free;
9147+ if (caps)
9148+ gst_buffer_set_caps (buf, caps);
9149+
9150+ return buf;
9151+}
9152+
9153+int
9154+gst_ffmpeg_auto_max_threads (void)
9155+{
9156+ static gsize n_threads = 0;
9157+ if (g_once_init_enter (&n_threads)) {
9158+ int n = 1;
9159+#if defined(_WIN32)
9160+ {
9161+ const char *s = getenv ("NUMBER_OF_PROCESSORS");
9162+ if (s) {
9163+ n = atoi (s);
9164+ }
9165+ }
9166+#elif defined(__APPLE__)
9167+ {
9168+ int mib[] = { CTL_HW, HW_NCPU };
9169+ size_t dataSize = sizeof (int);
9170+
9171+ if (sysctl (mib, 2, &n_threads, &dataSize, NULL, 0)) {
9172+ n = 1;
9173+ }
9174+ }
9175+#else
9176+ n = sysconf (_SC_NPROCESSORS_CONF);
9177+#endif
9178+ if (n < 1)
9179+ n = 1;
9180+
9181+ g_once_init_leave (&n_threads, n);
9182+ }
9183+
9184+ return (int) (n_threads);
9185+}
9186diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h
9187--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h 2011-11-02 14:04:05.000000000 +0100
9188+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h 2014-08-08 15:34:04.007874626 +0200
9189@@ -23,6 +23,7 @@
9190 #ifdef HAVE_FFMPEG_UNINSTALLED
9191 #include <avcodec.h>
9192 #else
9193+#include <libavutil/mathematics.h>
9194 #include <libavcodec/avcodec.h>
9195 #endif
9196 #include <gst/gst.h>
9197@@ -87,7 +88,7 @@
9198 gst_ffmpeg_get_codecid_longname (enum CodecID codec_id);
9199
9200 gint
9201-av_smp_format_depth(enum SampleFormat smp_fmt);
9202+av_smp_format_depth(enum AVSampleFormat smp_fmt);
9203
9204 GstBuffer *
9205 new_aligned_buffer (gint size, GstCaps * caps);
9206diff -uNr gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h.orig gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h.orig
9207--- gst-ffmpeg-0.10.13.orig/ext/ffmpeg/gstffmpegutils.h.orig 1970-01-01 01:00:00.000000000 +0100
9208+++ gst-ffmpeg-0.10.13/ext/ffmpeg/gstffmpegutils.h.orig 2014-08-08 15:26:38.473858652 +0200
9209@@ -0,0 +1,95 @@
9210+/* GStreamer
9211+ * Copyright (C) <2009> Edward Hervey <bilboed@bilboed.com>
9212+ *
9213+ * This library is free software; you can redistribute it and/or
9214+ * modify it under the terms of the GNU Library General Public
9215+ * License as published by the Free Software Foundation; either
9216+ * version 2 of the License, or (at your option) any later version.
9217+ *
9218+ * This library is distributed in the hope that it will be useful,
9219+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
9220+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9221+ * Library General Public License for more details.
9222+ *
9223+ * You should have received a copy of the GNU Library General Public
9224+ * License along with this library; if not, write to the
9225+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
9226+ * Boston, MA 02111-1307, USA.
9227+ */
9228+
9229+#ifndef __GST_FFMPEG_UTILS_H__
9230+#define __GST_FFMPEG_UTILS_H__
9231+
9232+#ifdef HAVE_FFMPEG_UNINSTALLED
9233+#include <avcodec.h>
9234+#else
9235+#include <libavcodec/avcodec.h>
9236+#endif
9237+#include <gst/gst.h>
9238+
9239+/*
9240+ *Get the size of an picture
9241+ */
9242+int
9243+gst_ffmpeg_avpicture_get_size (int pix_fmt, int width, int height);
9244+
9245+/*
9246+ * Fill in pointers in an AVPicture, aligned by 4 (required by X).
9247+ */
9248+
9249+int
9250+gst_ffmpeg_avpicture_fill (AVPicture * picture,
9251+ uint8_t * ptr,
9252+ enum PixelFormat pix_fmt,
9253+ int width,
9254+ int height);
9255+
9256+/*
9257+ * Convert from/to a GStreamer <-> FFMpeg timestamp.
9258+ */
9259+static inline guint64
9260+gst_ffmpeg_time_ff_to_gst (gint64 pts, AVRational base)
9261+{
9262+ guint64 out;
9263+
9264+ if (pts == AV_NOPTS_VALUE){
9265+ out = GST_CLOCK_TIME_NONE;
9266+ } else {
9267+ AVRational bq = { 1, GST_SECOND };
9268+ out = av_rescale_q (pts, base, bq);
9269+ }
9270+
9271+ return out;
9272+}
9273+
9274+static inline gint64
9275+gst_ffmpeg_time_gst_to_ff (guint64 time, AVRational base)
9276+{
9277+ gint64 out;
9278+
9279+ if (!GST_CLOCK_TIME_IS_VALID (time) || base.num == 0) {
9280+ out = AV_NOPTS_VALUE;
9281+ } else {
9282+ AVRational bq = { 1, GST_SECOND };
9283+ out = av_rescale_q (time, bq, base);
9284+ }
9285+
9286+ return out;
9287+}
9288+
9289+void
9290+gst_ffmpeg_init_pix_fmt_info(void);
9291+
9292+int
9293+gst_ffmpeg_auto_max_threads(void);
9294+
9295+G_CONST_RETURN gchar *
9296+gst_ffmpeg_get_codecid_longname (enum CodecID codec_id);
9297+
9298+gint
9299+av_smp_format_depth(enum AVSampleFormat smp_fmt);
9300+
9301+GstBuffer *
9302+new_aligned_buffer (gint size, GstCaps * caps);
9303+
9304+#endif /* __GST_FFMPEG_UTILS_H__ */
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch
new file mode 100644
index 0000000000..eba4988031
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e500mc.patch
@@ -0,0 +1,21 @@
1diff --git a/gst-libs/ext/libav/configure b/gst-libs/ext/libav/configure
2index 8473069..4f74952 100755
3--- a/gst-libs/ext/libav/configure
4+++ b/gst-libs/ext/libav/configure
5Fix gst-ffmpeg build issues for libav on e500mc (fsl-p4080)
6
7Upstream-Status: Backport
8
9Signed-off-by: Yao Zhao <yao.zhao@windriver.com>
10
11@@ -2210,6 +2210,10 @@ elif enabled ppc; then
12 cpuflags="-mcpu=cell"
13 enable ldbrx
14 ;;
15+ e500mc)
16+ cpuflags="-mcpu=e500mc"
17+ disable altivec
18+ ;;
19 e500v2)
20 cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
21 disable altivec
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch
new file mode 100644
index 0000000000..d9ea2c29e0
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/libav_e5500.patch
@@ -0,0 +1,19 @@
1libav: Add configs for ppc e5500
2
3Upstream-Status: Pending
4
5Signed-off-by: Jesse Zhang <sen.zhang@windriver.com>
6
7--- gst-ffmpeg-0.10.13/gst-libs/ext/libav/configure 2013-06-20 05:18:36.073104964 -0400
8+++ gst-ffmpeg-0.10.13/gst-libs/ext/libav/configure 2013-06-20 05:18:38.269104150 -0400
9@@ -2222,6 +2222,10 @@
10 cpuflags="-mcpu=8540 -mhard-float"
11 disable altivec
12 ;;
13+ e5500)
14+ cpuflags="-mcpu=e5500 -mhard-float"
15+ disable altivec
16+ ;;
17 esac
18
19 elif enabled x86; then
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff
new file mode 100644
index 0000000000..5f08afe59a
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg-0.10.13/lower-rank.diff
@@ -0,0 +1,16 @@
1Lower the rank of ffmpeg plugin so codecs that hook into accelerated pieces (e.g. dsp or hw engines) can get picked over this
2Derived from OE by Dongxiao Xu <dongxiao.xu@intel.com>
3
4Upstream-Status: Inappropriate [embedded specific]
5
6--- /tmp/gstffmpegdec.c 2009-03-05 09:31:15.000000000 +0100
7+++ gst-ffmpeg-0.10.6/ext/ffmpeg/gstffmpegdec.c 2009-03-05 09:33:09.000000000 +0100
8@@ -2588,7 +2588,7 @@
9 case CODEC_ID_MSMPEG4V3:
10 case CODEC_ID_H264:
11 case CODEC_ID_COOK:
12- rank = GST_RANK_PRIMARY;
13+ rank = GST_RANK_SECONDARY;
14 break;
15 case CODEC_ID_DVVIDEO:
16 /* we have a good dv decoder, fast on both ppc as well as x86. they say
diff --git a/meta/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb b/meta/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb
new file mode 100644
index 0000000000..30e5deb1f9
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-ffmpeg_0.10.13.bb
@@ -0,0 +1,92 @@
1SUMMARY = "FFmpeg-based GStreamer plug-in"
2SECTION = "multimedia"
3LICENSE = "GPLv2+ & LGPLv2+ & ( (GPLv2+ & LGPLv2.1+) | (GPLv3+ & LGPLv3+) )"
4LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
5 file://ext/libpostproc/gstpostproc.c;beginline=1;endline=18;md5=5896e445e41681324381f5869ee33d38 \
6 file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
7 file://ext/ffmpeg/gstffmpeg.h;beginline=1;endline=18;md5=ff65467b0c53cdfa98d0684c1bc240a9 \
8 file://gst-libs/ext/libav/LICENSE;md5=abc3b8cb02856aa7823bbbd162d16232 \
9 file://gst-libs/ext/libav/COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
10 file://gst-libs/ext/libav/COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \
11 file://gst-libs/ext/libav/COPYING.LGPLv2.1;md5=e344c8fa836c3a41c4cbd79d7bd3a379 \
12 file://gst-libs/ext/libav/COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02"
13LICENSE_FLAGS = "commercial"
14HOMEPAGE = "http://www.gstreamer.net/"
15DEPENDS = "gstreamer gst-plugins-base zlib bzip2 yasm-native"
16
17inherit autotools pkgconfig
18
19SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2 \
20 file://lower-rank.diff \
21 file://configure-fix.patch \
22 file://h264_qpel_mmx.patch \
23 file://libav_e500mc.patch \
24 file://libav_e5500.patch \
25 file://gst-ffmpeg-CVE-2013-3674.patch \
26 file://0001-avformat-mpegtsenc-Check-data-array-size-in-mpegts_w.patch \
27 file://0001-vqavideo-check-chunk-sizes-before-reading-chunks.patch \
28 file://0001-avcodec-msrle-use-av_image_get_linesize-to-calculate.patch \
29 file://0001-huffyuvdec-Skip-len-0-cases.patch \
30 file://0001-huffyuvdec-Check-init_vlc-return-codes.patch \
31 file://0001-alsdec-check-block-length.patch \
32 file://0001-pgssubdec-check-RLE-size-before-copying.-Fix-out-of-.patch \
33 file://0001-atrac3dec-Check-coding-mode-against-channels.patch \
34 file://0001-eamad-fix-out-of-array-accesses.patch \
35 file://0001-mjpegdec-check-SE.patch \
36 file://0001-alac-fix-nb_samples-order-case.patch \
37 file://0001-h264-correct-ref-count-check-and-limit-fix-out-of-ar.patch \
38 file://0001-roqvideodec-check-dimensions-validity.patch \
39 file://0001-aacdec-check-channel-count.patch \
40 file://0001-pngdec-filter-dont-access-out-of-array-elements-at-t.patch \
41 file://0001-error_concealment-Check-that-the-picture-is-not-in-a.patch \
42 file://0001-vp3-fix-oob-read-for-negative-tokens-and-memleaks-on.patch \
43 file://0001-vp3-Copy-all-3-frames-for-thread-updates.patch \
44 file://0001-h264_sei-Fix-infinite-loop.patch \
45 file://0001-avcodec-parser-reset-indexes-on-realloc-failure.patch \
46 file://0001-avcodec-rpza-Perform-pointer-advance-and-checks-befo.patch \
47 file://gst-ffmpeg-CVE-2013-0855.patch \
48 file://0001-qdm2dec-fix-buffer-overflow.patch \
49 file://0001-huffyuvdec-check-width-more-completely-avoid-out-of-.patch \
50 file://0001-smackerdec-Check-that-the-last-indexes-are-within-th.patch \
51 file://0001-avcodec-dsputil-fix-signedness-in-sizeof-comparissio.patch \
52 file://0001-error-concealment-initialize-block-index.patch \
53 file://0001-qdm2-check-array-index-before-use-fix-out-of-array-a.patch \
54 file://0001-lavf-compute-probe-buffer-size-more-reliably.patch \
55 file://0001-ffserver-set-oformat.patch \
56 file://0001-h264-set-parameters-from-SPS-whenever-it-changes.patch \
57 file://0001-h264-skip-error-concealment-when-SPS-and-slices-are-.patch \
58 file://0001-avcodec-smc-fix-off-by-1-error.patch \
59 file://0002-avcodec-mjpegdec-check-bits-per-pixel-for-changes-si.patch \
60 ${@bb.utils.contains('PACKAGECONFIG', 'libav9', 'file://libav-9.patch', '', d)} \
61"
62
63SRC_URI[md5sum] = "7f5beacaf1312db2db30a026b36888c4"
64SRC_URI[sha256sum] = "76fca05b08e00134e3cb92fa347507f42cbd48ddb08ed3343a912def187fbb62"
65
66PR = "r8"
67
68GSTREAMER_DEBUG ?= "--disable-debug"
69
70FFMPEG_EXTRA_CONFIGURE = "--with-ffmpeg-extra-configure"
71# pass --cpu for powerpc. get cpu name by stripping "ppc" or "ppc64"
72# from DEFAULTTUNE
73FFMPEG_CPU_powerpc = "--cpu=${@d.getVar('DEFAULTTUNE')[3:]}"
74FFMPEG_CPU_powerpc64 = "--cpu=${@d.getVar('DEFAULTTUNE')[5:]}"
75FFMPEG_EXTRA_CONFIGURE_COMMON_ARG = "--target-os=linux ${FFMPEG_CPU} \
76 --cc='${CC}' --as='${CC}' --ld='${CC}' --nm='${NM}' --ar='${AR}' \
77 --ranlib='${RANLIB}' \
78 ${GSTREAMER_DEBUG}"
79FFMPEG_EXTRA_CONFIGURE_COMMON = \
80'${FFMPEG_EXTRA_CONFIGURE}="${FFMPEG_EXTRA_CONFIGURE_COMMON_ARG}"'
81
82EXTRA_OECONF = "${FFMPEG_EXTRA_CONFIGURE_COMMON}"
83
84PACKAGECONFIG ??= "external-libav"
85PACKAGECONFIG[external-libav] = "--with-system-ffmpeg,,libav"
86PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
87PACKAGECONFIG[libav9] = ",,,"
88
89FILES_${PN} += "${libdir}/gstreamer-0.10/*.so"
90FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug"
91FILES_${PN}-dev += "${libdir}/gstreamer-0.10/*.la"
92FILES_${PN}-staticdev += "${libdir}/gstreamer-0.10/*.a"
diff --git a/meta/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.19.bb b/meta/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.19.bb
new file mode 100644
index 0000000000..9e68288844
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-fluendo-mp3_0.10.19.bb
@@ -0,0 +1,14 @@
1require gst-fluendo.inc
2
3SUMMARY = "Fluendo closed-format mp3 GStreamer plug-in"
4LICENSE = "MIT"
5LIC_FILES_CHKSUM = "file://COPYING;md5=259a43dd1c9854b71fc396f74699f4d2"
6LICENSE_FLAGS = "commercial"
7
8GSTREAMER_DEBUG ?= "--disable-debug"
9EXTRA_OECONF += "${GSTREAMER_DEBUG}"
10
11acpaths = "-I ${S}/common/m4 -I ${S}/m4"
12
13SRC_URI[md5sum] = "5d95a9a216dd15bc5c00c9414061115c"
14SRC_URI[sha256sum] = "30c79d24d8926f75dd4ef0f572942ce155ad541734b36a95591b9c0524dcc0f3"
diff --git a/meta/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.72.bb b/meta/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.72.bb
new file mode 100644
index 0000000000..f79015403b
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-fluendo-mpegdemux_0.10.72.bb
@@ -0,0 +1,12 @@
1require gst-fluendo.inc
2
3SUMMARY = "Fluendo closed-format mpeg video GStreamer plug-in"
4LICENSE = "MPLv1.1"
5LIC_FILES_CHKSUM = "file://COPYING;md5=be282f1c3cc9a98cc0dc5c2b25dfc510 \
6 file://src/gstmpegdemux.h;beginline=1;endline=19;md5=a9e90033f59897b91664d9f2a2ff01dd"
7LICENSE_FLAGS = "commercial"
8
9acpaths = "-I ${S}/common/m4 -I ${S}/m4"
10
11SRC_URI[md5sum] = "df726579404af65b9536428661ab4322"
12SRC_URI[sha256sum] = "a9784bc16352d0fb73de81b9c17142609e8bede46f6d9b881fc3d19673954abf"
diff --git a/meta/recipes-multimedia/gstreamer/gst-fluendo.inc b/meta/recipes-multimedia/gstreamer/gst-fluendo.inc
new file mode 100644
index 0000000000..feaf1c7c62
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-fluendo.inc
@@ -0,0 +1,14 @@
1SUMMARY = "Fluendo closed-format GStreamer plug-in"
2SECTION = "multimedia"
3HOMEPAGE = "http://www.fluendo.com/resources/source-plugins.php"
4DEPENDS = "gstreamer zlib"
5
6inherit autotools pkgconfig
7
8SRC_URI = "http://core.fluendo.com/gstreamer/src/${BPN}/${BPN}-${PV}.tar.bz2"
9
10FILES_${PN} += "${libdir}/gstreamer-0.10/*.so"
11FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug"
12FILES_${PN}-dev += "${libdir}/gstreamer-0.10/*.la ${libdir}/gstreamer-0.10/*.a"
13
14EXTRA_OECONF = "--disable-valgrind"
diff --git a/meta/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb b/meta/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb
new file mode 100644
index 0000000000..039abe14fa
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-meta-base_0.10.bb
@@ -0,0 +1,73 @@
1SUMMARY = "GStreamer package groups"
2LICENSE = "MIT"
3
4COMMERCIAL_PLUGINS = "${COMMERCIAL_AUDIO_PLUGINS} ${COMMERCIAL_VIDEO_PLUGINS}"
5DEPENDS_UGLY="${@'gst-plugins-ugly' if 'ugly' in COMMERCIAL_PLUGINS.split('-') else ''}"
6DEPENDS_BAD="${@'gst-plugins-bad' if 'bad' in COMMERCIAL_PLUGINS.split('-') else ''}"
7DEPENDS = "gstreamer gst-plugins-base gst-plugins-good ${DEPENDS_UGLY} ${DEPENDS_BAD}"
8
9LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
10 file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
11
12
13PR = "r13"
14
15PACKAGES = "\
16 gst-meta-base \
17 gst-meta-x11-base \
18 gst-meta-audio \
19 gst-meta-debug \
20 gst-meta-video"
21
22ALLOW_EMPTY_gst-meta-base = "1"
23ALLOW_EMPTY_gst-meta-x11-base = "1"
24ALLOW_EMPTY_gst-meta-audio = "1"
25ALLOW_EMPTY_gst-meta-debug = "1"
26ALLOW_EMPTY_gst-meta-video = "1"
27
28RDEPENDS_gst-meta-base = "\
29 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'gst-meta-x11-base', '', d)} \
30 gstreamer \
31 gst-plugins-base-playbin \
32 gst-plugins-base-decodebin \
33 gst-plugins-base-decodebin2 \
34 gst-plugins-base-gio \
35 gst-plugins-base-alsa \
36 gst-plugins-base-volume \
37 gst-plugins-base-audioconvert \
38 gst-plugins-base-audioresample \
39 gst-plugins-base-typefindfunctions \
40 gst-plugins-base-videoscale \
41 gst-plugins-base-ffmpegcolorspace \
42 gst-plugins-good-autodetect \
43 gst-plugins-good-souphttpsrc"
44
45RRECOMMENDS_gst-meta-x11-base = "\
46 gst-plugins-base-ximagesink \
47 gst-plugins-base-xvimagesink"
48
49RDEPENDS_gst-meta-audio = "\
50 gst-meta-base \
51 gst-plugins-base-vorbis \
52 gst-plugins-base-ogg \
53 gst-plugins-good-wavparse \
54 gst-plugins-good-flac \
55 ${COMMERCIAL_AUDIO_PLUGINS}"
56
57
58RDEPENDS_gst-meta-debug = "\
59 gst-meta-base \
60 gst-plugins-good-debug \
61 gst-plugins-base-audiotestsrc \
62 gst-plugins-base-videotestsrc"
63
64
65RDEPENDS_gst-meta-video = "\
66 gst-meta-base \
67 gst-plugins-good-avi \
68 gst-plugins-good-matroska \
69 gst-plugins-base-theora \
70 ${COMMERCIAL_VIDEO_PLUGINS}"
71
72RRECOMMENDS_gst-meta-video = "\
73 gst-meta-audio"
diff --git a/meta/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch b/meta/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch
new file mode 100644
index 0000000000..57a63b5a0f
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-openmax/gcc_4.6.patch
@@ -0,0 +1,18 @@
1Upstream-Status: Pending
2
3Signed-off-by: Saul Wold <sgw@linux.intel.com>
4
5Index: gst-openmax-0.10.1/omx/gstomx.c
6===================================================================
7--- gst-openmax-0.10.1.orig/omx/gstomx.c 2010-09-30 18:00:24.000000000 -0700
8+++ gst-openmax-0.10.1/omx/gstomx.c 2011-05-17 23:08:08.794535872 -0700
9@@ -238,7 +238,8 @@
10 const gchar *element_name = gst_structure_nth_field_name (element_table, i);
11 GstStructure *element = get_element_entry (element_name);
12 const gchar *type_name, *parent_type_name;
13- const gchar *component_name, *component_role, *library_name;
14+ const gchar *component_name, *library_name;
15+ const gchar __attribute__((__unused__)) *component_role;
16 GType type;
17 gint rank;
18
diff --git a/meta/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch b/meta/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch
new file mode 100644
index 0000000000..5965bbafbb
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-openmax/ptr-array.patch
@@ -0,0 +1,46 @@
1Rename static functions that use GLib naming conventions as one of them
2(g_ptr_array_insert) has now been added to GLib.
3
4Upstream-Status: Pending
5Signed-off-by: Ross Burton <ross.burton@intel.com>
6
7diff --git a/omx/gstomx_util.c b/omx/gstomx_util.c
8index 423e441..579dbf5 100644
9--- a/omx/gstomx_util.c
10+++ b/omx/gstomx_util.c
11@@ -85,7 +85,7 @@ static gboolean initialized;
12 */
13
14 static void
15-g_ptr_array_clear (GPtrArray * array)
16+omx_g_ptr_array_clear (GPtrArray * array)
17 {
18 guint index;
19 for (index = 0; index < array->len; index++)
20@@ -93,7 +93,7 @@ g_ptr_array_clear (GPtrArray * array)
21 }
22
23 static void
24-g_ptr_array_insert (GPtrArray * array, guint index, gpointer data)
25+omx_g_ptr_array_insert (GPtrArray * array, guint index, gpointer data)
26 {
27 if (index + 1 > array->len) {
28 g_ptr_array_set_size (array, index + 1);
29@@ -394,7 +394,7 @@ g_omx_core_unload (GOmxCore * core)
30 }
31
32 core_for_each_port (core, g_omx_port_free);
33- g_ptr_array_clear (core->ports);
34+ omx_g_ptr_array_clear (core->ports);
35 }
36
37 static inline GOmxPort *
38@@ -418,7 +418,7 @@ g_omx_core_new_port (GOmxCore * core, guint index)
39 }
40
41 port = g_omx_port_new (core, index);
42- g_ptr_array_insert (core->ports, index, port);
43+ omx_g_ptr_array_insert (core->ports, index, port);
44
45 return port;
46 }
diff --git a/meta/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb b/meta/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb
new file mode 100644
index 0000000000..2e01579569
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-openmax_0.10.1.bb
@@ -0,0 +1,35 @@
1SUMMARY = "GStreamer plug-in for communication with OpenMAX IL components"
2DESCRIPTION = "GstOpenMAX is a GStreamer plug-in that allows \
3communication with OpenMAX Integration Layer (IL) components. OpenMAX \
4IL is an industry standard that provides an abstraction layer for \
5computer graphics, video, and sound routines."
6HOMEPAGE = "http://freedesktop.org/wiki/GstOpenMAX"
7DEPENDS = "gstreamer"
8RDEPENDS_${PN} = "libomxil"
9LICENSE = "LGPLv2.1"
10LICENSE_FLAGS = "commercial"
11LIC_FILES_CHKSUM = "file://COPYING;md5=fbc093901857fcd118f065f900982c24 \
12 file://util/sem.h;beginline=1;endline=20;md5=accce5550d5583b839b441a0623f09fc"
13
14SRC_URI = "http://gstreamer.freedesktop.org/src/gst-openmax/gst-openmax-${PV}.tar.bz2 \
15 file://gcc_4.6.patch \
16 file://ptr-array.patch \
17 "
18
19inherit autotools pkgconfig
20
21# Tell configure that this isn't a development snapshot so we don't want
22# -Werror (hopefully fixed in 0.10.2)
23export GST_CVS="no"
24
25EXTRA_OECONF += "--disable-valgrind"
26
27PR = "r4"
28
29FILES_${PN} += "${libdir}/gstreamer-0.10/libgstomx.so"
30FILES_${PN}-dev += "${libdir}/gstreamer-0.10/libgstomx.la"
31FILES_${PN}-staticdev += "${libdir}/gstreamer-0.10/libgstomx.a"
32FILES_${PN}-dbg += "${libdir}/gstreamer-0.10/.debug/"
33
34SRC_URI[md5sum] = "4d0370bfe99dea20918c84347abadb4e"
35SRC_URI[sha256sum] = "9074d5a0591995133d19cfb15144f19664f902c1623f996595695cf2c2070e1f"
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb b/meta/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb
new file mode 100644
index 0000000000..0f64871497
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-plugins-bad_0.10.23.bb
@@ -0,0 +1,50 @@
1require gst-plugins.inc
2
3LICENSE = "GPLv2+ & LGPLv2+ & LGPLv2.1+ "
4LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
5 file://gst/tta/filters.h;beginline=12;endline=29;md5=629b0c7a665d155a6677778f4460ec06 \
6 file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
7 file://gst/tta/crc32.h;beginline=12;endline=29;md5=71a904d99ce7ae0c1cf129891b98145c"
8
9DEPENDS += "gst-plugins-base"
10
11PR = "r4"
12
13inherit gettext gsettings
14
15EXTRA_OECONF += "--disable-experimental \
16 --disable-sdl --disable-cdaudio --disable-directfb \
17 --disable-vdpau --disable-apexsink"
18
19PACKAGECONFIG ??= "bzip curl \
20 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'rsvg', '', d)}"
21
22PACKAGECONFIG[bzip] = "--enable-bz2,--disable-bz2,bzip2"
23PACKAGECONFIG[curl] = "--enable-curl,--disable-curl,curl"
24PACKAGECONFIG[rsvg] = "--enable-rsvg,--disable-rsvg,librsvg,"
25PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
26PACKAGECONFIG[neon] = "--enable-neon,--disable-neon,neon"
27PACKAGECONFIG[mms] = "--enable-libmms,--disable-libmms,libmms"
28PACKAGECONFIG[cog] = "--enable-cog,--disable-cog,libpng"
29PACKAGECONFIG[faad] = "--enable-faad,--disable-faad,faad2"
30PACKAGECONFIG[jp2k] = "--enable-jp2k,--disable-jp2k,jasper"
31PACKAGECONFIG[modplug] = "--enable-modplug,--disable-modplug,libmodplug"
32PACKAGECONFIG[opus] = "--enable-opus,--disable-opus,libopus"
33PACKAGECONFIG[sndfile] = "--enable-sndfile,--disable-sndfile,libsndfile1"
34PACKAGECONFIG[vp8] = "--enable-vp8,--disable-vp8,libvpx"
35PACKAGECONFIG[ass] = "--enable-assrender,--disable-assrender,libass"
36PACKAGECONFIG[openal] = "--enable-openal,--disable-openal,openal-soft"
37PACKAGECONFIG[schro] = "--enable-schro,--disable-schro,schroedinger"
38PACKAGECONFIG[dc1394] = "--enable-dc1394,--disable-dc1394,libdc1394"
39PACKAGECONFIG[faac] = "--enable-faac,--disable-faac,faac"
40PACKAGECONFIG[rtmp] = "--enable-rtmp,--disable-rtmp,rtmpdump"
41
42ARM_INSTRUCTION_SET = "arm"
43
44do_configure_prepend() {
45 # This m4 file contains nastiness which conflicts with libtool 2.2.2
46 rm ${S}/m4/lib-link.m4 || true
47}
48
49SRC_URI[md5sum] = "fcb09798114461955260e4d940db5987"
50SRC_URI[sha256sum] = "0eae7d1a1357ae8377fded6a1b42e663887beabe0e6cc336e2ef9ada42e11491"
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch b/meta/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 0000000000..52142562ab
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch
@@ -0,0 +1,37 @@
1audioresample: Fix build on x86 if emmintrin.h is available but can't be used
2
3On x86, EMMINTRIN is defined but not usable without SSE so check for
4__SSE__ and __SSE2__ as well.
5
6https://bugzilla.gnome.org/show_bug.cgi?id=670690
7
8Upstream-Status: Backport
9
10Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
11---
12 gst/audioresample/resample.c | 4 ++--
13 1 files changed, 2 insertions(+), 2 deletions(-)
14
15diff --git a/gst/audioresample/resample.c b/gst/audioresample/resample.c
16index 98d006c..481fa01 100644
17--- a/gst/audioresample/resample.c
18+++ b/gst/audioresample/resample.c
19@@ -77,13 +77,13 @@
20 #define EXPORT G_GNUC_INTERNAL
21
22 #ifdef _USE_SSE
23-#ifndef HAVE_XMMINTRIN_H
24+#if !defined(__SSE__) || !defined(HAVE_XMMINTRIN_H)
25 #undef _USE_SSE
26 #endif
27 #endif
28
29 #ifdef _USE_SSE2
30-#ifndef HAVE_EMMINTRIN_H
31+#if !defined(__SSE2__) || !defined(HAVE_EMMINTRIN_H)
32 #undef _USE_SSE2
33 #endif
34 #endif
35--
361.7.1
37
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch b/meta/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
new file mode 100644
index 0000000000..b8602c80d7
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/configure.ac-fix-subparse-plugin.patch
@@ -0,0 +1,27 @@
1Upstream-Status: Submitted [similar patch by other author, bugzilla]
2Bugtracker-URL: https://bugzilla.gnome.org/show_bug.cgi?id=663600
3
4Prepend PKG_CONFIG_SYSROOT to includedir, so configure doesn't
5search for gstconfig.h in /usr/include.
6
7Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
8---
9 configure.ac | 2 +-
10 1 files changed, 1 insertions(+), 1 deletions(-)
11
12diff --git a/configure.ac b/configure.ac
13index 1901bcf..460fb0a 100644
14--- a/configure.ac
15+++ b/configure.ac
16@@ -435,7 +435,7 @@ AG_GST_CHECK_PLUGIN(volume)
17 dnl check for gstreamer core features (subsystems)
18 dnl FIXME: this assumes srcdir == builddir for uninstalled setups
19 GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-0.10`"/gst/gstconfig.h"
20-AG_GST_PARSE_SUBSYSTEM_DISABLES($GST_CONFIGPATH)
21+AG_GST_PARSE_SUBSYSTEM_DISABLES($PKG_CONFIG_SYSROOT_DIR$GST_CONFIGPATH)
22 AM_CONDITIONAL(USE_XML, test $GST_DISABLE_XML != "1")
23
24 dnl disable plug-ins that require libxml2's HTML support if it is not available
25--
261.7.5.4
27
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch b/meta/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
new file mode 100644
index 0000000000..99dbc9d52e
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-plugins-base-0.10.36/gst-plugins-base-tremor.patch
@@ -0,0 +1,20 @@
1Remove -DTREMOR option since Tremor has dropped its internal
2libogg2, and gst-plugins-base has dependency on that.
3
4Upstream-Status: Inappropriate [configuration]
5
6Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
7Signed-off-by: Shane Wang <shane.wang@intel.com>
8
9diff -r 70065fb4e085 ext/vorbis/Makefile.am
10--- a/ext/vorbis/Makefile.am Tue Mar 13 16:36:56 2012 +0800
11+++ b/ext/vorbis/Makefile.am Tue Mar 13 16:38:53 2012 +0800
12@@ -30,7 +30,7 @@
13 gstvorbisdec.c gstvorbisdeclib.c gstvorbiscommon.c
14 libgstivorbisdec_la_CFLAGS = \
15 $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \
16- -DTREMOR $(IVORBIS_CFLAGS)
17+ $(IVORBIS_CFLAGS)
18 libgstivorbisdec_la_LIBADD = \
19 $(top_builddir)/gst-libs/gst/tag/libgsttag-@GST_MAJORMINOR@.la \
20 $(top_builddir)/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la \
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb b/meta/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb
new file mode 100644
index 0000000000..c8a949973d
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-plugins-base_0.10.36.bb
@@ -0,0 +1,39 @@
1require gst-plugins.inc
2
3LICENSE = "GPLv2+ & LGPLv2+"
4LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
5 file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=622921ffad8cb18ab906c56052788a3f \
6 file://COPYING.LIB;md5=55ca817ccb7d5b5b66355690e9abc605 \
7 file://gst/ffmpegcolorspace/utils.c;beginline=1;endline=20;md5=9c83a200b8e597b26ca29df20fc6ecd0"
8
9DEPENDS += "alsa-lib liboil libogg libvorbis libtheora util-linux tremor glib-2.0-native"
10
11SRC_URI += "file://gst-plugins-base-tremor.patch \
12 file://configure.ac-fix-subparse-plugin.patch \
13 file://audioresample-Fix-build-on-x86-if-emmintrin.h-is-ava.patch \
14"
15
16SRC_URI[md5sum] = "776c73883e567f67b9c4a2847d8d041a"
17SRC_URI[sha256sum] = "2cd3b0fa8e9b595db8f514ef7c2bdbcd639a0d63d154c00f8c9b609321f49976"
18
19PR = "r8"
20
21inherit gettext
22
23EXTRA_OECONF += "--disable-freetypetest"
24
25PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}"
26
27PACKAGECONFIG[gnomevfs] = "--enable-gnome_vfs,--disable-gnome_vfs,gnome-vfs"
28PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
29PACKAGECONFIG[pango] = "--enable-pango,--disable-pango,pango"
30PACKAGECONFIG[x11] = "--enable-x --enable-xvideo,--disable-x --disable-xvideo,virtual/libx11 libxv libsm libice"
31
32do_configure_prepend() {
33 # This m4 file contains nastiness which conflicts with libtool 2.2.2
34 rm -f ${S}/m4/lib-link.m4
35}
36
37FILES_${PN} += "${datadir}/${BPN}"
38
39CACHED_CONFIGUREVARS_append_i586 = " ac_cv_header_emmintrin_h=no ac_cv_header_xmmintrin_h=no"
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch b/meta/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
new file mode 100644
index 0000000000..bc2f88b241
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-plugins-gl/0001-conditional-gl-framebuffer-undefined-use.patch
@@ -0,0 +1,35 @@
1From 14d51cbefef19737e7ab2b6818ee1d3bdb248d12 Mon Sep 17 00:00:00 2001
2From: Jeremy Stashluk <jstashluk@dekaresearch.com>
3Date: Wed, 6 Feb 2013 09:59:48 -0500
4Subject: [PATCH] conditional gl framebuffer undefined use
5
6The OpenGL extension GL_ARB_framebuffer_object defines the macro
7GL_FRAMEBUFFER_UNDEFINED. The macro will only need to map to an error
8string if the extension provides functions that might return the macro.
9
10Upstream-Status: Pending
11
12Signed-off-by: Jeremy Stashluk <jstashluk@dekaresearch.com>
13---
14 gst-libs/gst/gl/gstgldisplay.c | 2 ++
15 1 file changed, 2 insertions(+)
16
17diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c
18index 3ed0b71..64c6c2c 100644
19--- a/gst-libs/gst/gl/gstgldisplay.c
20+++ b/gst-libs/gst/gl/gstgldisplay.c
21@@ -2177,9 +2177,11 @@ gst_gl_display_check_framebuffer_status (void)
22 GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
23 break;
24
25+#if defined(GL_ARB_framebuffer_object)
26 case GL_FRAMEBUFFER_UNDEFINED:
27 GST_ERROR ("GL_FRAMEBUFFER_UNDEFINED");
28 break;
29+#endif
30
31 default:
32 GST_ERROR ("General FBO error");
33--
341.7.9.5
35
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb b/meta/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb
new file mode 100644
index 0000000000..90efbcc025
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-plugins-gl_0.10.3.bb
@@ -0,0 +1,25 @@
1require recipes-multimedia/gstreamer/gst-plugins.inc
2
3LICENSE = "GPLv2+ & LGPLv2+ & LGPLv2.1+ "
4LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605"
5
6SRC_URI[md5sum] = "ac70ede13f79978d56eaed8abaa3c938"
7SRC_URI[sha256sum] = "48340b6a4b8abce16344a7bc33e74a94fdcce4f57ef6342cdf2f941c429bf210"
8
9SRC_URI += " file://0001-conditional-gl-framebuffer-undefined-use.patch"
10
11DEPENDS += "gst-plugins-base virtual/libgles2 virtual/egl jpeg libpng glew"
12
13PR = "r4"
14
15inherit gettext
16
17# This package doesn't have a configure switch for EGL or GL, so forcibly tell
18# configure that it can't find gl.h so it always uses EGL. If/when we have some
19# way for machines to specify their preferred GL flavour this can be
20# automatically adapted.
21EXTRA_OECONF += "ac_cv_header_GL_gl_h=no"
22
23ALLOW_EMPTY_${PN} = "1"
24ALLOW_EMPTY_${PN}-apps = "1"
25ALLOW_EMPTY_${PN}-glib = "1"
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch b/meta/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 0000000000..6456d3c6c2
--- /dev/null
+++ b/meta/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 @@
1From 12d18fe4e98e7c232d59b56d529a0521f293fe6d Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com>
3Date: Wed, 5 Sep 2012 18:54:42 +0200
4Subject: [PATCH] v4l2: fix build with recent kernels, the v4l2_buffer input
5 field was removed
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10Upstream-Status: Backport
11
12[1] http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=9f2aa8d47f835ea155aaf635f618c0fc1ca87012
13
14Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
15---
16 sys/v4l2/gstv4l2bufferpool.c | 1 -
17 1 files changed, 0 insertions(+), 1 deletions(-)
18
19diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c
20index b81c6a4..51cc0ce 100644
21--- a/sys/v4l2/gstv4l2bufferpool.c
22+++ b/sys/v4l2/gstv4l2bufferpool.c
23@@ -181,7 +181,6 @@ gst_v4l2_buffer_new (GstV4l2BufferPool * pool, guint index, GstCaps * caps)
24 GST_LOG_OBJECT (pool->v4l2elem, " MMAP offset: %u",
25 ret->vbuffer.m.offset);
26 GST_LOG_OBJECT (pool->v4l2elem, " length: %u", ret->vbuffer.length);
27- GST_LOG_OBJECT (pool->v4l2elem, " input: %u", ret->vbuffer.input);
28
29 data = (guint8 *) v4l2_mmap (0, ret->vbuffer.length,
30 PROT_READ | PROT_WRITE, MAP_SHARED, pool->video_fd,
31--
321.7.6.5
33
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch b/meta/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 0000000000..bd0de583a5
--- /dev/null
+++ b/meta/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 @@
1From ccb01de8096a32d86d47b0d92ec3416c57ee4d25 Mon Sep 17 00:00:00 2001
2From: Bruce Ashfield <bruce.ashfield@windriver.com>
3Date: Thu, 22 Aug 2013 12:15:54 -0400
4Subject: [PATCH] v4l2_calls: define V4L2_CID_HCENTER and V4L2_CID_VCENTER
5
6kernel commit 24b9f5017 [[media] V4L: Remove deprecated image centering controls]
7removed the definitions of V4L2_CID_HCENTER and V4L2_CID_VCENTER after three
8years of depreciation.
9
10The ioctl values are still free, and the case statement which processess them
11in v4l2 userspace falls through to the proper replacement. So in the short
12term, we can explicitly define them using the old absolute values, and everything
13will work.
14
15Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
16---
17 sys/v4l2/v4l2_calls.c | 9 +++++++--
18 1 file changed, 7 insertions(+), 2 deletions(-)
19
20diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c
21index 309bfb6..3c64544 100644
22--- a/sys/v4l2/v4l2_calls.c
23+++ b/sys/v4l2/v4l2_calls.c
24@@ -54,11 +54,16 @@
25 #include "gst/gst-i18n-plugin.h"
26
27 /* Those are ioctl calls */
28+
29+/* V4L2_CID_HCENTER has been removed from the mainline kernel, but
30+ the ioctl space is still present. Since these values fall through
31+ to their replacement, it is safe (in the short term) to re-use the
32+ old values explictily */
33 #ifndef V4L2_CID_HCENTER
34-#define V4L2_CID_HCENTER V4L2_CID_HCENTER_DEPRECATED
35+#define V4L2_CID_HCENTER V4L2_CID_BASE+22
36 #endif
37 #ifndef V4L2_CID_VCENTER
38-#define V4L2_CID_VCENTER V4L2_CID_VCENTER_DEPRECATED
39+#define V4L2_CID_VCENTER V4L2_CID_BASE+23
40 #endif
41
42 GST_DEBUG_CATEGORY_EXTERN (v4l2_debug);
43--
441.7.10.4
45
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch b/meta/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
new file mode 100644
index 0000000000..48b8e98b81
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-plugins-good-0.10.31/0407-mulawdec-fix-integer-overrun.patch
@@ -0,0 +1,47 @@
1From ce94b2c2b91b6db190c121860e12a6afafce7ae1 Mon Sep 17 00:00:00 2001
2From: Roland Krikava <rkrikava@gmail.com>
3Date: Fri, 2 Nov 2012 12:38:44 -0400
4Subject: [PATCH 407/440] mulawdec: fix integer overrun
5
6There might be more than 65535 samples in a chunk of data.
7
8https://bugzilla.gnome.org/show_bug.cgi?id=687469
9
10Commit - 3be45f70220310ec1c60d819f90b5f2ae03b5d83 in 0.10 branch
11
12Upstream Status: Backported
13
14Signed-off-by: Roland Krikava <rkrikava@gmail.com>
15---
16 gst/law/mulaw-conversion.c | 6 ++++--
17 1 file changed, 4 insertions(+), 2 deletions(-)
18
19diff --git a/gst/law/mulaw-conversion.c b/gst/law/mulaw-conversion.c
20index 8afae80..190a9f5 100644
21--- a/gst/law/mulaw-conversion.c
22+++ b/gst/law/mulaw-conversion.c
23@@ -51,9 +51,10 @@ mulaw_encode (gint16 * in, guint8 * out, gint numsamples)
24 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
25 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
26 };
27- gint16 sign, exponent, mantissa, i;
28+ gint16 sign, exponent, mantissa;
29 gint16 sample;
30 guint8 ulawbyte;
31+ gint i;
32
33 for (i = 0; i < numsamples; i++) {
34 sample = in[i];
35@@ -102,7 +103,8 @@ mulaw_decode (guint8 * in, gint16 * out, gint numsamples)
36 static gint16 exp_lut[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 };
37 gint16 sign, exponent, mantissa;
38 guint8 ulawbyte;
39- gint16 linear, i;
40+ gint16 linear;
41+ gint i;
42
43 for (i = 0; i < numsamples; i++) {
44 ulawbyte = in[i];
45--
461.7.9.5
47
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb b/meta/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb
new file mode 100644
index 0000000000..495bb17649
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-plugins-good_0.10.31.bb
@@ -0,0 +1,44 @@
1require gst-plugins.inc
2
3LICENSE = "GPLv2+ & LGPLv2.1+"
4LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
5 file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=622921ffad8cb18ab906c56052788a3f \
6 file://gst/replaygain/rganalysis.c;beginline=1;endline=23;md5=b60ebefd5b2f5a8e0cab6bfee391a5fe"
7
8PR = "r8"
9
10PACKAGECONFIG ?= "jpeg \
11 ${@bb.utils.contains('DISTRO_FEATURES', 'pulseaudio', 'pulseaudio', '', d)} \
12 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)} \
13"
14PACKAGECONFIG[pulseaudio] = "--enable-pulse,--disable-pulse,pulseaudio"
15PACKAGECONFIG[jack] = "--enable-jack,--disable-jack,jack"
16PACKAGECONFIG[jpeg] = "--enable-jpeg,--disable-jpeg,jpeg"
17PACKAGECONFIG[wavpack] = "--enable-wavpack,--disable-wavpack,wavpack"
18PACKAGECONFIG[gdkpixbuf] = "--enable-gdk_pixbuf,--disable-gdk_pixbuf,gdk-pixbuf"
19PACKAGECONFIG[v4l] = "--with-libv4l2,--without-libv4l2,libv4l"
20PACKAGECONFIG[bzip2] = "--enable-bz2,--disable-bz2,bzip2"
21PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
22PACKAGECONFIG[x11] = "--enable-x,--disable-x,virtual/libx11 libxfixes libxdamage"
23
24DEPENDS += "gst-plugins-base gconf cairo libpng zlib libid3tag flac \
25 speex libsoup-2.4 libcap"
26
27inherit gettext gconf
28
29SRC_URI += "file://0001-v4l2-fix-build-with-recent-kernels-the-v4l2_buffer-i.patch \
30 file://0001-v4l2_calls-define-V4L2_CID_HCENTER-and-V4L2_CID_VCEN.patch \
31 file://0407-mulawdec-fix-integer-overrun.patch \
32"
33EXTRA_OECONF += "--disable-aalib --disable-esd --disable-shout2 --disable-libcaca --disable-hal \
34 --disable-examples --disable-taglib"
35
36do_configure_prepend() {
37 # This m4 file contains nastiness which conflicts with libtool 2.2.2
38 rm ${S}/m4/lib-link.m4 || true
39}
40
41SRC_URI[md5sum] = "24f98a294a2b521e1b29412bdadae2e6"
42SRC_URI[sha256sum] = "7e27840e40a7932ef2dc032d7201f9f41afcaf0b437daf5d1d44dc96d9e35ac6"
43
44FILES_${PN}-gconfelements += "${sysconfdir}/gconf/schemas/gstreamer-0.10.schemas"
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins-package.inc b/meta/recipes-multimedia/gstreamer/gst-plugins-package.inc
new file mode 100644
index 0000000000..7bb567866f
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-plugins-package.inc
@@ -0,0 +1,58 @@
1PACKAGESPLITFUNCS_prepend = " split_gstreamer10_packages "
2PACKAGESPLITFUNCS_append = " set_metapkg_rdepends "
3
4python split_gstreamer10_packages () {
5 gst_libdir = d.expand('${libdir}/gstreamer-${LIBV}')
6 postinst = d.getVar('plugin_postinst', True)
7 glibdir = d.getVar('libdir', True)
8
9 do_split_packages(d, glibdir, '^lib(.*)\.so\.*', 'lib%s', 'gstreamer %s library', extra_depends='', allow_links=True)
10 do_split_packages(d, gst_libdir, 'libgst(.*)\.so$', d.expand('${PN}-%s'), 'GStreamer plugin for %s', postinst=postinst, extra_depends=d.expand('${PN}'))
11 do_split_packages(d, gst_libdir, 'libgst(.*)\.la$', d.expand('${PN}-%s-dev'), 'GStreamer plugin for %s (development files)', extra_depends=d.expand('${PN}-dev'))
12 do_split_packages(d, gst_libdir, 'libgst(.*)\.a$', d.expand('${PN}-%s-staticdev'), 'GStreamer plugin for %s (static development files)', extra_depends=d.expand('${PN}-staticdev'))
13}
14
15python set_metapkg_rdepends () {
16 import os
17
18 pn = d.getVar('PN', True)
19 metapkg = pn + '-meta'
20 d.setVar('ALLOW_EMPTY_' + metapkg, "1")
21 d.setVar('FILES_' + metapkg, "")
22 blacklist = [ pn, pn + '-locale', pn + '-dev', pn + '-dbg', pn + '-doc', pn + '-meta' ]
23 metapkg_rdepends = []
24 packages = d.getVar('PACKAGES', True).split()
25 pkgdest = d.getVar('PKGDEST', True)
26 for pkg in packages[1:]:
27 if not pkg in blacklist and not pkg in metapkg_rdepends and not pkg.endswith('-dev') and not pkg.endswith('-dbg') and not pkg.count('locale') and not pkg.count('-staticdev'):
28 # See if the package is empty by looking at the contents of its PKGDEST subdirectory.
29 # If this subdirectory is empty, then the package is.
30 # Empty packages do not get added to the meta package's RDEPENDS
31 pkgdir = os.path.join(pkgdest, pkg)
32 if os.path.exists(pkgdir):
33 dir_contents = os.listdir(pkgdir) or []
34 else:
35 dir_contents = []
36 is_empty = len(dir_contents) == 0
37 if not is_empty:
38 metapkg_rdepends.append(pkg)
39 d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends))
40 d.setVar('DESCRIPTION_' + metapkg, pn + ' meta package')
41}
42
43# metapkg has runtime dependency on PN
44# each plugin depends on PN, plugin-dev on PN-dev, plugin-staticdev on PN-staticdev
45# so we need them even when empty (like in gst-plugins-good case)
46ALLOW_EMPTY_${PN} = "1"
47ALLOW_EMPTY_${PN}-dev = "1"
48ALLOW_EMPTY_${PN}-staticdev = "1"
49
50PACKAGES += "${PN}-apps ${PN}-meta ${PN}-glib"
51FILES_${PN}-apps = "${bindir}"
52
53RDEPENDS_${PN}-apps += "perl"
54
55FILES_${PN} = "${datadir}/gstreamer-${LIBV}"
56FILES_${PN}-dbg += "${libdir}/gstreamer-${LIBV}/.debug"
57FILES_${PN}-glib = "${datadir}/glib-2.0"
58
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb b/meta/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb
new file mode 100644
index 0000000000..2fdf03f348
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-plugins-ugly_0.10.19.bb
@@ -0,0 +1,29 @@
1require gst-plugins.inc
2
3LICENSE = "GPLv2+ & LGPLv2.1+ & LGPLv2+"
4LICENSE_FLAGS = "commercial"
5LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
6 file://gst/synaesthesia/synaescope.h;beginline=1;endline=20;md5=99f301df7b80490c6ff8305fcc712838 \
7 file://tests/check/elements/xingmux.c;beginline=1;endline=21;md5=4c771b8af188724855cb99cadd390068 \
8 file://gst/mpegstream/gstmpegparse.h;beginline=1;endline=18;md5=ff65467b0c53cdfa98d0684c1bc240a9"
9
10DEPENDS += "gst-plugins-base libid3tag libmad mpeg2dec liba52 lame"
11PR = "r3"
12
13inherit gettext
14
15EXTRA_OECONF += "--with-plugins=a52dec,lame,id3tag,mad,mpeg2dec,mpegstream,mpegaudioparse,asfdemux,realmedia \
16 --disable-orc"
17
18PACKAGECONFIG ??= ""
19PACKAGECONFIG[x264] = "--enable-x264,--disable-x264,x264"
20PACKAGECONFIG[cdio] = "--enable-cdio,--disable-cdio,libcdio"
21PACKAGECONFIG[dvdread] = "--enable-dvdread,--disable-dvdread,libdvdread"
22
23do_configure_prepend() {
24 # This m4 file contains nastiness which conflicts with libtool 2.2.2
25 rm ${S}/m4/lib-link.m4 || true
26}
27
28SRC_URI[md5sum] = "1d81c593e22a6cdf0f2b4f57eae93df2"
29SRC_URI[sha256sum] = "1ca90059275c0f5dca71d4d1601a8f429b7852baed0723e820703b977e2c8df0"
diff --git a/meta/recipes-multimedia/gstreamer/gst-plugins.inc b/meta/recipes-multimedia/gstreamer/gst-plugins.inc
new file mode 100644
index 0000000000..26976092d6
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gst-plugins.inc
@@ -0,0 +1,28 @@
1SUMMARY = "Plugins for the GStreamer multimedia framework"
2HOMEPAGE = "http://gstreamer.freedesktop.org/"
3BUGTRACKER = "https://bugzilla.gnome.org/enter_bug.cgi?product=Gstreamer"
4SECTION = "multimedia"
5DEPENDS = "gstreamer"
6
7inherit autotools pkgconfig
8
9SRC_URI = "http://gstreamer.freedesktop.org/src/${BPN}/${BPN}-${PV}.tar.bz2"
10
11GSTREAMER_DEBUG ?= "--disable-debug"
12EXTRA_OECONF = "--disable-valgrind ${GSTREAMER_DEBUG} --disable-examples "
13
14acpaths = "-I ${S}/common/m4 -I ${S}/m4"
15
16LIBV = "0.10"
17require gst-plugins-package.inc
18
19PACKAGES_DYNAMIC += "^${PN}-.*"
20
21# apply gstreamer hack after Makefile.in.in in source is replaced by our version from
22# ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in, but before configure is executed
23# http://lists.linuxtogo.org/pipermail/openembedded-core/2012-November/032233.html
24oe_runconf_prepend() {
25 if [ -e ${S}/po/Makefile.in.in ]; then
26 sed -i -e "1a\\" -e 'GETTEXT_PACKAGE = @GETTEXT_PACKAGE@' ${S}/po/Makefile.in.in
27 fi
28}
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch b/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
new file mode 100644
index 0000000000..d07749682b
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch
@@ -0,0 +1,32 @@
1From ed7f4802222234eef192aa3f74bc92268f338f97 Mon Sep 17 00:00:00 2001
2From: Sebastian Droege <sebastian.droege@collabora.co.uk>
3Date: Tue, 6 Mar 2012 12:28:02 +0100
4Subject: [PATCH] baseparse: Fix 'self-comparison always evaluates to true'
5
6This was really a bug.
7
8Commit is ed7f4802222234eef192aa3f74bc92268f338f97 in 0.10 branch
9
10Upstream Status: Backported
11
12Signed-off-by: Sebastian Droege <sebastian.droege@collabora.co.uk>
13---
14 libs/gst/base/gstbaseparse.c | 2 +-
15 1 file changed, 1 insertion(+), 1 deletion(-)
16
17diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c
18index 851ec1d..108ee89 100644
19--- a/libs/gst/base/gstbaseparse.c
20+++ b/libs/gst/base/gstbaseparse.c
21@@ -3899,7 +3899,7 @@ gst_base_parse_handle_seek (GstBaseParse * parse, GstEvent * event)
22 seek event (in bytes) to upstream. Segment / flush handling happens
23 in corresponding src event handlers */
24 GST_DEBUG_OBJECT (parse, "seek in PUSH mode");
25- if (seekstop >= 0 && seekpos <= seekpos)
26+ if (seekstop >= 0 && seekstop <= seekpos)
27 seekstop = seekpos;
28 new_event = gst_event_new_seek (rate, GST_FORMAT_BYTES, flags,
29 GST_SEEK_TYPE_SET, seekpos, stop_type, seekstop);
30--
311.7.9.5
32
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch b/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch
new file mode 100644
index 0000000000..5d8bb13403
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/check_fix.patch
@@ -0,0 +1,19 @@
1# gstreamer: Fix a problem with configure if check has already been built
2# Richard Purdie <rpurdie@linux.intel.com>
3
4Upstream-Status: Inappropriate [configuration]
5
6diff -urN gstreamer-0.10.29-orig/configure.ac gstreamer-0.10.29/configure.ac
7--- gstreamer-0.10.29-orig/configure.ac 2010-06-26 12:49:27.774930773 +0800
8+++ gstreamer-0.10.29/configure.ac 2010-06-26 12:51:12.899200233 +0800
9@@ -543,8 +543,10 @@
10 *) BUILD_CHECK=yes ;;
11 esac
12 ])
13+
14 dnl bit of a misnomer, but keep the conditional named like this so we don't
15 dnl have to change too much elsewhere
16+HAVE_CHECK=no
17 AM_CONDITIONAL(HAVE_CHECK, test "x$BUILD_CHECK" = "xyes")
18
19 dnl configure the desired buffer alignment
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch b/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch
new file mode 100644
index 0000000000..30be85f59d
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/gst-inspect-check-error.patch
@@ -0,0 +1,16 @@
1# Fix crash with gst-inspect
2# Chris Lord <chris@openedhand.com>
3
4Upstream-Status: Pending
5
6--- gstreamer-0.10.9/tools/gst-inspect.c.old 2006-09-12 11:56:53.000000000 +0100
7+++ gstreamer-0.10.9/tools/gst-inspect.c 2006-09-12 11:57:27.000000000 +0100
8@@ -1123,7 +1123,7 @@
9 g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
10 g_option_context_add_group (ctx, gst_init_get_option_group ());
11 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
12- g_print ("Error initializing: %s\n", err->message);
13+ g_print ("Error initializing: %s\n", err ? err->message : "(null)");
14 exit (1);
15 }
16 g_option_context_free (ctx);
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c b/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c
new file mode 100644
index 0000000000..c1f3e71af6
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.c
@@ -0,0 +1,487 @@
1/* GStreamer
2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
4 * 2005 David A. Schleef <ds@schleef.org>
5 *
6 * gstregistryxml.c: GstRegistry object, support routines
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it ulnder the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
22 */
23
24
25#include <gst/gstregistrybinary.h>
26
27/*
28** Simple handy function to write a memory location to the registry cache file
29*/
30inline static gboolean
31gst_registry_binary_write(GstRegistry *registry, const void *mem, const ssize_t size)
32{
33 if (write(registry->cache_file, mem, size) != size)
34 {
35 GST_ERROR("Failed to write binary registry element: ptr=%p size=%u error=%s\n",
36 mem, size, strerror(errno));
37 return FALSE;
38 }
39 return TRUE;
40}
41
42/*
43** Save features GstBinary style
44*/
45static gboolean
46gst_registry_binary_fill_feature(GList **list, GstPluginFeature *orig, GstBinaryPluginFeature *dest, const char *name)
47{
48 GstBinaryChunck *chk;
49
50 if ((chk = calloc(1, sizeof (GstBinaryChunck))) == NULL)
51 return FALSE;
52
53 chk->data = dest;
54 chk->size = sizeof (GstBinaryPluginFeature);
55
56 *list = g_list_append(*list, chk);
57
58 dest->rank = orig->rank;
59 if (!strncpy(dest->typename, name, GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN) ||
60 !strncpy(dest->name, orig->name, GST_BINARY_REGISTRY_TYPENAME_NAME_LEN))
61 {
62 GST_ERROR("Failed to write binary registry feature");
63 goto fail;
64 }
65
66 if (GST_IS_ELEMENT_FACTORY(orig))
67 {
68 GstElementFactory *factory = GST_ELEMENT_FACTORY(orig);
69
70 if (!strncpy(dest->longname, factory->details.longname, GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN) ||
71 !strncpy(dest->class, factory->details.klass, GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN) ||
72 !strncpy(dest->description, factory->details.description, GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN) ||
73 !strncpy(dest->author, factory->details.author, GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN))
74 {
75 GST_ERROR("Failed to write binary registry feature");
76 goto fail;
77 }
78 }
79
80 dest->npadtemplates = dest->ninterfaces = dest->nuritypes = 0;
81 return TRUE;
82
83 fail:
84 free(chk);
85 return FALSE;
86}
87
88
89/*
90** Initialize the GstBinaryRegistryMagic, setting both our magic number and gstreamer major/minor version
91*/
92inline static gboolean
93gst_registry_binary_initialize_magic(GstBinaryRegistryMagic *m)
94{
95 if (!strncpy(m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) ||
96 !strncpy(m->version, GST_MAJORMINOR, GST_BINARY_REGISTRY_VERSION_LEN))
97 {
98 GST_ERROR("Failed to write magic to the registry magic structure");
99 return FALSE;
100 }
101 return TRUE;
102}
103
104/*
105** Check GstBinaryRegistryMagic validity.
106** Return a pointer pointing right after the magic structure
107*/
108static gchar *
109gst_registry_binary_check_magic(gchar *in)
110{
111 GstBinaryRegistryMagic *m = (GstBinaryRegistryMagic *) in;
112
113 if (m == NULL || m->magic == NULL || m->version == NULL)
114 {
115 GST_ERROR("Binary registry magic structure is broken");
116 return NULL;
117 }
118 if (strncmp(m->magic, GST_MAGIC_BINARY_REGISTRY_STR, GST_MAGIC_BINARY_REGISTRY_LEN) != 0)
119 {
120 GST_ERROR("Binary registry magic is different : %02x%02x%02x%02x != %02x%02x%02x%02x",
121 GST_MAGIC_BINARY_REGISTRY_STR[0] & 0xff, GST_MAGIC_BINARY_REGISTRY_STR[1] & 0xff,
122 GST_MAGIC_BINARY_REGISTRY_STR[2] & 0xff, GST_MAGIC_BINARY_REGISTRY_STR[3] & 0xff,
123 m->magic[0] & 0xff, m->magic[1] & 0xff, m->magic[2] & 0xff, m->magic[3] & 0xff);
124 return NULL;
125 }
126 if (strncmp(m->version, GST_MAJORMINOR, GST_BINARY_REGISTRY_VERSION_LEN))
127 {
128 GST_ERROR("Binary registry magic version is different : %s != %s",
129 GST_MAJORMINOR, m->version);
130 return NULL;
131 }
132 return (in + sizeof (GstBinaryRegistryMagic));
133}
134
135/*
136** Adapt a GstPlugin to our GstBinaryPluginElement structure, and write it to the
137** registry file.
138*/
139static gboolean
140gst_registry_binary_save_plugin(GList **list, GstRegistry *registry, GstPlugin *plugin)
141{
142 GstBinaryPluginElement *e;
143 GstBinaryChunck *chk;
144 GList *walk;
145
146 if ((e = calloc(1, sizeof (GstBinaryPluginElement))) == NULL ||
147 (chk = calloc(1, sizeof (GstBinaryChunck))) == NULL)
148 return FALSE;
149
150 chk->data = e;
151 chk->size = sizeof (GstBinaryPluginElement);
152 *list = g_list_append(*list, chk);
153
154 if (!strncpy(e->name, plugin->desc.name, GST_BINARY_REGISTRY_NAME_LEN) ||
155 !strncpy(e->description, plugin->desc.description, GST_BINARY_REGISTRY_DESCRIPTION_LEN) ||
156 !strncpy(e->filename, plugin->filename, _POSIX_PATH_MAX) ||
157 !strncpy(e->version, plugin->desc.version, GST_BINARY_REGISTRY_VERSION_LEN) ||
158 !strncpy(e->license, plugin->desc.license, GST_BINARY_REGISTRY_LICENSE_LEN) ||
159 !strncpy(e->source, plugin->desc.source, GST_BINARY_REGISTRY_SOURCE_LEN) ||
160 !strncpy(e->package, plugin->desc.package, GST_BINARY_REGISTRY_PACKAGE_LEN) ||
161 !strncpy(e->origin, plugin->desc.origin, GST_BINARY_REGISTRY_ORIGIN_LEN))
162 {
163 GST_DEBUG("Can't adapt GstPlugin to GstBinaryPluginElement");
164 goto fail;
165 }
166
167 e->size = plugin->file_size;
168 e->m32p = plugin->file_mtime;
169
170 GList *ft_list = gst_registry_get_feature_list_by_plugin(registry, plugin->desc.name);
171
172 for (walk = ft_list; walk; walk = g_list_next(walk), e->nfeatures++)
173 {
174 GstPluginFeature *curfeat = GST_PLUGIN_FEATURE (walk->data);
175 GstBinaryPluginFeature *newfeat;
176 const char *feat_name = g_type_name(G_OBJECT_TYPE(curfeat));
177
178 if ((newfeat = calloc(1, sizeof (GstBinaryPluginFeature))) == NULL)
179 goto fail;
180
181 if (!feat_name || !gst_registry_binary_fill_feature(list, curfeat, newfeat, feat_name))
182 {
183 GST_ERROR("Can't fill plugin feature, aborting.");
184 goto fail;
185 }
186 }
187
188 GST_DEBUG("Found %d features in plugin \"%s\"\n", e->nfeatures, e->name);
189 return TRUE;
190
191 fail:
192 free(chk);
193 free(e);
194 return FALSE;
195}
196
197/*
198** Write the cache to file. Part of the code was taken from gstregistryxml.c
199*/
200gboolean
201gst_registry_binary_write_cache(GstRegistry *registry, const char *location)
202{
203 GList *walk;
204 char *tmp_location;
205 GstBinaryRegistryMagic *magic;
206 GstBinaryChunck *magic_chunck;
207 GList *to_write = NULL;
208
209 GST_INFO("Writing binary registry cache");
210
211 g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
212 tmp_location = g_strconcat (location, ".tmpXXXXXX", NULL);
213 registry->cache_file = g_mkstemp (tmp_location);
214 if (registry->cache_file == -1)
215 {
216 char *dir;
217
218 /* oops, I bet the directory doesn't exist */
219 dir = g_path_get_dirname (location);
220 g_mkdir_with_parents (dir, 0777);
221 g_free (dir);
222
223 registry->cache_file = g_mkstemp (tmp_location);
224 }
225
226 if (registry->cache_file == -1)
227 goto fail;
228
229 if ((magic = calloc(1, sizeof (GstBinaryRegistryMagic))) == NULL ||
230 !gst_registry_binary_initialize_magic(magic))
231 goto fail;
232
233 if ((magic_chunck = calloc(1, sizeof (GstBinaryChunck))) == NULL)
234 goto fail;
235
236 magic_chunck->data = magic;
237 magic_chunck->size = sizeof (GstBinaryRegistryMagic);
238 to_write = g_list_append(to_write, magic_chunck);
239
240 /* Iterate trough the list of plugins in the GstRegistry and adapt them to our structures */
241 for (walk = g_list_last(registry->plugins); walk; walk = g_list_previous(walk))
242 {
243 GstPlugin *plugin = GST_PLUGIN(walk->data);
244
245 if (!plugin->filename)
246 continue;
247
248 if (plugin->flags & GST_PLUGIN_FLAG_CACHED)
249 {
250 int ret;
251 struct stat statbuf;
252
253 ret = g_stat (plugin->filename, &statbuf);
254 if ((ret = g_stat (plugin->filename, &statbuf)) < 0 ||
255 plugin->file_mtime != statbuf.st_mtime ||
256 plugin->file_size != statbuf.st_size)
257 continue;
258 }
259
260 if (!gst_registry_binary_save_plugin(&to_write, registry, plugin))
261 {
262 GST_ERROR("Can't write binary plugin information for \"%s\"", plugin->filename);
263 continue; /* Try anyway */
264 }
265 }
266
267 for (walk = g_list_first(to_write); walk; walk = g_list_next(walk))
268 {
269 GstBinaryChunck *cur = walk->data;
270
271 if (!gst_registry_binary_write(registry, cur->data, cur->size))
272 {
273 free(cur->data);
274 free(cur);
275 g_list_free(to_write);
276 goto fail;
277 }
278 free(cur->data);
279 free(cur);
280 }
281 g_list_free(to_write);
282
283 if (close(registry->cache_file) < 0)
284 {
285 GST_DEBUG("Can't close registry file : %s", strerror(errno));
286 goto fail;
287 }
288
289 if (g_file_test (tmp_location, G_FILE_TEST_EXISTS)) {
290#ifdef WIN32
291 remove (location);
292#endif
293 rename (tmp_location, location);
294 }
295
296 g_free (tmp_location);
297 return TRUE;
298
299 fail:
300 g_free(tmp_location);
301 return FALSE;
302}
303
304static GstPluginFeature*
305gst_registry_binary_load_feature(GstBinaryPluginFeature *in)
306{
307 GstPluginFeature *feature;
308 GType type;
309
310 if (!in->typename || !*(in->typename))
311 return NULL;
312
313 /* GST_INFO("Plugin feature typename : %s", in->typename);*/
314
315 if (!(type = g_type_from_name(in->typename)))
316 {
317 GST_ERROR("Unknown type from typename");
318 return NULL;
319 }
320 feature = g_object_new (type, NULL);
321
322 if (!feature) {
323 GST_ERROR("Can't create feature from type");
324 return NULL;
325 }
326
327 if (!GST_IS_PLUGIN_FEATURE (feature)) {
328 /* don't really know what it is */
329 if (GST_IS_OBJECT (feature))
330 gst_object_unref (feature);
331 else
332 g_object_unref (feature);
333 return NULL;
334 }
335
336 feature->name = g_strdup(in->name);
337 feature->rank = in->rank;
338
339 if (GST_IS_ELEMENT_FACTORY(feature))
340 {
341 GstElementFactory *factory = GST_ELEMENT_FACTORY(feature);
342
343 factory->details.longname = g_strdup(in->longname);
344 factory->details.klass = g_strdup(in->class);
345 factory->details.description = g_strdup(in->description);
346 factory->details.author = g_strdup(in->author);
347
348 /* GST_INFO("Element factory : %s", factory->details.longname); */
349 }
350
351 GST_DEBUG("Added feature %p with name %s", feature, feature->name);
352 return feature;
353}
354
355/*
356** Make a new plugin from current GstBinaryPluginElement structure
357** and save it to the GstRegistry. Return an offset to the next
358** GstBinaryPluginElement structure.
359*/
360static unsigned long
361gst_registry_binary_get_binary_plugin(GstRegistry *registry, gchar *in)
362{
363 GstBinaryPluginElement *p = (GstBinaryPluginElement *) in;
364 GstPlugin *plugin = NULL;
365 GList *plugin_features = NULL;
366 GstBinaryPluginFeature *feat;
367 unsigned int i;
368 unsigned long offset;
369
370 plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
371
372 plugin->flags |= GST_PLUGIN_FLAG_CACHED;
373
374 plugin->desc.name = g_strdup(p->name);
375 plugin->desc.description= g_strdup(p->description);
376 plugin->filename = g_strdup(p->filename);
377 plugin->desc.version = g_strdup(p->version);
378 plugin->desc.license = g_strdup(p->license);
379 plugin->desc.source = g_strdup(p->source);
380 plugin->desc.package = g_strdup(p->package);
381 plugin->desc.origin = g_strdup(p->origin);
382 plugin->file_mtime = p->m32p;
383 plugin->file_size = p->size;
384 plugin->basename = g_path_get_basename (plugin->filename);
385
386 if (plugin->file_mtime < 0 || plugin->file_size < 0)
387 {
388 GST_ERROR("Plugin time or file size is not valid !");
389 g_free(plugin);
390 return -1;
391 }
392
393 if (p->nfeatures < 0)
394 {
395 GST_ERROR("The number of feature structure is not valid !");
396 gst_object_unref(plugin);
397 return -1;
398 }
399
400 for (feat = (GstBinaryPluginFeature *) (in + sizeof (GstBinaryPluginElement)), i = 0;
401 i < p->nfeatures; i++, feat++)
402 {
403 GstPluginFeature *gstfeat;
404
405 if ((gstfeat = gst_registry_binary_load_feature(feat)) == NULL)
406 {
407 g_list_free(plugin_features);
408 g_free(plugin);
409 GST_ERROR("Error while loading binary feature");
410 return -1;
411 }
412 gstfeat->plugin_name = g_strdup(plugin->desc.name);
413 plugin_features = g_list_prepend(plugin_features, gstfeat);
414 }
415
416 GST_DEBUG("Added plugin \"%s\" to global registry from binary registry", plugin->desc.name);
417 GList *g;
418
419 gst_registry_add_plugin (registry, plugin);
420 for (g = plugin_features; g; g = g_list_next (g))
421 gst_registry_add_feature (registry, GST_PLUGIN_FEATURE (g->data));
422 /* g_list_free(plugin_features); */
423
424 offset = sizeof (GstBinaryPluginElement) + p->nfeatures * sizeof (GstBinaryPluginFeature);
425 return offset;
426}
427
428
429/*
430** Read the cache and adapt it to fill GstRegistry
431*/
432gboolean
433gst_registry_binary_read_cache(GstRegistry *registry, const char *location)
434{
435 GMappedFile *mapped = NULL;
436 GTimer *timer = NULL;
437 gchar *contents = NULL;
438 gdouble seconds;
439 unsigned long offset, inc;
440 gsize size;
441
442 /* make sure these types exist */
443 GST_TYPE_ELEMENT_FACTORY;
444 GST_TYPE_TYPE_FIND_FACTORY;
445 GST_TYPE_INDEX_FACTORY;
446
447 timer = g_timer_new ();
448
449 if ((mapped = g_mapped_file_new(location, FALSE, NULL)) == NULL ||
450 (contents = g_mapped_file_get_contents(mapped)) == NULL)
451 {
452 GST_ERROR("Can't load file : %s", strerror(errno));
453 return FALSE;
454 }
455 if ((contents = gst_registry_binary_check_magic(contents)) == NULL)
456 {
457 GST_ERROR("Binary registry type not recognized (invalid magic)");
458 g_mapped_file_free(mapped);
459 return FALSE;
460 }
461
462 if ((size = g_mapped_file_get_length(mapped)) < sizeof (GstBinaryPluginElement))
463 {
464 GST_INFO("No binary plugins structure to read");
465 return TRUE; /* This is not really an error */
466 }
467
468 for (offset = inc = 0; (offset + sizeof (GstBinaryPluginElement)) < size &&
469 (inc = gst_registry_binary_get_binary_plugin(registry, contents + offset)) > 0;
470 offset += inc)
471 ; /* May want in the future to do something here */
472 if (inc < 0)
473 {
474 GST_DEBUG("Problem while reading binary registry");
475 return FALSE;
476 }
477
478 g_timer_stop (timer);
479 seconds = g_timer_elapsed (timer, NULL);
480 g_timer_destroy (timer);
481
482 GST_INFO ("loaded %s in %f seconds", location, seconds);
483
484 if (mapped)
485 g_mapped_file_free (mapped);
486 return TRUE;
487}
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h b/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h
new file mode 100644
index 0000000000..2ef24d765d
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer-0.10.36/gstregistrybinary.h
@@ -0,0 +1,194 @@
1/* GStreamer
2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wim.taymans@chello.be>
4 *
5 * gstregistry.h: Header for registry handling
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
23/* SUGGESTIONS AND TODO :
24** ====================
25** - Use a compressed registry, but would induce performance loss
26** - Encrypt the registry, for security purpose, but would also reduce performances
27** - Also have a non-mmap based cache reading (work with file descriptors)
28*/
29
30#ifndef __GST_REGISTRYBINARY_H__
31#define __GST_REGISTRYBINARY_H__
32
33#ifdef HAVE_CONFIG_H
34# include "config.h"
35#endif
36
37#include <stdio.h>
38#include <errno.h>
39#include <sys/types.h>
40#include <sys/stat.h>
41#include <dirent.h>
42#include <fcntl.h>
43#include <sys/mman.h>
44#ifdef HAVE_UNISTD_H
45#include <unistd.h>
46#endif
47
48#include <gst/gst_private.h>
49#include <gst/gstelement.h>
50#include <gst/gsttypefind.h>
51#include <gst/gsttypefindfactory.h>
52#include <gst/gsturi.h>
53#include <gst/gstinfo.h>
54#include <gst/gstenumtypes.h>
55#include <gst/gstregistry.h>
56#include <gst/gstpadtemplate.h>
57
58#include "glib-compat-private.h"
59#include <glib/gstdio.h>
60
61/* A magic, written at the beginning of the file */
62#define GST_MAGIC_BINARY_REGISTRY_STR "\xc0\xde\xf0\x0d"
63#define GST_MAGIC_BINARY_REGISTRY_LEN (4)
64#define GST_MAGIC_BINARY_VERSION_LEN (64)
65
66typedef struct _GstBinaryRegistryMagic
67{
68 char magic[GST_MAGIC_BINARY_REGISTRY_LEN];
69 char version[GST_MAGIC_BINARY_VERSION_LEN];
70} GstBinaryRegistryMagic;
71
72
73/* Used to store pointers to write */
74typedef struct _GstBinaryChunck
75{
76 void *data;
77 unsigned int size;
78} GstBinaryChunck;
79
80
81/* A structure containing (staticely) every information needed for a plugin
82**
83** Notes :
84** "nfeatures" is used to say how many GstBinaryPluginFeature structures we will have
85** right after the structure itself.
86*/
87
88/* Various lenght defines for our GstBinaryPluginElement structure
89** Note : We could eventually use smaller size
90*/
91#define GST_BINARY_REGISTRY_NAME_LEN (256)
92#define GST_BINARY_REGISTRY_DESCRIPTION_LEN (1024)
93#define GST_BINARY_REGISTRY_VERSION_LEN (64)
94#define GST_BINARY_REGISTRY_LICENSE_LEN (256)
95#define GST_BINARY_REGISTRY_SOURCE_LEN (256)
96#define GST_BINARY_REGISTRY_PACKAGE_LEN (1024)
97#define GST_BINARY_REGISTRY_ORIGIN_LEN (1024)
98
99typedef struct _GstBinaryPluginElement
100{
101 char name[GST_BINARY_REGISTRY_NAME_LEN];
102 char description[GST_BINARY_REGISTRY_DESCRIPTION_LEN];
103 char filename[_POSIX_PATH_MAX];
104 char version[GST_BINARY_REGISTRY_VERSION_LEN];
105 char license[GST_BINARY_REGISTRY_LICENSE_LEN];
106 char source[GST_BINARY_REGISTRY_SOURCE_LEN];
107 char package[GST_BINARY_REGISTRY_PACKAGE_LEN];
108 char origin[GST_BINARY_REGISTRY_ORIGIN_LEN];
109 unsigned long size;
110 unsigned long m32p;
111 unsigned int nfeatures;
112} GstBinaryPluginElement;
113
114
115/* A structure containing the plugin features
116**
117** Note :
118** "npadtemplates" is used to store the number of GstBinaryPadTemplate structures following the structure itself.
119** "ninterfaces" is used to store the number of GstBinaryInterface structures following the structure itself.
120** "nuritypes" is used to store the number of GstBinaryUriType structures following the structure itself.
121*/
122#define GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN (256)
123#define GST_BINARY_REGISTRY_TYPENAME_NAME_LEN (256)
124#define GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN (1024)
125#define GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN (512)
126#define GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN (1024)
127#define GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN (256)
128
129typedef struct _GstBinaryPluginFeature
130{
131 char typename[GST_BINARY_REGISTRY_TYPENAME_TYPENAME_LEN];
132 char name[GST_BINARY_REGISTRY_TYPENAME_NAME_LEN];
133 unsigned long rank;
134 char longname[GST_BINARY_REGISTRY_TYPENAME_LONGNAME_LEN];
135 char class[GST_BINARY_REGISTRY_TYPENAME_CLASS_LEN];
136 char description[GST_BINARY_REGISTRY_TYPENAME_DESCRIPTION_LEN];
137 char author[GST_BINARY_REGISTRY_TYPENAME_AUTHOR_LEN];
138 unsigned int npadtemplates;
139 unsigned int ninterfaces;
140 unsigned int nuritypes;
141} GstBinaryPluginFeature;
142
143
144/*
145** A structure containing the static pad templates of a plugin feature
146*/
147#define GST_BINARY_REGISTRY_PADTEMPLATE_NAME_LEN (256)
148#define GST_BINARY_REGISTRY_PADTEMPLATE_CAP_LEN (1024)
149
150typedef struct _GstBinaryPadTemplate
151{
152 char name[GST_BINARY_REGISTRY_PADTEMPLATE_NAME_LEN];
153 char cap[GST_BINARY_REGISTRY_PADTEMPLATE_CAP_LEN];
154 int direction; /* Either 0:"sink" or 1:"src" */
155 GstPadPresence presence;
156} GstBinaryPadTemplate;
157
158/*
159** A very simple structure defining the plugin feature interface string
160*/
161#define GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN (512)
162typedef struct _GstBinaryInterface
163{
164 char interface[GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN];
165 unsigned long size;
166} GstBinaryInterface;
167
168/* Uri Type */
169typedef struct _GstBinaryUriType
170{
171 GstURIType type;
172 unsigned long nuriprotocols;
173} GstBinaryUriType;
174
175/*
176** Function prototypes
177*/
178
179/* Local prototypes */
180inline static gboolean gst_registry_binary_write(GstRegistry *registry, const void *mem, const ssize_t size);
181inline static gboolean gst_registry_binary_initialize_magic(GstBinaryRegistryMagic *m);
182static gboolean gst_registry_binary_fill_feature(GList **list, GstPluginFeature *, GstBinaryPluginFeature *, const char *);
183static gboolean gst_registry_binary_save_plugin(GList **list, GstRegistry *registry, GstPlugin *plugin);
184static gchar *gst_registry_binary_check_magic(gchar *in);
185static GstPluginFeature *gst_registry_binary_load_feature(GstBinaryPluginFeature *);
186static unsigned long gst_registry_binary_get_binary_plugin(GstRegistry *registry, gchar *in);
187
188/* Exportable */
189gboolean gst_registry_binary_write_cache(GstRegistry *registry, const char *location);
190gboolean gst_registry_binary_read_cache(GstRegistry *registry, const char *location);
191
192#endif /* !__GST_REGISTRYBINARY_H__ */
193
194
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-libav.inc b/meta/recipes-multimedia/gstreamer/gstreamer1.0-libav.inc
new file mode 100644
index 0000000000..84e6e95d36
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-libav.inc
@@ -0,0 +1,32 @@
1SUMMARY = "Libav-based GStreamer 1.x plugin"
2SECTION = "multimedia"
3LICENSE = "GPLv2+ & LGPLv2+ & ( (GPLv2+ & LGPLv2.1+) | (GPLv3+ & LGPLv3+) )"
4LICENSE_FLAGS = "commercial"
5HOMEPAGE = "http://www.gstreamer.net/"
6DEPENDS = "gstreamer1.0 gstreamer1.0-plugins-base zlib bzip2"
7
8inherit autotools pkgconfig
9
10# CAUTION: Using the system libav is not recommended. Since the libav API is changing all the time,
11# compilation errors (and other, more subtle bugs) can happen. It is usually better to rely on the
12# libav copy included in the gst-libav package.
13PACKAGECONFIG ??= " orc yasm "
14PACKAGECONFIG[libav] = "--with-system-libav,,libav"
15PACKAGECONFIG[lgpl] = "--enable-lgpl,,"
16PACKAGECONFIG[yasm] = "--enable-yasm,--disable-yasm,yasm-native"
17PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
18
19
20GSTREAMER_1_0_DEBUG ?= "--disable-debug"
21
22LIBAV_EXTRA_CONFIGURE = "--with-libav-extra-configure"
23LIBAV_EXTRA_CONFIGURE_COMMON = \
24'${LIBAV_EXTRA_CONFIGURE}="${LIBAV_EXTRA_CONFIGURE_COMMON_ARG}"'
25
26EXTRA_OECONF = "${LIBAV_EXTRA_CONFIGURE_COMMON}"
27
28FILES_${PN} += "${libdir}/gstreamer-1.0/*.so"
29FILES_${PN}-dbg += "${libdir}/gstreamer-1.0/.debug"
30FILES_${PN}-dev += "${libdir}/gstreamer-1.0/*.la"
31FILES_${PN}-staticdev += "${libdir}/gstreamer-1.0/*.a"
32
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-libav/0001-Disable-yasm-for-libav-when-disable-yasm.patch b/meta/recipes-multimedia/gstreamer/gstreamer1.0-libav/0001-Disable-yasm-for-libav-when-disable-yasm.patch
new file mode 100644
index 0000000000..1d99ad1251
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-libav/0001-Disable-yasm-for-libav-when-disable-yasm.patch
@@ -0,0 +1,33 @@
1From 54bba228ea52d01fd84941d97be23c03f9862b64 Mon Sep 17 00:00:00 2001
2From: Carlos Rafael Giani <dv@pseudoterminal.org>
3Date: Sat, 6 Apr 2013 01:22:22 +0200
4Subject: [PATCH] Disable yasm for libav when --disable-yasm
5
6Upstream-Status: Inappropriate [configuration]
7
8Signed-off-by: Shane Wang <shane.wang@intel.com>
9Signed-off-by: Carlos Rafael Giani <dv@pseudoterminal.org>
10---
11 configure.ac | 4 ++++
12 1 file changed, 4 insertions(+)
13
14diff --git a/configure.ac b/configure.ac
15index 22ede88..ef3c050 100644
16--- a/configure.ac
17+++ b/configure.ac
18@@ -305,6 +305,12 @@ else
19 emblibav_configure_args="$emblibav_configure_args --enable-gpl"
20 fi
21
22+ AC_ARG_ENABLE(yasm,
23+ [AC_HELP_STRING([--disable-yasm], [disable use of yasm assembler])])
24+ if test "x$enable_yasm" = "xno"; then
25+ emblibav_configure_args="$emblibav_configure_args --disable-yasm"
26+ fi
27+
28 # if we are cross-compiling, tell libav so
29 case $host in
30 *android*)
31--
321.8.2
33
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-libav_1.4.1.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-libav_1.4.1.bb
new file mode 100644
index 0000000000..8bba8312bc
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-libav_1.4.1.bb
@@ -0,0 +1,24 @@
1include gstreamer1.0-libav.inc
2
3LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
4 file://COPYING.LIB;md5=6762ed442b3822387a51c92d928ead0d \
5 file://ext/libav/gstav.h;beginline=1;endline=18;md5=a752c35267d8276fd9ca3db6994fca9c \
6 file://gst-libs/ext/libav/LICENSE;md5=df1087a33b5cafe5e70b3452aac81515 \
7 file://gst-libs/ext/libav/COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
8 file://gst-libs/ext/libav/COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \
9 file://gst-libs/ext/libav/COPYING.LGPLv2.1;md5=bd7a443320af8c812e4c18d1b79df004 \
10 file://gst-libs/ext/libav/COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02"
11
12SRC_URI = " \
13 http://gstreamer.freedesktop.org/src/gst-libav/gst-libav-${PV}.tar.xz \
14 file://0001-Disable-yasm-for-libav-when-disable-yasm.patch \
15"
16SRC_URI[md5sum] = "ea2d636c24d7c5ae123967ef22e37c07"
17SRC_URI[sha256sum] = "fc125521187fa84f3210269a0eecc51f8a856802f1ca4bb251f118dab90c5a9d"
18LIBAV_EXTRA_CONFIGURE_COMMON_ARG = "--target-os=linux \
19 --cc='${CC}' --as='${CC}' --ld='${CC}' --nm='${NM}' --ar='${AR}' \
20 --ranlib='${RANLIB}' \
21 ${GSTREAMER_1_0_DEBUG}"
22
23S = "${WORKDIR}/gst-libav-${PV}"
24
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-libav_git.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-libav_git.bb
new file mode 100644
index 0000000000..b0e6b2ecb8
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-libav_git.bb
@@ -0,0 +1,28 @@
1DEFAULT_PREFERENCE = "-1"
2
3include gstreamer1.0-libav.inc
4
5LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
6 file://COPYING.LIB;md5=6762ed442b3822387a51c92d928ead0d \
7 file://ext/libav/gstav.h;beginline=1;endline=18;md5=a752c35267d8276fd9ca3db6994fca9c \
8 file://gst-libs/ext/libav/LICENSE;md5=23a54f59b82572c203a559346e89ed57 \
9 file://gst-libs/ext/libav/COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
10 file://gst-libs/ext/libav/COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \
11 file://gst-libs/ext/libav/COPYING.LGPLv2.1;md5=bd7a443320af8c812e4c18d1b79df004 \
12 file://gst-libs/ext/libav/COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02"
13
14SRC_URI = "git://anongit.freedesktop.org/gstreamer/gst-libav;branch=master"
15S = "${WORKDIR}/git"
16
17SRCREV = "127202d6f65584891dabf92be031f0d170b0e7f1"
18
19LIBAV_EXTRA_CONFIGURE_COMMON_ARG = "--target-os=linux \
20 --cc='${CC}' --as='${CC}' --ld='${CC}' --nm='${NM}' --ar='${AR}' \
21 ${GSTREAMER_1_0_DEBUG}"
22
23do_configure_prepend() {
24 cd ${S}
25 ./autogen.sh --noconfigure
26 cd ${B}
27}
28
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-meta-base.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-meta-base.bb
new file mode 100644
index 0000000000..3ef10c3723
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-meta-base.bb
@@ -0,0 +1,65 @@
1DESCRIPTION = "Gstreamer1.0 package groups"
2LICENSE = "MIT"
3
4inherit packagegroup
5
6COMMERCIAL_PLUGINS = "${COMMERCIAL_AUDIO_PLUGINS} ${COMMERCIAL_VIDEO_PLUGINS}"
7DEPENDS_UGLY="${@'gstreamer1.0-plugins-ugly' if 'ugly' in COMMERCIAL_PLUGINS.split('-') else ''}"
8DEPENDS_BAD="${@'gstreamer1.0-plugins-bad' if 'bad' in COMMERCIAL_PLUGINS.split('-') else ''}"
9DEPENDS = "gstreamer1.0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good ${DEPENDS_UGLY} ${DEPENDS_BAD}"
10
11PACKAGES = "\
12 gstreamer1.0-meta-base \
13 gstreamer1.0-meta-x11-base \
14 gstreamer1.0-meta-audio \
15 gstreamer1.0-meta-debug \
16 gstreamer1.0-meta-video"
17
18ALLOW_EMPTY_gstreamer1.0-meta-base = "1"
19ALLOW_EMPTY_gstreamer1.0-meta-x11-base = "1"
20ALLOW_EMPTY_gstreamer1.0-meta-audio = "1"
21ALLOW_EMPTY_gstreamer1.0-meta-debug = "1"
22ALLOW_EMPTY_gstreamer1.0-meta-video = "1"
23
24RDEPENDS_gstreamer1.0-meta-base = "\
25 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'gstreamer1.0-meta-x11-base', '', d)} \
26 gstreamer1.0 \
27 gstreamer1.0-plugins-base-playback \
28 gstreamer1.0-plugins-base-gio \
29 gstreamer1.0-plugins-base-alsa \
30 gstreamer1.0-plugins-base-volume \
31 gstreamer1.0-plugins-base-audioconvert \
32 gstreamer1.0-plugins-base-audioresample \
33 gstreamer1.0-plugins-base-typefindfunctions \
34 gstreamer1.0-plugins-base-videoscale \
35 gstreamer1.0-plugins-base-videoconvert \
36 gstreamer1.0-plugins-good-autodetect \
37 gstreamer1.0-plugins-good-souphttpsrc"
38
39RRECOMMENDS_gstreamer1.0-meta-x11-base = "\
40 gstreamer1.0-plugins-base-ximagesink \
41 gstreamer1.0-plugins-base-xvimagesink"
42
43RDEPENDS_gstreamer1.0-meta-audio = "\
44 gstreamer1.0-meta-base \
45 gstreamer1.0-plugins-base-vorbis \
46 gstreamer1.0-plugins-base-ogg \
47 gstreamer1.0-plugins-good-wavparse \
48 gstreamer1.0-plugins-good-flac \
49 ${COMMERCIAL_AUDIO_PLUGINS}"
50
51RDEPENDS_gstreamer1.0-meta-debug = "\
52 gstreamer1.0-meta-base \
53 gstreamer1.0-plugins-good-debug \
54 gstreamer1.0-plugins-base-audiotestsrc \
55 gstreamer1.0-plugins-base-videotestsrc"
56
57RDEPENDS_gstreamer1.0-meta-video = "\
58 gstreamer1.0-meta-base \
59 gstreamer1.0-plugins-good-avi \
60 gstreamer1.0-plugins-good-matroska \
61 gstreamer1.0-plugins-base-theora \
62 ${COMMERCIAL_VIDEO_PLUGINS}"
63
64RRECOMMENDS_gstreamer1.0-meta-video = "\
65 gstreamer1.0-meta-audio"
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-omx.inc b/meta/recipes-multimedia/gstreamer/gstreamer1.0-omx.inc
new file mode 100644
index 0000000000..d698904349
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-omx.inc
@@ -0,0 +1,42 @@
1SUMMARY = "OpenMAX IL plugins for GStreamer"
2SECTION = "multimedia"
3LICENSE = "LGPLv2.1"
4LICENSE_FLAGS = "commercial"
5HOMEPAGE = "http://www.gstreamer.net/"
6DEPENDS = "gstreamer1.0 gstreamer1.0-plugins-base gstreamer1.0-plugins-bad"
7RDEPENDS_${PN} = "libomxil"
8
9inherit autotools pkgconfig gettext
10
11acpaths = "-I ${S}/common/m4 -I ${S}/m4"
12
13PR = "r1"
14
15GSTREAMER_1_0_OMX_TARGET ?= "bellagio"
16GSTREAMER_1_0_OMX_CORE_NAME ?= "${libdir}/libomxil-bellagio.so.0"
17
18EXTRA_OECONF += "--disable-valgrind --with-omx-target=${GSTREAMER_1_0_OMX_TARGET}"
19
20python __anonymous () {
21 omx_target = d.getVar("GSTREAMER_1_0_OMX_TARGET", True)
22 if omx_target in ['generic', 'bellagio']:
23 srcdir = d.getVar("S", True)
24 # Bellagio headers are incomplete (they are missing the OMX_VERSION_MAJOR,#
25 # OMX_VERSION_MINOR, OMX_VERSION_REVISION, and OMX_VERSION_STEP macros);
26 # appending a directory path to gst-omx' internal OpenMAX IL headers fixes this
27 d.appendVar("CFLAGS", " -I%s/omx/openmax" % srcdir)
28 elif omx_target == "rpi":
29 # Dedicated Raspberry Pi OpenMAX IL support makes this package machine specific
30 d.setVar("PACKAGE_ARCH", d.getVar("MACHINE_ARCH", True))
31}
32
33set_omx_core_name() {
34 sed -i -e "s;^core-name=.*;core-name=${GSTREAMER_1_0_OMX_CORE_NAME};" "${D}${sysconfdir}/xdg/gstomx.conf"
35}
36do_install[postfuncs] += " set_omx_core_name "
37
38FILES_${PN} += "${libdir}/gstreamer-1.0/*.so"
39FILES_${PN}-dbg += "${libdir}/gstreamer-1.0/.debug"
40FILES_${PN}-dev += "${libdir}/gstreamer-1.0/*.la"
41FILES_${PN}-staticdev += "${libdir}/gstreamer-1.0/*.a"
42
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-omx/0001-omx-fixed-type-error-in-printf-call.patch b/meta/recipes-multimedia/gstreamer/gstreamer1.0-omx/0001-omx-fixed-type-error-in-printf-call.patch
new file mode 100644
index 0000000000..a428ac9c91
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-omx/0001-omx-fixed-type-error-in-printf-call.patch
@@ -0,0 +1,30 @@
1From f629e041e9f678fcd86ad764a15117dff63c271c Mon Sep 17 00:00:00 2001
2From: Carlos Rafael Giani <dv@pseudoterminal.org>
3Date: Sat, 27 Apr 2013 02:50:25 +0200
4Subject: [PATCH] omx: fixed type error in printf call
5
6%zu expects size_t
7
8Upstream-Status: Submitted [https://bugzilla.gnome.org/show_bug.cgi?id=699008]
9
10Signed-off-by: Carlos Rafael Giani <dv@pseudoterminal.org>
11---
12 omx/gstomx.c | 2 +-
13 1 file changed, 1 insertion(+), 1 deletion(-)
14
15diff --git a/omx/gstomx.c b/omx/gstomx.c
16index a2945ed..1eca7cc 100644
17--- a/omx/gstomx.c
18+++ b/omx/gstomx.c
19@@ -1630,7 +1630,7 @@ gst_omx_port_allocate_buffers_unlocked (GstOMXPort * port,
20
21 GST_INFO_OBJECT (comp->parent,
22 "Allocating %d buffers of size %zu for %s port %u", n,
23- port->port_def.nBufferSize, comp->name, (guint) port->index);
24+ (size_t) (port->port_def.nBufferSize), comp->name, (guint) port->index);
25
26 if (!port->buffers)
27 port->buffers = g_ptr_array_sized_new (n);
28--
291.7.9.5
30
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-omx_1.2.0.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-omx_1.2.0.bb
new file mode 100644
index 0000000000..fe7c91cb30
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-omx_1.2.0.bb
@@ -0,0 +1,12 @@
1include gstreamer1.0-omx.inc
2
3LIC_FILES_CHKSUM = "file://COPYING;md5=4fbd65380cdd255951079008b364516c \
4 file://omx/gstomx.h;beginline=1;endline=21;md5=5c8e1fca32704488e76d2ba9ddfa935f"
5
6SRC_URI = "http://gstreamer.freedesktop.org/src/gst-omx/gst-omx-${PV}.tar.xz"
7
8SRC_URI[md5sum] = "d24e8c0153c35dfefee3e26b1c2c35f8"
9SRC_URI[sha256sum] = "0b4874961e6488ad9e5808114bd486ea981c540907262caab1419355fd82d745"
10
11S = "${WORKDIR}/gst-omx-${PV}"
12
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-omx_git.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-omx_git.bb
new file mode 100644
index 0000000000..931a7fcc96
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-omx_git.bb
@@ -0,0 +1,21 @@
1DEFAULT_PREFERENCE = "-1"
2
3include gstreamer1.0-omx.inc
4
5LIC_FILES_CHKSUM = "file://COPYING;md5=4fbd65380cdd255951079008b364516c \
6 file://omx/gstomx.h;beginline=1;endline=21;md5=5c8e1fca32704488e76d2ba9ddfa935f"
7
8SRC_URI = " \
9 git://anongit.freedesktop.org/gstreamer/gst-omx;branch=master \
10 file://0001-omx-fixed-type-error-in-printf-call.patch \
11 "
12S = "${WORKDIR}/git"
13
14SRCREV = "a2db76b048db278ef0aa798e106b7594264e06c0"
15
16do_configure_prepend() {
17 cd ${S}
18 ./autogen.sh --noconfigure
19 cd ${B}
20}
21
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad.inc b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad.inc
new file mode 100644
index 0000000000..dab0bf54a6
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad.inc
@@ -0,0 +1,134 @@
1require gstreamer1.0-plugins.inc
2
3LICENSE = "GPLv2+ & LGPLv2+ & LGPLv2.1+ "
4
5DEPENDS += "gstreamer1.0-plugins-base bzip2 libpng jpeg"
6
7S = "${WORKDIR}/gst-plugins-bad-${PV}"
8
9SRC_URI += "file://configure-allow-to-disable-libssh2.patch \
10 "
11
12inherit gettext
13
14# opengl packageconfig factored out to make it easy for distros
15# and BSP layers to pick either (desktop) opengl, gles2, or no GL
16PACKAGECONFIG_GL ?= "${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'gles2', '', d)}"
17
18PACKAGECONFIG ??= " \
19 ${PACKAGECONFIG_GL} \
20 ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland', '', d)} \
21 ${@bb.utils.contains('DISTRO_FEATURES', 'bluetooth', 'bluez', '', d)} \
22 ${@bb.utils.contains('DISTRO_FEATURES', 'directfb', 'directfb', '', d)} \
23 orc curl uvch264 neon sndfile \
24 hls sbc dash bz2 smoothstreaming \
25 "
26
27# dash = Dynamic Adaptive Streaming over HTTP
28PACKAGECONFIG[assrender] = "--enable-assrender,--disable-assrender,libass"
29PACKAGECONFIG[curl] = "--enable-curl,--disable-curl,curl"
30PACKAGECONFIG[gles2] = "--enable-gles2 --enable-egl,--disable-gles2 --disable-egl,virtual/libgles2 virtual/egl"
31PACKAGECONFIG[opengl] = "--enable-opengl,--disable-opengl,virtual/libgl libglu"
32PACKAGECONFIG[faac] = "--enable-faac,--disable-faac,faac"
33PACKAGECONFIG[faad] = "--enable-faad,--disable-faad,faad2"
34PACKAGECONFIG[libmms] = "--enable-libmms,--disable-libmms,libmms"
35PACKAGECONFIG[modplug] = "--enable-modplug,--disable-modplug,libmodplug"
36PACKAGECONFIG[mpg123] = "--enable-mpg123,--disable-mpg123,mpg123"
37PACKAGECONFIG[opus] = "--enable-opus,--disable-opus,libopus"
38PACKAGECONFIG[flite] = "--enable-flite,--disable-flite,flite-alsa"
39PACKAGECONFIG[opencv] = "--enable-opencv,--disable-opencv,opencv"
40PACKAGECONFIG[wayland] = "--enable-wayland,--disable-wayland,wayland"
41PACKAGECONFIG[uvch264] = "--enable-uvch264,--disable-uvch264,libusb1 udev"
42PACKAGECONFIG[directfb] = "--enable-directfb,--disable-directfb,directfb"
43PACKAGECONFIG[neon] = "--enable-neon,--disable-neon,neon"
44PACKAGECONFIG[openal] = "--enable-openal,--disable-openal,openal-soft"
45PACKAGECONFIG[hls] = "--enable-hls,--disable-hls,gnutls"
46PACKAGECONFIG[sbc] = "--enable-sbc,--disable-sbc,sbc"
47PACKAGECONFIG[dash] = "--enable-dash,--disable-dash,libxml2"
48PACKAGECONFIG[bz2] = "--enable-bz2,--disable-bz2,bzip2"
49PACKAGECONFIG[fluidsynth] = "--enable-fluidsynth,--disable-fluidsynth,fluidsynth"
50PACKAGECONFIG[schroedinger] = "--enable-schro,--disable-schro,schroedinger"
51PACKAGECONFIG[smoothstreaming] = "--enable-smoothstreaming,--disable-smoothstreaming,libxml2"
52PACKAGECONFIG[bluez] = "--enable-bluez,--disable-bluez,bluez4"
53PACKAGECONFIG[rsvg] = "--enable-rsvg,--disable-rsvg,librsvg"
54PACKAGECONFIG[sndfile] = "--enable-sndfile,--disable-sndfile,libsndfile1"
55PACKAGECONFIG[webp] = "--enable-webp,--disable-webp,libwebp"
56PACKAGECONFIG[rtmp] = "--enable-rtmp,--disable-rtmp,rtmpdump"
57PACKAGECONFIG[libssh2] = "--enable-libssh2,--disable-libssh2,libssh2"
58
59# these plugins have not been ported to 1.0 (yet):
60# directdraw vcd apexsink dc1394 lv2 linsys musepack mythtv
61# nas timidity teletextdec sdl xvid wininet acm gsettings
62# sndio qtwrapper cdxaparse dccp faceoverlay hdvparse tta
63# mve nuvdemux osx_video patchdetect quicktime real sdi
64# videomeasure gsettings
65
66# these plugins have no corresponding library in OE-core or meta-openembedded:
67# openni2 winks direct3d directdraw directsound winscreencap osx_video
68# apple_media android_media avc chromaprint daala dts gme gsm kate ladspa mimic
69# mpeg2enc mplex ofa openjpeg opensles pvr resindvd rtmp soundtouch spandsp spc
70# srtp vdpau voaacenc voamrwbenc wasapi zbar
71
72EXTRA_OECONF += " \
73 --enable-dvb \
74 --enable-shm \
75 --enable-fbdev \
76 --enable-decklink \
77 --disable-acm \
78 --disable-android_media \
79 --disable-apexsink \
80 --disable-apple_media \
81 --disable-avc \
82 --disable-chromaprint \
83 --disable-daala \
84 --disable-dc1394 \
85 --disable-direct3d \
86 --disable-directdraw \
87 --disable-directsound \
88 --disable-dts \
89 --disable-gme \
90 --disable-gsettings \
91 --disable-gsm \
92 --disable-kate \
93 --disable-ladspa \
94 --disable-linsys \
95 --disable-lv2 \
96 --disable-mimic \
97 --disable-mpeg2enc \
98 --disable-mplex \
99 --disable-musepack \
100 --disable-mythtv \
101 --disable-nas \
102 --disable-ofa \
103 --disable-openjpeg \
104 --disable-opensles \
105 --disable-osx_video \
106 --disable-pvr \
107 --disable-quicktime \
108 --disable-resindvd \
109 --disable-sdl \
110 --disable-sdltest \
111 --disable-sndio \
112 --disable-soundtouch \
113 --disable-spandsp \
114 --disable-spc \
115 --disable-srtp \
116 --disable-teletextdec \
117 --disable-timidity \
118 --disable-vcd \
119 --disable-vdpau \
120 --disable-voaacenc \
121 --disable-voamrwbenc \
122 --disable-wasapi \
123 --disable-wildmidi \
124 --disable-wininet \
125 --disable-winscreencap \
126 --disable-xvid \
127 --disable-zbar \
128 ${GSTREAMER_1_0_ORC} \
129 "
130
131ARM_INSTRUCTION_SET = "arm"
132
133FILES_gstreamer1.0-plugins-bad-opencv += "${datadir}/gst-plugins-bad/1.0/opencv*"
134
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0001-gl-do-not-check-for-GL-GLU-EGL-GLES2-libs-if-disable.patch b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0001-gl-do-not-check-for-GL-GLU-EGL-GLES2-libs-if-disable.patch
new file mode 100644
index 0000000000..042a32c04d
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0001-gl-do-not-check-for-GL-GLU-EGL-GLES2-libs-if-disable.patch
@@ -0,0 +1,41 @@
1From deba0da45ec821209a7ed148a4521d562e6512cd Mon Sep 17 00:00:00 2001
2From: Carlos Rafael Giani <dv@pseudoterminal.org>
3Date: Wed, 27 Aug 2014 14:47:25 +0200
4Subject: [PATCH] gl: do not check for GL/GLU/EGL/GLES2 libs if disabled in
5 configuration
6
7Upstream-Status: Submitted [https://bugzilla.gnome.org/show_bug.cgi?id=735522]
8
9Signed-off-by: Carlos Rafael Giani <dv@pseudoterminal.org>
10---
11 configure.ac | 14 ++++++++++----
12 1 file changed, 10 insertions(+), 4 deletions(-)
13
14diff --git a/configure.ac b/configure.ac
15index 1a46afb..e85d4ba 100644
16--- a/configure.ac
17+++ b/configure.ac
18@@ -661,10 +661,16 @@ case $host in
19 fi
20 ;;
21 *)
22- AG_GST_CHECK_LIBHEADER(GL, GL, glTexImage2D,, GL/gl.h)
23- AG_GST_CHECK_LIBHEADER(GLU, GLU, gluSphere,, GL/glu.h)
24- AG_GST_CHECK_LIBHEADER(GLES2, GLESv2, glTexImage2D,, GLES2/gl2.h)
25- AG_GST_CHECK_LIBHEADER(EGL, EGL, eglGetError,, EGL/egl.h)
26+ if test "x$NEED_GL" != "xno"; then
27+ AG_GST_CHECK_LIBHEADER(GL, GL, glTexImage2D,, GL/gl.h)
28+ AG_GST_CHECK_LIBHEADER(GLU, GLU, gluSphere,, GL/glu.h)
29+ fi
30+ if test "x$NEED_GLES2" != "xno"; then
31+ AG_GST_CHECK_LIBHEADER(GLES2, GLESv2, glTexImage2D,, GLES2/gl2.h)
32+ fi
33+ if test "x$NEED_EGL" != "xno"; then
34+ AG_GST_CHECK_LIBHEADER(EGL, EGL, eglGetError,, EGL/egl.h)
35+ fi
36
37 old_LIBS=$LIBS
38 old_CFLAGS=$CFLAGS
39--
401.8.3.2
41
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/configure-allow-to-disable-libssh2.patch b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/configure-allow-to-disable-libssh2.patch
new file mode 100644
index 0000000000..d52afd5d57
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/configure-allow-to-disable-libssh2.patch
@@ -0,0 +1,64 @@
1From f59c5269f92d59a5296cbfeeb682d42095cd88ad Mon Sep 17 00:00:00 2001
2From: Wenzong Fan <wenzong.fan@windriver.com>
3Date: Thu, 18 Sep 2014 02:24:07 -0400
4Subject: [PATCH] gstreamer1.0-plugins-bad: allow to disable libssh2
5
6libssh2 is automatically linked to if present, this undetermined
7dependency may cause build errors like:
8
9 .../x86_64-poky-linux/4.9.0/ld: cannot find -lssh2
10
11libssh2 isn't an oe-core recipe, so allow to disable it from
12configure.
13
14Upstream-Status: Pending
15
16Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
17---
18 configure.ac | 23 +++++++++++++++++------
19 1 file changed, 17 insertions(+), 6 deletions(-)
20
21diff --git a/configure.ac b/configure.ac
22index 0e95c5c..12153b4 100644
23--- a/configure.ac
24+++ b/configure.ac
25@@ -1901,6 +1901,15 @@ AG_GST_CHECK_FEATURE(CHROMAPRINT, [chromaprint], chromaprint, [
26 ])
27
28 dnl *** Curl ***
29+AC_ARG_ENABLE([libssh2],
30+ [ --enable-libssh2 enable LIBSSH2 support @<:@default=auto@:>@],
31+ [case "${enableval}" in
32+ yes) NEED_SSH2=yes ;;
33+ no) NEED_SSH2=no ;;
34+ auto) NEED_SSH2=auto ;;
35+ *) AC_MSG_ERROR([bad value ${enableval} for --enable-libssh2]) ;;
36+ esac],[NEED_SSH2=auto])
37+
38 translit(dnm, m, l) AM_CONDITIONAL(USE_CURL, true)
39 AG_GST_CHECK_FEATURE(CURL, [Curl plugin], curl, [
40 PKG_CHECK_MODULES(CURL, libcurl >= 7.21.0, [
41@@ -1915,12 +1924,14 @@ AG_GST_CHECK_FEATURE(CURL, [Curl plugin], curl, [
42 ])
43 AC_SUBST(CURL_CFLAGS)
44 AC_SUBST(CURL_LIBS)
45- PKG_CHECK_MODULES(SSH2, libssh2 >= 1.4.3, [
46- HAVE_SSH2="yes"
47- AC_DEFINE(HAVE_SSH2, 1, [Define if libssh2 is available])
48- ], [
49- HAVE_SSH2="no"
50- ])
51+ if test "x$NEED_SSH2" != "xno"; then
52+ PKG_CHECK_MODULES(SSH2, libssh2 >= 1.4.3, [
53+ HAVE_SSH2="yes"
54+ AC_DEFINE(HAVE_SSH2, 1, [Define if libssh2 is available])
55+ ], [
56+ HAVE_SSH2="no"
57+ ])
58+ fi
59 AM_CONDITIONAL(USE_SSH2, test "x$HAVE_SSH2" = "xyes")
60 AC_SUBST(SSH2_CFLAGS)
61 AC_SUBST(SSH2_LIBS)
62--
631.7.9.5
64
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.4.1.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.4.1.bb
new file mode 100644
index 0000000000..f0116c08a1
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.4.1.bb
@@ -0,0 +1,13 @@
1include gstreamer1.0-plugins-bad.inc
2
3LIC_FILES_CHKSUM = "file://COPYING;md5=73a5855a8119deb017f5f13cf327095d \
4 file://gst/tta/filters.h;beginline=12;endline=29;md5=8a08270656f2f8ad7bb3655b83138e5a \
5 file://COPYING.LIB;md5=21682e4e8fea52413fd26c60acb907e5 \
6 file://gst/tta/crc32.h;beginline=12;endline=29;md5=27db269c575d1e5317fffca2d33b3b50"
7
8SRC_URI += "file://0001-gl-do-not-check-for-GL-GLU-EGL-GLES2-libs-if-disable.patch"
9
10SRC_URI[md5sum] = "20cb190b18dc63017326321cdb7c91e5"
11SRC_URI[sha256sum] = "0268db2faaf0bb22e5b709a11633abbca4f3d289b1f513bb262d0bf3f53e19ae"
12S = "${WORKDIR}/gst-plugins-bad-${PV}"
13
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_git.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_git.bb
new file mode 100644
index 0000000000..75859f9a89
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_git.bb
@@ -0,0 +1,27 @@
1DEFAULT_PREFERENCE = "-1"
2
3include gstreamer1.0-plugins-bad.inc
4
5LIC_FILES_CHKSUM = "file://COPYING;md5=73a5855a8119deb017f5f13cf327095d \
6 file://gst/tta/filters.h;beginline=12;endline=29;md5=8a08270656f2f8ad7bb3655b83138e5a \
7 file://COPYING.LIB;md5=21682e4e8fea52413fd26c60acb907e5 \
8 file://gst/tta/crc32.h;beginline=12;endline=29;md5=27db269c575d1e5317fffca2d33b3b50"
9
10S = "${WORKDIR}/git"
11
12SRCREV = "6e5db57d2446a753aaa76bee268e1f95600b14ce"
13
14PACKAGECONFIG[bluez] = "--enable-bluez,--disable-bluez,bluez4"
15PACKAGECONFIG[sbc] = "--enable-sbc,--disable-sbc,sbc"
16PACKAGECONFIG[hls] = "--enable-hls,--disable-hls,gnutls"
17
18EXTRA_OECONF += " \
19 -disable-openjpeg \
20 "
21
22do_configure_prepend() {
23 cd ${S}
24 ./autogen.sh --noconfigure
25 cd ${B}
26}
27
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base.inc b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base.inc
new file mode 100644
index 0000000000..972ff18160
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base.inc
@@ -0,0 +1,40 @@
1require gstreamer1.0-plugins.inc
2
3LICENSE = "GPLv2+ & LGPLv2+"
4
5DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'virtual/libx11 libxv', '', d)}"
6DEPENDS += "freetype liboil util-linux"
7
8inherit gettext
9
10PACKAGES_DYNAMIC =+ "^libgst.*"
11
12PACKAGECONFIG ??= " \
13 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)} \
14 ${@bb.utils.contains('DISTRO_FEATURES', 'alsa', 'alsa', '', d)} \
15 orc ivorbis ogg theora vorbis \
16 "
17
18X11DEPENDS = "virtual/libx11 libsm libxrender"
19X11ENABLEOPTS = "--enable-x --enable-xvideo --enable-xshm"
20X11DISABLEOPTS = "--disable-x --disable-xvideo --disable-xshm"
21PACKAGECONFIG[x11] = "${X11ENABLEOPTS},${X11DISABLEOPTS},${X11DEPENDS}"
22PACKAGECONFIG[alsa] = "--enable-alsa,--disable-alsa,alsa-lib"
23PACKAGECONFIG[ivorbis] = "--enable-ivorbis,--disable-ivorbis,tremor"
24PACKAGECONFIG[ogg] = "--enable-ogg,--disable-ogg,libogg"
25PACKAGECONFIG[theora] = "--enable-theora,--disable-theora,libtheora"
26PACKAGECONFIG[vorbis] = "--enable-vorbis,--disable-vorbis,libvorbis"
27PACKAGECONFIG[pango] = "--enable-pango,--disable-pango,pango"
28
29
30# cdparanoia and libvisual do not seem to exist anywhere in OE
31EXTRA_OECONF += " \
32 --disable-freetypetest \
33 --disable-cdparanoia \
34 --disable-libvisual \
35 ${GSTREAMER_1_0_ORC} \
36"
37
38FILES_${PN} += "${datadir}/gst-plugins-base"
39
40CACHED_CONFIGUREVARS_append_i586 = " ac_cv_header_emmintrin_h=no ac_cv_header_xmmintrin_h=no"
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/do-not-change-eos-event-to-gap-event-if.patch b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/do-not-change-eos-event-to-gap-event-if.patch
new file mode 100644
index 0000000000..0407a30f90
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/do-not-change-eos-event-to-gap-event-if.patch
@@ -0,0 +1,37 @@
1From b608d027fff6efc2d1988ebf169cbe3b2b44a61b Mon Sep 17 00:00:00 2001
2From: zhouming <b42586@freescale.com>
3Date: Thu, 8 May 2014 12:01:17 +0800
4Subject: [PATCH] ENGR00312034: do not change eos event to gap event if no
5 data has passed to streamsynchronizer.
6
7https://bugzilla.gnome.org/show_bug.cgi?id=727074
8
9Upstream Status: Pending
10
11Signed-off-by: zhouming <b42586@freescale.com>
12---
13 gst/playback/gststreamsynchronizer.c | 5 ++---
14 1 file changed, 2 insertions(+), 3 deletions(-)
15
16diff --git a/gst/playback/gststreamsynchronizer.c b/gst/playback/gststreamsynchronizer.c
17index 3997d1b..3e17c55 100644
18--- a/gst/playback/gststreamsynchronizer.c
19+++ b/gst/playback/gststreamsynchronizer.c
20@@ -488,12 +488,11 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent,
21 }
22 g_slist_free (pads);
23 } else {
24- /* if EOS, but no data has passed, then send something to replace EOS
25- * for preroll purposes */
26+ /* if EOS, but no data has passed, then send EOS event */
27 if (!seen_data) {
28 GstEvent *gap_event;
29
30- gap_event = gst_event_new_gap (timestamp, GST_CLOCK_TIME_NONE);
31+ gap_event = gst_event_new_eos ();
32 ret = gst_pad_push_event (srcpad, gap_event);
33 } else {
34 GstEvent *gap_event;
35--
361.7.9.5
37
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/get-caps-from-src-pad-when-query-caps.patch b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/get-caps-from-src-pad-when-query-caps.patch
new file mode 100644
index 0000000000..0fc561c012
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/get-caps-from-src-pad-when-query-caps.patch
@@ -0,0 +1,44 @@
1From af0dac26f62aaceb4bf266720911953793e0fc5d Mon Sep 17 00:00:00 2001
2From: zhouming <b42586@freescale.com>
3Date: Wed, 14 May 2014 10:16:20 +0800
4Subject: [PATCH] ENGR00312515: get caps from src pad when query caps
5
6https://bugzilla.gnome.org/show_bug.cgi?id=728312
7
8Upstream Status: Pending
9
10Signed-off-by: zhouming <b42586@freescale.com>
11---
12 gst-libs/gst/tag/gsttagdemux.c | 13 +++++++++++++
13 1 file changed, 13 insertions(+)
14 mode change 100644 => 100755 gst-libs/gst/tag/gsttagdemux.c
15
16diff --git a/gst-libs/gst/tag/gsttagdemux.c b/gst-libs/gst/tag/gsttagdemux.c
17old mode 100644
18new mode 100755
19index 9b6c478..ae2294a
20--- a/gst-libs/gst/tag/gsttagdemux.c
21+++ b/gst-libs/gst/tag/gsttagdemux.c
22@@ -1708,6 +1708,19 @@ gst_tag_demux_pad_query (GstPad * pad, GstObject * parent, GstQuery * query)
23 }
24 break;
25 }
26+ case GST_QUERY_CAPS:
27+ {
28+
29+ /* We can hijack caps query if we typefind already */
30+ if (demux->priv->src_caps) {
31+ gst_query_set_caps_result (query, demux->priv->src_caps);
32+ res = TRUE;
33+ } else {
34+ res = gst_pad_query_default (pad, parent, query);
35+ }
36+ break;
37+ }
38+
39 default:
40 res = gst_pad_query_default (pad, parent, query);
41 break;
42--
431.7.9.5
44
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.4.1.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.4.1.bb
new file mode 100644
index 0000000000..0db42cec94
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.4.1.bb
@@ -0,0 +1,14 @@
1include gstreamer1.0-plugins-base.inc
2
3LIC_FILES_CHKSUM = "file://COPYING;md5=c54ce9345727175ff66d17b67ff51f58 \
4 file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=a4e1830fce078028c8f0974161272607 \
5 file://COPYING.LIB;md5=6762ed442b3822387a51c92d928ead0d \
6 "
7
8SRC_URI += "file://do-not-change-eos-event-to-gap-event-if.patch \
9 file://get-caps-from-src-pad-when-query-caps.patch \
10"
11
12SRC_URI[md5sum] = "a825628225bd0a58c0df87cdd2a5db91"
13SRC_URI[sha256sum] = "aea9e25be6691bd3cc0785d005b2b5d70ce313a2c897901680a3f7e7cab5a499"
14S = "${WORKDIR}/gst-plugins-base-${PV}"
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_git.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_git.bb
new file mode 100644
index 0000000000..fbe3a42cd7
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_git.bb
@@ -0,0 +1,19 @@
1DEFAULT_PREFERENCE = "-1"
2
3include gstreamer1.0-plugins-base.inc
4
5LIC_FILES_CHKSUM = "file://COPYING;md5=c54ce9345727175ff66d17b67ff51f58 \
6 file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=a4e1830fce078028c8f0974161272607 \
7 file://COPYING.LIB;md5=6762ed442b3822387a51c92d928ead0d \
8 "
9
10S = "${WORKDIR}/git"
11
12SRCREV = "8d4cb64a4b9d84b10076bf350f80a0d6ea68ec2d"
13
14do_configure_prepend() {
15 cd ${S}
16 ./autogen.sh --noconfigure
17 cd ${B}
18}
19
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good.inc b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good.inc
new file mode 100644
index 0000000000..b33ab2b705
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good.inc
@@ -0,0 +1,57 @@
1require gstreamer1.0-plugins.inc
2
3LICENSE = "GPLv2+ & LGPLv2.1+"
4
5# libid3tag
6DEPENDS += "gstreamer1.0-plugins-base zlib bzip2 libcap"
7
8inherit gettext
9
10
11PACKAGECONFIG ??= " \
12 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)} \
13 ${@bb.utils.contains('DISTRO_FEATURES', 'pulseaudio', 'pulseaudio', '', d)} \
14 orc cairo flac gdk-pixbuf gudev jpeg libpng soup speex taglib \
15 "
16
17X11DEPENDS = "virtual/libx11 libsm libxrender libxfixes libxdamage"
18X11ENABLEOPTS = "--enable-x --enable-xshm"
19X11DISABLEOPTS = "--disable-x --disable-xshm"
20PACKAGECONFIG[x11] = "${X11ENABLEOPTS},${X11DISABLEOPTS},${X11DEPENDS}"
21PACKAGECONFIG[pulseaudio] = "--enable-pulse,--disable-pulse,pulseaudio"
22PACKAGECONFIG[cairo] = "--enable-cairo,--disable-cairo,cairo"
23PACKAGECONFIG[flac] = "--enable-flac,--disable-flac,flac"
24PACKAGECONFIG[gdk-pixbuf] = "--enable-gdk_pixbuf,--disable-gdk_pixbuf,gdk-pixbuf"
25PACKAGECONFIG[gudev] = "--with-gudev,--without-gudev,udev"
26PACKAGECONFIG[jack] = "--enable-jack,--disable-jack,jack"
27PACKAGECONFIG[jpeg] = "--enable-jpeg,--disable-jpeg,jpeg"
28PACKAGECONFIG[libpng] = "--enable-libpng,--disable-libpng,libpng"
29PACKAGECONFIG[soup] = "--enable-soup,--disable-soup,libsoup-2.4"
30PACKAGECONFIG[speex] = "--enable-speex,--disable-speex,speex"
31PACKAGECONFIG[taglib] = "--enable-taglib,--disable-taglib,taglib"
32PACKAGECONFIG[vpx] = "--enable-vpx,--disable-vpx,libvpx"
33PACKAGECONFIG[wavpack] = "--enable-wavpack,--disable-wavpack,wavpack"
34
35# the 1394 plugins require both libraw1394 and libiec61883
36# the former is included in meta-oe, the latter isn't
37# -> disabled
38
39EXTRA_OECONF += " \
40 --enable-oss \
41 --enable-gst_v4l2 \
42 --without-libv4l2 \
43 --disable-directsound \
44 --disable-waveform \
45 --disable-oss4 \
46 --disable-sunaudio \
47 --disable-osx_audio \
48 --disable-osx_video \
49 --disable-aalib \
50 --disable-libcaca \
51 --disable-libdv \
52 --disable-shout2 \
53 --disable-examples \
54 --disable-dv1394 \
55 ${GSTREAMER_1_0_ORC} \
56"
57
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good/0001-gstrtpmp4gpay-set-dafault-value-for-MPEG4-without-co.patch b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good/0001-gstrtpmp4gpay-set-dafault-value-for-MPEG4-without-co.patch
new file mode 100755
index 0000000000..53147df42b
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good/0001-gstrtpmp4gpay-set-dafault-value-for-MPEG4-without-co.patch
@@ -0,0 +1,62 @@
1From c782a30482908a4b4dd9cd4abff9f9bc4016698f Mon Sep 17 00:00:00 2001
2From: Song Bing <b06498@freescale.com>
3Date: Tue, 5 Aug 2014 14:40:46 +0800
4Subject: [PATCH] gstrtpmp4gpay: set dafault value for MPEG4 without codec
5 data in caps.
6
7https://bugzilla.gnome.org/show_bug.cgi?id=734263
8
9Upstream Status: Submitted
10
11Signed-off-by: Song Bing <b06498@freescale.com>
12---
13 gst/rtp/gstrtpmp4gpay.c | 19 ++++++++++++++++++-
14 1 file changed, 18 insertions(+), 1 deletion(-)
15
16diff --git a/gst/rtp/gstrtpmp4gpay.c b/gst/rtp/gstrtpmp4gpay.c
17index 7913d9a..1749d39 100644
18--- a/gst/rtp/gstrtpmp4gpay.c
19+++ b/gst/rtp/gstrtpmp4gpay.c
20@@ -390,6 +390,7 @@ gst_rtp_mp4g_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
21 const GValue *codec_data;
22 const gchar *media_type = NULL;
23 gboolean res;
24+ const gchar *name;
25
26 rtpmp4gpay = GST_RTP_MP4G_PAY (payload);
27
28@@ -400,7 +401,6 @@ gst_rtp_mp4g_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
29 GST_LOG_OBJECT (rtpmp4gpay, "got codec_data");
30 if (G_VALUE_TYPE (codec_data) == GST_TYPE_BUFFER) {
31 GstBuffer *buffer;
32- const gchar *name;
33
34 buffer = gst_value_get_buffer (codec_data);
35 GST_LOG_OBJECT (rtpmp4gpay, "configuring codec_data");
36@@ -426,6 +426,23 @@ gst_rtp_mp4g_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
37
38 rtpmp4gpay->config = gst_buffer_copy (buffer);
39 }
40+ } else {
41+ name = gst_structure_get_name (structure);
42+
43+ if (!strcmp (name, "video/mpeg")) {
44+ rtpmp4gpay->profile = g_strdup ("1");
45+
46+ /* fixed rate */
47+ rtpmp4gpay->rate = 90000;
48+ /* video stream type */
49+ rtpmp4gpay->streamtype = "4";
50+ /* no params for video */
51+ rtpmp4gpay->params = NULL;
52+ /* mode */
53+ rtpmp4gpay->mode = "generic";
54+
55+ media_type = "video";
56+ }
57 }
58 if (media_type == NULL)
59 goto config_failed;
60--
611.7.9.5
62
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_1.4.1.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_1.4.1.bb
new file mode 100644
index 0000000000..441dd51e39
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_1.4.1.bb
@@ -0,0 +1,12 @@
1include gstreamer1.0-plugins-good.inc
2
3LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
4 file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=a4e1830fce078028c8f0974161272607 \
5 file://gst/replaygain/rganalysis.c;beginline=1;endline=23;md5=b60ebefd5b2f5a8e0cab6bfee391a5fe"
6
7SRC_URI += "file://0001-gstrtpmp4gpay-set-dafault-value-for-MPEG4-without-co.patch \
8"
9SRC_URI[md5sum] = "eb3a3296b2f6009def1f5a09590ce767"
10SRC_URI[sha256sum] = "8559d4270065b30ed5c49b826e1b7a3a2bd5ee9a340ae745a2ae3f9718e4c637"
11S = "${WORKDIR}/gst-plugins-good-${PV}"
12
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_git.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_git.bb
new file mode 100644
index 0000000000..2c0e0efe68
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-good_git.bb
@@ -0,0 +1,18 @@
1DEFAULT_PREFERENCE = "-1"
2
3include gstreamer1.0-plugins-good.inc
4
5LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
6 file://common/coverage/coverage-report.pl;beginline=2;endline=17;md5=a4e1830fce078028c8f0974161272607 \
7 file://gst/replaygain/rganalysis.c;beginline=1;endline=23;md5=b60ebefd5b2f5a8e0cab6bfee391a5fe"
8
9S = "${WORKDIR}/git"
10
11SRCREV = "fd0123800c8c1cf1468c0fa5d592ad0d0d8b4140"
12
13do_configure_prepend() {
14 cd ${S}
15 ./autogen.sh --noconfigure
16 cd ${B}
17}
18
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly.inc b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly.inc
new file mode 100644
index 0000000000..0dd011bf33
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly.inc
@@ -0,0 +1,31 @@
1require gstreamer1.0-plugins.inc
2
3LICENSE = "GPLv2+ & LGPLv2.1+ & LGPLv2+"
4LICENSE_FLAGS = "commercial"
5
6DEPENDS += "gstreamer1.0-plugins-base libid3tag"
7
8inherit gettext
9
10
11PACKAGECONFIG ??= " \
12 orc a52dec lame mad mpeg2dec \
13 "
14
15PACKAGECONFIG[a52dec] = "--enable-a52dec,--disable-a52dec,liba52"
16PACKAGECONFIG[cdio] = "--enable-cdio,--disable-cdio,libcdio"
17PACKAGECONFIG[dvdread] = "--enable-dvdread,--disable-dvdread,libdvdread"
18PACKAGECONFIG[lame] = "--enable-lame,--disable-lame,lame"
19PACKAGECONFIG[mad] = "--enable-mad,--disable-mad,libmad"
20PACKAGECONFIG[mpeg2dec] = "--enable-mpeg2dec,--disable-mpeg2dec,mpeg2dec"
21PACKAGECONFIG[x264] = "--enable-x264,--disable-x264,x264"
22
23
24EXTRA_OECONF += " \
25 --disable-amrnb \
26 --disable-amrwb \
27 --disable-sidplay \
28 --disable-twolame \
29 ${GSTREAMER_1_0_ORC} \
30 "
31
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly_1.4.1.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly_1.4.1.bb
new file mode 100644
index 0000000000..6d63ba62d4
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly_1.4.1.bb
@@ -0,0 +1,8 @@
1include gstreamer1.0-plugins-ugly.inc
2
3LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
4 file://tests/check/elements/xingmux.c;beginline=1;endline=21;md5=4c771b8af188724855cb99cadd390068 "
5SRC_URI[md5sum] = "316974af949ca4654efee704a0164076"
6SRC_URI[sha256sum] = "25440435ac4ed795d213f2420a0e7355e4a2e2e76d1f9d020b2073f815e8b071"
7S = "${WORKDIR}/gst-plugins-ugly-${PV}"
8
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly_git.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly_git.bb
new file mode 100644
index 0000000000..dcf5ffc3c1
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly_git.bb
@@ -0,0 +1,17 @@
1DEFAULT_PREFERENCE = "-1"
2
3include gstreamer1.0-plugins-ugly.inc
4
5LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
6 file://tests/check/elements/xingmux.c;beginline=1;endline=21;md5=4c771b8af188724855cb99cadd390068 "
7
8S = "${WORKDIR}/git"
9
10SRCREV = "06b8ac10cee85c5c304ca320997aa8f44295a66f"
11
12do_configure_prepend() {
13 cd ${S}
14 ./autogen.sh --noconfigure
15 cd ${B}
16}
17
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins.inc b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins.inc
new file mode 100644
index 0000000000..687aa2f5f4
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins.inc
@@ -0,0 +1,57 @@
1SUMMARY = "Plugins for the GStreamer multimedia framework 1.x"
2HOMEPAGE = "http://gstreamer.freedesktop.org/"
3BUGTRACKER = "https://bugzilla.gnome.org/enter_bug.cgi?product=Gstreamer"
4SECTION = "multimedia"
5DEPENDS = "gstreamer1.0"
6
7inherit autotools pkgconfig
8
9GSTREAMER_1_0_DEBUG ?= "--disable-debug"
10GSTREAMER_1_0_GIT_BRANCH ?= "master"
11EXTRA_OECONF = "--disable-valgrind ${GSTREAMER_1_0_DEBUG} --disable-examples "
12
13acpaths = "-I ${S}/common/m4 -I ${S}/m4"
14
15LIBV = "1.0"
16require gst-plugins-package.inc
17
18PACKAGECONFIG[orc] = "--enable-orc,--disable-orc,orc"
19
20PACKAGES_DYNAMIC = "^${PN}-.*"
21
22# apply gstreamer hack after Makefile.in.in in source is replaced by our version from
23# ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in, but before configure is executed
24# http://lists.linuxtogo.org/pipermail/openembedded-core/2012-November/032233.html
25oe_runconf_prepend() {
26 if [ -e ${S}/po/Makefile.in.in ]; then
27 sed -i -e "1a\\" -e 'GETTEXT_PACKAGE = @GETTEXT_PACKAGE@' ${S}/po/Makefile.in.in
28 fi
29}
30
31SRC_URI = "${@get_gst_srcuri(d)}"
32
33def get_gst_srcuri(d):
34 # check if expected prefix is present
35 prefix = "gstreamer1.0-"
36 bpn = d.getVar("BPN", True)
37 if not bpn.startswith(prefix):
38 bb.fatal('Invalid GStreamer 1.0 plugin package name "%s" : must start with "%s"' % (bpn, prefix))
39
40 # replaced prefix with "gst-", which is what is used for the tarball and repository filenames
41 gstpkg_basename = "gst-" + bpn[len(prefix):]
42 pv = d.getVar("PV", True)
43 branch = d.getVar("GSTREAMER_1_0_GIT_BRANCH", True)
44
45 if pv == "git":
46 s = "git://anongit.freedesktop.org/gstreamer/%s;branch=%s" % (gstpkg_basename, branch)
47 else:
48 s = "http://gstreamer.freedesktop.org/src/%s/%s-%s.tar.xz" % (gstpkg_basename, gstpkg_basename, pv)
49 return s
50
51delete_liblink_m4_file() {
52 # This m4 file contains nastiness which conflicts with libtool 2.2.2
53 rm "${S}/m4/lib-link.m4" || true
54}
55
56do_configure[prefuncs] += " delete_liblink_m4_file "
57
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-rtsp-server.inc b/meta/recipes-multimedia/gstreamer/gstreamer1.0-rtsp-server.inc
new file mode 100644
index 0000000000..28a9420f85
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-rtsp-server.inc
@@ -0,0 +1,14 @@
1SUMMARY = "A library on top of GStreamer for building an RTSP server"
2SECTION = "multimedia"
3LICENSE = "LGPLv2"
4HOMEPAGE = "http://cgit.freedesktop.org/gstreamer/gst-rtsp-server/"
5DEPENDS = "gstreamer1.0 libcgroup gstreamer1.0-plugins-base"
6
7PNREAL = "gst-rtsp-server"
8
9SRC_URI = "http://gstreamer.freedesktop.org/src/${PNREAL}/${PNREAL}-${PV}.tar.xz"
10
11S = "${WORKDIR}/${PNREAL}-${PV}"
12
13inherit autotools pkgconfig
14
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-rtsp-server_1.4.1.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-rtsp-server_1.4.1.bb
new file mode 100644
index 0000000000..1f34be0e8f
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-rtsp-server_1.4.1.bb
@@ -0,0 +1,6 @@
1include gstreamer1.0-rtsp-server.inc
2
3LIC_FILES_CHKSUM = "file://COPYING;md5=6762ed442b3822387a51c92d928ead0d"
4
5SRC_URI[md5sum] = "e39f8643eb363611c342d87088a29aa0"
6SRC_URI[sha256sum] = "10aeacc774e99d81607aeb2748c0a1c6736425b8ae3a9caf8db3cd0c4a08d06e"
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0.inc b/meta/recipes-multimedia/gstreamer/gstreamer1.0.inc
new file mode 100644
index 0000000000..a01c33ce5f
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0.inc
@@ -0,0 +1,27 @@
1SUMMARY = "GStreamer 1.0 multimedia framework"
2DESCRIPTION = "GStreamer is a multimedia framework for encoding and decoding video and sound. \
3It supports a wide range of formats including mp3, ogg, avi, mpeg and quicktime."
4HOMEPAGE = "http://gstreamer.freedesktop.org/"
5BUGTRACKER = "https://bugzilla.gnome.org/enter_bug.cgi?product=Gstreamer"
6SECTION = "multimedia"
7LICENSE = "LGPLv2+"
8DEPENDS = "glib-2.0 libxml2 bison-native flex-native"
9
10inherit autotools pkgconfig gettext
11
12GSTREAMER_1_DEBUG ?= "--disable-debug"
13EXTRA_OECONF = "--disable-docbook --disable-gtk-doc \
14 --disable-dependency-tracking --disable-check \
15 --disable-examples --disable-tests \
16 --disable-valgrind ${GSTREAMER_1_DEBUG} \
17 "
18
19RRECOMMENDS_${PN}_qemux86 += "kernel-module-snd-ens1370 kernel-module-snd-rawmidi"
20RRECOMMENDS_${PN}_qemux86-64 += "kernel-module-snd-ens1370 kernel-module-snd-rawmidi"
21
22CACHED_CONFIGUREVARS += "ac_cv_header_valgrind_valgrind_h=no"
23
24FILES_${PN} += " ${libdir}/gstreamer-1.0/*.so"
25FILES_${PN}-dev += " ${libdir}/gstreamer-1.0/*.la ${libdir}/gstreamer-1.0/*.a"
26FILES_${PN}-dbg += " ${libdir}/gstreamer-1.0/.debug/ ${libexecdir}/gstreamer-1.0/.debug/"
27
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0/0001-Fix-crash-with-gst-inspect.patch b/meta/recipes-multimedia/gstreamer/gstreamer1.0/0001-Fix-crash-with-gst-inspect.patch
new file mode 100644
index 0000000000..94f5cc56e8
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0/0001-Fix-crash-with-gst-inspect.patch
@@ -0,0 +1,28 @@
1From 6b26f3dbf9bf577d71534ab7410de66d06e46ba2 Mon Sep 17 00:00:00 2001
2From: Carlos Rafael Giani <dv@pseudoterminal.org>
3Date: Sat, 6 Apr 2013 23:52:11 +0200
4Subject: [PATCH] Fix crash with gst-inspect Chris Lord <chris@openedhand.com>
5
6Upstream-Status: Pending
7
8Signed-off-by: Carlos Rafael Giani <dv@pseudoterminal.org>
9---
10 tools/gst-inspect.c | 2 +-
11 1 file changed, 1 insertion(+), 1 deletion(-)
12
13diff --git a/tools/gst-inspect.c b/tools/gst-inspect.c
14index 23b7c44..b79b02e 100644
15--- a/tools/gst-inspect.c
16+++ b/tools/gst-inspect.c
17@@ -1556,7 +1556,7 @@ main (int argc, char *argv[])
18 g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
19 g_option_context_add_group (ctx, gst_init_get_option_group ());
20 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
21- g_printerr ("Error initializing: %s\n", err->message);
22+ g_printerr ("Error initializing: %s\n", err ? err->message : "(null)");
23 return -1;
24 }
25 g_option_context_free (ctx);
26--
271.8.2
28
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0_1.4.1.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0_1.4.1.bb
new file mode 100644
index 0000000000..56fc4f2083
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0_1.4.1.bb
@@ -0,0 +1,13 @@
1include gstreamer1.0.inc
2
3LIC_FILES_CHKSUM = "file://COPYING;md5=6762ed442b3822387a51c92d928ead0d \
4 file://gst/gst.h;beginline=1;endline=21;md5=e059138481205ee2c6fc1c079c016d0d"
5
6SRC_URI = " \
7 http://gstreamer.freedesktop.org/src/gstreamer/gstreamer-${PV}.tar.xz \
8 file://0001-Fix-crash-with-gst-inspect.patch \
9"
10SRC_URI[md5sum] = "bd0938d680d657249b885162f310702d"
11SRC_URI[sha256sum] = "5638f75003282135815c0077d491da11e9a884ad91d4ba6ab3cc78bae0fb452e"
12S = "${WORKDIR}/gstreamer-${PV}"
13
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0_git.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0_git.bb
new file mode 100644
index 0000000000..cb00d319a7
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0_git.bb
@@ -0,0 +1,18 @@
1DEFAULT_PREFERENCE = "-1"
2
3include gstreamer1.0.inc
4
5LIC_FILES_CHKSUM = "file://COPYING;md5=6762ed442b3822387a51c92d928ead0d \
6 file://gst/gst.h;beginline=1;endline=21;md5=e059138481205ee2c6fc1c079c016d0d"
7
8SRC_URI = "git://anongit.freedesktop.org/gstreamer/gstreamer;branch=master"
9S = "${WORKDIR}/git"
10
11SRCREV = "3b8181a8c550e74acaba4e8c55bdc649fa551dc9"
12
13do_configure_prepend() {
14 cd ${S}
15 ./autogen.sh --noconfigure
16 cd ${B}
17}
18
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb b/meta/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb
new file mode 100644
index 0000000000..f08908a216
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer_0.10.36.bb
@@ -0,0 +1,50 @@
1SUMMARY = "GStreamer multimedia framework"
2DESCRIPTION = "GStreamer is a multimedia framework for encoding and decoding video and sound. \
3It supports a wide range of formats including mp3, ogg, avi, mpeg and quicktime."
4HOMEPAGE = "http://gstreamer.freedesktop.org/"
5BUGTRACKER = "https://bugzilla.gnome.org/enter_bug.cgi?product=Gstreamer"
6SECTION = "multimedia"
7LICENSE = "LGPLv2+"
8LIC_FILES_CHKSUM = "file://COPYING;md5=55ca817ccb7d5b5b66355690e9abc605 \
9 file://gst/gst.h;beginline=1;endline=21;md5=8e5fe5e87d33a04479fde862e238eaa4"
10DEPENDS = "glib-2.0 libxml2 bison-native flex-native"
11
12PR = "r2"
13
14SRC_URI = "http://gstreamer.freedesktop.org/src/gstreamer/gstreamer-${PV}.tar.bz2 \
15 file://check_fix.patch \
16 file://gst-inspect-check-error.patch \
17 file://0001-baseparse-Fix-self-comparison-always-evaluates-to-tr.patch \
18"
19
20SRC_URI[md5sum] = "a0cf7d6877f694a1a2ad2b4d1ecb890b"
21SRC_URI[sha256sum] = "e556a529e0a8cf1cd0afd0cab2af5488c9524e7c3f409de29b5d82bb41ae7a30"
22
23inherit autotools pkgconfig gettext
24
25GSTREAMER_DEBUG ?= "--disable-debug"
26EXTRA_OECONF = "--disable-docbook --disable-gtk-doc \
27 --disable-dependency-tracking --disable-check \
28 --disable-examples --disable-tests \
29 --disable-valgrind ${GSTREAMER_DEBUG} \
30 "
31
32CACHED_CONFIGUREVARS += "ac_cv_header_valgrind_valgrind_h=no"
33
34# apply gstreamer hack after Makefile.in.in in source is replaced by our version from
35# ${STAGING_DATADIR_NATIVE}/gettext/po/Makefile.in.in, but before configure is executed
36# http://lists.linuxtogo.org/pipermail/openembedded-core/2012-November/032233.html
37oe_runconf_prepend() {
38 sed -i -e "1a\\" -e 'GETTEXT_PACKAGE = @GETTEXT_PACKAGE@' ${S}/po/Makefile.in.in
39}
40
41#do_compile_prepend () {
42# mv ${WORKDIR}/gstregistrybinary.[ch] ${S}/gst/
43#}
44
45RRECOMMENDS_${PN}_qemux86 += "kernel-module-snd-ens1370 kernel-module-snd-rawmidi"
46RRECOMMENDS_${PN}_qemux86-64 += "kernel-module-snd-ens1370 kernel-module-snd-rawmidi"
47
48FILES_${PN} += " ${libdir}/gstreamer-0.10/*.so"
49FILES_${PN}-dev += " ${libdir}/gstreamer-0.10/*.la ${libdir}/gstreamer-0.10/*.a"
50FILES_${PN}-dbg += " ${libdir}/gstreamer-0.10/.debug/ ${libexecdir}/gstreamer-0.10/.debug/"
diff --git a/meta/recipes-multimedia/lame/lame/lame-3.99.5_fix_for_automake-1.12.x.patch b/meta/recipes-multimedia/lame/lame/lame-3.99.5_fix_for_automake-1.12.x.patch
new file mode 100644
index 0000000000..571a1d07a3
--- /dev/null
+++ b/meta/recipes-multimedia/lame/lame/lame-3.99.5_fix_for_automake-1.12.x.patch
@@ -0,0 +1,59 @@
1Upstream-Status: Pending
2
3Fix this kind of errors with automake 1.12.x:
4| doc/man/Makefile.am:3: error: automatic de-ANSI-fication support has been removed
5| autoreconf: automake failed with exit status: 1
6
7Signed-Off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
82012/07/13
9
10Index: lame-3.99.5/configure.in
11===================================================================
12--- lame-3.99.5.orig/configure.in
13+++ lame-3.99.5/configure.in
14@@ -77,9 +77,6 @@ if test "${GCC}" = "yes"; then
15 AC_MSG_RESULT(${GCC_version})
16 fi
17
18-dnl more automake stuff
19-AM_C_PROTOTYPES
20-
21 AC_CHECK_HEADER(dmalloc.h)
22 if test "${ac_cv_header_dmalloc_h}" = "yes"; then
23 AM_WITH_DMALLOC
24Index: lame-3.99.5/doc/html/Makefile.am
25===================================================================
26--- lame-3.99.5.orig/doc/html/Makefile.am
27+++ lame-3.99.5/doc/html/Makefile.am
28@@ -1,6 +1,6 @@
29 ## $Id: Makefile.am,v 1.7 2010/09/30 20:58:40 jaz001 Exp $
30
31-AUTOMAKE_OPTIONS = foreign ansi2knr
32+AUTOMAKE_OPTIONS = foreign
33
34 docdir = $(datadir)/doc
35 pkgdocdir = $(docdir)/$(PACKAGE)
36Index: lame-3.99.5/libmp3lame/i386/Makefile.am
37===================================================================
38--- lame-3.99.5.orig/libmp3lame/i386/Makefile.am
39+++ lame-3.99.5/libmp3lame/i386/Makefile.am
40@@ -1,6 +1,6 @@
41 ## $Id: Makefile.am,v 1.26 2011/04/04 09:42:34 aleidinger Exp $
42
43-AUTOMAKE_OPTIONS = foreign $(top_srcdir)/ansi2knr
44+AUTOMAKE_OPTIONS = foreign
45
46 DEFS = @DEFS@ @CONFIG_DEFS@
47
48Index: lame-3.99.5/doc/man/Makefile.am
49===================================================================
50--- lame-3.99.5.orig/doc/man/Makefile.am
51+++ lame-3.99.5/doc/man/Makefile.am
52@@ -1,6 +1,6 @@
53 ## $Id: Makefile.am,v 1.1 2000/10/22 11:39:44 aleidinger Exp $
54
55-AUTOMAKE_OPTIONS = foreign ansi2knr
56+AUTOMAKE_OPTIONS = foreign
57
58 man_MANS = lame.1
59 EXTRA_DIST = ${man_MANS}
diff --git a/meta/recipes-multimedia/lame/lame/no-gtk1.patch b/meta/recipes-multimedia/lame/lame/no-gtk1.patch
new file mode 100644
index 0000000000..e88d7f1bb4
--- /dev/null
+++ b/meta/recipes-multimedia/lame/lame/no-gtk1.patch
@@ -0,0 +1,20 @@
1Upstream-Status: Inappropriate [configuration]
2
3# Acquired from OpenEmbedded
4
5--- lame-3.96.1/configure.in~no-gtk1.patch 2004-07-25 15:52:12.000000000 +0100
6+++ lame-3.96.1/configure.in 2004-09-10 15:54:39.000000000 +0100
7@@ -363,7 +363,12 @@
8
9 dnl configure use of features
10
11-AM_PATH_GTK(1.2.0, HAVE_GTK="yes", HAVE_GTK="no")
12+#AM_PATH_GTK(1.2.0, HAVE_GTK="yes", HAVE_GTK="no")
13+HAVE_GTK="no"
14+GTK_CFLAGS=""
15+GTK_LIBS=""
16+AC_SUBST(GTK_CFLAGS)
17+AC_SUBST(GTK_LIBS)
18
19 dnl ElectricFence malloc debugging
20 AC_MSG_CHECKING(use of ElectricFence malloc debugging)
diff --git a/meta/recipes-multimedia/lame/lame_3.99.5.bb b/meta/recipes-multimedia/lame/lame_3.99.5.bb
new file mode 100644
index 0000000000..d0e887271c
--- /dev/null
+++ b/meta/recipes-multimedia/lame/lame_3.99.5.bb
@@ -0,0 +1,30 @@
1SUMMARY = "High quality MP3 audio encoder"
2HOMEPAGE = "http://lame.sourceforge.net/"
3BUGTRACKER = "http://sourceforge.net/tracker/?group_id=290&atid=100290"
4SECTION = "console/utils"
5LICENSE = "LGPLv2+"
6LICENSE_FLAGS = "commercial"
7
8DEPENDS = "ncurses gettext-native"
9
10LIC_FILES_CHKSUM = "file://COPYING;md5=c46bda00ffbb0ba1dac22f8d087f54d9 \
11 file://include/lame.h;beginline=1;endline=20;md5=a2258182c593c398d15a48262130a92b \
12"
13PR = "r1"
14
15SRC_URI = "${SOURCEFORGE_MIRROR}/lame/lame-${PV}.tar.gz \
16 file://no-gtk1.patch \
17 file://lame-3.99.5_fix_for_automake-1.12.x.patch "
18
19SRC_URI[md5sum] = "84835b313d4a8b68f5349816d33e07ce"
20SRC_URI[sha256sum] = "24346b4158e4af3bd9f2e194bb23eb473c75fb7377011523353196b19b9a23ff"
21
22inherit autotools pkgconfig
23
24PACKAGES += "libmp3lame libmp3lame-dev"
25FILES_${PN} = "${bindir}/lame"
26FILES_libmp3lame = "${libdir}/libmp3lame.so.*"
27FILES_libmp3lame-dev = "${includedir} ${libdir}/*"
28FILES_${PN}-dev = ""
29
30CACHED_CONFIGUREVARS_append_i586 = " ac_cv_header_emmintrin_h=no ac_cv_header_xmmintrin_h=no"
diff --git a/meta/recipes-multimedia/liba52/liba52/buildcleanup.patch b/meta/recipes-multimedia/liba52/liba52/buildcleanup.patch
new file mode 100644
index 0000000000..5168100f3a
--- /dev/null
+++ b/meta/recipes-multimedia/liba52/liba52/buildcleanup.patch
@@ -0,0 +1,89 @@
1It makes much more sense to control our own CFLAGS and avoiding fPIC breaks
2some arches too. Assume we know what we're doing and remove all the messing
3around.
4
5RP 23/2/10
6
7Upstream-Status: Inappropriate [configuration]
8
9Index: a52dec-0.7.4/configure.in
10===================================================================
11--- a52dec-0.7.4.orig/configure.in 2010-02-23 14:51:50.000000000 +0000
12+++ a52dec-0.7.4/configure.in 2010-02-23 14:52:36.000000000 +0000
13@@ -14,62 +14,6 @@
14 AC_PROG_CC
15 AC_PROG_GCC_TRADITIONAL
16
17-if test x"$GCC" = x"yes"; then
18-
19- dnl GCC-specific flags - try to optimize them sometime
20- dnl -Wall -Werror moved to the end to not disturb the configure script
21-
22- dnl -O3
23- changequote(<<,>>)
24- OPT_CFLAGS=`echo "$CFLAGS"|sed "s/-O[0-9]*//g"`
25- changequote([,])
26- OPT_CFLAGS="$OPT_CFLAGS -O3"
27- AC_TRY_CFLAGS([$OPT_CFLAGS],[CFLAGS=$OPT_CFLAGS])
28-
29- dnl -fomit-frame-pointer
30- OPT_CFLAGS="$CFLAGS -fomit-frame-pointer"
31- AC_TRY_CFLAGS([$OPT_CFLAGS],[CFLAGS=$OPT_CFLAGS])
32-
33- dnl arch-specific flags
34- case "$host" in
35- i?86-* | k?-*)
36- case "$host" in
37- i386-*) OPT_CFLAGS="$CFLAGS -mcpu=i386";;
38- i486-*) OPT_CFLAGS="$CFLAGS -mcpu=i486";;
39- i586-*) OPT_CFLAGS="$CFLAGS -mcpu=pentium";;
40- i686-*) OPT_CFLAGS="$CFLAGS -mcpu=pentiumpro";;
41- k6-*) OPT_CFLAGS="$CFLAGS -mcpu=k6";;
42- esac
43- AC_TRY_CFLAGS([$OPT_CFLAGS],[CFLAGS=$OPT_CFLAGS]);;
44- sparc-* | sparc64-*)
45- OPT_CFLAGS="$CFLAGS -mtune=ultrasparc"
46- AC_TRY_CFLAGS([$OPT_CFLAGS],[CFLAGS=$OPT_CFLAGS]);;
47- mips-sgi-irix6.*) dnl do we need to be that specific ?
48- OPT_CFLAGS="$CFLAGS -mabi=64"
49- AC_TRY_CFLAGS([$OPT_CFLAGS],[CFLAGS=$OPT_CFLAGS]);;
50- esac
51-elif test x"$CC" = x"tcc" -a x"`$CC -version 2>&1 | grep TenDRA`" != x""; then
52- dnl TenDRA portability checking compiler
53- TENDRA=yes
54- CFLAGS="-Xp -Yansi -f`pwd`/include/tendra.h -DELIDE_CODE"
55- enable_mlib=no
56- enable_oss=no
57- enable_solaris_audio=no
58-elif test x"$CC" = x"icc" -a x"`$CC -V 2>&1 | grep Intel`" != x""; then
59- dnl Intel C++ compiler
60- CFLAGS="-g -O3 -unroll -ip"
61-else
62- dnl non-gcc flags - we probably need exact configuration triplets here.
63- case "$host" in
64- mips-sgi-irix6.*)
65- OPT_CFLAGS="$CFLAGS -64"
66- AC_TRY_CFLAGS([$OPT_CFLAGS],[CFLAGS=$OPT_CFLAGS]);;
67- sparc-sun-solaris*)
68- OPT_CFLAGS="$CFLAGS -xCC -fast -xO5"
69- AC_TRY_CFLAGS([$OPT_CFLAGS],[CFLAGS=$OPT_CFLAGS]);;
70- esac
71-fi
72-
73 dnl Checks for libtool - this must be done after we set cflags
74 AC_DISABLE_SHARED
75 AC_LIBTOOL_WIN32_DLL
76Index: a52dec-0.7.4/liba52/configure.incl
77===================================================================
78--- a52dec-0.7.4.orig/liba52/configure.incl 2010-02-23 14:51:44.000000000 +0000
79+++ a52dec-0.7.4/liba52/configure.incl 2010-02-23 14:51:59.000000000 +0000
80@@ -1,9 +1,6 @@
81 AC_SUBST([LIBA52_CFLAGS])
82 AC_SUBST([LIBA52_LIBS])
83
84-dnl avoid -fPIC when possible
85-LIBA52_CFLAGS="$LIBA52_CFLAGS -prefer-non-pic"
86-
87 AC_ARG_ENABLE([double],
88 [ --enable-double use double-precision samples])
89 if test x"$enable_double" = x"yes"; then
diff --git a/meta/recipes-multimedia/liba52/liba52_0.7.4.bb b/meta/recipes-multimedia/liba52/liba52_0.7.4.bb
new file mode 100644
index 0000000000..94b66b189e
--- /dev/null
+++ b/meta/recipes-multimedia/liba52/liba52_0.7.4.bb
@@ -0,0 +1,23 @@
1SUMMARY = "ATSC A/52 surround sound stream decoder"
2HOMEPAGE = "http://liba52.sourceforge.net/"
3LICENSE = "GPLv2+"
4LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
5 file://include/a52.h;beginline=1;endline=12;md5=81152ceb3562bf20a60d1b6018175dd1"
6SECTION = "libs"
7PR = "r4"
8
9inherit autotools
10
11SRC_URI = "http://liba52.sourceforge.net/files/a52dec-${PV}.tar.gz \
12 file://buildcleanup.patch"
13
14SRC_URI[md5sum] = "caa9f5bc44232dc8aeea773fea56be80"
15SRC_URI[sha256sum] = "a21d724ab3b3933330194353687df82c475b5dfb997513eef4c25de6c865ec33"
16S = "${WORKDIR}/a52dec-${PV}"
17
18EXTRA_OECONF = " --enable-shared "
19
20PACKAGES =+ "a52dec a52dec-doc"
21
22FILES_a52dec = " ${bindir}/* "
23FILES_a52dec-doc = " ${mandir}/man1/* "
diff --git a/meta/recipes-multimedia/libav/libav.inc b/meta/recipes-multimedia/libav/libav.inc
new file mode 100644
index 0000000000..5c327df386
--- /dev/null
+++ b/meta/recipes-multimedia/libav/libav.inc
@@ -0,0 +1,144 @@
1SUMMARY = "Open source audio and video processing tools and librairies"
2DESCRIPTION = "Libav is a friendly and community-driven effort to provide its users \
3 with a set of portable, functional and high-performance libraries for \
4 dealing with multimedia formats of all sorts. It originates from the \
5 FFmpeg codebase, but goes its own way these days, providing its users \
6 with reliable releases and a clear vision how to go forward."
7HOMEPAGE = "http://libav.org/"
8SECTION = "libs"
9
10LICENSE = "GPLv2+"
11LICENSE_FLAGS = "commercial"
12
13# Provides ffmpeg compat, see http://libav.org/about.html
14PROVIDES = "ffmpeg"
15
16ARM_INSTRUCTION_SET = "arm"
17
18DEPENDS = "zlib libogg yasm-native"
19
20INC_PR = "r8"
21
22inherit autotools pkgconfig
23
24B = "${S}/build.${HOST_SYS}.${TARGET_SYS}"
25
26FULL_OPTIMIZATION_armv7a = "-fexpensive-optimizations -fomit-frame-pointer -O4 -ffast-math"
27BUILD_OPTIMIZATION = "${FULL_OPTIMIZATION}"
28
29EXTRA_FFCONF_armv7a = "--cpu=cortex-a8"
30EXTRA_FFCONF ?= ""
31
32PACKAGECONFIG ??= "bzip2 x264 theora ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}"
33PACKAGECONFIG[bzip2] = "--enable-bzlib,--disable-bzlib,bzip2"
34PACKAGECONFIG[faac] = "--enable-libfaac,--disable-libfaac,faac"
35PACKAGECONFIG[gsm] = "--enable-libgsm,--disable-libgsm,libgsm"
36PACKAGECONFIG[jack] = "--enable-indev=jack,--disable-indev=jack,jack"
37PACKAGECONFIG[libvorbis] = "--enable-libvorbis,--disable-libvorbis,libvorbis"
38PACKAGECONFIG[mp3lame] = "--enable-libmp3lame,--disable-libmp3lame,lame"
39PACKAGECONFIG[openssl] = "--enable-openssl,--disable-openssl,openssl"
40PACKAGECONFIG[schroedinger] = "--enable-libschroedinger,--disable-libschroedinger,schroedinger"
41PACKAGECONFIG[speex] = "--enable-libspeex,--disable-libspeex,speex"
42PACKAGECONFIG[theora] = "--enable-libtheora,--disable-libtheora,libtheora"
43PACKAGECONFIG[vpx] = "--enable-libvpx,--disable-libvpx,libvpx"
44PACKAGECONFIG[x11] = "--enable-x11grab,--disable-x11grab,virtual/libx11 libxfixes libxext xproto virtual/libsdl"
45PACKAGECONFIG[x264] = "--enable-libx264,--disable-libx264,x264"
46
47# Check codecs that require --enable-nonfree
48USE_NONFREE = "${@bb.utils.contains_any('PACKAGECONFIG', [ 'faac', 'openssl' ], 'yes', '', d)}"
49
50EXTRA_OECONF = " \
51 --enable-shared \
52 --enable-pthreads \
53 --enable-gpl \
54 ${@bb.utils.contains('USE_NONFREE', 'yes', '--enable-nonfree', '', d)} \
55 --enable-avfilter \
56 \
57 --cross-prefix=${TARGET_PREFIX} \
58 --prefix=${prefix} \
59 \
60 --enable-avserver \
61 --enable-avplay \
62 --ld="${CCLD}" \
63 --arch=${TARGET_ARCH} \
64 --target-os="linux" \
65 --enable-cross-compile \
66 --extra-cflags="${TARGET_CFLAGS} ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" \
67 --extra-ldflags="${TARGET_LDFLAGS}" \
68 --sysroot="${STAGING_DIR_TARGET}" \
69 --enable-hardcoded-tables \
70 ${EXTRA_FFCONF} \
71 --libdir=${libdir} \
72 --shlibdir=${libdir} \
73"
74
75do_configure() {
76 # We don't have TARGET_PREFIX-pkgconfig
77 sed -i '/pkg_config_default="${cross_prefix}${pkg_config_default}"/d' ${S}/configure
78 mkdir -p ${B}
79 cd ${B}
80 ${S}/configure ${EXTRA_OECONF}
81 sed -i -e s:Os:O4:g ${B}/config.h
82}
83
84do_install_append() {
85 install -m 0644 ${S}/libavfilter/*.h ${D}${includedir}/libavfilter/
86}
87
88FFMPEG_LIBS = "libavcodec libavdevice libavformat \
89 libavutil libpostproc libswscale libavfilter"
90
91PACKAGES += "${PN}-vhook-dbg ${PN}-vhook ffmpeg-x264-presets"
92
93RSUGGESTS_${PN} = "mplayer"
94FILES_${PN} = "${bindir}"
95FILES_${PN}-dev = "${includedir}/${PN}"
96
97FILES_${PN}-vhook = "${libdir}/vhook"
98FILES_${PN}-vhook-dbg += "${libdir}/vhook/.debug"
99
100FILES_ffmpeg-x264-presets = "${datadir}/*.avpreset"
101
102LEAD_SONAME = "libavcodec.so"
103
104FILES_${PN}-dev = "${includedir}"
105
106python populate_packages_prepend() {
107 av_libdir = d.expand('${libdir}')
108 av_pkgconfig = d.expand('${libdir}/pkgconfig')
109
110 # Runtime package
111 do_split_packages(d, av_libdir, '^lib(.*)\.so\..*',
112 output_pattern='lib%s',
113 description='libav %s library',
114 extra_depends='',
115 prepend=True,
116 allow_links=True)
117
118 # Development packages (-dev, -staticdev)
119 do_split_packages(d, av_libdir, '^lib(.*)\.so$',
120 output_pattern='lib%s-dev',
121 description='libav %s development package',
122 extra_depends='${PN}-dev',
123 prepend=True,
124 allow_links=True)
125 do_split_packages(d, av_pkgconfig, '^lib(.*)\.pc$',
126 output_pattern='lib%s-dev',
127 description='libav %s development package',
128 extra_depends='${PN}-dev',
129 prepend=True)
130 do_split_packages(d, av_libdir, '^lib(.*)\.a$',
131 output_pattern='lib%s-staticdev',
132 description='libav %s development package - static library',
133 extra_depends='${PN}-dev',
134 prepend=True,
135 allow_links=True)
136
137 if d.getVar('TARGET_ARCH', True) == 'i586':
138 # libav can't be build with -fPIC for 32-bit x86
139 pkgs = d.getVar('PACKAGES', True).split()
140 for pkg in pkgs:
141 d.appendVar('INSANE_SKIP_%s' % pkg, ' textrel')
142}
143
144PACKAGES_DYNAMIC += "^lib(av(codec|device|filter|format|util)|postproc|swscale).*"
diff --git a/meta/recipes-multimedia/libav/libav/0001-configure-enable-pic-for-AArch64.patch b/meta/recipes-multimedia/libav/libav/0001-configure-enable-pic-for-AArch64.patch
new file mode 100644
index 0000000000..d9b22b9b6a
--- /dev/null
+++ b/meta/recipes-multimedia/libav/libav/0001-configure-enable-pic-for-AArch64.patch
@@ -0,0 +1,23 @@
1From 58db99e98f615d79ea90cac8f4bcf11c94e3e7c7 Mon Sep 17 00:00:00 2001
2From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
3Date: Thu, 10 Jan 2013 12:42:19 +0100
4Subject: [PATCH] configure: enable pic for AArch64
5
6Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
7
8Upstream-Status: Backport
9---
10 configure | 2 +-
11 1 file changed, 1 insertion(+), 1 deletion(-)
12
13--- git.orig/configure
14+++ git/configure
15@@ -2393,7 +2393,7 @@ check_host_cflags -std=c99
16 check_host_cflags -Wall
17
18 case "$arch" in
19- alpha|ia64|mips|parisc|ppc|sparc)
20+ alpha|ia64|mips|parisc|ppc|sparc|aarch64)
21 spic=$shared
22 ;;
23 x86)
diff --git a/meta/recipes-multimedia/libav/libav_0.8.15.bb b/meta/recipes-multimedia/libav/libav_0.8.15.bb
new file mode 100644
index 0000000000..18dc49a12e
--- /dev/null
+++ b/meta/recipes-multimedia/libav/libav_0.8.15.bb
@@ -0,0 +1,18 @@
1require libav.inc
2
3SRC_URI = "http://libav.org/releases/${BP}.tar.xz \
4 file://0001-configure-enable-pic-for-AArch64.patch"
5
6SRC_URI[md5sum] = "e483ea8f482b5ecd65ee1d09251b0a5b"
7SRC_URI[sha256sum] = "495789ec547e93632937f0f36b06f4dd3180bc61518181f124af6746c6218710"
8
9LIC_FILES_CHKSUM = "file://COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
10 file://COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \
11 file://COPYING.LGPLv2.1;md5=e344c8fa836c3a41c4cbd79d7bd3a379 \
12 file://COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02"
13
14PROVIDES += "libpostproc"
15
16EXTRA_OECONF += " \
17 --enable-postproc \
18"
diff --git a/meta/recipes-multimedia/libav/libav_9.16.bb b/meta/recipes-multimedia/libav/libav_9.16.bb
new file mode 100644
index 0000000000..d0468859a9
--- /dev/null
+++ b/meta/recipes-multimedia/libav/libav_9.16.bb
@@ -0,0 +1,13 @@
1require libav.inc
2
3LIC_FILES_CHKSUM = "file://COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
4 file://COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \
5 file://COPYING.LGPLv2.1;md5=bd7a443320af8c812e4c18d1b79df004 \
6 file://COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02"
7
8SRC_URI = "http://libav.org/releases/${BP}.tar.xz"
9
10SRC_URI[md5sum] = "7b44b75cec24b8e7545e5029e76917e0"
11SRC_URI[sha256sum] = "ca846473b0b8ed8e3404c52e5e92df6d35cb5fa487eec498525de3ffda4367a0"
12
13DEFAULT_PREFERENCE = "-1"
diff --git a/meta/recipes-multimedia/libid3tag/libid3tag/addpkgconfig.patch b/meta/recipes-multimedia/libid3tag/libid3tag/addpkgconfig.patch
new file mode 100644
index 0000000000..38d40c3632
--- /dev/null
+++ b/meta/recipes-multimedia/libid3tag/libid3tag/addpkgconfig.patch
@@ -0,0 +1,43 @@
1Upstream-Status: Inappropriate [configuration]
2
3Index: libid3tag-0.15.1b/Makefile.am
4===================================================================
5--- libid3tag-0.15.1b.orig/Makefile.am 2009-07-29 09:29:20.000000000 +0100
6+++ libid3tag-0.15.1b/Makefile.am 2009-07-29 09:29:47.000000000 +0100
7@@ -27,6 +27,9 @@
8 lib_LTLIBRARIES = libid3tag.la
9 include_HEADERS = id3tag.h
10
11+pkgconfigdir = $(libdir)/pkgconfig
12+pkgconfig_DATA = id3tag.pc
13+
14 ## From the libtool documentation on library versioning:
15 ##
16 ## CURRENT
17Index: libid3tag-0.15.1b/configure.ac
18===================================================================
19--- libid3tag-0.15.1b.orig/configure.ac 2009-07-29 09:27:15.000000000 +0100
20+++ libid3tag-0.15.1b/configure.ac 2009-07-29 09:27:45.000000000 +0100
21@@ -201,5 +201,5 @@
22 dnl AC_SUBST(LTLIBOBJS)
23
24 AC_CONFIG_FILES([Makefile msvc++/Makefile \
25- libid3tag.list])
26+ libid3tag.list id3tag.pc])
27 AC_OUTPUT
28Index: libid3tag-0.15.1b/id3tag.pc.in
29===================================================================
30--- /dev/null 1970-01-01 00:00:00.000000000 +0000
31+++ libid3tag-0.15.1b/id3tag.pc.in 2009-07-29 09:29:10.000000000 +0100
32@@ -0,0 +1,11 @@
33+prefix=@prefix@
34+exec_prefix=@exec_prefix@
35+libdir=@libdir@
36+includedir=@includedir@
37+
38+Name: id3tag
39+Description: ID3 tag reading library
40+Requires:
41+Version: @VERSION@
42+Libs: -L${libdir} -lid3tag -lz
43+Cflags: -I${includedir}
diff --git a/meta/recipes-multimedia/libid3tag/libid3tag/obsolete_automake_macros.patch b/meta/recipes-multimedia/libid3tag/libid3tag/obsolete_automake_macros.patch
new file mode 100644
index 0000000000..2845fb1d3a
--- /dev/null
+++ b/meta/recipes-multimedia/libid3tag/libid3tag/obsolete_automake_macros.patch
@@ -0,0 +1,15 @@
1Upstream-Status: Submitted [https://sourceforge.net/tracker/?func=detail&aid=3599280&group_id=12349&atid=112349]
2
3Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
4diff -Nurd libid3tag-0.15.1b/configure.ac libid3tag-0.15.1b/configure.ac
5--- libid3tag-0.15.1b/configure.ac 2004-01-24 01:22:46.000000000 +0200
6+++ libid3tag-0.15.1b/configure.ac 2013-01-03 06:41:02.734835014 +0200
7@@ -28,7 +28,7 @@
8
9-AM_INIT_AUTOMAKE
10+AM_INIT_AUTOMAKE([foreign])
11
12-AM_CONFIG_HEADER([config.h])
13+AC_CONFIG_HEADERS([config.h])
14
15 dnl System type.
diff --git a/meta/recipes-multimedia/libid3tag/libid3tag_0.15.1b.bb b/meta/recipes-multimedia/libid3tag/libid3tag_0.15.1b.bb
new file mode 100644
index 0000000000..05a8a47631
--- /dev/null
+++ b/meta/recipes-multimedia/libid3tag/libid3tag_0.15.1b.bb
@@ -0,0 +1,22 @@
1SUMMARY = "Library for interacting with ID3 tags in MP3 files"
2HOMEPAGE = "http://sourceforge.net/projects/mad/"
3BUGTRACKER = "http://sourceforge.net/tracker/?group_id=12349&atid=112349"
4LICENSE = "GPLv2+"
5LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
6 file://COPYRIGHT;md5=5e6279efb87c26c6e5e7a68317a6a87a \
7 file://version.h;beginline=1;endline=8;md5=86ac68b67f054b7afde9e149bbc3fe63"
8SECTION = "libs"
9DEPENDS = "zlib gperf-native"
10PR = "r7"
11
12SRC_URI = "ftp://ftp.mars.org/pub/mpeg/libid3tag-${PV}.tar.gz \
13 file://addpkgconfig.patch \
14 file://obsolete_automake_macros.patch \
15"
16
17SRC_URI[md5sum] = "e5808ad997ba32c498803822078748c3"
18SRC_URI[sha256sum] = "63da4f6e7997278f8a3fef4c6a372d342f705051d1eeb6a46a86b03610e26151"
19
20S = "${WORKDIR}/libid3tag-${PV}"
21
22inherit autotools pkgconfig
diff --git a/meta/recipes-multimedia/libmad/libmad/add-pkgconfig.patch b/meta/recipes-multimedia/libmad/libmad/add-pkgconfig.patch
new file mode 100644
index 0000000000..b49dc8c983
--- /dev/null
+++ b/meta/recipes-multimedia/libmad/libmad/add-pkgconfig.patch
@@ -0,0 +1,70 @@
1Here is a patch for adding pkg-config support to libmad.
2It would make life a bit easier for distro maintainers if this was applied.
3In case you didn't know, pkg-config is a tool for providing LDFLAGS and
4CFLAGS for packages using shared libraries. It's on freedesktop.org.
5Debian has already been distributing the pkg-config file mad.pc with
6libmad for some time, and people developing on debian (notably xmms2
7developers) have started relying on this support being present, causing
8some confusion for people installing from source and on some BSDs which
9do not provide mad.pc (google: pkgconfig libmad).
10
11EMH
12
13Upstream-Status: Inappropriate [configuration]
14
15--h31gzZEtNLTqOjlF
16Content-Type: text/plain; charset=us-ascii
17Content-Disposition: attachment; filename=&quot;libmad-0.15.1b-pkgconfig.patch&quot;
18
19diff -Naur libmad-0.15.1b.old/configure.ac libmad-0.15.1b/configure.ac
20--- libmad-0.15.1b.old/configure.ac 2004-01-23 10:41:32.000000000 +0100
21+++ libmad-0.15.1b/configure.ac 2004-08-07 02:25:24.633462168 +0200
22@@ -429,5 +429,5 @@
23 dnl AC_SUBST(LTLIBOBJS)
24
25 AC_CONFIG_FILES([Makefile msvc++/Makefile \
26- libmad.list])
27+ libmad.list mad.pc])
28 AC_OUTPUT
29diff -Naur libmad-0.15.1b.old/mad.pc.in libmad-0.15.1b/mad.pc.in
30--- libmad-0.15.1b.old/mad.pc.in 1970-01-01 01:00:00.000000000 +0100
31+++ libmad-0.15.1b/mad.pc.in 2004-08-07 02:04:59.617692872 +0200
32@@ -0,0 +1,14 @@
33+# libmad pkg-config source file
34+
35+prefix=@prefix@
36+exec_prefix=@exec_prefix@
37+libdir=@libdir@
38+includedir=@includedir@
39+
40+Name: mad
41+Description: MPEG Audio Decoder
42+Version: @VERSION@
43+Requires:
44+Conflicts:
45+Libs: -L${libdir} -lmad -lm
46+Cflags: -I${includedir}
47diff -Naur libmad-0.15.1b.old/Makefile.am libmad-0.15.1b/Makefile.am
48--- libmad-0.15.1b.old/Makefile.am 2004-02-17 03:02:03.000000000 +0100
49+++ libmad-0.15.1b/Makefile.am 2004-08-07 02:03:19.859858368 +0200
50@@ -24,6 +24,9 @@
51 SUBDIRS =
52 DIST_SUBDIRS = msvc++
53
54+pkgconfigdir = $(libdir)/pkgconfig
55+pkgconfig_DATA = mad.pc
56+
57 lib_LTLIBRARIES = libmad.la
58 include_HEADERS = mad.h
59
60@@ -34,7 +37,8 @@
61 minimad_LDADD = libmad.la
62
63 EXTRA_DIST = mad.h.sed \
64- CHANGES COPYRIGHT CREDITS README TODO VERSION
65+ CHANGES COPYRIGHT CREDITS README TODO VERSION \
66+ mad.pc.in
67
68 exported_headers = version.h fixed.h bit.h timer.h stream.h frame.h \
69 synth.h decoder.h
70
diff --git a/meta/recipes-multimedia/libmad/libmad/automake-foreign.patch b/meta/recipes-multimedia/libmad/libmad/automake-foreign.patch
new file mode 100644
index 0000000000..3e544248d9
--- /dev/null
+++ b/meta/recipes-multimedia/libmad/libmad/automake-foreign.patch
@@ -0,0 +1,12 @@
1Pass foreign to AM_INIT_AUTOMAKE so it doesn't enforce GNU strictness.
2
3Upstream-Status: Pending
4Signed-off-by: Ross Burton <ross.burton@intel.com>
5
6diff --git a/configure.ac b/configure.ac
7index e602fd3..e075b86 100644
8--- a/configure.ac
9+++ b/configure.ac
10@@ -29 +29 @@ AC_CONFIG_SRCDIR([decoder.h])
11-AM_INIT_AUTOMAKE
12+AM_INIT_AUTOMAKE([foreign])
diff --git a/meta/recipes-multimedia/libmad/libmad/fix_for_mips_with_gcc-4.5.0.patch b/meta/recipes-multimedia/libmad/libmad/fix_for_mips_with_gcc-4.5.0.patch
new file mode 100644
index 0000000000..01c7aa3c8c
--- /dev/null
+++ b/meta/recipes-multimedia/libmad/libmad/fix_for_mips_with_gcc-4.5.0.patch
@@ -0,0 +1,33 @@
1gcc 4.4 did this: The MIPS port no longer recognizes the h asm constraint. It was necessary to remove this constraint in order to avoid generating unpredictable code sequences.
2
3so the libmad build with gcc-4.5.0 was failing.
4
5Found a solution here:
6
7http://us.generation-nt.com/answer/bug-568418-libmad0-dev-mpg321-compilation-errors-mips-mipsel-architectures-help-169033451.html
8
9Upstream-Status: Pending
10
112010/07/29
12Nitin A Kamble <nitin.a.kamble@intel.com>
13
14Index: libmad-0.15.1b/fixed.h
15===================================================================
16--- libmad-0.15.1b.orig/fixed.h
17+++ libmad-0.15.1b/fixed.h
18@@ -297,6 +297,15 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t
19
20 /* --- MIPS ---------------------------------------------------------------- */
21
22+# elif defined(FPM_MIPS) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
23+ typedef unsigned int u64_di_t __attribute__ ((mode (DI)));
24+# define MAD_F_MLX(hi, lo, x, y) \
25+ do { \
26+ u64_di_t __ll = (u64_di_t) (x) * (y); \
27+ hi = __ll >> 32; \
28+ lo = __ll; \
29+ } while (0)
30+
31 # elif defined(FPM_MIPS)
32
33 /*
diff --git a/meta/recipes-multimedia/libmad/libmad/no-force-mem.patch b/meta/recipes-multimedia/libmad/libmad/no-force-mem.patch
new file mode 100644
index 0000000000..d5e6d206e2
--- /dev/null
+++ b/meta/recipes-multimedia/libmad/libmad/no-force-mem.patch
@@ -0,0 +1,18 @@
1This option no longer exists in gcc 3.4.1
2
3RP - 18/07/2008
4
5Upstream-Status: Inappropriate [configuration]
6
7Index: libmad-0.15.1b/configure.ac
8===================================================================
9--- libmad-0.15.1b.orig/configure.ac 2008-07-18 15:45:30.000000000 +0100
10+++ libmad-0.15.1b/configure.ac 2008-07-18 15:45:37.000000000 +0100
11@@ -140,7 +140,6 @@
12 case "$optimize" in
13 -O|"-O "*)
14 optimize="-O"
15- optimize="$optimize -fforce-mem"
16 optimize="$optimize -fforce-addr"
17 : #x optimize="$optimize -finline-functions"
18 : #- optimize="$optimize -fstrength-reduce"
diff --git a/meta/recipes-multimedia/libmad/libmad/obsolete_automake_macros.patch b/meta/recipes-multimedia/libmad/libmad/obsolete_automake_macros.patch
new file mode 100644
index 0000000000..cc87d299ed
--- /dev/null
+++ b/meta/recipes-multimedia/libmad/libmad/obsolete_automake_macros.patch
@@ -0,0 +1,14 @@
1Upstream-Status: Submitted [https://sourceforge.net/tracker/?group_id=12349&atid=112349]
2
3Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
4diff -Nurd libmad-0.15.1b/configure.ac libmad-0.15.1b/configure.ac
5--- libmad-0.15.1b/configure.ac 2004-01-23 11:41:32.000000000 +0200
6+++ libmad-0.15.1b/configure.ac 2013-01-03 08:28:23.718693697 +0200
7@@ -28,7 +28,7 @@
8
9 AM_INIT_AUTOMAKE
10
11-AM_CONFIG_HEADER([config.h])
12+AC_CONFIG_HEADERS([config.h])
13
14 dnl System type.
diff --git a/meta/recipes-multimedia/libmad/libmad_0.15.1b.bb b/meta/recipes-multimedia/libmad/libmad_0.15.1b.bb
new file mode 100644
index 0000000000..30937ebe68
--- /dev/null
+++ b/meta/recipes-multimedia/libmad/libmad_0.15.1b.bb
@@ -0,0 +1,38 @@
1SUMMARY = "MPEG Audio Decoder library"
2HOMEPAGE = "http://sourceforge.net/projects/mad/"
3BUGTRACKER = "http://sourceforge.net/tracker/?group_id=12349&atid=112349"
4LICENSE = "GPLv2+"
5LICENSE_FLAGS = "commercial"
6LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
7 file://COPYRIGHT;md5=8e55eb14894e782b84488d5a239bc23d \
8 file://version.h;beginline=1;endline=8;md5=aa07311dd39288d4349f28e1de516454"
9SECTION = "libs"
10DEPENDS = "libid3tag"
11PR = "r3"
12
13SRC_URI = "${SOURCEFORGE_MIRROR}/mad/libmad-${PV}.tar.gz \
14 file://no-force-mem.patch \
15 file://add-pkgconfig.patch \
16 file://fix_for_mips_with_gcc-4.5.0.patch \
17 file://obsolete_automake_macros.patch \
18 file://automake-foreign.patch \
19"
20
21SRC_URI[md5sum] = "1be543bc30c56fb6bea1d7bf6a64e66c"
22SRC_URI[sha256sum] = "bbfac3ed6bfbc2823d3775ebb931087371e142bb0e9bb1bee51a76a6e0078690"
23
24S = "${WORKDIR}/libmad-${PV}"
25
26inherit autotools pkgconfig
27
28EXTRA_OECONF = "-enable-speed --enable-shared"
29# The ASO's don't take any account of thumb...
30EXTRA_OECONF_append_thumb = " --disable-aso --enable-fpm=default"
31EXTRA_OECONF_append_arm = " --enable-fpm=arm"
32
33do_configure_prepend () {
34# damn picky automake...
35 touch NEWS AUTHORS ChangeLog
36}
37
38ARM_INSTRUCTION_SET = "arm"
diff --git a/meta/recipes-multimedia/libogg/libogg_1.3.2.bb b/meta/recipes-multimedia/libogg/libogg_1.3.2.bb
new file mode 100644
index 0000000000..0142e0f4f8
--- /dev/null
+++ b/meta/recipes-multimedia/libogg/libogg_1.3.2.bb
@@ -0,0 +1,17 @@
1SUMMARY = "Ogg bitstream and framing libary"
2DESCRIPTION = "libogg is the bitstream and framing library \
3for the Ogg project. It provides functions which are \
4necessary to codec libraries like libvorbis."
5HOMEPAGE = "http://xiph.org/"
6BUGTRACKER = "https://trac.xiph.org/newticket"
7SECTION = "libs"
8LICENSE = "BSD"
9LIC_FILES_CHKSUM = "file://COPYING;md5=db1b7a668b2a6f47b2af88fb008ad555 \
10 file://include/ogg/ogg.h;beginline=1;endline=11;md5=eda812856f13a3b1326eb8f020cc3b0b"
11
12SRC_URI = "http://downloads.xiph.org/releases/ogg/${BP}.tar.xz"
13
14SRC_URI[md5sum] = "5c3a34309d8b98640827e5d0991a4015"
15SRC_URI[sha256sum] = "3f687ccdd5ac8b52d76328fbbfebc70c459a40ea891dbf3dccb74a210826e79b"
16
17inherit autotools pkgconfig
diff --git a/meta/recipes-multimedia/libomxil/libomxil-0.9.3/configure-fix.patch b/meta/recipes-multimedia/libomxil/libomxil-0.9.3/configure-fix.patch
new file mode 100644
index 0000000000..876e80ef76
--- /dev/null
+++ b/meta/recipes-multimedia/libomxil/libomxil-0.9.3/configure-fix.patch
@@ -0,0 +1,58 @@
1To enable --disable-Werror for libomxil to avoid some compilers which check code strictly.
2
3For example, at least the following errors happened to some compilers:
4
51) OMX_INDEXTYPE in include/OMX_Index.h IS NOT OMX_INDEXVENDORTYPE in src/base/omx_base_component.h
6| i586-poky-linux-libtool: compile: i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/yocto-build5/poky/build/tmp/sysroots/qemux86 -DHAVE_Climinate-unused-debug-types -Wall -Werror -DCONFIG_DEBUG_LEVEL=0 -c OMXComponentRMExt.c -fPIC -DPIC -o .libs/libomxbase_la-OMXComponentRMExt.o
7| omx_base_component.c: In function 'omx_base_component_GetParameter':
8| omx_base_component.c:991:3: error: case value '2130706435' not in enumerated type 'OMX_INDEXTYPE' [-Werror=switch]
9| omx_base_component.c:918:3: error: case value '2130706436' not in enumerated type 'OMX_INDEXTYPE' [-Werror=switch]
10
112)
12| i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/yocto-build5/poky/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I.. -DOMXILCOMPOminate-unused-debug-types -Wall -Werror -DCONFIG_DEBUG_LEVEL=0 -c -o omxregister_bellagio-omxregister.o `test -f 'omxregister.c' || echo './'`o
13| omxregister.c: In function 'buildComponentsList':
14| omxregister.c:175:7: error: variable 'err' set but not used [-Werror=unused-but-set-variable]
15| cc1: all warnings being treated as errors
16
17Upstream-Status: Inappropriate [configuration]
18
19Signed-off-by: Shane Wang <shane.wang@intel.com>
20
21diff -r 82d742d3ea90 configure.ac
22--- a/configure.ac Tue Dec 27 15:30:35 2011 +0800
23+++ b/configure.ac Tue Dec 27 16:26:03 2011 +0800
24@@ -5,7 +5,7 @@
25 AC_PREREQ([2.59])
26
27 AC_CONFIG_HEADERS([config.h])
28-CFLAGS="${CFLAGS} -Wall -Werror"
29+CFLAGS="${CFLAGS} -Wall"
30
31 ################################################################################
32 # Set the shared versioning info, according to section 6.3 of the libtool info #
33@@ -122,6 +122,14 @@
34 [with_android=$enableval],
35 [with_android=no])
36
37+AC_ARG_ENABLE(
38+ [Werror],
39+ [AC_HELP_STRING(
40+ [--disable-Werror],
41+ [whether to diable treating gcc warnings as errors])],
42+ [with_Werror=$enableval],
43+ [with_Werror=yes])
44+
45 ################################################################################
46 # Check for programs #
47 ################################################################################
48@@ -193,6 +201,10 @@
49 CFG_DEBUG_LEVEL=255
50 fi
51
52+if test "x$with_Werror" = "xyes"; then
53+ CFLAGS="${CFLAGS} -Werror"
54+fi
55+
56 AC_SUBST(CFG_DEBUG_LEVEL)
57 CFLAGS="${CFLAGS} -DCONFIG_DEBUG_LEVEL=$CFG_DEBUG_LEVEL"
58
diff --git a/meta/recipes-multimedia/libomxil/libomxil-0.9.3/disable-so-versioning.patch b/meta/recipes-multimedia/libomxil/libomxil-0.9.3/disable-so-versioning.patch
new file mode 100644
index 0000000000..f408e4a621
--- /dev/null
+++ b/meta/recipes-multimedia/libomxil/libomxil-0.9.3/disable-so-versioning.patch
@@ -0,0 +1,36 @@
1Disable so versioning since they are really not a versioned shared lib.
2
3Upstream-Status: Submitted @ https://sourceforge.net/p/omxil/bugs/59/
4
5Signed-off-by: Drew Moseley <drew_moseley@mentor.com>
6
7diff -rub libomxil-bellagio-0.9.3-orig/src/components/audio_effects/Makefile.am libomxil-bellagio-0.9.3/src/components/audio_effects/Makefile.am
8--- libomxil-bellagio-0.9.3-orig/src/components/audio_effects/Makefile.am 2014-07-20 15:22:00.858425234 -0400
9+++ libomxil-bellagio-0.9.3/src/components/audio_effects/Makefile.am 2014-07-20 15:25:42.687525225 -0400
10@@ -10,4 +10,5 @@
11 libomxaudio_effects_la_CFLAGS = -I$(top_srcdir)/include \
12 -I$(top_srcdir)/src \
13 -I$(top_srcdir)/src/base
14+libomxaudio_effects_la_LDFLAGS = -avoid-version
15
16diff -rub libomxil-bellagio-0.9.3-orig/src/components/clocksrc/Makefile.am libomxil-bellagio-0.9.3/src/components/clocksrc/Makefile.am
17--- libomxil-bellagio-0.9.3-orig/src/components/clocksrc/Makefile.am 2014-07-20 15:22:00.858425234 -0400
18+++ libomxil-bellagio-0.9.3/src/components/clocksrc/Makefile.am 2014-07-20 15:24:49.151259753 -0400
19@@ -10,4 +10,4 @@
20 -I$(top_srcdir)/include \
21 -I$(top_srcdir)/src \
22 -I$(top_srcdir)/src/base
23-
24+libomxclocksrc_la_LDFLAGS = -avoid-version
25diff -rub libomxil-bellagio-0.9.3-orig/src/components/videoscheduler/Makefile.am libomxil-bellagio-0.9.3/src/components/videoscheduler/Makefile.am
26--- libomxil-bellagio-0.9.3-orig/src/components/videoscheduler/Makefile.am 2014-07-20 15:22:00.862425254 -0400
27+++ libomxil-bellagio-0.9.3/src/components/videoscheduler/Makefile.am 2014-07-20 15:22:36.462601786 -0400
28@@ -6,7 +6,7 @@
29 library_entry_point.c
30
31 libomxvideosched_la_LIBADD = $(top_builddir)/src/libomxil-bellagio.la
32-libomxvideosched_la_LDFLAGS =
33+libomxvideosched_la_LDFLAGS = -avoid-version
34 libomxvideosched_la_CFLAGS = -I$(top_srcdir)/include \
35 -I$(top_srcdir)/src \
36 -I$(top_srcdir)/src/base
diff --git a/meta/recipes-multimedia/libomxil/libomxil-0.9.3/dynamicloader-linking.patch b/meta/recipes-multimedia/libomxil/libomxil-0.9.3/dynamicloader-linking.patch
new file mode 100644
index 0000000000..787953a99b
--- /dev/null
+++ b/meta/recipes-multimedia/libomxil/libomxil-0.9.3/dynamicloader-linking.patch
@@ -0,0 +1,20 @@
1This patch fixes link issue when libomxdynamicloader.so is loaded :
2Missing symbol RM_Deinit.
3
4This patch comes from "http://pkgs.fedoraproject.org/cgit/libomxil-bellagio.git/commit/?h=f17&id=4996a95828943d345e51ded6876c3103653eecf8"
5
6Upstream-Status: Pending
7
8Signed-off-by: Sébastien Mennetrier <s.mennetrier@innotis.org>
9
10--- a/src/dynamic_loader/Makefile.am 2014-02-25 15:29:10.128549636 +0100
11+++ b/src/dynamic_loader/Makefile.am 2014-02-25 15:30:15.756548808 +0100
12@@ -3,7 +3,7 @@
13 omxdynamicloader_LTLIBRARIES = libomxdynamicloader.la
14 libomxdynamicloader_la_SOURCES = ste_dynamic_component_loader.c ste_dynamic_component_loader.h
15
16-libomxdynamicloader_la_LDFLAGS =
17+libomxdynamicloader_la_LDFLAGS = -lomxil-bellagio -L$(top_builddir)/src/.libs
18 libomxdynamicloader_la_CFLAGS = -I$(top_srcdir)/include \
19 -I$(top_srcdir)/src \
20 -I$(top_srcdir)/src/base \
diff --git a/meta/recipes-multimedia/libomxil/libomxil-0.9.3/makefile-docdir-fix.patch b/meta/recipes-multimedia/libomxil/libomxil-0.9.3/makefile-docdir-fix.patch
new file mode 100644
index 0000000000..dbe8c41f74
--- /dev/null
+++ b/meta/recipes-multimedia/libomxil/libomxil-0.9.3/makefile-docdir-fix.patch
@@ -0,0 +1,19 @@
1This patch is to remove DESTDIR in docdir.
2Otherwise, when users install by running `make install DESTDIR=/alternate/directory' specified in the file INSTALL, the doc will go into /alternate/directory/alternate/directory, which is not expected.
3
4Upstream-Status: Pending
5
6Signed-off-by: Shane Wang <shane.wang@intel.com>
7
8diff -r 30b597e4e70d Makefile.am
9--- a/Makefile.am Wed Dec 28 15:38:35 2011 +0800
10+++ b/Makefile.am Wed Dec 28 15:39:25 2011 +0800
11@@ -7,7 +7,7 @@
12 pkgconfigdir = $(libdir)/pkgconfig
13 pkgconfig_DATA = libomxil-bellagio.pc
14
15-docdir = $(DESTDIR)$(prefix)/share/doc/@PACKAGE@
16+docdir = $(prefix)/share/doc/@PACKAGE@
17 doc_DATA = README \
18 ChangeLog \
19 TODO
diff --git a/meta/recipes-multimedia/libomxil/libomxil-0.9.3/parallel-make.patch b/meta/recipes-multimedia/libomxil/libomxil-0.9.3/parallel-make.patch
new file mode 100644
index 0000000000..483ca1328b
--- /dev/null
+++ b/meta/recipes-multimedia/libomxil/libomxil-0.9.3/parallel-make.patch
@@ -0,0 +1,18 @@
1This patch is to make libomxil Makefile support "make -jN".
2The omxregister_bellagio stuffs depend on libomxil_bellagio library.
3
4Upstream-Status: Pending
5
6Signed-off-by: Shane Wang <shane.wang@intel.com>
7
8diff -r f59d077d3dd5 Makefile.am
9--- a/src/Makefile.am Wed Dec 28 10:54:36 2011 +0800
10+++ b/src/Makefile.am Wed Dec 28 10:55:46 2011 +0800
11@@ -7,6 +7,7 @@
12 omxregister_bellagio_SOURCES = omxregister.c common.c common.h
13 omxregister_bellagio_CFLAGS = -DOMXILCOMPONENTSPATH=\"$(plugindir)/\" \
14 -I$(top_srcdir)/include
15+omxregister_bellagio_LDADD = $(lib_LTLIBRARIES)
16 omxregister_bellagio_LDFLAGS = -lomxil-bellagio -L$(builddir)
17
18 lib_LTLIBRARIES = libomxil-bellagio.la
diff --git a/meta/recipes-multimedia/libomxil/libomxil_0.9.3.bb b/meta/recipes-multimedia/libomxil/libomxil_0.9.3.bb
new file mode 100644
index 0000000000..40d6df8b6a
--- /dev/null
+++ b/meta/recipes-multimedia/libomxil/libomxil_0.9.3.bb
@@ -0,0 +1,39 @@
1SUMMARY = "Bellagio OpenMAX Integration Layer (IL)"
2DESCRIPTION = "Bellagio is an opensource implementation of the Khronos OpenMAX \
3 Integration Layer API to access multimedia components."
4HOMEPAGE = "http://omxil.sourceforge.net/"
5
6LICENSE = "LGPLv2.1+"
7LICENSE_FLAGS = "commercial"
8LIC_FILES_CHKSUM = "file://COPYING;md5=ae6f0f4dbc7ac193b50f323a6ae191cb \
9 file://src/omxcore.h;beginline=1;endline=27;md5=806b1e5566c06486fe8e42b461e03a90"
10
11SRC_URI = "${SOURCEFORGE_MIRROR}/omxil/libomxil-bellagio-${PV}.tar.gz \
12 file://configure-fix.patch \
13 file://parallel-make.patch \
14 file://makefile-docdir-fix.patch \
15 file://dynamicloader-linking.patch \
16 file://disable-so-versioning.patch"
17
18SRC_URI[md5sum] = "a1de827fdb75c02c84e55f740ca27cb8"
19SRC_URI[sha256sum] = "593c0729c8ef8c1467b3bfefcf355ec19a46dd92e31bfc280e17d96b0934d74c"
20
21S = "${WORKDIR}/${BPN}-bellagio-${PV}"
22
23inherit autotools
24
25EXTRA_OECONF += "--disable-doc --disable-Werror"
26
27#
28# The .so files under ${libdir}/bellagio are not intended to be versioned and symlinked.
29# Make sure they get packaged in the main package.
30#
31FILES_${PN} += "${libdir}/bellagio/*.so \
32 ${libdir}/omxloaders/*${SOLIBS}"
33FILES_${PN}-staticdev += "${libdir}/bellagio/*.a \
34 ${libdir}/omxloaders/*.a"
35FILES_${PN}-dev += "${libdir}/bellagio/*.la \
36 ${libdir}/omxloaders/*.la \
37 ${libdir}/omxloaders/*${SOLIBSDEV}"
38FILES_${PN}-dbg += "${libdir}/bellagio/.debug/ \
39 ${libdir}/omxloaders/.debug/"
diff --git a/meta/recipes-multimedia/libpng/libpng_1.6.13.bb b/meta/recipes-multimedia/libpng/libpng_1.6.13.bb
new file mode 100644
index 0000000000..3d32bfea2c
--- /dev/null
+++ b/meta/recipes-multimedia/libpng/libpng_1.6.13.bb
@@ -0,0 +1,29 @@
1SUMMARY = "PNG image format decoding library"
2HOMEPAGE = "http://www.libpng.org/"
3SECTION = "libs"
4LICENSE = "Libpng"
5LIC_FILES_CHKSUM = "file://LICENSE;md5=46401ee4b225b9ec066cb96cf1025c0f \
6 file://png.h;endline=15;md5=8167a17735fc618d1df109f8b0f839a6 \
7 file://png.h;beginline=229;endline=343;md5=5cdf8564a14e2f00339e4437a83b4913"
8DEPENDS = "zlib"
9LIBV = "16"
10
11SRC_URI = "${SOURCEFORGE_MIRROR}/project/libpng/libpng${LIBV}/${PV}/libpng-${PV}.tar.xz \
12 "
13
14SRC_URI[md5sum] = "9822c25466f060142359f80ed142c9e5"
15SRC_URI[sha256sum] = "d9c8ce54a5fc8052ed794ca65b553384a74c0608b09ae163cbbb07176018e625"
16
17BINCONFIG = "${bindir}/libpng-config ${bindir}/libpng16-config"
18
19inherit autotools binconfig-disabled pkgconfig
20
21# Work around missing symbols
22EXTRA_OECONF_append_arm = " ${@bb.utils.contains("TUNE_FEATURES", "neon", "--enable-arm-neon=on", "--enable-arm-neon=off" ,d)}"
23EXTRA_OECONF_append_aarch64 = " ${@bb.utils.contains("TUNE_FEATURES", "neon", "--enable-arm-neon=on", "--enable-arm-neon=off" ,d)}"
24
25PACKAGES =+ "${PN}-tools"
26
27FILES_${PN}-tools = "${bindir}/png-fix-itxt ${bindir}/pngfix"
28
29BBCLASSEXTEND = "native nativesdk"
diff --git a/meta/recipes-multimedia/libsamplerate/libsamplerate0_0.1.8.bb b/meta/recipes-multimedia/libsamplerate/libsamplerate0_0.1.8.bb
new file mode 100644
index 0000000000..f06935c8ba
--- /dev/null
+++ b/meta/recipes-multimedia/libsamplerate/libsamplerate0_0.1.8.bb
@@ -0,0 +1,18 @@
1SUMMARY = "Audio Sample Rate Conversion library"
2HOMEPAGE = "http://www.mega-nerd.com/SRC/"
3SECTION = "libs"
4LICENSE = "GPLv2+"
5LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
6 file://src/samplerate.c;beginline=1;endline=17;md5=d0807c35fc906466d24a50463534815a"
7DEPENDS = "flac libsndfile1"
8PR = "r1"
9
10SRC_URI = "http://www.mega-nerd.com/SRC/libsamplerate-${PV}.tar.gz"
11
12SRC_URI[md5sum] = "1c7fb25191b4e6e3628d198a66a84f47"
13SRC_URI[sha256sum] = "93b54bdf46d5e6d2354b7034395fe329c222a966790de34520702bb9642f1c06"
14S = "${WORKDIR}/libsamplerate-${PV}"
15
16inherit autotools pkgconfig
17
18PACKAGECONFIG[fftw] = ",--disable-fftw,fftw"
diff --git a/meta/recipes-multimedia/libsndfile/files/0001-src-sd2.c-Fix-segfault-in-SD2-RSRC-parser.patch b/meta/recipes-multimedia/libsndfile/files/0001-src-sd2.c-Fix-segfault-in-SD2-RSRC-parser.patch
new file mode 100644
index 0000000000..cd48710fb7
--- /dev/null
+++ b/meta/recipes-multimedia/libsndfile/files/0001-src-sd2.c-Fix-segfault-in-SD2-RSRC-parser.patch
@@ -0,0 +1,211 @@
1From 9341e9c6e70cd3ad76c901c3cf052d4cb52fd827 Mon Sep 17 00:00:00 2001
2From: Erik de Castro Lopo <erikd@mega-nerd.com>
3Date: Thu, 27 Jun 2013 18:04:03 +1000
4Subject: [PATCH] src/sd2.c : Fix segfault in SD2 RSRC parser.
5
6(Upstream commit 9341e9c6e70cd3ad76c901c3cf052d4cb52fd827)
7
8A specially crafted resource fork for an SD2 file can cause
9the SD2 RSRC parser to read data from outside a dynamically
10defined buffer. The data that is read is converted into a
11short or int and used during further processing.
12
13Since no write occurs, this is unlikely to be exploitable.
14
15Bug reported by The Mayhem Team from Cylab, Carnegie Mellon
16Univeristy. Paper is:
17http://users.ece.cmu.edu/~arebert/papers/mayhem-oakland-12.pdf
18
19Upstream-Status: Backport
20
21Signed-off-by: Yue Tao <yue.tao@windriver.com>
22---
23 src/sd2.c | 93 ++++++++++++++++++++++++++++++++++++-------------------------
24 1 file changed, 55 insertions(+), 38 deletions(-)
25
26diff --git a/src/sd2.c b/src/sd2.c
27index 35ce36b..6be150c 100644
28--- a/src/sd2.c
29+++ b/src/sd2.c
30@@ -1,5 +1,5 @@
31 /*
32-** Copyright (C) 2001-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
33+** Copyright (C) 2001-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
34 ** Copyright (C) 2004 Paavo Jumppanen
35 **
36 ** This program is free software; you can redistribute it and/or modify
37@@ -371,44 +371,61 @@ sd2_write_rsrc_fork (SF_PRIVATE *psf, int UNUSED (calc_length))
38 */
39
40 static inline int
41-read_char (const unsigned char * data, int offset)
42-{ return data [offset] ;
43-} /* read_char */
44+read_rsrc_char (const SD2_RSRC *prsrc, int offset)
45+{ const unsigned char * data = prsrc->rsrc_data ;
46+ if (offset < 0 || offset >= prsrc->rsrc_len)
47+ return 0 ;
48+ return data [offset] ;
49+} /* read_rsrc_char */
50
51 static inline int
52-read_short (const unsigned char * data, int offset)
53-{ return (data [offset] << 8) + data [offset + 1] ;
54-} /* read_short */
55+read_rsrc_short (const SD2_RSRC *prsrc, int offset)
56+{ const unsigned char * data = prsrc->rsrc_data ;
57+ if (offset < 0 || offset + 1 >= prsrc->rsrc_len)
58+ return 0 ;
59+ return (data [offset] << 8) + data [offset + 1] ;
60+} /* read_rsrc_short */
61
62 static inline int
63-read_int (const unsigned char * data, int offset)
64-{ return (data [offset] << 24) + (data [offset + 1] << 16) + (data [offset + 2] << 8) + data [offset + 3] ;
65-} /* read_int */
66+read_rsrc_int (const SD2_RSRC *prsrc, int offset)
67+{ const unsigned char * data = prsrc->rsrc_data ;
68+ if (offset < 0 || offset + 3 >= prsrc->rsrc_len)
69+ return 0 ;
70+ return (data [offset] << 24) + (data [offset + 1] << 16) + (data [offset + 2] << 8) + data [offset + 3] ;
71+} /* read_rsrc_int */
72
73 static inline int
74-read_marker (const unsigned char * data, int offset)
75-{
76+read_rsrc_marker (const SD2_RSRC *prsrc, int offset)
77+{ const unsigned char * data = prsrc->rsrc_data ;
78+
79+ if (offset < 0 || offset + 3 >= prsrc->rsrc_len)
80+ return 0 ;
81+
82 if (CPU_IS_BIG_ENDIAN)
83 return (data [offset] << 24) + (data [offset + 1] << 16) + (data [offset + 2] << 8) + data [offset + 3] ;
84- else if (CPU_IS_LITTLE_ENDIAN)
85+ if (CPU_IS_LITTLE_ENDIAN)
86 return data [offset] + (data [offset + 1] << 8) + (data [offset + 2] << 16) + (data [offset + 3] << 24) ;
87- else
88- return 0x666 ;
89-} /* read_marker */
90+
91+ return 0 ;
92+} /* read_rsrc_marker */
93
94 static void
95-read_str (const unsigned char * data, int offset, char * buffer, int buffer_len)
96-{ int k ;
97+read_rsrc_str (const SD2_RSRC *prsrc, int offset, char * buffer, int buffer_len)
98+{ const unsigned char * data = prsrc->rsrc_data ;
99+ int k ;
100
101 memset (buffer, 0, buffer_len) ;
102
103+ if (offset < 0 || offset + buffer_len >= prsrc->rsrc_len)
104+ return ;
105+
106 for (k = 0 ; k < buffer_len - 1 ; k++)
107 { if (psf_isprint (data [offset + k]) == 0)
108 return ;
109 buffer [k] = data [offset + k] ;
110 } ;
111 return ;
112-} /* read_str */
113+} /* read_rsrc_str */
114
115 static int
116 sd2_parse_rsrc_fork (SF_PRIVATE *psf)
117@@ -435,17 +452,17 @@ sd2_parse_rsrc_fork (SF_PRIVATE *psf)
118 /* Reset the header storage because we have changed to the rsrcdes. */
119 psf->headindex = psf->headend = rsrc.rsrc_len ;
120
121- rsrc.data_offset = read_int (rsrc.rsrc_data, 0) ;
122- rsrc.map_offset = read_int (rsrc.rsrc_data, 4) ;
123- rsrc.data_length = read_int (rsrc.rsrc_data, 8) ;
124- rsrc.map_length = read_int (rsrc.rsrc_data, 12) ;
125+ rsrc.data_offset = read_rsrc_int (&rsrc, 0) ;
126+ rsrc.map_offset = read_rsrc_int (&rsrc, 4) ;
127+ rsrc.data_length = read_rsrc_int (&rsrc, 8) ;
128+ rsrc.map_length = read_rsrc_int (&rsrc, 12) ;
129
130 if (rsrc.data_offset == 0x51607 && rsrc.map_offset == 0x20000)
131 { psf_log_printf (psf, "Trying offset of 0x52 bytes.\n") ;
132- rsrc.data_offset = read_int (rsrc.rsrc_data, 0x52 + 0) + 0x52 ;
133- rsrc.map_offset = read_int (rsrc.rsrc_data, 0x52 + 4) + 0x52 ;
134- rsrc.data_length = read_int (rsrc.rsrc_data, 0x52 + 8) ;
135- rsrc.map_length = read_int (rsrc.rsrc_data, 0x52 + 12) ;
136+ rsrc.data_offset = read_rsrc_int (&rsrc, 0x52 + 0) + 0x52 ;
137+ rsrc.map_offset = read_rsrc_int (&rsrc, 0x52 + 4) + 0x52 ;
138+ rsrc.data_length = read_rsrc_int (&rsrc, 0x52 + 8) ;
139+ rsrc.map_length = read_rsrc_int (&rsrc, 0x52 + 12) ;
140 } ;
141
142 psf_log_printf (psf, " data offset : 0x%04X\n map offset : 0x%04X\n"
143@@ -488,7 +505,7 @@ sd2_parse_rsrc_fork (SF_PRIVATE *psf)
144 goto parse_rsrc_fork_cleanup ;
145 } ;
146
147- rsrc.string_offset = rsrc.map_offset + read_short (rsrc.rsrc_data, rsrc.map_offset + 26) ;
148+ rsrc.string_offset = rsrc.map_offset + read_rsrc_short (&rsrc, rsrc.map_offset + 26) ;
149 if (rsrc.string_offset > rsrc.rsrc_len)
150 { psf_log_printf (psf, "Bad string offset (%d).\n", rsrc.string_offset) ;
151 error = SFE_SD2_BAD_RSRC ;
152@@ -497,7 +514,7 @@ sd2_parse_rsrc_fork (SF_PRIVATE *psf)
153
154 rsrc.type_offset = rsrc.map_offset + 30 ;
155
156- rsrc.type_count = read_short (rsrc.rsrc_data, rsrc.map_offset + 28) + 1 ;
157+ rsrc.type_count = read_rsrc_short (&rsrc, rsrc.map_offset + 28) + 1 ;
158 if (rsrc.type_count < 1)
159 { psf_log_printf (psf, "Bad type count.\n") ;
160 error = SFE_SD2_BAD_RSRC ;
161@@ -513,11 +530,11 @@ sd2_parse_rsrc_fork (SF_PRIVATE *psf)
162
163 rsrc.str_index = -1 ;
164 for (k = 0 ; k < rsrc.type_count ; k ++)
165- { marker = read_marker (rsrc.rsrc_data, rsrc.type_offset + k * 8) ;
166+ { marker = read_rsrc_marker (&rsrc, rsrc.type_offset + k * 8) ;
167
168 if (marker == STR_MARKER)
169 { rsrc.str_index = k ;
170- rsrc.str_count = read_short (rsrc.rsrc_data, rsrc.type_offset + k * 8 + 4) + 1 ;
171+ rsrc.str_count = read_rsrc_short (&rsrc, rsrc.type_offset + k * 8 + 4) + 1 ;
172 error = parse_str_rsrc (psf, &rsrc) ;
173 goto parse_rsrc_fork_cleanup ;
174 } ;
175@@ -549,26 +566,26 @@ parse_str_rsrc (SF_PRIVATE *psf, SD2_RSRC * rsrc)
176 for (k = 0 ; data_offset + data_len < rsrc->rsrc_len ; k++)
177 { int slen ;
178
179- slen = read_char (rsrc->rsrc_data, str_offset) ;
180- read_str (rsrc->rsrc_data, str_offset + 1, name, SF_MIN (SIGNED_SIZEOF (name), slen + 1)) ;
181+ slen = read_rsrc_char (rsrc, str_offset) ;
182+ read_rsrc_str (rsrc, str_offset + 1, name, SF_MIN (SIGNED_SIZEOF (name), slen + 1)) ;
183 str_offset += slen + 1 ;
184
185- rsrc_id = read_short (rsrc->rsrc_data, rsrc->item_offset + k * 12) ;
186+ rsrc_id = read_rsrc_short (rsrc, rsrc->item_offset + k * 12) ;
187
188- data_offset = rsrc->data_offset + read_int (rsrc->rsrc_data, rsrc->item_offset + k * 12 + 4) ;
189+ data_offset = rsrc->data_offset + read_rsrc_int (rsrc, rsrc->item_offset + k * 12 + 4) ;
190 if (data_offset < 0 || data_offset > rsrc->rsrc_len)
191 { psf_log_printf (psf, "Exiting parser on data offset of %d.\n", data_offset) ;
192 break ;
193 } ;
194
195- data_len = read_int (rsrc->rsrc_data, data_offset) ;
196+ data_len = read_rsrc_int (rsrc, data_offset) ;
197 if (data_len < 0 || data_len > rsrc->rsrc_len)
198 { psf_log_printf (psf, "Exiting parser on data length of %d.\n", data_len) ;
199 break ;
200 } ;
201
202- slen = read_char (rsrc->rsrc_data, data_offset + 4) ;
203- read_str (rsrc->rsrc_data, data_offset + 5, value, SF_MIN (SIGNED_SIZEOF (value), slen + 1)) ;
204+ slen = read_rsrc_char (rsrc, data_offset + 4) ;
205+ read_rsrc_str (rsrc, data_offset + 5, value, SF_MIN (SIGNED_SIZEOF (value), slen + 1)) ;
206
207 psf_log_printf (psf, " 0x%04x %4d %4d %3d '%s'\n", data_offset, rsrc_id, data_len, slen, value) ;
208
209--
2101.7.9.5
211
diff --git a/meta/recipes-multimedia/libsndfile/files/0001-src-sd2.c-Fix-two-potential-buffer-read-overflows.patch b/meta/recipes-multimedia/libsndfile/files/0001-src-sd2.c-Fix-two-potential-buffer-read-overflows.patch
new file mode 100644
index 0000000000..fa6473d4f8
--- /dev/null
+++ b/meta/recipes-multimedia/libsndfile/files/0001-src-sd2.c-Fix-two-potential-buffer-read-overflows.patch
@@ -0,0 +1,49 @@
1From dbe14f00030af5d3577f4cabbf9861db59e9c378 Mon Sep 17 00:00:00 2001
2From: Erik de Castro Lopo <erikd@mega-nerd.com>
3Date: Thu, 25 Dec 2014 19:23:12 +1100
4Subject: [PATCH] src/sd2.c : Fix two potential buffer read overflows.
5
6(Upstream commit dbe14f00030af5d3577f4cabbf9861db59e9c378)
7
8Closes: https://github.com/erikd/libsndfile/issues/93
9
10Upstream-Status: Backport
11
12Signed-off-by: Yue Tao <yue.tao@windriver.com>
13---
14 src/sd2.c | 12 +++++++++++-
15 1 file changed, 11 insertions(+), 1 deletion(-)
16
17diff --git a/src/sd2.c b/src/sd2.c
18index 0b4e5af..a70a1f1 100644
19--- a/src/sd2.c
20+++ b/src/sd2.c
21@@ -517,6 +517,11 @@ sd2_parse_rsrc_fork (SF_PRIVATE *psf)
22
23 rsrc.type_offset = rsrc.map_offset + 30 ;
24
25+ if (rsrc.map_offset + 28 > rsrc.rsrc_len)
26+ { psf_log_printf (psf, "Bad map offset.\n") ;
27+ goto parse_rsrc_fork_cleanup ;
28+ } ;
29+
30 rsrc.type_count = read_rsrc_short (&rsrc, rsrc.map_offset + 28) + 1 ;
31 if (rsrc.type_count < 1)
32 { psf_log_printf (psf, "Bad type count.\n") ;
33@@ -533,7 +538,12 @@ sd2_parse_rsrc_fork (SF_PRIVATE *psf)
34
35 rsrc.str_index = -1 ;
36 for (k = 0 ; k < rsrc.type_count ; k ++)
37- { marker = read_rsrc_marker (&rsrc, rsrc.type_offset + k * 8) ;
38+ { if (rsrc.type_offset + k * 8 > rsrc.rsrc_len)
39+ { psf_log_printf (psf, "Bad rsrc marker.\n") ;
40+ goto parse_rsrc_fork_cleanup ;
41+ } ;
42+
43+ marker = read_rsrc_marker (&rsrc, rsrc.type_offset + k * 8) ;
44
45 if (marker == STR_MARKER)
46 { rsrc.str_index = k ;
47--
481.7.9.5
49
diff --git a/meta/recipes-multimedia/libsndfile/libsndfile1_1.0.25.bb b/meta/recipes-multimedia/libsndfile/libsndfile1_1.0.25.bb
new file mode 100644
index 0000000000..3e02f4ea78
--- /dev/null
+++ b/meta/recipes-multimedia/libsndfile/libsndfile1_1.0.25.bb
@@ -0,0 +1,33 @@
1SUMMARY = "Audio format Conversion library"
2HOMEPAGE = "http://www.mega-nerd.com/libsndfile"
3AUTHOR = "Erik de Castro Lopo"
4DEPENDS = "sqlite3"
5SECTION = "libs/multimedia"
6LICENSE = "LGPLv2.1"
7PR = "r2"
8
9SRC_URI = "http://www.mega-nerd.com/libsndfile/files/libsndfile-${PV}.tar.gz \
10 file://0001-src-sd2.c-Fix-segfault-in-SD2-RSRC-parser.patch \
11 file://0001-src-sd2.c-Fix-two-potential-buffer-read-overflows.patch \
12"
13
14SRC_URI[md5sum] = "e2b7bb637e01022c7d20f95f9c3990a2"
15SRC_URI[sha256sum] = "59016dbd326abe7e2366ded5c344c853829bebfd1702ef26a07ef662d6aa4882"
16
17LIC_FILES_CHKSUM = "file://COPYING;md5=e77fe93202736b47c07035910f47974a"
18
19S = "${WORKDIR}/libsndfile-${PV}"
20
21PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'alsa', 'alsa', '', d)}"
22PACKAGECONFIG[alsa] = "--enable-alsa,--disable-alsa,alsa-lib"
23
24EXTRA_OECONF = "--disable-external-libs"
25
26inherit autotools lib_package pkgconfig
27
28do_configure_prepend_arm() {
29 export ac_cv_sys_largefile_source=1
30 export ac_cv_sys_file_offset_bits=64
31 ac_cv_sizeof_off_t=8
32}
33
diff --git a/meta/recipes-multimedia/libtheora/libtheora-1.1.1/no-docs.patch b/meta/recipes-multimedia/libtheora/libtheora-1.1.1/no-docs.patch
new file mode 100644
index 0000000000..359f3d1a7a
--- /dev/null
+++ b/meta/recipes-multimedia/libtheora/libtheora-1.1.1/no-docs.patch
@@ -0,0 +1,15 @@
1Upstream-Status: Inappropriate [configuration]
2
3Index: libtheora-1.1.1/Makefile.am
4===================================================================
5--- libtheora-1.1.1.orig/Makefile.am 2009-11-25 22:01:53.593775926 +0100
6+++ libtheora-1.1.1/Makefile.am 2009-11-25 22:02:00.777524017 +0100
7@@ -8,7 +8,7 @@
8 EXAMPLES_DIR =
9 endif
10
11-SUBDIRS = lib include doc tests m4 $(EXAMPLES_DIR)
12+SUBDIRS = lib include tests m4 $(EXAMPLES_DIR)
13
14
15 # we include the whole debian/ dir in EXTRA_DIST because there's a problem
diff --git a/meta/recipes-multimedia/libtheora/libtheora_1.1.1.bb b/meta/recipes-multimedia/libtheora/libtheora_1.1.1.bb
new file mode 100644
index 0000000000..18cb168c52
--- /dev/null
+++ b/meta/recipes-multimedia/libtheora/libtheora_1.1.1.bb
@@ -0,0 +1,20 @@
1SUMMARY = "Theora Video Codec"
2DESCRIPTION = "The libtheora reference implementation provides the standard encoder and decoder under a BSD license."
3HOMEPAGE = "http://xiph.org/"
4BUGTRACKER = "https://trac.xiph.org/newticket"
5SECTION = "libs"
6LICENSE = "BSD"
7LIC_FILES_CHKSUM = "file://COPYING;md5=cf91718f59eb6a83d06dc7bcaf411132"
8DEPENDS = "libogg"
9
10PR = "r1"
11
12SRC_URI = "http://downloads.xiph.org/releases/theora/libtheora-${PV}.tar.bz2 \
13 file://no-docs.patch"
14
15SRC_URI[md5sum] = "292ab65cedd5021d6b7ddd117e07cd8e"
16SRC_URI[sha256sum] = "b6ae1ee2fa3d42ac489287d3ec34c5885730b1296f0801ae577a35193d3affbc"
17
18inherit autotools pkgconfig
19
20EXTRA_OECONF = "--disable-examples"
diff --git a/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-1960.patch b/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-1960.patch
new file mode 100644
index 0000000000..e4348f1d2c
--- /dev/null
+++ b/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-1960.patch
@@ -0,0 +1,151 @@
1This patch comes from: http://pkgs.fedoraproject.org/cgit/libtiff.git/plain/libtiff-CVE-2013-1960.patch
2
3Upstream-Status: Pending
4
5Signed-off-by: Ming Liu <ming.liu@windriver.com>
6
7diff -Naur a/tools/tiff2pdf.c b/tools/tiff2pdf.c
8--- a/tools/tiff2pdf.c 2012-07-25 22:56:43.000000000 -0400
9+++ b/tools/tiff2pdf.c 2013-05-02 12:04:49.057090227 -0400
10@@ -3341,33 +3341,56 @@
11 uint32 height){
12
13 tsize_t i=0;
14- uint16 ri =0;
15- uint16 v_samp=1;
16- uint16 h_samp=1;
17- int j=0;
18-
19- i++;
20-
21- while(i<(*striplength)){
22+
23+ while (i < *striplength) {
24+ tsize_t datalen;
25+ uint16 ri;
26+ uint16 v_samp;
27+ uint16 h_samp;
28+ int j;
29+ int ncomp;
30+
31+ /* marker header: one or more FFs */
32+ if (strip[i] != 0xff)
33+ return(0);
34+ i++;
35+ while (i < *striplength && strip[i] == 0xff)
36+ i++;
37+ if (i >= *striplength)
38+ return(0);
39+ /* SOI is the only pre-SOS marker without a length word */
40+ if (strip[i] == 0xd8)
41+ datalen = 0;
42+ else {
43+ if ((*striplength - i) <= 2)
44+ return(0);
45+ datalen = (strip[i+1] << 8) | strip[i+2];
46+ if (datalen < 2 || datalen >= (*striplength - i))
47+ return(0);
48+ }
49 switch( strip[i] ){
50- case 0xd8:
51- /* SOI - start of image */
52+ case 0xd8: /* SOI - start of image */
53 _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), 2);
54 *bufferoffset+=2;
55- i+=2;
56 break;
57- case 0xc0:
58- case 0xc1:
59- case 0xc3:
60- case 0xc9:
61- case 0xca:
62+ case 0xc0: /* SOF0 */
63+ case 0xc1: /* SOF1 */
64+ case 0xc3: /* SOF3 */
65+ case 0xc9: /* SOF9 */
66+ case 0xca: /* SOF10 */
67 if(no==0){
68- _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), strip[i+2]+2);
69- for(j=0;j<buffer[*bufferoffset+9];j++){
70- if( (buffer[*bufferoffset+11+(2*j)]>>4) > h_samp)
71- h_samp = (buffer[*bufferoffset+11+(2*j)]>>4);
72- if( (buffer[*bufferoffset+11+(2*j)] & 0x0f) > v_samp)
73- v_samp = (buffer[*bufferoffset+11+(2*j)] & 0x0f);
74+ _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2);
75+ ncomp = buffer[*bufferoffset+9];
76+ if (ncomp < 1 || ncomp > 4)
77+ return(0);
78+ v_samp=1;
79+ h_samp=1;
80+ for(j=0;j<ncomp;j++){
81+ uint16 samp = buffer[*bufferoffset+11+(3*j)];
82+ if( (samp>>4) > h_samp)
83+ h_samp = (samp>>4);
84+ if( (samp & 0x0f) > v_samp)
85+ v_samp = (samp & 0x0f);
86 }
87 v_samp*=8;
88 h_samp*=8;
89@@ -3381,45 +3404,43 @@
90 (unsigned char) ((height>>8) & 0xff);
91 buffer[*bufferoffset+6]=
92 (unsigned char) (height & 0xff);
93- *bufferoffset+=strip[i+2]+2;
94- i+=strip[i+2]+2;
95-
96+ *bufferoffset+=datalen+2;
97+ /* insert a DRI marker */
98 buffer[(*bufferoffset)++]=0xff;
99 buffer[(*bufferoffset)++]=0xdd;
100 buffer[(*bufferoffset)++]=0x00;
101 buffer[(*bufferoffset)++]=0x04;
102 buffer[(*bufferoffset)++]=(ri >> 8) & 0xff;
103 buffer[(*bufferoffset)++]= ri & 0xff;
104- } else {
105- i+=strip[i+2]+2;
106 }
107 break;
108- case 0xc4:
109- case 0xdb:
110- _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), strip[i+2]+2);
111- *bufferoffset+=strip[i+2]+2;
112- i+=strip[i+2]+2;
113+ case 0xc4: /* DHT */
114+ case 0xdb: /* DQT */
115+ _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2);
116+ *bufferoffset+=datalen+2;
117 break;
118- case 0xda:
119+ case 0xda: /* SOS */
120 if(no==0){
121- _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), strip[i+2]+2);
122- *bufferoffset+=strip[i+2]+2;
123- i+=strip[i+2]+2;
124+ _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2);
125+ *bufferoffset+=datalen+2;
126 } else {
127 buffer[(*bufferoffset)++]=0xff;
128 buffer[(*bufferoffset)++]=
129 (unsigned char)(0xd0 | ((no-1)%8));
130- i+=strip[i+2]+2;
131 }
132- _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), (*striplength)-i-1);
133- *bufferoffset+=(*striplength)-i-1;
134+ i += datalen + 1;
135+ /* copy remainder of strip */
136+ _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i]), *striplength - i);
137+ *bufferoffset+= *striplength - i;
138 return(1);
139 default:
140- i+=strip[i+2]+2;
141+ /* ignore any other marker */
142+ break;
143 }
144+ i += datalen + 1;
145 }
146-
147
148+ /* failed to find SOS marker */
149 return(0);
150 }
151 #endif
diff --git a/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-1961.patch b/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-1961.patch
new file mode 100644
index 0000000000..fc4adb59d8
--- /dev/null
+++ b/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-1961.patch
@@ -0,0 +1,786 @@
1libtiff: fix CVE-2013-1961.
2
3Upstream-Status: Backported
4
5Issue Description: CVE-2013-1961
6Stack-based buffer overflow in the t2p_write_pdf_page function in tiff2pdf
7in libtiff before 4.0.3 allows remote attackers to cause a denial of service
8(application crash) via a crafted image length and resolution in a TIFF image file.
9
10Fix Description: Replace sprintf with snprintf
11
12Signed-off-by: Priyanka Shobhan <priyanka_shobhan@mentor.com>
13---
14
15diff --git a/contrib/dbs/xtiff/xtiff.c b/contrib/dbs/xtiff/xtiff.c
16index 2634030..97e4ffe 100644
17--- a/contrib/dbs/xtiff/xtiff.c
18+++ b/contrib/dbs/xtiff/xtiff.c
19@@ -512,9 +512,9 @@ SetNameLabel()
20 Arg args[1];
21
22 if (tfMultiPage)
23- sprintf(buffer, "%s - page %d", fileName, tfDirectory);
24+ snprintf(buffer, sizeof(buffer), "%s - page %d", fileName, tfDirectory);
25 else
26- strcpy(buffer, fileName);
27+ snprintf(buffer, sizeof(buffer), "%s", fileName);
28 XtSetArg(args[0], XtNlabel, buffer);
29 XtSetValues(labelWidget, args, 1);
30 }
31diff --git a/libtiff/tif_codec.c b/libtiff/tif_codec.c
32index e201667..703e87d 100644
33--- a/libtiff/tif_codec.c
34+++ b/libtiff/tif_codec.c
35@@ -108,7 +108,8 @@ _notConfigured(TIFF* tif)
36 const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
37 char compression_code[20];
38
39- sprintf( compression_code, "%d", tif->tif_dir.td_compression );
40+ snprintf(compression_code, sizeof(compression_code), "%d",
41+ tif->tif_dir.td_compression );
42 TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
43 "%s compression support is not configured",
44 c ? c->name : compression_code );
45diff --git a/libtiff/tif_dirinfo.c b/libtiff/tif_dirinfo.c
46index d319931..4dae5e5 100644
47--- a/libtiff/tif_dirinfo.c
48+++ b/libtiff/tif_dirinfo.c
49@@ -711,7 +711,7 @@ _TIFFCreateAnonField(TIFF *tif, uint32 tag, TIFFDataType field_type)
50 * note that this name is a special sign to TIFFClose() and
51 * _TIFFSetupFields() to free the field
52 */
53- sprintf(fld->field_name, "Tag %d", (int) tag);
54+ snprintf(fld->field_name, 32, "Tag %d", (int) tag);
55
56 return fld;
57 }
58diff --git a/tools/rgb2ycbcr.c b/tools/rgb2ycbcr.c
59index 162aac1..a3eeb03 100644
60--- a/tools/rgb2ycbcr.c
61+++ b/tools/rgb2ycbcr.c
62@@ -332,7 +332,8 @@ tiffcvt(TIFF* in, TIFF* out)
63 TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
64 { char buf[2048];
65 char *cp = strrchr(TIFFFileName(in), '/');
66- sprintf(buf, "YCbCr conversion of %s", cp ? cp+1 : TIFFFileName(in));
67+ snprintf(buf, sizeof(buf), "YCbCr conversion of %s",
68+ cp ? cp+1 : TIFFFileName(in));
69 TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, buf);
70 }
71 TIFFSetField(out, TIFFTAG_SOFTWARE, TIFFGetVersion());
72diff --git a/tools/tiff2bw.c b/tools/tiff2bw.c
73index bda754a..7ffaca0 100644
74--- a/tools/tiff2bw.c
75+++ b/tools/tiff2bw.c
76@@ -205,7 +205,7 @@ main(int argc, char* argv[])
77 }
78 }
79 TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
80- sprintf(thing, "B&W version of %s", argv[optind]);
81+ snprintf(thing, sizeof(thing), "B&W version of %s", argv[optind]);
82 TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, thing);
83 TIFFSetField(out, TIFFTAG_SOFTWARE, "tiff2bw");
84 outbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out));
85diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
86index 356328c..957fd9f 100644
87--- a/tools/tiff2pdf.c
88+++ b/tools/tiff2pdf.c
89@@ -3609,7 +3609,9 @@ tsize_t t2p_write_pdf_header(T2P* t2p, TIFF* output){
90 char buffer[16];
91 int buflen=0;
92
93- buflen=sprintf(buffer, "%%PDF-%u.%u ", t2p->pdf_majorversion&0xff, t2p->pdf_minorversion&0xff);
94+ buflen = snprintf(buffer, sizeof(buffer), "%%PDF-%u.%u ",
95+ t2p->pdf_majorversion&0xff,
96+ t2p->pdf_minorversion&0xff);
97 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
98 written += t2pWriteFile(output, (tdata_t)"\n%\342\343\317\323\n", 7);
99
100@@ -3623,10 +3625,10 @@ tsize_t t2p_write_pdf_header(T2P* t2p, TIFF* output){
101 tsize_t t2p_write_pdf_obj_start(uint32 number, TIFF* output){
102
103 tsize_t written=0;
104- char buffer[16];
105+ char buffer[32];
106 int buflen=0;
107
108- buflen=sprintf(buffer, "%lu", (unsigned long)number);
109+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)number);
110 written += t2pWriteFile(output, (tdata_t) buffer, buflen );
111 written += t2pWriteFile(output, (tdata_t) " 0 obj\n", 7);
112
113@@ -3665,13 +3667,13 @@ tsize_t t2p_write_pdf_name(unsigned char* name, TIFF* output){
114 written += t2pWriteFile(output, (tdata_t) "/", 1);
115 for (i=0;i<namelen;i++){
116 if ( ((unsigned char)name[i]) < 0x21){
117- sprintf(buffer, "#%.2X", name[i]);
118+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
119 buffer[sizeof(buffer) - 1] = '\0';
120 written += t2pWriteFile(output, (tdata_t) buffer, 3);
121 nextchar=1;
122 }
123 if ( ((unsigned char)name[i]) > 0x7E){
124- sprintf(buffer, "#%.2X", name[i]);
125+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
126 buffer[sizeof(buffer) - 1] = '\0';
127 written += t2pWriteFile(output, (tdata_t) buffer, 3);
128 nextchar=1;
129@@ -3679,57 +3681,57 @@ tsize_t t2p_write_pdf_name(unsigned char* name, TIFF* output){
130 if (nextchar==0){
131 switch (name[i]){
132 case 0x23:
133- sprintf(buffer, "#%.2X", name[i]);
134+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
135 buffer[sizeof(buffer) - 1] = '\0';
136 written += t2pWriteFile(output, (tdata_t) buffer, 3);
137 break;
138 case 0x25:
139- sprintf(buffer, "#%.2X", name[i]);
140+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
141 buffer[sizeof(buffer) - 1] = '\0';
142 written += t2pWriteFile(output, (tdata_t) buffer, 3);
143 break;
144 case 0x28:
145- sprintf(buffer, "#%.2X", name[i]);
146+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
147 buffer[sizeof(buffer) - 1] = '\0';
148 written += t2pWriteFile(output, (tdata_t) buffer, 3);
149 break;
150 case 0x29:
151- sprintf(buffer, "#%.2X", name[i]);
152+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
153 buffer[sizeof(buffer) - 1] = '\0';
154 written += t2pWriteFile(output, (tdata_t) buffer, 3);
155 break;
156 case 0x2F:
157- sprintf(buffer, "#%.2X", name[i]);
158+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
159 buffer[sizeof(buffer) - 1] = '\0';
160 written += t2pWriteFile(output, (tdata_t) buffer, 3);
161 break;
162 case 0x3C:
163- sprintf(buffer, "#%.2X", name[i]);
164+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
165 buffer[sizeof(buffer) - 1] = '\0';
166 written += t2pWriteFile(output, (tdata_t) buffer, 3);
167 break;
168 case 0x3E:
169- sprintf(buffer, "#%.2X", name[i]);
170+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
171 buffer[sizeof(buffer) - 1] = '\0';
172 written += t2pWriteFile(output, (tdata_t) buffer, 3);
173 break;
174 case 0x5B:
175- sprintf(buffer, "#%.2X", name[i]);
176+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
177 buffer[sizeof(buffer) - 1] = '\0';
178 written += t2pWriteFile(output, (tdata_t) buffer, 3);
179 break;
180 case 0x5D:
181- sprintf(buffer, "#%.2X", name[i]);
182+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
183 buffer[sizeof(buffer) - 1] = '\0';
184 written += t2pWriteFile(output, (tdata_t) buffer, 3);
185 break;
186 case 0x7B:
187- sprintf(buffer, "#%.2X", name[i]);
188+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
189 buffer[sizeof(buffer) - 1] = '\0';
190 written += t2pWriteFile(output, (tdata_t) buffer, 3);
191 break;
192 case 0x7D:
193- sprintf(buffer, "#%.2X", name[i]);
194+ snprintf(buffer, sizeof(buffer), "#%.2X", name[i]);
195 buffer[sizeof(buffer) - 1] = '\0';
196 written += t2pWriteFile(output, (tdata_t) buffer, 3);
197 break;
198@@ -3844,14 +3846,14 @@ tsize_t t2p_write_pdf_stream_end(TIFF* output){
199 tsize_t t2p_write_pdf_stream_dict(tsize_t len, uint32 number, TIFF* output){
200
201 tsize_t written=0;
202- char buffer[16];
203+ char buffer[32];
204 int buflen=0;
205
206 written += t2pWriteFile(output, (tdata_t) "/Length ", 8);
207 if(len!=0){
208 written += t2p_write_pdf_stream_length(len, output);
209 } else {
210- buflen=sprintf(buffer, "%lu", (unsigned long)number);
211+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)number);
212 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
213 written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6);
214 }
215@@ -3892,10 +3894,10 @@ tsize_t t2p_write_pdf_stream_dict_end(TIFF* output){
216 tsize_t t2p_write_pdf_stream_length(tsize_t len, TIFF* output){
217
218 tsize_t written=0;
219- char buffer[16];
220+ char buffer[32];
221 int buflen=0;
222
223- buflen=sprintf(buffer, "%lu", (unsigned long)len);
224+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)len);
225 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
226 written += t2pWriteFile(output, (tdata_t) "\n", 1);
227
228@@ -3909,7 +3911,7 @@ tsize_t t2p_write_pdf_stream_length(tsize_t len, TIFF* output){
229 tsize_t t2p_write_pdf_catalog(T2P* t2p, TIFF* output)
230 {
231 tsize_t written = 0;
232- char buffer[16];
233+ char buffer[32];
234 int buflen = 0;
235
236 written += t2pWriteFile(output,
237@@ -3948,7 +3950,6 @@ tsize_t t2p_write_pdf_info(T2P* t2p, TIFF* input, TIFF* output)
238 written += t2p_write_pdf_string(t2p->pdf_datetime, output);
239 }
240 written += t2pWriteFile(output, (tdata_t) "\n/Producer ", 11);
241- _TIFFmemset((tdata_t)buffer, 0x00, sizeof(buffer));
242 snprintf(buffer, sizeof(buffer), "libtiff / tiff2pdf - %d", TIFFLIB_VERSION);
243 written += t2p_write_pdf_string(buffer, output);
244 written += t2pWriteFile(output, (tdata_t) "\n", 1);
245@@ -4089,7 +4090,7 @@ tsize_t t2p_write_pdf_pages(T2P* t2p, TIFF* output)
246 {
247 tsize_t written=0;
248 tdir_t i=0;
249- char buffer[16];
250+ char buffer[32];
251 int buflen=0;
252
253 int page=0;
254@@ -4097,7 +4098,7 @@ tsize_t t2p_write_pdf_pages(T2P* t2p, TIFF* output)
255 (tdata_t) "<< \n/Type /Pages \n/Kids [ ", 26);
256 page = t2p->pdf_pages+1;
257 for (i=0;i<t2p->tiff_pagecount;i++){
258- buflen=sprintf(buffer, "%d", page);
259+ buflen=snprintf(buffer, sizeof(buffer), "%d", page);
260 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
261 written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
262 if ( ((i+1)%8)==0 ) {
263@@ -4112,8 +4113,7 @@ tsize_t t2p_write_pdf_pages(T2P* t2p, TIFF* output)
264 }
265 }
266 written += t2pWriteFile(output, (tdata_t) "] \n/Count ", 10);
267- _TIFFmemset(buffer, 0x00, 16);
268- buflen=sprintf(buffer, "%d", t2p->tiff_pagecount);
269+ buflen=snprintf(buffer, sizeof(buffer), "%d", t2p->tiff_pagecount);
270 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
271 written += t2pWriteFile(output, (tdata_t) " \n>> \n", 6);
272
273@@ -4128,28 +4128,28 @@ tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){
274
275 unsigned int i=0;
276 tsize_t written=0;
277- char buffer[16];
278+ char buffer[256];
279 int buflen=0;
280
281 written += t2pWriteFile(output, (tdata_t) "<<\n/Type /Page \n/Parent ", 24);
282- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_pages);
283+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_pages);
284 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
285 written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6);
286 written += t2pWriteFile(output, (tdata_t) "/MediaBox [", 11);
287- buflen=sprintf(buffer, "%.4f",t2p->pdf_mediabox.x1);
288+ buflen=snprintf(buffer, sizeof(buffer), "%.4f",t2p->pdf_mediabox.x1);
289 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
290 written += t2pWriteFile(output, (tdata_t) " ", 1);
291- buflen=sprintf(buffer, "%.4f",t2p->pdf_mediabox.y1);
292+ buflen=snprintf(buffer, sizeof(buffer), "%.4f",t2p->pdf_mediabox.y1);
293 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
294 written += t2pWriteFile(output, (tdata_t) " ", 1);
295- buflen=sprintf(buffer, "%.4f",t2p->pdf_mediabox.x2);
296+ buflen=snprintf(buffer, sizeof(buffer), "%.4f",t2p->pdf_mediabox.x2);
297 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
298 written += t2pWriteFile(output, (tdata_t) " ", 1);
299- buflen=sprintf(buffer, "%.4f",t2p->pdf_mediabox.y2);
300+ buflen=snprintf(buffer, sizeof(buffer), "%.4f",t2p->pdf_mediabox.y2);
301 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
302 written += t2pWriteFile(output, (tdata_t) "] \n", 3);
303 written += t2pWriteFile(output, (tdata_t) "/Contents ", 10);
304- buflen=sprintf(buffer, "%lu", (unsigned long)(object + 1));
305+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(object + 1));
306 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
307 written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6);
308 written += t2pWriteFile(output, (tdata_t) "/Resources << \n", 15);
309@@ -4157,15 +4157,13 @@ tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){
310 written += t2pWriteFile(output, (tdata_t) "/XObject <<\n", 12);
311 for(i=0;i<t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount;i++){
312 written += t2pWriteFile(output, (tdata_t) "/Im", 3);
313- buflen = sprintf(buffer, "%u", t2p->pdf_page+1);
314+ buflen = snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1);
315 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
316 written += t2pWriteFile(output, (tdata_t) "_", 1);
317- buflen = sprintf(buffer, "%u", i+1);
318+ buflen = snprintf(buffer, sizeof(buffer), "%u", i+1);
319 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
320 written += t2pWriteFile(output, (tdata_t) " ", 1);
321- buflen = sprintf(
322- buffer,
323- "%lu",
324+ buflen = snprintf(buffer, sizeof(buffer), "%lu",
325 (unsigned long)(object+3+(2*i)+t2p->tiff_pages[t2p->pdf_page].page_extra));
326 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
327 written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
328@@ -4177,12 +4175,10 @@ tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){
329 } else {
330 written += t2pWriteFile(output, (tdata_t) "/XObject <<\n", 12);
331 written += t2pWriteFile(output, (tdata_t) "/Im", 3);
332- buflen = sprintf(buffer, "%u", t2p->pdf_page+1);
333+ buflen = snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1);
334 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
335 written += t2pWriteFile(output, (tdata_t) " ", 1);
336- buflen = sprintf(
337- buffer,
338- "%lu",
339+ buflen = snprintf(buffer, sizeof(buffer), "%lu",
340 (unsigned long)(object+3+(2*i)+t2p->tiff_pages[t2p->pdf_page].page_extra));
341 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
342 written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
343@@ -4191,9 +4187,7 @@ tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){
344 if(t2p->tiff_transferfunctioncount != 0) {
345 written += t2pWriteFile(output, (tdata_t) "/ExtGState <<", 13);
346 t2pWriteFile(output, (tdata_t) "/GS1 ", 5);
347- buflen = sprintf(
348- buffer,
349- "%lu",
350+ buflen = snprintf(buffer, sizeof(buffer), "%lu",
351 (unsigned long)(object + 3));
352 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
353 written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
354@@ -4566,7 +4560,7 @@ tsize_t t2p_write_pdf_page_content_stream(T2P* t2p, TIFF* output){
355 if(t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount>0){
356 for(i=0;i<t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount; i++){
357 box=t2p->tiff_tiles[t2p->pdf_page].tiles_tiles[i].tile_box;
358- buflen=sprintf(buffer,
359+ buflen=snprintf(buffer, sizeof(buffer),
360 "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%d_%ld Do Q\n",
361 t2p->tiff_transferfunctioncount?"/GS1 gs ":"",
362 box.mat[0],
363@@ -4581,7 +4575,7 @@ tsize_t t2p_write_pdf_page_content_stream(T2P* t2p, TIFF* output){
364 }
365 } else {
366 box=t2p->pdf_imagebox;
367- buflen=sprintf(buffer,
368+ buflen=snprintf(buffer, sizeof(buffer),
369 "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%d Do Q\n",
370 t2p->tiff_transferfunctioncount?"/GS1 gs ":"",
371 box.mat[0],
372@@ -4606,59 +4600,48 @@ tsize_t t2p_write_pdf_xobject_stream_dict(ttile_t tile,
373 TIFF* output){
374
375 tsize_t written=0;
376- char buffer[16];
377+ char buffer[32];
378 int buflen=0;
379
380 written += t2p_write_pdf_stream_dict(0, t2p->pdf_xrefcount+1, output);
381 written += t2pWriteFile(output,
382 (tdata_t) "/Type /XObject \n/Subtype /Image \n/Name /Im",
383 42);
384- buflen=sprintf(buffer, "%u", t2p->pdf_page+1);
385+ buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1);
386 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
387 if(tile != 0){
388 written += t2pWriteFile(output, (tdata_t) "_", 1);
389- buflen=sprintf(buffer, "%lu", (unsigned long)tile);
390+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)tile);
391 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
392 }
393 written += t2pWriteFile(output, (tdata_t) "\n/Width ", 8);
394- _TIFFmemset((tdata_t)buffer, 0x00, 16);
395 if(tile==0){
396- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->tiff_width);
397+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->tiff_width);
398 } else {
399 if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)!=0){
400- buflen=sprintf(
401- buffer,
402- "%lu",
403+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
404 (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth);
405 } else {
406- buflen=sprintf(
407- buffer,
408- "%lu",
409+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
410 (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth);
411 }
412 }
413 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
414 written += t2pWriteFile(output, (tdata_t) "\n/Height ", 9);
415- _TIFFmemset((tdata_t)buffer, 0x00, 16);
416 if(tile==0){
417- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->tiff_length);
418+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->tiff_length);
419 } else {
420 if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)!=0){
421- buflen=sprintf(
422- buffer,
423- "%lu",
424+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
425 (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength);
426 } else {
427- buflen=sprintf(
428- buffer,
429- "%lu",
430+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
431 (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength);
432 }
433 }
434 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
435 written += t2pWriteFile(output, (tdata_t) "\n/BitsPerComponent ", 19);
436- _TIFFmemset((tdata_t)buffer, 0x00, 16);
437- buflen=sprintf(buffer, "%u", t2p->tiff_bitspersample);
438+ buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_bitspersample);
439 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
440 written += t2pWriteFile(output, (tdata_t) "\n/ColorSpace ", 13);
441 written += t2p_write_pdf_xobject_cs(t2p, output);
442@@ -4702,11 +4685,10 @@ tsize_t t2p_write_pdf_xobject_cs(T2P* t2p, TIFF* output){
443 t2p->pdf_colorspace ^= T2P_CS_PALETTE;
444 written += t2p_write_pdf_xobject_cs(t2p, output);
445 t2p->pdf_colorspace |= T2P_CS_PALETTE;
446- buflen=sprintf(buffer, "%u", (0x0001 << t2p->tiff_bitspersample)-1 );
447+ buflen=snprintf(buffer, sizeof(buffer), "%u", (0x0001 << t2p->tiff_bitspersample)-1 );
448 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
449 written += t2pWriteFile(output, (tdata_t) " ", 1);
450- _TIFFmemset(buffer, 0x00, 16);
451- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_palettecs );
452+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_palettecs );
453 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
454 written += t2pWriteFile(output, (tdata_t) " 0 R ]\n", 7);
455 return(written);
456@@ -4740,10 +4722,10 @@ tsize_t t2p_write_pdf_xobject_cs(T2P* t2p, TIFF* output){
457 X_W /= Y_W;
458 Z_W /= Y_W;
459 Y_W = 1.0F;
460- buflen=sprintf(buffer, "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W);
461+ buflen=snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W);
462 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
463 written += t2pWriteFile(output, (tdata_t) "/Range ", 7);
464- buflen=sprintf(buffer, "[%d %d %d %d] \n",
465+ buflen=snprintf(buffer, sizeof(buffer), "[%d %d %d %d] \n",
466 t2p->pdf_labrange[0],
467 t2p->pdf_labrange[1],
468 t2p->pdf_labrange[2],
469@@ -4759,26 +4741,26 @@ tsize_t t2p_write_pdf_xobject_cs(T2P* t2p, TIFF* output){
470 tsize_t t2p_write_pdf_transfer(T2P* t2p, TIFF* output){
471
472 tsize_t written=0;
473- char buffer[16];
474+ char buffer[32];
475 int buflen=0;
476
477 written += t2pWriteFile(output, (tdata_t) "<< /Type /ExtGState \n/TR ", 25);
478 if(t2p->tiff_transferfunctioncount == 1){
479- buflen=sprintf(buffer, "%lu",
480+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
481 (unsigned long)(t2p->pdf_xrefcount + 1));
482 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
483 written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
484 } else {
485 written += t2pWriteFile(output, (tdata_t) "[ ", 2);
486- buflen=sprintf(buffer, "%lu",
487+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
488 (unsigned long)(t2p->pdf_xrefcount + 1));
489 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
490 written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
491- buflen=sprintf(buffer, "%lu",
492+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
493 (unsigned long)(t2p->pdf_xrefcount + 2));
494 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
495 written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
496- buflen=sprintf(buffer, "%lu",
497+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
498 (unsigned long)(t2p->pdf_xrefcount + 3));
499 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
500 written += t2pWriteFile(output, (tdata_t) " 0 R ", 5);
501@@ -4800,7 +4782,7 @@ tsize_t t2p_write_pdf_transfer_dict(T2P* t2p, TIFF* output, uint16 i){
502 written += t2pWriteFile(output, (tdata_t) "/FunctionType 0 \n", 17);
503 written += t2pWriteFile(output, (tdata_t) "/Domain [0.0 1.0] \n", 19);
504 written += t2pWriteFile(output, (tdata_t) "/Range [0.0 1.0] \n", 18);
505- buflen=sprintf(buffer, "/Size [%u] \n", (1<<t2p->tiff_bitspersample));
506+ buflen=snprintf(buffer, sizeof(buffer), "/Size [%u] \n", (1<<t2p->tiff_bitspersample));
507 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
508 written += t2pWriteFile(output, (tdata_t) "/BitsPerSample 16 \n", 19);
509 written += t2p_write_pdf_stream_dict(((tsize_t)1)<<(t2p->tiff_bitspersample+1), 0, output);
510@@ -4827,7 +4809,7 @@ tsize_t t2p_write_pdf_transfer_stream(T2P* t2p, TIFF* output, uint16 i){
511 tsize_t t2p_write_pdf_xobject_calcs(T2P* t2p, TIFF* output){
512
513 tsize_t written=0;
514- char buffer[128];
515+ char buffer[256];
516 int buflen=0;
517
518 float X_W=0.0;
519@@ -4895,16 +4877,16 @@ tsize_t t2p_write_pdf_xobject_calcs(T2P* t2p, TIFF* output){
520 written += t2pWriteFile(output, (tdata_t) "<< \n", 4);
521 if(t2p->pdf_colorspace & T2P_CS_CALGRAY){
522 written += t2pWriteFile(output, (tdata_t) "/WhitePoint ", 12);
523- buflen=sprintf(buffer, "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W);
524+ buflen=snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W);
525 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
526 written += t2pWriteFile(output, (tdata_t) "/Gamma 2.2 \n", 12);
527 }
528 if(t2p->pdf_colorspace & T2P_CS_CALRGB){
529 written += t2pWriteFile(output, (tdata_t) "/WhitePoint ", 12);
530- buflen=sprintf(buffer, "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W);
531+ buflen=snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W);
532 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
533 written += t2pWriteFile(output, (tdata_t) "/Matrix ", 8);
534- buflen=sprintf(buffer, "[%.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f] \n",
535+ buflen=snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f] \n",
536 X_R, Y_R, Z_R,
537 X_G, Y_G, Z_G,
538 X_B, Y_B, Z_B);
539@@ -4923,11 +4905,11 @@ tsize_t t2p_write_pdf_xobject_calcs(T2P* t2p, TIFF* output){
540 tsize_t t2p_write_pdf_xobject_icccs(T2P* t2p, TIFF* output){
541
542 tsize_t written=0;
543- char buffer[16];
544+ char buffer[32];
545 int buflen=0;
546
547 written += t2pWriteFile(output, (tdata_t) "[/ICCBased ", 11);
548- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_icccs);
549+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_icccs);
550 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
551 written += t2pWriteFile(output, (tdata_t) " 0 R] \n", 7);
552
553@@ -4937,11 +4919,11 @@ tsize_t t2p_write_pdf_xobject_icccs(T2P* t2p, TIFF* output){
554 tsize_t t2p_write_pdf_xobject_icccs_dict(T2P* t2p, TIFF* output){
555
556 tsize_t written=0;
557- char buffer[16];
558+ char buffer[32];
559 int buflen=0;
560
561 written += t2pWriteFile(output, (tdata_t) "/N ", 3);
562- buflen=sprintf(buffer, "%u \n", t2p->tiff_samplesperpixel);
563+ buflen=snprintf(buffer, sizeof(buffer), "%u \n", t2p->tiff_samplesperpixel);
564 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
565 written += t2pWriteFile(output, (tdata_t) "/Alternate ", 11);
566 t2p->pdf_colorspace ^= T2P_CS_ICCBASED;
567@@ -5006,7 +4988,7 @@ tsize_t t2p_write_pdf_xobject_decode(T2P* t2p, TIFF* output){
568 tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t tile, T2P* t2p, TIFF* output){
569
570 tsize_t written=0;
571- char buffer[16];
572+ char buffer[32];
573 int buflen=0;
574
575 if(t2p->pdf_compression==T2P_COMPRESS_NONE){
576@@ -5021,41 +5003,33 @@ tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t tile, T2P* t2p, TIFF* output
577 written += t2pWriteFile(output, (tdata_t) "<< /K -1 ", 9);
578 if(tile==0){
579 written += t2pWriteFile(output, (tdata_t) "/Columns ", 9);
580- buflen=sprintf(buffer, "%lu",
581+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
582 (unsigned long)t2p->tiff_width);
583 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
584 written += t2pWriteFile(output, (tdata_t) " /Rows ", 7);
585- buflen=sprintf(buffer, "%lu",
586+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
587 (unsigned long)t2p->tiff_length);
588 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
589 } else {
590 if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){
591 written += t2pWriteFile(output, (tdata_t) "/Columns ", 9);
592- buflen=sprintf(
593- buffer,
594- "%lu",
595+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
596 (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth);
597 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
598 } else {
599 written += t2pWriteFile(output, (tdata_t) "/Columns ", 9);
600- buflen=sprintf(
601- buffer,
602- "%lu",
603+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
604 (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth);
605 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
606 }
607 if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){
608 written += t2pWriteFile(output, (tdata_t) " /Rows ", 7);
609- buflen=sprintf(
610- buffer,
611- "%lu",
612+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
613 (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength);
614 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
615 } else {
616 written += t2pWriteFile(output, (tdata_t) " /Rows ", 7);
617- buflen=sprintf(
618- buffer,
619- "%lu",
620+ buflen=snprintf(buffer, sizeof(buffer), "%lu",
621 (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength);
622 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
623 }
624@@ -5082,21 +5056,17 @@ tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t tile, T2P* t2p, TIFF* output
625 if(t2p->pdf_compressionquality%100){
626 written += t2pWriteFile(output, (tdata_t) "/DecodeParms ", 13);
627 written += t2pWriteFile(output, (tdata_t) "<< /Predictor ", 14);
628- _TIFFmemset(buffer, 0x00, 16);
629- buflen=sprintf(buffer, "%u", t2p->pdf_compressionquality%100);
630+ buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_compressionquality%100);
631 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
632 written += t2pWriteFile(output, (tdata_t) " /Columns ", 10);
633- _TIFFmemset(buffer, 0x00, 16);
634- buflen = sprintf(buffer, "%lu",
635+ buflen = snprintf(buffer, sizeof(buffer), "%lu",
636 (unsigned long)t2p->tiff_width);
637 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
638 written += t2pWriteFile(output, (tdata_t) " /Colors ", 9);
639- _TIFFmemset(buffer, 0x00, 16);
640- buflen=sprintf(buffer, "%u", t2p->tiff_samplesperpixel);
641+ buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_samplesperpixel);
642 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
643 written += t2pWriteFile(output, (tdata_t) " /BitsPerComponent ", 19);
644- _TIFFmemset(buffer, 0x00, 16);
645- buflen=sprintf(buffer, "%u", t2p->tiff_bitspersample);
646+ buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_bitspersample);
647 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
648 written += t2pWriteFile(output, (tdata_t) ">>\n", 3);
649 }
650@@ -5116,16 +5086,16 @@ tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t tile, T2P* t2p, TIFF* output
651 tsize_t t2p_write_pdf_xreftable(T2P* t2p, TIFF* output){
652
653 tsize_t written=0;
654- char buffer[21];
655+ char buffer[64];
656 int buflen=0;
657 uint32 i=0;
658
659 written += t2pWriteFile(output, (tdata_t) "xref\n0 ", 7);
660- buflen=sprintf(buffer, "%lu", (unsigned long)(t2p->pdf_xrefcount + 1));
661+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(t2p->pdf_xrefcount + 1));
662 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
663 written += t2pWriteFile(output, (tdata_t) " \n0000000000 65535 f \n", 22);
664 for (i=0;i<t2p->pdf_xrefcount;i++){
665- sprintf(buffer, "%.10lu 00000 n \n",
666+ snprintf(buffer, sizeof(buffer), "%.10lu 00000 n \n",
667 (unsigned long)t2p->pdf_xrefoffsets[i]);
668 written += t2pWriteFile(output, (tdata_t) buffer, 20);
669 }
670@@ -5149,17 +5119,14 @@ tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output)
671 snprintf(t2p->pdf_fileid + i, 9, "%.8X", rand());
672
673 written += t2pWriteFile(output, (tdata_t) "trailer\n<<\n/Size ", 17);
674- buflen = sprintf(buffer, "%lu", (unsigned long)(t2p->pdf_xrefcount+1));
675+ buflen = snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(t2p->pdf_xrefcount+1));
676 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
677- _TIFFmemset(buffer, 0x00, 32);
678 written += t2pWriteFile(output, (tdata_t) "\n/Root ", 7);
679- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_catalog);
680+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_catalog);
681 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
682- _TIFFmemset(buffer, 0x00, 32);
683 written += t2pWriteFile(output, (tdata_t) " 0 R \n/Info ", 12);
684- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_info);
685+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_info);
686 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
687- _TIFFmemset(buffer, 0x00, 32);
688 written += t2pWriteFile(output, (tdata_t) " 0 R \n/ID[<", 11);
689 written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid,
690 sizeof(t2p->pdf_fileid) - 1);
691@@ -5167,9 +5134,8 @@ tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output)
692 written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid,
693 sizeof(t2p->pdf_fileid) - 1);
694 written += t2pWriteFile(output, (tdata_t) ">]\n>>\nstartxref\n", 16);
695- buflen=sprintf(buffer, "%lu", (unsigned long)t2p->pdf_startxref);
696+ buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_startxref);
697 written += t2pWriteFile(output, (tdata_t) buffer, buflen);
698- _TIFFmemset(buffer, 0x00, 32);
699 written += t2pWriteFile(output, (tdata_t) "\n%%EOF\n", 7);
700
701 return(written);
702diff --git a/tools/tiff2ps.c b/tools/tiff2ps.c
703index 3330750..7a9a816 100644
704--- a/tools/tiff2ps.c
705+++ b/tools/tiff2ps.c
706@@ -1789,8 +1789,8 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h)
707 imageOp = "imagemask";
708
709 (void)strcpy(im_x, "0");
710- (void)sprintf(im_y, "%lu", (long) h);
711- (void)sprintf(im_h, "%lu", (long) h);
712+ (void)snprintf(im_y, sizeof(im_y), "%lu", (long) h);
713+ (void)snprintf(im_h, sizeof(im_h), "%lu", (long) h);
714 tile_width = w;
715 tile_height = h;
716 if (TIFFIsTiled(tif)) {
717@@ -1811,7 +1811,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h)
718 }
719 if (tile_height < h) {
720 fputs("/im_y 0 def\n", fd);
721- (void)sprintf(im_y, "%lu im_y sub", (unsigned long) h);
722+ (void)snprintf(im_y, sizeof(im_y), "%lu im_y sub", (unsigned long) h);
723 }
724 } else {
725 repeat_count = tf_numberstrips;
726@@ -1823,7 +1823,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h)
727 fprintf(fd, "/im_h %lu def\n",
728 (unsigned long) tile_height);
729 (void)strcpy(im_h, "im_h");
730- (void)sprintf(im_y, "%lu im_y sub", (unsigned long) h);
731+ (void)snprintf(im_y, sizeof(im_y), "%lu im_y sub", (unsigned long) h);
732 }
733 }
734
735diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
736index 9cd5d86..a2443aa 100644
737--- a/tools/tiffcrop.c
738+++ b/tools/tiffcrop.c
739@@ -2077,7 +2077,7 @@ update_output_file (TIFF **tiffout, char *mode, int autoindex,
740 return 1;
741 }
742
743- sprintf (filenum, "-%03d%s", findex, export_ext);
744+ snprintf(filenum, sizeof(filenum), "-%03d%s", findex, export_ext);
745 filenum[14] = '\0';
746 strncat (exportname, filenum, 15);
747 }
748@@ -2230,8 +2230,8 @@ main(int argc, char* argv[])
749
750 /* dump.infilename is guaranteed to be NUL termimated and have 20 bytes
751 fewer than PATH_MAX */
752- memset (temp_filename, '\0', PATH_MAX + 1);
753- sprintf (temp_filename, "%s-read-%03d.%s", dump.infilename, dump_images,
754+ snprintf(temp_filename, sizeof(temp_filename), "%s-read-%03d.%s",
755+ dump.infilename, dump_images,
756 (dump.format == DUMP_TEXT) ? "txt" : "raw");
757 if ((dump.infile = fopen(temp_filename, dump.mode)) == NULL)
758 {
759@@ -2249,8 +2249,8 @@ main(int argc, char* argv[])
760
761 /* dump.outfilename is guaranteed to be NUL termimated and have 20 bytes
762 fewer than PATH_MAX */
763- memset (temp_filename, '\0', PATH_MAX + 1);
764- sprintf (temp_filename, "%s-write-%03d.%s", dump.outfilename, dump_images,
765+ snprintf(temp_filename, sizeof(temp_filename), "%s-write-%03d.%s",
766+ dump.outfilename, dump_images,
767 (dump.format == DUMP_TEXT) ? "txt" : "raw");
768 if ((dump.outfile = fopen(temp_filename, dump.mode)) == NULL)
769 {
770diff --git a/tools/tiffdither.c b/tools/tiffdither.c
771index f2f0f20..4308946 100644
772--- a/tools/tiffdither.c
773+++ b/tools/tiffdither.c
774@@ -260,7 +260,7 @@ main(int argc, char* argv[])
775 TIFFSetField(out, TIFFTAG_FILLORDER, fillorder);
776 else
777 CopyField(TIFFTAG_FILLORDER, shortv);
778- sprintf(thing, "Dithered B&W version of %s", argv[optind]);
779+ snprintf(thing, sizeof(thing), "Dithered B&W version of %s", argv[optind]);
780 TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, thing);
781 CopyField(TIFFTAG_PHOTOMETRIC, shortv);
782 CopyField(TIFFTAG_ORIENTATION, shortv);
783--
7841.8.3.rc3
785
786
diff --git a/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4231.patch b/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4231.patch
new file mode 100644
index 0000000000..d8d4e961db
--- /dev/null
+++ b/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4231.patch
@@ -0,0 +1,44 @@
1Upstream-Status: Backport
2
3Multiple buffer overflows in libtiff before 4.0.3 allow remote attackers
4to cause a denial of service (out-of-bounds write) via a crafted (1)
5extension block in a GIF image or (2) GIF raster image to
6tools/gif2tiff.c or (3) a long filename for a TIFF image to
7tools/rgb2ycbcr.c. NOTE: vectors 1 and 3 are disputed by Red Hat, which
8states that the input cannot exceed the allocated buffer size.
9
10http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2013-4231Multiple
11buffer overflows in libtiff before 4.0.3 allow remote attackers to cause
12a denial of service (out-of-bounds write) via a crafted (1) extension
13block in a GIF image or (2) GIF raster image to tools/gif2tiff.c or (3)
14a long filename for a TIFF image to tools/rgb2ycbcr.c. NOTE: vectors 1
15and 3 are disputed by Red Hat, which states that the input cannot exceed
16the allocated buffer size.
17
18http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2013-4231
19
20Signed-off-by: Yue Tao <Yue.Tao@windriver.com>
21
22Index: tools/gif2tiff.c
23===================================================================
24RCS file: /cvs/maptools/cvsroot/libtiff/tools/gif2tiff.c,v
25retrieving revision 1.12
26retrieving revision 1.13
27diff -u -r1.12 -r1.13
28--- a/tools/gif2tiff.c 15 Dec 2010 00:22:44 -0000 1.12
29+++ b/tools/gif2tiff.c 14 Aug 2013 05:18:53 -0000 1.13
30@@ -1,4 +1,4 @@
31-/* $Id: gif2tiff.c,v 1.12 2010-12-15 00:22:44 faxguy Exp $ */
32+/* $Id: gif2tiff.c,v 1.13 2013-08-14 05:18:53 fwarmerdam Exp $ */
33
34 /*
35 * Copyright (c) 1990-1997 Sam Leffler
36@@ -333,6 +333,8 @@
37 int status = 1;
38
39 datasize = getc(infile);
40+ if (datasize > 12)
41+ return 0;
42 clear = 1 << datasize;
43 eoi = clear + 1;
44 avail = clear + 2;
diff --git a/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4232.patch b/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4232.patch
new file mode 100644
index 0000000000..9ebf8f9a2d
--- /dev/null
+++ b/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4232.patch
@@ -0,0 +1,15 @@
1This patch comes from: http://bugzilla.maptools.org/attachment.cgi?id=513&action=diff
2
3Upstream-Status: Pending
4
5Signed-off-by: Baogen shang <baogen.shang@windriver.com>
6--- a/tools/tiff2pdf.c 2013-10-21 10:36:38.214170346 +0800
7+++ b/tools/tiff2pdf.c 2013-10-21 10:38:58.246170329 +0800
8@@ -2387,6 +2387,7 @@
9 TIFFFileName(input));
10 t2p->t2p_error = T2P_ERR_ERROR;
11 _TIFFfree(buffer);
12+ return(0);
13 } else {
14 buffer=samplebuffer;
15 t2p->tiff_datasize *= t2p->tiff_samplesperpixel;
diff --git a/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4243.patch b/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4243.patch
new file mode 100644
index 0000000000..642a117976
--- /dev/null
+++ b/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4243.patch
@@ -0,0 +1,40 @@
1This patch comes from: http://bugzilla.maptools.org/attachment.cgi?id=518&action=diff#tools/gif2tiff.c_sec2
2
3Upstream-Status: Pending
4
5Signed-off-by: Baogen shang <baogen.shang@windriver.com>
6--- a/tools/gif2tiff.c 2013-10-14 17:08:43.966239709 +0800
7+++ b/tools/gif2tiff.c 2013-10-14 17:18:22.994239638 +0800
8@@ -280,6 +280,10 @@
9 fprintf(stderr, "no colormap present for image\n");
10 return (0);
11 }
12+ if (width == 0 || height == 0) {
13+ fprintf(stderr, "Invalid value of width or height\n");
14+ return(0);
15+ }
16 if ((raster = (unsigned char*) _TIFFmalloc(width*height+EXTRAFUDGE)) == NULL) {
17 fprintf(stderr, "not enough memory for image\n");
18 return (0);
19@@ -397,6 +401,10 @@
20 return 1;
21 }
22
23+ if (*fill >= raster + width*height) {
24+ fprintf(stderr, "raster full before eoi code\n");
25+ return 0;
26+ }
27 if (oldcode == -1) {
28 *(*fill)++ = suffix[code];
29 firstchar = oldcode = code;
30@@ -428,6 +436,10 @@
31 }
32 oldcode = incode;
33 do {
34+ if (*fill >= raster + width*height) {
35+ fprintf(stderr, "raster full before eoi code\n");
36+ return 0;
37+ }
38 *(*fill)++ = *--stackp;
39 } while (stackp > stack);
40 return 1;
diff --git a/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4244.patch b/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4244.patch
new file mode 100644
index 0000000000..1a668307ae
--- /dev/null
+++ b/meta/recipes-multimedia/libtiff/files/libtiff-CVE-2013-4244.patch
@@ -0,0 +1,19 @@
1This patch comes from: https://github.com/vadz/libtiff/commit/ce6841d9e41d621ba23cf18b190ee6a23b2cc833
2
3Upstream-Status: Backport
4
5Signed-off-by: Baogen shang <baogen.shang@windriver.com>
6--- a/tools/gif2tiff.c 2013-12-17 16:46:02.160814995 +0800
7+++ b/tools/gif2tiff.c 2013-12-17 16:52:25.140814949 +0800
8@@ -406,6 +406,11 @@
9 return 0;
10 }
11 if (oldcode == -1) {
12+ if (code >= clear) {
13+ fprintf(stderr, "bad input: code=%d is larger than clear=%d\n",code, clear);
14+ return 0;
15+ }
16+
17 *(*fill)++ = suffix[code];
18 firstchar = oldcode = code;
19 return 1;
diff --git a/meta/recipes-multimedia/libtiff/files/libtool2.patch b/meta/recipes-multimedia/libtiff/files/libtool2.patch
new file mode 100644
index 0000000000..457202eae5
--- /dev/null
+++ b/meta/recipes-multimedia/libtiff/files/libtool2.patch
@@ -0,0 +1,19 @@
1Upstream-Status: Inappropriate [configuration]
2
3---
4 configure.ac | 2 +-
5 1 file changed, 1 insertion(+), 1 deletion(-)
6
7Index: tiff-3.9.5/configure.ac
8===================================================================
9--- tiff-3.9.5.orig/configure.ac
10+++ tiff-3.9.5/configure.ac
11@@ -27,7 +27,7 @@ dnl Process this file with autoconf to p
12 AC_PREREQ(2.64)
13 AC_INIT([LibTIFF Software],[3.9.5],[tiff@lists.maptools.org],[tiff])
14 AC_CONFIG_AUX_DIR(config)
15-AC_CONFIG_MACRO_DIR(m4)
16+dnl AC_CONFIG_MACRO_DIR(m4)
17 AC_LANG(C)
18
19 dnl Compute the canonical host (run-time) system type variable
diff --git a/meta/recipes-multimedia/libtiff/files/tiff-CVE-2012-4564.patch b/meta/recipes-multimedia/libtiff/files/tiff-CVE-2012-4564.patch
new file mode 100644
index 0000000000..23649790c4
--- /dev/null
+++ b/meta/recipes-multimedia/libtiff/files/tiff-CVE-2012-4564.patch
@@ -0,0 +1,99 @@
1Upstream-Status: Backport
2
3Signed-off-by: Yue Tao <Yue.Tao@windriver.com>
4Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
5
6Index: tools/ppm2tiff.c
7===================================================================
8RCS file: /cvs/maptools/cvsroot/libtiff/tools/ppm2tiff.c,v
9retrieving revision 1.16
10retrieving revision 1.18
11diff -u -r1.16 -r1.18
12--- a/tools/ppm2tiff.c 10 Apr 2010 19:22:34 -0000 1.16
13+++ b/tools/ppm2tiff.c 10 Dec 2012 18:19:11 -0000 1.18
14@@ -1,4 +1,4 @@
15-/* $Id: ppm2tiff.c,v 1.16 2010-04-10 19:22:34 bfriesen Exp $ */
16+/* $Id: ppm2tiff.c,v 1.18 2012-12-10 18:19:11 tgl Exp $ */
17
18 /*
19 * Copyright (c) 1991-1997 Sam Leffler
20@@ -72,6 +72,17 @@
21 exit(-2);
22 }
23
24+static tmsize_t
25+multiply_ms(tmsize_t m1, tmsize_t m2)
26+{
27+ tmsize_t bytes = m1 * m2;
28+
29+ if (m1 && bytes / m1 != m2)
30+ bytes = 0;
31+
32+ return bytes;
33+}
34+
35 int
36 main(int argc, char* argv[])
37 {
38@@ -79,7 +90,7 @@
39 uint32 rowsperstrip = (uint32) -1;
40 double resolution = -1;
41 unsigned char *buf = NULL;
42- tsize_t linebytes = 0;
43+ tmsize_t linebytes = 0;
44 uint16 spp = 1;
45 uint16 bpp = 8;
46 TIFF *out;
47@@ -89,6 +100,7 @@
48 int c;
49 extern int optind;
50 extern char* optarg;
51+ tmsize_t scanline_size;
52
53 if (argc < 2) {
54 fprintf(stderr, "%s: Too few arguments\n", argv[0]);
55@@ -221,7 +233,8 @@
56 }
57 switch (bpp) {
58 case 1:
59- linebytes = (spp * w + (8 - 1)) / 8;
60+ /* if round-up overflows, result will be zero, OK */
61+ linebytes = (multiply_ms(spp, w) + (8 - 1)) / 8;
62 if (rowsperstrip == (uint32) -1) {
63 TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, h);
64 } else {
65@@ -230,15 +243,31 @@
66 }
67 break;
68 case 8:
69- linebytes = spp * w;
70+ linebytes = multiply_ms(spp, w);
71 TIFFSetField(out, TIFFTAG_ROWSPERSTRIP,
72 TIFFDefaultStripSize(out, rowsperstrip));
73 break;
74 }
75- if (TIFFScanlineSize(out) > linebytes)
76+ if (linebytes == 0) {
77+ fprintf(stderr, "%s: scanline size overflow\n", infile);
78+ (void) TIFFClose(out);
79+ exit(-2);
80+ }
81+ scanline_size = TIFFScanlineSize(out);
82+ if (scanline_size == 0) {
83+ /* overflow - TIFFScanlineSize already printed a message */
84+ (void) TIFFClose(out);
85+ exit(-2);
86+ }
87+ if (scanline_size < linebytes)
88 buf = (unsigned char *)_TIFFmalloc(linebytes);
89 else
90- buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out));
91+ buf = (unsigned char *)_TIFFmalloc(scanline_size);
92+ if (buf == NULL) {
93+ fprintf(stderr, "%s: Not enough memory\n", infile);
94+ (void) TIFFClose(out);
95+ exit(-2);
96+ }
97 if (resolution > 0) {
98 TIFFSetField(out, TIFFTAG_XRESOLUTION, resolution);
99 TIFFSetField(out, TIFFTAG_YRESOLUTION, resolution);
diff --git a/meta/recipes-multimedia/libtiff/tiff_4.0.3.bb b/meta/recipes-multimedia/libtiff/tiff_4.0.3.bb
new file mode 100644
index 0000000000..b7d1129ad6
--- /dev/null
+++ b/meta/recipes-multimedia/libtiff/tiff_4.0.3.bb
@@ -0,0 +1,54 @@
1SUMMARY = "Provides support for the Tag Image File Format (TIFF)"
2LICENSE = "BSD-2-Clause"
3LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=34da3db46fab7501992f9615d7e158cf"
4HOMEPAGE = "http://www.remotesensing.org/libtiff/"
5
6SRC_URI = "ftp://ftp.remotesensing.org/pub/libtiff/tiff-${PV}.tar.gz \
7 file://libtool2.patch \
8 file://libtiff-CVE-2013-1960.patch \
9 file://libtiff-CVE-2013-1961.patch \
10 file://libtiff-CVE-2013-4232.patch \
11 file://libtiff-CVE-2013-4243.patch \
12 file://libtiff-CVE-2013-4244.patch \
13 file://libtiff-CVE-2013-4231.patch \
14 file://tiff-CVE-2012-4564.patch "
15
16SRC_URI[md5sum] = "051c1068e6a0627f461948c365290410"
17SRC_URI[sha256sum] = "ea1aebe282319537fb2d4d7805f478dd4e0e05c33d0928baba76a7c963684872"
18
19inherit autotools
20
21CACHED_CONFIGUREVARS = "ax_cv_check_gl_libgl=no"
22
23PACKAGECONFIG ?= "cxx jpeg zlib lzma \
24 strip-chopping extrasample-as-alpha check-ycbcr-subsampling"
25
26PACKAGECONFIG[cxx] = "--enable-cxx,--disable-cxx,,"
27PACKAGECONFIG[jpeg] = "--enable-jpeg,--disable-jpeg,jpeg,"
28PACKAGECONFIG[zlib] = "--enable-zlib,--disable-zlib,zlib,"
29PACKAGECONFIG[lzma] = "--enable-lzma,--disable-lzma,xz,"
30
31# Convert single-strip uncompressed images to multiple strips of specified
32# size (default: 8192) to reduce memory usage
33PACKAGECONFIG[strip-chopping] = "--enable-strip-chopping,--disable-strip-chopping,,"
34
35# Treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA
36PACKAGECONFIG[extrasample-as-alpha] = "--enable-extrasample-as-alpha,--disable-extrasample-as-alpha,,"
37
38# Control picking up YCbCr subsample info. Disable to support files lacking
39# the tag
40PACKAGECONFIG[check-ycbcr-subsampling] = "--enable-check-ycbcr-subsampling,--disable-check-ycbcr-subsampling,,"
41
42# Support a mechanism allowing reading large strips (usually one strip files)
43# in chunks when using TIFFReadScanline. Experimental 4.0+ feature
44PACKAGECONFIG[chunky-strip-read] = "--enable-chunky-strip-read,--disable-chunky-strip-read,,"
45
46PACKAGES =+ "tiffxx tiffxx-dbg tiffxx-dev tiffxx-staticdev tiff-utils tiff-utils-dbg"
47FILES_tiffxx = "${libdir}/libtiffxx.so.*"
48FILES_tiffxx-dev = "${libdir}/libtiffxx.so ${libdir}/libtiffxx.la"
49FILES_tiffxx-staticdev = "${libdir}/libtiffxx.a"
50FILES_tiffxx-dbg += "${libdir}/.debug/libtiffxx.so*"
51FILES_tiff-utils = "${bindir}/*"
52FILES_tiff-utils-dbg += "${bindir}/.debug/"
53
54BBCLASSEXTEND = "native"
diff --git a/meta/recipes-multimedia/libvorbis/libvorbis_1.3.4.bb b/meta/recipes-multimedia/libvorbis/libvorbis_1.3.4.bb
new file mode 100644
index 0000000000..0788c94bce
--- /dev/null
+++ b/meta/recipes-multimedia/libvorbis/libvorbis_1.3.4.bb
@@ -0,0 +1,25 @@
1SUMMARY = "Ogg Vorbis Audio Codec"
2DESCRIPTION = "Ogg Vorbis is a high-quality lossy audio codec \
3that is free of intellectual property restrictions. libvorbis \
4is the main vorbis codec library."
5HOMEPAGE = "http://www.vorbis.com/"
6BUGTRACKER = "https://trac.xiph.org"
7SECTION = "libs"
8LICENSE = "BSD"
9LIC_FILES_CHKSUM = "file://COPYING;md5=ca77c6c3ea4d29cb68dce8ef5ab0d897 \
10 file://include/vorbis/vorbisenc.h;beginline=1;endline=11;md5=d1c1d138863d6315131193d4046d81cb"
11DEPENDS = "libogg"
12
13SRC_URI = "http://downloads.xiph.org/releases/vorbis/${BP}.tar.xz"
14
15SRC_URI[md5sum] = "55f2288055e44754275a17c9a2497391"
16SRC_URI[sha256sum] = "2f05497d29195dc23ee952a24ee3973a74e6277569c4c2eca0ec5968e541f372"
17
18inherit autotools pkgconfig
19
20# vorbisfile.c reveals a problem in the gcc register spilling for the
21# thumb instruction set...
22FULL_OPTIMIZATION_thumb = "-O0"
23
24EXTRA_OECONF = "--with-ogg-libraries=${STAGING_LIBDIR} \
25 --with-ogg-includes=${STAGING_INCDIR}"
diff --git a/meta/recipes-multimedia/mpeg2dec/mpeg2dec-0.4.1/altivec_h_needed.patch b/meta/recipes-multimedia/mpeg2dec/mpeg2dec-0.4.1/altivec_h_needed.patch
new file mode 100644
index 0000000000..7dc56436f0
--- /dev/null
+++ b/meta/recipes-multimedia/mpeg2dec/mpeg2dec-0.4.1/altivec_h_needed.patch
@@ -0,0 +1,43 @@
1Add new method to judge whether <altivec.h> is needed
2
3The original logic will use "typedef vector int t;" to judge
4whether <altivec.h> is needed. altivec.h contains the following
5statement:
6
7 #if !defined(__APPLE_ALTIVEC__)
8 #define vector __vector
9 #define pixel __pixel
10 #define bool
11 #endif
12
13In gcc-4.3.3, __APPLE_ALTIVEC__ is not defined by compiler, neither
14as vector, pixel, and bool. In order to make "typedef vector int t;"
15pass the compilation, we need to include altivec.h.
16
17However in gcc-4.5.0, __APPLE_ALTIVEC__ is defined by compiler,
18so as vector, pixel, and bool. We could not judge whether
19altivec.h is needed by "typedef vector int t;".
20Here we include another statement "int tmp = __CR6_EQ;", in
21which __CR6_EQ is defined in altivec.h.
22
23Upstream-Status: Pending
24
25Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
26
27diff -ruN mpeg2dec-0.4.1-orig/configure.in mpeg2dec-0.4.1/configure.in
28--- mpeg2dec-0.4.1-orig/configure.in 2010-09-14 20:55:42.399687663 +0800
29+++ mpeg2dec-0.4.1/configure.in 2010-09-14 20:56:43.403204648 +0800
30@@ -75,11 +75,11 @@
31 CFLAGS="$OPT_CFLAGS $TRY_CFLAGS $CFLAGS"
32 AC_MSG_CHECKING([if <altivec.h> is needed])
33 AC_TRY_COMPILE([],
34- [typedef vector int t;
35+ [typedef vector int t; int tmp = __CR6_EQ;
36 vec_ld(0, (unsigned char *)0);],
37 [have_altivec=yes; AC_MSG_RESULT(no)],
38 [AC_TRY_COMPILE([#include <altivec.h>],
39- [typedef vector int t; vec_ld(0, (unsigned char *)0);],
40+ [typedef vector int t; int tmp = __CR6_EQ; vec_ld(0, (unsigned char *)0);],
41 [AC_DEFINE([HAVE_ALTIVEC_H],,
42 [Define to 1 if you have the <altivec.h> header.])
43 have_altivec=yes; AC_MSG_RESULT(yes)],
diff --git a/meta/recipes-multimedia/mpeg2dec/mpeg2dec_0.4.1.bb b/meta/recipes-multimedia/mpeg2dec/mpeg2dec_0.4.1.bb
new file mode 100644
index 0000000000..cede2bf100
--- /dev/null
+++ b/meta/recipes-multimedia/mpeg2dec/mpeg2dec_0.4.1.bb
@@ -0,0 +1,38 @@
1SUMMARY = "Library and test program for decoding MPEG-2 and MPEG-1 video streams"
2HOMEPAGE = "http://libmpeg2.sourceforge.net/"
3SECTION = "libs"
4LICENSE = "GPLv2+"
5LICENSE_FLAGS = "commercial"
6LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
7 file://include/mpeg2.h;beginline=1;endline=22;md5=ead62602d4638329d3b5b86a55803154"
8
9PR = "r2"
10
11SRC_URI = "http://libmpeg2.sourceforge.net/files/mpeg2dec-${PV}.tar.gz \
12 file://altivec_h_needed.patch"
13
14SRC_URI[md5sum] = "7631b0a4bcfdd0d78c0bb0083080b0dc"
15SRC_URI[sha256sum] = "c74a76068f8ec36d4bb59a03bf1157be44118ca02252180e8b358b0b5e3edeee"
16
17inherit autotools pkgconfig
18
19EXTRA_OECONF = "--enable-shared --disable-sdl"
20
21PACKAGECONFIG ?= "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}"
22PACKAGECONFIG[x11] = "--with-x,--without-x,virtual/libx11 libxext libxv"
23
24PACKAGES = "mpeg2dec-dbg mpeg2dec mpeg2dec-doc libmpeg2 libmpeg2-dev libmpeg2convert libmpeg2convert-dev libmpeg2-staticdev libmpeg2convert-staticdev"
25
26FILES_${PN} = "${bindir}/*"
27FILES_libmpeg2 = "${libdir}/libmpeg2.so.*"
28FILES_libmpeg2convert = "${libdir}/libmpeg2convert.so.*"
29FILES_libmpeg2-dev = "${libdir}/libmpeg2.so \
30 ${libdir}/libmpeg2.la \
31 ${libdir}/pkgconfig/libmpeg2.pc \
32 ${includedir}/mpeg2dec/mpeg2.h"
33FILES_libmpeg2-staticdev = "${libdir}/libmpeg2.a"
34FILES_libmpeg2convert-dev = "${libdir}/libmpeg2convert.so \
35 ${libdir}/libmpeg2convert.la \
36 ${libdir}/pkgconfig/libmpeg2convert.pc \
37 ${includedir}/mpeg2dec/mpeg2convert.h"
38FILES_libmpeg2convert-staticdev = "${libdir}/libmpeg2convert.a"
diff --git a/meta/recipes-multimedia/pulseaudio/libatomics-ops_7.2.bb b/meta/recipes-multimedia/pulseaudio/libatomics-ops_7.2.bb
new file mode 100644
index 0000000000..4632d240d2
--- /dev/null
+++ b/meta/recipes-multimedia/pulseaudio/libatomics-ops_7.2.bb
@@ -0,0 +1,31 @@
1SUMMARY = "A library for atomic integer operations"
2DESCRIPTION = "A library for atomic integer operations"
3HOMEPAGE = "http://www.hpl.hp.com/research/linux/atomic_ops/"
4SECTION = "optional"
5LICENSE = "GPLv2 & MIT"
6LIC_FILES_CHKSUM = "file://doc/COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
7 file://doc/LICENSING.txt;md5=607073e04548eac7d1f763e480477bab \
8 "
9PR = "r1"
10
11SRC_URI = "http://www.hpl.hp.com/research/linux/atomic_ops/download/libatomic_ops-${PV}.tar.gz \
12 "
13
14SRC_URI[md5sum] = "890acdc83a7cd10e2e9536062d3741c8"
15SRC_URI[sha256sum] = "c4ee6e0c304c6f13bcc32968453cdb54b2ec233d8bf4cfcf266ee09dc33b4eb5"
16
17S = "${WORKDIR}/libatomic_ops-${PV}"
18
19ALLOW_EMPTY_${PN} = "1"
20
21ARM_INSTRUCTION_SET = "arm"
22
23inherit autotools pkgconfig
24
25do_install_append() {
26 # those contain only docs, not necessary for now.
27 install -m 0755 -d ${D}${docdir}
28 mv ${D}${datadir}/libatomic_ops ${D}${docdir}/${BPN}
29}
30
31BBCLASSEXTEND = "native nativesdk"
diff --git a/meta/recipes-multimedia/pulseaudio/pulseaudio.inc b/meta/recipes-multimedia/pulseaudio/pulseaudio.inc
new file mode 100644
index 0000000000..99cad76186
--- /dev/null
+++ b/meta/recipes-multimedia/pulseaudio/pulseaudio.inc
@@ -0,0 +1,151 @@
1SUMMARY = "Sound server for Linux and Unix-like operating systems"
2HOMEPAGE = "http://www.pulseaudio.org"
3AUTHOR = "Lennart Poettering"
4SECTION = "libs/multimedia"
5LICENSE = "GPLv2+ & LGPLv2.1"
6LIC_FILES_CHKSUM = "file://GPL;md5=4325afd396febcb659c36b49533135d4 \
7 file://LGPL;md5=2d5025d4aa3495befef8f17206a5b0a1 \
8 file://src/pulsecore/resampler.h;beginline=4;endline=23;md5=c3d539b93f8c82a1780bfa3cfa544a95"
9
10DEPENDS = "libatomics-ops liboil libsamplerate0 libsndfile1 libtool"
11# optional
12DEPENDS += "udev alsa-lib glib-2.0 dbus gconf"
13DEPENDS += "json-c gdbm speex libxml-parser-perl-native libcap"
14
15inherit autotools pkgconfig useradd gettext perlnative
16
17# *.desktop rules wont be generated during configure and build will fail
18# if using --disable-nls
19USE_NLS = "yes"
20
21EXTRA_OECONF = "\
22 --disable-hal-compat \
23 --disable-orc \
24 --enable-tcpwrap=no \
25 --with-access-group=audio \
26 --disable-openssl \
27 --disable-xen \
28 --with-database=simple \
29 --without-fftw \
30 --with-udev-rules-dir=`pkg-config --variable=udevdir udev`/rules.d \
31 ac_cv_header_valgrind_memcheck_h=no \
32"
33
34PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'bluetooth', 'bluez4', '', d)} \
35 ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
36 ${@bb.utils.contains('DISTRO_FEATURES', 'zeroconf', 'avahi', '', d)} \
37 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}"
38PACKAGECONFIG[bluez4] = "--enable-bluez4,--disable-bluez4,bluez4 sbc"
39PACKAGECONFIG[bluez5] = "--enable-bluez5,--disable-bluez5,bluez5 sbc"
40PACKAGECONFIG[gtk] = "--enable-gtk3,--disable-gtk3,gtk+3"
41PACKAGECONFIG[systemd] = "--enable-systemd,--disable-systemd,systemd"
42PACKAGECONFIG[x11] = "--enable-x11,--disable-x11,virtual/libx11 libxtst libice libsm libxcb"
43PACKAGECONFIG[avahi] = "--enable-avahi,--disable-avahi,avahi"
44PACKAGECONFIG[jack] = "--enable-jack,--disable-jack,jack"
45
46EXTRA_OECONF_append_arm = "${@bb.utils.contains("TUNE_FEATURES", "neon", "", " --enable-neon-opt=no", d)}"
47EXTRA_OECONF_append_armeb = "${@bb.utils.contains("TUNE_FEATURES", "neon", "", " --enable-neon-opt=no", d)}"
48
49
50export TARGET_PFPU = "${TARGET_FPU}"
51
52# TODO: Use more fine granular version
53#OE_LT_RPATH_ALLOW=":${libdir}/pulse-0.9:"
54OE_LT_RPATH_ALLOW = "any"
55OE_LT_RPATH_ALLOW[export]="1"
56
57do_install_append() {
58 install -d ${D}${sysconfdir}/default/volatiles
59 install -m 0644 ${WORKDIR}/volatiles.04_pulse ${D}${sysconfdir}/default/volatiles/volatiles.04_pulse
60
61 if [ "x${TARGET_PFPU}" = "xsoft" ] ; then
62 sed -i -e s:\;\ resample-method\ =\ sinc-fastest:resample-method\ =\ trivial: ${D}${sysconfdir}/pulse/daemon.conf
63 fi
64}
65
66USERADD_PACKAGES = "pulseaudio-server"
67GROUPADD_PARAM_pulseaudio-server = "pulse"
68USERADD_PARAM_pulseaudio-server = "--system --home /var/run/pulse \
69 --no-create-home --shell /bin/false \
70 --groups audio,pulse --gid pulse pulse"
71
72# The console-kit module is included here explicitly so bitbake can map to the
73# RDEPENDS we define for it in this recipe, and thereby ensure that when
74# adding the console-kit module to an image, we also get the necessary
75# consolekit package produced.
76PACKAGES =+ "libpulsecore libpulsecommon libpulse libpulse-simple libpulse-mainloop-glib \
77 pulseaudio-server pulseaudio-misc ${@bb.utils.contains('PACKAGECONFIG', 'x11', 'pulseaudio-module-console-kit', '', d)}"
78
79#upgrade path:
80RREPLACES_pulseaudio-server = "libpulse-bin libpulse-conf"
81
82PACKAGES_DYNAMIC += "^pulseaudio-lib-.* ^pulseaudio-module-.*"
83
84FILES_libpulsecore = "${libdir}/libpulsecore*.so"
85FILES_libpulsecommon = "${libdir}/pulseaudio/libpulsecommon*.so"
86FILES_libpulse = "${libdir}/libpulse.so.*"
87FILES_libpulse-simple = "${libdir}/libpulse-simple.so.*"
88FILES_libpulse-mainloop-glib = "${libdir}/libpulse-mainloop-glib.so.*"
89
90FILES_${PN}-dbg += "${libexecdir}/pulse/.debug \
91 ${libdir}/pulse-${PV}/modules/.debug"
92FILES_${PN}-dev += "${libdir}/pulse-${PV}/modules/*.la ${datadir}/vala ${libdir}/cmake"
93FILES_${PN}-conf = "${sysconfdir}"
94FILES_${PN}-bin += "${sysconfdir}/default/volatiles/volatiles.04_pulse"
95FILES_${PN}-server = "${bindir}/pulseaudio ${bindir}/start-* ${sysconfdir} ${bindir}/pactl */udev/rules.d/*.rules"
96FILES_${PN}-misc = "${bindir}/* ${libdir}/pulseaudio/libpulsedsp.so"
97
98# Allow the pulseaudio package to be created empty as a placeholder (-dbg and -dev depend on it)
99ALLOW_EMPTY_${PN} = "1"
100
101CONFFILES_pulseaudio-server = "\
102 ${sysconfdir}/pulse/default.pa \
103 ${sysconfdir}/pulse/daemon.conf \
104 ${sysconfdir}/pulse/client.conf \
105 "
106
107pkg_postinst_${PN}-server() {
108 if [ -z "$D" ] && [ -e ${sysconfdir}/init.d/populate-volatile.sh ] ; then
109 ${sysconfdir}/init.d/populate-volatile.sh update
110 fi
111}
112
113python populate_packages_prepend() {
114 #d.setVar('PKG_pulseaudio', 'pulseaudio')
115
116 plugindir = d.expand('${libdir}/pulse-${PV}/modules/')
117 do_split_packages(d, plugindir, '^module-(.*)\.so$', 'pulseaudio-module-%s', 'PulseAudio module for %s', extra_depends='', prepend=True)
118 do_split_packages(d, plugindir, '^lib(.*)\.so$', 'pulseaudio-lib-%s', 'PulseAudio library for %s', extra_depends='', prepend=True)
119}
120
121RDEPENDS_pulseaudio-server = " \
122 pulseaudio-module-filter-apply \
123 pulseaudio-module-filter-heuristics \
124 pulseaudio-module-udev-detect \
125 pulseaudio-module-null-sink \
126 pulseaudio-module-device-restore \
127 pulseaudio-module-stream-restore \
128 pulseaudio-module-card-restore \
129 pulseaudio-module-augment-properties \
130 pulseaudio-module-detect \
131 pulseaudio-module-alsa-sink \
132 pulseaudio-module-alsa-source \
133 pulseaudio-module-alsa-card \
134 pulseaudio-module-native-protocol-unix \
135 pulseaudio-module-default-device-restore \
136 pulseaudio-module-intended-roles \
137 pulseaudio-module-rescue-streams \
138 pulseaudio-module-always-sink \
139 pulseaudio-module-suspend-on-idle \
140 pulseaudio-module-position-event-sounds \
141 pulseaudio-module-role-cork \
142 pulseaudio-module-switch-on-port-available"
143
144RDEPENDS_pulseaudio-module-console-kit =+ "consolekit"
145RDEPENDS_pulseaudio-misc += "pulseaudio-module-cli-protocol-unix"
146
147FILES_pulseaudio-module-gconf += "${libexecdir}/pulse/gconf-helper"
148FILES_pulseaudio-module-alsa-card += "${datadir}/pulseaudio/alsa-mixer"
149
150RDEPENDS_pulseaudio-server += "\
151 ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'pulseaudio-module-console-kit', '', d)}"
diff --git a/meta/recipes-multimedia/pulseaudio/pulseaudio/0001-configure.ac-Check-only-for-libsystemd-not-libsystem.patch b/meta/recipes-multimedia/pulseaudio/pulseaudio/0001-configure.ac-Check-only-for-libsystemd-not-libsystem.patch
new file mode 100644
index 0000000000..467cd2cbd0
--- /dev/null
+++ b/meta/recipes-multimedia/pulseaudio/pulseaudio/0001-configure.ac-Check-only-for-libsystemd-not-libsystem.patch
@@ -0,0 +1,30 @@
1From 002b16f0f2176b4c685e210e335bf69c02563ede Mon Sep 17 00:00:00 2001
2From: Martin Jansa <Martin.Jansa@gmail.com>
3Date: Sat, 22 Feb 2014 18:03:10 +0100
4Subject: [PATCH] configure.ac: Check only for libsystemd not libsystemd-login
5
6* they were merged into libsystemd in systemd-209
7
8Upstream-Status: Pending (it would need to be conditional on systemd version for upstream to accept this)
9
10Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
11---
12 configure.ac | 2 +-
13 1 file changed, 1 insertion(+), 1 deletion(-)
14
15diff --git a/configure.ac b/configure.ac
16index 388fae2..fff7a83 100644
17--- a/configure.ac
18+++ b/configure.ac
19@@ -1160,7 +1160,7 @@ AC_ARG_ENABLE([systemd],
20 AS_HELP_STRING([--disable-systemd],[Disable optional systemd support]))
21
22 AS_IF([test "x$enable_systemd" != "xno"],
23- [PKG_CHECK_MODULES(SYSTEMD, [ libsystemd-login ], HAVE_SYSTEMD=1, HAVE_SYSTEMD=0)],
24+ [PKG_CHECK_MODULES(SYSTEMD, [ libsystemd ], HAVE_SYSTEMD=1, HAVE_SYSTEMD=0)],
25 HAVE_SYSTEMD=0)
26
27 AS_IF([test "x$enable_systemd" = "xyes" && test "x$HAVE_SYSTEMD" = "x0"],
28--
291.8.5.3
30
diff --git a/meta/recipes-multimedia/pulseaudio/pulseaudio/CVE-2014-3970.patch b/meta/recipes-multimedia/pulseaudio/pulseaudio/CVE-2014-3970.patch
new file mode 100644
index 0000000000..d5f33dc42e
--- /dev/null
+++ b/meta/recipes-multimedia/pulseaudio/pulseaudio/CVE-2014-3970.patch
@@ -0,0 +1,52 @@
1Upstream-Status: Backport
2
3commit 26b9d22dd24c17eb118d0205bf7b02b75d435e3c upstream
4
5rtp-recv: fix crash on empty UDP packets (CVE-2014-3970)
6
7On FIONREAD returning 0 bytes, we cannot return success, as the caller
8(rtpoll_work_cb in module-rtp-recv.c) would then try to
9pa_memblock_unref(chunk.memblock) and, because memblock is NULL, trigger
10an assertion.
11
12Also we have to read out the possible empty packet from the socket, so
13that the kernel doesn't tell us again and again about it.
14
15Signed-off-by: Alexander E. Patrakov <patrakov@gmail.com>
16
17diff --git a/src/modules/rtp/rtp.c b/src/modules/rtp/rtp.c
18index 9195493..c45981e 100644
19--- a/src/modules/rtp/rtp.c
20+++ b/src/modules/rtp/rtp.c
21@@ -182,8 +182,29 @@ int pa_rtp_recv(pa_rtp_context *c, pa_memchunk *chunk, pa_mempool *pool, struct
22 goto fail;
23 }
24
25- if (size <= 0)
26- return 0;
27+ if (size <= 0) {
28+ /* size can be 0 due to any of the following reasons:
29+ *
30+ * 1. Somebody sent us a perfectly valid zero-length UDP packet.
31+ * 2. Somebody sent us a UDP packet with a bad CRC.
32+ *
33+ * It is unknown whether size can actually be less than zero.
34+ *
35+ * In the first case, the packet has to be read out, otherwise the
36+ * kernel will tell us again and again about it, thus preventing
37+ * reception of any further packets. So let's just read it out
38+ * now and discard it later, when comparing the number of bytes
39+ * received (0) with the number of bytes wanted (1, see below).
40+ *
41+ * In the second case, recvmsg() will fail, thus allowing us to
42+ * return the error.
43+ *
44+ * Just to avoid passing zero-sized memchunks and NULL pointers to
45+ * recvmsg(), let's force allocation of at least one byte by setting
46+ * size to 1.
47+ */
48+ size = 1;
49+ }
50
51 if (c->memchunk.length < (unsigned) size) {
52 size_t l;
diff --git a/meta/recipes-multimedia/pulseaudio/pulseaudio/volatiles.04_pulse b/meta/recipes-multimedia/pulseaudio/pulseaudio/volatiles.04_pulse
new file mode 100644
index 0000000000..5b1998032b
--- /dev/null
+++ b/meta/recipes-multimedia/pulseaudio/pulseaudio/volatiles.04_pulse
@@ -0,0 +1,2 @@
1# <type> <owner> <group> <mode> <path> <linksource>
2d pulse pulse 0755 /var/run/pulse none
diff --git a/meta/recipes-multimedia/pulseaudio/pulseaudio_5.0.bb b/meta/recipes-multimedia/pulseaudio/pulseaudio_5.0.bb
new file mode 100644
index 0000000000..99f0ef3a46
--- /dev/null
+++ b/meta/recipes-multimedia/pulseaudio/pulseaudio_5.0.bb
@@ -0,0 +1,14 @@
1require pulseaudio.inc
2
3SRC_URI = "http://freedesktop.org/software/pulseaudio/releases/pulseaudio-${PV}.tar.xz \
4 file://0001-configure.ac-Check-only-for-libsystemd-not-libsystem.patch \
5 file://volatiles.04_pulse \
6 file://CVE-2014-3970.patch \
7"
8SRC_URI[md5sum] = "c43749838612f4860465e83ed62ca38e"
9SRC_URI[sha256sum] = "99c13a8b1249ddbd724f195579df79484e9af6418cecf6a15f003a7f36caf939"
10
11do_compile_prepend() {
12 mkdir -p ${S}/libltdl
13 cp ${STAGING_LIBDIR}/libltdl* ${S}/libltdl
14}
diff --git a/meta/recipes-multimedia/sbc/sbc_1.2.bb b/meta/recipes-multimedia/sbc/sbc_1.2.bb
new file mode 100644
index 0000000000..9cdf01bb74
--- /dev/null
+++ b/meta/recipes-multimedia/sbc/sbc_1.2.bb
@@ -0,0 +1,16 @@
1SUMMARY = "SBC Audio Codec"
2DESCRIPTION = "Bluetooth low-complexity, subband codec (SBC) library."
3HOMEPAGE = "https://www.bluez.org"
4SECTION = "libs"
5LICENSE = "GPLv2"
6LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e \
7 file://sbc/sbc.h;beginline=1;endline=26;md5=0f57d0df22b0d40746bdd29805a4361b"
8
9DEPENDS = "libsndfile1"
10
11SRC_URI = "${KERNELORG_MIRROR}/linux/bluetooth/${BP}.tar.xz"
12
13SRC_URI[md5sum] = "ec65c444ad4c32aa85702641045b19e9"
14SRC_URI[sha256sum] = "c2f01ea54f7473704825113a9cdd46a23e67c650eff575f0670c3d9d66c4a5dc"
15
16inherit autotools pkgconfig
diff --git a/meta/recipes-multimedia/speex/speex-fpu.inc b/meta/recipes-multimedia/speex/speex-fpu.inc
new file mode 100644
index 0000000000..2571d32484
--- /dev/null
+++ b/meta/recipes-multimedia/speex/speex-fpu.inc
@@ -0,0 +1,4 @@
1def get_speex_fpu_setting(bb, d):
2 if bb.data.getVar('TARGET_FPU', d, 1) in [ 'soft' ]:
3 return "--enable-fixed-point --disable-float-api --disable-vbr"
4 return ""
diff --git a/meta/recipes-multimedia/speex/speex_1.2rc1.bb b/meta/recipes-multimedia/speex/speex_1.2rc1.bb
new file mode 100644
index 0000000000..9fd88a39f3
--- /dev/null
+++ b/meta/recipes-multimedia/speex/speex_1.2rc1.bb
@@ -0,0 +1,25 @@
1SUMMARY = "Speech Audio Codec"
2DESCRIPTION = "Speex is an Open Source/Free Software patent-free audio compression format designed for speech."
3HOMEPAGE = "http://www.speex.org"
4SECTION = "libs"
5LICENSE = "BSD"
6LIC_FILES_CHKSUM = "file://COPYING;md5=314649d8ba9dd7045dfb6683f298d0a8 \
7 file://include/speex/speex.h;beginline=1;endline=34;md5=a68129f78d7fe66e07163f73aba143b3"
8DEPENDS = "libogg"
9
10PR = "r2"
11
12SRC_URI = "http://downloads.us.xiph.org/releases/speex/speex-${PV}.tar.gz"
13
14SRC_URI[md5sum] = "c4438b22c08e5811ff10e2b06ee9b9ae"
15SRC_URI[sha256sum] = "342f30dc57bd4a6dad41398365baaa690429660b10d866b7d508e8f1179cb7a6"
16
17PARALLEL_MAKE = ""
18
19inherit autotools pkgconfig lib_package
20
21EXTRA_OECONF = " --enable-fixed-point --with-ogg-libraries=${STAGING_LIBDIR} \
22 --with-ogg-includes=${STAGING_INCDIR} --disable-oggtest"
23
24require speex-fpu.inc
25EXTRA_OECONF += "${@get_speex_fpu_setting(bb, d)}"
diff --git a/meta/recipes-multimedia/tremor/tremor-20120314/obsolete_automake_macros.patch b/meta/recipes-multimedia/tremor/tremor-20120314/obsolete_automake_macros.patch
new file mode 100644
index 0000000000..7e5102903b
--- /dev/null
+++ b/meta/recipes-multimedia/tremor/tremor-20120314/obsolete_automake_macros.patch
@@ -0,0 +1,15 @@
1Upstream-Status: Submitted [https://trac.xiph.org/ticket/1922]
2
3Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
4Index: configure.in
5===================================================================
6--- configure.in (revision 18764)
7+++ configure.in (working copy)
8@@ -9,7 +9,7 @@
9 AC_CANONICAL_HOST
10 AC_CANONICAL_TARGET
11
12-AM_CONFIG_HEADER([config.h])
13+AC_CONFIG_HEADERS([config.h])
14
15 AM_INIT_AUTOMAKE(libvorbisidec,1.2.1)
diff --git a/meta/recipes-multimedia/tremor/tremor-20120314/tremor-arm-thumb2.patch b/meta/recipes-multimedia/tremor/tremor-20120314/tremor-arm-thumb2.patch
new file mode 100644
index 0000000000..2049542227
--- /dev/null
+++ b/meta/recipes-multimedia/tremor/tremor-20120314/tremor-arm-thumb2.patch
@@ -0,0 +1,104 @@
1From: Xin Ouyang <Xin.Ouyang@windriver.com>
2Date: Mon, 16 Jul 2012 13:29:34 +0800
3Subject: [PATCH] tremor: add IT instructions for arm thumb2 tune flags.
4
5Upstream-Status: Pending
6
7In Thumb-2, most instructions do not have a built in condition code (except for
8conditional branches). Instead, short sequences of instructions which are to be
9executed conditionally can be preceded by a special "IT instruction" which
10describes the condition and which of the following instructions should be
11executed if the condition is false respectively.
12
13For the ARM/Thumb IT(If-Then) instruction:
14http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489c/Cjabicci.html
15
16Signed-off-by: Xin Ouyang <Xin.Ouyang@windriver.com>
17---
18 asm_arm.h | 14 ++++++++++++++
19 1 file changed, 14 insertions(+)
20
21diff --git a/asm_arm.h b/asm_arm.h
22index c3bda00..823c54f 100755
23--- a/asm_arm.h
24+++ b/asm_arm.h
25@@ -108,9 +108,11 @@ static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
26 static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
27 int tmp;
28 asm volatile("subs %1, %0, #32768\n\t"
29+ "itt pl\n\t"
30 "movpl %0, #0x7f00\n\t"
31 "orrpl %0, %0, #0xff\n"
32 "adds %1, %0, #32768\n\t"
33+ "it mi\n\t"
34 "movmi %0, #0x8000"
35 : "+r"(x),"=r"(tmp)
36 :
37@@ -139,10 +141,12 @@ static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
38
39 "ldmdb r0!,{r1,r3};"
40 "subs r1,r1,%4;" //ilsp[j]-wi
41+ "it mi;"
42 "rsbmi r1,r1,#0;" //labs(ilsp[j]-wi)
43 "umull %0,r2,r1,%0;" //qi*=labs(ilsp[j]-wi)
44
45 "subs r1,r3,%4;" //ilsp[j+1]-wi
46+ "it mi;"
47 "rsbmi r1,r1,#0;" //labs(ilsp[j+1]-wi)
48 "umull %1,r3,r1,%1;" //pi*=labs(ilsp[j+1]-wi)
49
50@@ -167,6 +171,7 @@ static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
51 "mov r0,#0x4000;\n"
52
53 "subs r1,r1,%4;\n" //ilsp[j]-wi
54+ "it mi;\n"
55 "rsbmi r1,r1,#0;\n" //labs(ilsp[j]-wi)
56 "umull %0,r2,r1,%0;\n" //qi*=labs(ilsp[j]-wi)
57 "umull %1,r3,r0,%1;\n" //pi*=labs(ilsp[j+1]-wi)
58@@ -190,18 +195,23 @@ static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
59 "mov r2,#0;"
60 "orr r1,%0,%1;"
61 "tst r1,#0xff000000;"
62+ "itt ne;"
63 "addne r2,r2,#8;"
64 "movne r1,r1,lsr #8;"
65 "tst r1,#0x00f00000;"
66+ "itt ne;"
67 "addne r2,r2,#4;"
68 "movne r1,r1,lsr #4;"
69 "tst r1,#0x000c0000;"
70+ "itt ne;"
71 "addne r2,r2,#2;"
72 "movne r1,r1,lsr #2;"
73 "tst r1,#0x00020000;"
74+ "itt ne;"
75 "addne r2,r2,#1;"
76 "movne r1,r1,lsr #1;"
77 "tst r1,#0x00010000;"
78+ "it ne;"
79 "addne r2,r2,#1;"
80 "mov %0,%0,lsr r2;"
81 "mov %1,%1,lsr r2;"
82@@ -222,15 +232,19 @@ static inline void lsp_norm_asm(ogg_uint32_t *qip,ogg_int32_t *qexpp){
83 ogg_int32_t qexp=*qexpp;
84
85 asm("tst %0,#0x0000ff00;"
86+ "itt eq;"
87 "moveq %0,%0,lsl #8;"
88 "subeq %1,%1,#8;"
89 "tst %0,#0x0000f000;"
90+ "itt eq;"
91 "moveq %0,%0,lsl #4;"
92 "subeq %1,%1,#4;"
93 "tst %0,#0x0000c000;"
94+ "itt eq;"
95 "moveq %0,%0,lsl #2;"
96 "subeq %1,%1,#2;"
97 "tst %0,#0x00008000;"
98+ "itt eq;"
99 "moveq %0,%0,lsl #1;"
100 "subeq %1,%1,#1;"
101 : "+r"(qi),"+r"(qexp)
102--
1031.7.9.5
104
diff --git a/meta/recipes-multimedia/tremor/tremor_20120314.bb b/meta/recipes-multimedia/tremor/tremor_20120314.bb
new file mode 100644
index 0000000000..afc78ac424
--- /dev/null
+++ b/meta/recipes-multimedia/tremor/tremor_20120314.bb
@@ -0,0 +1,22 @@
1SUMMARY = "Fixed-point decoder"
2DESCRIPTION = "tremor is a fixed point implementation of the vorbis codec."
3SECTION = "libs"
4LICENSE = "BSD"
5LIC_FILES_CHKSUM = "file://COPYING;md5=db1b7a668b2a6f47b2af88fb008ad555 \
6 file://os.h;beginline=3;endline=14;md5=5c0af5e1bedef3ce8178c89f48cd6f1f"
7DEPENDS = "libogg"
8SRCDATE = "${PV}"
9PR = "r1"
10
11SRC_URI = "svn://svn.xiph.org/trunk;module=Tremor;rev=18221;protocol=http \
12 file://obsolete_automake_macros.patch;striplevel=0 \
13 file://tremor-arm-thumb2.patch \
14"
15
16S = "${WORKDIR}/Tremor"
17
18inherit autotools pkgconfig
19
20EXTRA_OECONF = "--enable-shared"
21
22ARM_INSTRUCTION_SET = "arm"
diff --git a/meta/recipes-multimedia/x264/x264/don-t-default-to-cortex-a9-with-neon.patch b/meta/recipes-multimedia/x264/x264/don-t-default-to-cortex-a9-with-neon.patch
new file mode 100644
index 0000000000..b844d88fe8
--- /dev/null
+++ b/meta/recipes-multimedia/x264/x264/don-t-default-to-cortex-a9-with-neon.patch
@@ -0,0 +1,20 @@
1-march flag is not in CFLAGS so this will always default to -mcpu=cortex-a8
2-mfpu=neon.
3
4Upstream-Status: Pending
5Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
6
7Index: git/configure
8===================================================================
9--- git.orig/configure 2013-02-10 16:26:40.666343682 +0200
10+++ git/configure 2013-02-10 16:27:49.198341677 +0200
11@@ -703,9 +703,6 @@
12 fi
13
14 if [ $asm = auto -a $ARCH = ARM ] ; then
15- # set flags so neon is built by default
16- echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon"
17-
18 if cc_check '' '' '__asm__("rev ip, ip");' ; then define HAVE_ARMV6
19 cc_check '' '' '__asm__("movt r0, #0");' && define HAVE_ARMV6T2
20 cc_check '' '' '__asm__("vadd.i16 q0, q0, q0");' && define HAVE_NEON
diff --git a/meta/recipes-multimedia/x264/x264_git.bb b/meta/recipes-multimedia/x264/x264_git.bb
new file mode 100644
index 0000000000..0e856b3ba1
--- /dev/null
+++ b/meta/recipes-multimedia/x264/x264_git.bb
@@ -0,0 +1,55 @@
1SUMMARY = "H.264/MPEG-4 AVC video encoder"
2DESCRIPTION = "A free software library and application for encoding video streams into the H.264/MPEG-4 AVC format."
3HOMEPAGE = "http://www.videolan.org/developers/x264.html"
4
5LICENSE = "GPLv2"
6LICENSE_FLAGS = "commercial"
7LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f"
8
9DEPENDS = "yasm-native"
10
11SRC_URI = "git://git.videolan.org/x264.git \
12 file://don-t-default-to-cortex-a9-with-neon.patch \
13 "
14
15SRCREV = "ffc3ad4945da69f3caa2b40e4eed715a9a8d9526"
16
17PV = "r2265+git${SRCPV}"
18
19S = "${WORKDIR}/git"
20
21inherit lib_package pkgconfig perlnative
22
23X264_DISABLE_ASM = ""
24X264_DISABLE_ASM_armv4 = "--disable-asm"
25X264_DISABLE_ASM_armv5 = "--disable-asm"
26X264_DISABLE_ASM_powerpc = "${@bb.utils.contains("TUNE_FEATURES", "spe", "--disable-asm", "", d)}"
27
28EXTRA_OECONF = '--prefix=${prefix} \
29 --host=${HOST_SYS} \
30 --libdir=${libdir} \
31 --cross-prefix=${TARGET_PREFIX} \
32 --sysroot=${STAGING_DIR_TARGET} \
33 --enable-shared \
34 --enable-static \
35 --disable-lavf \
36 --disable-swscale \
37 --enable-pic \
38 ${X264_DISABLE_ASM} \
39 '
40
41do_configure() {
42 ./configure ${EXTRA_OECONF}
43}
44
45# Get rid of -e
46EXTRA_OEMAKE = ""
47AS = "${TARGET_PREFIX}gcc"
48
49do_install() {
50 oe_runmake install DESTDIR=${D}
51}
52
53# PIC can't be enabled for 32-bit x86
54INSANE_SKIP_${PN}_append_i586 = " textrel"
55