Skip to content

Commit 3bc0acb

Browse files
committed
Merge branch 'dev41' into unicode
2 parents 91b18ff + 3bb6b1f commit 3bc0acb

File tree

147 files changed

+6628
-1571
lines changed

Some content is hidden

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

147 files changed

+6628
-1571
lines changed

opus/CMakeLists.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ add_definitions(
2020
-DOPUS_X86_PRESUME_SSE4_1
2121
)
2222

23+
if("${TIM41_X86_SIMD_LEVEL}" MATCHES "^(AVX2|AVX512)$")
24+
add_definitions(
25+
-DOPUS_X86_MAY_HAVE_AVX2
26+
-DOPUS_X86_PRESUME_AVX2
27+
)
28+
elseif(MSVC)
29+
add_definitions(
30+
-DOPUS_HAVE_RTCD
31+
-DOPUS_X86_MAY_HAVE_AVX2
32+
)
33+
endif()
34+
2335
add_library(
2436
opus SHARED
2537

@@ -32,6 +44,7 @@ add_library(
3244

3345
src/analysis.c
3446
src/analysis.h
47+
src/extensions.c
3548
src/mlp.c
3649
src/mlp.h
3750
src/mlp_data.c
@@ -43,7 +56,6 @@ add_library(
4356
src/opus_multistream_encoder.c
4457
src/opus_private.h
4558
src/repacketizer.c
46-
src/tansig_table.h
4759

4860
celt/arch.h
4961
celt/bands.c
@@ -95,12 +107,14 @@ add_library(
95107
celt/_kiss_fft_guts.h
96108
celt/x86/celt_lpc_sse4_1.c
97109
celt/x86/celt_lpc_sse.h
110+
celt/x86/pitch_avx.c
98111
celt/x86/pitch_sse.c
99112
celt/x86/pitch_sse.h
100113
celt/x86/pitch_sse2.c
101114
celt/x86/pitch_sse4_1.c
102115
celt/x86/vq_sse.h
103116
celt/x86/vq_sse2.c
117+
celt/x86/x86_arch_macros.h
104118
celt/x86/x86cpu.c
105119
celt/x86/x86cpu.h
106120
celt/x86/x86_celt_map.c
@@ -243,4 +257,13 @@ add_library(
243257
silk/x86/x86_silk_map.c
244258
)
245259

260+
if("${TIM41_X86_SIMD_LEVEL}" MATCHES "^(AVX2|AVX512)$" OR MSVC)
261+
target_sources(
262+
opus
263+
PRIVATE
264+
silk/float/x86/inner_product_FLP_avx2.c
265+
silk/x86/NSQ_del_dec_avx2.c
266+
)
267+
endif()
268+
246269
install(TARGETS opus)

opus/COPYING

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Copyright 2001-2011 Xiph.Org, Skype Limited, Octasic,
1+
Copyright 2001-2023 Xiph.Org, Skype Limited, Octasic,
22
Jean-Marc Valin, Timothy B. Terriberry,
33
CSIRO, Gregory Maxwell, Mark Borgerding,
4-
Erik de Castro Lopo
4+
Erik de Castro Lopo, Mozilla, Amazon
55

66
Redistribution and use in source and binary forms, with or without
77
modification, are permitted provided that the following conditions

opus/README

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This package implements a shared library for encoding and decoding raw Opus
2222
bitstreams. Raw Opus bitstreams should be used over RTP according to
2323
https://tools.ietf.org/html/rfc7587
2424

25-
The package also includes a number of test tools used for testing the
25+
The package also includes a number of test tools used for testing the
2626
correct operation of the library. The bitstreams read/written by these
2727
tools should not be used for Opus file distribution: They include
2828
additional debugging data and cannot support seeking.
@@ -35,10 +35,32 @@ An opus-tools package is available which provides encoding and decoding of
3535
Ogg encapsulated Opus files and includes a number of useful features.
3636

3737
Opus-tools can be found at:
38-
https://git.xiph.org/?p=opus-tools.git
38+
https://gitlab.xiph.org/xiph/opus-tools.git
3939
or on the main Opus website:
4040
https://opus-codec.org/
4141

42+
== Deep Learning and Opus ==
43+
44+
Lossy networks continue to be a challenge for real-time communications.
45+
While the original implementation of Opus provides an excellent packet loss
46+
concealment mechanism, the team has continued to advance the methodology used
47+
to improve audio quality in challenge network environments.
48+
49+
In Opus 1.5, we added a deep learning based redundancy encoder that enhances
50+
audio in lossy networks by embedding one second of recovery data in the padding
51+
data of each packet. The underlying algorithm behind encoding and decoding the
52+
recovery data is called the deep redundancy (DRED) algorithm. By leveraging
53+
the padding data within the packet, Opus 1.5 is fully backward compatible with
54+
prior revisions of Opus. Please see the README under the "dnn" subdirectory to
55+
understand DRED.
56+
57+
DRED was developed by a team that Amazon Web Services initially sponsored,
58+
who open-sourced the implementation as well as began the
59+
standardization process at the IETF:
60+
https://datatracker.ietf.org/doc/draft-ietf-mlcodec-opus-extension/
61+
The license behind Opus or the intellectual property position of Opus does
62+
not change with Opus 1.5.
63+
4264
== Compiling libopus ==
4365

4466
To build from a distribution tarball, you only need to do the following:
@@ -68,7 +90,7 @@ On Apple macOS, install Xcode and brew.sh, then in the Terminal enter:
6890

6991
1) Clone the repository:
7092

71-
% git clone https://git.xiph.org/opus.git
93+
% git clone https://gitlab.xiph.org/xiph/opus.git
7294
% cd opus
7395

7496
2) Compiling the source
@@ -77,6 +99,8 @@ On Apple macOS, install Xcode and brew.sh, then in the Terminal enter:
7799
% ./configure
78100
% make
79101

102+
On x86, it's a good idea to use a -march= option that allows the use of AVX2.
103+
80104
3) Install the codec libraries (optional)
81105

82106
% sudo make install
@@ -133,6 +157,10 @@ To run compare the code to these test vectors:
133157
% tar -zxf opus_testvectors-rfc8251.tar.gz
134158
% ./tests/run_vectors.sh ./ opus_newvectors 48000
135159

160+
== Compiling libopus for Windows and alternative build systems ==
161+
162+
See cmake/README.md or meson/README.md.
163+
136164
== Portability notes ==
137165

138166
This implementation uses floating-point by default but can be compiled to

opus/celt/arch.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ __attribute__((noreturn))
7373
void celt_fatal(const char *str, const char *file, int line)
7474
{
7575
fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str);
76+
#if defined(_MSC_VER)
77+
_set_abort_behavior( 0, _WRITE_ABORT_MSG);
78+
#endif
7679
abort();
7780
}
7881
#endif

