summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libopus/celt
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2013-12-11 22:59:14 +0100
committerNils Wallménius <nils@rockbox.org>2013-12-16 21:13:23 +0100
commite3c2ed7a71f65dc721c7210f120259ecd4ff65cb (patch)
treede593c1e927dcc036f1b6656f1f881995491b3b9 /lib/rbcodec/codecs/libopus/celt
parentd0918b98fa0cfba21208a4fb5ed153687b8f02c3 (diff)
downloadrockbox-e3c2ed7a71f65dc721c7210f120259ecd4ff65cb.tar.gz
rockbox-e3c2ed7a71f65dc721c7210f120259ecd4ff65cb.zip
Sync libopus to upstream release 1.1
Change-Id: I9fea7460fc33f60faff961b3389dd97b5191463c
Diffstat (limited to 'lib/rbcodec/codecs/libopus/celt')
-rw-r--r--lib/rbcodec/codecs/libopus/celt/_kiss_fft_guts.h6
-rw-r--r--lib/rbcodec/codecs/libopus/celt/arch.h10
-rw-r--r--lib/rbcodec/codecs/libopus/celt/arm/fixed_armv4.h4
-rw-r--r--lib/rbcodec/codecs/libopus/celt/arm/fixed_armv5e.h10
-rw-r--r--lib/rbcodec/codecs/libopus/celt/bands.c28
-rw-r--r--lib/rbcodec/codecs/libopus/celt/celt.h31
-rw-r--r--lib/rbcodec/codecs/libopus/celt/celt_decoder.c19
-rw-r--r--lib/rbcodec/codecs/libopus/celt/celt_lpc.c5
-rw-r--r--lib/rbcodec/codecs/libopus/celt/celt_lpc.h3
-rw-r--r--lib/rbcodec/codecs/libopus/celt/cpu_support.h7
-rw-r--r--lib/rbcodec/codecs/libopus/celt/cwrs.c12
-rw-r--r--lib/rbcodec/codecs/libopus/celt/ecintrin.h2
-rw-r--r--lib/rbcodec/codecs/libopus/celt/entcode.h9
-rw-r--r--lib/rbcodec/codecs/libopus/celt/fixed_generic.h3
-rw-r--r--lib/rbcodec/codecs/libopus/celt/float_cast.h4
-rw-r--r--lib/rbcodec/codecs/libopus/celt/mathops.c2
-rw-r--r--lib/rbcodec/codecs/libopus/celt/mathops.h23
-rw-r--r--lib/rbcodec/codecs/libopus/celt/os_support.h9
-rw-r--r--lib/rbcodec/codecs/libopus/celt/pitch.c15
-rw-r--r--lib/rbcodec/codecs/libopus/celt/pitch.h38
-rw-r--r--lib/rbcodec/codecs/libopus/celt/quant_bands.c6
-rw-r--r--lib/rbcodec/codecs/libopus/celt/rate.c2
-rw-r--r--lib/rbcodec/codecs/libopus/celt/rate.h6
-rw-r--r--lib/rbcodec/codecs/libopus/celt/stack_alloc.h9
24 files changed, 168 insertions, 95 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/_kiss_fft_guts.h b/lib/rbcodec/codecs/libopus/celt/_kiss_fft_guts.h
index 866a6520ca..cc52f37c36 100644
--- a/lib/rbcodec/codecs/libopus/celt/_kiss_fft_guts.h
+++ b/lib/rbcodec/codecs/libopus/celt/_kiss_fft_guts.h
@@ -94,15 +94,15 @@
94 do {(res).r = ADD32((res).r,(a).r); (res).i = SUB32((res).i,(a).i); \ 94 do {(res).r = ADD32((res).r,(a).r); (res).i = SUB32((res).i,(a).i); \
95 }while(0) 95 }while(0)
96 96
97#if defined(ARMv4_ASM) 97#if defined(OPUS_ARM_INLINE_ASM)
98#include "arm/kiss_fft_armv4.h" 98#include "arm/kiss_fft_armv4.h"
99#endif 99#endif
100 100
101#if defined(ARMv5E_ASM) 101#if defined(OPUS_ARM_INLINE_EDSP)
102#include "arm/kiss_fft_armv5e.h" 102#include "arm/kiss_fft_armv5e.h"
103#endif 103#endif
104 104
105#if defined(CF_ASM) 105#if defined(OPUS_CF_INLINE_ASM)
106#include "cf/kiss_fft_cf.h" 106#include "cf/kiss_fft_cf.h"
107#endif 107#endif
108 108
diff --git a/lib/rbcodec/codecs/libopus/celt/arch.h b/lib/rbcodec/codecs/libopus/celt/arch.h
index c0f9413d00..b2d26c4ee4 100644
--- a/lib/rbcodec/codecs/libopus/celt/arch.h
+++ b/lib/rbcodec/codecs/libopus/celt/arch.h
@@ -35,6 +35,7 @@
35#define ARCH_H 35#define ARCH_H
36 36
37#include "opus_types.h" 37#include "opus_types.h"
38#include "opus_defines.h"
38 39
39# if !defined(__GNUC_PREREQ) 40# if !defined(__GNUC_PREREQ)
40# if defined(__GNUC__)&&defined(__GNUC_MINOR__) 41# if defined(__GNUC__)&&defined(__GNUC_MINOR__)
@@ -54,7 +55,7 @@
54#ifdef __GNUC__ 55#ifdef __GNUC__
55__attribute__((noreturn)) 56__attribute__((noreturn))
56#endif 57#endif
57static inline void _celt_fatal(const char *str, const char *file, int line) 58static OPUS_INLINE void _celt_fatal(const char *str, const char *file, int line)
58{ 59{
59 fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str); 60 fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str);
60 abort(); 61 abort();
@@ -113,9 +114,9 @@ typedef opus_val32 celt_ener;
113 114
114#include "fixed_generic.h" 115#include "fixed_generic.h"
115 116
116#ifdef ARMv5E_ASM 117#ifdef OPUS_ARM_INLINE_EDSP
117#include "arm/fixed_armv5e.h" 118#include "arm/fixed_armv5e.h"
118#elif defined (ARMv4_ASM) 119#elif defined (OPUS_ARM_INLINE_ASM)
119#include "arm/fixed_armv4.h" 120#include "arm/fixed_armv4.h"
120#elif defined (BFIN_ASM) 121#elif defined (BFIN_ASM)
121#include "fixed_bfin.h" 122#include "fixed_bfin.h"
@@ -123,7 +124,7 @@ typedef opus_val32 celt_ener;
123#include "fixed_c5x.h" 124#include "fixed_c5x.h"
124#elif defined (TI_C6X_ASM) 125#elif defined (TI_C6X_ASM)
125#include "fixed_c6x.h" 126#include "fixed_c6x.h"
126#elif defined (CF_ASM) 127#elif defined (OPUS_CF_INLINE_ASM)
127#include "cf/fixed_cf.h" 128#include "cf/fixed_cf.h"
128#endif 129#endif
129 130
@@ -187,6 +188,7 @@ typedef float celt_ener;
187#define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) 188#define MAC16_32_Q15(c,a,b) ((c)+(a)*(b))
188 189
189#define MULT16_16_Q11_32(a,b) ((a)*(b)) 190#define MULT16_16_Q11_32(a,b) ((a)*(b))
191#define MULT16_16_Q11(a,b) ((a)*(b))
190#define MULT16_16_Q13(a,b) ((a)*(b)) 192#define MULT16_16_Q13(a,b) ((a)*(b))
191#define MULT16_16_Q14(a,b) ((a)*(b)) 193#define MULT16_16_Q14(a,b) ((a)*(b))
192#define MULT16_16_Q15(a,b) ((a)*(b)) 194#define MULT16_16_Q15(a,b) ((a)*(b))
diff --git a/lib/rbcodec/codecs/libopus/celt/arm/fixed_armv4.h b/lib/rbcodec/codecs/libopus/celt/arm/fixed_armv4.h
index bcacc343e8..b690bc8cea 100644
--- a/lib/rbcodec/codecs/libopus/celt/arm/fixed_armv4.h
+++ b/lib/rbcodec/codecs/libopus/celt/arm/fixed_armv4.h
@@ -29,7 +29,7 @@
29 29
30/** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ 30/** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */
31#undef MULT16_32_Q16 31#undef MULT16_32_Q16
32static inline opus_val32 MULT16_32_Q16_armv4(opus_val16 a, opus_val32 b) 32static OPUS_INLINE opus_val32 MULT16_32_Q16_armv4(opus_val16 a, opus_val32 b)
33{ 33{
34 unsigned rd_lo; 34 unsigned rd_lo;
35 int rd_hi; 35 int rd_hi;
@@ -46,7 +46,7 @@ static inline opus_val32 MULT16_32_Q16_armv4(opus_val16 a, opus_val32 b)
46 46
47/** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ 47/** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */
48#undef MULT16_32_Q15 48#undef MULT16_32_Q15
49static inline opus_val32 MULT16_32_Q15_armv4(opus_val16 a, opus_val32 b) 49static OPUS_INLINE opus_val32 MULT16_32_Q15_armv4(opus_val16 a, opus_val32 b)
50{ 50{
51 unsigned rd_lo; 51 unsigned rd_lo;
52 int rd_hi; 52 int rd_hi;
diff --git a/lib/rbcodec/codecs/libopus/celt/arm/fixed_armv5e.h b/lib/rbcodec/codecs/libopus/celt/arm/fixed_armv5e.h
index 80632c4a94..1194a7d3ec 100644
--- a/lib/rbcodec/codecs/libopus/celt/arm/fixed_armv5e.h
+++ b/lib/rbcodec/codecs/libopus/celt/arm/fixed_armv5e.h
@@ -34,7 +34,7 @@
34 34
35/** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ 35/** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */
36#undef MULT16_32_Q16 36#undef MULT16_32_Q16
37static inline opus_val32 MULT16_32_Q16_armv5e(opus_val16 a, opus_val32 b) 37static OPUS_INLINE opus_val32 MULT16_32_Q16_armv5e(opus_val16 a, opus_val32 b)
38{ 38{
39 int res; 39 int res;
40 __asm__( 40 __asm__(
@@ -50,7 +50,7 @@ static inline opus_val32 MULT16_32_Q16_armv5e(opus_val16 a, opus_val32 b)
50 50
51/** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ 51/** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */
52#undef MULT16_32_Q15 52#undef MULT16_32_Q15
53static inline opus_val32 MULT16_32_Q15_armv5e(opus_val16 a, opus_val32 b) 53static OPUS_INLINE opus_val32 MULT16_32_Q15_armv5e(opus_val16 a, opus_val32 b)
54{ 54{
55 int res; 55 int res;
56 __asm__( 56 __asm__(
@@ -68,7 +68,7 @@ static inline opus_val32 MULT16_32_Q15_armv5e(opus_val16 a, opus_val32 b)
68 b must fit in 31 bits. 68 b must fit in 31 bits.
69 Result fits in 32 bits. */ 69 Result fits in 32 bits. */
70#undef MAC16_32_Q15 70#undef MAC16_32_Q15
71static inline opus_val32 MAC16_32_Q15_armv5e(opus_val32 c, opus_val16 a, 71static OPUS_INLINE opus_val32 MAC16_32_Q15_armv5e(opus_val32 c, opus_val16 a,
72 opus_val32 b) 72 opus_val32 b)
73{ 73{
74 int res; 74 int res;
@@ -84,7 +84,7 @@ static inline opus_val32 MAC16_32_Q15_armv5e(opus_val32 c, opus_val16 a,
84 84
85/** 16x16 multiply-add where the result fits in 32 bits */ 85/** 16x16 multiply-add where the result fits in 32 bits */
86#undef MAC16_16 86#undef MAC16_16
87static inline opus_val32 MAC16_16_armv5e(opus_val32 c, opus_val16 a, 87static OPUS_INLINE opus_val32 MAC16_16_armv5e(opus_val32 c, opus_val16 a,
88 opus_val16 b) 88 opus_val16 b)
89{ 89{
90 int res; 90 int res;
@@ -100,7 +100,7 @@ static inline opus_val32 MAC16_16_armv5e(opus_val32 c, opus_val16 a,
100 100
101/** 16x16 multiplication where the result fits in 32 bits */ 101/** 16x16 multiplication where the result fits in 32 bits */
102#undef MULT16_16 102#undef MULT16_16
103static inline opus_val32 MULT16_16_armv5e(opus_val16 a, opus_val16 b) 103static OPUS_INLINE opus_val32 MULT16_16_armv5e(opus_val16 a, opus_val16 b)
104{ 104{
105 int res; 105 int res;
106 __asm__( 106 __asm__(
diff --git a/lib/rbcodec/codecs/libopus/celt/bands.c b/lib/rbcodec/codecs/libopus/celt/bands.c
index 5c715aff53..1ad786d795 100644
--- a/lib/rbcodec/codecs/libopus/celt/bands.c
+++ b/lib/rbcodec/codecs/libopus/celt/bands.c
@@ -216,7 +216,9 @@ void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X,
216 j=M*eBands[i]; 216 j=M*eBands[i];
217 band_end = M*eBands[i+1]; 217 band_end = M*eBands[i+1];
218 lg = ADD16(bandLogE[i+c*m->nbEBands], SHL16((opus_val16)eMeans[i],6)); 218 lg = ADD16(bandLogE[i+c*m->nbEBands], SHL16((opus_val16)eMeans[i],6));
219#ifdef FIXED_POINT 219#ifndef FIXED_POINT
220 g = celt_exp2(lg);
221#else
220 /* Handle the integer part of the log energy */ 222 /* Handle the integer part of the log energy */
221 shift = 16-(lg>>DB_SHIFT); 223 shift = 16-(lg>>DB_SHIFT);
222 if (shift>31) 224 if (shift>31)
@@ -227,9 +229,23 @@ void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X,
227 /* Handle the fractional part. */ 229 /* Handle the fractional part. */
228 g = celt_exp2_frac(lg&((1<<DB_SHIFT)-1)); 230 g = celt_exp2_frac(lg&((1<<DB_SHIFT)-1));
229 } 231 }
230#else 232 /* Handle extreme gains with negative shift. */
231 g = celt_exp2(lg); 233 if (shift<0)
234 {
235 /* For shift < -2 we'd be likely to overflow, so we're capping
236 the gain here. This shouldn't happen unless the bitstream is
237 already corrupted. */
238 if (shift < -2)
239 {
240 g = 32767;
241 shift = -2;
242 }
243 do {
244 *f++ = SHL32(MULT16_16(*x++, g), -shift);
245 } while (++j<band_end);
246 } else
232#endif 247#endif
248 /* Be careful of the fixed-point "else" just above when changing this code */
233 do { 249 do {
234 *f++ = SHR32(MULT16_16(*x++, g), shift); 250 *f++ = SHR32(MULT16_16(*x++, g), shift);
235 } while (++j<band_end); 251 } while (++j<band_end);
@@ -495,7 +511,7 @@ int spreading_decision(const CELTMode *m, celt_norm *X, int *average,
495 *tapset_decision=0; 511 *tapset_decision=0;
496 } 512 }
497 /*printf("%d %d %d\n", hf_sum, *hf_average, *tapset_decision);*/ 513 /*printf("%d %d %d\n", hf_sum, *hf_average, *tapset_decision);*/
498 celt_assert(nbBands>0); /*M*(eBands[end]-eBands[end-1]) <= 8 assures this*/ 514 celt_assert(nbBands>0); /* end has to be non-zero */
499 sum /= nbBands; 515 sum /= nbBands;
500 /* Recursive averaging */ 516 /* Recursive averaging */
501 sum = (sum+*average)>>1; 517 sum = (sum+*average)>>1;
@@ -873,7 +889,6 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X,
873 int q; 889 int q;
874 int curr_bits; 890 int curr_bits;
875 int imid=0, iside=0; 891 int imid=0, iside=0;
876 int N_B=N;
877 int B0=B; 892 int B0=B;
878 opus_val16 mid=0, side=0; 893 opus_val16 mid=0, side=0;
879 unsigned cm=0; 894 unsigned cm=0;
@@ -895,8 +910,6 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X,
895 spread = ctx->spread; 910 spread = ctx->spread;
896 ec = ctx->ec; 911 ec = ctx->ec;
897 912
898 N_B /= B;
899
900 /* If we need 1.5 more bit than we can produce, split the band in two. */ 913 /* If we need 1.5 more bit than we can produce, split the band in two. */
901 cache = m->cache.bits + m->cache.index[(LM+1)*m->nbEBands+i]; 914 cache = m->cache.bits + m->cache.index[(LM+1)*m->nbEBands+i];
902 if (LM != -1 && b > cache[cache[0]]+12 && N>2) 915 if (LM != -1 && b > cache[cache[0]]+12 && N>2)
@@ -1076,7 +1089,6 @@ static unsigned quant_band(struct band_ctx *ctx, celt_norm *X,
1076 longBlocks = B0==1; 1089 longBlocks = B0==1;
1077 1090
1078 N_B /= B; 1091 N_B /= B;
1079 N_B0 = N_B;
1080 1092
1081 /* Special case for one sample */ 1093 /* Special case for one sample */
1082 if (N==1) 1094 if (N==1)
diff --git a/lib/rbcodec/codecs/libopus/celt/celt.h b/lib/rbcodec/codecs/libopus/celt/celt.h
index 0911c72f72..5deea1f0aa 100644
--- a/lib/rbcodec/codecs/libopus/celt/celt.h
+++ b/lib/rbcodec/codecs/libopus/celt/celt.h
@@ -52,11 +52,11 @@ extern "C" {
52 52
53typedef struct { 53typedef struct {
54 int valid; 54 int valid;
55 opus_val16 tonality; 55 float tonality;
56 opus_val16 tonality_slope; 56 float tonality_slope;
57 opus_val16 noisiness; 57 float noisiness;
58 opus_val16 activity; 58 float activity;
59 opus_val16 music_prob; 59 float music_prob;
60 int bandwidth; 60 int bandwidth;
61}AnalysisInfo; 61}AnalysisInfo;
62 62
@@ -66,6 +66,10 @@ typedef struct {
66 66
67/* Encoder/decoder Requests */ 67/* Encoder/decoder Requests */
68 68
69/* Expose this option again when variable framesize actually works */
70#define OPUS_FRAMESIZE_VARIABLE 5010 /**< Optimize the frame size dynamically */
71
72
69#define CELT_SET_PREDICTION_REQUEST 10002 73#define CELT_SET_PREDICTION_REQUEST 10002
70/** Controls the use of interframe prediction. 74/** Controls the use of interframe prediction.
71 0=Independent frames 75 0=Independent frames
@@ -109,10 +113,7 @@ typedef struct {
109#define OPUS_SET_LFE_REQUEST 10024 113#define OPUS_SET_LFE_REQUEST 10024
110#define OPUS_SET_LFE(x) OPUS_SET_LFE_REQUEST, __opus_check_int(x) 114#define OPUS_SET_LFE(x) OPUS_SET_LFE_REQUEST, __opus_check_int(x)
111 115
112#define OPUS_SET_ENERGY_SAVE_REQUEST 10026 116#define OPUS_SET_ENERGY_MASK_REQUEST 10026
113#define OPUS_SET_ENERGY_SAVE(x) OPUS_SET_ENERGY_SAVE_REQUEST, __opus_check_val16_ptr(x)
114
115#define OPUS_SET_ENERGY_MASK_REQUEST 10028
116#define OPUS_SET_ENERGY_MASK(x) OPUS_SET_ENERGY_MASK_REQUEST, __opus_check_val16_ptr(x) 117#define OPUS_SET_ENERGY_MASK(x) OPUS_SET_ENERGY_MASK_REQUEST, __opus_check_val16_ptr(x)
117 118
118/* Encoder stuff */ 119/* Encoder stuff */
@@ -121,7 +122,8 @@ int celt_encoder_get_size(int channels);
121 122
122int celt_encode_with_ec(OpusCustomEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc); 123int celt_encode_with_ec(OpusCustomEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc);
123 124
124int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels); 125int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels,
126 int arch);
125 127
126 128
127 129
@@ -141,7 +143,7 @@ int celt_decode_with_ec(OpusCustomDecoder * OPUS_RESTRICT st, const unsigned cha
141#ifdef CUSTOM_MODES 143#ifdef CUSTOM_MODES
142#define OPUS_CUSTOM_NOSTATIC 144#define OPUS_CUSTOM_NOSTATIC
143#else 145#else
144#define OPUS_CUSTOM_NOSTATIC static inline 146#define OPUS_CUSTOM_NOSTATIC static OPUS_INLINE
145#endif 147#endif
146 148
147static const unsigned char trim_icdf[11] = {126, 124, 119, 109, 87, 41, 19, 9, 4, 2, 0}; 149static const unsigned char trim_icdf[11] = {126, 124, 119, 109, 87, 41, 19, 9, 4, 2, 0};
@@ -166,7 +168,7 @@ static const unsigned char fromOpusTable[16] = {
166 0x00, 0x08, 0x10, 0x18 168 0x00, 0x08, 0x10, 0x18
167}; 169};
168 170
169static inline int toOpus(unsigned char c) 171static OPUS_INLINE int toOpus(unsigned char c)
170{ 172{
171 int ret=0; 173 int ret=0;
172 if (c<0xA0) 174 if (c<0xA0)
@@ -177,7 +179,7 @@ static inline int toOpus(unsigned char c)
177 return ret|(c&0x7); 179 return ret|(c&0x7);
178} 180}
179 181
180static inline int fromOpus(unsigned char c) 182static OPUS_INLINE int fromOpus(unsigned char c)
181{ 183{
182 if (c<0x80) 184 if (c<0x80)
183 return -1; 185 return -1;
@@ -193,6 +195,9 @@ extern const signed char tf_select_table[4][8];
193 195
194int resampling_factor(opus_int32 rate); 196int resampling_factor(opus_int32 rate);
195 197
198void celt_preemphasis(const opus_val16 * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTRICT inp,
199 int N, int CC, int upsample, const opus_val16 *coef, celt_sig *mem, int clip);
200
196void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, 201void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N,
197 opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, 202 opus_val16 g0, opus_val16 g1, int tapset0, int tapset1,
198 const opus_val16 *window, int overlap); 203 const opus_val16 *window, int overlap);
diff --git a/lib/rbcodec/codecs/libopus/celt/celt_decoder.c b/lib/rbcodec/codecs/libopus/celt/celt_decoder.c
index 3d8211b9b0..77fa2d01f7 100644
--- a/lib/rbcodec/codecs/libopus/celt/celt_decoder.c
+++ b/lib/rbcodec/codecs/libopus/celt/celt_decoder.c
@@ -175,7 +175,7 @@ void opus_custom_decoder_destroy(CELTDecoder *st)
175} 175}
176#endif /* CUSTOM_MODES */ 176#endif /* CUSTOM_MODES */
177 177
178static inline opus_val16 SIG2WORD16(celt_sig x) 178static OPUS_INLINE opus_val16 SIG2WORD16(celt_sig x)
179{ 179{
180#ifdef FIXED_POINT 180#ifdef FIXED_POINT
181 x = PSHR32(x, SIG_SHIFT); 181 x = PSHR32(x, SIG_SHIFT);
@@ -213,7 +213,7 @@ void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, c
213 opus_val16 coef3 = coef[3]; 213 opus_val16 coef3 = coef[3];
214 for (j=0;j<N;j++) 214 for (j=0;j<N;j++)
215 { 215 {
216 celt_sig tmp = x[j] + m; 216 celt_sig tmp = x[j] + m + VERY_SMALL;
217 m = MULT16_32_Q15(coef0, tmp) 217 m = MULT16_32_Q15(coef0, tmp)
218 - MULT16_32_Q15(coef1, x[j]); 218 - MULT16_32_Q15(coef1, x[j]);
219 tmp = SHL32(MULT16_32_Q15(coef3, tmp), 2); 219 tmp = SHL32(MULT16_32_Q15(coef3, tmp), 2);
@@ -227,7 +227,7 @@ void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, c
227 /* Shortcut for the standard (non-custom modes) case */ 227 /* Shortcut for the standard (non-custom modes) case */
228 for (j=0;j<N;j++) 228 for (j=0;j<N;j++)
229 { 229 {
230 celt_sig tmp = x[j] + m; 230 celt_sig tmp = x[j] + m + VERY_SMALL;
231 m = MULT16_32_Q15(coef0, tmp); 231 m = MULT16_32_Q15(coef0, tmp);
232 scratch[j] = tmp; 232 scratch[j] = tmp;
233 } 233 }
@@ -447,10 +447,11 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R
447 { 447 {
448 VARDECL( opus_val16, lp_pitch_buf ); 448 VARDECL( opus_val16, lp_pitch_buf );
449 ALLOC( lp_pitch_buf, DECODE_BUFFER_SIZE>>1, opus_val16 ); 449 ALLOC( lp_pitch_buf, DECODE_BUFFER_SIZE>>1, opus_val16 );
450 pitch_downsample(decode_mem, lp_pitch_buf, DECODE_BUFFER_SIZE, C); 450 pitch_downsample(decode_mem, lp_pitch_buf,
451 DECODE_BUFFER_SIZE, C, st->arch);
451 pitch_search(lp_pitch_buf+(PLC_PITCH_LAG_MAX>>1), lp_pitch_buf, 452 pitch_search(lp_pitch_buf+(PLC_PITCH_LAG_MAX>>1), lp_pitch_buf,
452 DECODE_BUFFER_SIZE-PLC_PITCH_LAG_MAX, 453 DECODE_BUFFER_SIZE-PLC_PITCH_LAG_MAX,
453 PLC_PITCH_LAG_MAX-PLC_PITCH_LAG_MIN, &pitch_index); 454 PLC_PITCH_LAG_MAX-PLC_PITCH_LAG_MIN, &pitch_index, st->arch);
454 pitch_index = PLC_PITCH_LAG_MAX-pitch_index; 455 pitch_index = PLC_PITCH_LAG_MAX-pitch_index;
455 st->last_pitch_index = pitch_index; 456 st->last_pitch_index = pitch_index;
456 } else { 457 } else {
@@ -481,7 +482,8 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R
481 opus_val32 ac[LPC_ORDER+1]; 482 opus_val32 ac[LPC_ORDER+1];
482 /* Compute LPC coefficients for the last MAX_PERIOD samples before 483 /* Compute LPC coefficients for the last MAX_PERIOD samples before
483 the first loss so we can work in the excitation-filter domain. */ 484 the first loss so we can work in the excitation-filter domain. */
484 _celt_autocorr(exc, ac, window, overlap, LPC_ORDER, MAX_PERIOD); 485 _celt_autocorr(exc, ac, window, overlap,
486 LPC_ORDER, MAX_PERIOD, st->arch);
485 /* Add a noise floor of -40 dB. */ 487 /* Add a noise floor of -40 dB. */
486#ifdef FIXED_POINT 488#ifdef FIXED_POINT
487 ac[0] += SHR32(ac[0],13); 489 ac[0] += SHR32(ac[0],13);
@@ -668,7 +670,6 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
668 VARDECL(int, fine_priority); 670 VARDECL(int, fine_priority);
669 VARDECL(int, tf_res); 671 VARDECL(int, tf_res);
670 VARDECL(unsigned char, collapse_masks); 672 VARDECL(unsigned char, collapse_masks);
671 celt_sig *out_mem[2] = {NULL, NULL};
672 celt_sig *decode_mem[2]; 673 celt_sig *decode_mem[2];
673 celt_sig *out_syn[2]; 674 celt_sig *out_syn[2];
674 opus_val16 *lpc; 675 opus_val16 *lpc;
@@ -709,7 +710,6 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
709 710
710 c=0; do { 711 c=0; do {
711 decode_mem[c] = st->_decode_mem + c*(DECODE_BUFFER_SIZE+overlap); 712 decode_mem[c] = st->_decode_mem + c*(DECODE_BUFFER_SIZE+overlap);
712 out_mem[c] = decode_mem[c]+DECODE_BUFFER_SIZE-MAX_PERIOD;
713 } while (++c<CC); 713 } while (++c<CC);
714 lpc = (opus_val16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+overlap)*CC); 714 lpc = (opus_val16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+overlap)*CC);
715 oldBandE = lpc+CC*LPC_ORDER; 715 oldBandE = lpc+CC*LPC_ORDER;
@@ -934,7 +934,6 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
934 /* Synthesis */ 934 /* Synthesis */
935 denormalise_bands(mode, X, freq, oldBandE, st->start, effEnd, C, M); 935 denormalise_bands(mode, X, freq, oldBandE, st->start, effEnd, C, M);
936 } 936 }
937
938 c=0; do { 937 c=0; do {
939 OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap/2); 938 OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap/2);
940 } while (++c<CC); 939 } while (++c<CC);
@@ -948,7 +947,7 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
948 } while (++c<C); 947 } while (++c<C);
949 948
950 c=0; do { 949 c=0; do {
951 out_syn[c] = out_mem[c]+MAX_PERIOD-N; 950 out_syn[c] = decode_mem[c]+DECODE_BUFFER_SIZE-N;
952 } while (++c<CC); 951 } while (++c<CC);
953 952
954 if (CC==2&&C==1) 953 if (CC==2&&C==1)
diff --git a/lib/rbcodec/codecs/libopus/celt/celt_lpc.c b/lib/rbcodec/codecs/libopus/celt/celt_lpc.c
index 7ffe90a357..fa29d626ea 100644
--- a/lib/rbcodec/codecs/libopus/celt/celt_lpc.c
+++ b/lib/rbcodec/codecs/libopus/celt/celt_lpc.c
@@ -226,7 +226,8 @@ int _celt_autocorr(
226 const opus_val16 *window, 226 const opus_val16 *window,
227 int overlap, 227 int overlap,
228 int lag, 228 int lag,
229 int n 229 int n,
230 int arch
230 ) 231 )
231{ 232{
232 opus_val32 d; 233 opus_val32 d;
@@ -275,7 +276,7 @@ int _celt_autocorr(
275 shift = 0; 276 shift = 0;
276 } 277 }
277#endif 278#endif
278 celt_pitch_xcorr(xptr, xptr, ac, fastN, lag+1); 279 celt_pitch_xcorr(xptr, xptr, ac, fastN, lag+1, arch);
279 for (k=0;k<=lag;k++) 280 for (k=0;k<=lag;k++)
280 { 281 {
281 for (i = k+fastN, d = 0; i < n; i++) 282 for (i = k+fastN, d = 0; i < n; i++)
diff --git a/lib/rbcodec/codecs/libopus/celt/celt_lpc.h b/lib/rbcodec/codecs/libopus/celt/celt_lpc.h
index 19279a0ed6..dc2a0a3d26 100644
--- a/lib/rbcodec/codecs/libopus/celt/celt_lpc.h
+++ b/lib/rbcodec/codecs/libopus/celt/celt_lpc.h
@@ -48,6 +48,7 @@ void celt_iir(const opus_val32 *x,
48 int ord, 48 int ord,
49 opus_val16 *mem); 49 opus_val16 *mem);
50 50
51int _celt_autocorr(const opus_val16 *x, opus_val32 *ac, const opus_val16 *window, int overlap, int lag, int n); 51int _celt_autocorr(const opus_val16 *x, opus_val32 *ac,
52 const opus_val16 *window, int overlap, int lag, int n, int arch);
52 53
53#endif /* PLC_H */ 54#endif /* PLC_H */
diff --git a/lib/rbcodec/codecs/libopus/celt/cpu_support.h b/lib/rbcodec/codecs/libopus/celt/cpu_support.h
index 41481feb9c..d68dbe62c5 100644
--- a/lib/rbcodec/codecs/libopus/celt/cpu_support.h
+++ b/lib/rbcodec/codecs/libopus/celt/cpu_support.h
@@ -28,7 +28,10 @@
28#ifndef CPU_SUPPORT_H 28#ifndef CPU_SUPPORT_H
29#define CPU_SUPPORT_H 29#define CPU_SUPPORT_H
30 30
31#if defined(OPUS_HAVE_RTCD) && defined(ARMv4_ASM) 31#include "opus_types.h"
32#include "opus_defines.h"
33
34#if defined(OPUS_HAVE_RTCD) && defined(OPUS_ARM_ASM)
32#include "arm/armcpu.h" 35#include "arm/armcpu.h"
33 36
34/* We currently support 4 ARM variants: 37/* We currently support 4 ARM variants:
@@ -42,7 +45,7 @@
42#else 45#else
43#define OPUS_ARCHMASK 0 46#define OPUS_ARCHMASK 0
44 47
45static inline int opus_select_arch(void) 48static OPUS_INLINE int opus_select_arch(void)
46{ 49{
47 return 0; 50 return 0;
48} 51}
diff --git a/lib/rbcodec/codecs/libopus/celt/cwrs.c b/lib/rbcodec/codecs/libopus/celt/cwrs.c
index eb8fa1c807..03b86985d2 100644
--- a/lib/rbcodec/codecs/libopus/celt/cwrs.c
+++ b/lib/rbcodec/codecs/libopus/celt/cwrs.c
@@ -410,7 +410,7 @@ static const opus_uint32 CELT_PVQ_U_DATA[1272] ICONST_ATTR ={
410}; 410};
411 411
412#if defined(CUSTOM_MODES) 412#if defined(CUSTOM_MODES)
413const opus_uint32 *const CELT_PVQ_U_ROW[15]={ 413static const opus_uint32 *const CELT_PVQ_U_ROW[15]={
414 CELT_PVQ_U_DATA+ 0,CELT_PVQ_U_DATA+ 208,CELT_PVQ_U_DATA+ 415, 414 CELT_PVQ_U_DATA+ 0,CELT_PVQ_U_DATA+ 208,CELT_PVQ_U_DATA+ 415,
415 CELT_PVQ_U_DATA+ 621,CELT_PVQ_U_DATA+ 826,CELT_PVQ_U_DATA+1030, 415 CELT_PVQ_U_DATA+ 621,CELT_PVQ_U_DATA+ 826,CELT_PVQ_U_DATA+1030,
416 CELT_PVQ_U_DATA+1233,CELT_PVQ_U_DATA+1336,CELT_PVQ_U_DATA+1389, 416 CELT_PVQ_U_DATA+1233,CELT_PVQ_U_DATA+1336,CELT_PVQ_U_DATA+1389,
@@ -418,7 +418,7 @@ const opus_uint32 *const CELT_PVQ_U_ROW[15]={
418 CELT_PVQ_U_DATA+1464,CELT_PVQ_U_DATA+1470,CELT_PVQ_U_DATA+1473 418 CELT_PVQ_U_DATA+1464,CELT_PVQ_U_DATA+1470,CELT_PVQ_U_DATA+1473
419}; 419};
420#else 420#else
421const opus_uint32 *const CELT_PVQ_U_ROW[15]={ 421static const opus_uint32 *const CELT_PVQ_U_ROW[15]={
422 CELT_PVQ_U_DATA+ 0,CELT_PVQ_U_DATA+ 176,CELT_PVQ_U_DATA+ 351, 422 CELT_PVQ_U_DATA+ 0,CELT_PVQ_U_DATA+ 176,CELT_PVQ_U_DATA+ 351,
423 CELT_PVQ_U_DATA+ 525,CELT_PVQ_U_DATA+ 698,CELT_PVQ_U_DATA+ 870, 423 CELT_PVQ_U_DATA+ 525,CELT_PVQ_U_DATA+ 698,CELT_PVQ_U_DATA+ 870,
424 CELT_PVQ_U_DATA+1041,CELT_PVQ_U_DATA+1131,CELT_PVQ_U_DATA+1178, 424 CELT_PVQ_U_DATA+1041,CELT_PVQ_U_DATA+1131,CELT_PVQ_U_DATA+1178,
@@ -534,7 +534,7 @@ void decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){
534/*Computes the next row/column of any recurrence that obeys the relation 534/*Computes the next row/column of any recurrence that obeys the relation
535 u[i][j]=u[i-1][j]+u[i][j-1]+u[i-1][j-1]. 535 u[i][j]=u[i-1][j]+u[i][j-1]+u[i-1][j-1].
536 _ui0 is the base case for the new row/column.*/ 536 _ui0 is the base case for the new row/column.*/
537static inline void unext(opus_uint32 *_ui,unsigned _len,opus_uint32 _ui0){ 537static OPUS_INLINE void unext(opus_uint32 *_ui,unsigned _len,opus_uint32 _ui0){
538 opus_uint32 ui1; 538 opus_uint32 ui1;
539 unsigned j; 539 unsigned j;
540 /*This do-while will overrun the array if we don't have storage for at least 540 /*This do-while will overrun the array if we don't have storage for at least
@@ -550,7 +550,7 @@ static inline void unext(opus_uint32 *_ui,unsigned _len,opus_uint32 _ui0){
550/*Computes the previous row/column of any recurrence that obeys the relation 550/*Computes the previous row/column of any recurrence that obeys the relation
551 u[i-1][j]=u[i][j]-u[i][j-1]-u[i-1][j-1]. 551 u[i-1][j]=u[i][j]-u[i][j-1]-u[i-1][j-1].
552 _ui0 is the base case for the new row/column.*/ 552 _ui0 is the base case for the new row/column.*/
553static inline void uprev(opus_uint32 *_ui,unsigned _n,opus_uint32 _ui0){ 553static OPUS_INLINE void uprev(opus_uint32 *_ui,unsigned _n,opus_uint32 _ui0){
554 opus_uint32 ui1; 554 opus_uint32 ui1;
555 unsigned j; 555 unsigned j;
556 /*This do-while will overrun the array if we don't have storage for at least 556 /*This do-while will overrun the array if we don't have storage for at least
@@ -617,7 +617,7 @@ static void cwrsi(int _n,int _k,opus_uint32 _i,int *_y,opus_uint32 *_u){
617 of size 1 with associated sign bits. 617 of size 1 with associated sign bits.
618 _y: The vector of pulses, whose sum of absolute values is K. 618 _y: The vector of pulses, whose sum of absolute values is K.
619 _k: Returns K.*/ 619 _k: Returns K.*/
620static inline opus_uint32 icwrs1(const int *_y,int *_k){ 620static OPUS_INLINE opus_uint32 icwrs1(const int *_y,int *_k){
621 *_k=abs(_y[0]); 621 *_k=abs(_y[0]);
622 return _y[0]<0; 622 return _y[0]<0;
623} 623}
@@ -626,7 +626,7 @@ static inline opus_uint32 icwrs1(const int *_y,int *_k){
626 of size _n with associated sign bits. 626 of size _n with associated sign bits.
627 _y: The vector of pulses, whose sum of absolute values must be _k. 627 _y: The vector of pulses, whose sum of absolute values must be _k.
628 _nc: Returns V(_n,_k).*/ 628 _nc: Returns V(_n,_k).*/
629static inline opus_uint32 icwrs(int _n,int _k,opus_uint32 *_nc,const int *_y, 629static OPUS_INLINE opus_uint32 icwrs(int _n,int _k,opus_uint32 *_nc,const int *_y,
630 opus_uint32 *_u){ 630 opus_uint32 *_u){
631 opus_uint32 i; 631 opus_uint32 i;
632 int j; 632 int j;
diff --git a/lib/rbcodec/codecs/libopus/celt/ecintrin.h b/lib/rbcodec/codecs/libopus/celt/ecintrin.h
index be57dd40de..2263cff6bd 100644
--- a/lib/rbcodec/codecs/libopus/celt/ecintrin.h
+++ b/lib/rbcodec/codecs/libopus/celt/ecintrin.h
@@ -33,7 +33,7 @@
33#if !defined(_ecintrin_H) 33#if !defined(_ecintrin_H)
34# define _ecintrin_H (1) 34# define _ecintrin_H (1)
35 35
36/*Some specific platforms may have optimized intrinsic or inline assembly 36/*Some specific platforms may have optimized intrinsic or OPUS_INLINE assembly
37 versions of these functions which can substantially improve performance. 37 versions of these functions which can substantially improve performance.
38 We define macros for them to allow easy incorporation of these non-ANSI 38 We define macros for them to allow easy incorporation of these non-ANSI
39 features.*/ 39 features.*/
diff --git a/lib/rbcodec/codecs/libopus/celt/entcode.h b/lib/rbcodec/codecs/libopus/celt/entcode.h
index aebecc0647..dd13e49e50 100644
--- a/lib/rbcodec/codecs/libopus/celt/entcode.h
+++ b/lib/rbcodec/codecs/libopus/celt/entcode.h
@@ -26,6 +26,7 @@
26*/ 26*/
27 27
28#include "opus_types.h" 28#include "opus_types.h"
29#include "opus_defines.h"
29 30
30#if !defined(_entcode_H) 31#if !defined(_entcode_H)
31# define _entcode_H (1) 32# define _entcode_H (1)
@@ -83,15 +84,15 @@ struct ec_ctx{
83 int error; 84 int error;
84}; 85};
85 86
86static inline opus_uint32 ec_range_bytes(ec_ctx *_this){ 87static OPUS_INLINE opus_uint32 ec_range_bytes(ec_ctx *_this){
87 return _this->offs; 88 return _this->offs;
88} 89}
89 90
90static inline unsigned char *ec_get_buffer(ec_ctx *_this){ 91static OPUS_INLINE unsigned char *ec_get_buffer(ec_ctx *_this){
91 return _this->buf; 92 return _this->buf;
92} 93}
93 94
94static inline int ec_get_error(ec_ctx *_this){ 95static OPUS_INLINE int ec_get_error(ec_ctx *_this){
95 return _this->error; 96 return _this->error;
96} 97}
97 98
@@ -101,7 +102,7 @@ static inline int ec_get_error(ec_ctx *_this){
101 Return: The number of bits. 102 Return: The number of bits.
102 This will always be slightly larger than the exact value (e.g., all 103 This will always be slightly larger than the exact value (e.g., all
103 rounding error is in the positive direction).*/ 104 rounding error is in the positive direction).*/
104static inline int ec_tell(ec_ctx *_this){ 105static OPUS_INLINE int ec_tell(ec_ctx *_this){
105 return _this->nbits_total-EC_ILOG(_this->rng); 106 return _this->nbits_total-EC_ILOG(_this->rng);
106} 107}
107 108
diff --git a/lib/rbcodec/codecs/libopus/celt/fixed_generic.h b/lib/rbcodec/codecs/libopus/celt/fixed_generic.h
index 0e77976e83..ecf018a244 100644
--- a/lib/rbcodec/codecs/libopus/celt/fixed_generic.h
+++ b/lib/rbcodec/codecs/libopus/celt/fixed_generic.h
@@ -40,7 +40,7 @@
40#define MULT16_32_Q16(a,b) ADD32(MULT16_16((a),SHR((b),16)), SHR(MULT16_16SU((a),((b)&0x0000ffff)),16)) 40#define MULT16_32_Q16(a,b) ADD32(MULT16_16((a),SHR((b),16)), SHR(MULT16_16SU((a),((b)&0x0000ffff)),16))
41 41
42/** 16x32 multiplication, followed by a 16-bit shift right (round-to-nearest). Results fits in 32 bits */ 42/** 16x32 multiplication, followed by a 16-bit shift right (round-to-nearest). Results fits in 32 bits */
43#define MULT16_32_P16(a,b) ADD32(MULT16_16((a),SHR((b),16)), PSHR(MULT16_16((a),((b)&0x0000ffff)),16)) 43#define MULT16_32_P16(a,b) ADD32(MULT16_16((a),SHR((b),16)), PSHR(MULT16_16SU((a),((b)&0x0000ffff)),16))
44 44
45/** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ 45/** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */
46#define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),((b)&0x0000ffff)),15)) 46#define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),((b)&0x0000ffff)),15))
@@ -116,6 +116,7 @@
116#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))) 116#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)))
117 117
118#define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11)) 118#define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11))
119#define MULT16_16_Q11(a,b) (SHR(MULT16_16((a),(b)),11))
119#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13)) 120#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
120#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14)) 121#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))
121#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15)) 122#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15))
diff --git a/lib/rbcodec/codecs/libopus/celt/float_cast.h b/lib/rbcodec/codecs/libopus/celt/float_cast.h
index 5ded291599..ede6574860 100644
--- a/lib/rbcodec/codecs/libopus/celt/float_cast.h
+++ b/lib/rbcodec/codecs/libopus/celt/float_cast.h
@@ -101,7 +101,7 @@
101 #include <math.h> 101 #include <math.h>
102 102
103 /* Win32 doesn't seem to have these functions. 103 /* Win32 doesn't seem to have these functions.
104 ** Therefore implement inline versions of these functions here. 104 ** Therefore implement OPUS_INLINE versions of these functions here.
105 */ 105 */
106 106
107 __inline long int 107 __inline long int
@@ -128,7 +128,7 @@
128#endif 128#endif
129 129
130#ifndef DISABLE_FLOAT_API 130#ifndef DISABLE_FLOAT_API
131static inline opus_int16 FLOAT2INT16(float x) 131static OPUS_INLINE opus_int16 FLOAT2INT16(float x)
132{ 132{
133 x = x*CELT_SIG_SCALE; 133 x = x*CELT_SIG_SCALE;
134 x = MAX32(x, -32768); 134 x = MAX32(x, -32768);
diff --git a/lib/rbcodec/codecs/libopus/celt/mathops.c b/lib/rbcodec/codecs/libopus/celt/mathops.c
index 21fd942960..3f8c5dcc0e 100644
--- a/lib/rbcodec/codecs/libopus/celt/mathops.c
+++ b/lib/rbcodec/codecs/libopus/celt/mathops.c
@@ -139,7 +139,7 @@ opus_val32 celt_sqrt(opus_val32 x)
139#define L3 8277 139#define L3 8277
140#define L4 -626 140#define L4 -626
141 141
142static inline opus_val16 _celt_cos_pi_2(opus_val16 x) 142static OPUS_INLINE opus_val16 _celt_cos_pi_2(opus_val16 x)
143{ 143{
144 opus_val16 x2; 144 opus_val16 x2;
145 145
diff --git a/lib/rbcodec/codecs/libopus/celt/mathops.h b/lib/rbcodec/codecs/libopus/celt/mathops.h
index 44fa97c697..a0525a9610 100644
--- a/lib/rbcodec/codecs/libopus/celt/mathops.h
+++ b/lib/rbcodec/codecs/libopus/celt/mathops.h
@@ -44,7 +44,7 @@
44unsigned isqrt32(opus_uint32 _val); 44unsigned isqrt32(opus_uint32 _val);
45 45
46#ifndef OVERRIDE_CELT_MAXABS16 46#ifndef OVERRIDE_CELT_MAXABS16
47static inline opus_val32 celt_maxabs16(const opus_val16 *x, int len) 47static OPUS_INLINE opus_val32 celt_maxabs16(const opus_val16 *x, int len)
48{ 48{
49 int i; 49 int i;
50 opus_val16 maxval = 0; 50 opus_val16 maxval = 0;
@@ -60,7 +60,7 @@ static inline opus_val32 celt_maxabs16(const opus_val16 *x, int len)
60 60
61#ifndef OVERRIDE_CELT_MAXABS32 61#ifndef OVERRIDE_CELT_MAXABS32
62#ifdef FIXED_POINT 62#ifdef FIXED_POINT
63static inline opus_val32 celt_maxabs32(const opus_val32 *x, int len) 63static OPUS_INLINE opus_val32 celt_maxabs32(const opus_val32 *x, int len)
64{ 64{
65 int i; 65 int i;
66 opus_val32 maxval = 0; 66 opus_val32 maxval = 0;
@@ -95,7 +95,7 @@ static inline opus_val32 celt_maxabs32(const opus_val32 *x, int len)
95 denorm, +/- inf and NaN are *not* handled */ 95 denorm, +/- inf and NaN are *not* handled */
96 96
97/** Base-2 log approximation (log2(x)). */ 97/** Base-2 log approximation (log2(x)). */
98static inline float celt_log2(float x) 98static OPUS_INLINE float celt_log2(float x)
99{ 99{
100 int integer; 100 int integer;
101 float frac; 101 float frac;
@@ -113,7 +113,7 @@ static inline float celt_log2(float x)
113} 113}
114 114
115/** Base-2 exponential approximation (2^x). */ 115/** Base-2 exponential approximation (2^x). */
116static inline float celt_exp2(float x) 116static OPUS_INLINE float celt_exp2(float x)
117{ 117{
118 int integer; 118 int integer;
119 float frac; 119 float frac;
@@ -145,7 +145,7 @@ static inline float celt_exp2(float x)
145 145
146#ifndef OVERRIDE_CELT_ILOG2 146#ifndef OVERRIDE_CELT_ILOG2
147/** Integer log in base2. Undefined for zero and negative numbers */ 147/** Integer log in base2. Undefined for zero and negative numbers */
148static inline opus_int16 celt_ilog2(opus_int32 x) 148static OPUS_INLINE opus_int16 celt_ilog2(opus_int32 x)
149{ 149{
150 celt_assert2(x>0, "celt_ilog2() only defined for strictly positive numbers"); 150 celt_assert2(x>0, "celt_ilog2() only defined for strictly positive numbers");
151 return EC_ILOG(x)-1; 151 return EC_ILOG(x)-1;
@@ -154,7 +154,7 @@ static inline opus_int16 celt_ilog2(opus_int32 x)
154 154
155 155
156/** Integer log in base2. Defined for zero, but not for negative numbers */ 156/** Integer log in base2. Defined for zero, but not for negative numbers */
157static inline opus_int16 celt_zlog2(opus_val32 x) 157static OPUS_INLINE opus_int16 celt_zlog2(opus_val32 x)
158{ 158{
159 return x <= 0 ? 0 : celt_ilog2(x); 159 return x <= 0 ? 0 : celt_ilog2(x);
160} 160}
@@ -165,7 +165,8 @@ opus_val32 celt_sqrt(opus_val32 x);
165 165
166opus_val16 celt_cos_norm(opus_val32 x); 166opus_val16 celt_cos_norm(opus_val32 x);
167 167
168static inline opus_val16 celt_log2(opus_val32 x) 168/** Base-2 logarithm approximation (log2(x)). (Q14 input, Q10 output) */
169static OPUS_INLINE opus_val16 celt_log2(opus_val32 x)
169{ 170{
170 int i; 171 int i;
171 opus_val16 n, frac; 172 opus_val16 n, frac;
@@ -191,14 +192,14 @@ static inline opus_val16 celt_log2(opus_val32 x)
191#define D2 14819 192#define D2 14819
192#define D3 10204 193#define D3 10204
193 194
194static inline opus_val32 celt_exp2_frac(opus_val16 x) 195static OPUS_INLINE opus_val32 celt_exp2_frac(opus_val16 x)
195{ 196{
196 opus_val16 frac; 197 opus_val16 frac;
197 frac = SHL16(x, 4); 198 frac = SHL16(x, 4);
198 return ADD16(D0, MULT16_16_Q15(frac, ADD16(D1, MULT16_16_Q15(frac, ADD16(D2 , MULT16_16_Q15(D3,frac)))))); 199 return ADD16(D0, MULT16_16_Q15(frac, ADD16(D1, MULT16_16_Q15(frac, ADD16(D2 , MULT16_16_Q15(D3,frac))))));
199} 200}
200/** Base-2 exponential approximation (2^x). (Q10 input, Q16 output) */ 201/** Base-2 exponential approximation (2^x). (Q10 input, Q16 output) */
201static inline opus_val32 celt_exp2(opus_val16 x) 202static OPUS_INLINE opus_val32 celt_exp2(opus_val16 x)
202{ 203{
203 int integer; 204 int integer;
204 opus_val16 frac; 205 opus_val16 frac;
@@ -224,7 +225,7 @@ opus_val32 frac_div32(opus_val32 a, opus_val32 b);
224 225
225/* Atan approximation using a 4th order polynomial. Input is in Q15 format 226/* Atan approximation using a 4th order polynomial. Input is in Q15 format
226 and normalized by pi/4. Output is in Q15 format */ 227 and normalized by pi/4. Output is in Q15 format */
227static inline opus_val16 celt_atan01(opus_val16 x) 228static OPUS_INLINE opus_val16 celt_atan01(opus_val16 x)
228{ 229{
229 return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x))))))); 230 return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x)))))));
230} 231}
@@ -235,7 +236,7 @@ static inline opus_val16 celt_atan01(opus_val16 x)
235#undef M4 236#undef M4
236 237
237/* atan2() approximation valid for positive input values */ 238/* atan2() approximation valid for positive input values */
238static inline opus_val16 celt_atan2p(opus_val16 y, opus_val16 x) 239static OPUS_INLINE opus_val16 celt_atan2p(opus_val16 y, opus_val16 x)
239{ 240{
240 if (y < x) 241 if (y < x)
241 { 242 {
diff --git a/lib/rbcodec/codecs/libopus/celt/os_support.h b/lib/rbcodec/codecs/libopus/celt/os_support.h
index 2484f0b2f7..5e47e3cff9 100644
--- a/lib/rbcodec/codecs/libopus/celt/os_support.h
+++ b/lib/rbcodec/codecs/libopus/celt/os_support.h
@@ -35,13 +35,16 @@
35# include "custom_support.h" 35# include "custom_support.h"
36#endif 36#endif
37 37
38#include "opus_types.h"
39#include "opus_defines.h"
40
38#include <string.h> 41#include <string.h>
39#include <stdio.h> 42#include <stdio.h>
40#include <stdlib.h> 43#include <stdlib.h>
41 44
42/** Opus wrapper for malloc(). To do your own dynamic allocation, all you need to do is replace this function and opus_free */ 45/** Opus wrapper for malloc(). To do your own dynamic allocation, all you need to do is replace this function and opus_free */
43#ifndef OVERRIDE_OPUS_ALLOC 46#ifndef OVERRIDE_OPUS_ALLOC
44static inline void *opus_alloc (size_t size) 47static OPUS_INLINE void *opus_alloc (size_t size)
45{ 48{
46 return malloc(size); 49 return malloc(size);
47} 50}
@@ -49,7 +52,7 @@ static inline void *opus_alloc (size_t size)
49 52
50/** Same as celt_alloc(), except that the area is only needed inside a CELT call (might cause problem with wideband though) */ 53/** Same as celt_alloc(), except that the area is only needed inside a CELT call (might cause problem with wideband though) */
51#ifndef OVERRIDE_OPUS_ALLOC_SCRATCH 54#ifndef OVERRIDE_OPUS_ALLOC_SCRATCH
52static inline void *opus_alloc_scratch (size_t size) 55static OPUS_INLINE void *opus_alloc_scratch (size_t size)
53{ 56{
54 /* Scratch space doesn't need to be cleared */ 57 /* Scratch space doesn't need to be cleared */
55 return opus_alloc(size); 58 return opus_alloc(size);
@@ -58,7 +61,7 @@ static inline void *opus_alloc_scratch (size_t size)
58 61
59/** Opus wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function and opus_alloc */ 62/** Opus wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function and opus_alloc */
60#ifndef OVERRIDE_OPUS_FREE 63#ifndef OVERRIDE_OPUS_FREE
61static inline void opus_free (void *ptr) 64static OPUS_INLINE void opus_free (void *ptr)
62{ 65{
63 free(ptr); 66 free(ptr);
64} 67}
diff --git a/lib/rbcodec/codecs/libopus/celt/pitch.c b/lib/rbcodec/codecs/libopus/celt/pitch.c
index 0d8be13025..c28857297a 100644
--- a/lib/rbcodec/codecs/libopus/celt/pitch.c
+++ b/lib/rbcodec/codecs/libopus/celt/pitch.c
@@ -145,7 +145,7 @@ static void celt_fir5(const opus_val16 *x,
145 145
146 146
147void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x_lp, 147void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x_lp,
148 int len, int C) 148 int len, int C, int arch)
149{ 149{
150 int i; 150 int i;
151 opus_val32 ac[5]; 151 opus_val32 ac[5];
@@ -180,7 +180,7 @@ void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x
180 } 180 }
181 181
182 _celt_autocorr(x_lp, ac, NULL, 0, 182 _celt_autocorr(x_lp, ac, NULL, 0,
183 4, len>>1); 183 4, len>>1, arch);
184 184
185 /* Noise floor -40 dB */ 185 /* Noise floor -40 dB */
186#ifdef FIXED_POINT 186#ifdef FIXED_POINT
@@ -250,9 +250,14 @@ opus_val32
250#else 250#else
251void 251void
252#endif 252#endif
253celt_pitch_xcorr(const opus_val16 *_x, const opus_val16 *_y, opus_val32 *xcorr, int len, int max_pitch) 253celt_pitch_xcorr_c(const opus_val16 *_x, const opus_val16 *_y, opus_val32 *xcorr, int len, int max_pitch)
254{ 254{
255 int i,j; 255 int i,j;
256 /*The EDSP version requires that max_pitch is at least 1, and that _x is
257 32-bit aligned.
258 Since it's hard to put asserts in assembly, put them here.*/
259 celt_assert(max_pitch>0);
260 celt_assert((((unsigned char *)_x-(unsigned char *)NULL)&3)==0);
256#ifdef FIXED_POINT 261#ifdef FIXED_POINT
257 opus_val32 maxcorr=1; 262 opus_val32 maxcorr=1;
258#endif 263#endif
@@ -289,7 +294,7 @@ celt_pitch_xcorr(const opus_val16 *_x, const opus_val16 *_y, opus_val32 *xcorr,
289 294
290#endif 295#endif
291void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTRICT y, 296void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTRICT y,
292 int len, int max_pitch, int *pitch) 297 int len, int max_pitch, int *pitch, int arch)
293{ 298{
294 int i, j; 299 int i, j;
295 int lag; 300 int lag;
@@ -342,7 +347,7 @@ void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTR
342#ifdef FIXED_POINT 347#ifdef FIXED_POINT
343 maxcorr = 348 maxcorr =
344#endif 349#endif
345 celt_pitch_xcorr(x_lp4, y_lp4, xcorr, len>>2, max_pitch>>2); 350 celt_pitch_xcorr(x_lp4, y_lp4, xcorr, len>>2, max_pitch>>2, arch);
346 351
347 find_best_pitch(xcorr, y_lp4, len>>2, max_pitch>>2, best_pitch 352 find_best_pitch(xcorr, y_lp4, len>>2, max_pitch>>2, best_pitch
348#ifdef FIXED_POINT 353#ifdef FIXED_POINT
diff --git a/lib/rbcodec/codecs/libopus/celt/pitch.h b/lib/rbcodec/codecs/libopus/celt/pitch.h
index caffd24bc4..df317ecc1d 100644
--- a/lib/rbcodec/codecs/libopus/celt/pitch.h
+++ b/lib/rbcodec/codecs/libopus/celt/pitch.h
@@ -35,16 +35,21 @@
35#define PITCH_H 35#define PITCH_H
36 36
37#include "modes.h" 37#include "modes.h"
38#include "cpu_support.h"
38 39
39#if defined(__SSE__) && !defined(FIXED_POINT) 40#if defined(__SSE__) && !defined(FIXED_POINT)
40#include "x86/pitch_sse.h" 41#include "x86/pitch_sse.h"
41#endif 42#endif
42 43
44#if defined(OPUS_ARM_ASM) && defined(FIXED_POINT)
45# include "arm/pitch_arm.h"
46#endif
47
43void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x_lp, 48void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x_lp,
44 int len, int C); 49 int len, int C, int arch);
45 50
46void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTRICT y, 51void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTRICT y,
47 int len, int max_pitch, int *pitch); 52 int len, int max_pitch, int *pitch, int arch);
48 53
49opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, 54opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
50 int N, int *T0, int prev_period, opus_val16 prev_gain); 55 int N, int *T0, int prev_period, opus_val16 prev_gain);
@@ -52,10 +57,11 @@ opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
52/* OPT: This is the kernel you really want to optimize. It gets used a lot 57/* OPT: This is the kernel you really want to optimize. It gets used a lot
53 by the prefilter and by the PLC. */ 58 by the prefilter and by the PLC. */
54#ifndef OVERRIDE_XCORR_KERNEL 59#ifndef OVERRIDE_XCORR_KERNEL
55static inline void xcorr_kernel(const opus_val16 * x, const opus_val16 * y, opus_val32 sum[4], int len) 60static OPUS_INLINE void xcorr_kernel(const opus_val16 * x, const opus_val16 * y, opus_val32 sum[4], int len)
56{ 61{
57 int j; 62 int j;
58 opus_val16 y_0, y_1, y_2, y_3; 63 opus_val16 y_0, y_1, y_2, y_3;
64 celt_assert(len>=3);
59 y_3=0; /* gcc doesn't realize that y_3 can't be used uninitialized */ 65 y_3=0; /* gcc doesn't realize that y_3 can't be used uninitialized */
60 y_0=*y++; 66 y_0=*y++;
61 y_1=*y++; 67 y_1=*y++;
@@ -119,7 +125,7 @@ static inline void xcorr_kernel(const opus_val16 * x, const opus_val16 * y, opus
119#endif /* OVERRIDE_XCORR_KERNEL */ 125#endif /* OVERRIDE_XCORR_KERNEL */
120 126
121#ifndef OVERRIDE_DUAL_INNER_PROD 127#ifndef OVERRIDE_DUAL_INNER_PROD
122static inline void dual_inner_prod(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, 128static OPUS_INLINE void dual_inner_prod(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02,
123 int N, opus_val32 *xy1, opus_val32 *xy2) 129 int N, opus_val32 *xy1, opus_val32 *xy2)
124{ 130{
125 int i; 131 int i;
@@ -140,6 +146,28 @@ opus_val32
140#else 146#else
141void 147void
142#endif 148#endif
143celt_pitch_xcorr(const opus_val16 *_x, const opus_val16 *_y, opus_val32 *xcorr, int len, int max_pitch); 149celt_pitch_xcorr_c(const opus_val16 *_x, const opus_val16 *_y,
150 opus_val32 *xcorr, int len, int max_pitch);
151
152#if !defined(OVERRIDE_PITCH_XCORR)
153/*Is run-time CPU detection enabled on this platform?*/
154# if defined(OPUS_HAVE_RTCD)
155extern
156# if defined(FIXED_POINT)
157opus_val32
158# else
159void
160# endif
161(*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
162 const opus_val16 *, opus_val32 *, int, int);
163
164# define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \
165 ((*CELT_PITCH_XCORR_IMPL[(arch)&OPUS_ARCHMASK])(_x, _y, \
166 xcorr, len, max_pitch))
167# else
168# define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \
169 ((void)(arch),celt_pitch_xcorr_c(_x, _y, xcorr, len, max_pitch))
170# endif
171#endif
144 172
145#endif 173#endif
diff --git a/lib/rbcodec/codecs/libopus/celt/quant_bands.c b/lib/rbcodec/codecs/libopus/celt/quant_bands.c
index 79685e17cb..ac6952c266 100644
--- a/lib/rbcodec/codecs/libopus/celt/quant_bands.c
+++ b/lib/rbcodec/codecs/libopus/celt/quant_bands.c
@@ -312,6 +312,7 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
312 opus_int32 tell_intra; 312 opus_int32 tell_intra;
313 opus_uint32 nstart_bytes; 313 opus_uint32 nstart_bytes;
314 opus_uint32 nintra_bytes; 314 opus_uint32 nintra_bytes;
315 opus_uint32 save_bytes;
315 int badness2; 316 int badness2;
316 VARDECL(unsigned char, intra_bits); 317 VARDECL(unsigned char, intra_bits);
317 318
@@ -322,7 +323,10 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
322 nstart_bytes = ec_range_bytes(&enc_start_state); 323 nstart_bytes = ec_range_bytes(&enc_start_state);
323 nintra_bytes = ec_range_bytes(&enc_intra_state); 324 nintra_bytes = ec_range_bytes(&enc_intra_state);
324 intra_buf = ec_get_buffer(&enc_intra_state) + nstart_bytes; 325 intra_buf = ec_get_buffer(&enc_intra_state) + nstart_bytes;
325 ALLOC(intra_bits, nintra_bytes-nstart_bytes, unsigned char); 326 save_bytes = nintra_bytes-nstart_bytes;
327 if (save_bytes == 0)
328 save_bytes = ALLOC_NONE;
329 ALLOC(intra_bits, save_bytes, unsigned char);
326 /* Copy bits from intra bit-stream */ 330 /* Copy bits from intra bit-stream */
327 OPUS_COPY(intra_bits, intra_buf, nintra_bytes - nstart_bytes); 331 OPUS_COPY(intra_bits, intra_buf, nintra_bytes - nstart_bytes);
328 332
diff --git a/lib/rbcodec/codecs/libopus/celt/rate.c b/lib/rbcodec/codecs/libopus/celt/rate.c
index e474cf5004..e13d839d63 100644
--- a/lib/rbcodec/codecs/libopus/celt/rate.c
+++ b/lib/rbcodec/codecs/libopus/celt/rate.c
@@ -245,7 +245,7 @@ void compute_pulse_cache(CELTMode *m, int LM)
245 245
246#define ALLOC_STEPS 6 246#define ALLOC_STEPS 6
247 247
248static inline int interp_bits2pulses(const CELTMode *m, int start, int end, int skip_start, 248static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, int skip_start,
249 const int *bits1, const int *bits2, const int *thresh, const int *cap, opus_int32 total, opus_int32 *_balance, 249 const int *bits1, const int *bits2, const int *thresh, const int *cap, opus_int32 total, opus_int32 *_balance,
250 int skip_rsv, int *intensity, int intensity_rsv, int *dual_stereo, int dual_stereo_rsv, int *bits, 250 int skip_rsv, int *intensity, int intensity_rsv, int *dual_stereo, int dual_stereo_rsv, int *bits,
251 int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev, int signalBandwidth) 251 int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev, int signalBandwidth)
diff --git a/lib/rbcodec/codecs/libopus/celt/rate.h b/lib/rbcodec/codecs/libopus/celt/rate.h
index 263fde9820..f1e0661129 100644
--- a/lib/rbcodec/codecs/libopus/celt/rate.h
+++ b/lib/rbcodec/codecs/libopus/celt/rate.h
@@ -45,12 +45,12 @@
45 45
46void compute_pulse_cache(CELTMode *m, int LM); 46void compute_pulse_cache(CELTMode *m, int LM);
47 47
48static inline int get_pulses(int i) 48static OPUS_INLINE int get_pulses(int i)
49{ 49{
50 return i<8 ? i : (8 + (i&7)) << ((i>>3)-1); 50 return i<8 ? i : (8 + (i&7)) << ((i>>3)-1);
51} 51}
52 52
53static inline int bits2pulses(const CELTMode *m, int band, int LM, int bits) 53static OPUS_INLINE int bits2pulses(const CELTMode *m, int band, int LM, int bits)
54{ 54{
55 int i; 55 int i;
56 int lo, hi; 56 int lo, hi;
@@ -77,7 +77,7 @@ static inline int bits2pulses(const CELTMode *m, int band, int LM, int bits)
77 return hi; 77 return hi;
78} 78}
79 79
80static inline int pulses2bits(const CELTMode *m, int band, int LM, int pulses) 80static OPUS_INLINE int pulses2bits(const CELTMode *m, int band, int LM, int pulses)
81{ 81{
82 const unsigned char *cache; 82 const unsigned char *cache;
83 83
diff --git a/lib/rbcodec/codecs/libopus/celt/stack_alloc.h b/lib/rbcodec/codecs/libopus/celt/stack_alloc.h
index 1c093a8cdc..316a6ce12c 100644
--- a/lib/rbcodec/codecs/libopus/celt/stack_alloc.h
+++ b/lib/rbcodec/codecs/libopus/celt/stack_alloc.h
@@ -32,6 +32,9 @@
32#ifndef STACK_ALLOC_H 32#ifndef STACK_ALLOC_H
33#define STACK_ALLOC_H 33#define STACK_ALLOC_H
34 34
35#include "opus_types.h"
36#include "opus_defines.h"
37
35#if (!defined (VAR_ARRAYS) && !defined (USE_ALLOCA) && !defined (NONTHREADSAFE_PSEUDOSTACK)) 38#if (!defined (VAR_ARRAYS) && !defined (USE_ALLOCA) && !defined (NONTHREADSAFE_PSEUDOSTACK))
36#error "Opus requires one of VAR_ARRAYS, USE_ALLOCA, or NONTHREADSAFE_PSEUDOSTACK be defined to select the temporary allocation mode." 39#error "Opus requires one of VAR_ARRAYS, USE_ALLOCA, or NONTHREADSAFE_PSEUDOSTACK be defined to select the temporary allocation mode."
37#endif 40#endif
@@ -92,6 +95,8 @@
92#define SAVE_STACK 95#define SAVE_STACK
93#define RESTORE_STACK 96#define RESTORE_STACK
94#define ALLOC_STACK 97#define ALLOC_STACK
98/* C99 does not allow VLAs of size zero */
99#define ALLOC_NONE 1
95 100
96#elif defined(USE_ALLOCA) 101#elif defined(USE_ALLOCA)
97 102
@@ -106,6 +111,7 @@
106#define SAVE_STACK 111#define SAVE_STACK
107#define RESTORE_STACK 112#define RESTORE_STACK
108#define ALLOC_STACK 113#define ALLOC_STACK
114#define ALLOC_NONE 0
109 115
110#else 116#else
111 117
@@ -143,6 +149,7 @@ extern char *global_stack_top;
143#define VARDECL(type, var) type *var 149#define VARDECL(type, var) type *var
144#define ALLOC(var, size, type) var = PUSH(global_stack, size, type) 150#define ALLOC(var, size, type) var = PUSH(global_stack, size, type)
145#define SAVE_STACK char *_saved_stack = global_stack; 151#define SAVE_STACK char *_saved_stack = global_stack;
152#define ALLOC_NONE 0
146 153
147#endif /* VAR_ARRAYS */ 154#endif /* VAR_ARRAYS */
148 155
@@ -159,7 +166,7 @@ extern char *global_stack_top;
159 166
160#else 167#else
161 168
162static inline int _opus_false(void) {return 0;} 169static OPUS_INLINE int _opus_false(void) {return 0;}
163#define OPUS_CHECK_ARRAY(ptr, len) _opus_false() 170#define OPUS_CHECK_ARRAY(ptr, len) _opus_false()
164#define OPUS_CHECK_VALUE(value) _opus_false() 171#define OPUS_CHECK_VALUE(value) _opus_false()
165#define OPUS_PRINT_INT(value) do{}while(0) 172#define OPUS_PRINT_INT(value) do{}while(0)