diff options
Diffstat (limited to 'lib/rbcodec/codecs/libopus/opus.c')
-rw-r--r-- | lib/rbcodec/codecs/libopus/opus.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/rbcodec/codecs/libopus/opus.c b/lib/rbcodec/codecs/libopus/opus.c index 0526f8b414..538b5ea74e 100644 --- a/lib/rbcodec/codecs/libopus/opus.c +++ b/lib/rbcodec/codecs/libopus/opus.c | |||
@@ -104,6 +104,10 @@ OPUS_EXPORT void opus_pcm_soft_clip(float *_x, int N, int C, float *declip_mem) | |||
104 | 104 | ||
105 | /* Compute a such that maxval + a*maxval^2 = 1 */ | 105 | /* Compute a such that maxval + a*maxval^2 = 1 */ |
106 | a=(maxval-1)/(maxval*maxval); | 106 | a=(maxval-1)/(maxval*maxval); |
107 | /* Slightly boost "a" by 2^-22. This is just enough to ensure -ffast-math | ||
108 | does not cause output values larger than +/-1, but small enough not | ||
109 | to matter even for 24-bit output. */ | ||
110 | a += a*2.4e-7f; | ||
107 | if (x[i*C]>0) | 111 | if (x[i*C]>0) |
108 | a = -a; | 112 | a = -a; |
109 | /* Apply soft clipping */ | 113 | /* Apply soft clipping */ |
@@ -133,7 +137,6 @@ OPUS_EXPORT void opus_pcm_soft_clip(float *_x, int N, int C, float *declip_mem) | |||
133 | } | 137 | } |
134 | #endif | 138 | #endif |
135 | 139 | ||
136 | #if 0 | ||
137 | int encode_size(int size, unsigned char *data) | 140 | int encode_size(int size, unsigned char *data) |
138 | { | 141 | { |
139 | if (size < 252) | 142 | if (size < 252) |
@@ -146,7 +149,6 @@ int encode_size(int size, unsigned char *data) | |||
146 | return 2; | 149 | return 2; |
147 | } | 150 | } |
148 | } | 151 | } |
149 | #endif | ||
150 | 152 | ||
151 | static int parse_size(const unsigned char *data, opus_int32 len, opus_int16 *size) | 153 | static int parse_size(const unsigned char *data, opus_int32 len, opus_int16 *size) |
152 | { | 154 | { |
@@ -203,8 +205,10 @@ int opus_packet_parse_impl(const unsigned char *data, opus_int32 len, | |||
203 | opus_int32 pad = 0; | 205 | opus_int32 pad = 0; |
204 | const unsigned char *data0 = data; | 206 | const unsigned char *data0 = data; |
205 | 207 | ||
206 | if (size==NULL) | 208 | if (size==NULL || len<0) |
207 | return OPUS_BAD_ARG; | 209 | return OPUS_BAD_ARG; |
210 | if (len==0) | ||
211 | return OPUS_INVALID_PACKET; | ||
208 | 212 | ||
209 | framesize = opus_packet_get_samples_per_frame(data, 48000); | 213 | framesize = opus_packet_get_samples_per_frame(data, 48000); |
210 | 214 | ||
@@ -248,7 +252,7 @@ int opus_packet_parse_impl(const unsigned char *data, opus_int32 len, | |||
248 | /* Number of frames encoded in bits 0 to 5 */ | 252 | /* Number of frames encoded in bits 0 to 5 */ |
249 | ch = *data++; | 253 | ch = *data++; |
250 | count = ch&0x3F; | 254 | count = ch&0x3F; |
251 | if (count <= 0 || framesize*count > 5760) | 255 | if (count <= 0 || framesize*(opus_int32)count > 5760) |
252 | return OPUS_INVALID_PACKET; | 256 | return OPUS_INVALID_PACKET; |
253 | len--; | 257 | len--; |
254 | /* Padding flag is bit 6 */ | 258 | /* Padding flag is bit 6 */ |
@@ -342,7 +346,6 @@ int opus_packet_parse_impl(const unsigned char *data, opus_int32 len, | |||
342 | return count; | 346 | return count; |
343 | } | 347 | } |
344 | 348 | ||
345 | #if 0 | ||
346 | int opus_packet_parse(const unsigned char *data, opus_int32 len, | 349 | int opus_packet_parse(const unsigned char *data, opus_int32 len, |
347 | unsigned char *out_toc, const unsigned char *frames[48], | 350 | unsigned char *out_toc, const unsigned char *frames[48], |
348 | opus_int16 size[48], int *payload_offset) | 351 | opus_int16 size[48], int *payload_offset) |
@@ -350,5 +353,4 @@ int opus_packet_parse(const unsigned char *data, opus_int32 len, | |||
350 | return opus_packet_parse_impl(data, len, 0, out_toc, | 353 | return opus_packet_parse_impl(data, len, 0, out_toc, |
351 | frames, size, payload_offset, NULL); | 354 | frames, size, payload_offset, NULL); |
352 | } | 355 | } |
353 | #endif | ||
354 | 356 | ||