opus/celt/arm/arm_celt_map.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, c
4040
celt_inner_prod_c, /* ARMv4 */
4141
celt_inner_prod_c, /* EDSP */
4242
celt_inner_prod_c, /* Media */
43-
celt_inner_prod_neon /* NEON */
43+
celt_inner_prod_neon,/* NEON */
44+
celt_inner_prod_neon /* DOTPROD */
4445
};
4546

4647
void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02,
4748
int N, opus_val32 *xy1, opus_val32 *xy2) = {
4849
dual_inner_prod_c, /* ARMv4 */
4950
dual_inner_prod_c, /* EDSP */
5051
dual_inner_prod_c, /* Media */
51-
dual_inner_prod_neon /* NEON */
52+
dual_inner_prod_neon,/* NEON */
53+
dual_inner_prod_neon /* DOTPROD */
5254
};
5355
# endif
5456

@@ -61,7 +63,8 @@ opus_val32 (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
6163
celt_pitch_xcorr_c, /* ARMv4 */
6264
MAY_HAVE_EDSP(celt_pitch_xcorr), /* EDSP */
6365
MAY_HAVE_MEDIA(celt_pitch_xcorr), /* Media */
64-
MAY_HAVE_NEON(celt_pitch_xcorr) /* NEON */
66+
MAY_HAVE_NEON(celt_pitch_xcorr), /* NEON */
67+
MAY_HAVE_NEON(celt_pitch_xcorr) /* DOTPROD */
6568
};
6669

