Skip to content

Commit 92f1fb8

Browse files
committed
Add OPUS audio codec support
1 parent 08dd8df commit 92f1fb8

File tree

233 files changed

+52406
-120
lines changed

Some content is hidden

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

233 files changed

+52406
-120
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
**/.gradle
33
.idea
44
*.iml
5+
*.bat
56
**/msvc/Debug*
67
**/msvc/Release*
8+
**/msvc/.vs
9+
**/msvc/*.db
10+
**/msvc/*.opendb
711
**/msvc/*.sdf
812
**/msvc/*.opensdf
913
**/msvc/*.user
1014
**/msvc/*.suo
15+
**/msvc/*.db
16+
**/msvc/*.opendb
1117
**/msvc/*.aps
1218
**/msvc/ipch
1319
**/PublishPath*.txt

dep/opus/build.gradle

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import org.doomedsociety.gradlecpp.cfg.ToolchainConfig
2+
import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils
3+
import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig
4+
import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig
5+
import org.doomedsociety.gradlecpp.toolchain.icc.Icc
6+
import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin
7+
import org.gradle.nativeplatform.NativeBinarySpec
8+
import org.gradle.nativeplatform.NativeLibrarySpec
9+
import org.gradle.nativeplatform.toolchain.VisualCpp
10+
11+
apply plugin: 'cpp'
12+
apply plugin: IccCompilerPlugin
13+
14+
void setupToolchain(NativeBinarySpec b) {
15+
ToolchainConfig cfg = rootProject.createToolchainConfig(b)
16+
17+
cfg.projectInclude(project, '', '/src', '/include', '/celt', '/celt/x86', '/silk', '/silk/float')
18+
cfg.singleDefines('OPUS_BUILD', 'USE_ALLOCA');
19+
20+
if (cfg instanceof MsvcToolchainConfig) {
21+
cfg.compilerOptions.args '/Ob2', '/Oi', '/GF', '/GR-'
22+
} else if (cfg instanceof GccToolchainConfig) {
23+
cfg.compilerOptions.languageStandard = 'c++0x'
24+
cfg.compilerOptions.args '-msse2', '-fp-model fast=2', '-fomit-frame-pointer', '-fvisibility=hidden', '-fvisibility-inlines-hidden', '-fno-rtti', '-g0', '-s'
25+
}
26+
27+
ToolchainConfigUtils.apply(project, cfg, b)
28+
}
29+
30+
model {
31+
buildTypes {
32+
debug
33+
release
34+
}
35+
36+
platforms {
37+
x86 {
38+
architecture "x86"
39+
}
40+
}
41+
42+
toolChains {
43+
visualCpp(VisualCpp) {
44+
}
45+
icc(Icc) {
46+
}
47+
}
48+
49+
components {
50+
opus(NativeLibrarySpec) {
51+
targetPlatform 'x86'
52+
53+
sources {
54+
opus_src(CppSourceSet) {
55+
source {
56+
srcDirs "src", "silk", "celt"
57+
include "**/*.c"
58+
}
59+
60+
exportedHeaders {
61+
srcDirs "celt", "silk", "include"
62+
}
63+
}
64+
}
65+
66+
binaries.all { NativeBinarySpec b ->
67+
project.setupToolchain(b)
68+
}
69+
}
70+
}
71+
}

