summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0001-build-Protect-against-unsupported-CPU-types.patch29
-rw-r--r--meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0002-build-Add-ARM-64bit-support.patch30
-rw-r--r--meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0003-build-fix-architecture-detection.patch96
-rw-r--r--meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0004-typedefs.h-add-support-for-64-bit-and-big-endian-MIP.patch41
-rw-r--r--meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0005-typedefs.h-add-support-for-PowerPC.patch28
-rw-r--r--meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0006-common_audio-implement-endianness-conversion-in-wav-.patch116
-rw-r--r--meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing_0.3.bb25
7 files changed, 365 insertions, 0 deletions
diff --git a/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0001-build-Protect-against-unsupported-CPU-types.patch b/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0001-build-Protect-against-unsupported-CPU-types.patch
new file mode 100644
index 000000000..7668df35d
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0001-build-Protect-against-unsupported-CPU-types.patch
@@ -0,0 +1,29 @@
1From 4945dca11bc4ddec60bd858f45212dc8f39638e0 Mon Sep 17 00:00:00 2001
2From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
3Date: Tue, 5 Jul 2016 18:07:45 -0400
4Subject: [PATCH 1/6] build: Protect against unsupported CPU types
5
6Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
7Upstream-Status: Accepted [expected in 0.4]
8---
9 configure.ac | 3 ++-
10 1 file changed, 2 insertions(+), 1 deletion(-)
11
12diff --git a/configure.ac b/configure.ac
13index 6f9553b..f5304b8 100644
14--- a/configure.ac
15+++ b/configure.ac
16@@ -70,8 +70,9 @@ AS_CASE(["${host_cpu}"],
17 [
18 HAVE_ARM=1
19 ARCH_CFLAGS="-DWEBRTC_ARCH_ARM"
20- ]
21+ ],
22 # FIXME: Add MIPS support, see webrtc/BUILD.gn for defines
23+ [AC_MSG_ERROR([Unsupported CPU type $host_cpu])]
24 )
25 AM_CONDITIONAL(HAVE_X86, [test "x${HAVE_X86}" = "x1"])
26 AM_CONDITIONAL(HAVE_ARM, [test "x${HAVE_ARM}" = "x1"])
27--
282.11.0
29
diff --git a/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0002-build-Add-ARM-64bit-support.patch b/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0002-build-Add-ARM-64bit-support.patch
new file mode 100644
index 000000000..2e202b03c
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0002-build-Add-ARM-64bit-support.patch
@@ -0,0 +1,30 @@
1From b5bda3431159b6505dcd069641c863018c4d4309 Mon Sep 17 00:00:00 2001
2From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
3Date: Wed, 6 Jul 2016 15:18:15 -0400
4Subject: [PATCH 2/6] build: Add ARM 64bit support
5
6Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
7Upstream-Status: Accepted [expected in 0.4]
8---
9 configure.ac | 5 +++++
10 1 file changed, 5 insertions(+)
11
12diff --git a/configure.ac b/configure.ac
13index f5304b8..be20514 100644
14--- a/configure.ac
15+++ b/configure.ac
16@@ -71,6 +71,11 @@ AS_CASE(["${host_cpu}"],
17 HAVE_ARM=1
18 ARCH_CFLAGS="-DWEBRTC_ARCH_ARM"
19 ],
20+ [aarch64*],
21+ [
22+ HAVE_NEON=1
23+ ARCH_CFLAGS="-DWEBRTC_HAS_NEON -DWEBRTC_ARCH_ARM64"
24+ ],
25 # FIXME: Add MIPS support, see webrtc/BUILD.gn for defines
26 [AC_MSG_ERROR([Unsupported CPU type $host_cpu])]
27 )
28--
292.11.0
30
diff --git a/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0003-build-fix-architecture-detection.patch b/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0003-build-fix-architecture-detection.patch
new file mode 100644
index 000000000..82e270fac
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0003-build-fix-architecture-detection.patch
@@ -0,0 +1,96 @@
1From 7722fb8a3189fea0f6381f02a0e4f63c847f0393 Mon Sep 17 00:00:00 2001
2From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3Date: Sat, 6 Aug 2016 11:02:43 +0200
4Subject: [PATCH 3/6] build: fix architecture detection
5
6The current architecture detection, based on the "host_cpu" part of the
7tuple does not work properly for a number of reason:
8
9 - The code assumes that if host_cpu starts with "arm" then ARM
10 instructions are available, which is incorrect. Indeed, Cortex-M
11 platforms can run Linux, they are ARM platforms (so host_cpu = arm),
12 but they don't support ARM instructions: they support only the
13 Thumb-2 instruction set.
14
15 - The armv7 case is also not very useful, as it is not standard at all
16 to pass armv7 as host_cpu even if the host system is actually ARMv7
17 based.
18
19 - For the same reason, the armv8 case is not very useful: ARMv8 is
20 AArch64, and there is already a separate case to handle this
21 architecture.
22
23So, this commit moves away from a host_cpu based logic, and instead
24tests using AC_CHECK_DECLS() the built-in definitions of the compiler:
25
26 - If we have __ARM_ARCH_ISA_ARM defined, then it's an ARM processor
27 that supports the ARM instruction set (this allows to exclude Thumb-2
28 only processors).
29
30 - If we have __ARM_ARCH_7A__, then we have an ARMv7-A processor, and
31 we can enable the corresponding optimizations
32
33 - Same for __aarch64__, __i386__ and __x86_64__.
34
35In addition, we remove the AC_MSG_ERROR() that makes the build fail for
36all architectures but the ones that are explicitly supported. Indeed,
37webrtc-audio-processing builds just fine for other architectures (tested
38on MIPS), it's just that none of the architecture-specific optimizations
39will be used.
40
41Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
42Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
43Upstream-Status: Accepted [expected in 0.4]
44---
45 configure.ac | 35 +++++++++++------------------------
46 1 file changed, 11 insertions(+), 24 deletions(-)
47
48diff --git a/configure.ac b/configure.ac
49index be20514..e898014 100644
50--- a/configure.ac
51+++ b/configure.ac
52@@ -55,30 +55,17 @@ AS_CASE(["${host}"],
53 )
54 AC_SUBST(PLATFORM_CFLAGS)
55
56-AS_CASE(["${host_cpu}"],
57- [i?86|x86_64],
58- [
59- HAVE_X86=1
60- ],
61- [armv7*|armv8*],
62- [
63- HAVE_ARM=1
64- HAVE_ARMV7=1
65- ARCH_CFLAGS="-DWEBRTC_ARCH_ARM -DWEBRTC_ARCH_ARM_V7"
66- ],
67- [arm*],
68- [
69- HAVE_ARM=1
70- ARCH_CFLAGS="-DWEBRTC_ARCH_ARM"
71- ],
72- [aarch64*],
73- [
74- HAVE_NEON=1
75- ARCH_CFLAGS="-DWEBRTC_HAS_NEON -DWEBRTC_ARCH_ARM64"
76- ],
77- # FIXME: Add MIPS support, see webrtc/BUILD.gn for defines
78- [AC_MSG_ERROR([Unsupported CPU type $host_cpu])]
79-)
80+# Testing __ARM_ARCH_ISA_ARM since the code contains ARM instructions,
81+# which don't work on Thumb-2 only platforms (ARMv7-M).
82+AC_CHECK_DECLS([__ARM_ARCH_ISA_ARM],
83+ [HAVE_ARM=1; ARCH_CFLAGS="${ARCH_CFLAGS} -DWEBRTC_ARCH_ARM"])
84+AC_CHECK_DECLS([__ARM_ARCH_7A__],
85+ [HAVE_ARMV7=1; ARCH_CFLAGS="${ARCH_CFLAGS} -DWEBRTC_ARCH_ARM_V7"])
86+AC_CHECK_DECLS([__aarch64__],
87+ [HAVE_NEON=1; ARCH_CFLAGS="${ARCH_CFLAGS} -DWEBRTC_HAS_NEON -DWEBRTC_ARCH_ARM64"])
88+AC_CHECK_DECLS([__i386__], [HAVE_X86=1])
89+AC_CHECK_DECLS([__x86_64__], [HAVE_X86=1])
90+
91 AM_CONDITIONAL(HAVE_X86, [test "x${HAVE_X86}" = "x1"])
92 AM_CONDITIONAL(HAVE_ARM, [test "x${HAVE_ARM}" = "x1"])
93 AM_CONDITIONAL(HAVE_ARMV7, [test "x${HAVE_ARMV7}" = "x1"])
94--
952.11.0
96
diff --git a/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0004-typedefs.h-add-support-for-64-bit-and-big-endian-MIP.patch b/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0004-typedefs.h-add-support-for-64-bit-and-big-endian-MIP.patch
new file mode 100644
index 000000000..c96f10ed9
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0004-typedefs.h-add-support-for-64-bit-and-big-endian-MIP.patch
@@ -0,0 +1,41 @@
1From 0c332b7d94f8425c4f33344ddf406b6eea458861 Mon Sep 17 00:00:00 2001
2From: Tanu Kaskinen <tanuk@iki.fi>
3Date: Mon, 8 May 2017 17:01:49 +0300
4Subject: [PATCH 4/6] typedefs.h: add support for 64-bit and big endian MIPS
5
6The 64-bit check is taken from the upstream webrtc project, the big
7endian check is my own addition.
8
9Upstream-Status: Pending
10Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
11---
12 webrtc/typedefs.h | 11 ++++++++++-
13 1 file changed, 10 insertions(+), 1 deletion(-)
14
15diff --git a/webrtc/typedefs.h b/webrtc/typedefs.h
16index d875490..d1b2f54 100644
17--- a/webrtc/typedefs.h
18+++ b/webrtc/typedefs.h
19@@ -41,9 +41,18 @@
20 //#define WEBRTC_ARCH_ARMEL
21 #define WEBRTC_ARCH_32_BITS
22 #define WEBRTC_ARCH_LITTLE_ENDIAN
23-#elif defined(__MIPSEL__)
24+#elif defined(__MIPSEL__) || defined(__MIPSEB__)
25+#define WEBRTC_ARCH_MIPS_FAMILY
26+#if defined(__LP64__)
27+#define WEBRTC_ARCH_64_BITS
28+#else
29 #define WEBRTC_ARCH_32_BITS
30+#endif
31+#if defined(__MIPSEL__)
32 #define WEBRTC_ARCH_LITTLE_ENDIAN
33+#else
34+#define WEBRTC_ARCH_BIG_ENDIAN
35+#endif
36 #elif defined(__pnacl__)
37 #define WEBRTC_ARCH_32_BITS
38 #define WEBRTC_ARCH_LITTLE_ENDIAN
39--
402.11.0
41
diff --git a/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0005-typedefs.h-add-support-for-PowerPC.patch b/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0005-typedefs.h-add-support-for-PowerPC.patch
new file mode 100644
index 000000000..e16b57ecb
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0005-typedefs.h-add-support-for-PowerPC.patch
@@ -0,0 +1,28 @@
1From db5f570e928c8ca5b0b8dc702e1af0a57277f092 Mon Sep 17 00:00:00 2001
2From: Tanu Kaskinen <tanuk@iki.fi>
3Date: Mon, 3 Jul 2017 16:20:08 +0300
4Subject: [PATCH 5/6] typedefs.h: add support for PowerPC
5
6Upstream-Status: Pending
7Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
8---
9 webrtc/typedefs.h | 3 +++
10 1 file changed, 3 insertions(+)
11
12diff --git a/webrtc/typedefs.h b/webrtc/typedefs.h
13index d1b2f54..6e34d9e 100644
14--- a/webrtc/typedefs.h
15+++ b/webrtc/typedefs.h
16@@ -53,6 +53,9 @@
17 #else
18 #define WEBRTC_ARCH_BIG_ENDIAN
19 #endif
20+#elif defined(__powerpc__)
21+#define WEBRTC_ARCH_32_BITS
22+#define WEBRTC_ARCH_BIG_ENDIAN
23 #elif defined(__pnacl__)
24 #define WEBRTC_ARCH_32_BITS
25 #define WEBRTC_ARCH_LITTLE_ENDIAN
26--
272.11.0
28
diff --git a/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0006-common_audio-implement-endianness-conversion-in-wav-.patch b/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0006-common_audio-implement-endianness-conversion-in-wav-.patch
new file mode 100644
index 000000000..5826ab00d
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing/0006-common_audio-implement-endianness-conversion-in-wav-.patch
@@ -0,0 +1,116 @@
1From 7d31da8ef93987000f297d435dbacaf7d436107b Mon Sep 17 00:00:00 2001
2From: Tanu Kaskinen <tanuk@iki.fi>
3Date: Thu, 15 Jun 2017 18:38:30 +0300
4Subject: [PATCH 6/6] common_audio: implement endianness conversion in wav file
5 handling
6
7The code didn't build for big endian machines due to the missing
8endianness conversions.
9
10Upstream-Status: Pending
11Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
12---
13 webrtc/common_audio/wav_file.cc | 27 +++++++++++++++++++++------
14 webrtc/common_audio/wav_header.cc | 32 +++++++++++++++++++++++++++++++-
15 2 files changed, 52 insertions(+), 7 deletions(-)
16
17diff --git a/webrtc/common_audio/wav_file.cc b/webrtc/common_audio/wav_file.cc
18index b14b620..e2f7738 100644
19--- a/webrtc/common_audio/wav_file.cc
20+++ b/webrtc/common_audio/wav_file.cc
21@@ -64,9 +64,6 @@ WavReader::~WavReader() {
22 }
23
24 size_t WavReader::ReadSamples(size_t num_samples, int16_t* samples) {
25-#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
26-#error "Need to convert samples to big-endian when reading from WAV file"
27-#endif
28 // There could be metadata after the audio; ensure we don't read it.
29 num_samples = std::min(rtc::checked_cast<uint32_t>(num_samples),
30 num_samples_remaining_);
31@@ -76,6 +73,13 @@ size_t WavReader::ReadSamples(size_t num_samples, int16_t* samples) {
32 RTC_CHECK(read == num_samples || feof(file_handle_));
33 RTC_CHECK_LE(read, num_samples_remaining_);
34 num_samples_remaining_ -= rtc::checked_cast<uint32_t>(read);
35+
36+#ifdef WEBRTC_ARCH_BIG_ENDIAN
37+ // Convert the read samples from little-endian to big-endian.
38+ for (size_t i = 0; i < read; i++)
39+ samples[i] = ((uint16_t) samples[i] >> 8) | ((uint16_t) samples[i] << 8);
40+#endif
41+
42 return read;
43 }
44
45@@ -119,11 +123,22 @@ WavWriter::~WavWriter() {
46 }
47
48 void WavWriter::WriteSamples(const int16_t* samples, size_t num_samples) {
49-#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
50-#error "Need to convert samples to little-endian when writing to WAV file"
51-#endif
52+#ifdef WEBRTC_ARCH_BIG_ENDIAN
53+ // Convert the samples from big-endian samples to little-endian.
54+ int16_t* converted_samples = static_cast<int16_t*>(malloc(num_samples * sizeof(*samples)));
55+ RTC_CHECK(converted_samples) << "Out of memory.";
56+ for (int i = 0; i < num_samples; i++)
57+ converted_samples[i] =
58+ ((uint16_t) samples[i] >> 8) | ((uint16_t) samples[i] << 8);
59+
60+ const size_t written =
61+ fwrite(converted_samples, sizeof(*converted_samples), num_samples,
62+ file_handle_);
63+ free(converted_samples);
64+#else
65 const size_t written =
66 fwrite(samples, sizeof(*samples), num_samples, file_handle_);
67+#endif
68 RTC_CHECK_EQ(num_samples, written);
69 num_samples_ += static_cast<uint32_t>(written);
70 RTC_CHECK(written <= std::numeric_limits<uint32_t>::max() ||
71diff --git a/webrtc/common_audio/wav_header.cc b/webrtc/common_audio/wav_header.cc
72index 61cfffe..382bfc7 100644
73--- a/webrtc/common_audio/wav_header.cc
74+++ b/webrtc/common_audio/wav_header.cc
75@@ -129,7 +129,37 @@ static inline std::string ReadFourCC(uint32_t x) {
76 return std::string(reinterpret_cast<char*>(&x), 4);
77 }
78 #else
79-#error "Write be-to-le conversion functions"
80+static inline void WriteLE16(uint16_t* f, uint16_t x) {
81+ *f = x >> 8 | x << 8;
82+}
83+static inline void WriteLE32(uint32_t* f, uint32_t x) {
84+ *f = x >> 24
85+ | (x && 0xFF0000) >> 8
86+ | (x && 0xFF00) << 8
87+ | x << 24;
88+}
89+static inline void WriteFourCC(uint32_t* f, char a, char b, char c, char d) {
90+ *f = static_cast<uint32_t>(d)
91+ | static_cast<uint32_t>(c) << 8
92+ | static_cast<uint32_t>(b) << 16
93+ | static_cast<uint32_t>(a) << 24;
94+}
95+
96+static inline uint32_t ReadLE16(uint16_t x) {
97+ return x >> 8 | x << 8;
98+}
99+
100+static inline uint32_t ReadLE32(uint32_t x) {
101+ return x >> 24
102+ | (x && 0xFF0000) >> 8
103+ | (x && 0xFF00) << 8
104+ | x << 24;
105+}
106+
107+static inline std::string ReadFourCC(uint32_t x) {
108+ x = ReadLE32(x);
109+ return std::string(reinterpret_cast<char*>(&x), 4);
110+}
111 #endif
112
113 static inline uint32_t RiffChunkSize(uint32_t bytes_in_payload) {
114--
1152.11.0
116
diff --git a/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing_0.3.bb b/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing_0.3.bb
new file mode 100644
index 000000000..eb9a30466
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/webrtc-audio-processing/webrtc-audio-processing_0.3.bb
@@ -0,0 +1,25 @@
1DESCRIPTION = "Audio processing bits of the WebRTC reference implementation"
2HOMEPAGE = "https://www.freedesktop.org/software/pulseaudio/webrtc-audio-processing/"
3SECTION = "audio"
4
5LICENSE = "BSD-3-Clause"
6LIC_FILES_CHKSUM = "file://COPYING;md5=da08a38a32a340c5d91e13ee86a118f2 \
7 file://webrtc/common.h;beginline=1;endline=9;md5=41f7322d91deabaf0acbbd0b8d0bc548 \
8"
9
10# Note that patch 3 effectively reverts patches 1 and 2. The only reason
11# why patches 1 and 2 are included is that otherwise patch 3 wouldn't
12# apply cleanly.
13SRC_URI = "http://freedesktop.org/software/pulseaudio/webrtc-audio-processing/${BP}.tar.xz \
14 file://0001-build-Protect-against-unsupported-CPU-types.patch \
15 file://0002-build-Add-ARM-64bit-support.patch \
16 file://0003-build-fix-architecture-detection.patch \
17 file://0004-typedefs.h-add-support-for-64-bit-and-big-endian-MIP.patch \
18 file://0005-typedefs.h-add-support-for-PowerPC.patch \
19 file://0006-common_audio-implement-endianness-conversion-in-wav-.patch \
20"
21
22SRC_URI[md5sum] = "336ae032f608e65808ac577cde0ab72c"
23SRC_URI[sha256sum] = "756e291d4f557d88cd50c4fe3b8454ec238362d22cedb3e6173240d90f0a80fa"
24
25inherit autotools