Skip to content

Commit f82ec6d

Browse files
youennfphiln
authored andcommitted
Update libwebrtc opus to M115
https://bugs.webkit.org/show_bug.cgi?id=257808 rdar://problem/110398459 Reviewed by Eric Carlson. * Source/ThirdParty/libwebrtc/Source/third_party/opus: Resynced. Canonical link: https://commits.webkit.org/265062@main
1 parent 25e5016 commit f82ec6d

79 files changed

Lines changed: 1318 additions & 1026 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Source/ThirdParty/libwebrtc/Source/third_party/opus/BUILD.gn

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2014 The Chromium Authors. All rights reserved.
1+
# Copyright 2014 The Chromium Authors
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

@@ -11,7 +11,7 @@ use_opus_fixed_point = current_cpu == "arm" || current_cpu == "arm64"
1111
# If ARM optimizations shall be used to accelerate performance.
1212
# TODO(scottmg): Disabled on Fuchsia for now, see https://crbug.com/775272.
1313
use_opus_arm_optimization =
14-
current_cpu == "arm" || (current_cpu == "arm64" && is_ios)
14+
current_cpu == "arm" || (current_cpu == "arm64" && (is_ios || is_win))
1515

1616
# NaCl, unlike Chrome, doesn't target SSE2 minimum, so skip optimizations for
1717
# the sake of simplicity.
@@ -610,20 +610,23 @@ test("test_opus_padding") {
610610
deps = [ ":opus" ]
611611
}
612612