6770
# endif
@@ -72,7 +75,8 @@ void (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
7275
celt_pitch_xcorr_c, /* ARMv4 */
7376
celt_pitch_xcorr_c, /* EDSP */
7477
celt_pitch_xcorr_c, /* Media */
75-
celt_pitch_xcorr_float_neon /* Neon */
78+
celt_pitch_xcorr_float_neon, /* Neon */
79+
celt_pitch_xcorr_float_neon /* DOTPROD */
7680
};
7781
# endif
7882
# endif /* FIXED_POINT */
@@ -90,6 +94,7 @@ void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])(
9094
xcorr_kernel_c, /* EDSP */
9195
xcorr_kernel_c, /* Media */
9296
xcorr_kernel_neon_fixed, /* Neon */
97+
xcorr_kernel_neon_fixed /* DOTPROD */
9398
};
9499

95100
#endif
@@ -101,14 +106,16 @@ int (*const OPUS_FFT_ALLOC_ARCH_IMPL[OPUS_ARCHMASK+1])(kiss_fft_state *st) = {
101106
opus_fft_alloc_arch_c, /* ARMv4 */
102107
opus_fft_alloc_arch_c, /* EDSP */
103108
opus_fft_alloc_arch_c, /* Media */
104-
opus_fft_alloc_arm_neon /* Neon with NE10 library support */
109+
opus_fft_alloc_arm_neon, /* Neon with NE10 library support */
110+
opus_fft_alloc_arm_neon /* DOTPROD with NE10 library support */
105111
};
106112

107113
void (*const OPUS_FFT_FREE_ARCH_IMPL[OPUS_ARCHMASK+1])(kiss_fft_state *st) = {
108114
opus_fft_free_arch_c, /* ARMv4 */
109115
opus_fft_free_arch_c, /* EDSP */
110116
opus_fft_free_arch_c, /* Media */
111-
opus_fft_free_arm_neon /* Neon with NE10 */
117+
opus_fft_free_arm_neon, /* Neon with NE10 */
118+
opus_fft_free_arm_neon /* DOTPROD with NE10 */
112119
};
113120
# endif /* CUSTOM_MODES */
114121

@@ -118,7 +125,8 @@ void (*const OPUS_FFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg,
118125
opus_fft_c, /* ARMv4 */
119126
opus_fft_c, /* EDSP */
120127
opus_fft_c, /* Media */
121-
opus_fft_neon /* Neon with NE10 */
128+
opus_fft_neon, /* Neon with NE10 */
129+
opus_fft_neon /* DOTPROD with NE10 */
122130
};
123131

124132
void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg,
@@ -127,7 +135,8 @@ void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg,
127135
opus_ifft_c, /* ARMv4 */
128136
opus_ifft_c, /* EDSP */
129137
opus_ifft_c, /* Media */
130-
opus_ifft_neon /* Neon with NE10 */
138+
opus_ifft_neon, /* Neon with NE10 */
139+
opus_ifft_neon /* DOTPROD with NE10 */
131140
};
132141

133142
void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
@@ -139,7 +148,8 @@ void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
139148
clt_mdct_forward_c, /* ARMv4 */
140149
clt_mdct_forward_c, /* EDSP */
141150
clt_mdct_forward_c, /* Media */
142-
clt_mdct_forward_neon /* Neon with NE10 */
151+
clt_mdct_forward_neon, /* Neon with NE10 */
152+
clt_mdct_forward_neon /* DOTPROD with NE10 */
143153
};
144154

145155
void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
@@ -151,7 +161,8 @@ void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
151161
clt_mdct_backward_c, /* ARMv4 */
152162
clt_mdct_backward_c, /* EDSP */
153163
clt_mdct_backward_c, /* Media */
154-
clt_mdct_backward_neon /* Neon with NE10 */
164+
clt_mdct_backward_neon, /* Neon with NE10 */
165+
clt_mdct_backward_neon /* DOTPROD with NE10 */
155166
};
156167

157168
# endif /* HAVE_ARM_NE10 */

opus/celt/arm/armcpu.c

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#define OPUS_CPU_ARM_EDSP_FLAG (1<<OPUS_ARCH_ARM_EDSP)
4444
#define OPUS_CPU_ARM_MEDIA_FLAG (1<<OPUS_ARCH_ARM_MEDIA)
4545
#define OPUS_CPU_ARM_NEON_FLAG (1<<OPUS_ARCH_ARM_NEON)
46+
#define OPUS_CPU_ARM_DOTPROD_FLAG (1<<OPUS_ARCH_ARM_DOTPROD)
4647

