Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: celt/bands.c

Issue 107243004: Updating Opus to release 1.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/opus
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « celt/arm/pitch_arm.h ('k') | celt/celt.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: celt/bands.c
diff --git a/celt/bands.c b/celt/bands.c
index 93bd0bc7220a86ed86f174fe02e5c2698d380df2..cce56e2f6ebe5978fbdae8bff75a74da3f1c7ba8 100644
--- a/celt/bands.c
+++ b/celt/bands.c
@@ -214,7 +214,9 @@ void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X,
j=M*eBands[i];
band_end = M*eBands[i+1];
lg = ADD16(bandLogE[i+c*m->nbEBands], SHL16((opus_val16)eMeans[i],6));
-#ifdef FIXED_POINT
+#ifndef FIXED_POINT
+ g = celt_exp2(lg);
+#else
/* Handle the integer part of the log energy */
shift = 16-(lg>>DB_SHIFT);
if (shift>31)
@@ -225,9 +227,23 @@ void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X,
/* Handle the fractional part. */
g = celt_exp2_frac(lg&((1<<DB_SHIFT)-1));
}
-#else
- g = celt_exp2(lg);
+ /* Handle extreme gains with negative shift. */
+ if (shift<0)
+ {
+ /* For shift < -2 we'd be likely to overflow, so we're capping
+ the gain here. This shouldn't happen unless the bitstream is
+ already corrupted. */
+ if (shift < -2)
+ {
+ g = 32767;
+ shift = -2;
+ }
+ do {
+ *f++ = SHL32(MULT16_16(*x++, g), -shift);
+ } while (++j<band_end);
+ } else
#endif
+ /* Be careful of the fixed-point "else" just above when changing this code */
do {
*f++ = SHR32(MULT16_16(*x++, g), shift);
} while (++j<band_end);
@@ -492,7 +508,7 @@ int spreading_decision(const CELTMode *m, celt_norm *X, int *average,
*tapset_decision=0;
}
/*printf("%d %d %d\n", hf_sum, *hf_average, *tapset_decision);*/
- celt_assert(nbBands>0); /*M*(eBands[end]-eBands[end-1]) <= 8 assures this*/
+ celt_assert(nbBands>0); /* end has to be non-zero */
sum /= nbBands;
/* Recursive averaging */
sum = (sum+*average)>>1;
@@ -869,7 +885,6 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X,
int q;
int curr_bits;
int imid=0, iside=0;
- int N_B=N;
int B0=B;
opus_val16 mid=0, side=0;
unsigned cm=0;
@@ -891,8 +906,6 @@ static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X,
spread = ctx->spread;
ec = ctx->ec;
- N_B /= B;
-
/* If we need 1.5 more bit than we can produce, split the band in two. */
cache = m->cache.bits + m->cache.index[(LM+1)*m->nbEBands+i];
if (LM != -1 && b > cache[cache[0]]+12 && N>2)
@@ -1072,7 +1085,6 @@ static unsigned quant_band(struct band_ctx *ctx, celt_norm *X,
longBlocks = B0==1;
N_B /= B;
- N_B0 = N_B;
/* Special case for one sample */
if (N==1)
« no previous file with comments | « celt/arm/pitch_arm.h ('k') | celt/celt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698