613-
# Compilation fails on windows due to wstring/string mistmatch.
614-
# This is not worth looking at it since the benchmark is tailored for android.
615-
# It is ok to run it on linux though, for experimentation purpose.
616-
if (is_android || is_linux || is_chromeos) {
617-
test("opus_tests") {
618-
sources = [ "tests/opus_benchmark.cc" ]
619-
620-
data = [ "tests/resources/speech_mono_32_48kHz.pcm" ]
621-
622-
deps = [
623-
":opus",
624-
"//base",
625-
"//testing/gtest",
626-
"//testing/gtest:gtest_main",
627-
]
613+
# Not all checkouts have a //base directory.
614+
if (build_with_chromium) {
615+
# Compilation fails on windows due to wstring/string mistmatch.
616+
# This is not worth looking at it since the benchmark is tailored for android.
617+
# It is ok to run it on linux though, for experimentation purpose.
618+
if (is_android || is_linux || is_chromeos) {
619+
test("opus_tests") {
620+
sources = [ "tests/opus_benchmark.cc" ]
621+
622+
data = [ "tests/resources/speech_mono_32_48kHz.pcm" ]
623+
624+
deps = [
625+
":opus",
626+
"//base",
627+
"//testing/gtest",
628+
"//testing/gtest:gtest_main",
629+
]
630+
}
628631
}
629632
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
flim@chromium.org
2-
henrika@chromium.org
2+
gustaf@chromium.org

Source/ThirdParty/libwebrtc/Source/third_party/opus/README.chromium

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: opus
22
URL: https://gitlab.xiph.org/xiph/opus
3-
Version: 7b05f44f
3+
Version: 8cf872a1
44
License: BSD
55
License File: src/COPYING
66
Security Critical: yes
@@ -18,4 +18,5 @@ Local changes:
1818
* add workaround to ignore some int-overflows when fuzzing (see crbug/1146174)
1919

2020
Opus' own unit tests are located in ./src/tests
21-
Additional chromium tests are located in ./tests
21+
Additional chromium tests are located in ./tests, and require chromium
22+
checkout to run the tests.

Source/ThirdParty/libwebrtc/Source/third_party/opus/convert_rtcd_assembler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# Copyright 2014 The Chromium Authors. All rights reserved.
2+
# Copyright 2014 The Chromium Authors
33
# Use of this source code is governed by a BSD-style license that can be
44
# found in the LICENSE file.
55

Source/ThirdParty/libwebrtc/Source/third_party/opus/src/CMakeLists.txt

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,23 @@ if(NOT OPUS_ENABLE_FLOAT_API)
366366
endif()
367367

368368
if(NOT OPUS_DISABLE_INTRINSICS)
369-
if((OPUS_X86_MAY_HAVE_SSE AND NOT OPUS_X86_PRESUME_SSE) OR
369+
if(((OPUS_X86_MAY_HAVE_SSE AND NOT OPUS_X86_PRESUME_SSE) OR
370370
(OPUS_X86_MAY_HAVE_SSE2 AND NOT OPUS_X86_PRESUME_SSE2) OR
371371
(OPUS_X86_MAY_HAVE_SSE4_1 AND NOT OPUS_X86_PRESUME_SSE4_1) OR
372-
(OPUS_X86_MAY_HAVE_AVX AND NOT OPUS_X86_PRESUME_AVX))
372+
(OPUS_X86_MAY_HAVE_AVX AND NOT OPUS_X86_PRESUME_AVX)) AND
373+
RUNTIME_CPU_CAPABILITY_DETECTION)
373374
target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD)
375+
if(NOT MSVC)
376+
if(CPU_INFO_BY_ASM_SUPPORTED)
377+
target_compile_definitions(opus PRIVATE CPU_INFO_BY_ASM)
378+
elseif(CPU_INFO_BY_C_SUPPORTED)
379+
target_compile_definitions(opus PRIVATE CPU_INFO_BY_C)
380+
else()
381+
message(ERROR "Runtime cpu capability detection is enabled while CPU_INFO is not supported")
382+
endif()
383+
endif()
384+
add_sources_group(opus celt ${celt_sources_x86_rtcd})
385+
add_sources_group(opus silk ${silk_sources_x86_rtcd})
374386
endif()
375387

376388
if(SSE1_SUPPORTED)
@@ -455,15 +467,13 @@ if(NOT OPUS_DISABLE_INTRINSICS)
455467
endif()
456468
endif()
457469

458-
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)")
459-
add_sources_group(opus celt ${celt_sources_arm})
460-
endif()
461-
462470
if(COMPILER_SUPPORT_NEON)
463471
if(OPUS_MAY_HAVE_NEON)
464472
if(RUNTIME_CPU_CAPABILITY_DETECTION)
465473
message(STATUS "OPUS_MAY_HAVE_NEON enabling runtime detection")
466474
target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD)
475+
add_sources_group(opus celt ${celt_sources_arm_rtcd})
476+
add_sources_group(opus silk ${silk_sources_arm_rtcd})
467477
else()
468478
message(ERROR "Runtime cpu capability detection needed for MAY_HAVE_NEON")
469479
endif()
@@ -565,54 +575,72 @@ if(OPUS_BUILD_PROGRAMS)
565575
target_include_directories(opus_custom_demo
566576
PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
567577
target_link_libraries(opus_custom_demo PRIVATE opus)
578+
target_compile_definitions(opus_custom_demo PRIVATE OPUS_BUILD)
568579
endif()
569580

570581
add_executable(opus_demo ${opus_demo_sources})
571582
target_include_directories(opus_demo PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
572583
target_include_directories(opus_demo PRIVATE silk) # debug.h
573584
target_include_directories(opus_demo PRIVATE celt) # arch.h
574585
target_link_libraries(opus_demo PRIVATE opus ${OPUS_REQUIRED_LIBRARIES})
586+
target_compile_definitions(opus_demo PRIVATE OPUS_BUILD)
575587

576588
# compare
577589
add_executable(opus_compare ${opus_compare_sources})
578590
target_include_directories(opus_compare PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
579591
target_link_libraries(opus_compare PRIVATE opus ${OPUS_REQUIRED_LIBRARIES})
592+
if(MSVC)
593+
# move cosmetic warning to level 4 for opus_compare
594+
target_compile_options(opus_compare PRIVATE /w44244)
595+
endif()
580596
endif()
581597

582-
if(BUILD_TESTING)
598+
if(BUILD_TESTING AND NOT BUILD_SHARED_LIBS)
583599
enable_testing()
584600

585601
# tests
586602
add_executable(test_opus_decode ${test_opus_decode_sources})
587603
target_include_directories(test_opus_decode
588604
PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
589605
target_link_libraries(test_opus_decode PRIVATE opus)
606+
target_compile_definitions(test_opus_decode PRIVATE OPUS_BUILD)
590607
if(OPUS_FIXED_POINT)
591608
target_compile_definitions(test_opus_decode PRIVATE DISABLE_FLOAT_API)
592609
endif()
593-
add_test(NAME test_opus_decode COMMAND $<TARGET_FILE:test_opus_decode> WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
610+
add_test(NAME test_opus_decode COMMAND ${CMAKE_COMMAND}
611+
-DTEST_EXECUTABLE=$<TARGET_FILE:test_opus_decode>
612+
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
613+
-P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake")
594614

595615
add_executable(test_opus_padding ${test_opus_padding_sources})
596616
target_include_directories(test_opus_padding
597617
PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
598618
target_link_libraries(test_opus_padding PRIVATE opus)
599-
add_test(NAME test_opus_padding COMMAND $<TARGET_FILE:test_opus_padding> WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
600-
601-
if(NOT BUILD_SHARED_LIBS)
602-
# disable tests that depends on private API when building shared lib
603-
add_executable(test_opus_api ${test_opus_api_sources})
604-
target_include_directories(test_opus_api
605-
PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt)
606-
target_link_libraries(test_opus_api PRIVATE opus)
607-
if(OPUS_FIXED_POINT)
608-
target_compile_definitions(test_opus_api PRIVATE DISABLE_FLOAT_API)
609-
endif()
610-
add_test(NAME test_opus_api COMMAND $<TARGET_FILE:test_opus_api> WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
611-
612-
add_executable(test_opus_encode ${test_opus_encode_sources})
613-
target_include_directories(test_opus_encode
614-
PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt)
615-
target_link_libraries(test_opus_encode PRIVATE opus)
616-
add_test(NAME test_opus_encode COMMAND $<TARGET_FILE:test_opus_encode> WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
619+
add_test(NAME test_opus_padding COMMAND ${CMAKE_COMMAND}
620+
-DTEST_EXECUTABLE=$<TARGET_FILE:test_opus_padding>
621+
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
622+
-P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake")
623+
624+
add_executable(test_opus_api ${test_opus_api_sources})
625+
target_include_directories(test_opus_api
626+
PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt)
627+
target_link_libraries(test_opus_api PRIVATE opus)
628+
target_compile_definitions(test_opus_api PRIVATE OPUS_BUILD)
629+
if(OPUS_FIXED_POINT)
630+
target_compile_definitions(test_opus_api PRIVATE DISABLE_FLOAT_API)
617631
endif()
632+
add_test(NAME test_opus_api COMMAND ${CMAKE_COMMAND}
633+
-DTEST_EXECUTABLE=$<TARGET_FILE:test_opus_api>
634+
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
635+
-P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake")
636+
637+
add_executable(test_opus_encode ${test_opus_encode_sources})
638+
target_include_directories(test_opus_encode
639+
PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt)
640+
target_link_libraries(test_opus_encode PRIVATE opus)
641+
target_compile_definitions(test_opus_encode PRIVATE OPUS_BUILD)
642+
add_test(NAME test_opus_encode COMMAND ${CMAKE_COMMAND}
643+
-DTEST_EXECUTABLE=$<TARGET_FILE:test_opus_encode>
644+
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
645+
-P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake")
618646
endif()

Source/ThirdParty/libwebrtc/Source/third_party/opus/src/Makefile.am

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ else
3636
OPUS_SOURCES += $(OPUS_SOURCES_FLOAT)
3737
endif
3838

39+
if CPU_X86
40+
if HAVE_RTCD
41+
CELT_SOURCES += $(CELT_SOURCES_X86_RTCD)
42+
SILK_SOURCES += $(SILK_SOURCES_X86_RTCD)
43+
endif
3944
if HAVE_SSE
4045
CELT_SOURCES += $(CELT_SOURCES_SSE)
4146
endif
@@ -45,10 +50,13 @@ endif
4550
if HAVE_SSE4_1
4651
CELT_SOURCES += $(CELT_SOURCES_SSE4_1)
4752
endif
53+
endif
4854

4955
if CPU_ARM
50-
CELT_SOURCES += $(CELT_SOURCES_ARM)
51-
SILK_SOURCES += $(SILK_SOURCES_ARM)
56+
if HAVE_RTCD
57+
CELT_SOURCES += $(CELT_SOURCES_ARM_RTCD)
58+
SILK_SOURCES += $(SILK_SOURCES_ARM_RTCD)
59+
endif
5260

5361
if HAVE_ARM_NEON_INTR
5462
CELT_SOURCES += $(CELT_SOURCES_ARM_NEON_INTR)
@@ -222,8 +230,11 @@ EXTRA_DIST = opus.pc.in \
222230
cmake/OpusFunctions.cmake \
223231
cmake/OpusPackageVersion.cmake \
224232
cmake/OpusSources.cmake \
233+
cmake/RunTest.cmake \
225234
cmake/config.h.cmake.in \
226235
cmake/vla.c \
236+
cmake/cpu_info_by_asm.c \
237+
cmake/cpu_info_by_c.c \
227238
meson/get-version.py \
228239
meson/read-sources-list.py \
229240
meson.build \

Source/ThirdParty/libwebrtc/Source/third_party/opus/src/celt/arm/armcpu.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ opus_uint32 opus_cpu_capabilities(void)
156156
"your platform. Reconfigure with --disable-rtcd (or send patches)."
157157
#endif
158158

159-
int opus_select_arch(void)
159+
static int opus_select_arch_impl(void)
160160
{
161161
opus_uint32 flags = opus_cpu_capabilities();
162162
int arch = 0;
@@ -184,4 +184,11 @@ int opus_select_arch(void)
184184
return arch;
185185
}
186186

187+
int opus_select_arch(void) {
188+
int arch = opus_select_arch_impl();
189+
#ifdef FUZZING
190+
arch = rand()%(arch+1);
191+
#endif
192+
return arch;
193+
}
187194
#endif

Source/ThirdParty/libwebrtc/Source/third_party/opus/src/celt/arm/pitch_neon_intr.c

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -137,55 +137,38 @@ void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, const opus
137137
/* celt_inner_prod_neon_float_c_simulation() simulates the floating-point */
138138
/* operations of celt_inner_prod_neon(), and both functions should have bit */
139139
/* exact output. */
140-
static opus_val32 celt_inner_prod_neon_float_c_simulation(const opus_val16 *x, const opus_val16 *y, int N)
140+
static opus_val32 celt_inner_prod_neon_float_c_simulation(const opus_val16 *x, const opus_val16 *y, float *err, int N)
141141
{
142142
int i;
143+
*err = 0;
143144
opus_val32 xy, xy0 = 0, xy1 = 0, xy2 = 0, xy3 = 0;
144145
for (i = 0; i < N - 3; i += 4) {
145146
xy0 = MAC16_16(xy0, x[i + 0], y[i + 0]);
146147
xy1 = MAC16_16(xy1, x[i + 1], y[i + 1]);
147148
xy2 = MAC16_16(xy2, x[i + 2], y[i + 2]);
148149
xy3 = MAC16_16(xy3, x[i + 3], y[i + 3]);
150+
*err += ABS32(xy0)+ABS32(xy1)+ABS32(xy2)+ABS32(xy3);
149151
}
150152
xy0 += xy2;
151153
xy1 += xy3;
152154
xy = xy0 + xy1;
155+
*err += ABS32(xy1)+ABS32(xy0)+ABS32(xy);
153156
for (; i < N; i++) {
154157
xy = MAC16_16(xy, x[i], y[i]);
158+
*err += ABS32(xy);
155159
}
160+
*err = *err*2e-7 + N*1e-37;
156161
return xy;
157162
}
158163

159164
/* dual_inner_prod_neon_float_c_simulation() simulates the floating-point */
160165
/* operations of dual_inner_prod_neon(), and both functions should have bit */
161166
/* exact output. */
162167
static void dual_inner_prod_neon_float_c_simulation(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02,
163-
int N, opus_val32 *xy1, opus_val32 *xy2)
168+
int N, opus_val32 *xy1, opus_val32 *xy2, float *err)
164169
{
165-
int i;
166-
opus_val32 xy01, xy02, xy01_0 = 0, xy01_1 = 0, xy01_2 = 0, xy01_3 = 0, xy02_0 = 0, xy02_1 = 0, xy02_2 = 0, xy02_3 = 0;
167-
for (i = 0; i < N - 3; i += 4) {
168-
xy01_0 = MAC16_16(xy01_0, x[i + 0], y01[i + 0]);
169-
xy01_1 = MAC16_16(xy01_1, x[i + 1], y01[i + 1]);
170-
xy01_2 = MAC16_16(xy01_2, x[i + 2], y01[i + 2]);
171-
xy01_3 = MAC16_16(xy01_3, x[i + 3], y01[i + 3]);
172-
xy02_0 = MAC16_16(xy02_0, x[i + 0], y02[i + 0]);
173-
xy02_1 = MAC16_16(xy02_1, x[i + 1], y02[i + 1]);
174-
xy02_2 = MAC16_16(xy02_2, x[i + 2], y02[i + 2]);
175-
xy02_3 = MAC16_16(xy02_3, x[i + 3], y02[i + 3]);
176-
}
177-
xy01_0 += xy01_2;
178-
xy02_0 += xy02_2;
179-
xy01_1 += xy01_3;
180-
xy02_1 += xy02_3;
181-
xy01 = xy01_0 + xy01_1;
182-
xy02 = xy02_0 + xy02_1;
183-
for (; i < N; i++) {
184-
xy01 = MAC16_16(xy01, x[i], y01[i]);
185-
xy02 = MAC16_16(xy02, x[i], y02[i]);
186-
}
187-
*xy1 = xy01;
188-
*xy2 = xy02;
170+
*xy1 = celt_inner_prod_neon_float_c_simulation(x, y01, &err[0], N);
171+
*xy2 = celt_inner_prod_neon_float_c_simulation(x, y02, &err[1], N);
189172
}
190173

191174
#endif /* OPUS_CHECK_ASM */
@@ -225,7 +208,12 @@ opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N)
225208
}
226209

227210
#ifdef OPUS_CHECK_ASM
228-
celt_assert(ABS32(celt_inner_prod_neon_float_c_simulation(x, y, N) - xy) <= VERY_SMALL);
211+
{
212+
float err, res;
213+
res = celt_inner_prod_neon_float_c_simulation(x, y, &err, N);
214+
/*if (ABS32(res - xy) > err) fprintf(stderr, "%g %g %g\n", res, xy, err);*/
215+
celt_assert(ABS32(res - xy) <= err);
216+
}
229217
#endif
230218

231219
return xy;
@@ -280,9 +268,12 @@ void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, const opus
280268
#ifdef OPUS_CHECK_ASM
281269
{
282270
opus_val32 xy1_c, xy2_c;
283-
dual_inner_prod_neon_float_c_simulation(x, y01, y02, N, &xy1_c, &xy2_c);
284-
celt_assert(ABS32(xy1_c - *xy1) <= VERY_SMALL);
285-
celt_assert(ABS32(xy2_c - *xy2) <= VERY_SMALL);
271+
float err[2];
272+
dual_inner_prod_neon_float_c_simulation(x, y01, y02, N, &xy1_c, &xy2_c, err);
273+
/*if (ABS32(xy1_c - *xy1) > err[0]) fprintf(stderr, "dual1 fail: %g %g %g\n", xy1_c, *xy1, err[0]);
274+
if (ABS32(xy2_c - *xy2) > err[1]) fprintf(stderr, "dual2 fail: %g %g %g\n", xy2_c, *xy2, err[1]);*/
275+
celt_assert(ABS32(xy1_c - *xy1) <= err[0]);
276+
celt_assert(ABS32(xy2_c - *xy2) <= err[1]);
286277
}
287278
#endif
288279
}

0 commit comments

Comments
 (0)