Skip to content

Commit d65dcd6

Browse files
committed
Added WebRTC, pffft to the project & build instructions + Replaced rnnoise with WebRTC-modified version + Set include interface for ffmpeg dependencies
1 parent 859161c commit d65dcd6

35 files changed

+11018
-19
lines changed

‎.gitmodules

+3-4
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,9 @@
8686
path = app/jni/third_party/openh264
8787
url = https://github.com/cisco/openh264
8888
shallow = true
89-
[submodule "rnnoise"]
90-
path = app/jni/third_party/rnnoise
91-
url = https://github.com/xiph/rnnoise
92-
shallow = true
9389
[submodule "app/jni/third_party/abseil-cpp"]
9490
path = app/jni/third_party/abseil-cpp
9591
url = https://github.com/abseil/abseil-cpp
92+
[submodule "app/jni/third_party/webrtc"]
93+
path = app/jni/third_party/webrtc
94+
url = https://github.com/ali-fareed/webrtc

‎app/jni/BuildAbsl.cmake

+4-1
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ add_library(absl STATIC
347347
"${ABSL_DIR}/absl/types/bad_optional_access.cc"
348348
"${ABSL_DIR}/absl/types/bad_variant_access.cc"
349349
)
350+
target_compile_definitions(absl PRIVATE
351+
ABSL_ALLOCATOR_NOTHROW=1
352+
)
350353
target_include_directories(absl PUBLIC
351354
"${ABSL_DIR}"
352-
)
355+
)

