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/rate.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/rate.c')
-rw-r--r-- | lib/rbcodec/codecs/libopus/celt/rate.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/rate.c b/lib/rbcodec/codecs/libopus/celt/rate.c index f85c3ee63c..465e1ba26c 100644 --- a/lib/rbcodec/codecs/libopus/celt/rate.c +++ b/lib/rbcodec/codecs/libopus/celt/rate.c | |||
@@ -131,7 +131,7 @@ void compute_pulse_cache(CELTMode *m, int LM) | |||
131 | for (i=0;i<nbEntries;i++) | 131 | for (i=0;i<nbEntries;i++) |
132 | { | 132 | { |
133 | unsigned char *ptr = bits+entryI[i]; | 133 | unsigned char *ptr = bits+entryI[i]; |
134 | opus_int16 tmp[MAX_PULSES+1]; | 134 | opus_int16 tmp[CELT_MAX_PULSES+1]; |
135 | get_required_bits(tmp, entryN[i], get_pulses(entryK[i]), BITRES); | 135 | get_required_bits(tmp, entryN[i], get_pulses(entryK[i]), BITRES); |
136 | for (j=1;j<=entryK[i];j++) | 136 | for (j=1;j<=entryK[i];j++) |
137 | ptr[j] = tmp[get_pulses(j)]-1; | 137 | ptr[j] = tmp[get_pulses(j)]-1; |
@@ -296,7 +296,7 @@ static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, | |||
296 | done = 0; | 296 | done = 0; |
297 | for (j=end;j-->start;) | 297 | for (j=end;j-->start;) |
298 | { | 298 | { |
299 | int tmp = bits1[j] + (lo*bits2[j]>>ALLOC_STEPS); | 299 | int tmp = bits1[j] + ((opus_int32)lo*bits2[j]>>ALLOC_STEPS); |
300 | if (tmp < thresh[j] && !done) | 300 | if (tmp < thresh[j] && !done) |
301 | { | 301 | { |
302 | if (tmp >= alloc_floor) | 302 | if (tmp >= alloc_floor) |
@@ -348,12 +348,17 @@ static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, | |||
348 | /*This if() block is the only part of the allocation function that | 348 | /*This if() block is the only part of the allocation function that |
349 | is not a mandatory part of the bitstream: any bands we choose to | 349 | is not a mandatory part of the bitstream: any bands we choose to |
350 | skip here must be explicitly signaled.*/ | 350 | skip here must be explicitly signaled.*/ |
351 | /*Choose a threshold with some hysteresis to keep bands from | 351 | int depth_threshold; |
352 | fluctuating in and out.*/ | 352 | /*We choose a threshold with some hysteresis to keep bands from |
353 | fluctuating in and out, but we try not to fold below a certain point. */ | ||
354 | if (codedBands > 17) | ||
355 | depth_threshold = j<prev ? 7 : 9; | ||
356 | else | ||
357 | depth_threshold = 0; | ||
353 | #ifdef FUZZING | 358 | #ifdef FUZZING |
354 | if ((rand()&0x1) == 0) | 359 | if ((rand()&0x1) == 0) |
355 | #else | 360 | #else |
356 | if (codedBands<=start+2 || (band_bits > ((j<prev?7:9)*band_width<<LM<<BITRES)>>4 && j<=signalBandwidth)) | 361 | if (codedBands<=start+2 || (band_bits > (depth_threshold*band_width<<LM<<BITRES)>>4 && j<=signalBandwidth)) |
357 | #endif | 362 | #endif |
358 | { | 363 | { |
359 | ec_enc_bit_logp(ec, 1, 1); | 364 | ec_enc_bit_logp(ec, 1, 1); |
@@ -524,7 +529,7 @@ static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, | |||
524 | return codedBands; | 529 | return codedBands; |
525 | } | 530 | } |
526 | 531 | ||
527 | int compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, int *intensity, int *dual_stereo, | 532 | int clt_compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, int *intensity, int *dual_stereo, |
528 | opus_int32 total, opus_int32 *balance, int *pulses, int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev, int signalBandwidth) | 533 | opus_int32 total, opus_int32 *balance, int *pulses, int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev, int signalBandwidth) |
529 | { | 534 | { |
530 | int lo, hi, len, j; | 535 | int lo, hi, len, j; |