summaryrefslogtreecommitdiffstats
path: root/libAACenc/src/intensity.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2013-03-18 16:23:17 +0200
committerMartin Storsjo <martin@martin.st>2013-03-18 16:28:50 +0200
commit226601a8d9bce81455e161a0e26051d2f22c5d7a (patch)
treebd3eb8e41203ccde93c3b5e1db3a4f8d0d2017ce /libAACenc/src/intensity.cpp
parentbae4553d428accc6438102578ffd9e7968333b94 (diff)
downloadfdk-aac-226601a8d9bce81455e161a0e26051d2f22c5d7a.tar.gz
fdk-aac-226601a8d9bce81455e161a0e26051d2f22c5d7a.tar.bz2
fdk-aac-226601a8d9bce81455e161a0e26051d2f22c5d7a.zip
Avoid too big changes in isScale
These values are delta encoded, but only steps [-60,60] are possible to encode. If the difference between two values are bigger than that, we end up with a sequence we are unable to encode. This fixes crashes on certain stereo samples at higher bitrates.
Diffstat (limited to 'libAACenc/src/intensity.cpp')
-rw-r--r--libAACenc/src/intensity.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/libAACenc/src/intensity.cpp b/libAACenc/src/intensity.cpp
index 514c8e0..632620a 100644
--- a/libAACenc/src/intensity.cpp
+++ b/libAACenc/src/intensity.cpp
@@ -584,6 +584,7 @@ void FDKaacEnc_IntensityStereoProcessing(
FIXP_DBL realIsScale[MAX_GROUPED_SFB];
INTENSITY_PARAMETERS isParams;
INT isMask[MAX_GROUPED_SFB];
+ INT lastValIs = 0, delta;
FDKmemclear((void*)isBook,sfbCnt*sizeof(INT));
FDKmemclear((void*)isMask,sfbCnt*sizeof(INT));
@@ -739,6 +740,14 @@ void FDKaacEnc_IntensityStereoProcessing(
isScale[sfb+sfboffs] = (INT)(((realIsScale[sfb+sfboffs]>>1)+FL2FXCONST_DBL(0.5f/(1<<(REAL_SCALE_SF+LD_DATA_SHIFT+1))))>>(DFRACT_BITS-1-REAL_SCALE_SF-LD_DATA_SHIFT-1));
}
+ delta = isScale[sfb+sfboffs] - lastValIs;
+ if (delta < -CODE_BOOK_SCF_LAV) {
+ isScale[sfb+sfboffs] = lastValIs - CODE_BOOK_SCF_LAV;
+ } else if (delta + CODE_BOOK_SCF_LAV >= (INT)(sizeof(FDKaacEnc_huff_ltabscf)/sizeof(FDKaacEnc_huff_ltabscf[0]))) {
+ isScale[sfb+sfboffs] = lastValIs + sizeof(FDKaacEnc_huff_ltabscf)/sizeof(FDKaacEnc_huff_ltabscf[0]) - CODE_BOOK_SCF_LAV - 1;
+ }
+ lastValIs = isScale[sfb+sfboffs];
+
sfbEnergyRight[sfb+sfboffs] = FL2FXCONST_DBL(0.0f);
sfbEnergyLdDataRight[sfb+sfboffs] = FL2FXCONST_DBL(-1.0f);
sfbThresholdRight[sfb+sfboffs] = FL2FXCONST_DBL(0.0f);