summaryrefslogtreecommitdiffstats
path: root/libSBRenc/src/nf_est.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2013-11-01 10:46:40 +0200
committerMartin Storsjo <martin@martin.st>2013-11-01 10:46:40 +0200
commit321233ee92e138f44294c7bb9a375eadad9d24fa (patch)
tree1de928ad26325302f64c56603157f50095dcf2b1 /libSBRenc/src/nf_est.cpp
parentfcb5f1b692cb8343de35e69f9084328c652cf690 (diff)
parentfa3eba16446cc8f2f5e2dfc20d86a49dbd37299e (diff)
downloadfdk-aac-dabplus-321233ee92e138f44294c7bb9a375eadad9d24fa.tar.gz
fdk-aac-dabplus-321233ee92e138f44294c7bb9a375eadad9d24fa.tar.bz2
fdk-aac-dabplus-321233ee92e138f44294c7bb9a375eadad9d24fa.zip
Merge remote-tracking branch 'aosp/kitkat-release' into kitkat-merge
Conflicts: libAACenc/src/quantize.cpp
Diffstat (limited to 'libSBRenc/src/nf_est.cpp')
-rw-r--r--libSBRenc/src/nf_est.cpp36
1 files changed, 22 insertions, 14 deletions
diff --git a/libSBRenc/src/nf_est.cpp b/libSBRenc/src/nf_est.cpp
index 62bcc79..7a3c022 100644
--- a/libSBRenc/src/nf_est.cpp
+++ b/libSBRenc/src/nf_est.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -102,7 +102,7 @@ static const FIXP_DBL QuantOffset = (INT)0xfc000000; /* ld64(0.25) */
#define max(a,b) ( a > b ? a:b)
#endif
-#define NOISE_FLOOR_OFFSET_SCALING (3)
+#define NOISE_FLOOR_OFFSET_SCALING (4)
@@ -484,11 +484,13 @@ FDKsbrEnc_InitSbrNoiseFloorEstimate (HANDLE_SBR_NOISE_FLOOR_ESTIMATE h_sbrNoise
tmp = ((FIXP_DBL)MAXVAL_DBL)>>NOISE_FLOOR_OFFSET_SCALING;
}
else {
- FDK_ASSERT(noiseFloorOffset<=8); /* because of NOISE_FLOOR_OFFSET_SCALING */
+ /* noiseFloorOffset has to be smaller than 12, because
+ the result of the calculation below must be smaller than 1:
+ (2^(noiseFloorOffset/3))*2^4<1 */
+ FDK_ASSERT(noiseFloorOffset<12);
- /* Assumes the noise floor offset in tuning table are in q31 */
- /* Currently the table contains only 0 for noise floor offset */
- /* Change the qformat here when non-zero values would be filled */
+ /* Assumes the noise floor offset in tuning table are in q31 */
+ /* Change the qformat here when non-zero values would be filled */
exp = fDivNorm((FIXP_DBL)noiseFloorOffset, 3, &qexp);
tmp = fPow(2, DFRACT_BITS-1, exp, qexp, &qtmp);
tmp = scaleValue(tmp, qtmp-NOISE_FLOOR_OFFSET_SCALING);
@@ -527,24 +529,30 @@ FDKsbrEnc_resetSbrNoiseFloorEstimate (HANDLE_SBR_NOISE_FLOOR_ESTIMATE h_sbrNoise
h_sbrNoiseFloorEstimate->noNoiseBands = 1;
}
else{
- /*
- * Calculate number of noise bands 1,2 or 3 bands/octave
+ /*
+ * Calculate number of noise bands 1,2 or 3 bands/octave
********************************************************/
FIXP_DBL tmp, ratio, lg2;
- INT ratio_e, qlg2;
+ INT ratio_e, qlg2, nNoiseBands;
ratio = fDivNorm(k2, kx, &ratio_e);
lg2 = fLog2(ratio, ratio_e, &qlg2);
tmp = fMult((FIXP_DBL)(h_sbrNoiseFloorEstimate->noiseBands<<24), lg2);
tmp = scaleValue(tmp, qlg2-23);
- h_sbrNoiseFloorEstimate->noNoiseBands = (INT)((tmp + (FIXP_DBL)1) >> 1);
+ nNoiseBands = (INT)((tmp + (FIXP_DBL)1) >> 1);
+
+
+ if (nNoiseBands > MAX_NUM_NOISE_COEFFS ) {
+ nNoiseBands = MAX_NUM_NOISE_COEFFS;
+ }
+
+ if( nNoiseBands == 0 ) {
+ nNoiseBands = 1;
+ }
- if (h_sbrNoiseFloorEstimate->noNoiseBands > MAX_NUM_NOISE_COEFFS)
- h_sbrNoiseFloorEstimate->noNoiseBands = MAX_NUM_NOISE_COEFFS;
+ h_sbrNoiseFloorEstimate->noNoiseBands = nNoiseBands;
- if( h_sbrNoiseFloorEstimate->noNoiseBands==0)
- h_sbrNoiseFloorEstimate->noNoiseBands=1;
}