4748
#if defined(_MSC_VER)
4849
/*For GetExceptionCode() and EXCEPTION_ILLEGAL_INSTRUCTION.*/
@@ -93,6 +94,8 @@ static OPUS_INLINE opus_uint32 opus_cpu_capabilities(void){
9394

9495
#elif defined(__linux__)
9596
/* Linux based */
97+
#include <stdio.h>
98+
9699
opus_uint32 opus_cpu_capabilities(void)
97100
{
98101
opus_uint32 flags = 0;
@@ -124,6 +127,14 @@ opus_uint32 opus_cpu_capabilities(void)
124127
p = strstr(buf, " neon");
125128
if(p != NULL && (p[5] == ' ' || p[5] == '\n'))
126129
flags |= OPUS_CPU_ARM_NEON_FLAG;
130+
p = strstr(buf, " asimd");
131+
if(p != NULL && (p[6] == ' ' || p[6] == '\n'))
132+
flags |= OPUS_CPU_ARM_NEON_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_EDSP_FLAG;
133+
# endif
134+
# if defined(OPUS_ARM_MAY_HAVE_DOTPROD)
135+
p = strstr(buf, " asimddp");
136+
if(p != NULL && (p[8] == ' ' || p[8] == '\n'))
137+
flags |= OPUS_CPU_ARM_DOTPROD_FLAG;
127138
# endif
128139
}
129140
# endif
@@ -142,10 +153,44 @@ opus_uint32 opus_cpu_capabilities(void)
142153
# endif
143154
}
144155

156+
#if defined(OPUS_ARM_PRESUME_AARCH64_NEON_INTR)
157+
flags |= OPUS_CPU_ARM_EDSP_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_NEON_FLAG;
158+
# if defined(OPUS_ARM_PRESUME_DOTPROD)
159+
flags |= OPUS_CPU_ARM_DOTPROD_FLAG;
160+
# endif
161+
#endif
162+
145163
fclose(cpuinfo);
146164
}
147165
return flags;
148166
}
167+
168+
#elif defined(__APPLE__)
169+
#include <sys/types.h>
170+
#include <sys/sysctl.h>
171+
172+
opus_uint32 opus_cpu_capabilities(void)
173+
{
174+
opus_uint32 flags = 0;
175+
176+
#if defined(OPUS_ARM_MAY_HAVE_DOTPROD)
177+
size_t size = sizeof(uint32_t);
178+
uint32_t value = 0;
179+
if (!sysctlbyname("hw.optional.arm.FEAT_DotProd", &value, &size, NULL, 0) && value)
180+
{
181+
flags |= OPUS_CPU_ARM_DOTPROD_FLAG;
182+
}
183+
#endif
184+
185+
#if defined(OPUS_ARM_PRESUME_AARCH64_NEON_INTR)
186+
flags |= OPUS_CPU_ARM_EDSP_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_NEON_FLAG;
187+
# if defined(OPUS_ARM_PRESUME_DOTPROD)
188+
flags |= OPUS_CPU_ARM_DOTPROD_FLAG;
189+
# endif
190+
#endif
191+
return flags;
192+
}
193+
149194
#else
150195
/* The feature registers which can tell us what the processor supports are
151196
* accessible in priveleged modes only, so we can't have a general user-space
@@ -154,7 +199,7 @@ opus_uint32 opus_cpu_capabilities(void)
154199
"your platform. Reconfigure with --disable-rtcd (or send patches)."
155200
#endif
156201

157-
int opus_select_arch(void)
202+
static int opus_select_arch_impl(void)
158203
{
159204
opus_uint32 flags = opus_cpu_capabilities();
160205
int arch = 0;
@@ -178,8 +223,21 @@ int opus_select_arch(void)
178223
}
179224
arch++;
180225

181-
celt_assert(arch == OPUS_ARCH_ARM_NEON);
226+
if(!(flags & OPUS_CPU_ARM_DOTPROD_FLAG)) {
227+
celt_assert(arch == OPUS_ARCH_ARM_NEON);
228+
return arch;
229+
}
230+
arch++;
231+
232+
celt_assert(arch == OPUS_ARCH_ARM_DOTPROD);
182233
return arch;
183234
}
184235

236+
int opus_select_arch(void) {
237+
int arch = opus_select_arch_impl();
238+
#ifdef FUZZING
239+
arch = rand()%(arch+1);
240+
#endif
241+
return arch;
242+
}
185243
#endif

0 commit comments

Comments
 (0)