diff options
author | William Wilgus <me.theuser@yahoo.com> | 2019-01-04 02:01:18 -0600 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2021-04-23 14:23:04 +0000 |
commit | 14c6bb798d6bebc80f07e863236adbaf8d156a9c (patch) | |
tree | 551a4b641906c2626af844fa3239c1b2b1ff0ad3 /lib/rbcodec/codecs/libopus/celt/celt.c | |
parent | 75d93937965ec4df70d37df6d4feea04577c996b (diff) | |
download | rockbox-14c6bb798d6bebc80f07e863236adbaf8d156a9c.tar.gz rockbox-14c6bb798d6bebc80f07e863236adbaf8d156a9c.zip |
Sync opus codec to upstream git
Change-Id: I0cfcc0005c4ad7bfbb1aaf454188ce70fb043dc1
Diffstat (limited to 'lib/rbcodec/codecs/libopus/celt/celt.c')
-rw-r--r-- | lib/rbcodec/codecs/libopus/celt/celt.c | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/celt.c b/lib/rbcodec/codecs/libopus/celt/celt.c index c0a1e0dab9..9ce234695c 100644 --- a/lib/rbcodec/codecs/libopus/celt/celt.c +++ b/lib/rbcodec/codecs/libopus/celt/celt.c | |||
@@ -89,10 +89,13 @@ int resampling_factor(opus_int32 rate) | |||
89 | return ret; | 89 | return ret; |
90 | } | 90 | } |
91 | 91 | ||
92 | #ifndef OVERRIDE_COMB_FILTER_CONST | 92 | #if !defined(OVERRIDE_COMB_FILTER_CONST) || defined(NON_STATIC_COMB_FILTER_CONST_C) |
93 | /* This version should be faster on ARM */ | 93 | /* This version should be faster on ARM */ |
94 | #ifdef OPUS_ARM_ASM | 94 | #ifdef OPUS_ARM_ASM |
95 | static void comb_filter_const(opus_val32 *y, opus_val32 *x, int T, int N, | 95 | #ifndef NON_STATIC_COMB_FILTER_CONST_C |
96 | static | ||
97 | #endif | ||
98 | void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N, | ||
96 | opus_val16 g10, opus_val16 g11, opus_val16 g12) | 99 | opus_val16 g10, opus_val16 g11, opus_val16 g12) |
97 | { | 100 | { |
98 | opus_val32 x0, x1, x2, x3, x4; | 101 | opus_val32 x0, x1, x2, x3, x4; |
@@ -108,26 +111,31 @@ static void comb_filter_const(opus_val32 *y, opus_val32 *x, int T, int N, | |||
108 | t = MAC16_32_Q16(x[i], g10, x2); | 111 | t = MAC16_32_Q16(x[i], g10, x2); |
109 | t = MAC16_32_Q16(t, g11, ADD32(x1,x3)); | 112 | t = MAC16_32_Q16(t, g11, ADD32(x1,x3)); |
110 | t = MAC16_32_Q16(t, g12, ADD32(x0,x4)); | 113 | t = MAC16_32_Q16(t, g12, ADD32(x0,x4)); |
114 | t = SATURATE(t, SIG_SAT); | ||
111 | y[i] = t; | 115 | y[i] = t; |
112 | x4=SHL32(x[i-T+3],1); | 116 | x4=SHL32(x[i-T+3],1); |
113 | t = MAC16_32_Q16(x[i+1], g10, x1); | 117 | t = MAC16_32_Q16(x[i+1], g10, x1); |
114 | t = MAC16_32_Q16(t, g11, ADD32(x0,x2)); | 118 | t = MAC16_32_Q16(t, g11, ADD32(x0,x2)); |
115 | t = MAC16_32_Q16(t, g12, ADD32(x4,x3)); | 119 | t = MAC16_32_Q16(t, g12, ADD32(x4,x3)); |
120 | t = SATURATE(t, SIG_SAT); | ||
116 | y[i+1] = t; | 121 | y[i+1] = t; |
117 | x3=SHL32(x[i-T+4],1); | 122 | x3=SHL32(x[i-T+4],1); |
118 | t = MAC16_32_Q16(x[i+2], g10, x0); | 123 | t = MAC16_32_Q16(x[i+2], g10, x0); |
119 | t = MAC16_32_Q16(t, g11, ADD32(x4,x1)); | 124 | t = MAC16_32_Q16(t, g11, ADD32(x4,x1)); |
120 | t = MAC16_32_Q16(t, g12, ADD32(x3,x2)); | 125 | t = MAC16_32_Q16(t, g12, ADD32(x3,x2)); |
126 | t = SATURATE(t, SIG_SAT); | ||
121 | y[i+2] = t; | 127 | y[i+2] = t; |
122 | x2=SHL32(x[i-T+5],1); | 128 | x2=SHL32(x[i-T+5],1); |
123 | t = MAC16_32_Q16(x[i+3], g10, x4); | 129 | t = MAC16_32_Q16(x[i+3], g10, x4); |
124 | t = MAC16_32_Q16(t, g11, ADD32(x3,x0)); | 130 | t = MAC16_32_Q16(t, g11, ADD32(x3,x0)); |
125 | t = MAC16_32_Q16(t, g12, ADD32(x2,x1)); | 131 | t = MAC16_32_Q16(t, g12, ADD32(x2,x1)); |
132 | t = SATURATE(t, SIG_SAT); | ||
126 | y[i+3] = t; | 133 | y[i+3] = t; |
127 | x1=SHL32(x[i-T+6],1); | 134 | x1=SHL32(x[i-T+6],1); |
128 | t = MAC16_32_Q16(x[i+4], g10, x3); | 135 | t = MAC16_32_Q16(x[i+4], g10, x3); |
129 | t = MAC16_32_Q16(t, g11, ADD32(x2,x4)); | 136 | t = MAC16_32_Q16(t, g11, ADD32(x2,x4)); |
130 | t = MAC16_32_Q16(t, g12, ADD32(x1,x0)); | 137 | t = MAC16_32_Q16(t, g12, ADD32(x1,x0)); |
138 | t = SATURATE(t, SIG_SAT); | ||
131 | y[i+4] = t; | 139 | y[i+4] = t; |
132 | } | 140 | } |
133 | #ifdef CUSTOM_MODES | 141 | #ifdef CUSTOM_MODES |
@@ -138,6 +146,7 @@ static void comb_filter_const(opus_val32 *y, opus_val32 *x, int T, int N, | |||
138 | t = MAC16_32_Q16(x[i], g10, x2); | 146 | t = MAC16_32_Q16(x[i], g10, x2); |
139 | t = MAC16_32_Q16(t, g11, ADD32(x1,x3)); | 147 | t = MAC16_32_Q16(t, g11, ADD32(x1,x3)); |
140 | t = MAC16_32_Q16(t, g12, ADD32(x0,x4)); | 148 | t = MAC16_32_Q16(t, g12, ADD32(x0,x4)); |
149 | t = SATURATE(t, SIG_SAT); | ||
141 | y[i] = t; | 150 | y[i] = t; |
142 | x4=x3; | 151 | x4=x3; |
143 | x3=x2; | 152 | x3=x2; |
@@ -147,7 +156,10 @@ static void comb_filter_const(opus_val32 *y, opus_val32 *x, int T, int N, | |||
147 | #endif | 156 | #endif |
148 | } | 157 | } |
149 | #else | 158 | #else |
150 | static void comb_filter_const(opus_val32 *y, opus_val32 *x, int T, int N, | 159 | #ifndef NON_STATIC_COMB_FILTER_CONST_C |
160 | static | ||
161 | #endif | ||
162 | void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N, | ||
151 | opus_val16 g10, opus_val16 g11, opus_val16 g12) | 163 | opus_val16 g10, opus_val16 g11, opus_val16 g12) |
152 | { | 164 | { |
153 | opus_val32 x0, x1, x2, x3, x4; | 165 | opus_val32 x0, x1, x2, x3, x4; |
@@ -163,6 +175,7 @@ static void comb_filter_const(opus_val32 *y, opus_val32 *x, int T, int N, | |||
163 | + MULT16_32_Q15(g10,x2) | 175 | + MULT16_32_Q15(g10,x2) |
164 | + MULT16_32_Q15(g11,ADD32(x1,x3)) | 176 | + MULT16_32_Q15(g11,ADD32(x1,x3)) |
165 | + MULT16_32_Q15(g12,ADD32(x0,x4)); | 177 | + MULT16_32_Q15(g12,ADD32(x0,x4)); |
178 | y[i] = SATURATE(y[i], SIG_SAT); | ||
166 | x4=x3; | 179 | x4=x3; |
167 | x3=x2; | 180 | x3=x2; |
168 | x2=x1; | 181 | x2=x1; |
@@ -176,7 +189,7 @@ static void comb_filter_const(opus_val32 *y, opus_val32 *x, int T, int N, | |||
176 | #ifndef OVERRIDE_comb_filter | 189 | #ifndef OVERRIDE_comb_filter |
177 | void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, | 190 | void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, |
178 | opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, | 191 | opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, |
179 | const opus_val16 *window, int overlap) | 192 | const opus_val16 *window, int overlap, int arch) |
180 | { | 193 | { |
181 | int i; | 194 | int i; |
182 | /* printf ("%d %d %f %f\n", T0, T1, g0, g1); */ | 195 | /* printf ("%d %d %f %f\n", T0, T1, g0, g1); */ |
@@ -194,6 +207,10 @@ void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, | |||
194 | OPUS_MOVE(y, x, N); | 207 | OPUS_MOVE(y, x, N); |
195 | return; | 208 | return; |
196 | } | 209 | } |
210 | /* When the gain is zero, T0 and/or T1 is set to zero. We need | ||
211 | to have then be at least 2 to avoid processing garbage data. */ | ||
212 | T0 = IMAX(T0, COMBFILTER_MINPERIOD); | ||
213 | T1 = IMAX(T1, COMBFILTER_MINPERIOD); | ||
197 | g00 = MULT16_16_P15(g0, gains[tapset0][0]); | 214 | g00 = MULT16_16_P15(g0, gains[tapset0][0]); |
198 | g01 = MULT16_16_P15(g0, gains[tapset0][1]); | 215 | g01 = MULT16_16_P15(g0, gains[tapset0][1]); |
199 | g02 = MULT16_16_P15(g0, gains[tapset0][2]); | 216 | g02 = MULT16_16_P15(g0, gains[tapset0][2]); |
@@ -219,6 +236,7 @@ void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, | |||
219 | + MULT16_32_Q15(MULT16_16_Q15(f,g10),x2) | 236 | + MULT16_32_Q15(MULT16_16_Q15(f,g10),x2) |
220 | + MULT16_32_Q15(MULT16_16_Q15(f,g11),ADD32(x1,x3)) | 237 | + MULT16_32_Q15(MULT16_16_Q15(f,g11),ADD32(x1,x3)) |
221 | + MULT16_32_Q15(MULT16_16_Q15(f,g12),ADD32(x0,x4)); | 238 | + MULT16_32_Q15(MULT16_16_Q15(f,g12),ADD32(x0,x4)); |
239 | y[i] = SATURATE(y[i], SIG_SAT); | ||
222 | x4=x3; | 240 | x4=x3; |
223 | x3=x2; | 241 | x3=x2; |
224 | x2=x1; | 242 | x2=x1; |
@@ -234,15 +252,20 @@ void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, | |||
234 | } | 252 | } |
235 | 253 | ||
236 | /* Compute the part with the constant filter. */ | 254 | /* Compute the part with the constant filter. */ |
237 | comb_filter_const(y+i, x+i, T1, N-i, g10, g11, g12); | 255 | comb_filter_const(y+i, x+i, T1, N-i, g10, g11, g12, arch); |
238 | } | 256 | } |
239 | #endif /* OVERRIDE_comb_filter */ | 257 | #endif /* OVERRIDE_comb_filter */ |
240 | 258 | ||
259 | /* TF change table. Positive values mean better frequency resolution (longer | ||
260 | effective window), whereas negative values mean better time resolution | ||
261 | (shorter effective window). The second index is computed as: | ||
262 | 4*isTransient + 2*tf_select + per_band_flag */ | ||
241 | const signed char tf_select_table[4][8] = { | 263 | const signed char tf_select_table[4][8] = { |
242 | {0, -1, 0, -1, 0,-1, 0,-1}, | 264 | /*isTransient=0 isTransient=1 */ |
243 | {0, -1, 0, -2, 1, 0, 1,-1}, | 265 | {0, -1, 0, -1, 0,-1, 0,-1}, /* 2.5 ms */ |
244 | {0, -2, 0, -3, 2, 0, 1,-1}, | 266 | {0, -1, 0, -2, 1, 0, 1,-1}, /* 5 ms */ |
245 | {0, -2, 0, -3, 3, 0, 1,-1}, | 267 | {0, -2, 0, -3, 2, 0, 1,-1}, /* 10 ms */ |
268 | {0, -2, 0, -3, 3, 0, 1,-1}, /* 20 ms */ | ||
246 | }; | 269 | }; |
247 | 270 | ||
248 | 271 | ||
@@ -280,6 +303,9 @@ const char *opus_strerror(int error) | |||
280 | const char *opus_get_version_string(void) | 303 | const char *opus_get_version_string(void) |
281 | { | 304 | { |
282 | return "libopus " PACKAGE_VERSION | 305 | return "libopus " PACKAGE_VERSION |
306 | /* Applications may rely on the presence of this substring in the version | ||
307 | string to determine if they have a fixed-point or floating-point build | ||
308 | at runtime. */ | ||
283 | #ifdef FIXED_POINT | 309 | #ifdef FIXED_POINT |
284 | "-fixed" | 310 | "-fixed" |
285 | #endif | 311 | #endif |