summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2012-02-19 21:46:24 +0200
committerMartin Storsjo <martin@martin.st>2012-02-19 21:47:54 +0200
commitdcdfc1ad27cb64bcb51a864b020b846ba22ce2a7 (patch)
tree79772e6a3714586e3931f1702fe29494ae964cb4 /media
parent01e29ede19cd7d85bfef38896de8e71e569cd211 (diff)
downloadframeworks_av-dcdfc1ad27cb64bcb51a864b020b846ba22ce2a7.zip
frameworks_av-dcdfc1ad27cb64bcb51a864b020b846ba22ce2a7.tar.gz
frameworks_av-dcdfc1ad27cb64bcb51a864b020b846ba22ce2a7.tar.bz2
stagefright aacenc: Avoid overflows when calculating normFactor
normFactor is calculated using the saturating L_add function, but if the value added (*psfbPeFactors) is negative, the sum can end up negative. *psfbPeFactors can end up negative if redThrExp is less than *psfbNActiveLines. In cases where *psfbPeFactors ended up negative, normFactor became INT_MIN, causing division by zero later. Change-Id: I00c852e457b22f7eef4d6ed1887629828057206b
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/codecs/aacenc/src/adj_thr.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/media/libstagefright/codecs/aacenc/src/adj_thr.c b/media/libstagefright/codecs/aacenc/src/adj_thr.c
index 54fb19d..3e058c1 100644
--- a/media/libstagefright/codecs/aacenc/src/adj_thr.c
+++ b/media/libstagefright/codecs/aacenc/src/adj_thr.c
@@ -437,7 +437,7 @@ static void correctThresh(PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS],
for (sfb=0; sfb<psyOutChan->maxSfbPerGroup; sfb++) {
Word32 redThrExp = thrExp[ch][sfbGrp+sfb] + redVal;
- if (((*pahFlag < AH_ACTIVE) || (deltaPe > 0)) && (redThrExp > 0) ) {
+ if (((*pahFlag < AH_ACTIVE) || (deltaPe > 0)) && (redThrExp > 0) && (redThrExp >= *psfbNActiveLines)) {
*psfbPeFactors = (*psfbNActiveLines) * (0x7fffffff / redThrExp);
normFactor = L_add(normFactor, *psfbPeFactors);