dep/opus/celt/_kiss_fft_guts.h

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
/*Copyright (c) 2003-2004, Mark Borgerding
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice,
9+
this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the
12+
documentation and/or other materials provided with the distribution.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24+
POSSIBILITY OF SUCH DAMAGE.*/
25+
26+
#ifndef KISS_FFT_GUTS_H
27+
#define KISS_FFT_GUTS_H
28+
29+
#define MIN(a,b) ((a)<(b) ? (a):(b))
30+
#define MAX(a,b) ((a)>(b) ? (a):(b))
31+
32+
/* kiss_fft.h
33+
defines kiss_fft_scalar as either short or a float type
34+
and defines
35+
typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */
36+
#include "kiss_fft.h"
37+
38+
/*
39+
Explanation of macros dealing with complex math:
40+
41+
C_MUL(m,a,b) : m = a*b
42+
C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise
43+
C_SUB( res, a,b) : res = a - b
44+
C_SUBFROM( res , a) : res -= a
45+
C_ADDTO( res , a) : res += a
46+
* */
47+
#ifdef FIXED_POINT
48+
#include "arch.h"
49+
50+
51+
#define SAMP_MAX 2147483647
52+
#define TWID_MAX 32767
53+
#define TRIG_UPSCALE 1
54+
55+
#define SAMP_MIN -SAMP_MAX
56+
57+
58+
# define S_MUL(a,b) MULT16_32_Q15(b, a)
59+
60+
# define C_MUL(m,a,b) \
61+
do{ (m).r = SUB32(S_MUL((a).r,(b).r) , S_MUL((a).i,(b).i)); \
62+
(m).i = ADD32(S_MUL((a).r,(b).i) , S_MUL((a).i,(b).r)); }while(0)
63+
64+
# define C_MULC(m,a,b) \
65+
do{ (m).r = ADD32(S_MUL((a).r,(b).r) , S_MUL((a).i,(b).i)); \
66+
(m).i = SUB32(S_MUL((a).i,(b).r) , S_MUL((a).r,(b).i)); }while(0)
67+
68+
# define C_MULBYSCALAR( c, s ) \
69+
do{ (c).r = S_MUL( (c).r , s ) ;\
70+
(c).i = S_MUL( (c).i , s ) ; }while(0)
71+
72+
# define DIVSCALAR(x,k) \
73+
(x) = S_MUL( x, (TWID_MAX-((k)>>1))/(k)+1 )
74+
75+
# define C_FIXDIV(c,div) \
76+
do { DIVSCALAR( (c).r , div); \
77+
DIVSCALAR( (c).i , div); }while (0)
78+
79+
#define C_ADD( res, a,b)\
80+
do {(res).r=ADD32((a).r,(b).r); (res).i=ADD32((a).i,(b).i); \
81+
}while(0)
82+
#define C_SUB( res, a,b)\
83+
do {(res).r=SUB32((a).r,(b).r); (res).i=SUB32((a).i,(b).i); \
84+
}while(0)
85+
#define C_ADDTO( res , a)\
86+
do {(res).r = ADD32((res).r, (a).r); (res).i = ADD32((res).i,(a).i);\
87+
}while(0)
88+
89+
#define C_SUBFROM( res , a)\
90+
do {(res).r = ADD32((res).r,(a).r); (res).i = SUB32((res).i,(a).i); \
91+
}while(0)
92+
93+
#if defined(OPUS_ARM_INLINE_ASM)
94+
#include "arm/kiss_fft_armv4.h"
95+
#endif
96+
97+
#if defined(OPUS_ARM_INLINE_EDSP)
98+
#include "arm/kiss_fft_armv5e.h"
99+
#endif
100+
#if defined(MIPSr1_ASM)
101+
#include "mips/kiss_fft_mipsr1.h"
102+
#endif
103+
104+
#else /* not FIXED_POINT*/
105+
106+
# define S_MUL(a,b) ( (a)*(b) )
107+
#define C_MUL(m,a,b) \
108+
do{ (m).r = (a).r*(b).r - (a).i*(b).i;\
109+
(m).i = (a).r*(b).i + (a).i*(b).r; }while(0)
110+
#define C_MULC(m,a,b) \
111+
do{ (m).r = (a).r*(b).r + (a).i*(b).i;\
112+
(m).i = (a).i*(b).r - (a).r*(b).i; }while(0)
113+
114+
#define C_MUL4(m,a,b) C_MUL(m,a,b)
115+
116+
# define C_FIXDIV(c,div) /* NOOP */
117+
# define C_MULBYSCALAR( c, s ) \
118+
do{ (c).r *= (s);\
119+
(c).i *= (s); }while(0)
120+
#endif
121+
122+
#ifndef CHECK_OVERFLOW_OP
123+
# define CHECK_OVERFLOW_OP(a,op,b) /* noop */
124+
#endif
125+
126+
#ifndef C_ADD
127+
#define C_ADD( res, a,b)\
128+
do { \
129+
CHECK_OVERFLOW_OP((a).r,+,(b).r)\
130+
CHECK_OVERFLOW_OP((a).i,+,(b).i)\
131+
(res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \
132+
}while(0)
133+
#define C_SUB( res, a,b)\
134+
do { \
135+
CHECK_OVERFLOW_OP((a).r,-,(b).r)\
136+
CHECK_OVERFLOW_OP((a).i,-,(b).i)\
137+
(res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \
138+
}while(0)
139+
#define C_ADDTO( res , a)\
140+
do { \
141+
CHECK_OVERFLOW_OP((res).r,+,(a).r)\
142+
CHECK_OVERFLOW_OP((res).i,+,(a).i)\
143+
(res).r += (a).r; (res).i += (a).i;\
144+
}while(0)
145+
146+
#define C_SUBFROM( res , a)\
147+
do {\
148+
CHECK_OVERFLOW_OP((res).r,-,(a).r)\
149+
CHECK_OVERFLOW_OP((res).i,-,(a).i)\
150+
(res).r -= (a).r; (res).i -= (a).i; \
151+
}while(0)
152+
#endif /* C_ADD defined */
153+
154+
#ifdef FIXED_POINT
155+
/*# define KISS_FFT_COS(phase) TRIG_UPSCALE*floor(MIN(32767,MAX(-32767,.5+32768 * cos (phase))))
156+
# define KISS_FFT_SIN(phase) TRIG_UPSCALE*floor(MIN(32767,MAX(-32767,.5+32768 * sin (phase))))*/
157+
# define KISS_FFT_COS(phase) floor(.5+TWID_MAX*cos (phase))
158+
# define KISS_FFT_SIN(phase) floor(.5+TWID_MAX*sin (phase))
159+
# define HALF_OF(x) ((x)>>1)
160+
#elif defined(USE_SIMD)
161+
# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) )
162+
# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) )
163+
# define HALF_OF(x) ((x)*_mm_set1_ps(.5f))
164+
#else
165+
# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase)
166+
# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase)
167+
# define HALF_OF(x) ((x)*.5f)
168+
#endif
169+
170+
#define kf_cexp(x,phase) \
171+
do{ \
172+
(x)->r = KISS_FFT_COS(phase);\
173+
(x)->i = KISS_FFT_SIN(phase);\
174+
}while(0)
175+
176+
#define kf_cexp2(x,phase) \
177+
do{ \
178+
(x)->r = TRIG_UPSCALE*celt_cos_norm((phase));\
179+
(x)->i = TRIG_UPSCALE*celt_cos_norm((phase)-32768);\
180+
}while(0)
181+
182+
#endif /* KISS_FFT_GUTS_H */

0 commit comments

Comments
 (0)