‎app/jni/BuildOpenH264.cmake

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ add_library(openh264 STATIC
6969
"${OPENH264_DIR}/codec/processing/src/vaacalc/vaacalcfuncs.cpp"
7070
"${OPENH264_DIR}/codec/processing/src/vaacalc/vaacalculation.cpp"
7171
)
72-
target_include_directories(openh264 PUBLIC
72+
target_include_directories(openh264 PRIVATE
7373
"${OPENH264_DIR}/codec/encoder/core/inc"
7474
"${OPENH264_DIR}/codec/encoder/plus/inc"
7575
"${OPENH264_DIR}/codec/decoder/plus/inc"
@@ -97,10 +97,10 @@ if (${ANDROID_ABI} STREQUAL "armeabi-v7a")
9797
"${OPENH264_DIR}/codec/processing/src/arm/pixel_sad_neon.S"
9898
"${OPENH264_DIR}/codec/processing/src/arm/vaa_calc_neon.S"
9999
)
100-
target_include_directories(openh264 PUBLIC
100+
target_include_directories(openh264 PRIVATE
101101
"${OPENH264_DIR}/codec/common/arm"
102102
)
103-
target_compile_definitions(openh264 PUBLIC
103+
target_compile_definitions(openh264 PRIVATE
104104
HAVE_NEON=1
105105
)
106106
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
@@ -121,7 +121,7 @@ elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
121121
"${OPENH264_DIR}/codec/processing/src/arm64/pixel_sad_aarch64_neon.S"
122122
"${OPENH264_DIR}/codec/processing/src/arm64/vaa_calc_aarch64_neon.S"
123123
)
124-
target_include_directories(openh264 PUBLIC
124+
target_include_directories(openh264 PRIVATE
125125
"${OPENH264_DIR}/codec/common/arm64"
126126
)
127127
target_compile_definitions(openh264 PUBLIC

‎app/jni/BuildWebRTC.cmake

+2,738
Large diffs are not rendered by default.

‎app/jni/CMakeLists.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ elseif(${ANDROID_ABI} STREQUAL "x86")
3131
elseif(${ANDROID_ABI} STREQUAL "armeabi-v7a")
3232
set(FFMPEG_ABI "armv7-a")
3333
else()
34-
error("Unknown abi: ${ANDROID_ABI}")
34+
message(FATAL_ERROR "Unknown abi: ${ANDROID_ABI}")
3535
endif()
3636
set(FFMPEG_DIR "${THIRDPARTY_DIR}/ffmpeg/build/${FFMPEG_ABI}")
3737
set(FFMPEG_LIBS
@@ -75,10 +75,9 @@ else()
7575
)
7676
endif()
7777
set(ADD_C_FLAGS ${ADD_COMMON_FLAGS}
78-
-std=c11
7978
-D_LARGEFILE_SOURCE=1
8079
)
81-
set(ADD_CXX_FLAGS ${ADD_COMMON_FLAGS})
80+
set(ADD_CXX_FLAGS ${ADD_COMMON_FLAGS} -std=c++17)
8281

8382
foreach(lang C CXX)
8483
Join(ADD_${lang}_FLAGS "${ADD_${lang}_FLAGS}" " ")
@@ -105,8 +104,8 @@ set(EXCLUDE_LIBS
105104
libusrsctp.a
106105
libsrtp.a
107106
libopenh264.a
108-
librnnoise.a
109107
libabsl.a
108+
libwebrtc.a
110109
)
111110
if (${USE_WEBP})
112111
list(APPEND EXCLUDE_LIBS
@@ -168,12 +167,12 @@ include("${CMAKE_HOME_DIRECTORY}/BuildLibSRTP.cmake")
168167
# openh264
169168
include("${CMAKE_HOME_DIRECTORY}/BuildOpenH264.cmake")
170169

171-
# rnnoise
172-
include("${CMAKE_HOME_DIRECTORY}/BuildRNNoise.cmake")
173-
174170
# absl
175171
include("${CMAKE_HOME_DIRECTORY}/BuildAbsl.cmake")
176172

173+
# webrtc
174+
include("${CMAKE_HOME_DIRECTORY}/BuildWebRTC.cmake")
175+
177176
# yuv
178177
include("${CMAKE_HOME_DIRECTORY}/BuildYuv.cmake")
179178

@@ -206,6 +205,7 @@ endif()
206205
foreach(FFMPEG_LIB IN LISTS FFMPEG_LIBS)
207206
add_library(${FFMPEG_LIB} STATIC IMPORTED)
208207
set_target_properties(${FFMPEG_LIB} PROPERTIES IMPORTED_LOCATION "${FFMPEG_DIR}/lib/lib${FFMPEG_LIB}.a")
208+
target_include_directories(${FFMPEG_LIB} INTERFACE "${FFMPEG_DIR}/include")
209209
endforeach()
210210

211211
# == Target ==
@@ -285,8 +285,8 @@ target_link_libraries(${NATIVE_LIB}
285285
usrsctp
286286
srtp
287287
openh264
288-
rnnoise
289288
absl
289+
webrtc
290290
)
291291
if (${USE_WEBP})
292292
target_link_libraries(${NATIVE_LIB} webpdecoder_static)

‎app/jni/third_party/libyuv

Submodule libyuv updated from b4ddbaf to 2bdc210

‎app/jni/third_party/pffft/BUILD.gn

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Copyright 2019 The Chromium Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
import("//build/config/arm.gni")
6+
import("//testing/libfuzzer/fuzzer_test.gni")
7+
import("//testing/test.gni")
8+
9+
config("common_config") {
10+
if (is_win) {
11+
defines = [
12+
# Required to use math constants from math.h.
13+
"_USE_MATH_DEFINES",
14+
]
15+
}
16+
17+
# PFFFT doesn't support SIMD on some cpus, so build a scalar version.
18+
if ((current_cpu == "arm" && !arm_use_neon) || current_cpu == "mipsel" ||
19+
current_cpu == "mips64el" || current_cpu == "ppc64" ||
20+
current_cpu == "s390x") {
21+
defines = [ "PFFFT_SIMD_DISABLE" ]
22+
}
23+
}
24+
25+
static_library("pffft") {
26+
configs += [ ":common_config" ]
27+
sources = [
28+
"src/pffft.c",
29+
"src/pffft.h",
30+
]
31+
}
32+
33+
# Fuzzing.
34+
35+
group("fuzzers") {
36+
testonly = true
37+
deps = [
38+
":pffft_complex_fuzzer",
39+
":pffft_real_fuzzer",
40+
]
41+
}
42+
43+
fuzzer_testdata_dir = "$target_gen_dir/testdata"
44+
45+
action("generate_pffft_fuzzer_corpus") {
46+
script = "generate_seed_corpus.py"
47+
sources = [ "generate_seed_corpus.py" ]
48+
args = [ rebase_path(fuzzer_testdata_dir, root_build_dir) ]
49+
outputs = [ fuzzer_testdata_dir ]
50+
}
51+
52+
fuzzer_test("pffft_complex_fuzzer") {
53+
sources = [ "pffft_fuzzer.cc" ]
54+
cflags = [ "-DTRANSFORM_COMPLEX" ]
55+
deps = [ ":pffft" ]
56+
seed_corpus = fuzzer_testdata_dir
57+
seed_corpus_deps = [ ":generate_pffft_fuzzer_corpus" ]
58+
}
59+
60+
fuzzer_test("pffft_real_fuzzer") {
61+
sources = [ "pffft_fuzzer.cc" ]
62+
cflags = [ "-DTRANSFORM_REAL" ]
63+
deps = [ ":pffft" ]
64+
seed_corpus = fuzzer_testdata_dir
65+
seed_corpus_deps = [ ":generate_pffft_fuzzer_corpus" ]
66+
}
67+
68+
# Unit tests and benchmark.
69+
70+
# This target must be used only for testing and benchmark purposes.
71+
static_library("fftpack") {
72+
testonly = true
73+
configs += [ ":common_config" ]
74+
sources = [
75+
"src/fftpack.c",
76+
"src/fftpack.h",
77+
]
78+
visibility = [ ":*" ]
79+
}
80+
81+
config("pffft_benchmark_internal_config") {
82+
cflags = [
83+
# test_pffft.c contains an `exit(1)` following a `break` statement.
84+
"-Wno-unreachable-code",
85+
]
86+
}
87+
88+
executable("pffft_benchmark") {
89+
testonly = true
90+
configs += [
91+
":common_config",
92+
":pffft_benchmark_internal_config",
93+
]
94+
sources = [ "src/test_pffft.c" ]
95+
deps = [
96+
":fftpack",
97+
":pffft",
98+
]
99+
}
100+
101+
test("pffft_unittest") {
102+
testonly = true
103+
sources = [ "pffft_unittest.cc" ]
104+
deps = [
105+
":fftpack",
106+
":pffft",
107+
"//testing/gtest",
108+
"//testing/gtest:gtest_main",
109+
]
110+
}

‎app/jni/third_party/pffft/DEPS

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include_rules = [
2+
"+testing/gtest/include/gtest",
3+
]

‎app/jni/third_party/pffft/LICENSE

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Copyright (c) 2013 Julien Pommier ( pommier@modartt.com )
2+
3+
Based on original fortran 77 code from FFTPACKv4 from NETLIB,
4+
authored by Dr Paul Swarztrauber of NCAR, in 1985.
5+
6+
As confirmed by the NCAR fftpack software curators, the following
7+
FFTPACKv5 license applies to FFTPACKv4 sources. My changes are
8+
released under the same terms.
9+
10+
FFTPACK license:
11+
12+
http://www.cisl.ucar.edu/css/software/fftpack5/ftpk.html
13+
14+
Copyright (c) 2004 the University Corporation for Atmospheric
15+
Research ("UCAR"). All rights reserved. Developed by NCAR's
16+
Computational and Information Systems Laboratory, UCAR,
17+
www.cisl.ucar.edu.
18+
19+
Redistribution and use of the Software in source and binary forms,
20+
with or without modification, is permitted provided that the
21+
following conditions are met:
22+
23+
- Neither the names of NCAR's Computational and Information Systems
24+
Laboratory, the University Corporation for Atmospheric Research,
25+
nor the names of its sponsors or contributors may be used to
26+
endorse or promote products derived from this Software without
27+
specific prior written permission.
28+
29+
- Redistributions of source code must retain the above copyright
30+
notices, this list of conditions, and the disclaimer below.
31+
32+
- Redistributions in binary form must reproduce the above copyright
33+
notice, this list of conditions, and the disclaimer below in the
34+
documentation and/or other materials provided with the
35+
distribution.
36+
37+
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
38+
EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF
39+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
40+
NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT
41+
HOLDERS BE LIABLE FOR ANY CLAIM, INDIRECT, INCIDENTAL, SPECIAL,
42+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY, WHETHER IN AN
43+
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
44+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
45+
SOFTWARE.

‎app/jni/third_party/pffft/OWNERS

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
maxmorin@chromium.org
2+
olka@chromium.org
3+
4+
# COMPONENT: Blink>WebRTC>Audio
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Name: PFFFT: a pretty fast FFT.
2+
Short Name: PFFFT
3+
URL: https://bitbucket.org/jpommier/pffft/
4+
Version: 0
5+
Date: 2014-08-09
6+
Revision: 483453d8f766
7+
License: BSD-like
8+
License File: LICENSE
9+
Security Critical: Yes
10+
License Android Compatible: Yes
11+
12+
Description:
13+
PFFFT does 1D Fast Fourier Transforms, of single precision real and complex vectors. It tries do it fast, it tries to be correct, and it tries to be small. Computations do take advantage of SSE1 instructions on x86 cpus, Altivec on powerpc cpus, and NEON on ARM cpus.
14+
15+
Note about the structure of //third_party/pffft:
16+
The imported third party code (with patches applied, see "Local Modifications") lives in //third_party/pffft/src/, whereas the fuzzer and unit test code lives in //third_party/pffft.
17+
18+
Remarks on the C library and recommendations:
19+
- The C API is unsafe: input and output arrays are passed as pointers without size
20+
- When a scratch array is not provided (e.g., pffft_transform(/*work=*/nullptr)), VLA is used
21+
* MSVC: stack or heap depending on size
22+
* other compilers: always on the stack
23+
- According to the PFFFT documentation, when SIMD is enabled, input, output and scratch arrays must be allocated as aligned memory (16-byte boundary on intel and PowerPC);
24+
as long as the SIMD extension API requirements are met, one may use different options (and not only pffft_aligned_malloc) such as std::vector
25+
- It is strongly recommended that a C++ wrapper is used to
26+
(i) avoid pointer arguments (e.g., using absl::Span)
27+
(ii) pre-allocate the scratch buffer for large FFT sizes
28+
(iii) provide a function to check if an integer is a supported FFT size
29+
30+
Local Modifications:
31+
32+
Local modifications live in //third_party/pffft/patches/. To apply them run:
33+
$ for patch in third_party/pffft/patches/*; do patch -s -p1 < $patch; done
34+
35+
In case of conflict, update those patches accordingly and save them back in //third_party/pffft/patches/.
36+
37+
* 01-rmv_printf.diff: remove printf and stop including stdio.h
38+
* 02-decl_validate_simd.diff: declare validate_pffft_simd() in pffft.h
39+
* 03-malloca.diff: replace _alloca (deprecated) with _malloca (MSVC case only) + cleanup
40+
* 04-fix_ptr_cast.diff: avoid MSVC warnings by fixing pointer cast
41+
* 05-fix-arch-detection.diff: better arch detection to avoid to define PFFFT_SIMD_DISABLE

0 commit comments

Comments
 (0)